Skip to content

Commit bbd87ba

Browse files
committed
fix: llvm: import Alpine patches for ThinLTO on Musl
Signed-off-by: Dmitrii Sharshakov <[email protected]>
1 parent 10c9c94 commit bbd87ba

File tree

9 files changed

+171
-0
lines changed

9 files changed

+171
-0
lines changed
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
Imported from Alpine: https://gitlab.alpinelinux.org/alpine/aports/-/blob/9e8202998fa718a7be6fb2d8aba639f97a94bb6a/main/llvm21/fix-memory-mf_exec-on-aarch64.patch
2+
3+
Fix failures in AllocationTests/MappedMemoryTest.* on aarch64:
4+
5+
Failing Tests (8):
6+
LLVM-Unit :: Support/./SupportTests/AllocationTests/MappedMemoryTest.AllocAndRelease/3
7+
LLVM-Unit :: Support/./SupportTests/AllocationTests/MappedMemoryTest.DuplicateNear/3
8+
LLVM-Unit :: Support/./SupportTests/AllocationTests/MappedMemoryTest.EnabledWrite/3
9+
LLVM-Unit :: Support/./SupportTests/AllocationTests/MappedMemoryTest.MultipleAllocAndRelease/3
10+
LLVM-Unit :: Support/./SupportTests/AllocationTests/MappedMemoryTest.SuccessiveNear/3
11+
LLVM-Unit :: Support/./SupportTests/AllocationTests/MappedMemoryTest.UnalignedNear/3
12+
LLVM-Unit :: Support/./SupportTests/AllocationTests/MappedMemoryTest.ZeroNear/3
13+
LLVM-Unit :: Support/./SupportTests/AllocationTests/MappedMemoryTest.ZeroSizeNear/3
14+
15+
Upstream-Issue: https://bugs.llvm.org/show_bug.cgi?id=14278#c10
16+
17+
diff --git a/llvm/lib/Support/Unix/Memory.inc b/llvm/lib/Support/Unix/Memory.inc
18+
index 4c8f6b2ea..6cddae13b 100644
19+
--- a/llvm/lib/Support/Unix/Memory.inc
20+
+++ b/llvm/lib/Support/Unix/Memory.inc
21+
@@ -50,7 +50,7 @@ static int getPosixProtectionFlags(unsigned Flags) {
22+
llvm::sys::Memory::MF_EXEC:
23+
return PROT_READ | PROT_WRITE | PROT_EXEC;
24+
case llvm::sys::Memory::MF_EXEC:
25+
-#if defined(__FreeBSD__) || defined(__powerpc__)
26+
+#if defined(__FreeBSD__) || defined(__powerpc__) || (defined(__linux__) && defined(__aarch64__))
27+
// On PowerPC, having an executable page that has no read permission
28+
// can have unintended consequences. The function InvalidateInstruction-
29+
// Cache uses instructions dcbf and icbi, both of which are treated by
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
Imported from Alpine: https://gitlab.alpinelinux.org/alpine/aports/-/blob/9e8202998fa718a7be6fb2d8aba639f97a94bb6a/main/llvm21/llvm-stack-size.patch
2+
3+
Patch-Source: https://github.com/chimera-linux/cports/blob/8c0359f31b9d888e59ced0320e93ca8ad79ba1f9/main/llvm/patches/0010-always-set-a-larger-stack-size-explicitly.patch
4+
From 18e09846d9333b554e3dfbbd768ada6643bf92c0 Mon Sep 17 00:00:00 2001
5+
From: Daniel Kolesa <[email protected]>
6+
Date: Sat, 27 Nov 2021 01:03:28 +0100
7+
Subject: [PATCH 10/22] always set a larger stack size explicitly
8+
9+
---
10+
llvm/lib/Support/Threading.cpp | 9 ---------
11+
1 file changed, 9 deletions(-)
12+
13+
diff --git a/llvm/lib/Support/Threading.cpp b/llvm/lib/Support/Threading.cpp
14+
index 923935bbc..26594aac8 100644
15+
--- a/llvm/lib/Support/Threading.cpp
16+
+++ b/llvm/lib/Support/Threading.cpp
17+
@@ -77,7 +77,7 @@ unsigned llvm::ThreadPoolStrategy::compute_thread_count() const {
18+
// keyword.
19+
#include "llvm/Support/thread.h"
20+
21+
-#if defined(__APPLE__)
22+
+#if 1
23+
// Darwin's default stack size for threads except the main one is only 512KB,
24+
// which is not enough for some/many normal LLVM compilations. This implements
25+
// the same interface as std::thread but requests the same stack size as the

clang/pkg.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,9 @@ steps:
2929
tar -xJf cmake.tar.xz --strip-components=1 -C cmake
3030
mkdir third-party
3131
tar -xJf third-party.tar.xz --strip-components=1 -C third-party
32+
33+
patch -p1 < /pkg/patches/fix-memory-mf_exec-on-aarch64.patch
34+
patch -p1 < /pkg/patches/llvm-stack-size.patch
3235
- |
3336
cmake -S clang -B build -G Ninja \
3437
-DCMAKE_BUILD_TYPE=Release \
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
Imported from Alpine: https://gitlab.alpinelinux.org/alpine/aports/-/blob/9e8202998fa718a7be6fb2d8aba639f97a94bb6a/main/llvm21/fix-memory-mf_exec-on-aarch64.patch
2+
3+
Fix failures in AllocationTests/MappedMemoryTest.* on aarch64:
4+
5+
Failing Tests (8):
6+
LLVM-Unit :: Support/./SupportTests/AllocationTests/MappedMemoryTest.AllocAndRelease/3
7+
LLVM-Unit :: Support/./SupportTests/AllocationTests/MappedMemoryTest.DuplicateNear/3
8+
LLVM-Unit :: Support/./SupportTests/AllocationTests/MappedMemoryTest.EnabledWrite/3
9+
LLVM-Unit :: Support/./SupportTests/AllocationTests/MappedMemoryTest.MultipleAllocAndRelease/3
10+
LLVM-Unit :: Support/./SupportTests/AllocationTests/MappedMemoryTest.SuccessiveNear/3
11+
LLVM-Unit :: Support/./SupportTests/AllocationTests/MappedMemoryTest.UnalignedNear/3
12+
LLVM-Unit :: Support/./SupportTests/AllocationTests/MappedMemoryTest.ZeroNear/3
13+
LLVM-Unit :: Support/./SupportTests/AllocationTests/MappedMemoryTest.ZeroSizeNear/3
14+
15+
Upstream-Issue: https://bugs.llvm.org/show_bug.cgi?id=14278#c10
16+
17+
diff --git a/llvm/lib/Support/Unix/Memory.inc b/llvm/lib/Support/Unix/Memory.inc
18+
index 4c8f6b2ea..6cddae13b 100644
19+
--- a/llvm/lib/Support/Unix/Memory.inc
20+
+++ b/llvm/lib/Support/Unix/Memory.inc
21+
@@ -50,7 +50,7 @@ static int getPosixProtectionFlags(unsigned Flags) {
22+
llvm::sys::Memory::MF_EXEC:
23+
return PROT_READ | PROT_WRITE | PROT_EXEC;
24+
case llvm::sys::Memory::MF_EXEC:
25+
-#if defined(__FreeBSD__) || defined(__powerpc__)
26+
+#if defined(__FreeBSD__) || defined(__powerpc__) || (defined(__linux__) && defined(__aarch64__))
27+
// On PowerPC, having an executable page that has no read permission
28+
// can have unintended consequences. The function InvalidateInstruction-
29+
// Cache uses instructions dcbf and icbi, both of which are treated by

lld/patches/llvm-stack-size.patch

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
Imported from Alpine: https://gitlab.alpinelinux.org/alpine/aports/-/blob/9e8202998fa718a7be6fb2d8aba639f97a94bb6a/main/llvm21/llvm-stack-size.patch
2+
3+
Patch-Source: https://github.com/chimera-linux/cports/blob/8c0359f31b9d888e59ced0320e93ca8ad79ba1f9/main/llvm/patches/0010-always-set-a-larger-stack-size-explicitly.patch
4+
From 18e09846d9333b554e3dfbbd768ada6643bf92c0 Mon Sep 17 00:00:00 2001
5+
From: Daniel Kolesa <[email protected]>
6+
Date: Sat, 27 Nov 2021 01:03:28 +0100
7+
Subject: [PATCH 10/22] always set a larger stack size explicitly
8+
9+
---
10+
llvm/lib/Support/Threading.cpp | 9 ---------
11+
1 file changed, 9 deletions(-)
12+
13+
diff --git a/llvm/lib/Support/Threading.cpp b/llvm/lib/Support/Threading.cpp
14+
index 923935bbc..26594aac8 100644
15+
--- a/llvm/lib/Support/Threading.cpp
16+
+++ b/llvm/lib/Support/Threading.cpp
17+
@@ -77,7 +77,7 @@ unsigned llvm::ThreadPoolStrategy::compute_thread_count() const {
18+
// keyword.
19+
#include "llvm/Support/thread.h"
20+
21+
-#if defined(__APPLE__)
22+
+#if 1
23+
// Darwin's default stack size for threads except the main one is only 512KB,
24+
// which is not enough for some/many normal LLVM compilations. This implements
25+
// the same interface as std::thread but requests the same stack size as the

lld/pkg.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,9 @@ steps:
4141
tar -xJf libunwind.tar.xz --strip-components=1 -C libunwind
4242
mkdir llvm
4343
tar -xJf llvm.tar.xz --strip-components=1 -C llvm
44+
45+
patch -p1 < /pkg/patches/fix-memory-mf_exec-on-aarch64.patch
46+
patch -p1 < /pkg/patches/llvm-stack-size.patch
4447
- |
4548
cmake -S lld -B build -G Ninja \
4649
-DCMAKE_BUILD_TYPE=Release \
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
Imported from Alpine: https://gitlab.alpinelinux.org/alpine/aports/-/blob/9e8202998fa718a7be6fb2d8aba639f97a94bb6a/main/llvm21/fix-memory-mf_exec-on-aarch64.patch
2+
3+
Fix failures in AllocationTests/MappedMemoryTest.* on aarch64:
4+
5+
Failing Tests (8):
6+
LLVM-Unit :: Support/./SupportTests/AllocationTests/MappedMemoryTest.AllocAndRelease/3
7+
LLVM-Unit :: Support/./SupportTests/AllocationTests/MappedMemoryTest.DuplicateNear/3
8+
LLVM-Unit :: Support/./SupportTests/AllocationTests/MappedMemoryTest.EnabledWrite/3
9+
LLVM-Unit :: Support/./SupportTests/AllocationTests/MappedMemoryTest.MultipleAllocAndRelease/3
10+
LLVM-Unit :: Support/./SupportTests/AllocationTests/MappedMemoryTest.SuccessiveNear/3
11+
LLVM-Unit :: Support/./SupportTests/AllocationTests/MappedMemoryTest.UnalignedNear/3
12+
LLVM-Unit :: Support/./SupportTests/AllocationTests/MappedMemoryTest.ZeroNear/3
13+
LLVM-Unit :: Support/./SupportTests/AllocationTests/MappedMemoryTest.ZeroSizeNear/3
14+
15+
Upstream-Issue: https://bugs.llvm.org/show_bug.cgi?id=14278#c10
16+
17+
diff --git a/llvm/lib/Support/Unix/Memory.inc b/llvm/lib/Support/Unix/Memory.inc
18+
index 4c8f6b2ea..6cddae13b 100644
19+
--- a/llvm/lib/Support/Unix/Memory.inc
20+
+++ b/llvm/lib/Support/Unix/Memory.inc
21+
@@ -50,7 +50,7 @@ static int getPosixProtectionFlags(unsigned Flags) {
22+
llvm::sys::Memory::MF_EXEC:
23+
return PROT_READ | PROT_WRITE | PROT_EXEC;
24+
case llvm::sys::Memory::MF_EXEC:
25+
-#if defined(__FreeBSD__) || defined(__powerpc__)
26+
+#if defined(__FreeBSD__) || defined(__powerpc__) || (defined(__linux__) && defined(__aarch64__))
27+
// On PowerPC, having an executable page that has no read permission
28+
// can have unintended consequences. The function InvalidateInstruction-
29+
// Cache uses instructions dcbf and icbi, both of which are treated by

llvm/patches/llvm-stack-size.patch

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
Imported from Alpine: https://gitlab.alpinelinux.org/alpine/aports/-/blob/9e8202998fa718a7be6fb2d8aba639f97a94bb6a/main/llvm21/llvm-stack-size.patch
2+
3+
Patch-Source: https://github.com/chimera-linux/cports/blob/8c0359f31b9d888e59ced0320e93ca8ad79ba1f9/main/llvm/patches/0010-always-set-a-larger-stack-size-explicitly.patch
4+
From 18e09846d9333b554e3dfbbd768ada6643bf92c0 Mon Sep 17 00:00:00 2001
5+
From: Daniel Kolesa <[email protected]>
6+
Date: Sat, 27 Nov 2021 01:03:28 +0100
7+
Subject: [PATCH 10/22] always set a larger stack size explicitly
8+
9+
---
10+
llvm/lib/Support/Threading.cpp | 9 ---------
11+
1 file changed, 9 deletions(-)
12+
13+
diff --git a/llvm/lib/Support/Threading.cpp b/llvm/lib/Support/Threading.cpp
14+
index 923935bbc..26594aac8 100644
15+
--- a/llvm/lib/Support/Threading.cpp
16+
+++ b/llvm/lib/Support/Threading.cpp
17+
@@ -77,7 +77,7 @@ unsigned llvm::ThreadPoolStrategy::compute_thread_count() const {
18+
// keyword.
19+
#include "llvm/Support/thread.h"
20+
21+
-#if defined(__APPLE__)
22+
+#if 1
23+
// Darwin's default stack size for threads except the main one is only 512KB,
24+
// which is not enough for some/many normal LLVM compilations. This implements
25+
// the same interface as std::thread but requests the same stack size as the

llvm/pkg.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,9 @@ steps:
2828
tar -xJf cmake.tar.xz --strip-components=1 -C cmake
2929
mkdir third-party
3030
tar -xJf third-party.tar.xz --strip-components=1 -C third-party
31+
32+
patch -p1 < /pkg/patches/fix-memory-mf_exec-on-aarch64.patch
33+
patch -p1 < /pkg/patches/llvm-stack-size.patch
3134
- |
3235
cmake -S llvm -B build -G Ninja \
3336
-DCMAKE_BUILD_TYPE=Release \

0 commit comments

Comments
 (0)