Skip to content

Commit 240e478

Browse files
authored
Revert "[runtimes] Probe for -nostdlib++ and -nostdinc++ with the C compiler" (#113653)
Reverts #108357 Breaks https://lab.llvm.org/buildbot/#/builders/164/builds/3908 and similar bots
1 parent d0c8150 commit 240e478

File tree

6 files changed

+19
-35
lines changed

6 files changed

+19
-35
lines changed

Diff for: libcxx/cmake/config-ix.cmake

+4-8
Original file line numberDiff line numberDiff line change
@@ -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++")
4945
else()
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()
8682
endif()
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 ()

Diff for: libcxxabi/cmake/config-ix.cmake

+4-8
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,9 @@ endif ()
2222
# required during compilation (which has the -nodefaultlibs). libc is
2323
# required for the link to go through. We remove sanitizers from the
2424
# configuration checks to avoid spurious link errors.
25-
#
26-
# Adding flags to CMAKE_REQUIRED_FLAGS will include the flags both when testing
27-
# compilation of C and C++. Therefore test to make sure that the flags are
28-
# supported by the C compiler driver, before deciding to include them.
2925

30-
check_c_compiler_flag(-nostdlib++ C_SUPPORTS_NOSTDLIBXX_FLAG)
31-
if (C_SUPPORTS_NOSTDLIBXX_FLAG)
26+
check_cxx_compiler_flag(-nostdlib++ CXX_SUPPORTS_NOSTDLIBXX_FLAG)
27+
if (CXX_SUPPORTS_NOSTDLIBXX_FLAG)
3228
set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -nostdlib++")
3329
else()
3430
check_c_compiler_flag(-nodefaultlibs C_SUPPORTS_NODEFAULTLIBS_FLAG)
@@ -39,7 +35,7 @@ endif()
3935

4036
# Only link against compiler-rt manually if we use -nodefaultlibs, since
4137
# otherwise the compiler will do the right thing on its own.
42-
if (NOT C_SUPPORTS_NOSTDLIBXX_FLAG AND C_SUPPORTS_NODEFAULTLIBS_FLAG)
38+
if (NOT CXX_SUPPORTS_NOSTDLIBXX_FLAG AND C_SUPPORTS_NODEFAULTLIBS_FLAG)
4339
if (LIBCXXABI_HAS_C_LIB)
4440
list(APPEND CMAKE_REQUIRED_LIBRARIES c)
4541
endif ()
@@ -75,7 +71,7 @@ if (NOT C_SUPPORTS_NOSTDLIBXX_FLAG AND C_SUPPORTS_NODEFAULTLIBS_FLAG)
7571
endif()
7672
endif()
7773

78-
if (C_SUPPORTS_NOSTDLIBXX_FLAG OR C_SUPPORTS_NODEFAULTLIBS_FLAG)
74+
if (CXX_SUPPORTS_NOSTDLIBXX_FLAG OR C_SUPPORTS_NODEFAULTLIBS_FLAG)
7975
if (CMAKE_C_FLAGS MATCHES -fsanitize OR CMAKE_CXX_FLAGS MATCHES -fsanitize)
8076
set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -fno-sanitize=all")
8177
endif ()

Diff for: libcxxabi/src/CMakeLists.txt

+2-2
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ if (ANDROID AND ANDROID_PLATFORM_LEVEL LESS 21)
9191
endif()
9292

9393
# Setup flags.
94-
if (C_SUPPORTS_NOSTDLIBXX_FLAG)
94+
if (CXX_SUPPORTS_NOSTDLIBXX_FLAG)
9595
add_link_flags_if_supported(-nostdlib++)
9696
else()
9797
add_link_flags_if_supported(-nodefaultlibs)
@@ -167,7 +167,7 @@ if (LIBCXXABI_USE_LLVM_UNWINDER)
167167
endif()
168168
endif()
169169
target_link_libraries(cxxabi_shared_objects PRIVATE cxx-headers ${LIBCXXABI_LIBRARIES})
170-
if (NOT C_SUPPORTS_NOSTDLIBXX_FLAG)
170+
if (NOT CXX_SUPPORTS_NOSTDLIBXX_FLAG)
171171
target_link_libraries(cxxabi_shared_objects PRIVATE ${LIBCXXABI_BUILTINS_LIBRARY})
172172
endif()
173173
target_link_libraries(cxxabi_shared_objects PUBLIC cxxabi-headers)

Diff for: libunwind/cmake/config-ix.cmake

+4-8
Original file line numberDiff line numberDiff line change
@@ -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++")
4541
else()
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()
8783
endif()
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 ()

Diff for: libunwind/src/CMakeLists.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ set(LIBUNWIND_SOURCES
6666
${LIBUNWIND_ASM_SOURCES})
6767

6868
# Generate library list.
69-
if (C_SUPPORTS_NOSTDLIBXX_FLAG)
69+
if (CXX_SUPPORTS_NOSTDLIBXX_FLAG)
7070
add_link_flags_if_supported(-nostdlib++)
7171
else()
7272
if (LIBUNWIND_USE_COMPILER_RT)

Diff for: runtimes/CMakeLists.txt

+4-8
Original file line numberDiff line numberDiff line change
@@ -143,16 +143,12 @@ endif()
143143
# Check for -nostdlib++ first; if there's no C++ standard library yet,
144144
# all check_cxx_compiler_flag commands will fail until we add -nostdlib++
145145
# (or -nodefaultlibs).
146-
#
147-
# Adding flags to CMAKE_REQUIRED_FLAGS will include the flags both when testing
148-
# compilation of C and C++. Therefore test to make sure that the flags are
149-
# supported by the C compiler driver, before deciding to include them.
150-
llvm_check_compiler_linker_flag(C "-nostdlib++" C_SUPPORTS_NOSTDLIBXX_FLAG)
151-
if (C_SUPPORTS_NOSTDLIBXX_FLAG)
146+
llvm_check_compiler_linker_flag(CXX "-nostdlib++" CXX_SUPPORTS_NOSTDLIBXX_FLAG)
147+
if (CXX_SUPPORTS_NOSTDLIBXX_FLAG)
152148
set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -nostdlib++")
153149
endif()
154-
check_c_compiler_flag(-nostdinc++ C_SUPPORTS_NOSTDINCXX_FLAG)
155-
if (C_SUPPORTS_NOSTDINCXX_FLAG)
150+
check_cxx_compiler_flag(-nostdinc++ CXX_SUPPORTS_NOSTDINCXX_FLAG)
151+
if (CXX_SUPPORTS_NOSTDINCXX_FLAG)
156152
set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -nostdinc++")
157153
endif()
158154

0 commit comments

Comments
 (0)