Skip to content

Commit 75a77c3

Browse files
committed
ci: build libc++abi.a for musl with -fPIC
1 parent 0816ba5 commit 75a77c3

4 files changed

Lines changed: 117 additions & 23 deletions

File tree

.github/workflows/libc++abi.yml

Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
name: Build libc++abi
2+
3+
on:
4+
push:
5+
branches:
6+
- release-libcxxabi
7+
tags-ignore:
8+
- '**'
9+
10+
permissions:
11+
contents: write
12+
id-token: write
13+
attestations: write
14+
15+
jobs:
16+
setup-llvm-version:
17+
runs-on: ubuntu-latest
18+
outputs:
19+
llvm-version: ${{ steps.setup-llvm-version.outputs.llvm-version }}
20+
steps:
21+
- uses: actions/checkout@v4
22+
- name: Setup
23+
id: setup-llvm-version
24+
run: |
25+
echo "llvm-version=$(cat llvm-version)" >> $GITHUB_OUTPUT
26+
27+
build-musl:
28+
runs-on: ${{ matrix.settings.runs-on }}
29+
needs: setup-llvm-version
30+
name: Build libc++abi for ${{ matrix.settings.arch }} Linux musl
31+
strategy:
32+
matrix:
33+
settings:
34+
- { arch: x86_64, runs-on: ubuntu-latest }
35+
- { arch: aarch64, runs-on: ubuntu-24.04-arm }
36+
steps:
37+
- uses: actions/checkout@v4
38+
- name: Build in docker
39+
uses: addnab/docker-run-action@v3
40+
with:
41+
image: node:18-alpine
42+
options: -v ${{ github.workspace }}:/build -w /build
43+
run: |
44+
apk add clang llvm wget unzip cmake ninja xz tar musl-dev python3
45+
node scripts/build-c++abi.mjs
46+
- uses: actions/attest-build-provenance@v2
47+
with:
48+
subject-path: |
49+
libc++abi.a
50+
- name: Upload
51+
uses: actions/upload-artifact@v4
52+
with:
53+
name: libc++abi-${{ matrix.settings.arch }}.a
54+
path: libc++abi.a
55+
56+
release:
57+
needs:
58+
- setup-llvm-version
59+
- build-musl
60+
runs-on: ubuntu-latest
61+
steps:
62+
- uses: actions/checkout@v4
63+
- name: Download x86_64
64+
uses: actions/download-artifact@v4
65+
with:
66+
name: libc++abi-x86_64.a
67+
path: .
68+
- name: Rename
69+
run: |
70+
mv libc++abi.a libc++abi-x86_64.a
71+
- name: Download aarch64
72+
uses: actions/download-artifact@v4
73+
with:
74+
name: libc++abi-aarch64.a
75+
path: .
76+
- name: Rename
77+
run: |
78+
mv libc++abi.a libc++abi-aarch64.a
79+
- name: Release
80+
uses: softprops/action-gh-release@v2
81+
with:
82+
files: |
83+
libc++abi-x86_64.a
84+
libc++abi-aarch64.a
85+
name: libc++abi-${{ needs.setup-llvm-version.outputs.llvm-version }}
86+
tag_name: libc++abi-${{ needs.setup-llvm-version.outputs.llvm-version }}
87+
make_latest: false
88+

llvm-version

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
19.1.7

musl.Dockerfile

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ RUN apk add --no-cache \
1818
libc++-dev \
1919
libc++-static \
2020
llvm-libunwind-static \
21-
libc++-dev \
2221
tar \
2322
xz \
2423
ninja && \

scripts/build-c++abi.mjs

Lines changed: 28 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,43 @@
1-
import { execSync } from "node:child_process";
1+
import { execSync } from 'node:child_process'
2+
import { readFileSync } from 'node:fs'
3+
import { fileURLToPath } from 'node:url'
4+
import { join } from 'node:path'
25

3-
const LLVM_VERSION = "19.1.7";
6+
const LLVM_VERSION = readFileSync(join(fileURLToPath(import.meta.url), '..', '..', 'llvm-version'), 'utf-8').trim()
47

58
execSync(`wget https://github.com/llvm/llvm-project/archive/refs/tags/llvmorg-${LLVM_VERSION}.zip`, {
6-
stdio: "inherit",
7-
});
9+
stdio: 'inherit',
10+
})
811

912
execSync(`unzip llvmorg-${LLVM_VERSION}.zip`, {
10-
stdio: "inherit",
11-
});
13+
stdio: 'inherit',
14+
})
1215

1316
execSync(`mkdir -p build`, {
14-
stdio: "inherit",
17+
stdio: 'inherit',
1518
cwd: `llvm-project-llvmorg-${LLVM_VERSION}`,
16-
});
19+
})
1720

18-
execSync(`cmake -G Ninja -S runtimes -B build -DCMAKE_BUILD_TYPE=Release -DLLVM_ENABLE_RUNTIMES="libcxx;libcxxabi;libunwind" -DLIBCXX_ENABLE_LOCALIZATION=OFF`, {
19-
stdio: "inherit",
20-
cwd: `llvm-project-llvmorg-${LLVM_VERSION}`,
21-
env: {
22-
...process.env,
23-
CXX: "clang++",
24-
CC: "clang",
25-
CXXFLAGS: "-fPIC",
21+
execSync(
22+
`cmake -G Ninja -S runtimes -B build -DCMAKE_BUILD_TYPE=Release -DLLVM_ENABLE_RUNTIMES="libcxx;libcxxabi;libunwind" -DLIBCXX_ENABLE_LOCALIZATION=OFF`,
23+
{
24+
stdio: 'inherit',
25+
cwd: `llvm-project-llvmorg-${LLVM_VERSION}`,
26+
env: {
27+
...process.env,
28+
CXX: 'clang++',
29+
CC: 'clang',
30+
CXXFLAGS: '-fPIC',
31+
},
2632
},
27-
});
33+
)
2834

2935
execSync(`ninja -C build cxxabi`, {
30-
stdio: "inherit",
36+
stdio: 'inherit',
3137
cwd: `llvm-project-llvmorg-${LLVM_VERSION}`,
32-
});
38+
})
3339

34-
execSync(`cp build/lib/libc++abi.a /usr/lib/libc++abi.a`, {
35-
stdio: "inherit",
40+
execSync(`cp llvm-project-llvmorg-${LLVM_VERSION}/build/lib/libc++abi.a .`, {
41+
stdio: 'inherit',
3642
cwd: `llvm-project-llvmorg-${LLVM_VERSION}`,
37-
});
43+
})

0 commit comments

Comments
 (0)