-
Notifications
You must be signed in to change notification settings - Fork 28
feat: add LLVM+Clang+LLD toolchain #494
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
c5a4d58
bff3889
a9a8896
60a399c
0761f6f
8fbfdbc
c7aa622
14e1077
fbf9022
f3977d4
7ca10d5
22f5bba
1fe907b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -9,6 +9,7 @@ spec: | |
| - tools-libcap | ||
| - tools-libselinux | ||
| - tools-libsepol | ||
| - tools-llvm | ||
| - tools-openssl | ||
| - tools-pcre2 | ||
| - tools-squashfs-tools | ||
|
|
@@ -17,7 +18,7 @@ spec: | |
| - tools-xz | ||
| - tools-zlib-ng | ||
| - tools-zstd | ||
| reproducibleTargetName: tools | ||
| reproducibleTargetName: tools-llvm | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Needs a new reproducibility test target merging |
||
| --- | ||
| kind: common.Renovate | ||
| spec: | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,52 @@ | ||
| name: clang | ||
| variant: scratch | ||
| dependencies: | ||
| - stage: base | ||
| - stage: cmake | ||
| - stage: curl | ||
| - stage: ninja | ||
| - stage: python3 | ||
| - stage: llvm | ||
| steps: | ||
| - sources: | ||
| - url: https://github.com/llvm/llvm-project/releases/download/llvmorg-{{ .llvm_version }}/clang-{{ .llvm_version }}.src.tar.xz | ||
| destination: clang.tar.xz | ||
| sha256: "{{ .llvm_clang_sha256 }}" | ||
| sha512: "{{ .llvm_clang_sha512 }}" | ||
| - url: https://github.com/llvm/llvm-project/releases/download/llvmorg-{{ .llvm_version }}/cmake-{{ .llvm_version }}.src.tar.xz | ||
| destination: cmake.tar.xz | ||
| sha256: "{{ .llvm_cmake_sha256 }}" | ||
| sha512: "{{ .llvm_cmake_sha512 }}" | ||
| - url: https://github.com/llvm/llvm-project/releases/download/llvmorg-{{ .llvm_version }}/third-party-{{ .llvm_version }}.src.tar.xz | ||
| destination: third-party.tar.xz | ||
| sha256: "{{ .llvm_third_party_sha256 }}" | ||
| sha512: "{{ .llvm_third_party_sha512 }}" | ||
| prepare: | ||
| - | | ||
| mkdir clang | ||
| tar -xJf clang.tar.xz --strip-components=1 -C clang | ||
| mkdir cmake | ||
| tar -xJf cmake.tar.xz --strip-components=1 -C cmake | ||
| mkdir third-party | ||
| tar -xJf third-party.tar.xz --strip-components=1 -C third-party | ||
| - | | ||
| cmake -S clang -B build -G Ninja \ | ||
| -DCMAKE_BUILD_TYPE=Release \ | ||
| -DCMAKE_INSTALL_PREFIX=/usr \ | ||
| -DLLVM_INCLUDE_TESTS=OFF \ | ||
| -DLLVM_ENABLE_ASSERTIONS=OFF \ | ||
| -DCLANG_BUILT_STANDALONE=ON \ | ||
| -DCLANG_DEFAULT_PIE_ON_LINUX=ON \ | ||
| -DCLANG_LINK_CLANG_DYLIB=ON \ | ||
| -DENABLE_LINKER_BUILD_ID=ON \ | ||
| -DLIBCLANG_BUILD_STATIC=ON \ | ||
| -DLLVM_LINK_LLVM_DYLIB=ON | ||
| build: | ||
| - | | ||
| cmake --build build | ||
| install: | ||
| - | | ||
| DESTDIR=/rootfs cmake --install build | ||
| finalize: | ||
| - from: /rootfs | ||
| to: / | ||
dsseng marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,29 @@ | ||
| Imported from Alpine: https://gitlab.alpinelinux.org/alpine/aports/-/blob/9e8202998fa718a7be6fb2d8aba639f97a94bb6a/main/llvm21/fix-memory-mf_exec-on-aarch64.patch | ||
|
|
||
| Fix failures in AllocationTests/MappedMemoryTest.* on aarch64: | ||
|
|
||
| Failing Tests (8): | ||
| LLVM-Unit :: Support/./SupportTests/AllocationTests/MappedMemoryTest.AllocAndRelease/3 | ||
| LLVM-Unit :: Support/./SupportTests/AllocationTests/MappedMemoryTest.DuplicateNear/3 | ||
| LLVM-Unit :: Support/./SupportTests/AllocationTests/MappedMemoryTest.EnabledWrite/3 | ||
| LLVM-Unit :: Support/./SupportTests/AllocationTests/MappedMemoryTest.MultipleAllocAndRelease/3 | ||
| LLVM-Unit :: Support/./SupportTests/AllocationTests/MappedMemoryTest.SuccessiveNear/3 | ||
| LLVM-Unit :: Support/./SupportTests/AllocationTests/MappedMemoryTest.UnalignedNear/3 | ||
| LLVM-Unit :: Support/./SupportTests/AllocationTests/MappedMemoryTest.ZeroNear/3 | ||
| LLVM-Unit :: Support/./SupportTests/AllocationTests/MappedMemoryTest.ZeroSizeNear/3 | ||
|
|
||
| Upstream-Issue: https://bugs.llvm.org/show_bug.cgi?id=14278#c10 | ||
|
|
||
| diff --git a/llvm/lib/Support/Unix/Memory.inc b/llvm/lib/Support/Unix/Memory.inc | ||
| index 4c8f6b2ea..6cddae13b 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 |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| Imported from Alpine: https://gitlab.alpinelinux.org/alpine/aports/-/blob/9e8202998fa718a7be6fb2d8aba639f97a94bb6a/main/llvm21/llvm-stack-size.patch | ||
|
|
||
| Patch-Source: https://github.com/chimera-linux/cports/blob/8c0359f31b9d888e59ced0320e93ca8ad79ba1f9/main/llvm/patches/0010-always-set-a-larger-stack-size-explicitly.patch | ||
| From 18e09846d9333b554e3dfbbd768ada6643bf92c0 Mon Sep 17 00:00:00 2001 | ||
| From: Daniel Kolesa <[email protected]> | ||
| Date: Sat, 27 Nov 2021 01:03:28 +0100 | ||
| Subject: [PATCH 10/22] always set a larger stack size explicitly | ||
|
|
||
| --- | ||
| llvm/lib/Support/Threading.cpp | 9 --------- | ||
| 1 file changed, 9 deletions(-) | ||
|
|
||
| diff --git a/llvm/lib/Support/Threading.cpp b/llvm/lib/Support/Threading.cpp | ||
| index 923935bbc..26594aac8 100644 | ||
| --- a/llvm/lib/Support/Threading.cpp | ||
| +++ b/llvm/lib/Support/Threading.cpp | ||
| @@ -77,7 +77,7 @@ unsigned llvm::ThreadPoolStrategy::compute_thread_count() const { | ||
| // keyword. | ||
| #include "llvm/Support/thread.h" | ||
|
|
||
| -#if defined(__APPLE__) | ||
| +#if 1 | ||
| // 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 |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,63 @@ | ||
| name: lld | ||
| variant: scratch | ||
| dependencies: | ||
| - stage: base | ||
| - stage: cmake | ||
| - stage: curl | ||
| - stage: ninja | ||
| - stage: python3 | ||
| - stage: llvm | ||
| steps: | ||
| - sources: | ||
| - url: https://github.com/llvm/llvm-project/releases/download/llvmorg-{{ .llvm_version }}/lld-{{ .llvm_version }}.src.tar.xz | ||
| destination: lld.tar.xz | ||
| sha256: "{{ .llvm_lld_sha256 }}" | ||
| sha512: "{{ .llvm_lld_sha512 }}" | ||
| - url: https://github.com/llvm/llvm-project/releases/download/llvmorg-{{ .llvm_version }}/cmake-{{ .llvm_version }}.src.tar.xz | ||
| destination: cmake.tar.xz | ||
| sha256: "{{ .llvm_cmake_sha256 }}" | ||
| sha512: "{{ .llvm_cmake_sha512 }}" | ||
| - url: https://github.com/llvm/llvm-project/releases/download/llvmorg-{{ .llvm_version }}/third-party-{{ .llvm_version }}.src.tar.xz | ||
| destination: third-party.tar.xz | ||
| sha256: "{{ .llvm_third_party_sha256 }}" | ||
| sha512: "{{ .llvm_third_party_sha512 }}" | ||
| - url: https://github.com/llvm/llvm-project/releases/download/llvmorg-{{ .llvm_version }}/libunwind-{{ .llvm_version }}.src.tar.xz | ||
| destination: libunwind.tar.xz | ||
| sha256: "{{ .llvm_libunwind_sha256 }}" | ||
| sha512: "{{ .llvm_libunwind_sha512 }}" | ||
| - url: https://github.com/llvm/llvm-project/releases/download/llvmorg-{{ .llvm_version }}/llvm-{{ .llvm_version }}.src.tar.xz | ||
| destination: llvm.tar.xz | ||
| sha256: "{{ .llvm_sha256 }}" | ||
| sha512: "{{ .llvm_sha512 }}" | ||
| prepare: | ||
| - | | ||
| mkdir lld | ||
| tar -xJf lld.tar.xz --strip-components=1 -C lld | ||
| mkdir cmake | ||
| tar -xJf cmake.tar.xz --strip-components=1 -C cmake | ||
| mkdir third-party | ||
| tar -xJf third-party.tar.xz --strip-components=1 -C third-party | ||
| mkdir libunwind | ||
| tar -xJf libunwind.tar.xz --strip-components=1 -C libunwind | ||
| mkdir llvm | ||
| tar -xJf llvm.tar.xz --strip-components=1 -C llvm | ||
|
|
||
| patch -p1 < /pkg/patches/fix-memory-mf_exec-on-aarch64.patch | ||
| patch -p1 < /pkg/patches/llvm-stack-size.patch | ||
|
Comment on lines
+45
to
+46
|
||
| - | | ||
| cmake -S lld -B build -G Ninja \ | ||
| -DCMAKE_BUILD_TYPE=Release \ | ||
| -DCMAKE_INSTALL_PREFIX=/usr \ | ||
| -DLLVM_INCLUDE_TESTS=OFF \ | ||
| -DLLVM_ENABLE_ASSERTIONS=OFF \ | ||
| -DLLD_BUILT_STANDALONE=ON \ | ||
| -DLLVM_LINK_LLVM_DYLIB=ON | ||
| build: | ||
| - | | ||
| cmake --build build | ||
| install: | ||
| - | | ||
| DESTDIR=/rootfs cmake --install build | ||
| finalize: | ||
| - from: /rootfs | ||
| to: / | ||
dsseng marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,29 @@ | ||
| Imported from Alpine: https://gitlab.alpinelinux.org/alpine/aports/-/blob/9e8202998fa718a7be6fb2d8aba639f97a94bb6a/main/llvm21/fix-memory-mf_exec-on-aarch64.patch | ||
|
|
||
| Fix failures in AllocationTests/MappedMemoryTest.* on aarch64: | ||
|
|
||
| Failing Tests (8): | ||
| LLVM-Unit :: Support/./SupportTests/AllocationTests/MappedMemoryTest.AllocAndRelease/3 | ||
| LLVM-Unit :: Support/./SupportTests/AllocationTests/MappedMemoryTest.DuplicateNear/3 | ||
| LLVM-Unit :: Support/./SupportTests/AllocationTests/MappedMemoryTest.EnabledWrite/3 | ||
| LLVM-Unit :: Support/./SupportTests/AllocationTests/MappedMemoryTest.MultipleAllocAndRelease/3 | ||
| LLVM-Unit :: Support/./SupportTests/AllocationTests/MappedMemoryTest.SuccessiveNear/3 | ||
| LLVM-Unit :: Support/./SupportTests/AllocationTests/MappedMemoryTest.UnalignedNear/3 | ||
| LLVM-Unit :: Support/./SupportTests/AllocationTests/MappedMemoryTest.ZeroNear/3 | ||
| LLVM-Unit :: Support/./SupportTests/AllocationTests/MappedMemoryTest.ZeroSizeNear/3 | ||
|
|
||
| Upstream-Issue: https://bugs.llvm.org/show_bug.cgi?id=14278#c10 | ||
|
|
||
| diff --git a/llvm/lib/Support/Unix/Memory.inc b/llvm/lib/Support/Unix/Memory.inc | ||
| index 4c8f6b2ea..6cddae13b 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 |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| Imported from Alpine: https://gitlab.alpinelinux.org/alpine/aports/-/blob/9e8202998fa718a7be6fb2d8aba639f97a94bb6a/main/llvm21/llvm-stack-size.patch | ||
|
|
||
| Patch-Source: https://github.com/chimera-linux/cports/blob/8c0359f31b9d888e59ced0320e93ca8ad79ba1f9/main/llvm/patches/0010-always-set-a-larger-stack-size-explicitly.patch | ||
| From 18e09846d9333b554e3dfbbd768ada6643bf92c0 Mon Sep 17 00:00:00 2001 | ||
| From: Daniel Kolesa <[email protected]> | ||
| Date: Sat, 27 Nov 2021 01:03:28 +0100 | ||
| Subject: [PATCH 10/22] always set a larger stack size explicitly | ||
|
|
||
| --- | ||
| llvm/lib/Support/Threading.cpp | 9 --------- | ||
| 1 file changed, 9 deletions(-) | ||
|
|
||
| diff --git a/llvm/lib/Support/Threading.cpp b/llvm/lib/Support/Threading.cpp | ||
| index 923935bbc..26594aac8 100644 | ||
| --- a/llvm/lib/Support/Threading.cpp | ||
| +++ b/llvm/lib/Support/Threading.cpp | ||
| @@ -77,7 +77,7 @@ unsigned llvm::ThreadPoolStrategy::compute_thread_count() const { | ||
| // keyword. | ||
| #include "llvm/Support/thread.h" | ||
|
|
||
| -#if defined(__APPLE__) | ||
| +#if 1 | ||
| // 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 |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,77 @@ | ||
| name: llvm | ||
| variant: scratch | ||
| dependencies: | ||
| - stage: base | ||
| - stage: cmake | ||
| - stage: curl | ||
| - stage: ninja | ||
| - stage: python3 | ||
| steps: | ||
| - sources: | ||
| - url: https://github.com/llvm/llvm-project/releases/download/llvmorg-{{ .llvm_version }}/llvm-{{ .llvm_version }}.src.tar.xz | ||
| destination: llvm.tar.xz | ||
| sha256: "{{ .llvm_sha256 }}" | ||
| sha512: "{{ .llvm_sha512 }}" | ||
| - url: https://github.com/llvm/llvm-project/releases/download/llvmorg-{{ .llvm_version }}/cmake-{{ .llvm_version }}.src.tar.xz | ||
| destination: cmake.tar.xz | ||
| sha256: "{{ .llvm_cmake_sha256 }}" | ||
| sha512: "{{ .llvm_cmake_sha512 }}" | ||
| - url: https://github.com/llvm/llvm-project/releases/download/llvmorg-{{ .llvm_version }}/third-party-{{ .llvm_version }}.src.tar.xz | ||
| destination: third-party.tar.xz | ||
| sha256: "{{ .llvm_third_party_sha256 }}" | ||
| sha512: "{{ .llvm_third_party_sha512 }}" | ||
| - url: https://github.com/llvm/llvm-project/releases/download/llvmorg-{{ .llvm_version }}/clang-{{ .llvm_version }}.src.tar.xz | ||
| destination: clang.tar.xz | ||
| sha256: "{{ .llvm_clang_sha256 }}" | ||
| sha512: "{{ .llvm_clang_sha512 }}" | ||
| - url: https://github.com/llvm/llvm-project/releases/download/llvmorg-{{ .llvm_version }}/lld-{{ .llvm_version }}.src.tar.xz | ||
| destination: lld.tar.xz | ||
| sha256: "{{ .llvm_lld_sha256 }}" | ||
| sha512: "{{ .llvm_lld_sha512 }}" | ||
| - url: https://github.com/llvm/llvm-project/releases/download/llvmorg-{{ .llvm_version }}/libunwind-{{ .llvm_version }}.src.tar.xz | ||
| destination: libunwind.tar.xz | ||
| sha256: "{{ .llvm_libunwind_sha256 }}" | ||
| sha512: "{{ .llvm_libunwind_sha512 }}" | ||
| prepare: | ||
| - | | ||
| mkdir llvm | ||
| tar -xJf llvm.tar.xz --strip-components=1 -C llvm | ||
| mkdir cmake | ||
| tar -xJf cmake.tar.xz --strip-components=1 -C cmake | ||
| mkdir third-party | ||
| tar -xJf third-party.tar.xz --strip-components=1 -C third-party | ||
| mkdir clang | ||
| tar -xJf clang.tar.xz --strip-components=1 -C clang | ||
| mkdir lld | ||
| tar -xJf lld.tar.xz --strip-components=1 -C lld | ||
| mkdir libunwind | ||
| tar -xJf libunwind.tar.xz --strip-components=1 -C libunwind | ||
|
|
||
| patch -p1 < /pkg/patches/fix-memory-mf_exec-on-aarch64.patch | ||
| patch -p1 < /pkg/patches/llvm-stack-size.patch | ||
|
Comment on lines
+49
to
+51
|
||
| - | | ||
| cmake -S llvm -B build -G Ninja \ | ||
| -DCMAKE_BUILD_TYPE=Release \ | ||
| -DCMAKE_INSTALL_PREFIX=/usr \ | ||
| -DLLVM_DEFAULT_TARGET_TRIPLE="${ARCH}-linux-musl" \ | ||
| -DLLVM_HOST_TRIPLE="${ARCH}-linux-musl" \ | ||
| -DLLVM_ENABLE_PROJECTS="clang;lld" \ | ||
| -DLLVM_INCLUDE_TESTS=OFF \ | ||
| -DLLVM_INCLUDE_DOCS=OFF \ | ||
| -DLLVM_INCLUDE_EXAMPLES=OFF \ | ||
| -DLLVM_INCLUDE_BENCHMARKS=OFF \ | ||
| -DLLVM_ENABLE_BINDINGS=OFF \ | ||
| -DLLVM_INSTALL_UTILS=ON \ | ||
| -DLLVM_TARGETS_TO_BUILD='ARM;AArch64;X86' \ | ||
| -DLLVM_ENABLE_ASSERTIONS=OFF \ | ||
| -DLLVM_ENABLE_LTO=ON | ||
| build: | ||
| - | | ||
| cmake --build build | ||
| install: | ||
| - | | ||
| DESTDIR=/rootfs cmake --install build | ||
| # rm /rootfs/usr/lib/*.a # TODO - remove static libs from the tools image | ||
| finalize: | ||
| - from: /rootfs | ||
| to: / | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TODO: drop before merging