Skip to content
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

[libcxxabi] Always link against libzircon for Fuchsia targets #115910

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

ilovepi
Copy link
Contributor

@ilovepi ilovepi commented Nov 12, 2024

When using LTO, the deplibs mechanism is insufficient to ensure that libzircon
is always brought into the link prior to LTO code generation. The general
problem is discussed in depth in
#56070

To work around this, we can just provide libzircon as a link input.

Created using spr 1.3.4
@ilovepi ilovepi requested a review from a team as a code owner November 12, 2024 17:39
@llvmbot llvmbot added the libc++abi libc++abi C++ Runtime Library. Not libc++. label Nov 12, 2024
@llvmbot
Copy link
Member

llvmbot commented Nov 12, 2024

@llvm/pr-subscribers-libcxxabi

Author: Paul Kirth (ilovepi)

Changes

When using LTO, the deplibs mechanism is insufficient to ensure that libzircon
is always brought into the link prior to LTO code generation. The general
problem is discussed in depth in
#56070

To work around this, we can just provide libzircon as a link input.


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

1 Files Affected:

  • (modified) libcxxabi/src/CMakeLists.txt (+4)
diff --git a/libcxxabi/src/CMakeLists.txt b/libcxxabi/src/CMakeLists.txt
index 84fe2784bec5ca..5a384c5345d755 100644
--- a/libcxxabi/src/CMakeLists.txt
+++ b/libcxxabi/src/CMakeLists.txt
@@ -75,6 +75,10 @@ if (NOT APPLE) # On Apple platforms, we always use -nostdlib++ so we don't need
   add_library_flags_if(LIBCXXABI_HAS_C_LIB c)
 endif()
 
+if (FUCHSIA)
+    add_library_flags(zircon)
+endif()
+
 if (NOT LIBCXXABI_USE_COMPILER_RT)
   add_library_flags_if(LIBCXXABI_HAS_GCC_LIB gcc)
 endif()

@@ -75,6 +75,10 @@ if (NOT APPLE) # On Apple platforms, we always use -nostdlib++ so we don't need
add_library_flags_if(LIBCXXABI_HAS_C_LIB c)
endif()

if (FUCHSIA)
add_link_flags("-Wl,--push-state,--as-needed,-lzircon,--pop-state")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd leave a TODO comment to use https://cmake.org/cmake/help/latest/variable/CMAKE_LINK_LIBRARY_USING_FEATURE.html once LLVM requires CMake at least 3.24.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done.

Created using spr 1.3.6-beta.1
@ilovepi
Copy link
Contributor Author

ilovepi commented Nov 20, 2024

ping. Can someone for @llvm/reviewers-libcxxabi take a look at this please?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
libc++abi libc++abi C++ Runtime Library. Not libc++.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants