File tree 6 files changed +31
-15
lines changed
6 files changed +31
-15
lines changed Original file line number Diff line number Diff line change @@ -631,7 +631,7 @@ function(cxx_link_system_libraries target)
631
631
# Unfortunately this cannot be used universally because for example g++ supports
632
632
# only -nodefaultlibs in which case all libraries will be removed and
633
633
# all libraries but c++ have to be added in manually.
634
- if (CXX_SUPPORTS_NOSTDLIBXX_FLAG )
634
+ if (C_SUPPORTS_NOSTDLIBXX_FLAG )
635
635
target_add_link_flags_if_supported(${target} PRIVATE "-nostdlib++" )
636
636
else ()
637
637
target_add_link_flags_if_supported(${target} PRIVATE "-nodefaultlibs" )
Original file line number Diff line number Diff line change @@ -42,9 +42,13 @@ endif()
42
42
# required during compilation (which has the -nostdlib++ or -nodefaultlibs). libc is
43
43
# required for the link to go through. We remove sanitizers from the
44
44
# configuration checks to avoid spurious link errors.
45
+ #
46
+ # Adding flags to CMAKE_REQUIRED_FLAGS will include the flags both when testing
47
+ # compilation of C and C++. Therefore test to make sure that the flags are
48
+ # supported by the C compiler driver, before deciding to include them.
45
49
46
- check_cxx_compiler_flag (-nostdlib++ CXX_SUPPORTS_NOSTDLIBXX_FLAG )
47
- if (CXX_SUPPORTS_NOSTDLIBXX_FLAG )
50
+ check_c_compiler_flag (-nostdlib++ C_SUPPORTS_NOSTDLIBXX_FLAG )
51
+ if (C_SUPPORTS_NOSTDLIBXX_FLAG )
48
52
set (CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -nostdlib++" )
49
53
else ()
50
54
check_c_compiler_flag(-nodefaultlibs C_SUPPORTS_NODEFAULTLIBS_FLAG)
53
57
endif ()
54
58
endif ()
55
59
56
- if (CXX_SUPPORTS_NOSTDLIBXX_FLAG OR C_SUPPORTS_NODEFAULTLIBS_FLAG)
60
+ if (C_SUPPORTS_NOSTDLIBXX_FLAG OR C_SUPPORTS_NODEFAULTLIBS_FLAG)
57
61
if (LIBCXX_HAS_C_LIB)
58
62
list (APPEND CMAKE_REQUIRED_LIBRARIES c)
59
63
endif ()
Original file line number Diff line number Diff line change @@ -22,9 +22,13 @@ endif ()
22
22
# required during compilation (which has the -nodefaultlibs). libc is
23
23
# required for the link to go through. We remove sanitizers from the
24
24
# 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.
25
29
26
- check_cxx_compiler_flag (-nostdlib++ CXX_SUPPORTS_NOSTDLIBXX_FLAG )
27
- if (CXX_SUPPORTS_NOSTDLIBXX_FLAG )
30
+ check_c_compiler_flag (-nostdlib++ C_SUPPORTS_NOSTDLIBXX_FLAG )
31
+ if (C_SUPPORTS_NOSTDLIBXX_FLAG )
28
32
set (CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -nostdlib++" )
29
33
else ()
30
34
check_c_compiler_flag(-nodefaultlibs C_SUPPORTS_NODEFAULTLIBS_FLAG)
33
37
endif ()
34
38
endif ()
35
39
36
- if (CXX_SUPPORTS_NOSTDLIBXX_FLAG OR C_SUPPORTS_NODEFAULTLIBS_FLAG)
40
+ if (C_SUPPORTS_NOSTDLIBXX_FLAG OR C_SUPPORTS_NODEFAULTLIBS_FLAG)
37
41
if (LIBCXXABI_HAS_C_LIB)
38
42
list (APPEND CMAKE_REQUIRED_LIBRARIES c)
39
43
endif ()
Original file line number Diff line number Diff line change @@ -93,7 +93,7 @@ if (ANDROID AND ANDROID_PLATFORM_LEVEL LESS 21)
93
93
endif ()
94
94
95
95
# Setup flags.
96
- if (CXX_SUPPORTS_NOSTDLIBXX_FLAG )
96
+ if (C_SUPPORTS_NOSTDLIBXX_FLAG )
97
97
add_link_flags_if_supported(-nostdlib++)
98
98
else ()
99
99
add_link_flags_if_supported(-nodefaultlibs)
Original file line number Diff line number Diff line change @@ -30,9 +30,13 @@ endif()
30
30
# required during compilation (which has the -nostdlib++ or -nodefaultlibs). libc is
31
31
# required for the link to go through. We remove sanitizers from the
32
32
# configuration checks to avoid spurious link errors.
33
+ #
34
+ # Adding flags to CMAKE_REQUIRED_FLAGS will include the flags both when testing
35
+ # compilation of C and C++. Therefore test to make sure that the flags are
36
+ # supported by the C compiler driver, before deciding to include them.
33
37
34
- llvm_check_compiler_linker_flag(CXX "-nostdlib++" CXX_SUPPORTS_NOSTDLIBXX_FLAG )
35
- if (CXX_SUPPORTS_NOSTDLIBXX_FLAG )
38
+ llvm_check_compiler_linker_flag(C "-nostdlib++" C_SUPPORTS_NOSTDLIBXX_FLAG )
39
+ if (C_SUPPORTS_NOSTDLIBXX_FLAG )
36
40
set (CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -nostdlib++" )
37
41
else ()
38
42
llvm_check_compiler_linker_flag(C "-nodefaultlibs" C_SUPPORTS_NODEFAULTLIBS_FLAG)
41
45
endif ()
42
46
endif ()
43
47
44
- if (CXX_SUPPORTS_NOSTDLIBXX_FLAG OR C_SUPPORTS_NODEFAULTLIBS_FLAG)
48
+ if (C_SUPPORTS_NOSTDLIBXX_FLAG OR C_SUPPORTS_NODEFAULTLIBS_FLAG)
45
49
if (LIBUNWIND_HAS_C_LIB)
46
50
list (APPEND CMAKE_REQUIRED_LIBRARIES c)
47
51
endif ()
Original file line number Diff line number Diff line change @@ -139,12 +139,16 @@ endif()
139
139
# Check for -nostdlib++ first; if there's no C++ standard library yet,
140
140
# all check_cxx_compiler_flag commands will fail until we add -nostdlib++
141
141
# (or -nodefaultlibs).
142
- llvm_check_compiler_linker_flag(CXX "-nostdlib++" CXX_SUPPORTS_NOSTDLIBXX_FLAG)
143
- if (CXX_SUPPORTS_NOSTDLIBXX_FLAG)
142
+ #
143
+ # Adding flags to CMAKE_REQUIRED_FLAGS will include the flags both when testing
144
+ # compilation of C and C++. Therefore test to make sure that the flags are
145
+ # supported by the C compiler driver, before deciding to include them.
146
+ llvm_check_compiler_linker_flag(C "-nostdlib++" C_SUPPORTS_NOSTDLIBXX_FLAG)
147
+ if (C_SUPPORTS_NOSTDLIBXX_FLAG)
144
148
set (CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -nostdlib++" )
145
149
endif ()
146
- check_cxx_compiler_flag (-nostdinc++ CXX_SUPPORTS_NOSTDINCXX_FLAG )
147
- if (CXX_SUPPORTS_NOSTDINCXX_FLAG )
150
+ check_c_compiler_flag (-nostdinc++ C_SUPPORTS_NOSTDINCXX_FLAG )
151
+ if (C_SUPPORTS_NOSTDINCXX_FLAG )
148
152
set (CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -nostdinc++" )
149
153
endif ()
150
154
You can’t perform that action at this time.
0 commit comments