[compiler-rt] Reapply [compiler-rt] Check for and use -lunwind when linking with -nodefaultlibs (PR #66584)
Martin Storsjö via llvm-commits
llvm-commits at lists.llvm.org
Thu Apr 11 13:16:12 PDT 2024
================
@@ -63,6 +63,16 @@ if (C_SUPPORTS_NODEFAULTLIBS_FLAG)
moldname mingwex msvcrt)
list(APPEND CMAKE_REQUIRED_LIBRARIES ${MINGW_LIBRARIES})
endif()
+ if (NOT TARGET unwind)
+ # Don't check for a library named unwind, if there's a target with that name within
+ # the same build.
+ check_library_exists(unwind _Unwind_GetRegionStart "" COMPILER_RT_HAS_LIBUNWIND)
+ if (COMPILER_RT_HAS_LIBUNWIND)
+ # If we're omitting default libraries, we might need to manually link in libunwind.
+ # This can affect whether we detect a statically linked libc++ correctly.
+ list(APPEND CMAKE_REQUIRED_LIBRARIES unwind)
----------------
mstorsjo wrote:
Hmm, so you have an x86_64 libunwind, and enough 32 bit libraries, so that compilation with `-m32` works, but as we detected the x86_64 libunwind we now also require linking libunwind in all other tests, which makes the test for `-m32` fail suddenly.
That's unfortunate...
@petrhosek Do you have any good ideas about how to handle this? In principle, I think the whole handling of multiple archs (like compiler-rt does, when building both x86_64 and i386 in the same cmake invocation) to be kind of wrong - ideally each arch build should be a separate cmake configuration of all the runtimes, so that all the tests are done specifically for that arch. But untangling those bits of compiler-rt is outside of what I want to take on.
https://github.com/llvm/llvm-project/pull/66584
More information about the llvm-commits
mailing list