[compiler-rt] Reapply [compiler-rt] Check for and use -lunwind when linking with -nodefaultlibs (PR #66584)

Jan Palus via llvm-commits llvm-commits at lists.llvm.org
Thu Apr 11 11:12:33 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)
----------------
jpalus wrote:

Note that one of the implications of this change is that for example on `x86_64` test for `__i386__` symbol existence will fail if `32-bit` version of `libunwind` is not installed:
https://github.com/llvm/llvm-project/blob/43b2b2ebce635bec1e3c060092ea75db858ee3fd/compiler-rt/cmake/base-config-ix.cmake#L209
Although `32-bit libunwind` does not seem to be required.

https://github.com/llvm/llvm-project/pull/66584


More information about the llvm-commits mailing list