Initial stub of a Makefile and patches for LLVM
Nothing much, but getting some patches from chimera linux that should work.
This commit is contained in:
parent
636c6f0163
commit
6110995cfb
33 changed files with 1813 additions and 0 deletions
5
Makefile
Normal file
5
Makefile
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
include config.mk
|
||||
|
||||
all:
|
||||
|
||||
.PHONY:
|
||||
|
|
@ -0,0 +1,38 @@
|
|||
From cea7072189cb3a3743bcb8f032c6f6b70e90fe80 Mon Sep 17 00:00:00 2001
|
||||
From: q66 <q66@chimera-linux.org>
|
||||
Date: Sat, 4 Nov 2023 08:44:01 +0100
|
||||
Subject: [PATCH 01/29] llvm: always set a larger stack size explicitly
|
||||
|
||||
---
|
||||
llvm/lib/Support/Threading.cpp | 14 --------------
|
||||
1 file changed, 14 deletions(-)
|
||||
|
||||
diff --git a/llvm/lib/Support/Threading.cpp b/llvm/lib/Support/Threading.cpp
|
||||
index 693de0e64..dd3e76fb8 100644
|
||||
--- a/llvm/lib/Support/Threading.cpp
|
||||
+++ b/llvm/lib/Support/Threading.cpp
|
||||
@@ -75,21 +75,7 @@ unsigned llvm::ThreadPoolStrategy::compute_thread_count() const {
|
||||
// keyword.
|
||||
#include "llvm/Support/thread.h"
|
||||
|
||||
-#if defined(__APPLE__)
|
||||
- // Darwin's default stack size for threads except the main one is only 512KB,
|
||||
- // which is not enough for some/many normal LLVM compilations. This implements
|
||||
- // the same interface as std::thread but requests the same stack size as the
|
||||
- // main thread (8MB) before creation.
|
||||
const std::optional<unsigned> llvm::thread::DefaultStackSize = 8 * 1024 * 1024;
|
||||
-#elif defined(_AIX)
|
||||
- // On AIX, the default pthread stack size limit is ~192k for 64-bit programs.
|
||||
- // This limit is easily reached when doing link-time thinLTO. AIX library
|
||||
- // developers have used 4MB, so we'll do the same.
|
||||
-const std::optional<unsigned> llvm::thread::DefaultStackSize = 4 * 1024 * 1024;
|
||||
-#else
|
||||
-const std::optional<unsigned> llvm::thread::DefaultStackSize;
|
||||
-#endif
|
||||
-
|
||||
|
||||
#endif
|
||||
|
||||
--
|
||||
2.49.0
|
||||
|
||||
32
patches/llvm/0002-llvm-musl-workarounds.patch
Normal file
32
patches/llvm/0002-llvm-musl-workarounds.patch
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
From f8a083e37fd50672621504ce33e99b862ec4f49b Mon Sep 17 00:00:00 2001
|
||||
From: q66 <q66@chimera-linux.org>
|
||||
Date: Sat, 4 Nov 2023 08:50:28 +0100
|
||||
Subject: [PATCH 02/29] llvm: musl workarounds
|
||||
|
||||
---
|
||||
llvm/include/llvm/Analysis/TargetLibraryInfo.h | 9 +++++++++
|
||||
1 file changed, 9 insertions(+)
|
||||
|
||||
diff --git a/llvm/include/llvm/Analysis/TargetLibraryInfo.h b/llvm/include/llvm/Analysis/TargetLibraryInfo.h
|
||||
index f51d2bb9d..c3cbe951b 100644
|
||||
--- a/llvm/include/llvm/Analysis/TargetLibraryInfo.h
|
||||
+++ b/llvm/include/llvm/Analysis/TargetLibraryInfo.h
|
||||
@@ -19,6 +19,15 @@
|
||||
#include <bitset>
|
||||
#include <optional>
|
||||
|
||||
+#undef fopen64
|
||||
+#undef fseeko64
|
||||
+#undef fstat64
|
||||
+#undef fstatvfs64
|
||||
+#undef ftello64
|
||||
+#undef lstat64
|
||||
+#undef stat64
|
||||
+#undef tmpfile64
|
||||
+
|
||||
namespace llvm {
|
||||
|
||||
template <typename T> class ArrayRef;
|
||||
--
|
||||
2.49.0
|
||||
|
||||
|
|
@ -0,0 +1,26 @@
|
|||
From f9afee0ee3d452b701cfaa5b61729a46a97c36ce Mon Sep 17 00:00:00 2001
|
||||
From: q66 <q66@chimera-linux.org>
|
||||
Date: Tue, 2 May 2023 16:04:20 +0200
|
||||
Subject: [PATCH 03/29] llvm: fix some MF_EXEC related test failures on aarch64
|
||||
|
||||
https://bugs.llvm.org/show_bug.cgi?id=14278#c10
|
||||
---
|
||||
llvm/lib/Support/Unix/Memory.inc | 2 +-
|
||||
1 file changed, 1 insertion(+), 1 deletion(-)
|
||||
|
||||
diff --git a/llvm/lib/Support/Unix/Memory.inc b/llvm/lib/Support/Unix/Memory.inc
|
||||
index bac208a7d..4cb941d39 100644
|
||||
--- a/llvm/lib/Support/Unix/Memory.inc
|
||||
+++ b/llvm/lib/Support/Unix/Memory.inc
|
||||
@@ -50,7 +50,7 @@ static int getPosixProtectionFlags(unsigned Flags) {
|
||||
llvm::sys::Memory::MF_EXEC:
|
||||
return PROT_READ | PROT_WRITE | PROT_EXEC;
|
||||
case llvm::sys::Memory::MF_EXEC:
|
||||
-#if defined(__FreeBSD__) || defined(__powerpc__)
|
||||
+#if defined(__FreeBSD__) || defined(__powerpc__) || (defined(__linux__) && defined(__aarch64__))
|
||||
// On PowerPC, having an executable page that has no read permission
|
||||
// can have unintended consequences. The function InvalidateInstruction-
|
||||
// Cache uses instructions dcbf and icbi, both of which are treated by
|
||||
--
|
||||
2.49.0
|
||||
|
||||
|
|
@ -0,0 +1,75 @@
|
|||
From 4db989c74c1b837f218c253034bce2bbad7e5a54 Mon Sep 17 00:00:00 2001
|
||||
From: q66 <q66@chimera-linux.org>
|
||||
Date: Fri, 29 Nov 2024 19:33:12 +0100
|
||||
Subject: [PATCH 04/29] llvm: disable dependency on libexecinfo everywhere
|
||||
|
||||
---
|
||||
compiler-rt/cmake/config-ix.cmake | 1 -
|
||||
llvm/cmake/config-ix.cmake | 2 --
|
||||
llvm/include/llvm/Config/config.h.cmake | 5 -----
|
||||
llvm/lib/Support/CMakeLists.txt | 8 --------
|
||||
4 files changed, 16 deletions(-)
|
||||
|
||||
diff --git a/compiler-rt/cmake/config-ix.cmake b/compiler-rt/cmake/config-ix.cmake
|
||||
index cf729c3ad..2a8a424c0 100644
|
||||
--- a/compiler-rt/cmake/config-ix.cmake
|
||||
+++ b/compiler-rt/cmake/config-ix.cmake
|
||||
@@ -191,7 +191,6 @@ check_library_exists(dl dlopen "" COMPILER_RT_HAS_LIBDL)
|
||||
check_library_exists(rt shm_open "" COMPILER_RT_HAS_LIBRT)
|
||||
check_library_exists(m pow "" COMPILER_RT_HAS_LIBM)
|
||||
check_library_exists(pthread pthread_create "" COMPILER_RT_HAS_LIBPTHREAD)
|
||||
-check_library_exists(execinfo backtrace "" COMPILER_RT_HAS_LIBEXECINFO)
|
||||
|
||||
if (ANDROID AND COMPILER_RT_HAS_LIBDL)
|
||||
# Android's libstdc++ has a dependency on libdl.
|
||||
diff --git a/llvm/cmake/config-ix.cmake b/llvm/cmake/config-ix.cmake
|
||||
index 767774812..dbacb6127 100644
|
||||
--- a/llvm/cmake/config-ix.cmake
|
||||
+++ b/llvm/cmake/config-ix.cmake
|
||||
@@ -297,8 +297,6 @@ endif()
|
||||
# function checks
|
||||
check_symbol_exists(arc4random "stdlib.h" HAVE_DECL_ARC4RANDOM)
|
||||
find_package(Backtrace)
|
||||
-set(HAVE_BACKTRACE ${Backtrace_FOUND})
|
||||
-set(BACKTRACE_HEADER ${Backtrace_HEADER})
|
||||
|
||||
# Prevent check_symbol_exists from using API that is not supported for a given
|
||||
# deployment target.
|
||||
diff --git a/llvm/include/llvm/Config/config.h.cmake b/llvm/include/llvm/Config/config.h.cmake
|
||||
index f6f10ea4f..578751766 100644
|
||||
--- a/llvm/include/llvm/Config/config.h.cmake
|
||||
+++ b/llvm/include/llvm/Config/config.h.cmake
|
||||
@@ -27,11 +27,6 @@
|
||||
backslashes. */
|
||||
#cmakedefine01 LLVM_WINDOWS_PREFER_FORWARD_SLASH
|
||||
|
||||
-/* Define to 1 if you have the `backtrace' function. */
|
||||
-#cmakedefine HAVE_BACKTRACE ${HAVE_BACKTRACE}
|
||||
-
|
||||
-#define BACKTRACE_HEADER <${BACKTRACE_HEADER}>
|
||||
-
|
||||
/* Define to 1 if you have the <CrashReporterClient.h> header file. */
|
||||
#cmakedefine HAVE_CRASHREPORTERCLIENT_H
|
||||
|
||||
diff --git a/llvm/lib/Support/CMakeLists.txt b/llvm/lib/Support/CMakeLists.txt
|
||||
index a6d8a2581..2178edb7d 100644
|
||||
--- a/llvm/lib/Support/CMakeLists.txt
|
||||
+++ b/llvm/lib/Support/CMakeLists.txt
|
||||
@@ -49,14 +49,6 @@ elseif( CMAKE_HOST_UNIX )
|
||||
if( HAVE_LIBDL )
|
||||
set(system_libs ${system_libs} ${CMAKE_DL_LIBS})
|
||||
endif()
|
||||
- if( HAVE_BACKTRACE AND NOT "${Backtrace_LIBRARIES}" STREQUAL "" )
|
||||
- # On BSDs, CMake returns a fully qualified path to the backtrace library.
|
||||
- # We need to remove the path and the 'lib' prefix, to make it look like a
|
||||
- # regular short library name, suitable for appending to a -l link flag.
|
||||
- get_filename_component(Backtrace_LIBFILE ${Backtrace_LIBRARIES} NAME_WE)
|
||||
- STRING(REGEX REPLACE "^lib" "" Backtrace_LIBFILE ${Backtrace_LIBFILE})
|
||||
- set(system_libs ${system_libs} ${Backtrace_LIBFILE})
|
||||
- endif()
|
||||
set(system_libs ${system_libs} ${LLVM_ATOMIC_LIB})
|
||||
set(system_libs ${system_libs} ${LLVM_PTHREAD_LIB})
|
||||
if( UNIX AND NOT (BEOS OR HAIKU) )
|
||||
--
|
||||
2.49.0
|
||||
|
||||
136
patches/llvm/0005-compiler-rt-ppc-sanitizer-fixes.patch
Normal file
136
patches/llvm/0005-compiler-rt-ppc-sanitizer-fixes.patch
Normal file
|
|
@ -0,0 +1,136 @@
|
|||
From 682ad99f38c927c37c2c54d12f4084473d67a007 Mon Sep 17 00:00:00 2001
|
||||
From: q66 <q66@chimera-linux.org>
|
||||
Date: Sun, 14 Apr 2024 14:33:38 +0200
|
||||
Subject: [PATCH 05/29] compiler-rt: ppc sanitizer fixes
|
||||
|
||||
---
|
||||
compiler-rt/cmake/base-config-ix.cmake | 3 +-
|
||||
.../lib/sanitizer_common/sanitizer_linux.cpp | 4 ++
|
||||
.../sanitizer_platform_limits_posix.cpp | 2 +-
|
||||
.../sanitizer_stoptheworld_linux_libcdep.cpp | 2 +-
|
||||
compiler-rt/lib/xray/xray_powerpc64.inc | 37 ++++++++++++++++++-
|
||||
5 files changed, 44 insertions(+), 4 deletions(-)
|
||||
|
||||
diff --git a/compiler-rt/cmake/base-config-ix.cmake b/compiler-rt/cmake/base-config-ix.cmake
|
||||
index d92bc0e71..caeed40e3 100644
|
||||
--- a/compiler-rt/cmake/base-config-ix.cmake
|
||||
+++ b/compiler-rt/cmake/base-config-ix.cmake
|
||||
@@ -233,9 +233,10 @@ macro(test_targets)
|
||||
test_target_arch(loongarch64 "" "")
|
||||
elseif("${COMPILER_RT_DEFAULT_TARGET_ARCH}" MATCHES "powerpc64le|ppc64le")
|
||||
test_target_arch(powerpc64le "" "-m64")
|
||||
+ elseif("${COMPILER_RT_DEFAULT_TARGET_ARCH}" MATCHES "powerpc64")
|
||||
+ test_target_arch(powerpc64 "" "-m64")
|
||||
elseif("${COMPILER_RT_DEFAULT_TARGET_ARCH}" MATCHES "powerpc")
|
||||
test_target_arch(powerpc "" "-m32")
|
||||
- test_target_arch(powerpc64 "" "-m64")
|
||||
elseif("${COMPILER_RT_DEFAULT_TARGET_ARCH}" MATCHES "s390x")
|
||||
test_target_arch(s390x "" "")
|
||||
elseif("${COMPILER_RT_DEFAULT_TARGET_ARCH}" MATCHES "sparc")
|
||||
diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_linux.cpp b/compiler-rt/lib/sanitizer_common/sanitizer_linux.cpp
|
||||
index 7aa48d29d..a782d5221 100644
|
||||
--- a/compiler-rt/lib/sanitizer_common/sanitizer_linux.cpp
|
||||
+++ b/compiler-rt/lib/sanitizer_common/sanitizer_linux.cpp
|
||||
@@ -82,6 +82,10 @@
|
||||
# include <sys/personality.h>
|
||||
# endif
|
||||
|
||||
+# if SANITIZER_LINUX && defined(__powerpc__)
|
||||
+# include <asm/ptrace.h>
|
||||
+# endif
|
||||
+
|
||||
# if SANITIZER_LINUX && defined(__loongarch__)
|
||||
# include <sys/sysmacros.h>
|
||||
# endif
|
||||
diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_platform_limits_posix.cpp b/compiler-rt/lib/sanitizer_common/sanitizer_platform_limits_posix.cpp
|
||||
index a5311d266..cd86b2383 100644
|
||||
--- a/compiler-rt/lib/sanitizer_common/sanitizer_platform_limits_posix.cpp
|
||||
+++ b/compiler-rt/lib/sanitizer_common/sanitizer_platform_limits_posix.cpp
|
||||
@@ -96,7 +96,7 @@
|
||||
# include <sys/ptrace.h>
|
||||
# if defined(__mips64) || defined(__aarch64__) || defined(__arm__) || \
|
||||
defined(__hexagon__) || defined(__loongarch__) || SANITIZER_RISCV64 || \
|
||||
- defined(__sparc__) || defined(__powerpc64__)
|
||||
+ defined(__sparc__) || defined(__powerpc__)
|
||||
# include <asm/ptrace.h>
|
||||
# ifdef __arm__
|
||||
typedef struct user_fpregs elf_fpregset_t;
|
||||
diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_stoptheworld_linux_libcdep.cpp b/compiler-rt/lib/sanitizer_common/sanitizer_stoptheworld_linux_libcdep.cpp
|
||||
index 945da99d4..81822dbb1 100644
|
||||
--- a/compiler-rt/lib/sanitizer_common/sanitizer_stoptheworld_linux_libcdep.cpp
|
||||
+++ b/compiler-rt/lib/sanitizer_common/sanitizer_stoptheworld_linux_libcdep.cpp
|
||||
@@ -31,7 +31,7 @@
|
||||
#include <sys/types.h> // for pid_t
|
||||
#include <sys/uio.h> // for iovec
|
||||
#include <elf.h> // for NT_PRSTATUS
|
||||
-#if (defined(__aarch64__) || defined(__powerpc64__) || \
|
||||
+#if (defined(__aarch64__) || defined(__powerpc__) || \
|
||||
SANITIZER_RISCV64 || SANITIZER_LOONGARCH64) && \
|
||||
!SANITIZER_ANDROID
|
||||
// GLIBC 2.20+ sys/user does not include asm/ptrace.h
|
||||
diff --git a/compiler-rt/lib/xray/xray_powerpc64.inc b/compiler-rt/lib/xray/xray_powerpc64.inc
|
||||
index 7e872b5b4..9616a09d8 100644
|
||||
--- a/compiler-rt/lib/xray/xray_powerpc64.inc
|
||||
+++ b/compiler-rt/lib/xray/xray_powerpc64.inc
|
||||
@@ -12,7 +12,7 @@
|
||||
|
||||
#include <cstdint>
|
||||
#include <mutex>
|
||||
-#ifdef __linux__
|
||||
+#ifdef __GLIBC__
|
||||
#include <sys/platform/ppc.h>
|
||||
#elif defined(__FreeBSD__)
|
||||
#include <sys/types.h>
|
||||
@@ -27,6 +27,13 @@ uint64_t __ppc_get_timebase_freq (void)
|
||||
sysctlbyname("kern.timecounter.tc.timebase.frequency", &tb_freq, &length, nullptr, 0);
|
||||
return tb_freq;
|
||||
}
|
||||
+#else
|
||||
+#include <cctype>
|
||||
+#include <cstring>
|
||||
+#include <cstdlib>
|
||||
+
|
||||
+#define __ppc_get_timebase __builtin_ppc_get_timebase
|
||||
+
|
||||
#endif
|
||||
|
||||
#include "xray_defs.h"
|
||||
@@ -41,7 +48,35 @@ ALWAYS_INLINE uint64_t readTSC(uint8_t &CPU) XRAY_NEVER_INSTRUMENT {
|
||||
inline uint64_t getTSCFrequency() XRAY_NEVER_INSTRUMENT {
|
||||
static std::mutex M;
|
||||
std::lock_guard<std::mutex> Guard(M);
|
||||
+#ifdef __GLIBC__
|
||||
return __ppc_get_timebase_freq();
|
||||
+#else
|
||||
+ /* FIXME: a less dirty implementation? */
|
||||
+ static uint64_t base;
|
||||
+ if (!base) {
|
||||
+ FILE *f = fopen("/proc/cpuinfo", "rb");
|
||||
+ if (f) {
|
||||
+ ssize_t nr;
|
||||
+ /* virtually always big enough to hold the line */
|
||||
+ char buf[512];
|
||||
+ while (fgets(buf, sizeof(buf), f)) {
|
||||
+ char *ret = strstr(buf, "timebase");
|
||||
+ if (!ret) {
|
||||
+ continue;
|
||||
+ }
|
||||
+ ret += sizeof("timebase") - 1;
|
||||
+ ret = strchr(ret, ':');
|
||||
+ if (!ret) {
|
||||
+ continue;
|
||||
+ }
|
||||
+ base = strtoul(ret + 1, nullptr, 10);
|
||||
+ break;
|
||||
+ }
|
||||
+ fclose(f);
|
||||
+ }
|
||||
+ }
|
||||
+ return base;
|
||||
+#endif
|
||||
}
|
||||
|
||||
inline bool probeRequiredCPUFeatures() XRAY_NEVER_INSTRUMENT {
|
||||
--
|
||||
2.49.0
|
||||
|
||||
|
|
@ -0,0 +1,25 @@
|
|||
From 73de90029db874f0fe7c97b11692a7534f2e5f70 Mon Sep 17 00:00:00 2001
|
||||
From: q66 <q66@chimera-linux.org>
|
||||
Date: Sat, 4 Nov 2023 08:55:34 +0100
|
||||
Subject: [PATCH 06/29] compiler-rt: default to libc++ for sanitizers
|
||||
|
||||
---
|
||||
compiler-rt/CMakeLists.txt | 2 +-
|
||||
1 file changed, 1 insertion(+), 1 deletion(-)
|
||||
|
||||
diff --git a/compiler-rt/CMakeLists.txt b/compiler-rt/CMakeLists.txt
|
||||
index 2c52788de..bad897a12 100644
|
||||
--- a/compiler-rt/CMakeLists.txt
|
||||
+++ b/compiler-rt/CMakeLists.txt
|
||||
@@ -228,7 +228,7 @@ macro(handle_default_cxx_lib var)
|
||||
set(${var}_LIBNAME "libc++")
|
||||
set(${var}_INTREE 1)
|
||||
else()
|
||||
- set(${var}_LIBNAME "libstdc++")
|
||||
+ set(${var}_LIBNAME "libc++")
|
||||
set(${var}_SYSTEM 1)
|
||||
endif()
|
||||
else()
|
||||
--
|
||||
2.49.0
|
||||
|
||||
299
patches/llvm/0007-compiler-rt-build-crt-in-runtimes-build.patch
Normal file
299
patches/llvm/0007-compiler-rt-build-crt-in-runtimes-build.patch
Normal file
|
|
@ -0,0 +1,299 @@
|
|||
From ddba64ea50bc85499ccfae3f79ce7148eb3252bf Mon Sep 17 00:00:00 2001
|
||||
From: q66 <q66@chimera-linux.org>
|
||||
Date: Fri, 29 Nov 2024 19:40:34 +0100
|
||||
Subject: [PATCH 07/29] compiler-rt: build crt in runtimes build
|
||||
|
||||
We need this because otherwise the in-tree clang binaries will
|
||||
not work, as we don't supply external gcc-style runtime.
|
||||
---
|
||||
compiler-rt/CMakeLists.txt | 117 +++++++++++++-----------
|
||||
compiler-rt/lib/builtins/CMakeLists.txt | 55 ++---------
|
||||
llvm/runtimes/CMakeLists.txt | 12 ++-
|
||||
runtimes/CMakeLists.txt | 2 +-
|
||||
4 files changed, 80 insertions(+), 106 deletions(-)
|
||||
|
||||
diff --git a/compiler-rt/CMakeLists.txt b/compiler-rt/CMakeLists.txt
|
||||
index bad897a12..3ea1aac04 100644
|
||||
--- a/compiler-rt/CMakeLists.txt
|
||||
+++ b/compiler-rt/CMakeLists.txt
|
||||
@@ -60,47 +60,6 @@ set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} --no-default-config")
|
||||
check_cxx_compiler_flag("" COMPILER_RT_HAS_NO_DEFAULT_CONFIG_FLAG)
|
||||
set(CMAKE_REQUIRED_FLAGS "${OLD_CMAKE_REQUIRED_FLAGS}")
|
||||
|
||||
-option(COMPILER_RT_BUILD_BUILTINS "Build builtins" ON)
|
||||
-mark_as_advanced(COMPILER_RT_BUILD_BUILTINS)
|
||||
-option(COMPILER_RT_DISABLE_AARCH64_FMV "Disable AArch64 Function Multi Versioning support" OFF)
|
||||
-mark_as_advanced(COMPILER_RT_DISABLE_AARCH64_FMV)
|
||||
-option(COMPILER_RT_BUILD_SANITIZERS "Build sanitizers" ON)
|
||||
-mark_as_advanced(COMPILER_RT_BUILD_SANITIZERS)
|
||||
-option(COMPILER_RT_BUILD_XRAY "Build xray" ON)
|
||||
-mark_as_advanced(COMPILER_RT_BUILD_XRAY)
|
||||
-option(COMPILER_RT_BUILD_LIBFUZZER "Build libFuzzer" ON)
|
||||
-mark_as_advanced(COMPILER_RT_BUILD_LIBFUZZER)
|
||||
-option(COMPILER_RT_BUILD_PROFILE "Build profile runtime" ON)
|
||||
-mark_as_advanced(COMPILER_RT_BUILD_PROFILE)
|
||||
-option(COMPILER_RT_BUILD_CTX_PROFILE "Build ctx profile runtime" ON)
|
||||
-mark_as_advanced(COMPILER_RT_BUILD_CTX_PROFILE)
|
||||
-option(COMPILER_RT_BUILD_MEMPROF "Build memory profiling runtime" ON)
|
||||
-mark_as_advanced(COMPILER_RT_BUILD_MEMPROF)
|
||||
-option(COMPILER_RT_BUILD_XRAY_NO_PREINIT "Build xray with no preinit patching" OFF)
|
||||
-mark_as_advanced(COMPILER_RT_BUILD_XRAY_NO_PREINIT)
|
||||
-option(COMPILER_RT_BUILD_ORC "Build ORC runtime" ON)
|
||||
-mark_as_advanced(COMPILER_RT_BUILD_ORC)
|
||||
-option(COMPILER_RT_BUILD_GWP_ASAN "Build GWP-ASan, and link it into SCUDO" ON)
|
||||
-mark_as_advanced(COMPILER_RT_BUILD_GWP_ASAN)
|
||||
-option(COMPILER_RT_ENABLE_CET "Build Compiler RT with CET enabled" OFF)
|
||||
-
|
||||
-option(COMPILER_RT_SCUDO_STANDALONE_SYSROOT_PATH "Set custom sysroot for building SCUDO standalone" OFF)
|
||||
-mark_as_advanced(COMPILER_RT_SCUDO_STANDALONE_SYSROOT_PATH)
|
||||
-option(COMPILER_RT_SCUDO_STANDALONE_BUILD_SHARED "Build SCUDO standalone for shared libraries" ON)
|
||||
-mark_as_advanced(COMPILER_RT_SCUDO_STANDALONE_BUILD_SHARED)
|
||||
-option(COMPILER_RT_BUILD_SCUDO_STANDALONE_WITH_LLVM_LIBC "Build SCUDO standalone with LLVM's libc headers" OFF)
|
||||
-mark_as_advanced(COMPILER_RT_BUILD_SCUDO_STANDALONE_WITH_LLVM_LIBC)
|
||||
-
|
||||
-if(FUCHSIA)
|
||||
- set(COMPILER_RT_HWASAN_WITH_INTERCEPTORS_DEFAULT OFF)
|
||||
-else()
|
||||
- set(COMPILER_RT_HWASAN_WITH_INTERCEPTORS_DEFAULT ON)
|
||||
-endif()
|
||||
-set(COMPILER_RT_HWASAN_WITH_INTERCEPTORS ${COMPILER_RT_HWASAN_WITH_INTERCEPTORS_DEFAULT} CACHE BOOL "Enable libc interceptors in HWASan (testing mode)")
|
||||
-
|
||||
-set(COMPILER_RT_BAREMETAL_BUILD OFF CACHE BOOL
|
||||
- "Build for a bare-metal target.")
|
||||
-
|
||||
if (COMPILER_RT_STANDALONE_BUILD)
|
||||
set(CMAKE_CXX_STANDARD 17 CACHE STRING "C++ standard to conform to")
|
||||
set(CMAKE_CXX_STANDARD_REQUIRED YES)
|
||||
@@ -115,20 +74,7 @@ if (COMPILER_RT_STANDALONE_BUILD)
|
||||
set_target_properties(intrinsics_gen PROPERTIES FOLDER "LLVM/Tablegenning")
|
||||
endif()
|
||||
|
||||
- find_package(Python3 COMPONENTS Interpreter)
|
||||
- if(NOT Python3_Interpreter_FOUND)
|
||||
- message(WARNING "Python3 not found, using python2 as a fallback")
|
||||
- find_package(Python2 COMPONENTS Interpreter REQUIRED)
|
||||
- if(Python2_VERSION VERSION_LESS 2.7)
|
||||
- message(SEND_ERROR "Python 2.7 or newer is required")
|
||||
- endif()
|
||||
-
|
||||
- # Treat python2 as python3
|
||||
- add_executable(Python3::Interpreter IMPORTED)
|
||||
- set_target_properties(Python3::Interpreter PROPERTIES
|
||||
- IMPORTED_LOCATION ${Python2_EXECUTABLE})
|
||||
- set(Python3_EXECUTABLE ${Python2_EXECUTABLE})
|
||||
- endif()
|
||||
+ set(Python3_EXECUTABLE "/usr/bin/python3")
|
||||
|
||||
# Ensure that fat libraries are built correctly on Darwin
|
||||
if(APPLE)
|
||||
@@ -158,6 +104,67 @@ if ("${COMPILER_RT_DEFAULT_TARGET_TRIPLE}" MATCHES ".*android.*")
|
||||
endif()
|
||||
pythonize_bool(ANDROID)
|
||||
|
||||
+option(COMPILER_RT_BUILD_BUILTINS "Build builtins" ON)
|
||||
+mark_as_advanced(COMPILER_RT_BUILD_BUILTINS)
|
||||
+option(COMPILER_RT_DISABLE_AARCH64_FMV "Disable AArch64 Function Multi Versioning support" OFF)
|
||||
+mark_as_advanced(COMPILER_RT_DISABLE_AARCH64_FMV)
|
||||
+
|
||||
+option(COMPILER_RT_BOOTSTRAP "Build just builtins and crt" OFF)
|
||||
+mark_as_advanced(COMPILER_RT_BOOTSTRAP)
|
||||
+
|
||||
+if(COMPILER_RT_BOOTSTRAP)
|
||||
+ include(AddCompilerRT)
|
||||
+
|
||||
+ set(CMAKE_TRY_COMPILE_TARGET_TYPE STATIC_LIBRARY)
|
||||
+
|
||||
+ if(COMPILER_RT_BUILD_BUILTINS)
|
||||
+ set(COMPILER_RT_BUILTINS_STANDALONE_BUILD TRUE)
|
||||
+ add_subdirectory(lib/builtins)
|
||||
+ endif()
|
||||
+ if(COMPILER_RT_BUILD_CRT)
|
||||
+ set(COMPILER_RT_CRT_STANDALONE_BUILD TRUE)
|
||||
+ endif()
|
||||
+
|
||||
+ return()
|
||||
+endif()
|
||||
+
|
||||
+option(COMPILER_RT_BUILD_SANITIZERS "Build sanitizers" ON)
|
||||
+mark_as_advanced(COMPILER_RT_BUILD_SANITIZERS)
|
||||
+option(COMPILER_RT_BUILD_XRAY "Build xray" ON)
|
||||
+mark_as_advanced(COMPILER_RT_BUILD_XRAY)
|
||||
+option(COMPILER_RT_BUILD_LIBFUZZER "Build libFuzzer" ON)
|
||||
+mark_as_advanced(COMPILER_RT_BUILD_LIBFUZZER)
|
||||
+option(COMPILER_RT_BUILD_PROFILE "Build profile runtime" ON)
|
||||
+mark_as_advanced(COMPILER_RT_BUILD_PROFILE)
|
||||
+option(COMPILER_RT_BUILD_CTX_PROFILE "Build ctx profile runtime" ON)
|
||||
+mark_as_advanced(COMPILER_RT_BUILD_CTX_PROFILE)
|
||||
+option(COMPILER_RT_BUILD_MEMPROF "Build memory profiling runtime" ON)
|
||||
+mark_as_advanced(COMPILER_RT_BUILD_MEMPROF)
|
||||
+option(COMPILER_RT_BUILD_XRAY_NO_PREINIT "Build xray with no preinit patching" OFF)
|
||||
+mark_as_advanced(COMPILER_RT_BUILD_XRAY_NO_PREINIT)
|
||||
+option(COMPILER_RT_BUILD_ORC "Build ORC runtime" ON)
|
||||
+mark_as_advanced(COMPILER_RT_BUILD_ORC)
|
||||
+option(COMPILER_RT_BUILD_GWP_ASAN "Build GWP-ASan, and link it into SCUDO" ON)
|
||||
+mark_as_advanced(COMPILER_RT_BUILD_GWP_ASAN)
|
||||
+option(COMPILER_RT_ENABLE_CET "Build Compiler RT with CET enabled" OFF)
|
||||
+
|
||||
+option(COMPILER_RT_SCUDO_STANDALONE_SYSROOT_PATH "Set custom sysroot for building SCUDO standalone" OFF)
|
||||
+mark_as_advanced(COMPILER_RT_SCUDO_STANDALONE_SYSROOT_PATH)
|
||||
+option(COMPILER_RT_SCUDO_STANDALONE_BUILD_SHARED "Build SCUDO standalone for shared libraries" ON)
|
||||
+mark_as_advanced(COMPILER_RT_SCUDO_STANDALONE_BUILD_SHARED)
|
||||
+option(COMPILER_RT_BUILD_SCUDO_STANDALONE_WITH_LLVM_LIBC "Build SCUDO standalone with LLVM's libc headers" OFF)
|
||||
+mark_as_advanced(COMPILER_RT_BUILD_SCUDO_STANDALONE_WITH_LLVM_LIBC)
|
||||
+
|
||||
+if(FUCHSIA)
|
||||
+ set(COMPILER_RT_HWASAN_WITH_INTERCEPTORS_DEFAULT OFF)
|
||||
+else()
|
||||
+ set(COMPILER_RT_HWASAN_WITH_INTERCEPTORS_DEFAULT ON)
|
||||
+endif()
|
||||
+set(COMPILER_RT_HWASAN_WITH_INTERCEPTORS ${COMPILER_RT_HWASAN_WITH_INTERCEPTORS_DEFAULT} CACHE BOOL "Enable libc interceptors in HWASan (testing mode)")
|
||||
+
|
||||
+set(COMPILER_RT_BAREMETAL_BUILD OFF CACHE BOOL
|
||||
+ "Build for a bare-metal target.")
|
||||
+
|
||||
set(COMPILER_RT_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR})
|
||||
set(COMPILER_RT_BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR})
|
||||
|
||||
diff --git a/compiler-rt/lib/builtins/CMakeLists.txt b/compiler-rt/lib/builtins/CMakeLists.txt
|
||||
index 19316c52d..f89cf87c7 100644
|
||||
--- a/compiler-rt/lib/builtins/CMakeLists.txt
|
||||
+++ b/compiler-rt/lib/builtins/CMakeLists.txt
|
||||
@@ -7,54 +7,15 @@ if (CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR)
|
||||
|
||||
set(CMAKE_TRY_COMPILE_TARGET_TYPE STATIC_LIBRARY)
|
||||
project(CompilerRTBuiltins C ASM)
|
||||
- set(COMPILER_RT_STANDALONE_BUILD TRUE)
|
||||
- set(COMPILER_RT_BUILTINS_STANDALONE_BUILD TRUE)
|
||||
-
|
||||
- set(COMPILER_RT_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../..")
|
||||
-
|
||||
- set(LLVM_COMMON_CMAKE_UTILS "${COMPILER_RT_SOURCE_DIR}/../cmake")
|
||||
-
|
||||
- # Add path for custom modules
|
||||
- list(INSERT CMAKE_MODULE_PATH 0
|
||||
- "${COMPILER_RT_SOURCE_DIR}/cmake"
|
||||
- "${COMPILER_RT_SOURCE_DIR}/cmake/Modules"
|
||||
- "${LLVM_COMMON_CMAKE_UTILS}"
|
||||
- "${LLVM_COMMON_CMAKE_UTILS}/Modules"
|
||||
- )
|
||||
-
|
||||
- include(base-config-ix)
|
||||
- include(CompilerRTUtils)
|
||||
-
|
||||
- if (NOT LLVM_RUNTIMES_BUILD)
|
||||
- load_llvm_config()
|
||||
+ if(NOT _BUILTINS_PROCESSED)
|
||||
+ set(COMPILER_RT_BUILD_BUILTINS TRUE)
|
||||
+ set(COMPILER_RT_BUILD_CRT FALSE)
|
||||
+ set(COMPILER_RT_BOOTSTRAP TRUE)
|
||||
+ set(COMPILER_RT_STANDALONE_BUILD TRUE)
|
||||
+ include(../../CMakeLists.txt)
|
||||
+ set(_BUILTINS_PROCESSED TRUE)
|
||||
+ return()
|
||||
endif()
|
||||
- construct_compiler_rt_default_triple()
|
||||
-
|
||||
- include(SetPlatformToolchainTools)
|
||||
- if(APPLE)
|
||||
- include(CompilerRTDarwinUtils)
|
||||
- endif()
|
||||
- if(APPLE)
|
||||
- include(UseLibtool)
|
||||
- endif()
|
||||
- include(AddCompilerRT)
|
||||
-
|
||||
- if(MINGW)
|
||||
- # Simplified version of what's set in cmake/config-ix.cmake; not including
|
||||
- # builtins, which are linked separately.
|
||||
- set(MINGW_LIBRARIES mingw32 moldname mingwex msvcrt advapi32 shell32
|
||||
- user32 kernel32 mingw32 moldname mingwex msvcrt)
|
||||
- endif()
|
||||
-endif()
|
||||
-
|
||||
-if (COMPILER_RT_STANDALONE_BUILD)
|
||||
- # When compiler-rt is being built standalone, possibly as a cross-compilation
|
||||
- # target, the target may or may not want position independent code. This
|
||||
- # option provides an avenue through which the flag may be controlled when an
|
||||
- # LLVM configuration is not being utilized.
|
||||
- option(COMPILER_RT_BUILTINS_ENABLE_PIC
|
||||
- "Turns on or off -fPIC for the builtin library source"
|
||||
- ON)
|
||||
endif()
|
||||
|
||||
include(builtin-config-ix)
|
||||
diff --git a/llvm/runtimes/CMakeLists.txt b/llvm/runtimes/CMakeLists.txt
|
||||
index 70e85c123..7374074ac 100644
|
||||
--- a/llvm/runtimes/CMakeLists.txt
|
||||
+++ b/llvm/runtimes/CMakeLists.txt
|
||||
@@ -88,7 +88,7 @@ function(builtin_default_target compiler_rt_path)
|
||||
set_enable_per_target_runtime_dir()
|
||||
|
||||
llvm_ExternalProject_Add(builtins
|
||||
- ${compiler_rt_path}/lib/builtins
|
||||
+ ${compiler_rt_path}
|
||||
DEPENDS ${ARG_DEPENDS}
|
||||
CMAKE_ARGS -DLLVM_LIBRARY_OUTPUT_INTDIR=${LLVM_LIBRARY_DIR}
|
||||
-DLLVM_RUNTIME_OUTPUT_INTDIR=${LLVM_TOOLS_BINARY_DIR}
|
||||
@@ -96,7 +96,9 @@ function(builtin_default_target compiler_rt_path)
|
||||
-DLLVM_ENABLE_PER_TARGET_RUNTIME_DIR=${LLVM_ENABLE_PER_TARGET_RUNTIME_DIR}
|
||||
-DLLVM_CMAKE_DIR=${CMAKE_BINARY_DIR}
|
||||
-DCMAKE_C_COMPILER_WORKS=ON
|
||||
+ -DCMAKE_CXX_COMPILER_WORKS=ON
|
||||
-DCMAKE_ASM_COMPILER_WORKS=ON
|
||||
+ -DCOMPILER_RT_BOOTSTRAP=ON
|
||||
${COMMON_CMAKE_ARGS}
|
||||
${BUILTINS_CMAKE_ARGS}
|
||||
PASSTHROUGH_PREFIXES COMPILER_RT
|
||||
@@ -129,15 +131,17 @@ function(builtin_register_target compiler_rt_path name)
|
||||
endforeach()
|
||||
|
||||
llvm_ExternalProject_Add(builtins-${name}
|
||||
- ${compiler_rt_path}/lib/builtins
|
||||
+ ${compiler_rt_path}
|
||||
DEPENDS ${ARG_DEPENDS}
|
||||
CMAKE_ARGS -DLLVM_LIBRARY_OUTPUT_INTDIR=${LLVM_LIBRARY_DIR}
|
||||
-DLLVM_RUNTIME_OUTPUT_INTDIR=${LLVM_TOOLS_BINARY_DIR}
|
||||
-DLLVM_ENABLE_PER_TARGET_RUNTIME_DIR=ON
|
||||
-DLLVM_CMAKE_DIR=${CMAKE_BINARY_DIR}
|
||||
-DCMAKE_C_COMPILER_WORKS=ON
|
||||
+ -DCMAKE_CXX_COMPILER_WORKS=ON
|
||||
-DCMAKE_ASM_COMPILER_WORKS=ON
|
||||
-DCOMPILER_RT_DEFAULT_TARGET_ONLY=ON
|
||||
+ -DCOMPILER_RT_BOOTSTRAP=ON
|
||||
${COMMON_CMAKE_ARGS}
|
||||
${${name}_extra_args}
|
||||
USE_TOOLCHAIN
|
||||
@@ -262,7 +266,8 @@ function(runtime_default_target)
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/../../runtimes
|
||||
DEPENDS ${ARG_DEPENDS}
|
||||
# Builtins were built separately above
|
||||
- CMAKE_ARGS -DCOMPILER_RT_BUILD_BUILTINS=Off
|
||||
+ CMAKE_ARGS -DCOMPILER_RT_BUILD_BUILTINS=OFF
|
||||
+ -DCOMPILER_RT_BUILD_CRT=OFF
|
||||
-DLLVM_INCLUDE_TESTS=${LLVM_INCLUDE_TESTS}
|
||||
-DLLVM_DEFAULT_TARGET_TRIPLE=${LLVM_TARGET_TRIPLE}
|
||||
-DLLVM_ENABLE_PROJECTS_USED=${LLVM_ENABLE_PROJECTS_USED}
|
||||
@@ -399,6 +404,7 @@ function(runtime_register_target name)
|
||||
DEPENDS ${ARG_DEPENDS}
|
||||
# Builtins were built separately above
|
||||
CMAKE_ARGS -DCOMPILER_RT_BUILD_BUILTINS=OFF
|
||||
+ -DCOMPILER_RT_BUILD_CRT=OFF
|
||||
-DLLVM_INCLUDE_TESTS=${LLVM_INCLUDE_TESTS}
|
||||
-DLLVM_ENABLE_PROJECTS_USED=${LLVM_ENABLE_PROJECTS_USED}
|
||||
-DLLVM_ENABLE_PER_TARGET_RUNTIME_DIR=${LLVM_ENABLE_PER_TARGET_RUNTIME_DIR}
|
||||
diff --git a/runtimes/CMakeLists.txt b/runtimes/CMakeLists.txt
|
||||
index 4a6b317a0..cfbad056d 100644
|
||||
--- a/runtimes/CMakeLists.txt
|
||||
+++ b/runtimes/CMakeLists.txt
|
||||
@@ -177,7 +177,7 @@ include(HandleLLVMOptions)
|
||||
# Loot at the PATH first to avoid a version mismatch between the command-line
|
||||
# python and the CMake-found version
|
||||
set(Python3_FIND_REGISTRY LAST)
|
||||
-find_package(Python3 REQUIRED COMPONENTS Interpreter)
|
||||
+set(Python3_EXECUTABLE "/usr/bin/python3")
|
||||
|
||||
# Host triple is used by tests to check if they are running natively.
|
||||
include(GetHostTriple)
|
||||
--
|
||||
2.49.0
|
||||
|
||||
|
|
@ -0,0 +1,52 @@
|
|||
From da1c921a45908cd05aed5bd44245d2b424a8580a Mon Sep 17 00:00:00 2001
|
||||
From: q66 <q66@chimera-linux.org>
|
||||
Date: Sun, 14 Apr 2024 14:41:14 +0200
|
||||
Subject: [PATCH 08/29] compiler-rt: lsan: basic musl fixes on various archs
|
||||
|
||||
---
|
||||
.../lib/sanitizer_common/sanitizer_linux_libcdep.cpp | 11 +++++++++++
|
||||
1 file changed, 11 insertions(+)
|
||||
|
||||
diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_linux_libcdep.cpp b/compiler-rt/lib/sanitizer_common/sanitizer_linux_libcdep.cpp
|
||||
index e11eff13c..96e823ae7 100644
|
||||
--- a/compiler-rt/lib/sanitizer_common/sanitizer_linux_libcdep.cpp
|
||||
+++ b/compiler-rt/lib/sanitizer_common/sanitizer_linux_libcdep.cpp
|
||||
@@ -28,6 +28,14 @@
|
||||
# include "sanitizer_procmaps.h"
|
||||
# include "sanitizer_solaris.h"
|
||||
|
||||
+#if defined(__powerpc__)
|
||||
+#define DTP_OFFSET 0x8000
|
||||
+#elif SANITIZER_RISCV64
|
||||
+#define DTP_OFFSET 0x800
|
||||
+#else
|
||||
+#define DTP_OFFSET 0
|
||||
+#endif
|
||||
+
|
||||
# if SANITIZER_NETBSD
|
||||
# define _RTLD_SOURCE // for __lwp_gettcb_fast() / __lwp_getprivate_fast()
|
||||
# endif
|
||||
@@ -467,6 +475,7 @@ static int CollectStaticTlsBlocks(struct dl_phdr_info *info, size_t size,
|
||||
begin = (uptr)__tls_get_addr(mod_and_off);
|
||||
# endif
|
||||
}
|
||||
+ begin -= DTP_OFFSET;
|
||||
for (unsigned i = 0; i != info->dlpi_phnum; ++i)
|
||||
if (info->dlpi_phdr[i].p_type == PT_TLS) {
|
||||
static_cast<InternalMmapVector<TlsBlock> *>(data)->push_back(
|
||||
@@ -624,9 +624,11 @@
|
||||
# elif SANITIZER_FREEBSD
|
||||
*size += 128; // RTLD_STATIC_TLS_EXTRA
|
||||
# if defined(__mips__) || defined(__powerpc64__) || SANITIZER_RISCV64
|
||||
+# if SANITIZER_GLIBC
|
||||
const uptr pre_tcb_size = TlsPreTcbSize();
|
||||
*addr -= pre_tcb_size;
|
||||
*size += pre_tcb_size;
|
||||
+# endif
|
||||
# else
|
||||
// arm and aarch64 reserve two words at TP, so this underestimates the range.
|
||||
// However, this is sufficient for the purpose of finding the pointers to
|
||||
|
||||
--
|
||||
2.49.0
|
||||
|
||||
|
|
@ -0,0 +1,25 @@
|
|||
From 104af6e2a6816af2448c668ab58d3dd28771e90a Mon Sep 17 00:00:00 2001
|
||||
From: q66 <q66@chimera-linux.org>
|
||||
Date: Wed, 6 Apr 2022 00:58:39 +0200
|
||||
Subject: [PATCH 09/29] compiler-rt: HACK: hwasan build on x86_64
|
||||
|
||||
---
|
||||
compiler-rt/lib/hwasan/hwasan_exceptions.cpp | 2 +-
|
||||
1 file changed, 1 insertion(+), 1 deletion(-)
|
||||
|
||||
diff --git a/compiler-rt/lib/hwasan/hwasan_exceptions.cpp b/compiler-rt/lib/hwasan/hwasan_exceptions.cpp
|
||||
index bf700bf56..2c1f1b173 100644
|
||||
--- a/compiler-rt/lib/hwasan/hwasan_exceptions.cpp
|
||||
+++ b/compiler-rt/lib/hwasan/hwasan_exceptions.cpp
|
||||
@@ -14,7 +14,7 @@
|
||||
#include "hwasan_poisoning.h"
|
||||
#include "sanitizer_common/sanitizer_common.h"
|
||||
|
||||
-#include <unwind.h>
|
||||
+#include "../../../clang/lib/Headers/unwind.h"
|
||||
|
||||
using namespace __hwasan;
|
||||
using namespace __sanitizer;
|
||||
--
|
||||
2.49.0
|
||||
|
||||
|
|
@ -0,0 +1,77 @@
|
|||
From 223f5481951047fa74a74d57819bb082aa462447 Mon Sep 17 00:00:00 2001
|
||||
From: q66 <q66@chimera-linux.org>
|
||||
Date: Sun, 14 Apr 2024 14:42:37 +0200
|
||||
Subject: [PATCH 10/29] compiler-rt,libcxx(abi),libunwind: HACK: force -fno-lto
|
||||
|
||||
Also do -ftrivial-auto-var-init=unitialized for libunwind, as it appears
|
||||
to break unwinding in strange ways with C++ on ppc64le, particularly with
|
||||
LTO; this needs to be investigated properly though.
|
||||
|
||||
https://github.com/llvm/llvm-project/issues/76771
|
||||
---
|
||||
compiler-rt/lib/builtins/CMakeLists.txt | 2 +-
|
||||
libcxx/CMakeLists.txt | 4 ++++
|
||||
libcxxabi/CMakeLists.txt | 4 ++++
|
||||
libunwind/src/CMakeLists.txt | 3 +++
|
||||
4 files changed, 12 insertions(+), 1 deletion(-)
|
||||
|
||||
diff --git a/compiler-rt/lib/builtins/CMakeLists.txt b/compiler-rt/lib/builtins/CMakeLists.txt
|
||||
index f89cf87c7..51f59457a 100644
|
||||
--- a/compiler-rt/lib/builtins/CMakeLists.txt
|
||||
+++ b/compiler-rt/lib/builtins/CMakeLists.txt
|
||||
@@ -756,7 +756,7 @@ if (APPLE)
|
||||
add_subdirectory(macho_embedded)
|
||||
darwin_add_builtin_libraries(${BUILTIN_SUPPORTED_OS})
|
||||
else ()
|
||||
- set(BUILTIN_CFLAGS "")
|
||||
+ set(BUILTIN_CFLAGS "-fno-lto")
|
||||
add_security_warnings(BUILTIN_CFLAGS 0)
|
||||
|
||||
if (COMPILER_RT_HAS_FCF_PROTECTION_FLAG)
|
||||
diff --git a/libcxx/CMakeLists.txt b/libcxx/CMakeLists.txt
|
||||
index abe12c280..17cf7c7ed 100644
|
||||
--- a/libcxx/CMakeLists.txt
|
||||
+++ b/libcxx/CMakeLists.txt
|
||||
@@ -575,6 +575,10 @@ function(cxx_add_rtti_flags target)
|
||||
target_add_compile_flags_if_supported(${target} PUBLIC -fno-rtti)
|
||||
endif()
|
||||
endif()
|
||||
+
|
||||
+ target_add_compile_flags_if_supported(${target} PRIVATE "-fno-lto")
|
||||
+ target_add_link_flags_if_supported(${target} PRIVATE "-fno-lto")
|
||||
+ target_add_link_flags_if_supported(${target} PRIVATE "-rtlib=compiler-rt")
|
||||
endfunction()
|
||||
|
||||
# Modules flags ===============================================================
|
||||
diff --git a/libcxxabi/CMakeLists.txt b/libcxxabi/CMakeLists.txt
|
||||
index 6dcfc51e5..1d03714f5 100644
|
||||
--- a/libcxxabi/CMakeLists.txt
|
||||
+++ b/libcxxabi/CMakeLists.txt
|
||||
@@ -331,6 +331,10 @@ else()
|
||||
add_compile_flags_if_supported(-EHa-)
|
||||
endif()
|
||||
|
||||
+add_compile_flags("-fno-lto")
|
||||
+add_link_flags("-fno-lto")
|
||||
+add_link_flags("-rtlib=compiler-rt")
|
||||
+
|
||||
# Assert
|
||||
string(TOUPPER "${CMAKE_BUILD_TYPE}" uppercase_CMAKE_BUILD_TYPE)
|
||||
if (LIBCXXABI_ENABLE_ASSERTIONS)
|
||||
diff --git a/libunwind/src/CMakeLists.txt b/libunwind/src/CMakeLists.txt
|
||||
index ecbd019bb..ec4108bd9 100644
|
||||
--- a/libunwind/src/CMakeLists.txt
|
||||
+++ b/libunwind/src/CMakeLists.txt
|
||||
@@ -136,6 +136,9 @@ if (HAIKU)
|
||||
endif()
|
||||
endif ()
|
||||
|
||||
+add_compile_flags("-fno-lto -ftrivial-auto-var-init=uninitialized")
|
||||
+add_link_flags("-fno-lto -ftrivial-auto-var-init=uninitialized")
|
||||
+
|
||||
string(REPLACE ";" " " LIBUNWIND_COMPILE_FLAGS "${LIBUNWIND_COMPILE_FLAGS}")
|
||||
string(REPLACE ";" " " LIBUNWIND_CXX_FLAGS "${LIBUNWIND_CXX_FLAGS}")
|
||||
string(REPLACE ";" " " LIBUNWIND_C_FLAGS "${LIBUNWIND_C_FLAGS}")
|
||||
--
|
||||
2.49.0
|
||||
|
||||
|
|
@ -0,0 +1,51 @@
|
|||
From 89eaf55d6533d180e6eb9b58f36f19e70c1c03e4 Mon Sep 17 00:00:00 2001
|
||||
From: q66 <q66@chimera-linux.org>
|
||||
Date: Sat, 4 Nov 2023 09:04:56 +0100
|
||||
Subject: [PATCH 11/29] compiler-rt: HACK: always compile in gcc_personality_v0
|
||||
|
||||
Looks like HAVE_UNWIND_H is not accounted for when doing the
|
||||
runtimes build, but this is the only place where it's checked.
|
||||
|
||||
Unconditionally compile it in because some things use it.
|
||||
---
|
||||
compiler-rt/lib/builtins/CMakeLists.txt | 10 ++++------
|
||||
compiler-rt/lib/builtins/gcc_personality_v0.c | 2 +-
|
||||
2 files changed, 5 insertions(+), 7 deletions(-)
|
||||
|
||||
diff --git a/compiler-rt/lib/builtins/CMakeLists.txt b/compiler-rt/lib/builtins/CMakeLists.txt
|
||||
index 51f59457a..20e4a6eb9 100644
|
||||
--- a/compiler-rt/lib/builtins/CMakeLists.txt
|
||||
+++ b/compiler-rt/lib/builtins/CMakeLists.txt
|
||||
@@ -227,12 +227,10 @@ if(APPLE)
|
||||
)
|
||||
endif()
|
||||
|
||||
-if (HAVE_UNWIND_H)
|
||||
- set(GENERIC_SOURCES
|
||||
- ${GENERIC_SOURCES}
|
||||
- gcc_personality_v0.c
|
||||
- )
|
||||
-endif ()
|
||||
+set(GENERIC_SOURCES
|
||||
+ ${GENERIC_SOURCES}
|
||||
+ gcc_personality_v0.c
|
||||
+)
|
||||
|
||||
if (NOT FUCHSIA)
|
||||
set(GENERIC_SOURCES
|
||||
diff --git a/compiler-rt/lib/builtins/gcc_personality_v0.c b/compiler-rt/lib/builtins/gcc_personality_v0.c
|
||||
index ef63a5fb8..5a0a90b38 100644
|
||||
--- a/compiler-rt/lib/builtins/gcc_personality_v0.c
|
||||
+++ b/compiler-rt/lib/builtins/gcc_personality_v0.c
|
||||
@@ -9,7 +9,7 @@
|
||||
#include "int_lib.h"
|
||||
#include <stddef.h>
|
||||
|
||||
-#include <unwind.h>
|
||||
+#include "../../../libunwind/include/unwind.h"
|
||||
#if defined(__arm__) && !defined(__ARM_DWARF_EH__) && \
|
||||
!defined(__USING_SJLJ_EXCEPTIONS__)
|
||||
// When building with older compilers (e.g. clang <3.9), it is possible that we
|
||||
--
|
||||
2.49.0
|
||||
|
||||
|
|
@ -0,0 +1,67 @@
|
|||
From 2e1760e66725a8afabf9dd3680312a54403c8e53 Mon Sep 17 00:00:00 2001
|
||||
From: q66 <q66@chimera-linux.org>
|
||||
Date: Fri, 29 Nov 2024 19:42:47 +0100
|
||||
Subject: [PATCH 12/29] libc++,libc++abi,libunwind: disable multiarch locations
|
||||
|
||||
---
|
||||
libcxx/CMakeLists.txt | 2 +-
|
||||
libcxx/test/benchmarks/CMakeLists.txt | 2 +-
|
||||
libcxxabi/CMakeLists.txt | 2 +-
|
||||
libunwind/CMakeLists.txt | 2 +-
|
||||
4 files changed, 4 insertions(+), 4 deletions(-)
|
||||
|
||||
diff --git a/libcxx/CMakeLists.txt b/libcxx/CMakeLists.txt
|
||||
index 17cf7c7ed..6eba3b170 100644
|
||||
--- a/libcxx/CMakeLists.txt
|
||||
+++ b/libcxx/CMakeLists.txt
|
||||
@@ -414,7 +414,7 @@ set(LIBCXX_INSTALL_MODULES_DIR "share/libc++/v1" CACHE STRING
|
||||
set(LIBCXX_SHARED_OUTPUT_NAME "c++" CACHE STRING "Output name for the shared libc++ runtime library.")
|
||||
set(LIBCXX_STATIC_OUTPUT_NAME "c++" CACHE STRING "Output name for the static libc++ runtime library.")
|
||||
|
||||
-if(LLVM_ENABLE_PER_TARGET_RUNTIME_DIR AND NOT APPLE)
|
||||
+if(LLVM_ENABLE_PER_TARGET_RUNTIME_DIR AND NOT APPLE AND NOT CMAKE_SYSTEM_NAME MATCHES "Linux")
|
||||
set(LIBCXX_TARGET_SUBDIR ${LLVM_DEFAULT_TARGET_TRIPLE})
|
||||
if(LIBCXX_LIBDIR_SUBDIR)
|
||||
string(APPEND LIBCXX_TARGET_SUBDIR /${LIBCXX_LIBDIR_SUBDIR})
|
||||
diff --git a/libcxx/test/benchmarks/CMakeLists.txt b/libcxx/test/benchmarks/CMakeLists.txt
|
||||
index b0fe60062..304d68e10 100644
|
||||
--- a/libcxx/test/benchmarks/CMakeLists.txt
|
||||
+++ b/libcxx/test/benchmarks/CMakeLists.txt
|
||||
@@ -11,7 +11,7 @@ set(BENCHMARK_COMPILE_FLAGS
|
||||
-Wl,-rpath,${LIBCXX_LIBRARY_DIR}
|
||||
${SANITIZER_FLAGS}
|
||||
)
|
||||
-if(LLVM_ENABLE_PER_TARGET_RUNTIME_DIR AND NOT APPLE)
|
||||
+if(LLVM_ENABLE_PER_TARGET_RUNTIME_DIR AND NOT APPLE AND NOT CMAKE_SYSTEM_NAME MATCHES "Linux")
|
||||
list(APPEND BENCHMARK_COMPILE_FLAGS
|
||||
-isystem "${LIBCXX_GENERATED_INCLUDE_TARGET_DIR}")
|
||||
endif()
|
||||
diff --git a/libcxxabi/CMakeLists.txt b/libcxxabi/CMakeLists.txt
|
||||
index 1d03714f5..d69813bd0 100644
|
||||
--- a/libcxxabi/CMakeLists.txt
|
||||
+++ b/libcxxabi/CMakeLists.txt
|
||||
@@ -182,7 +182,7 @@ set(CMAKE_MODULE_PATH
|
||||
set(LIBCXXABI_INSTALL_RUNTIME_DIR "${CMAKE_INSTALL_BINDIR}" CACHE STRING
|
||||
"Path where built libc++abi runtime libraries should be installed.")
|
||||
|
||||
-if(LLVM_ENABLE_PER_TARGET_RUNTIME_DIR AND NOT APPLE)
|
||||
+if(LLVM_ENABLE_PER_TARGET_RUNTIME_DIR AND NOT APPLE AND NOT CMAKE_SYSTEM_NAME MATCHES "Linux")
|
||||
set(LIBCXXABI_TARGET_SUBDIR ${LLVM_DEFAULT_TARGET_TRIPLE})
|
||||
if(LIBCXXABI_LIBDIR_SUBDIR)
|
||||
string(APPEND LIBCXXABI_TARGET_SUBDIR /${LIBCXXABI_LIBDIR_SUBDIR})
|
||||
diff --git a/libunwind/CMakeLists.txt b/libunwind/CMakeLists.txt
|
||||
index 3c8499fd3..93b078659 100644
|
||||
--- a/libunwind/CMakeLists.txt
|
||||
+++ b/libunwind/CMakeLists.txt
|
||||
@@ -140,7 +140,7 @@ set(LIBUNWIND_INSTALL_RUNTIME_DIR "${CMAKE_INSTALL_BINDIR}" CACHE STRING
|
||||
set(LIBUNWIND_SHARED_OUTPUT_NAME "unwind" CACHE STRING "Output name for the shared libunwind runtime library.")
|
||||
set(LIBUNWIND_STATIC_OUTPUT_NAME "unwind" CACHE STRING "Output name for the static libunwind runtime library.")
|
||||
|
||||
-if(LLVM_ENABLE_PER_TARGET_RUNTIME_DIR AND NOT APPLE)
|
||||
+if(LLVM_ENABLE_PER_TARGET_RUNTIME_DIR AND NOT APPLE AND NOT CMAKE_SYSTEM_NAME MATCHES "Linux")
|
||||
set(LIBUNWIND_TARGET_SUBDIR ${LLVM_DEFAULT_TARGET_TRIPLE})
|
||||
if(LIBUNWIND_LIBDIR_SUBDIR)
|
||||
string(APPEND LIBUNWIND_TARGET_SUBDIR /${LIBUNWIND_LIBDIR_SUBDIR})
|
||||
--
|
||||
2.49.0
|
||||
|
||||
|
|
@ -0,0 +1,66 @@
|
|||
From 194f8e7519bec165fefcaf2a4be82cfd4c271a7d Mon Sep 17 00:00:00 2001
|
||||
From: q66 <q66@chimera-linux.org>
|
||||
Date: Wed, 16 Apr 2025 00:30:51 +0200
|
||||
Subject: [PATCH 13/29] llvm: fix isOSGlibc thinking musl is glibc
|
||||
|
||||
---
|
||||
llvm/include/llvm/TargetParser/Triple.h | 2 +-
|
||||
llvm/lib/Target/X86/X86ISelDAGToDAG.cpp | 2 +-
|
||||
llvm/lib/Target/X86/X86ISelLoweringCall.cpp | 2 +-
|
||||
llvm/lib/Target/X86/X86Subtarget.h | 1 +
|
||||
4 files changed, 4 insertions(+), 3 deletions(-)
|
||||
|
||||
diff --git a/llvm/include/llvm/TargetParser/Triple.h b/llvm/include/llvm/TargetParser/Triple.h
|
||||
index 7d67966d1..721a7a3e1 100644
|
||||
--- a/llvm/include/llvm/TargetParser/Triple.h
|
||||
+++ b/llvm/include/llvm/TargetParser/Triple.h
|
||||
@@ -737,7 +737,7 @@ public:
|
||||
bool isOSGlibc() const {
|
||||
return (getOS() == Triple::Linux || getOS() == Triple::KFreeBSD ||
|
||||
getOS() == Triple::Hurd) &&
|
||||
- !isAndroid();
|
||||
+ !isAndroid() && !isMusl();
|
||||
}
|
||||
|
||||
/// Tests whether the OS is AIX.
|
||||
diff --git a/llvm/lib/Target/X86/X86ISelDAGToDAG.cpp b/llvm/lib/Target/X86/X86ISelDAGToDAG.cpp
|
||||
index 84bcdae52..b6a8ce0ee 100644
|
||||
--- a/llvm/lib/Target/X86/X86ISelDAGToDAG.cpp
|
||||
+++ b/llvm/lib/Target/X86/X86ISelDAGToDAG.cpp
|
||||
@@ -1876,7 +1876,7 @@ bool X86DAGToDAGISel::matchLoadInAddress(LoadSDNode *N, X86ISelAddressMode &AM,
|
||||
// For more information see http://people.redhat.com/drepper/tls.pdf
|
||||
if (isNullConstant(Address) && AM.Segment.getNode() == nullptr &&
|
||||
!IndirectTlsSegRefs &&
|
||||
- (Subtarget->isTargetGlibc() || Subtarget->isTargetAndroid() ||
|
||||
+ (Subtarget->isTargetGlibc() || Subtarget->isTargetMusl() || Subtarget->isTargetAndroid() ||
|
||||
Subtarget->isTargetFuchsia())) {
|
||||
if (Subtarget->isTarget64BitILP32() && !AllowSegmentRegForX32)
|
||||
return true;
|
||||
diff --git a/llvm/lib/Target/X86/X86ISelLoweringCall.cpp b/llvm/lib/Target/X86/X86ISelLoweringCall.cpp
|
||||
index 6835c7e33..50eb2384b 100644
|
||||
--- a/llvm/lib/Target/X86/X86ISelLoweringCall.cpp
|
||||
+++ b/llvm/lib/Target/X86/X86ISelLoweringCall.cpp
|
||||
@@ -536,7 +536,7 @@ unsigned X86TargetLowering::getAddressSpace() const {
|
||||
}
|
||||
|
||||
static bool hasStackGuardSlotTLS(const Triple &TargetTriple) {
|
||||
- return TargetTriple.isOSGlibc() || TargetTriple.isOSFuchsia() ||
|
||||
+ return TargetTriple.isOSGlibc() || TargetTriple.isOSFuchsia() || TargetTriple.isMusl() ||
|
||||
(TargetTriple.isAndroid() && !TargetTriple.isAndroidVersionLT(17));
|
||||
}
|
||||
|
||||
diff --git a/llvm/lib/Target/X86/X86Subtarget.h b/llvm/lib/Target/X86/X86Subtarget.h
|
||||
index 722076ca8..c2fc60eff 100644
|
||||
--- a/llvm/lib/Target/X86/X86Subtarget.h
|
||||
+++ b/llvm/lib/Target/X86/X86Subtarget.h
|
||||
@@ -295,6 +295,7 @@ public:
|
||||
bool isTargetLinux() const { return TargetTriple.isOSLinux(); }
|
||||
bool isTargetKFreeBSD() const { return TargetTriple.isOSKFreeBSD(); }
|
||||
bool isTargetGlibc() const { return TargetTriple.isOSGlibc(); }
|
||||
+ bool isTargetMusl() const { return TargetTriple.isMusl(); }
|
||||
bool isTargetAndroid() const { return TargetTriple.isAndroid(); }
|
||||
bool isTargetNaCl() const { return TargetTriple.isOSNaCl(); }
|
||||
bool isTargetNaCl32() const { return isTargetNaCl() && !is64Bit(); }
|
||||
--
|
||||
2.49.0
|
||||
|
||||
|
|
@ -0,0 +1,28 @@
|
|||
From a131432945a9183642bab22188f03969a3855e40 Mon Sep 17 00:00:00 2001
|
||||
From: q66 <q66@chimera-linux.org>
|
||||
Date: Sat, 4 Nov 2023 09:08:54 +0100
|
||||
Subject: [PATCH 14/29] clang: disable multiarch layout on musl
|
||||
|
||||
---
|
||||
clang/lib/Driver/ToolChains/Linux.cpp | 5 +++++
|
||||
1 file changed, 5 insertions(+)
|
||||
|
||||
diff --git a/clang/lib/Driver/ToolChains/Linux.cpp b/clang/lib/Driver/ToolChains/Linux.cpp
|
||||
index 0767fe6c5..2ac0139dc 100644
|
||||
--- a/clang/lib/Driver/ToolChains/Linux.cpp
|
||||
+++ b/clang/lib/Driver/ToolChains/Linux.cpp
|
||||
@@ -47,6 +47,11 @@ std::string Linux::getMultiarchTriple(const Driver &D,
|
||||
bool IsMipsR6 = TargetTriple.getSubArch() == llvm::Triple::MipsSubArch_r6;
|
||||
bool IsMipsN32Abi = TargetTriple.getEnvironment() == llvm::Triple::GNUABIN32;
|
||||
|
||||
+ /* we are not multiarch */
|
||||
+ if (TargetTriple.isMusl()) {
|
||||
+ return "";
|
||||
+ }
|
||||
+
|
||||
// For most architectures, just use whatever we have rather than trying to be
|
||||
// clever.
|
||||
switch (TargetTriple.getArch()) {
|
||||
--
|
||||
2.49.0
|
||||
|
||||
|
|
@ -0,0 +1,26 @@
|
|||
From 08d4933ae45501fddb33795628bd313e0094d009 Mon Sep 17 00:00:00 2001
|
||||
From: q66 <q66@chimera-linux.org>
|
||||
Date: Sun, 14 Apr 2024 14:46:54 +0200
|
||||
Subject: [PATCH 15/29] clang: drop incorrect warning about vector equality
|
||||
results
|
||||
|
||||
---
|
||||
clang/lib/Sema/SemaExpr.cpp | 2 --
|
||||
1 file changed, 2 deletions(-)
|
||||
|
||||
diff --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp
|
||||
index e253e3a17..52e2bcf51 100644
|
||||
--- a/clang/lib/Sema/SemaExpr.cpp
|
||||
+++ b/clang/lib/Sema/SemaExpr.cpp
|
||||
@@ -12780,8 +12780,6 @@ QualType Sema::CheckVectorCompareOperands(ExprResult &LHS, ExprResult &RHS,
|
||||
if (vType->castAs<VectorType>()->getVectorKind() ==
|
||||
VectorKind::AltiVecVector)
|
||||
return Context.getLogicalOperationType();
|
||||
- else
|
||||
- Diag(Loc, diag::warn_deprecated_altivec_src_compat);
|
||||
break;
|
||||
case LangOptions::AltivecSrcCompatKind::GCC:
|
||||
// For GCC we always return the vector type.
|
||||
--
|
||||
2.49.0
|
||||
|
||||
|
|
@ -0,0 +1,53 @@
|
|||
From e54c80ab9def177802bb2bd758041933db24f76a Mon Sep 17 00:00:00 2001
|
||||
From: q66 <q66@chimera-linux.org>
|
||||
Date: Sun, 14 Apr 2024 14:47:34 +0200
|
||||
Subject: [PATCH 16/29] clang: add fortify include paths for musl triplets +
|
||||
enable fortify
|
||||
|
||||
---
|
||||
clang/lib/Driver/ToolChains/Linux.cpp | 12 ++++++++----
|
||||
clang/lib/Frontend/InitPreprocessor.cpp | 5 +++++
|
||||
2 files changed, 13 insertions(+), 4 deletions(-)
|
||||
|
||||
diff --git a/clang/lib/Driver/ToolChains/Linux.cpp b/clang/lib/Driver/ToolChains/Linux.cpp
|
||||
index 2ac0139dc..9a9b40a25 100644
|
||||
--- a/clang/lib/Driver/ToolChains/Linux.cpp
|
||||
+++ b/clang/lib/Driver/ToolChains/Linux.cpp
|
||||
@@ -688,10 +688,14 @@ void Linux::AddClangSystemIncludeArgs(const ArgList &DriverArgs,
|
||||
if (getTriple().getOS() == llvm::Triple::RTEMS)
|
||||
return;
|
||||
|
||||
- // Add an include of '/include' directly. This isn't provided by default by
|
||||
- // system GCCs, but is often used with cross-compiling GCCs, and harmless to
|
||||
- // add even when Clang is acting as-if it were a system compiler.
|
||||
- addExternCSystemInclude(DriverArgs, CC1Args, concat(SysRoot, "/include"));
|
||||
+ if (getTriple().isMusl()) {
|
||||
+ addExternCSystemInclude(DriverArgs, CC1Args, concat(SysRoot, "/usr/include/fortify"));
|
||||
+ } else {
|
||||
+ // Preserve original clang behavior for non-musl triples, but for musl
|
||||
+ // this just gets in the way and none of our crosstoolchains are ever
|
||||
+ // actually built this way (and we'd have to figure out fortify for it)
|
||||
+ addExternCSystemInclude(DriverArgs, CC1Args, concat(SysRoot, "/include"));
|
||||
+ }
|
||||
|
||||
addExternCSystemInclude(DriverArgs, CC1Args, concat(SysRoot, "/usr/include"));
|
||||
|
||||
diff --git a/clang/lib/Frontend/InitPreprocessor.cpp b/clang/lib/Frontend/InitPreprocessor.cpp
|
||||
index 17f624e96..c239342fa 100644
|
||||
--- a/clang/lib/Frontend/InitPreprocessor.cpp
|
||||
+++ b/clang/lib/Frontend/InitPreprocessor.cpp
|
||||
@@ -1523,6 +1523,11 @@ static void InitializePredefinedMacros(const TargetInfo &TI,
|
||||
#undef TARGET_OS
|
||||
}
|
||||
|
||||
+ // Enable fortify by default on musl when optimizing, but not with asan
|
||||
+ if (TI.getTriple().isMusl() && LangOpts.Optimize &&
|
||||
+ !LangOpts.Sanitize.has(SanitizerKind::Address))
|
||||
+ Builder.defineMacro("_FORTIFY_SOURCE", "3");
|
||||
+
|
||||
// Get other target #defines.
|
||||
TI.getTargetDefines(LangOpts, Builder);
|
||||
}
|
||||
--
|
||||
2.49.0
|
||||
|
||||
30
patches/llvm/0017-clang-use-as-needed-by-default.patch
Normal file
30
patches/llvm/0017-clang-use-as-needed-by-default.patch
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
From eaf3a6393892bd36899f3ccb8782e7c6a06d6a8f Mon Sep 17 00:00:00 2001
|
||||
From: q66 <q66@chimera-linux.org>
|
||||
Date: Sun, 14 Apr 2024 14:48:51 +0200
|
||||
Subject: [PATCH 17/29] clang: use --as-needed by default
|
||||
|
||||
---
|
||||
clang/lib/Driver/ToolChains/Gnu.cpp | 7 +++++++
|
||||
1 file changed, 7 insertions(+)
|
||||
|
||||
diff --git a/clang/lib/Driver/ToolChains/Gnu.cpp b/clang/lib/Driver/ToolChains/Gnu.cpp
|
||||
index f56eeda3c..5230be404 100644
|
||||
--- a/clang/lib/Driver/ToolChains/Gnu.cpp
|
||||
+++ b/clang/lib/Driver/ToolChains/Gnu.cpp
|
||||
@@ -541,6 +541,13 @@ void tools::gnutools::Linker::ConstructJob(Compilation &C, const JobAction &JA,
|
||||
bool NeedsSanitizerDeps = addSanitizerRuntimes(ToolChain, Args, CmdArgs);
|
||||
bool NeedsXRayDeps = addXRayRuntime(ToolChain, Args, CmdArgs);
|
||||
addLinkerCompressDebugSectionsOption(ToolChain, Args, CmdArgs);
|
||||
+
|
||||
+ // Use --as-needed by default for all explicit linker inputs on Linux
|
||||
+ // We don't reset it afterwards because explicit argument does not
|
||||
+ // get reset either (and that is permitted, so it should be fine)
|
||||
+ if (Triple.isOSLinux())
|
||||
+ CmdArgs.push_back("--as-needed");
|
||||
+
|
||||
AddLinkerInputs(ToolChain, Inputs, Args, CmdArgs, JA);
|
||||
|
||||
addHIPRuntimeLibArgs(ToolChain, C, Args, CmdArgs);
|
||||
--
|
||||
2.49.0
|
||||
|
||||
31
patches/llvm/0018-clang-switch-on-default-now-relro.patch
Normal file
31
patches/llvm/0018-clang-switch-on-default-now-relro.patch
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
From 8ebc91e973af382fbb0ef837400433106e3cd825 Mon Sep 17 00:00:00 2001
|
||||
From: q66 <q66@chimera-linux.org>
|
||||
Date: Sat, 4 Nov 2023 09:11:37 +0100
|
||||
Subject: [PATCH 18/29] clang: switch on default now/relro
|
||||
|
||||
---
|
||||
clang/lib/Driver/ToolChains/Linux.cpp | 4 ++--
|
||||
1 file changed, 2 insertions(+), 2 deletions(-)
|
||||
|
||||
diff --git a/clang/lib/Driver/ToolChains/Linux.cpp b/clang/lib/Driver/ToolChains/Linux.cpp
|
||||
index 9a9b40a25..57056ee2c 100644
|
||||
--- a/clang/lib/Driver/ToolChains/Linux.cpp
|
||||
+++ b/clang/lib/Driver/ToolChains/Linux.cpp
|
||||
@@ -228,12 +228,12 @@ Linux::Linux(const Driver &D, const llvm::Triple &Triple, const ArgList &Args)
|
||||
|
||||
Distro Distro(D.getVFS(), Triple);
|
||||
|
||||
- if (Distro.IsAlpineLinux() || Triple.isAndroid()) {
|
||||
+ if (Triple.isMusl() || Triple.isAndroid()) {
|
||||
ExtraOpts.push_back("-z");
|
||||
ExtraOpts.push_back("now");
|
||||
}
|
||||
|
||||
- if (Distro.IsOpenSUSE() || Distro.IsUbuntu() || Distro.IsAlpineLinux() ||
|
||||
+ if (Distro.IsOpenSUSE() || Distro.IsUbuntu() || Triple.isMusl() ||
|
||||
Triple.isAndroid()) {
|
||||
ExtraOpts.push_back("-z");
|
||||
ExtraOpts.push_back("relro");
|
||||
--
|
||||
2.49.0
|
||||
|
||||
|
|
@ -0,0 +1,27 @@
|
|||
From a30a86b7eb59e7ec5baace8e7252d38d7f8e15ed Mon Sep 17 00:00:00 2001
|
||||
From: q66 <q66@chimera-linux.org>
|
||||
Date: Sat, 4 Nov 2023 09:11:58 +0100
|
||||
Subject: [PATCH 19/29] clang: default to -fno-semantic-interposition
|
||||
|
||||
---
|
||||
clang/lib/Driver/ToolChains/Clang.cpp | 4 +---
|
||||
1 file changed, 1 insertion(+), 3 deletions(-)
|
||||
|
||||
diff --git a/clang/lib/Driver/ToolChains/Clang.cpp b/clang/lib/Driver/ToolChains/Clang.cpp
|
||||
index 57b7d2bd4..417b85899 100644
|
||||
--- a/clang/lib/Driver/ToolChains/Clang.cpp
|
||||
+++ b/clang/lib/Driver/ToolChains/Clang.cpp
|
||||
@@ -5824,9 +5824,7 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA,
|
||||
// The supported targets need to call AsmPrinter::getSymbolPreferLocal.
|
||||
bool SupportsLocalAlias =
|
||||
Triple.isAArch64() || Triple.isRISCV() || Triple.isX86();
|
||||
- if (!A)
|
||||
- CmdArgs.push_back("-fhalf-no-semantic-interposition");
|
||||
- else if (A->getOption().matches(options::OPT_fsemantic_interposition))
|
||||
+ if (A && A->getOption().matches(options::OPT_fsemantic_interposition))
|
||||
A->render(Args, CmdArgs);
|
||||
else if (!SupportsLocalAlias)
|
||||
CmdArgs.push_back("-fhalf-no-semantic-interposition");
|
||||
--
|
||||
2.49.0
|
||||
|
||||
|
|
@ -0,0 +1,33 @@
|
|||
From fafc3e8c4ab398e17911563f25b3fa8415cca69e Mon Sep 17 00:00:00 2001
|
||||
From: q66 <q66@chimera-linux.org>
|
||||
Date: Sat, 4 Nov 2023 09:12:24 +0100
|
||||
Subject: [PATCH 20/29] clang: implicitly link to libatomic on linux targets
|
||||
|
||||
---
|
||||
clang/lib/Driver/ToolChains/Gnu.cpp | 10 ++++++----
|
||||
1 file changed, 6 insertions(+), 4 deletions(-)
|
||||
|
||||
diff --git a/clang/lib/Driver/ToolChains/Gnu.cpp b/clang/lib/Driver/ToolChains/Gnu.cpp
|
||||
index 5230be404..8180d98c7 100644
|
||||
--- a/clang/lib/Driver/ToolChains/Gnu.cpp
|
||||
+++ b/clang/lib/Driver/ToolChains/Gnu.cpp
|
||||
@@ -613,10 +613,12 @@ void tools::gnutools::Linker::ConstructJob(Compilation &C, const JobAction &JA,
|
||||
|
||||
AddRunTimeLibs(ToolChain, D, CmdArgs, Args);
|
||||
|
||||
- // LLVM support for atomics on 32-bit SPARC V8+ is incomplete, so
|
||||
- // forcibly link with libatomic as a workaround.
|
||||
- // TODO: Issue #41880 and D118021.
|
||||
- if (getToolChain().getTriple().getArch() == llvm::Triple::sparc) {
|
||||
+ // implicitly link to libatomic, we don't want to bother with manually
|
||||
+ // adding this on platforms where libatomic is explicitly necessary,
|
||||
+ // and the as-needed will ensure it's left out when not needed
|
||||
+ //
|
||||
+ // chimera already ships its own version of libatomic, so it's fine
|
||||
+ if (Triple.isOSLinux()) {
|
||||
CmdArgs.push_back("--push-state");
|
||||
CmdArgs.push_back("--as-needed");
|
||||
CmdArgs.push_back("-latomic");
|
||||
--
|
||||
2.49.0
|
||||
|
||||
|
|
@ -0,0 +1,28 @@
|
|||
From ea82d4de395f920a4c8d13ed9bc152f95c986ded Mon Sep 17 00:00:00 2001
|
||||
From: q66 <q66@chimera-linux.org>
|
||||
Date: Tue, 2 May 2023 16:23:22 +0200
|
||||
Subject: [PATCH 21/29] clang: use strong stack protector by default
|
||||
|
||||
---
|
||||
clang/lib/Driver/ToolChains/Linux.h | 5 +++++
|
||||
1 file changed, 5 insertions(+)
|
||||
|
||||
diff --git a/clang/lib/Driver/ToolChains/Linux.h b/clang/lib/Driver/ToolChains/Linux.h
|
||||
index 2eb2d0578..80a0b035c 100644
|
||||
--- a/clang/lib/Driver/ToolChains/Linux.h
|
||||
+++ b/clang/lib/Driver/ToolChains/Linux.h
|
||||
@@ -63,6 +63,11 @@ public:
|
||||
|
||||
const char *getDefaultLinker() const override;
|
||||
|
||||
+ LangOptions::StackProtectorMode
|
||||
+ GetDefaultStackProtectorLevel(bool KernelOrKext) const override {
|
||||
+ return LangOptions::SSPStrong;
|
||||
+ }
|
||||
+
|
||||
protected:
|
||||
Tool *buildAssembler() const override;
|
||||
Tool *buildLinker() const override;
|
||||
--
|
||||
2.49.0
|
||||
|
||||
46
patches/llvm/0022-clang-fix-unwind-chain-inclusion.patch
Normal file
46
patches/llvm/0022-clang-fix-unwind-chain-inclusion.patch
Normal file
|
|
@ -0,0 +1,46 @@
|
|||
From 5b9530079f3623af96d47938adec11eefde65974 Mon Sep 17 00:00:00 2001
|
||||
From: q66 <q66@chimera-linux.org>
|
||||
Date: Tue, 2 May 2023 16:25:59 +0200
|
||||
Subject: [PATCH 22/29] clang: fix unwind chain inclusion
|
||||
|
||||
This fixes the compiler complaining about the __has_include_next.
|
||||
---
|
||||
clang/lib/Headers/unwind.h | 9 +++++----
|
||||
1 file changed, 5 insertions(+), 4 deletions(-)
|
||||
|
||||
diff --git a/clang/lib/Headers/unwind.h b/clang/lib/Headers/unwind.h
|
||||
index 33e1792cd..a32e18cda 100644
|
||||
--- a/clang/lib/Headers/unwind.h
|
||||
+++ b/clang/lib/Headers/unwind.h
|
||||
@@ -9,9 +9,6 @@
|
||||
|
||||
/* See "Data Definitions for libgcc_s" in the Linux Standard Base.*/
|
||||
|
||||
-#ifndef __CLANG_UNWIND_H
|
||||
-#define __CLANG_UNWIND_H
|
||||
-
|
||||
#if defined(__APPLE__) && __has_include_next(<unwind.h>)
|
||||
/* Darwin (from 11.x on) provide an unwind.h. If that's available,
|
||||
* use it. libunwind wraps some of its definitions in #ifdef _GNU_SOURCE,
|
||||
@@ -39,6 +36,9 @@
|
||||
# endif
|
||||
#else
|
||||
|
||||
+#ifndef __CLANG_UNWIND_H
|
||||
+#define __CLANG_UNWIND_H
|
||||
+
|
||||
#include <stdint.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
@@ -327,6 +327,7 @@ _Unwind_Ptr _Unwind_GetTextRelBase(struct _Unwind_Context *);
|
||||
}
|
||||
#endif
|
||||
|
||||
+#endif /* __CLANG_UNWIND_H */
|
||||
+
|
||||
#endif
|
||||
|
||||
-#endif /* __CLANG_UNWIND_H */
|
||||
--
|
||||
2.49.0
|
||||
|
||||
|
|
@ -0,0 +1,31 @@
|
|||
From 6838a67da41425e2268ce7b4e807669986c3699e Mon Sep 17 00:00:00 2001
|
||||
From: q66 <q66@chimera-linux.org>
|
||||
Date: Fri, 29 Nov 2024 19:46:27 +0100
|
||||
Subject: [PATCH 23/29] clang: error when using ifunc attribute on unsupported
|
||||
targets
|
||||
|
||||
---
|
||||
clang/lib/Sema/SemaDeclAttr.cpp | 7 +++++++
|
||||
1 file changed, 7 insertions(+)
|
||||
|
||||
diff --git a/clang/lib/Sema/SemaDeclAttr.cpp b/clang/lib/Sema/SemaDeclAttr.cpp
|
||||
index f351663c6..7138d953b 100644
|
||||
--- a/clang/lib/Sema/SemaDeclAttr.cpp
|
||||
+++ b/clang/lib/Sema/SemaDeclAttr.cpp
|
||||
@@ -1721,6 +1721,13 @@ static void handleIFuncAttr(Sema &S, Decl *D, const ParsedAttr &AL) {
|
||||
return;
|
||||
}
|
||||
|
||||
+ // Unsupported targets should raise a diagnostic error.
|
||||
+ if (!S.Context.getTargetInfo().supportsIFunc()) {
|
||||
+ S.Diag(AL.getLoc(), diag::err_keyword_not_supported_on_target)
|
||||
+ << AL << AL.getRange();
|
||||
+ return;
|
||||
+ }
|
||||
+
|
||||
markUsedForAliasOrIfunc(S, D, AL, Str);
|
||||
D->addAttr(::new (S.Context) IFuncAttr(S.Context, AL, Str));
|
||||
}
|
||||
--
|
||||
2.49.0
|
||||
|
||||
|
|
@ -0,0 +1,52 @@
|
|||
From 943608475319da1db4f44b74862ef9e321d14825 Mon Sep 17 00:00:00 2001
|
||||
From: q66 <q66@chimera-linux.org>
|
||||
Date: Sat, 4 Nov 2023 09:14:35 +0100
|
||||
Subject: [PATCH 24/29] clang: link libcxxabi on linux when using libc++
|
||||
|
||||
---
|
||||
clang/lib/Driver/ToolChains/Linux.cpp | 15 +++++++++++++++
|
||||
clang/lib/Driver/ToolChains/Linux.h | 2 ++
|
||||
2 files changed, 17 insertions(+)
|
||||
|
||||
diff --git a/clang/lib/Driver/ToolChains/Linux.cpp b/clang/lib/Driver/ToolChains/Linux.cpp
|
||||
index 57056ee2c..68a7eae38 100644
|
||||
--- a/clang/lib/Driver/ToolChains/Linux.cpp
|
||||
+++ b/clang/lib/Driver/ToolChains/Linux.cpp
|
||||
@@ -744,6 +744,21 @@ void Linux::addLibStdCxxIncludePaths(const llvm::opt::ArgList &DriverArgs,
|
||||
}
|
||||
}
|
||||
|
||||
+void Linux::AddCXXStdlibLibArgs(const ArgList &Args,
|
||||
+ ArgStringList &CmdArgs) const {
|
||||
+ switch (GetCXXStdlibType(Args)) {
|
||||
+ case ToolChain::CST_Libcxx:
|
||||
+ CmdArgs.push_back("-lc++");
|
||||
+ if (Args.hasArg(options::OPT_fexperimental_library))
|
||||
+ CmdArgs.push_back("-lc++experimental");
|
||||
+ CmdArgs.push_back("-lc++abi");
|
||||
+ break;
|
||||
+ case ToolChain::CST_Libstdcxx:
|
||||
+ CmdArgs.push_back("-lstdc++");
|
||||
+ break;
|
||||
+ }
|
||||
+}
|
||||
+
|
||||
void Linux::AddCudaIncludeArgs(const ArgList &DriverArgs,
|
||||
ArgStringList &CC1Args) const {
|
||||
CudaInstallation->AddCudaIncludeArgs(DriverArgs, CC1Args);
|
||||
diff --git a/clang/lib/Driver/ToolChains/Linux.h b/clang/lib/Driver/ToolChains/Linux.h
|
||||
index 80a0b035c..cbb0032a8 100644
|
||||
--- a/clang/lib/Driver/ToolChains/Linux.h
|
||||
+++ b/clang/lib/Driver/ToolChains/Linux.h
|
||||
@@ -33,6 +33,8 @@ public:
|
||||
void addLibStdCxxIncludePaths(
|
||||
const llvm::opt::ArgList &DriverArgs,
|
||||
llvm::opt::ArgStringList &CC1Args) const override;
|
||||
+ void AddCXXStdlibLibArgs(const llvm::opt::ArgList &Args,
|
||||
+ llvm::opt::ArgStringList &CmdArgs) const override;
|
||||
void AddCudaIncludeArgs(const llvm::opt::ArgList &DriverArgs,
|
||||
llvm::opt::ArgStringList &CC1Args) const override;
|
||||
void AddHIPIncludeArgs(const llvm::opt::ArgList &DriverArgs,
|
||||
--
|
||||
2.49.0
|
||||
|
||||
|
|
@ -0,0 +1,33 @@
|
|||
From 6034012a6645830a453a48561480f3e8c2291fec Mon Sep 17 00:00:00 2001
|
||||
From: q66 <q66@chimera-linux.org>
|
||||
Date: Sat, 4 Nov 2023 09:20:52 +0100
|
||||
Subject: [PATCH 25/29] Get rid of spurious trailing space in __clang_version__
|
||||
|
||||
---
|
||||
clang/lib/Frontend/InitPreprocessor.cpp | 10 +++++++---
|
||||
1 file changed, 7 insertions(+), 3 deletions(-)
|
||||
|
||||
diff --git a/clang/lib/Frontend/InitPreprocessor.cpp b/clang/lib/Frontend/InitPreprocessor.cpp
|
||||
index c239342fa..3ee01ac9a 100644
|
||||
--- a/clang/lib/Frontend/InitPreprocessor.cpp
|
||||
+++ b/clang/lib/Frontend/InitPreprocessor.cpp
|
||||
@@ -866,9 +866,13 @@ static void InitializePredefinedMacros(const TargetInfo &TI,
|
||||
Builder.defineMacro("__clang_patchlevel__", TOSTR(CLANG_VERSION_PATCHLEVEL));
|
||||
#undef TOSTR
|
||||
#undef TOSTR2
|
||||
- Builder.defineMacro("__clang_version__",
|
||||
- "\"" CLANG_VERSION_STRING " "
|
||||
- + getClangFullRepositoryVersion() + "\"");
|
||||
+ auto fullver = getClangFullRepositoryVersion();
|
||||
+ if (!fullver.empty()) {
|
||||
+ Builder.defineMacro("__clang_version__",
|
||||
+ "\"" CLANG_VERSION_STRING " " + fullver + "\"");
|
||||
+ } else {
|
||||
+ Builder.defineMacro("__clang_version__", "\"" CLANG_VERSION_STRING "\"");
|
||||
+ }
|
||||
|
||||
if (LangOpts.GNUCVersion != 0) {
|
||||
// Major, minor, patch, are given two decimal places each, so 4.2.1 becomes
|
||||
--
|
||||
2.49.0
|
||||
|
||||
|
|
@ -0,0 +1,41 @@
|
|||
From c5c9ef16fd4a48f1131d319497fa16473f88d4da Mon Sep 17 00:00:00 2001
|
||||
From: q66 <q66@chimera-linux.org>
|
||||
Date: Sun, 14 Apr 2024 14:55:21 +0200
|
||||
Subject: [PATCH 26/29] clang: implicitly include stdc-predef.h
|
||||
|
||||
This behavior is required to match gcc and get default access
|
||||
to some macros to get rid of certain hacks (especially on musl,
|
||||
which does not explicitly include this - glibc includes it from
|
||||
features.h)
|
||||
|
||||
Inspired by https://reviews.llvm.org/D137043 but this should not
|
||||
be tied to libc choice, as gcc unconditionally does the preinclude
|
||||
for both.
|
||||
---
|
||||
clang/lib/Driver/ToolChains/Clang.cpp | 10 ++++++++++
|
||||
1 file changed, 10 insertions(+)
|
||||
|
||||
diff --git a/clang/lib/Driver/ToolChains/Clang.cpp b/clang/lib/Driver/ToolChains/Clang.cpp
|
||||
index 417b85899..2e583c39c 100644
|
||||
--- a/clang/lib/Driver/ToolChains/Clang.cpp
|
||||
+++ b/clang/lib/Driver/ToolChains/Clang.cpp
|
||||
@@ -1168,6 +1168,16 @@ void Clang::AddPreprocessingOptions(Compilation &C, const JobAction &JA,
|
||||
}
|
||||
}
|
||||
|
||||
+ // Follow gcc in pre-including stdc-predef.h in non-freestanding mode
|
||||
+ // Has to be done this early so that it comes before user-supplied -includes
|
||||
+ if (!Args.hasArg(options::OPT_nostdinc) &&
|
||||
+ !Args.hasArg(options::OPT_nostdlibinc) &&
|
||||
+ !Args.hasArg(options::OPT_ffreestanding) &&
|
||||
+ getToolChain().getTriple().isOSLinux()) {
|
||||
+ CmdArgs.push_back("-include");
|
||||
+ CmdArgs.push_back("stdc-predef.h");
|
||||
+ }
|
||||
+
|
||||
bool RenderedImplicitInclude = false;
|
||||
for (const Arg *A : Args.filtered(options::OPT_clang_i_Group)) {
|
||||
if (A->getOption().matches(options::OPT_include) &&
|
||||
--
|
||||
2.49.0
|
||||
|
||||
96
patches/llvm/0027-32-bit-musl-sanitizer-fixes.patch
Normal file
96
patches/llvm/0027-32-bit-musl-sanitizer-fixes.patch
Normal file
|
|
@ -0,0 +1,96 @@
|
|||
From aef527f16bc8cf69f5253691c807881538597d5f Mon Sep 17 00:00:00 2001
|
||||
From: Erica Z <zerica@callcc.eu>
|
||||
Date: Fri, 29 Nov 2024 19:49:16 +0100
|
||||
Subject: [PATCH 27/29] 32-bit musl sanitizer fixes
|
||||
|
||||
---
|
||||
.../lib/sanitizer_common/sanitizer_linux.cpp | 48 +++----------------
|
||||
1 file changed, 7 insertions(+), 41 deletions(-)
|
||||
|
||||
diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_linux.cpp b/compiler-rt/lib/sanitizer_common/sanitizer_linux.cpp
|
||||
index a782d5221..6ebf10aa6 100644
|
||||
--- a/compiler-rt/lib/sanitizer_common/sanitizer_linux.cpp
|
||||
+++ b/compiler-rt/lib/sanitizer_common/sanitizer_linux.cpp
|
||||
@@ -329,25 +329,6 @@ uptr internal_ftruncate(fd_t fd, uptr size) {
|
||||
return res;
|
||||
}
|
||||
|
||||
-# if !SANITIZER_LINUX_USES_64BIT_SYSCALLS && SANITIZER_LINUX
|
||||
-static void stat64_to_stat(struct stat64 *in, struct stat *out) {
|
||||
- internal_memset(out, 0, sizeof(*out));
|
||||
- out->st_dev = in->st_dev;
|
||||
- out->st_ino = in->st_ino;
|
||||
- out->st_mode = in->st_mode;
|
||||
- out->st_nlink = in->st_nlink;
|
||||
- out->st_uid = in->st_uid;
|
||||
- out->st_gid = in->st_gid;
|
||||
- out->st_rdev = in->st_rdev;
|
||||
- out->st_size = in->st_size;
|
||||
- out->st_blksize = in->st_blksize;
|
||||
- out->st_blocks = in->st_blocks;
|
||||
- out->st_atime = in->st_atime;
|
||||
- out->st_mtime = in->st_mtime;
|
||||
- out->st_ctime = in->st_ctime;
|
||||
-}
|
||||
-# endif
|
||||
-
|
||||
# if SANITIZER_LINUX && defined(__loongarch__)
|
||||
static void statx_to_stat(struct statx *in, struct stat *out) {
|
||||
internal_memset(out, 0, sizeof(*out));
|
||||
@@ -447,17 +428,11 @@ uptr internal_stat(const char *path, void *buf) {
|
||||
kernel_stat_to_stat(&buf64, (struct stat *)buf);
|
||||
return res;
|
||||
# else
|
||||
- struct stat64 buf64;
|
||||
- int res = internal_syscall(SYSCALL(fstatat64), AT_FDCWD, (uptr)path,
|
||||
- (uptr)&buf64, 0);
|
||||
- stat64_to_stat(&buf64, (struct stat *)buf);
|
||||
- return res;
|
||||
+ return internal_syscall(SYSCALL(fstatat64), AT_FDCWD, (uptr)path, (uptr)buf,
|
||||
+ 0);
|
||||
# endif
|
||||
# else
|
||||
- struct stat64 buf64;
|
||||
- int res = internal_syscall(SYSCALL(stat64), path, &buf64);
|
||||
- stat64_to_stat(&buf64, (struct stat *)buf);
|
||||
- return res;
|
||||
+ return internal_syscall(SYSCALL(stat64), path, (uptr)buf);
|
||||
# endif
|
||||
}
|
||||
|
||||
@@ -486,17 +461,11 @@ uptr internal_lstat(const char *path, void *buf) {
|
||||
kernel_stat_to_stat(&buf64, (struct stat *)buf);
|
||||
return res;
|
||||
# else
|
||||
- struct stat64 buf64;
|
||||
- int res = internal_syscall(SYSCALL(fstatat64), AT_FDCWD, (uptr)path,
|
||||
- (uptr)&buf64, AT_SYMLINK_NOFOLLOW);
|
||||
- stat64_to_stat(&buf64, (struct stat *)buf);
|
||||
- return res;
|
||||
+ return internal_syscall(SYSCALL(fstatat64), AT_FDCWD, (uptr)path, (uptr)buf,
|
||||
+ AT_SYMLINK_NOFOLLOW);
|
||||
# endif
|
||||
# else
|
||||
- struct stat64 buf64;
|
||||
- int res = internal_syscall(SYSCALL(lstat64), path, &buf64);
|
||||
- stat64_to_stat(&buf64, (struct stat *)buf);
|
||||
- return res;
|
||||
+ return internal_syscall(SYSCALL(lstat64), path, (uptr)buf);
|
||||
# endif
|
||||
}
|
||||
|
||||
@@ -524,10 +493,7 @@ uptr internal_fstat(fd_t fd, void *buf) {
|
||||
return internal_syscall(SYSCALL(fstat), fd, (uptr)buf);
|
||||
# endif
|
||||
# else
|
||||
- struct stat64 buf64;
|
||||
- int res = internal_syscall(SYSCALL(fstat64), fd, &buf64);
|
||||
- stat64_to_stat(&buf64, (struct stat *)buf);
|
||||
- return res;
|
||||
+ return internal_syscall(SYSCALL(fstat64), fd, (uptr)buf);
|
||||
# endif
|
||||
}
|
||||
|
||||
--
|
||||
2.49.0
|
||||
|
||||
27
patches/llvm/0028-fix-scan-build.patch
Normal file
27
patches/llvm/0028-fix-scan-build.patch
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
From 35970d6bd6bedb1f3db60d8da8c9bed63708a91b Mon Sep 17 00:00:00 2001
|
||||
From: q66 <q66@chimera-linux.org>
|
||||
Date: Fri, 29 Nov 2024 19:54:08 +0100
|
||||
Subject: [PATCH 28/29] fix scan-build
|
||||
|
||||
---
|
||||
clang/tools/scan-build/libexec/ccc-analyzer | 4 ++--
|
||||
1 file changed, 2 insertions(+), 2 deletions(-)
|
||||
|
||||
diff --git a/clang/tools/scan-build/libexec/ccc-analyzer b/clang/tools/scan-build/libexec/ccc-analyzer
|
||||
index 74f812aef..72bbab742 100755
|
||||
--- a/clang/tools/scan-build/libexec/ccc-analyzer
|
||||
+++ b/clang/tools/scan-build/libexec/ccc-analyzer
|
||||
@@ -84,8 +84,8 @@ if (`uname -s` =~ m/Darwin/) {
|
||||
$DefaultCCompiler = 'cc';
|
||||
$DefaultCXXCompiler = 'c++';
|
||||
} else {
|
||||
- $DefaultCCompiler = 'gcc';
|
||||
- $DefaultCXXCompiler = 'g++';
|
||||
+ $DefaultCCompiler = 'clang';
|
||||
+ $DefaultCXXCompiler = 'clang++';
|
||||
}
|
||||
|
||||
if ($FindBin::Script =~ /c\+\+-analyzer/) {
|
||||
--
|
||||
2.49.0
|
||||
|
||||
36
patches/llvm/0029-libcxx-default-to-type-2.patch
Normal file
36
patches/llvm/0029-libcxx-default-to-type-2.patch
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
From 14dca6a04af1828917ab1602ff8b1d225411bf7b Mon Sep 17 00:00:00 2001
|
||||
From: q66 <q66@chimera-linux.org>
|
||||
Date: Wed, 16 Apr 2025 00:29:41 +0200
|
||||
Subject: [PATCH 29/29] libcxx: default to type 2
|
||||
|
||||
// This implementation of type_info does not assume there is always a unique
|
||||
// copy of the RTTI for a given type inside a program. For various reasons
|
||||
// the linker may have failed to merge every copy of a types RTTI
|
||||
// (For example: -Bsymbolic or llvm.org/PR37398). Under this assumption, two
|
||||
// type_infos are equal if their addresses are equal or if a deep string
|
||||
// comparison is equal.
|
||||
|
||||
this is mostly for compat with libstdc++, which some projects
|
||||
like kde* rely on:
|
||||
|
||||
https://bugs.kde.org/show_bug.cgi?id=479679
|
||||
---
|
||||
libcxx/include/typeinfo | 2 +-
|
||||
1 file changed, 1 insertion(+), 1 deletion(-)
|
||||
|
||||
diff --git a/libcxx/include/typeinfo b/libcxx/include/typeinfo
|
||||
index 799c6ebd5..12572e646 100644
|
||||
--- a/libcxx/include/typeinfo
|
||||
+++ b/libcxx/include/typeinfo
|
||||
@@ -182,7 +182,7 @@ public:
|
||||
|
||||
// On all other platforms, assume the Itanium C++ ABI and use the Unique implementation.
|
||||
# else
|
||||
-# define _LIBCPP_TYPEINFO_COMPARISON_IMPLEMENTATION 1
|
||||
+# define _LIBCPP_TYPEINFO_COMPARISON_IMPLEMENTATION 2
|
||||
# endif
|
||||
# endif
|
||||
|
||||
--
|
||||
2.49.0
|
||||
|
||||
101
patches/llvm/769c42f4a552a75c8c38870ddc1b50d2ea874e4e.patch
Normal file
101
patches/llvm/769c42f4a552a75c8c38870ddc1b50d2ea874e4e.patch
Normal file
|
|
@ -0,0 +1,101 @@
|
|||
From 769c42f4a552a75c8c38870ddc1b50d2ea874e4e Mon Sep 17 00:00:00 2001
|
||||
From: "A. Jiang" <de34@live.cn>
|
||||
Date: Tue, 3 Jun 2025 23:54:49 +0800
|
||||
Subject: [PATCH] [libc++] Fix padding calculation for function reference types
|
||||
(#142125)
|
||||
|
||||
#109028 caused `sizeof` to be sometimes applied to function reference
|
||||
types, which makes a program ill-formed. This PR handles reference types
|
||||
by specializations to prevent such bogus `sizeof` expression to be
|
||||
instantiated.
|
||||
|
||||
Fixes #142118.
|
||||
---
|
||||
libcxx/include/__memory/compressed_pair.h | 15 +++++++++++----
|
||||
.../unique.ptr.ctor/pointer_deleter.pass.cpp | 19 +++++++++++++++++++
|
||||
2 files changed, 30 insertions(+), 4 deletions(-)
|
||||
|
||||
diff --git a/libcxx/include/__memory/compressed_pair.h b/libcxx/include/__memory/compressed_pair.h
|
||||
index 38798a21fa3c9..fb7b7b7afcc8c 100644
|
||||
--- a/libcxx/include/__memory/compressed_pair.h
|
||||
+++ b/libcxx/include/__memory/compressed_pair.h
|
||||
@@ -15,7 +15,6 @@
|
||||
#include <__type_traits/datasizeof.h>
|
||||
#include <__type_traits/is_empty.h>
|
||||
#include <__type_traits/is_final.h>
|
||||
-#include <__type_traits/is_reference.h>
|
||||
|
||||
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
|
||||
# pragma GCC system_header
|
||||
@@ -63,9 +62,17 @@ inline const size_t __compressed_pair_alignment = _LIBCPP_ALIGNOF(_Tp);
|
||||
template <class _Tp>
|
||||
inline const size_t __compressed_pair_alignment<_Tp&> = _LIBCPP_ALIGNOF(void*);
|
||||
|
||||
-template <class _ToPad,
|
||||
- bool _Empty = ((is_empty<_ToPad>::value && !__libcpp_is_final<_ToPad>::value) ||
|
||||
- is_reference<_ToPad>::value || sizeof(_ToPad) == __datasizeof_v<_ToPad>)>
|
||||
+template <class _ToPad>
|
||||
+inline const bool __is_reference_or_unpadded_object =
|
||||
+ (is_empty<_ToPad>::value && !__libcpp_is_final<_ToPad>::value) || sizeof(_ToPad) == __datasizeof_v<_ToPad>;
|
||||
+
|
||||
+template <class _Tp>
|
||||
+inline const bool __is_reference_or_unpadded_object<_Tp&> = true;
|
||||
+
|
||||
+template <class _Tp>
|
||||
+inline const bool __is_reference_or_unpadded_object<_Tp&&> = true;
|
||||
+
|
||||
+template <class _ToPad, bool _Empty = __is_reference_or_unpadded_object<_ToPad> >
|
||||
class __compressed_pair_padding {
|
||||
char __padding_[sizeof(_ToPad) - __datasizeof_v<_ToPad>] = {};
|
||||
};
|
||||
diff --git a/libcxx/test/std/utilities/smartptr/unique.ptr/unique.ptr.class/unique.ptr.ctor/pointer_deleter.pass.cpp b/libcxx/test/std/utilities/smartptr/unique.ptr/unique.ptr.class/unique.ptr.ctor/pointer_deleter.pass.cpp
|
||||
index a91abc856fb19..a438bfb58ce44 100644
|
||||
--- a/libcxx/test/std/utilities/smartptr/unique.ptr/unique.ptr.class/unique.ptr.ctor/pointer_deleter.pass.cpp
|
||||
+++ b/libcxx/test/std/utilities/smartptr/unique.ptr/unique.ptr.class/unique.ptr.ctor/pointer_deleter.pass.cpp
|
||||
@@ -32,6 +32,8 @@ bool my_free_called = false;
|
||||
|
||||
void my_free(void*) { my_free_called = true; }
|
||||
|
||||
+TEST_CONSTEXPR_CXX23 void deleter_function(A*) {}
|
||||
+
|
||||
#if TEST_STD_VER >= 11
|
||||
struct DeleterBase {
|
||||
TEST_CONSTEXPR_CXX23 void operator()(void*) const {}
|
||||
@@ -325,6 +327,21 @@ TEST_CONSTEXPR_CXX23 void test_nullptr() {
|
||||
#endif
|
||||
}
|
||||
|
||||
+template <bool IsArray>
|
||||
+TEST_CONSTEXPR_CXX23 void test_function_reference() {
|
||||
+ typedef typename std::conditional<!IsArray, A, A[]>::type VT;
|
||||
+ {
|
||||
+ std::unique_ptr<VT, void (&)(A*)> u(nullptr, deleter_function);
|
||||
+ assert(u.get() == nullptr);
|
||||
+ assert(u.get_deleter() == deleter_function);
|
||||
+ }
|
||||
+ {
|
||||
+ std::unique_ptr<VT, void (&)(A*)> u(nullptr, deleter_function);
|
||||
+ assert(u.get() == nullptr);
|
||||
+ assert(u.get_deleter() == deleter_function);
|
||||
+ }
|
||||
+}
|
||||
+
|
||||
TEST_CONSTEXPR_CXX23 bool test() {
|
||||
{
|
||||
test_basic</*IsArray*/ false>();
|
||||
@@ -332,6 +349,7 @@ TEST_CONSTEXPR_CXX23 bool test() {
|
||||
test_basic_single();
|
||||
test_sfinae<false>();
|
||||
test_noexcept<false>();
|
||||
+ test_function_reference<false>();
|
||||
}
|
||||
{
|
||||
test_basic</*IsArray*/ true>();
|
||||
@@ -339,6 +357,7 @@ TEST_CONSTEXPR_CXX23 bool test() {
|
||||
test_sfinae<true>();
|
||||
test_sfinae_runtime();
|
||||
test_noexcept<true>();
|
||||
+ test_function_reference<true>();
|
||||
}
|
||||
|
||||
return true;
|
||||
118
patches/llvm/8f66fb784291c897a965a9ee4c280e314dc8cee4.patch
Normal file
118
patches/llvm/8f66fb784291c897a965a9ee4c280e314dc8cee4.patch
Normal file
|
|
@ -0,0 +1,118 @@
|
|||
From 8f66fb784291c897a965a9ee4c280e314dc8cee4 Mon Sep 17 00:00:00 2001
|
||||
From: Nikita Popov <npopov@redhat.com>
|
||||
Date: Tue, 18 Mar 2025 15:04:36 +0100
|
||||
Subject: [PATCH] [GlobalMerge] Fix handling of const options
|
||||
|
||||
For the NewPM, the merge-const option was assigned to an unused
|
||||
option field. Assign it to the correct one. The merge-const-aggressive
|
||||
option was not supported -- and invalid options were silently ignored.
|
||||
Accept it and error on invalid options.
|
||||
|
||||
For the LegacyPM, the corresponding cl::opt options were ignored when
|
||||
called via opt rather than llc.
|
||||
---
|
||||
llvm/include/llvm/CodeGen/GlobalMerge.h | 1 -
|
||||
llvm/lib/CodeGen/GlobalMerge.cpp | 2 ++
|
||||
llvm/lib/Passes/PassBuilder.cpp | 8 ++++++-
|
||||
llvm/lib/Passes/PassRegistry.def | 7 +++---
|
||||
llvm/test/Transforms/GlobalMerge/constants.ll | 22 +++++++++++++++++++
|
||||
5 files changed, 35 insertions(+), 5 deletions(-)
|
||||
create mode 100644 llvm/test/Transforms/GlobalMerge/constants.ll
|
||||
|
||||
diff --git a/llvm/include/llvm/CodeGen/GlobalMerge.h b/llvm/include/llvm/CodeGen/GlobalMerge.h
|
||||
index f1fb467fc7757..2220e5cfff5fb 100644
|
||||
--- a/llvm/include/llvm/CodeGen/GlobalMerge.h
|
||||
+++ b/llvm/include/llvm/CodeGen/GlobalMerge.h
|
||||
@@ -25,7 +25,6 @@ struct GlobalMergeOptions {
|
||||
unsigned MinSize = 0;
|
||||
bool GroupByUse = true;
|
||||
bool IgnoreSingleUse = true;
|
||||
- bool MergeConst = false;
|
||||
/// Whether we should merge global variables that have external linkage.
|
||||
bool MergeExternal = true;
|
||||
/// Whether we should merge constant global variables.
|
||||
diff --git a/llvm/lib/CodeGen/GlobalMerge.cpp b/llvm/lib/CodeGen/GlobalMerge.cpp
|
||||
index 1aedc447935b7..d0918acbe48fa 100644
|
||||
--- a/llvm/lib/CodeGen/GlobalMerge.cpp
|
||||
+++ b/llvm/lib/CodeGen/GlobalMerge.cpp
|
||||
@@ -198,6 +198,8 @@ class GlobalMerge : public FunctionPass {
|
||||
|
||||
explicit GlobalMerge() : FunctionPass(ID) {
|
||||
Opt.MaxOffset = GlobalMergeMaxOffset;
|
||||
+ Opt.MergeConstantGlobals = EnableGlobalMergeOnConst;
|
||||
+ Opt.MergeConstAggressive = GlobalMergeAllConst;
|
||||
initializeGlobalMergePass(*PassRegistry::getPassRegistry());
|
||||
}
|
||||
|
||||
diff --git a/llvm/lib/Passes/PassBuilder.cpp b/llvm/lib/Passes/PassBuilder.cpp
|
||||
index 7dfff2479d3cf..27c3335932633 100644
|
||||
--- a/llvm/lib/Passes/PassBuilder.cpp
|
||||
+++ b/llvm/lib/Passes/PassBuilder.cpp
|
||||
@@ -1313,7 +1313,9 @@ Expected<GlobalMergeOptions> parseGlobalMergeOptions(StringRef Params) {
|
||||
else if (ParamName == "ignore-single-use")
|
||||
Result.IgnoreSingleUse = Enable;
|
||||
else if (ParamName == "merge-const")
|
||||
- Result.MergeConst = Enable;
|
||||
+ Result.MergeConstantGlobals = Enable;
|
||||
+ else if (ParamName == "merge-const-aggressive")
|
||||
+ Result.MergeConstAggressive = Enable;
|
||||
else if (ParamName == "merge-external")
|
||||
Result.MergeExternal = Enable;
|
||||
else if (ParamName.consume_front("max-offset=")) {
|
||||
@@ -1322,6 +1324,10 @@ Expected<GlobalMergeOptions> parseGlobalMergeOptions(StringRef Params) {
|
||||
formatv("invalid GlobalMergePass parameter '{0}' ", ParamName)
|
||||
.str(),
|
||||
inconvertibleErrorCode());
|
||||
+ } else {
|
||||
+ return make_error<StringError>(
|
||||
+ formatv("invalid global-merge pass parameter '{0}' ", Params).str(),
|
||||
+ inconvertibleErrorCode());
|
||||
}
|
||||
}
|
||||
return Result;
|
||||
diff --git a/llvm/lib/Passes/PassRegistry.def b/llvm/lib/Passes/PassRegistry.def
|
||||
index 81f2ea52c2e84..60e3d01da5fec 100644
|
||||
--- a/llvm/lib/Passes/PassRegistry.def
|
||||
+++ b/llvm/lib/Passes/PassRegistry.def
|
||||
@@ -178,9 +178,10 @@ MODULE_PASS_WITH_PARAMS(
|
||||
"global-merge", "GlobalMergePass",
|
||||
[TM = TM](GlobalMergeOptions Opts) { return GlobalMergePass(TM, Opts); },
|
||||
parseGlobalMergeOptions,
|
||||
- "group-by-use;ignore-single-use;max-offset=N;merge-const;merge-external;"
|
||||
- "no-group-by-use;no-ignore-single-use;no-merge-const;no-merge-external;"
|
||||
- "size-only")
|
||||
+ "group-by-use;ignore-single-use;max-offset=N;merge-const;"
|
||||
+ "merge-const-aggressive;merge-external;no-group-by-use;"
|
||||
+ "no-ignore-single-use;no-merge-const;no-merge-const-aggressive;"
|
||||
+ "no-merge-external;size-only")
|
||||
MODULE_PASS_WITH_PARAMS(
|
||||
"embed-bitcode", "EmbedBitcodePass",
|
||||
[](EmbedBitcodeOptions Opts) { return EmbedBitcodePass(Opts); },
|
||||
diff --git a/llvm/test/Transforms/GlobalMerge/constants.ll b/llvm/test/Transforms/GlobalMerge/constants.ll
|
||||
new file mode 100644
|
||||
index 0000000000000..d5c30da2533b0
|
||||
--- /dev/null
|
||||
+++ b/llvm/test/Transforms/GlobalMerge/constants.ll
|
||||
@@ -0,0 +1,22 @@
|
||||
+; RUN: opt -global-merge -global-merge-max-offset=100 -global-merge-on-const -S < %s | FileCheck %s
|
||||
+; RUN: opt -global-merge -global-merge-max-offset=100 -global-merge-on-const -global-merge-all-const -S < %s | FileCheck %s --check-prefix=AGGRESSIVE
|
||||
+; RUN: opt -passes='global-merge<max-offset=100;merge-const>' -S < %s | FileCheck %s
|
||||
+; RUN: opt -passes='global-merge<max-offset=100;merge-const;merge-const-aggressive>' -S < %s | FileCheck %s --check-prefix=AGGRESSIVE
|
||||
+
|
||||
+; CHECK: @_MergedGlobals = private constant <{ i32, i32 }> <{ i32 1, i32 2 }>, align 4
|
||||
+; AGGRESSIVE: @_MergedGlobals = private constant <{ i32, i32, i32 }> <{ i32 1, i32 2, i32 3 }>, align 4
|
||||
+
|
||||
+@a = internal constant i32 1
|
||||
+@b = internal constant i32 2
|
||||
+@c = internal constant i32 3
|
||||
+
|
||||
+define void @use() {
|
||||
+ %a = load i32, ptr @a
|
||||
+ %b = load i32, ptr @b
|
||||
+ ret void
|
||||
+}
|
||||
+
|
||||
+define void @use2() {
|
||||
+ %c = load i32, ptr @c
|
||||
+ ret void
|
||||
+}
|
||||
2
sources.list
Normal file
2
sources.list
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
https://github.com/llvm/llvm-project/releases/download/llvmorg-20.1.8/llvm-project-20.1.8.src.tar.xz
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue