Skip to content

[libunwind] Use -nostdlib++ when linking libunwind #75646

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Dec 19, 2023

Conversation

ldionne
Copy link
Member

@ldionne ldionne commented Dec 15, 2023

We shouldn't need to link against libc++ or libc++abi when building libunwind, since that would otherwise be a circular dependency.

We shouldn't need to link against libc++ or libc++abi when building
libunwind, since that would otherwise be a circular dependency.
@ldionne ldionne requested a review from petrhosek December 15, 2023 19:44
@ldionne ldionne requested a review from a team as a code owner December 15, 2023 19:44
@llvmbot
Copy link
Member

llvmbot commented Dec 15, 2023

@llvm/pr-subscribers-libunwind

Author: Louis Dionne (ldionne)

Changes

We shouldn't need to link against libc++ or libc++abi when building libunwind, since that would otherwise be a circular dependency.


Full diff: https://github.com/llvm/llvm-project/pull/75646.diff

1 Files Affected:

  • (modified) libunwind/src/CMakeLists.txt (+10-9)
diff --git a/libunwind/src/CMakeLists.txt b/libunwind/src/CMakeLists.txt
index abb019b88ebabd..c0e60f29a3db25 100644
--- a/libunwind/src/CMakeLists.txt
+++ b/libunwind/src/CMakeLists.txt
@@ -66,20 +66,21 @@ set(LIBUNWIND_SOURCES
     ${LIBUNWIND_ASM_SOURCES})
 
 # Generate library list.
-if (LIBUNWIND_USE_COMPILER_RT)
-  add_library_flags("${LIBUNWIND_BUILTINS_LIBRARY}")
+if (CXX_SUPPORTS_NOSTDLIBXX_FLAG)
+  add_link_flags_if_supported(-nostdlib++)
 else()
-  add_library_flags_if(LIBUNWIND_HAS_GCC_S_LIB gcc_s)
-  add_library_flags_if(LIBUNWIND_HAS_GCC_LIB gcc)
-endif()
-if (NOT APPLE) # On Apple platforms, we don't need to link explicitly against system libraries
+  if (LIBUNWIND_USE_COMPILER_RT)
+    add_library_flags("${LIBUNWIND_BUILTINS_LIBRARY}")
+  else()
+    add_library_flags_if(LIBUNWIND_HAS_GCC_S_LIB gcc_s)
+    add_library_flags_if(LIBUNWIND_HAS_GCC_LIB gcc)
+  endif()
   add_library_flags_if(LIBUNWIND_HAS_C_LIB c)
   add_library_flags_if(LIBUNWIND_HAS_DL_LIB dl)
+endif()
 
-  if (LIBUNWIND_ENABLE_THREADS)
+if (LIBUNWIND_ENABLE_THREADS AND NOT APPLE)
     add_library_flags_if(LIBUNWIND_HAS_PTHREAD_LIB pthread)
-    add_compile_flags_if(LIBUNWIND_WEAK_PTHREAD_LIB -DLIBUNWIND_USE_WEAK_PTHREAD=1)
-  endif()
 endif()
 
 if (LIBUNWIND_ENABLE_THREADS)

@ldionne ldionne merged commit ab41ea4 into llvm:main Dec 19, 2023
@ldionne ldionne deleted the review/use-nostdlibxx-in-libunwind branch December 19, 2023 14:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants