From 3c8e751648dae3f2f68df71db8640f5baa708105 Mon Sep 17 00:00:00 2001 From: Przemyslaw Skibinski Date: Tue, 7 Jan 2020 10:51:04 -0800 Subject: [PATCH] ENABLE MYROCKS COMPILATION - Fix clang-5+ and gcc-5+ compilation issues (#1076) (#1076) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Summary: 1. Suppress warnings only if compiler supports "-Wno-xxxxxx". 2. Fix issues described at https://jira.percona.com/browse/PS-6054 and https://jira.percona.com/browse/PS-6058 3. Fix linking issues for clang-7 and clang-8: ``` /usr/bin/ld.gold: error: /usr/lib/llvm-8/lib/clang/8.0.1/lib/linux/libclang_rt.fuzzer-x86_64.a(FuzzerDataFlowTrace.cpp.o): invalid section group 9 refers to earlier section 3 /usr/bin/ld.gold: error: /usr/lib/llvm-8/lib/clang/8.0.1/lib/linux/libclang_rt.fuzzer-x86_64.a(FuzzerDataFlowTrace.cpp.o): invalid section group 10 refers to earlier section 4 /usr/bin/ld.gold: error: /usr/lib/llvm-8/lib/clang/8.0.1/lib/linux/libclang_rt.fuzzer-x86_64.a(FuzzerDataFlowTrace.cpp.o): invalid section group 11 refers to earlier section 5 ``` 4. Fix `-Werror=ignored-qualifiers` warnings e.g. ``` /fb-8.0.17/storage/rocksdb/ha_rocksdb.cc:882:70: error: type qualifiers ignored on cast result type [-Werror=ignored-qualifiers] 882 | static_cast(rocksdb_info_log_level)); ``` 5. Fix a `-Wundefined-reinterpret-cast` warning: ``` /fb-8.0.17/storage/rocksdb/ha_rocksdb.cc:3777:11: error: dereference of type 'myrocks::Rdb_transaction **' that was reinterpret_cast from type 'void **' has undefined behavior [-Werror,-Wundefined-reinterpret-cast] return *reinterpret_cast( ``` 6. Fix a `-Werror=attributes` warning: ``` /fb-8.0.17/include/my_compiler.h:100:40: error: ‘nonnull’ attribute only applies to function types [-Werror=attributes] 100 | #define MY_ATTRIBUTE(A) __attribute__(A) ``` 7. Fix ``` /fb-8.0.17/sql/dd/impl/types/schema_impl.cc:100:1: error: base class ‘class dd::Weak_object’ should be explicitly initialized in the copy constructor [-Werror=extra] Schema_impl::Schema_impl(const Schema_impl &src) ``` Pull Request resolved: https://github.com/facebook/mysql-5.6/pull/1076 Reviewed By: lloyd Differential Revision: D19301431 Pulled By: lth --- CMakeLists.txt | 1 + mysql-test/t/func_group.test | 2 +- sql/rpl_gtid.h | 1 + storage/rocksdb/CMakeLists.txt | 13 +++++++++++-- storage/rocksdb/rdb_psi.cc | 16 ++++++++-------- 5 files changed, 22 insertions(+), 11 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 50de21338a54..dec5eb07c014 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -777,6 +777,7 @@ INCLUDE(mysql_add_executable) INCLUDE(curl) INCLUDE(rapidjson) INCLUDE(fprofile) +INCLUDE(prepend_append_cflags_if_supported) INCLUDE(gloves) INCLUDE(fido2) diff --git a/mysql-test/t/func_group.test b/mysql-test/t/func_group.test index 935fd4d7c1b5..821ae8244d68 100644 --- a/mysql-test/t/func_group.test +++ b/mysql-test/t/func_group.test @@ -921,7 +921,7 @@ SELECT 1 FROM t1 GROUP BY (SELECT SLEEP(0) FROM t1 ORDER BY AVG(DISTINCT a) ); DROP TABLE t1; # -# Bug #30715: Assertion failed: item_field->field->real_maybe_null(), file +# Bug #30715: Assertion failed: item_field->field->is_nullable(), file # .\opt_sum.cc, line # diff --git a/sql/rpl_gtid.h b/sql/rpl_gtid.h index 09aab417cdbd..64d4eb27f497 100644 --- a/sql/rpl_gtid.h +++ b/sql/rpl_gtid.h @@ -30,6 +30,7 @@ #include // std::adopt_lock_t #include +#undef ZSTD // defined in storage/rocksdb/CMakeLists.txt #include "libbinlogevents/include/compression/base.h" #include "libbinlogevents/include/gtids/global.h" #include "libbinlogevents/include/uuid.h" diff --git a/storage/rocksdb/CMakeLists.txt b/storage/rocksdb/CMakeLists.txt index 3bcd9179394c..6635a16c2e65 100644 --- a/storage/rocksdb/CMakeLists.txt +++ b/storage/rocksdb/CMakeLists.txt @@ -1,5 +1,3 @@ -RETURN() # MyRocks is disabled - # TODO: Copyrights # This is a strong requirement coming from RocksDB. No conditional checks here. @@ -102,6 +100,12 @@ IF(CMAKE_CXX_COMPILER_ID MATCHES "Clang") append_cflags_if_supported(-Wno-deprecated-dynamic-exception-spec) ENDIF() +# Suppress googletest warnings for clang-12 or newer +IF(CMAKE_CXX_COMPILER_ID MATCHES "Clang" AND NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 12) + ADD_CXX_COMPILE_FLAGS_TO_FILES(-Wno-deprecated-copy FILES ../../rocksdb/options/db_options.cc ../../rocksdb/db/db_impl/db_impl.cc) + ADD_CXX_COMPILE_FLAGS_TO_FILES(-Wno-unused-but-set-variable FILES ../../rocksdb/utilities/env_mirror.cc) +ENDIF() + # Suppress warnings for all gcc versions IF(CMAKE_COMPILER_IS_GNUCXX) # "cmake/maintainer.cmake" sets "-Wmissing-format-attribute" which cause warnings with RocksDB @@ -113,6 +117,11 @@ IF(CMAKE_COMPILER_IS_GNUCXX AND NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 6) ADD_CXX_COMPILE_FLAGS_TO_FILES(-Wno-logical-op FILES ../../rocksdb/file/filename.cc) ENDIF() +# Suppress warnings for gcc-8 or newer +IF(CMAKE_COMPILER_IS_GNUCXX AND NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 8) + remove_compile_flags(-Wextra-semi) +ENDIF() + # Suppress warnings for gcc-9 or newer IF(CMAKE_COMPILER_IS_GNUCXX AND NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 9) ADD_CXX_COMPILE_FLAGS_TO_FILES(-Wno-maybe-uninitialized FILES ../../rocksdb/env/env.cc) diff --git a/storage/rocksdb/rdb_psi.cc b/storage/rocksdb/rdb_psi.cc index 3d2f98b9b2ad..76b89875a713 100644 --- a/storage/rocksdb/rdb_psi.cc +++ b/storage/rocksdb/rdb_psi.cc @@ -38,14 +38,14 @@ my_core::PSI_thread_key rdb_background_psi_thread_key, rdb_drop_idx_psi_thread_key, rdb_is_psi_thread_key, rdb_mc_psi_thread_key; my_core::PSI_thread_info all_rocksdb_threads[] = { - {&rdb_background_psi_thread_key, "background", PSI_FLAG_SINGLETON, 0, - PSI_DOCUMENT_ME}, - {&rdb_drop_idx_psi_thread_key, "drop index", PSI_FLAG_SINGLETON, 0, - PSI_DOCUMENT_ME}, - {&rdb_is_psi_thread_key, "index stats calculation", PSI_FLAG_SINGLETON, 0, - PSI_DOCUMENT_ME}, - {&rdb_mc_psi_thread_key, "manual compaction", PSI_FLAG_SINGLETON, 0, - PSI_DOCUMENT_ME}, + {&rdb_background_psi_thread_key, "background", "background", + PSI_FLAG_SINGLETON, 0, PSI_DOCUMENT_ME}, + {&rdb_drop_idx_psi_thread_key, "drop index", "drop_idx", PSI_FLAG_SINGLETON, + 0, PSI_DOCUMENT_ME}, + {&rdb_is_psi_thread_key, "index stats calculation", "is_psi", + PSI_FLAG_SINGLETON, 0, PSI_DOCUMENT_ME}, + {&rdb_mc_psi_thread_key, "manual compaction", "mc_psi", PSI_FLAG_SINGLETON, + 0, PSI_DOCUMENT_ME}, }; my_core::PSI_mutex_key rdb_psi_open_tbls_mutex_key, rdb_signal_bg_psi_mutex_key,