mirror of
https://git.proxmox.com/git/llvm-toolchain
synced 2025-08-07 01:03:08 +00:00
Drop compiler-rt hacks
This commit is contained in:
parent
5ca2adc357
commit
e5f5a75f7d
39
debian/patches/fix-unwind-detection-logic.patch
vendored
39
debian/patches/fix-unwind-detection-logic.patch
vendored
@ -1,39 +0,0 @@
|
|||||||
From 7c5e4e5fa3a948fc662be3a6bf057021d32f72e6 Mon Sep 17 00:00:00 2001
|
|
||||||
From: =?UTF-8?q?Martin=20Storsj=C3=B6?= <martin@martin.st>
|
|
||||||
Date: Thu, 5 Oct 2023 11:41:11 +0300
|
|
||||||
Subject: [PATCH] Reapply [compiler-rt] Check for and use -lunwind when linking
|
|
||||||
with -nodefaultlibs (#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.
|
|
||||||
---
|
|
||||||
compiler-rt/cmake/config-ix.cmake | 10 ++++++++++
|
|
||||||
1 file changed, 10 insertions(+)
|
|
||||||
|
|
||||||
diff --git a/compiler-rt/cmake/config-ix.cmake b/compiler-rt/cmake/config-ix.cmake
|
|
||||||
index 09a9b62ce4cd37..a8e078f1ebc988 100644
|
|
||||||
--- a/compiler-rt/cmake/config-ix.cmake
|
|
||||||
+++ b/compiler-rt/cmake/config-ix.cmake
|
|
||||||
@@ -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.
|
|
@ -1,169 +0,0 @@
|
|||||||
From 2075c7d921f07d148f096c10f57c3bc43b239870 Mon Sep 17 00:00:00 2001
|
|
||||||
From: Louis Dionne <ldionne.2@gmail.com>
|
|
||||||
Date: Wed, 13 Dec 2023 13:57:48 -0500
|
|
||||||
Subject: [PATCH 2/2] [runtimes] Don't link against compiler-rt explicitly when
|
|
||||||
we use -nostdlib++ (#75089)
|
|
||||||
|
|
||||||
When we use the -nostdlib++ flag, we don't need to explicitly link
|
|
||||||
against compiler-rt, since the compiler already links against it by
|
|
||||||
default. This simplifies the flags that we need to use when building
|
|
||||||
with Clang and GCC, and opens the door to further simplifications since
|
|
||||||
most platforms won't need to detect whether libgcc and libgcc_s are
|
|
||||||
supported anymore.
|
|
||||||
|
|
||||||
Furthermore, on platforms where -nostdlib++ is used, this patch prevents
|
|
||||||
manually linking compiler-rt *before* other system libraries. For
|
|
||||||
example, Apple platforms have several compiler-rt symbols defined in
|
|
||||||
libSystem.dylib. If we manually link against compiler-rt, we end up
|
|
||||||
overriding the default link order preferred by the compiler and
|
|
||||||
potentially using the symbols from the clang-provided libclang_rt.a
|
|
||||||
library instead of the system provided one.
|
|
||||||
|
|
||||||
Note that we don't touch how libunwind links against compiler-rt when it
|
|
||||||
builds the .so/.a because libunwind currently doesn't use -nodefaultlibs
|
|
||||||
and we want to avoid rocking the boat too much.
|
|
||||||
|
|
||||||
rdar://119506163
|
|
||||||
---
|
|
||||||
libcxx/CMakeLists.txt | 30 ++++++++++++++++--------------
|
|
||||||
libcxx/cmake/config-ix.cmake | 7 ++++++-
|
|
||||||
libcxxabi/cmake/config-ix.cmake | 7 ++++++-
|
|
||||||
libcxxabi/src/CMakeLists.txt | 5 ++++-
|
|
||||||
libunwind/cmake/config-ix.cmake | 7 ++++++-
|
|
||||||
5 files changed, 38 insertions(+), 18 deletions(-)
|
|
||||||
|
|
||||||
diff --git a/libcxx/CMakeLists.txt b/libcxx/CMakeLists.txt
|
|
||||||
index e1f12549c9ec..3423348decfb 100644
|
|
||||||
--- a/libcxx/CMakeLists.txt
|
|
||||||
+++ b/libcxx/CMakeLists.txt
|
|
||||||
@@ -666,20 +666,22 @@ function(cxx_link_system_libraries target)
|
|
||||||
target_link_libraries(${target} PRIVATE rt)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
- if (LIBCXX_USE_COMPILER_RT)
|
|
||||||
- find_compiler_rt_library(builtins LIBCXX_BUILTINS_LIBRARY)
|
|
||||||
- if (LIBCXX_BUILTINS_LIBRARY)
|
|
||||||
- target_link_libraries(${target} PRIVATE "${LIBCXX_BUILTINS_LIBRARY}")
|
|
||||||
- endif()
|
|
||||||
- elseif (LIBCXX_HAS_GCC_LIB)
|
|
||||||
- target_link_libraries(${target} PRIVATE gcc)
|
|
||||||
- if (LIBCXX_HAS_ATOMIC_LIB)
|
|
||||||
- target_link_libraries(${target} PRIVATE atomic)
|
|
||||||
- endif()
|
|
||||||
- elseif (LIBCXX_HAS_GCC_S_LIB)
|
|
||||||
- target_link_libraries(${target} PRIVATE gcc_s)
|
|
||||||
- if (LIBCXX_HAS_ATOMIC_LIB)
|
|
||||||
- target_link_libraries(${target} PRIVATE atomic)
|
|
||||||
+ if (MSVC)
|
|
||||||
+ if (LIBCXX_USE_COMPILER_RT)
|
|
||||||
+ find_compiler_rt_library(builtins LIBCXX_BUILTINS_LIBRARY)
|
|
||||||
+ if (LIBCXX_BUILTINS_LIBRARY)
|
|
||||||
+ target_link_libraries(${target} PRIVATE "${LIBCXX_BUILTINS_LIBRARY}")
|
|
||||||
+ endif()
|
|
||||||
+ elseif (LIBCXX_HAS_GCC_LIB)
|
|
||||||
+ target_link_libraries(${target} PRIVATE gcc)
|
|
||||||
+ if (LIBCXX_HAS_ATOMIC_LIB)
|
|
||||||
+ target_link_libraries(${target} PRIVATE atomic)
|
|
||||||
+ endif()
|
|
||||||
+ elseif (LIBCXX_HAS_GCC_S_LIB)
|
|
||||||
+ target_link_libraries(${target} PRIVATE gcc_s)
|
|
||||||
+ if (LIBCXX_HAS_ATOMIC_LIB)
|
|
||||||
+ target_link_libraries(${target} PRIVATE atomic)
|
|
||||||
+ endif()
|
|
||||||
endif()
|
|
||||||
endif()
|
|
||||||
|
|
||||||
diff --git a/libcxx/cmake/config-ix.cmake b/libcxx/cmake/config-ix.cmake
|
|
||||||
index 3bae53643683..19b112f36318 100644
|
|
||||||
--- a/libcxx/cmake/config-ix.cmake
|
|
||||||
+++ b/libcxx/cmake/config-ix.cmake
|
|
||||||
@@ -53,7 +53,9 @@ else()
|
|
||||||
endif()
|
|
||||||
endif()
|
|
||||||
|
|
||||||
-if (CXX_SUPPORTS_NOSTDLIBXX_FLAG OR C_SUPPORTS_NODEFAULTLIBS_FLAG)
|
|
||||||
+# Only link against compiler-rt manually if we use -nodefaultlibs, since
|
|
||||||
+# otherwise the compiler will do the right thing on its own.
|
|
||||||
+if (NOT CXX_SUPPORTS_NOSTDLIBXX_FLAG AND C_SUPPORTS_NODEFAULTLIBS_FLAG)
|
|
||||||
if (LIBCXX_HAS_C_LIB)
|
|
||||||
list(APPEND CMAKE_REQUIRED_LIBRARIES c)
|
|
||||||
endif ()
|
|
||||||
@@ -84,6 +86,9 @@ if (CXX_SUPPORTS_NOSTDLIBXX_FLAG OR C_SUPPORTS_NODEFAULTLIBS_FLAG)
|
|
||||||
moldname mingwex msvcrt)
|
|
||||||
list(APPEND CMAKE_REQUIRED_LIBRARIES ${MINGW_LIBRARIES})
|
|
||||||
endif()
|
|
||||||
+endif()
|
|
||||||
+
|
|
||||||
+if (CXX_SUPPORTS_NOSTDLIBXX_FLAG OR C_SUPPORTS_NODEFAULTLIBS_FLAG)
|
|
||||||
if (CMAKE_C_FLAGS MATCHES -fsanitize OR CMAKE_CXX_FLAGS MATCHES -fsanitize)
|
|
||||||
set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -fno-sanitize=all")
|
|
||||||
endif ()
|
|
||||||
diff --git a/libcxxabi/cmake/config-ix.cmake b/libcxxabi/cmake/config-ix.cmake
|
|
||||||
index f4ee8946c1fe..a5daf6e48f77 100644
|
|
||||||
--- a/libcxxabi/cmake/config-ix.cmake
|
|
||||||
+++ b/libcxxabi/cmake/config-ix.cmake
|
|
||||||
@@ -33,7 +33,9 @@ else()
|
|
||||||
endif()
|
|
||||||
endif()
|
|
||||||
|
|
||||||
-if (CXX_SUPPORTS_NOSTDLIBXX_FLAG OR C_SUPPORTS_NODEFAULTLIBS_FLAG)
|
|
||||||
+# Only link against compiler-rt manually if we use -nodefaultlibs, since
|
|
||||||
+# otherwise the compiler will do the right thing on its own.
|
|
||||||
+if (NOT CXX_SUPPORTS_NOSTDLIBXX_FLAG AND C_SUPPORTS_NODEFAULTLIBS_FLAG)
|
|
||||||
if (LIBCXXABI_HAS_C_LIB)
|
|
||||||
list(APPEND CMAKE_REQUIRED_LIBRARIES c)
|
|
||||||
endif ()
|
|
||||||
@@ -67,6 +69,9 @@ if (CXX_SUPPORTS_NOSTDLIBXX_FLAG OR C_SUPPORTS_NODEFAULTLIBS_FLAG)
|
|
||||||
moldname mingwex msvcrt)
|
|
||||||
list(APPEND CMAKE_REQUIRED_LIBRARIES ${MINGW_LIBRARIES})
|
|
||||||
endif()
|
|
||||||
+endif()
|
|
||||||
+
|
|
||||||
+if (CXX_SUPPORTS_NOSTDLIBXX_FLAG OR C_SUPPORTS_NODEFAULTLIBS_FLAG)
|
|
||||||
if (CMAKE_C_FLAGS MATCHES -fsanitize OR CMAKE_CXX_FLAGS MATCHES -fsanitize)
|
|
||||||
set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -fno-sanitize=all")
|
|
||||||
endif ()
|
|
||||||
diff --git a/libcxxabi/src/CMakeLists.txt b/libcxxabi/src/CMakeLists.txt
|
|
||||||
index 54002bafa0e2..a5fe833a10e2 100644
|
|
||||||
--- a/libcxxabi/src/CMakeLists.txt
|
|
||||||
+++ b/libcxxabi/src/CMakeLists.txt
|
|
||||||
@@ -167,7 +167,10 @@ if (LIBCXXABI_USE_LLVM_UNWINDER)
|
|
||||||
target_link_libraries(cxxabi_shared_objects PUBLIC unwind_shared)
|
|
||||||
endif()
|
|
||||||
endif()
|
|
||||||
-target_link_libraries(cxxabi_shared_objects PRIVATE cxx-headers ${LIBCXXABI_BUILTINS_LIBRARY} ${LIBCXXABI_SHARED_LIBRARIES} ${LIBCXXABI_LIBRARIES})
|
|
||||||
+target_link_libraries(cxxabi_shared_objects PRIVATE cxx-headers ${LIBCXXABI_LIBRARIES} ${LIBCXXABI_SHARED_LIBRARIES})
|
|
||||||
+if (NOT CXX_SUPPORTS_NOSTDLIBXX_FLAG)
|
|
||||||
+ target_link_libraries(cxxabi_shared_objects PRIVATE ${LIBCXXABI_BUILTINS_LIBRARY})
|
|
||||||
+endif()
|
|
||||||
target_link_libraries(cxxabi_shared_objects PUBLIC cxxabi-headers)
|
|
||||||
set_target_properties(cxxabi_shared_objects
|
|
||||||
PROPERTIES
|
|
||||||
diff --git a/libunwind/cmake/config-ix.cmake b/libunwind/cmake/config-ix.cmake
|
|
||||||
index d311477f02c6..d07c441bbd8a 100644
|
|
||||||
--- a/libunwind/cmake/config-ix.cmake
|
|
||||||
+++ b/libunwind/cmake/config-ix.cmake
|
|
||||||
@@ -41,7 +41,9 @@ else()
|
|
||||||
endif()
|
|
||||||
endif()
|
|
||||||
|
|
||||||
-if (CXX_SUPPORTS_NOSTDLIBXX_FLAG OR C_SUPPORTS_NODEFAULTLIBS_FLAG)
|
|
||||||
+# Only link against compiler-rt manually if we use -nodefaultlibs, since
|
|
||||||
+# otherwise the compiler will do the right thing on its own.
|
|
||||||
+if (NOT CXX_SUPPORTS_NOSTDLIBXX_FLAG AND C_SUPPORTS_NODEFAULTLIBS_FLAG)
|
|
||||||
if (LIBUNWIND_HAS_C_LIB)
|
|
||||||
list(APPEND CMAKE_REQUIRED_LIBRARIES c)
|
|
||||||
endif ()
|
|
||||||
@@ -71,6 +73,9 @@ if (CXX_SUPPORTS_NOSTDLIBXX_FLAG OR C_SUPPORTS_NODEFAULTLIBS_FLAG)
|
|
||||||
moldname mingwex msvcrt)
|
|
||||||
list(APPEND CMAKE_REQUIRED_LIBRARIES ${MINGW_LIBRARIES})
|
|
||||||
endif()
|
|
||||||
+endif()
|
|
||||||
+
|
|
||||||
+if (CXX_SUPPORTS_NOSTDLIBXX_FLAG OR C_SUPPORTS_NODEFAULTLIBS_FLAG)
|
|
||||||
if (CMAKE_C_FLAGS MATCHES -fsanitize OR CMAKE_CXX_FLAGS MATCHES -fsanitize)
|
|
||||||
set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -fno-sanitize=all")
|
|
||||||
endif ()
|
|
||||||
--
|
|
||||||
2.44.0
|
|
||||||
|
|
2
debian/patches/series
vendored
2
debian/patches/series
vendored
@ -135,8 +135,6 @@ protobuf_3.21.patch
|
|||||||
# compiler-rt
|
# compiler-rt
|
||||||
compiler-rt/compilerrt-builtins-arch-fix-armhf.diff
|
compiler-rt/compilerrt-builtins-arch-fix-armhf.diff
|
||||||
compiler-rt/compilerrt-build-scudo-standalone-option.diff
|
compiler-rt/compilerrt-build-scudo-standalone-option.diff
|
||||||
fix-unwind-detection-logic.patch
|
|
||||||
runtimes-Don-t-link-against-compiler-rt-explicitly.patch
|
|
||||||
|
|
||||||
# wasm patches
|
# wasm patches
|
||||||
wasm/wasm-ld-path.diff
|
wasm/wasm-ld-path.diff
|
||||||
|
6
debian/rules
vendored
6
debian/rules
vendored
@ -500,10 +500,6 @@ ifneq (,$(filter $(DEB_HOST_ARCH), mips64 mips64el))
|
|||||||
LIBOMP_ARCH = mips64
|
LIBOMP_ARCH = mips64
|
||||||
endif
|
endif
|
||||||
|
|
||||||
HAVE_COMPILER_RT := NO
|
|
||||||
ifeq (,$(filter $(RUNTIMES),compiler-rt))
|
|
||||||
HAVE_COMPILER_RT = YES
|
|
||||||
endif
|
|
||||||
# if cmake is installed in /tmp/cmake/ uses it
|
# if cmake is installed in /tmp/cmake/ uses it
|
||||||
# Used to build llvm on old ubuntu (precise) on the llvm.org/apt/ ci
|
# Used to build llvm on old ubuntu (precise) on the llvm.org/apt/ ci
|
||||||
CMAKE_BIN=cmake
|
CMAKE_BIN=cmake
|
||||||
@ -761,7 +757,7 @@ endif
|
|||||||
-DCOMPILER_RT_USE_LIBCXX=OFF \
|
-DCOMPILER_RT_USE_LIBCXX=OFF \
|
||||||
-DCOMPILER_RT_USE_BUILTINS_LIBRARY=$(COMPILER_RT_USE_BUILTINS_LIBRARY) \
|
-DCOMPILER_RT_USE_BUILTINS_LIBRARY=$(COMPILER_RT_USE_BUILTINS_LIBRARY) \
|
||||||
-DCOMPILER_RT_DEFAULT_TARGET_ONLY=ON \
|
-DCOMPILER_RT_DEFAULT_TARGET_ONLY=ON \
|
||||||
-DLIBUNWIND_USE_COMPILER_RT=$(HAVE_COMPILER_RT) \
|
-DLIBUNWIND_USE_COMPILER_RT=ON \
|
||||||
-DLIBUNWIND_INSTALL_LIBRARY=OFF \
|
-DLIBUNWIND_INSTALL_LIBRARY=OFF \
|
||||||
-DLIBCXXABI_ENABLE_EXCEPTIONS=$(LIBCXX_EXCEPTIONS) \
|
-DLIBCXXABI_ENABLE_EXCEPTIONS=$(LIBCXX_EXCEPTIONS) \
|
||||||
-DLIBCXXABI_USE_COMPILER_RT=$(LIBCXX_USE_COMPILER_RT) \
|
-DLIBCXXABI_USE_COMPILER_RT=$(LIBCXX_USE_COMPILER_RT) \
|
||||||
|
Loading…
Reference in New Issue
Block a user