This is an automated email from the ASF dual-hosted git repository. joemcdonnell pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/impala.git
commit f54b3c37577cabad396c3eee7d18a1a6e4eea9f1 Author: Joe McDonnell <[email protected]> AuthorDate: Fri Oct 28 19:54:56 2022 -0700 IMPALA-11713: Switch to C++17 This switches from C++14 to C++17, which allows Impala code to interact with libraries written in C++17. This fixes a few minor compilation differences, such as the need for comparators to be const. Since C++17 includes -faligned-new, this removes the CMake code that specified it. Testing: - Ran core job Change-Id: Iadac41817fe5eaaa469a5f0e9f94056a409c14b9 Reviewed-on: http://gerrit.cloudera.org:8080/19183 Reviewed-by: Impala Public Jenkins <[email protected]> Tested-by: Impala Public Jenkins <[email protected]> --- be/CMakeLists.txt | 14 ++------------ be/src/exec/file-metadata-utils.cc | 4 ++-- be/src/gutil/endian.h | 2 +- be/src/runtime/krpc-data-stream-mgr.h | 2 +- be/src/service/impala-server.h | 2 +- be/src/udf_samples/CMakeLists.txt | 2 +- 6 files changed, 8 insertions(+), 18 deletions(-) diff --git a/be/CMakeLists.txt b/be/CMakeLists.txt index 72022fd1f..b19423d90 100644 --- a/be/CMakeLists.txt +++ b/be/CMakeLists.txt @@ -45,7 +45,7 @@ endif() SET(CXX_COMMON_FLAGS "${CXX_COMMON_FLAGS} -Wall -Wno-sign-compare -Wno-unknown-pragmas -pthread") SET(CXX_COMMON_FLAGS "${CXX_COMMON_FLAGS} -fno-strict-aliasing -fno-omit-frame-pointer") SET(CXX_COMMON_FLAGS "${CXX_COMMON_FLAGS} -fsigned-char") -SET(CXX_COMMON_FLAGS "${CXX_COMMON_FLAGS} -std=c++14") +SET(CXX_COMMON_FLAGS "${CXX_COMMON_FLAGS} -std=c++17") SET(CXX_COMMON_FLAGS "${CXX_COMMON_FLAGS} -Wno-deprecated -Wno-vla") SET(CXX_COMMON_FLAGS "${CXX_COMMON_FLAGS} -DBOOST_DATE_TIME_POSIX_TIME_STD_CONFIG") SET(CXX_COMMON_FLAGS "${CXX_COMMON_FLAGS} -DBOOST_SYSTEM_NO_DEPRECATED") @@ -117,16 +117,6 @@ SET(CXX_GCC_FLAGS "-g -Wno-unused-local-typedefs -gdwarf-4 -Wno-maybe-uninitiali # are not clean yet (including some LLVM code). # TODO: These should be cleaned up and reenabled. SET(CXX_GCC_FLAGS "${CXX_GCC_FLAGS} -Wno-class-memaccess -Wno-init-list-lifetime") -if (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 7.0) - # We need to add additional arguments for GCC 7+. We go down this branch if building - # with a non-GCC compiler of version 7+, but in that case CXX_GCC_FLAGS is not used, - # so it is inconsequential. TODO: IMPALA-5490: make this non-conditional when we - # upgrade GCC. - # -faligned-new: new will automatically align types. Otherwise "new Counter()" in the - # Kudu util code produces a warning (see KUDU-2094). - # TODO: -faligned-new is part of C++17, remove flag when we bump language version. - SET(CXX_GCC_FLAGS "${CXX_GCC_FLAGS} -faligned-new") -endif() # compiler flags for different build types (run 'cmake -DCMAKE_BUILD_TYPE=<type> .') # For CMAKE_BUILD_TYPE=DEBUG_NOOPT @@ -302,7 +292,7 @@ add_definitions(-DKUDU_HEADERS_USE_RICH_SLICE -DKUDU_HEADERS_NO_STUBS) # -Wno-return-type-c-linkage: UDFs return C++ classes but use C linkage to prevent # mangling # -DBOOST_NO_EXCEPTIONS: call a custom error handler for exceptions in codegen'd code. -set(CLANG_IR_CXX_FLAGS "-emit-llvm" "-c" "-std=c++14" "-DIR_COMPILE" "-DHAVE_INTTYPES_H" +set(CLANG_IR_CXX_FLAGS "-emit-llvm" "-c" "-std=c++17" "-DIR_COMPILE" "-DHAVE_INTTYPES_H" "-DHAVE_NETINET_IN_H" "-DBOOST_DATE_TIME_POSIX_TIME_STD_CONFIG" "-DBOOST_NO_EXCEPTIONS" "-DBOOST_BIND_GLOBAL_PLACEHOLDERS" "-DBOOST_ALLOW_DEPRECATED_HEADERS" "-DKUDU_HEADERS_NO_STUBS" "-fcolor-diagnostics" "-Wno-deprecated" diff --git a/be/src/exec/file-metadata-utils.cc b/be/src/exec/file-metadata-utils.cc index b48b3605e..af575c8f0 100644 --- a/be/src/exec/file-metadata-utils.cc +++ b/be/src/exec/file-metadata-utils.cc @@ -96,7 +96,7 @@ void FileMetadataUtils::AddIcebergColumns(MemPool* mem_pool, Tuple** template_tu const ColumnDescriptor& col_desc = scan_node_->hdfs_table()->col_descs()[path.front()]; int field_id = col_desc.field_id(); - for (int i = 0; i < transforms->Length(); ++i) { + for (int i = 0; i < transforms->size(); ++i) { auto transform = transforms->Get(i); if (transform->transform_type() != FbIcebergTransformType::FbIcebergTransformType_IDENTITY) { @@ -161,7 +161,7 @@ bool FileMetadataUtils::IsValuePartitionCol(const SlotDescriptor* slot_desc) { const FbIcebergMetadata* ice_metadata = file_metadata->iceberg_metadata(); auto transforms = ice_metadata->partition_keys(); if (transforms == nullptr) return false; - for (int i = 0; i < transforms->Length(); ++i) { + for (int i = 0; i < transforms->size(); ++i) { auto transform = transforms->Get(i); if (transform->source_id() == field_id && transform->transform_type() == diff --git a/be/src/gutil/endian.h b/be/src/gutil/endian.h index 8cd0f1809..98fd318de 100644 --- a/be/src/gutil/endian.h +++ b/be/src/gutil/endian.h @@ -42,7 +42,7 @@ inline uint64 gbswap_64(uint64 host_int) { if (__builtin_constant_p(host_int)) { return __bswap_constant_64(host_int); } else { - register uint64 result; + uint64 result; __asm__("bswap %0" : "=r" (result) : "0" (host_int)); return result; } diff --git a/be/src/runtime/krpc-data-stream-mgr.h b/be/src/runtime/krpc-data-stream-mgr.h index 48a814497..8347c5b3b 100644 --- a/be/src/runtime/krpc-data-stream-mgr.h +++ b/be/src/runtime/krpc-data-stream-mgr.h @@ -358,7 +358,7 @@ class KrpcDataStreamMgr : public CacheLineAligned { /// the fragment instance ID is the query ID with the lower bits set to the /// index of the fragment instance within the query. struct ComparisonOp { - bool operator()(const RecvrId& a, const RecvrId& b) { + bool operator()(const RecvrId& a, const RecvrId& b) const { if (a.first.hi < b.first.hi) { return true; } else if (a.first.hi > b.first.hi) { diff --git a/be/src/service/impala-server.h b/be/src/service/impala-server.h index 37f41546b..a6cb34182 100644 --- a/be/src/service/impala-server.h +++ b/be/src/service/impala-server.h @@ -1568,7 +1568,7 @@ class ImpalaServer : public ImpalaServiceIf, /// Comparator that breaks ties when two queries have identical expiration deadlines. struct ExpirationEventComparator { - bool operator()(const ExpirationEvent& t1, const ExpirationEvent& t2) { + bool operator()(const ExpirationEvent& t1, const ExpirationEvent& t2) const { if (t1.deadline < t2.deadline) return true; if (t2.deadline < t1.deadline) return false; if (t1.query_id < t2.query_id) return true; diff --git a/be/src/udf_samples/CMakeLists.txt b/be/src/udf_samples/CMakeLists.txt index e4aaf8d26..75048a1a9 100644 --- a/be/src/udf_samples/CMakeLists.txt +++ b/be/src/udf_samples/CMakeLists.txt @@ -28,7 +28,7 @@ separate_arguments(HIDE_SYMBOLS_ARGS) # This should be called with the .cc src file and it will generate a # src-file-ir target that can be built. # e.g. COMPILE_TO_IR(test.cc) generates the "test-ir" make target. -set(IR_COMPILE_FLAGS "-emit-llvm" "-O3" "-std=c++14" "-c" "-I../" ${HIDE_SYMBOLS_ARGS}) +set(IR_COMPILE_FLAGS "-emit-llvm" "-O3" "-std=c++17" "-c" "-I../" ${HIDE_SYMBOLS_ARGS}) set(IR_COMPILE_FLAGS ${IR_COMPILE_FLAGS} ${CLANG_BASE_FLAGS}) function(COMPILE_TO_IR SRC_FILE) get_filename_component(BASE_NAME ${SRC_FILE} NAME_WE)
