Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/llvm/llvm-project.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPetr Hosek <phosek@google.com>2022-04-27 09:23:53 +0300
committerPetr Hosek <phosek@google.com>2022-05-07 03:36:17 +0300
commitfecad835fb4c6e65eb487fc626355686959605f6 (patch)
treea4b3410924f7d9645c55b3cfbb6c0f86626c1f2f /compiler-rt
parent57636c25904e05c6b94370c82e52a89f5baf80f1 (diff)
[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
Diffstat (limited to 'compiler-rt')
-rw-r--r--compiler-rt/CMakeLists.txt5
-rw-r--r--compiler-rt/cmake/config-ix.cmake13
2 files changed, 18 insertions, 0 deletions
diff --git a/compiler-rt/CMakeLists.txt b/compiler-rt/CMakeLists.txt
index 84575b49079c..fe08fef5125f 100644
--- a/compiler-rt/CMakeLists.txt
+++ b/compiler-rt/CMakeLists.txt
@@ -506,6 +506,11 @@ list(APPEND COMPILER_RT_COMMON_LINK_FLAGS ${stdlib_flag})
macro(append_libcxx_libs var)
if (${var}_INTREE)
+ # If we're linking directly against the libunwind that we're building
+ # in the same invocation, don't try to link in the toolchain's
+ # default libunwind (which may be missing still).
+ append_list_if(CXX_SUPPORTS_UNWINDLIB_NONE_FLAG --unwindlib=none SANITIZER_COMMON_LINK_FLAGS)
+
if (SANITIZER_USE_STATIC_LLVM_UNWINDER AND (TARGET unwind_static OR HAVE_LIBUNWIND))
list(APPEND ${var}_LIBRARIES unwind_static)
elseif (TARGET unwind_shared OR HAVE_LIBUNWIND)
diff --git a/compiler-rt/cmake/config-ix.cmake b/compiler-rt/cmake/config-ix.cmake
index 8cd80590258a..ceea657795a4 100644
--- a/compiler-rt/cmake/config-ix.cmake
+++ b/compiler-rt/cmake/config-ix.cmake
@@ -4,9 +4,22 @@ include(CheckCCompilerFlag)
include(CheckCXXCompilerFlag)
include(CheckIncludeFiles)
include(CheckLibraryExists)
+include(CheckLinkerFlag)
include(CheckSymbolExists)
include(TestBigEndian)
+# The compiler driver may be implicitly trying to link against libunwind.
+# This is normally ok (libcxx relies on an unwinder), but if libunwind is
+# built in the same cmake invocation as compiler-rt and we're using the
+# in tree version of runtimes, we'd be linking against the just-built
+# libunwind (and the compiler implicit -lunwind wouldn't succeed as the newly
+# built libunwind isn't installed yet). For those cases, it'd be good to
+# link with --uwnindlib=none. Check if that option works.
+llvm_check_linker_flag(CXX "--unwindlib=none" CXX_SUPPORTS_UNWINDLIB_NONE_FLAG)
+if (CXX_SUPPORTS_UNWINDLIB_NONE_FLAG)
+ set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} --unwindlib=none")
+endif()
+
check_library_exists(c fopen "" COMPILER_RT_HAS_LIBC)
if (COMPILER_RT_USE_BUILTINS_LIBRARY)
include(HandleCompilerRT)