Skip to content

Commit

Permalink
Reapply [compiler-rt] Check for and use -lunwind when linking with -n…
Browse files Browse the repository at this point in the history
…odefaultlibs (#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.
  • Loading branch information
mstorsjo authored Oct 5, 2023
1 parent 26bb22b commit 7c5e4e5
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions compiler-rt/cmake/config-ix.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit 7c5e4e5

Please sign in to comment.