Details
Description
MDEV-34996 was incomplete it its testing of -stdlib=libc++ as this required -fsanitize=memory
The MY_CHECK_AND_SET_COMPILER_FLAG("-fsanitize=memory prior to MY_CHECK_CXX_COMPILER_FLAG("-stdlib=libc++") doesn't set the CMAKE_REQUIRED_FLAGS so results in:
/source/CMakeLists.txt(249): MY_CHECK_CXX_COMPILER_FLAG(-stdlib=libc++ )
|
/source/cmake/check_compiler_flag.cmake(28): STRING(REGEX REPLACE [-,= +] _ result have_CXX_-stdlib=libc++ )
|
/source/cmake/check_compiler_flag.cmake(29): SET(SAVE_CMAKE_REQUIRED_FLAGS )
|
/source/cmake/check_compiler_flag.cmake(30): SET(CMAKE_REQUIRED_FLAGS -stdlib=libc++ )
|
/source/cmake/check_compiler_flag.cmake(31): CHECK_CXX_SOURCE_COMPILES(int main(void) { return 0; } have_CXX__stdlib_libc__ FAIL_REGEX;argument unused during compilation;FAIL_REGEX;unsupported .*option;FAIL_REGEX;unknown .*option;FAIL_REGEX;unrecognized .*option;FAIL_REGEX;ignoring unknown option;FAIL_REGEX;warning:.*ignored;FAIL_REGEX;warning:.*is valid for.*but not for;FAIL_REGEX;warning:.*redefined;FAIL_REGEX;[Ww]arning: [Oo]ption )
|
-- Performing Test have_CXX__stdlib_libc__
|
-- Performing Test have_CXX__stdlib_libc__ - Failed
|
/source/cmake/check_compiler_flag.cmake(33): SET(CMAKE_REQUIRED_FLAGS )
|
/source/CMakeLists.txt(250): IF(NOT have_CXX__stdlib_libc__ )
|
/source/CMakeLists.txt(251): MESSAGE(FATAL_ERROR C++ Compiler requires support for -stdlib=libc++ )
|
CMake Error at CMakeLists.txt:251 (MESSAGE):
|
C++ Compiler requires support for -stdlib=libc++
|
|
|
-- Configuring incomplete, errors occurred!
|
See also "/build/CMakeFiles/CMakeOutput.log".
|
See also "/build/CMakeFiles/CMakeError.log".
|
buildbot@2f11790aa1e1:/build$ rm -rf .ninja_*
|
buildbot@2f11790aa1e1:/build$ tail -n 30 /build/CMakeFiles/CMakeError.log
|
Change Dir: /build/CMakeFiles/CMakeScratch/TryCompile-RfQ4we
|
|
Run Build Command(s):/usr/bin/ninja cmTC_2cfad && [1/2] Building CXX object CMakeFiles/cmTC_2cfad.dir/src.cxx.o
|
[2/2] Linking CXX executable cmTC_2cfad
|
FAILED: cmTC_2cfad
|
: && /usr/bin/clang++ -stdlib=libc++ -L/msan-libs -Wl,-rpath=/msan-libs CMakeFiles/cmTC_2cfad.dir/src.cxx.o -o cmTC_2cfad && :
|
/usr/bin/ld: /msan-libs/libc++.so.1: undefined reference to `__msan_memset'
|
/usr/bin/ld: /msan-libs/libc++.so.1: undefined reference to `__msan_retval_origin_tls'
|
/usr/bin/ld: /msan-libs/libc++.so.1: undefined reference to `__msan_unpoison'
|
/usr/bin/ld: /msan-libs/libc++.so.1: undefined reference to `__msan_param_origin_tls'
|
/usr/bin/ld: /msan-libs/libc++.so.1: undefined reference to `__msan_memcpy'
|
/usr/bin/ld: /msan-libs/libc++.so.1: undefined reference to `__msan_retval_tls'
|
/usr/bin/ld: /msan-libs/libc++.so.1: undefined reference to `__msan_va_arg_overflow_size_tls'
|
/usr/bin/ld: /msan-libs/libc++.so.1: undefined reference to `__msan_va_arg_origin_tls'
|
/usr/bin/ld: /msan-libs/libc++.so.1: undefined reference to `__sanitizer_dtor_callback_fields'
|
/usr/bin/ld: /msan-libs/libc++.so.1: undefined reference to `__msan_memmove'
|
/usr/bin/ld: /msan-libs/libc++.so.1: undefined reference to `__msan_chain_origin'
|
/usr/bin/ld: /msan-libs/libc++.so.1: undefined reference to `__sanitizer_dtor_callback_vptr'
|
/usr/bin/ld: /msan-libs/libc++.so.1: undefined reference to `__msan_va_arg_tls'
|
/usr/bin/ld: /msan-libs/libc++.so.1: undefined reference to `__msan_warning_with_origin_noreturn'
|
/usr/bin/ld: /msan-libs/libc++.so.1: undefined reference to `__msan_set_alloca_origin_with_descr'
|
/usr/bin/ld: /msan-libs/libc++.so.1: undefined reference to `__msan_init'
|
/usr/bin/ld: /msan-libs/libc++.so.1: undefined reference to `__msan_param_tls'
|
clang++: error: linker command failed with exit code 1 (use -v to see invocation)
|
ninja: build stopped: subcommand failed.
|
Attachments
Issue Links
- is caused by
-
MDEV-34996 Buildbot MSAN options in buildbot rather than server
-
- Closed
-
draft
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -31,7 +31,7 @@ ENDIF()
# in RPM's:
#set(CPACK_RPM_SPEC_MORE_DEFINE "%define __spec_install_post /bin/true")
-FOREACH(p CMP0022 CMP0046 CMP0040 CMP0048 CMP0054 CMP0067 CMP0074 CMP0075 CMP0069 CMP0135)
+FOREACH(p CMP0022 CMP0046 CMP0040 CMP0048 CMP0054 CMP0056 CMP0066 CMP0067 CMP0074 CMP0075 CMP0069 CMP0135)
IF(POLICY ${p})
CMAKE_POLICY(SET ${p} NEW)
ENDIF()
@@ -246,7 +246,7 @@ ENDIF()
OPTION(WITH_MSAN "Enable memory sanitizer" OFF)
IF (WITH_MSAN)
- MY_CHECK_AND_SET_COMPILER_FLAG("-fsanitize=memory -fsanitize-memory-track-origins -U_FORTIFY_SOURCE" DEBUG RELWITHDEBINFO)
+ MY_CHECK_AND_SET_COMPILER_FLAG("-fsanitize=memory -fsanitize-memory-track-origins -U_FORTIFY_SOURCE")
IF(NOT (have_C__fsanitize_memory__fsanitize_memory_track_origins__U_FORTIFY_SOURCE
AND have_CXX__fsanitize_memory__fsanitize_memory_track_origins__U_FORTIFY_SOURCE))
MESSAGE(FATAL_ERROR "Compiler doesn't support -fsanitize=memory flags")
@@ -256,7 +256,7 @@ IF (WITH_MSAN)
MESSAGE(FATAL_ERROR "C++ Compiler requires support for -stdlib=libc++")
ENDIF()
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -stdlib=libc++")
- MY_CHECK_AND_SET_LINKER_FLAG("-fsanitize=memory" DEBUG RELWITHDEBINFO)
+ MY_CHECK_AND_SET_LINKER_FLAG("-fsanitize=memory")
IF(NOT HAVE_LINK_FLAG__fsanitize_memory)
MESSAGE(FATAL_ERROR "Linker doesn't support -fsanitize=memory flags")
ENDIF()
Policies use compile and linker flags for checks.
Removing DEBUG/RELWITHDEBINFO allows the CMAKE_C/CXX_FLAGS to be set which is the one used in try_compile etc tests.
Was important with MSAN as libfmt try_run test was failing to link and therefore fail.
experiments with CMAKE_REQUIRED_FLAGS reveiled the following missing/save/restore
diff --git a/cmake/os/SunOS.cmake b/cmake/os/SunOS.cmake
index 3a9d2dccb87..842111e774b 100644
--- a/cmake/os/SunOS.cmake
+++ b/cmake/os/SunOS.cmake
@@ -83,9 +83,10 @@ IF(CMAKE_COMPILER_IS_GNUCC AND CMAKE_SIZEOF_VOID_P EQUAL 4
} ")
CHECK_C_SOURCE_COMPILES(${SOURCE} HAVE_SPARC32_TICK)
IF(NOT HAVE_SPARC32_TICK)
+ SET(SAVE_CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS}")
SET(CMAKE_REQUIRED_FLAGS "-mcpu=v9")
CHECK_C_SOURCE_COMPILES(${SOURCE} HAVE_SPARC32_TICK_WITH_V9)
- SET(CMAKE_REQUIRED_FLAGS)
+ SET(CMAKE_REQUIRED_FLAGS "${SAVE_CMAKE_REQUIRED_FLAGS}")
IF(HAVE_SPARC32_TICK_WITH_V9)
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -mcpu=v9")
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mcpu=v9")
diff --git a/configure.cmake b/configure.cmake
index 027a810ed0e..7b484fdc105 100644
--- a/configure.cmake
+++ b/configure.cmake
@@ -273,6 +273,7 @@ FUNCTION(MY_CHECK_PTHREAD_ONCE_INIT)
IF(NOT have_C__Werror)
RETURN()
ENDIF()
+ SET(SAVE_CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS}")
SET(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -Werror")
CHECK_C_SOURCE_COMPILES("
#include <pthread.h>
@@ -299,6 +300,7 @@ FUNCTION(MY_CHECK_PTHREAD_ONCE_INIT)
HAVE_ARRAY_PTHREAD_ONCE_INIT
)
ENDIF()
+ SET(CMAKE_REQUIRED_FLAGS "${SAVE_CMAKE_REQUIRED_FLAGS}")
IF(HAVE_PTHREAD_ONCE_INIT)
SET(PTHREAD_ONCE_INITIALIZER "PTHREAD_ONCE_INIT" PARENT_SCOPE)
ENDIF()
And
diff --git a/plugin/auth_pam/CMakeLists.txt b/plugin/auth_pam/CMakeLists.txt
index f2cce80f800..04f9111ac54 100644
--- a/plugin/auth_pam/CMakeLists.txt
+++ b/plugin/auth_pam/CMakeLists.txt
@@ -13,6 +13,7 @@ CHECK_FUNCTION_EXISTS (getgrouplist HAVE_GETGROUPLIST)
INCLUDE_DIRECTORIES(${CMAKE_CURRENT_BINARY_DIR})
# Check whether getgrouplist uses gtid_t for second and third arguments.
+SET(CMAKE_REQUIRED_FLAGS "${SAVE_CMAKE_REQUIRED_FLAGS}")
SET(CMAKE_REQUIRED_FLAGS -Werror)
CHECK_C_SOURCE_COMPILES(
"
@@ -28,7 +29,7 @@ int main() {
"
HAVE_POSIX_GETGROUPLIST
)
-SET(CMAKE_REQUIRED_FLAGS)
+SET(CMAKE_REQUIRED_FLAGS "${SAVE_CMAKE_REQUIRED_FLAGS}")
SET(CMAKE_REQUIRED_LIBRARIES pam)
CHECK_FUNCTION_EXISTS(pam_syslog HAVE_PAM_SYSLOG)
diff --git a/storage/rocksdb/build_rocksdb.cmake b/storage/rocksdb/build_rocksdb.cmake
index e89dbfc0627..03a7a3052d6 100644
--- a/storage/rocksdb/build_rocksdb.cmake
+++ b/storage/rocksdb/build_rocksdb.cmake
@@ -459,7 +459,8 @@ if(MSVC)
# Workaround Win8.1 SDK bug, that breaks /permissive-
string(REPLACE "/permissive-" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
else()
- set(CMAKE_REQUIRED_FLAGS "-msse4.2 -mpclmul ${CXX11_FLAGS}")
+ SET(SAVE_CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS}")
+ set(CMAKE_REQUIRED_FLAGS "-msse4.2 -mpclmul ${CMAKE_REQUIRED_FLAGS} ${CXX11_FLAGS}")
CHECK_CXX_SOURCE_COMPILES("
#include <cstdint>
@@ -477,7 +478,7 @@ int main() {
set_source_files_properties(${ROCKSDB_SOURCE_DIR}/util/crc32c.cc
PROPERTIES COMPILE_FLAGS "-DHAVE_SSE42 -DHAVE_PCLMUL -msse4.2 -mpclmul")
endif()
- unset(CMAKE_REQUIRED_FLAGS)
+ SET(CMAKE_REQUIRED_FLAGS "${SAVE_CMAKE_REQUIRED_FLAGS}")
endif()
IF(CMAKE_VERSION VERSION_GREATER "2.8.10")
Though these are lower level and not parent_scope.