@@ -34,13 +34,9 @@ endif()
3434# required during compilation (which has the -nostdlib++ or -nodefaultlibs). libc is
3535# required for the link to go through. We remove sanitizers from the
3636# configuration checks to avoid spurious link errors.
37- #
38- # Adding flags to CMAKE_REQUIRED_FLAGS will include the flags both when testing
39- # compilation of C and C++. Therefore test to make sure that the flags are
40- # supported by the C compiler driver, before deciding to include them.
4137
42- llvm_check_compiler_linker_flag(C "-nostdlib++" C_SUPPORTS_NOSTDLIBXX_FLAG )
43- if (C_SUPPORTS_NOSTDLIBXX_FLAG )
38+ llvm_check_compiler_linker_flag(CXX "-nostdlib++" CXX_SUPPORTS_NOSTDLIBXX_FLAG )
39+ if (CXX_SUPPORTS_NOSTDLIBXX_FLAG )
4440 set (CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -nostdlib++" )
4541else ()
4642 llvm_check_compiler_linker_flag(C "-nodefaultlibs" C_SUPPORTS_NODEFAULTLIBS_FLAG)
@@ -51,7 +47,7 @@ endif()
5147
5248# Only link against compiler-rt manually if we use -nodefaultlibs, since
5349# otherwise the compiler will do the right thing on its own.
54- if (NOT C_SUPPORTS_NOSTDLIBXX_FLAG AND C_SUPPORTS_NODEFAULTLIBS_FLAG)
50+ if (NOT CXX_SUPPORTS_NOSTDLIBXX_FLAG AND C_SUPPORTS_NODEFAULTLIBS_FLAG)
5551 if (LIBUNWIND_HAS_C_LIB)
5652 list (APPEND CMAKE_REQUIRED_LIBRARIES c)
5753 endif ()
@@ -86,7 +82,7 @@ if (NOT C_SUPPORTS_NOSTDLIBXX_FLAG AND C_SUPPORTS_NODEFAULTLIBS_FLAG)
8682 endif ()
8783endif ()
8884
89- if (C_SUPPORTS_NOSTDLIBXX_FLAG OR C_SUPPORTS_NODEFAULTLIBS_FLAG)
85+ if (CXX_SUPPORTS_NOSTDLIBXX_FLAG OR C_SUPPORTS_NODEFAULTLIBS_FLAG)
9086 if (CMAKE_C_FLAGS MATCHES -fsanitize OR CMAKE_CXX_FLAGS MATCHES -fsanitize)
9187 set (CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -fno-sanitize=all" )
9288 endif ()
0 commit comments