llvm20: try to fix x86 build

This commit is contained in:
Jérôme Duval
2025-05-24 22:29:43 +02:00
parent 36ee9e6f96
commit 7d537e1161

View File

@@ -1,4 +1,4 @@
From 194a961e597a18b42f309c8fd145aaee3cd5c956 Mon Sep 17 00:00:00 2001
From 3711bb1867f615c4fdba116d823d92dd1f7742f1 Mon Sep 17 00:00:00 2001
From: Calvin Hill <calvin@hakobaito.co.uk>
Date: Sun, 9 Sep 2018 16:11:42 +0100
Subject: llvm: import header dir suffix patch from 3dEyes
@@ -24,7 +24,7 @@ index d5b76b1..df3fb59 100644
2.48.1
From 1391e358ed21a3c66081e2bc6ee562bf776ef6e4 Mon Sep 17 00:00:00 2001
From a66fef6f39345e15d042f0203009d1872c526ad3 Mon Sep 17 00:00:00 2001
From: Jerome Duval <jerome.duval@gmail.com>
Date: Sat, 3 Apr 2021 23:23:24 +0200
Subject: lld: MachO needs libunwind somehow, disable
@@ -118,7 +118,7 @@ index d6800fa..d2bac9f 100644
2.48.1
From cb1e6de69a76c96f6ba5dd8e1a3e13946d46776b Mon Sep 17 00:00:00 2001
From 519df7ed415f2c62f0c2d1f44ad5d5bacc902574 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Duval?= <jerome.duval@gmail.com>
Date: Mon, 18 Jul 2016 14:13:19 +0200
Subject: clang: support for secondary arch.
@@ -213,7 +213,7 @@ index af74f43..fa3f8cb 100644
2.48.1
From f429e1e4e5f467a9d4a3a56dd6e290d545eb20a5 Mon Sep 17 00:00:00 2001
From be4107fd21ce49da1cef3de468b8de8a3dfd7e66 Mon Sep 17 00:00:00 2001
From: David Karoly <karolyd577@gmail.com>
Date: Thu, 21 Sep 2023 17:44:12 +0000
Subject: fix build on x86 secondary arch
@@ -236,7 +236,7 @@ index 4312411..04db3fb 100644
2.48.1
From 01ff9cc116a23b6cb2fa947bbab777a23c1a3926 Mon Sep 17 00:00:00 2001
From 4acc0f2dd1c40e4ce2cfe3dc1bd5e04ebfe209d2 Mon Sep 17 00:00:00 2001
From: David Karoly <david.karoly@outlook.com>
Date: Mon, 6 Nov 2023 14:24:21 +0100
Subject: clang: Haiku: patch for analyzer scripts
@@ -298,7 +298,7 @@ index d01aebb..43ba8c3 100755
2.48.1
From 38fea247005185b27950b1773b1d33e10d3a689f Mon Sep 17 00:00:00 2001
From 68d94075792b72f7efa358a0d4105d9cc06c74c8 Mon Sep 17 00:00:00 2001
From: Brad Smith <brad@comstyle.com>
Date: Mon, 10 Jun 2024 11:13:29 +0200
Subject: A slightly better llvm-config diff that doesn't use #ifdef.
@@ -344,7 +344,7 @@ index df3fb59..30cb748 100644
2.48.1
From c6ed88a0090974f81c99d3a226a1c51bbc8b0da7 Mon Sep 17 00:00:00 2001
From eceeabebcd7a68b1eec6853dbee44b1829ad23f5 Mon Sep 17 00:00:00 2001
From: Gerasim Troeglazov <3dEyes@gmail.com>
Date: Sun, 19 May 2024 10:31:55 +0200
Subject: Allow linking gcc compiled code with lld
@@ -370,7 +370,7 @@ index a1e9eca..cc563d7 100644
2.48.1
From 58fd61d6302a83e2f2d0ce0c544e25f8bad100f8 Mon Sep 17 00:00:00 2001
From a11e6dfba0366ce78a2e235382c6619385a1bfbf Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Duval?= <jerome.duval@gmail.com>
Date: Thu, 6 Feb 2025 21:08:43 +0100
Subject: Haiku: Address sanitizer on x86_64
@@ -2030,10 +2030,10 @@ index bbe7040..9289b99 100644
2.48.1
From d591da66d61a66c422f8a46f33c439f28bd43ea6 Mon Sep 17 00:00:00 2001
From f451df45507f647b627df6685669ae44bd930c1f Mon Sep 17 00:00:00 2001
From: Brad Smith <brad@comstyle.com>
Date: Sun, 15 Dec 2024 10:26:32 +0000
Subject: [OpenMP] Add support for Haiku
Subject: Add support for Haiku
diff --git a/openmp/runtime/src/kmp.h b/openmp/runtime/src/kmp.h
@@ -2295,7 +2295,7 @@ index a73f2b3..4c17802 100644
2.48.1
From 336c454eb9853018ca99447311da4d57c8ef2b11 Mon Sep 17 00:00:00 2001
From 6d12de5c34ce1188ff948b856049ea35a5fb288c Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Duval?= <jerome.duval@gmail.com>
Date: Mon, 24 Mar 2025 21:41:12 +0100
Subject: install headers in clang/../include/ where clang searches them
@@ -2318,7 +2318,7 @@ index d92bc0e..4268fbb 100644
2.48.1
From d8b52bbbacfb7b3326813cfaff1e1c3eb54c630f Mon Sep 17 00:00:00 2001
From b965fd4943d5bcde23b47e7cb5ab31f082100557 Mon Sep 17 00:00:00 2001
From: Luc Schrijvers <begasus@gmail.com>
Date: Thu, 17 Apr 2025 16:38:48 +0200
Subject: Fix missing PATH for stddef
@@ -2346,10 +2346,11 @@ index 79054fe..c1c7341 100644
--
2.48.1
From 464d992011ad3191f67c1308741e3a5c66c96237 Mon Sep 17 00:00:00 2001
From 0e15dba3cc088fbc604ecd65e6d74688c8bb90cf Mon Sep 17 00:00:00 2001
From: Trung Nguyen <trungnt282910@gmail.com>
Date: Fri, 11 Apr 2025 23:53:14 +1000
Subject: [PATCH] [libunwind][Haiku] Fix signal frame unwinding
Subject: Fix signal frame unwinding
The current unwinding implementation on Haiku is messy and broken.
1. It searches weird paths for private headers, which is breaking builds
@@ -2359,13 +2360,9 @@ in consuming projects, such as dotnet/runtime.
This commit strips all references to private headers and ports a
working signal frame implementation. It has been tested against
`tests/signal_unwind.pass.cpp` and can go pass the signal frame.
---
libunwind/src/CMakeLists.txt | 16 ----
libunwind/src/UnwindCursor.hpp | 159 ++++++++++++++++++++-------------
2 files changed, 99 insertions(+), 76 deletions(-)
diff --git a/libunwind/src/CMakeLists.txt b/libunwind/src/CMakeLists.txt
index d69013e5dace1..70bd3a017cda7 100644
index ecbd019..babb04d 100644
--- a/libunwind/src/CMakeLists.txt
+++ b/libunwind/src/CMakeLists.txt
@@ -118,22 +118,6 @@ if (HAIKU)
@@ -2392,10 +2389,10 @@ index d69013e5dace1..70bd3a017cda7 100644
string(REPLACE ";" " " LIBUNWIND_COMPILE_FLAGS "${LIBUNWIND_COMPILE_FLAGS}")
diff --git a/libunwind/src/UnwindCursor.hpp b/libunwind/src/UnwindCursor.hpp
index ca9927edc9990..e70cf3b0ab38c 100644
index 3831d8e..4e659cd 100644
--- a/libunwind/src/UnwindCursor.hpp
+++ b/libunwind/src/UnwindCursor.hpp
@@ -41,6 +41,12 @@
@@ -40,6 +40,12 @@
#define _LIBUNWIND_CHECK_LINUX_SIGRETURN 1
#endif
@@ -2408,7 +2405,7 @@ index ca9927edc9990..e70cf3b0ab38c 100644
#include "AddressSpace.hpp"
#include "CompactUnwinder.hpp"
#include "config.h"
@@ -1015,7 +1021,7 @@ class UnwindCursor : public AbstractUnwindCursor{
@@ -1010,7 +1016,7 @@ private:
template <typename Registers> int stepThroughSigReturn(Registers &) {
return UNW_STEP_END;
}
@@ -2417,7 +2414,7 @@ index ca9927edc9990..e70cf3b0ab38c 100644
bool setInfoForSigReturn();
int stepThroughSigReturn();
#endif
@@ -2559,7 +2565,7 @@ int UnwindCursor<A, R>::stepWithTBTable(pint_t pc, tbtable *TBTable,
@@ -2554,7 +2560,7 @@ int UnwindCursor<A, R>::stepWithTBTable(pint_t pc, tbtable *TBTable,
template <typename A, typename R>
void UnwindCursor<A, R>::setInfoBasedOnIPRegister(bool isReturnAddress) {
#if defined(_LIBUNWIND_CHECK_LINUX_SIGRETURN) || \
@@ -2426,7 +2423,7 @@ index ca9927edc9990..e70cf3b0ab38c 100644
_isSigReturn = false;
#endif
@@ -2684,7 +2690,7 @@ void UnwindCursor<A, R>::setInfoBasedOnIPRegister(bool isReturnAddress) {
@@ -2679,7 +2685,7 @@ void UnwindCursor<A, R>::setInfoBasedOnIPRegister(bool isReturnAddress) {
#endif // #if defined(_LIBUNWIND_SUPPORT_DWARF_UNWIND)
#if defined(_LIBUNWIND_CHECK_LINUX_SIGRETURN) || \
@@ -2435,7 +2432,7 @@ index ca9927edc9990..e70cf3b0ab38c 100644
if (setInfoForSigReturn())
return;
#endif
@@ -2760,63 +2766,6 @@ int UnwindCursor<A, R>::stepThroughSigReturn(Registers_arm64 &) {
@@ -2755,63 +2761,6 @@ int UnwindCursor<A, R>::stepThroughSigReturn(Registers_arm64 &) {
_isSignalFrame = true;
return UNW_STEP_SUCCESS;
}
@@ -2499,7 +2496,7 @@ index ca9927edc9990..e70cf3b0ab38c 100644
#endif // defined(_LIBUNWIND_CHECK_LINUX_SIGRETURN) &&
// defined(_LIBUNWIND_TARGET_AARCH64)
@@ -3032,6 +2981,96 @@ int UnwindCursor<A, R>::stepThroughSigReturn(Registers_s390x &) {
@@ -2972,6 +2921,96 @@ int UnwindCursor<A, R>::stepThroughSigReturn(Registers_s390x &) {
#endif // defined(_LIBUNWIND_CHECK_LINUX_SIGRETURN) &&
// defined(_LIBUNWIND_TARGET_S390X)
@@ -2596,3 +2593,81 @@ index ca9927edc9990..e70cf3b0ab38c 100644
template <typename A, typename R> int UnwindCursor<A, R>::step(bool stage2) {
(void)stage2;
// Bottom of stack is defined is when unwind info cannot be found.
--
2.48.1
From e667485cfc0b32934788a6a7041bcd464bf77815 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Duval?= <jerome.duval@gmail.com>
Date: Sat, 24 May 2025 22:24:52 +0200
Subject: fix x86 build
r13 doesn't provide the trap err.
diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_linux.cpp b/compiler-rt/lib/sanitizer_common/sanitizer_linux.cpp
index ca74ce8..350a59c 100644
--- a/compiler-rt/lib/sanitizer_common/sanitizer_linux.cpp
+++ b/compiler-rt/lib/sanitizer_common/sanitizer_linux.cpp
@@ -1265,7 +1265,7 @@ uptr GetPageSize() {
uptr ReadBinaryName(/*out*/ char *buf, uptr buf_len) {
# if SANITIZER_HAIKU
- int cookie = 0;
+ int32 cookie = 0;
image_info info;
const char *argv0 = "<UNKNOWN>";
while (get_next_image_info(B_CURRENT_TEAM, &cookie, &info) == B_OK) {
@@ -2013,7 +2013,7 @@ SignalContext::WriteFlag SignalContext::GetWriteFlag() const {
# elif SANITIZER_NETBSD
uptr err = ucontext->uc_mcontext.__gregs[_REG_ERR];
# elif SANITIZER_HAIKU
- uptr err = ucontext->uc_mcontext.r13;
+ uptr err = 0; //ucontext->uc_mcontext.r13;
# elif SANITIZER_SOLARIS && defined(__i386__)
const int Err = 13;
uptr err = ucontext->uc_mcontext.gregs[Err];
@@ -2643,6 +2643,11 @@ static void GetPcSpBp(void *context, uptr *pc, uptr *sp, uptr *bp) {
*pc = ucontext->uc_mcontext.mc_eip;
*bp = ucontext->uc_mcontext.mc_ebp;
*sp = ucontext->uc_mcontext.mc_esp;
+# elif SANITIZER_HAIKU
+ ucontext_t *ucontext = (ucontext_t*)context;
+ *pc = ucontext->uc_mcontext.eip;
+ *bp = ucontext->uc_mcontext.ebp;
+ *sp = ucontext->uc_mcontext.esp;
# else
ucontext_t *ucontext = (ucontext_t *)context;
# if SANITIZER_SOLARIS
diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_platform_limits_posix.h b/compiler-rt/lib/sanitizer_common/sanitizer_platform_limits_posix.h
index e53923e..e39c545 100644
--- a/compiler-rt/lib/sanitizer_common/sanitizer_platform_limits_posix.h
+++ b/compiler-rt/lib/sanitizer_common/sanitizer_platform_limits_posix.h
@@ -603,7 +603,11 @@ typedef unsigned long __sanitizer_sigset_t;
#elif SANITIZER_APPLE
typedef unsigned __sanitizer_sigset_t;
#elif SANITIZER_HAIKU
+# if defined(__x86_64__)
typedef unsigned long __sanitizer_sigset_t;
+# else
+typedef unsigned long long __sanitizer_sigset_t;
+# endif
#elif SANITIZER_LINUX
struct __sanitizer_sigset_t {
// The size is determined by looking at sizeof of real sigset_t on linux.
diff --git a/libunwind/src/UnwindCursor.hpp b/libunwind/src/UnwindCursor.hpp
index 4e659cd..1f48b0e 100644
--- a/libunwind/src/UnwindCursor.hpp
+++ b/libunwind/src/UnwindCursor.hpp
@@ -40,7 +40,8 @@
#define _LIBUNWIND_CHECK_LINUX_SIGRETURN 1
#endif
-#if defined(_LIBUNWIND_TARGET_HAIKU) && defined(_LIBUNWIND_TARGET_X86_64)
+#if defined(_LIBUNWIND_TARGET_HAIKU) && (defined(_LIBUNWIND_TARGET_X86_64) || \
+ defined(_LIBUNWIND_TARGET_I386))
#include <OS.h>
#include <signal.h>
#define _LIBUNWIND_CHECK_HAIKU_SIGRETURN 1
--
2.48.1