Skip to content

Commit 102bc63

Browse files
committed
[runtime] Build compiler-rt with --unwindlib=none
This applies the change made to libunwind+libcxxabi+libcxx in D113253 to compiler-rt as well. Differential Revision: https://reviews.llvm.org/D115674
1 parent d773269 commit 102bc63

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

compiler-rt/CMakeLists.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -506,6 +506,11 @@ list(APPEND COMPILER_RT_COMMON_LINK_FLAGS ${stdlib_flag})
506506

507507
macro(append_libcxx_libs var)
508508
if (${var}_INTREE)
509+
# If we're linking directly against the libunwind that we're building
510+
# in the same invocation, don't try to link in the toolchain's
511+
# default libunwind (which may be missing still).
512+
append_list_if(CXX_SUPPORTS_UNWINDLIB_NONE_FLAG --unwindlib=none SANITIZER_COMMON_LINK_FLAGS)
513+
509514
if (SANITIZER_USE_STATIC_LLVM_UNWINDER AND (TARGET unwind_static OR HAVE_LIBUNWIND))
510515
list(APPEND ${var}_LIBRARIES unwind_static)
511516
elseif (TARGET unwind_shared OR HAVE_LIBUNWIND)

compiler-rt/cmake/config-ix.cmake

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,22 @@ include(CheckCCompilerFlag)
44
include(CheckCXXCompilerFlag)
55
include(CheckIncludeFiles)
66
include(CheckLibraryExists)
7+
include(LLVMCheckCompilerLinkerFlag)
78
include(CheckSymbolExists)
89
include(TestBigEndian)
910

11+
# The compiler driver may be implicitly trying to link against libunwind.
12+
# This is normally ok (libcxx relies on an unwinder), but if libunwind is
13+
# built in the same cmake invocation as compiler-rt and we're using the
14+
# in tree version of runtimes, we'd be linking against the just-built
15+
# libunwind (and the compiler implicit -lunwind wouldn't succeed as the newly
16+
# built libunwind isn't installed yet). For those cases, it'd be good to
17+
# link with --uwnindlib=none. Check if that option works.
18+
llvm_check_compiler_linker_flag(C "--unwindlib=none" CXX_SUPPORTS_UNWINDLIB_NONE_FLAG)
19+
if (CXX_SUPPORTS_UNWINDLIB_NONE_FLAG)
20+
set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} --unwindlib=none")
21+
endif()
22+
1023
check_library_exists(c fopen "" COMPILER_RT_HAS_LIBC)
1124
if (COMPILER_RT_USE_BUILTINS_LIBRARY)
1225
include(HandleCompilerRT)

0 commit comments

Comments
 (0)