Skip to content

Commit b4ae01b

Browse files
committed
[libunwind] Don't override LINKER_LANGUAGE (#98440)
libunwind's GCC build fails because it tested `-nostdlib++` flag against C++ linker but then use C linker to perform final linking, while gcc doesn't support this flag but g++ does. The rationale for setting LINKER_LANGUAGE to C is to avoid pulling in C++ standard libraries. However this is already guaranteed by the combination of `-nostdlib++` and `empty CMAKE_CXX_IMPLICIT_LINK_LIBRARIES`, thus we can safely remove this override. However, in case `-nostdlib++` is unsupported, we need to use `-nodefaultlibs` and link against rtlib & libc manually.
1 parent 649020c commit b4ae01b

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

libunwind/src/CMakeLists.txt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,9 @@ set(LIBUNWIND_SOURCES
7474
if (CXX_SUPPORTS_NOSTDLIBXX_FLAG)
7575
add_link_flags_if_supported(-nostdlib++)
7676
else()
77+
if (C_SUPPORTS_NODEFAULTLIBS_FLAG)
78+
add_link_flags_if_supported(-nodefaultlibs)
79+
endif()
7780
if (LIBUNWIND_USE_COMPILER_RT)
7881
add_library_flags("${LIBUNWIND_BUILTINS_LIBRARY}")
7982
else()
@@ -164,7 +167,6 @@ set_target_properties(unwind_shared
164167
PROPERTIES
165168
EXCLUDE_FROM_ALL "$<IF:$<BOOL:${LIBUNWIND_ENABLE_SHARED}>,FALSE,TRUE>"
166169
LINK_FLAGS "${LIBUNWIND_LINK_FLAGS}"
167-
LINKER_LANGUAGE C
168170
OUTPUT_NAME "${LIBUNWIND_SHARED_OUTPUT_NAME}"
169171
VERSION "${LIBUNWIND_LIBRARY_VERSION}"
170172
SOVERSION "1"
@@ -211,7 +213,6 @@ set_target_properties(unwind_static
211213
PROPERTIES
212214
EXCLUDE_FROM_ALL "$<IF:$<BOOL:${LIBUNWIND_ENABLE_STATIC}>,FALSE,TRUE>"
213215
LINK_FLAGS "${LIBUNWIND_LINK_FLAGS}"
214-
LINKER_LANGUAGE C
215216
OUTPUT_NAME "${LIBUNWIND_STATIC_OUTPUT_NAME}"
216217
)
217218

0 commit comments

Comments
 (0)