Skip to content

Commit f12cdda

Browse files
committed
Reapply [compiler-rt] Check for and use -lunwind when linking with -nodefaultlibs
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.
1 parent afe4006 commit f12cdda

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

compiler-rt/cmake/config-ix.cmake

+10
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,16 @@ if (C_SUPPORTS_NODEFAULTLIBS_FLAG)
6363
moldname mingwex msvcrt)
6464
list(APPEND CMAKE_REQUIRED_LIBRARIES ${MINGW_LIBRARIES})
6565
endif()
66+
if (NOT TARGET unwind)
67+
# Don't check for a library named unwind, if there's a target with that name within
68+
# the same build.
69+
check_library_exists(unwind _Unwind_GetRegionStart "" COMPILER_RT_HAS_LIBUNWIND)
70+
if (COMPILER_RT_HAS_LIBUNWIND)
71+
# If we're omitting default libraries, we might need to manually link in libunwind.
72+
# This can affect whether we detect a statically linked libc++ correctly.
73+
list(APPEND CMAKE_REQUIRED_LIBRARIES unwind)
74+
endif()
75+
endif()
6676
endif ()
6777

6878
# CodeGen options.

0 commit comments

Comments
 (0)