From e56ae86f0b1012e528d8d3ca6d8c96fc2a79298d Mon Sep 17 00:00:00 2001 From: sdk2 <469656392@qq.com> Date: Wed, 15 Sep 2021 11:57:27 +0800 Subject: [PATCH 1/2] fix clang flag use-ctor-homing --- CMakeLists.txt | 9 +++++---- cmake/check_flags.cmake | 1 + 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 897111e66bf..3625db4a2d7 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -28,6 +28,9 @@ endforeach() project(ClickHouse) +# Check if needed compiler flags are supported +include (cmake/check_flags.cmake) + # If turned off: e.g. when ENABLE_FOO is ON, but FOO tool was not found, the CMake will continue. option(FAIL_ON_UNSUPPORTED_OPTIONS_COMBINATION "Stop/Fail CMake configuration if some ENABLE_XXX option is defined (either ON or OFF) @@ -166,7 +169,8 @@ if (COMPILER_CLANG) set(COMPILER_FLAGS "${COMPILER_FLAGS} -gdwarf-aranges") endif () - if (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 12.0.0) + message(STATUS "HAS_USE_CTOR_HOMING: ${HAS_USE_CTOR_HOMING}") + if (HAS_USE_CTOR_HOMING AND CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 12.0.0) if (CMAKE_BUILD_TYPE_UC STREQUAL "DEBUG" OR CMAKE_BUILD_TYPE_UC STREQUAL "RELWITHDEBINFO") set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Xclang -fuse-ctor-homing") set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Xclang -fuse-ctor-homing") @@ -629,9 +633,6 @@ include_directories(${ConfigIncludePath}) # Add as many warnings as possible for our own code. include (cmake/warnings.cmake) -# Check if needed compiler flags are supported -include (cmake/check_flags.cmake) - add_subdirectory (base) add_subdirectory (src) add_subdirectory (programs) diff --git a/cmake/check_flags.cmake b/cmake/check_flags.cmake index 5a4ff472868..58605543dff 100644 --- a/cmake/check_flags.cmake +++ b/cmake/check_flags.cmake @@ -4,3 +4,4 @@ include (CheckCCompilerFlag) check_cxx_compiler_flag("-Wsuggest-destructor-override" HAS_SUGGEST_DESTRUCTOR_OVERRIDE) check_cxx_compiler_flag("-Wshadow" HAS_SHADOW) check_cxx_compiler_flag("-Wsuggest-override" HAS_SUGGEST_OVERRIDE) +check_cxx_compiler_flag("-Xclang -fuse-ctor-homing" HAS_USE_CTOR_HOMING) From 9117c88a924712b0c83ea7e1e8a0d34622b05555 Mon Sep 17 00:00:00 2001 From: sdk2 <469656392@qq.com> Date: Wed, 15 Sep 2021 12:26:27 +0800 Subject: [PATCH 2/2] better flag check --- CMakeLists.txt | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 3625db4a2d7..9c8903d853c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -28,9 +28,6 @@ endforeach() project(ClickHouse) -# Check if needed compiler flags are supported -include (cmake/check_flags.cmake) - # If turned off: e.g. when ENABLE_FOO is ON, but FOO tool was not found, the CMake will continue. option(FAIL_ON_UNSUPPORTED_OPTIONS_COMBINATION "Stop/Fail CMake configuration if some ENABLE_XXX option is defined (either ON or OFF) @@ -155,6 +152,7 @@ if (CMAKE_GENERATOR STREQUAL "Ninja" AND NOT DISABLE_COLORED_BUILD) set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fdiagnostics-color=always") endif () +include (cmake/check_flags.cmake) include (cmake/add_warning.cmake) if (NOT MSVC) @@ -169,8 +167,8 @@ if (COMPILER_CLANG) set(COMPILER_FLAGS "${COMPILER_FLAGS} -gdwarf-aranges") endif () - message(STATUS "HAS_USE_CTOR_HOMING: ${HAS_USE_CTOR_HOMING}") - if (HAS_USE_CTOR_HOMING AND CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 12.0.0) + if (HAS_USE_CTOR_HOMING) + # For more info see https://blog.llvm.org/posts/2021-04-05-constructor-homing-for-debug-info/ if (CMAKE_BUILD_TYPE_UC STREQUAL "DEBUG" OR CMAKE_BUILD_TYPE_UC STREQUAL "RELWITHDEBINFO") set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Xclang -fuse-ctor-homing") set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Xclang -fuse-ctor-homing")