Skip to content

Commit

Permalink
[compiler-rt] Check for and use -lunwind when linking with -nodefault…
Browse files Browse the repository at this point in the history
…libs (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.
  • Loading branch information
mstorsjo authored and ZijunZhaoCCK committed Sep 19, 2023
1 parent 3d2c132 commit 57ad287
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions compiler-rt/cmake/config-ix.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,12 @@ if (C_SUPPORTS_NODEFAULTLIBS_FLAG)
moldname mingwex msvcrt)
list(APPEND CMAKE_REQUIRED_LIBRARIES ${MINGW_LIBRARIES})
endif()
check_library_exists(unwind _Unwind_RaiseException "" 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 ()

# CodeGen options.
Expand Down

0 comments on commit 57ad287

Please sign in to comment.