Skip to content

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()

@ilovepi ilovepi requested a review from petrhosek November 12, 2024 17:44
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.

Copy link
Member

Choose a reason for hiding this comment

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

TODO: $upper_case is more common than TODO

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good catch. Thx.

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?

@ilovepi
Copy link
Contributor Author

ilovepi commented Dec 7, 2024

ping

Created using spr 1.3.6-beta.1
@ilovepi ilovepi merged commit fac9fcd into main Dec 9, 2024
8 of 11 checks passed
@ilovepi ilovepi deleted the users/ilovepi/spr/libcxxabi-always-link-against-libzircon-for-fuchsia-targets branch December 9, 2024 17:19
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.

5 participants