Skip to content

Commit 64c0bdd

Browse files
authored
[compiler-rt] Check for and use -lunwind when linking with -nodefaultlibs (llvm#65912)
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.
1 parent 85370b3 commit 64c0bdd

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

compiler-rt/cmake/config-ix.cmake

+6
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,12 @@ if (C_SUPPORTS_NODEFAULTLIBS_FLAG)
6363
moldname mingwex msvcrt)
6464
list(APPEND CMAKE_REQUIRED_LIBRARIES ${MINGW_LIBRARIES})
6565
endif()
66+
check_library_exists(unwind _Unwind_RaiseException "" COMPILER_RT_HAS_LIBUNWIND)
67+
if (COMPILER_RT_HAS_LIBUNWIND)
68+
# If we're omitting default libraries, we might need to manually link in libunwind.
69+
# This can affect whether we detect a statically linked libc++ correctly.
70+
list(APPEND CMAKE_REQUIRED_LIBRARIES unwind)
71+
endif()
6672
endif ()
6773

6874
# CodeGen options.

0 commit comments

Comments
 (0)