@@ -38,13 +38,9 @@ check_cxx_compiler_flag(-nolibc CXX_SUPPORTS_NOLIBC_FLAG)
3838# required during compilation (which has the -nostdlib++ or -nodefaultlibs). libc is
3939# required for the link to go through. We remove sanitizers from the
4040# configuration checks to avoid spurious link errors.
41- #
42- # Adding flags to CMAKE_REQUIRED_FLAGS will include the flags both when testing
43- # compilation of C and C++. Therefore test to make sure that the flags are
44- # supported by the C compiler driver, before deciding to include them.
4541
46- check_c_compiler_flag (-nostdlib++ C_SUPPORTS_NOSTDLIBXX_FLAG )
47- if (C_SUPPORTS_NOSTDLIBXX_FLAG )
42+ check_cxx_compiler_flag (-nostdlib++ CXX_SUPPORTS_NOSTDLIBXX_FLAG )
43+ if (CXX_SUPPORTS_NOSTDLIBXX_FLAG )
4844 set (CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -nostdlib++" )
4945else ()
5046 check_c_compiler_flag(-nodefaultlibs C_SUPPORTS_NODEFAULTLIBS_FLAG)
@@ -55,7 +51,7 @@ endif()
5551
5652# Only link against compiler-rt manually if we use -nodefaultlibs, since
5753# otherwise the compiler will do the right thing on its own.
58- if (NOT C_SUPPORTS_NOSTDLIBXX_FLAG AND C_SUPPORTS_NODEFAULTLIBS_FLAG)
54+ if (NOT CXX_SUPPORTS_NOSTDLIBXX_FLAG AND C_SUPPORTS_NODEFAULTLIBS_FLAG)
5955 if (LIBCXX_USE_COMPILER_RT)
6056 include (HandleCompilerRT)
6157 find_compiler_rt_library(builtins LIBCXX_BUILTINS_LIBRARY
@@ -85,7 +81,7 @@ if (NOT C_SUPPORTS_NOSTDLIBXX_FLAG AND C_SUPPORTS_NODEFAULTLIBS_FLAG)
8581 endif ()
8682endif ()
8783
88- if (C_SUPPORTS_NOSTDLIBXX_FLAG OR C_SUPPORTS_NODEFAULTLIBS_FLAG)
84+ if (CXX_SUPPORTS_NOSTDLIBXX_FLAG OR C_SUPPORTS_NODEFAULTLIBS_FLAG)
8985 if (CMAKE_C_FLAGS MATCHES -fsanitize OR CMAKE_CXX_FLAGS MATCHES -fsanitize)
9086 set (CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -fno-sanitize=all" )
9187 endif ()
0 commit comments