Skip to content

Commit ab41ea4

Browse files
authored
[libunwind] Use -nostdlib++ when linking libunwind (#75646)
We shouldn't need to link against libc++ or libc++abi when building libunwind, since that would otherwise be a circular dependency.
1 parent e9af57d commit ab41ea4

File tree

1 file changed

+13
-9
lines changed

1 file changed

+13
-9
lines changed

libunwind/src/CMakeLists.txt

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -66,20 +66,24 @@ set(LIBUNWIND_SOURCES
6666
${LIBUNWIND_ASM_SOURCES})
6767

6868
# Generate library list.
69-
if (LIBUNWIND_USE_COMPILER_RT)
70-
add_library_flags("${LIBUNWIND_BUILTINS_LIBRARY}")
69+
if (CXX_SUPPORTS_NOSTDLIBXX_FLAG)
70+
add_link_flags_if_supported(-nostdlib++)
7171
else()
72-
add_library_flags_if(LIBUNWIND_HAS_GCC_S_LIB gcc_s)
73-
add_library_flags_if(LIBUNWIND_HAS_GCC_LIB gcc)
74-
endif()
75-
if (NOT APPLE) # On Apple platforms, we don't need to link explicitly against system libraries
72+
if (LIBUNWIND_USE_COMPILER_RT)
73+
add_library_flags("${LIBUNWIND_BUILTINS_LIBRARY}")
74+
else()
75+
add_library_flags_if(LIBUNWIND_HAS_GCC_S_LIB gcc_s)
76+
add_library_flags_if(LIBUNWIND_HAS_GCC_LIB gcc)
77+
endif()
7678
add_library_flags_if(LIBUNWIND_HAS_C_LIB c)
79+
endif()
80+
81+
if (NOT APPLE)
7782
add_library_flags_if(LIBUNWIND_HAS_DL_LIB dl)
83+
endif()
7884

79-
if (LIBUNWIND_ENABLE_THREADS)
85+
if (LIBUNWIND_ENABLE_THREADS AND NOT APPLE)
8086
add_library_flags_if(LIBUNWIND_HAS_PTHREAD_LIB pthread)
81-
add_compile_flags_if(LIBUNWIND_WEAK_PTHREAD_LIB -DLIBUNWIND_USE_WEAK_PTHREAD=1)
82-
endif()
8387
endif()
8488

8589
if (LIBUNWIND_ENABLE_THREADS)

0 commit comments

Comments
 (0)