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

via llvm-commits llvm-commits at lists.llvm.org
Thu Oct 5 01:41:16 PDT 2023


Author: Martin Storsjö
Date: 2023-10-05T11:41:11+03:00
New Revision: 7c5e4e5fa3a948fc662be3a6bf057021d32f72e6

URL: https://github.com/llvm/llvm-project/commit/7c5e4e5fa3a948fc662be3a6bf057021d32f72e6
DIFF: https://github.com/llvm/llvm-project/commit/7c5e4e5fa3a948fc662be3a6bf057021d32f72e6.diff

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

If libc++ is available and should be used as the ubsan C++ ABI library,
the check for libc++ might fail if libc++ is a static library, as the
-nodefaultlibs flag inhibits a potential compiler default -lunwind.

Just like the -nodefaultlibs configuration tests for and manually adds a
bunch of compiler default libraries, look for -lunwind too.

This is a reland of #65912.

Added: 
    

Modified: 
    compiler-rt/cmake/config-ix.cmake

Removed: 
    


################################################################################
diff  --git a/compiler-rt/cmake/config-ix.cmake b/compiler-rt/cmake/config-ix.cmake
index 09a9b62ce4cd37b..a8e078f1ebc9888 100644
--- a/compiler-rt/cmake/config-ix.cmake
+++ b/compiler-rt/cmake/config-ix.cmake
@@ -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)
+    endif()
+  endif()
 endif ()
 
 # CodeGen options.


        


More information about the llvm-commits mailing list