diff --git a/debian/patches/fix-unwind-detection-logic.patch b/debian/patches/fix-unwind-detection-logic.patch deleted file mode 100644 index 667432c3..00000000 --- a/debian/patches/fix-unwind-detection-logic.patch +++ /dev/null @@ -1,39 +0,0 @@ -From 7c5e4e5fa3a948fc662be3a6bf057021d32f72e6 Mon Sep 17 00:00:00 2001 -From: =?UTF-8?q?Martin=20Storsj=C3=B6?= -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. diff --git a/debian/patches/runtimes-Don-t-link-against-compiler-rt-explicitly.patch b/debian/patches/runtimes-Don-t-link-against-compiler-rt-explicitly.patch deleted file mode 100644 index 77a35c60..00000000 --- a/debian/patches/runtimes-Don-t-link-against-compiler-rt-explicitly.patch +++ /dev/null @@ -1,169 +0,0 @@ -From 2075c7d921f07d148f096c10f57c3bc43b239870 Mon Sep 17 00:00:00 2001 -From: Louis Dionne -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 - diff --git a/debian/patches/series b/debian/patches/series index 218d718c..9b6c868c 100644 --- a/debian/patches/series +++ b/debian/patches/series @@ -135,8 +135,6 @@ protobuf_3.21.patch # compiler-rt compiler-rt/compilerrt-builtins-arch-fix-armhf.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/wasm-ld-path.diff diff --git a/debian/rules b/debian/rules index 7d4532b7..7c84baaf 100755 --- a/debian/rules +++ b/debian/rules @@ -500,10 +500,6 @@ ifneq (,$(filter $(DEB_HOST_ARCH), mips64 mips64el)) LIBOMP_ARCH = mips64 endif -HAVE_COMPILER_RT := NO -ifeq (,$(filter $(RUNTIMES),compiler-rt)) - HAVE_COMPILER_RT = YES -endif # if cmake is installed in /tmp/cmake/ uses it # Used to build llvm on old ubuntu (precise) on the llvm.org/apt/ ci CMAKE_BIN=cmake @@ -761,7 +757,7 @@ endif -DCOMPILER_RT_USE_LIBCXX=OFF \ -DCOMPILER_RT_USE_BUILTINS_LIBRARY=$(COMPILER_RT_USE_BUILTINS_LIBRARY) \ -DCOMPILER_RT_DEFAULT_TARGET_ONLY=ON \ - -DLIBUNWIND_USE_COMPILER_RT=$(HAVE_COMPILER_RT) \ + -DLIBUNWIND_USE_COMPILER_RT=ON \ -DLIBUNWIND_INSTALL_LIBRARY=OFF \ -DLIBCXXABI_ENABLE_EXCEPTIONS=$(LIBCXX_EXCEPTIONS) \ -DLIBCXXABI_USE_COMPILER_RT=$(LIBCXX_USE_COMPILER_RT) \