generated from napi-rs/package-template
-
-
Notifications
You must be signed in to change notification settings - Fork 79
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ci: build libc++abi.a for musl with -fPIC
- Loading branch information
1 parent
0816ba5
commit 467c8bb
Showing
4 changed files
with
114 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
name: Build libc++abi | ||
|
||
on: | ||
push: | ||
branches: | ||
- release-libc++abi | ||
tags-ignore: | ||
- '**' | ||
|
||
permissions: | ||
contents: write | ||
id-token: write | ||
attestations: write | ||
|
||
jobs: | ||
setup-llvm-version: | ||
runs-on: ubuntu-latest | ||
outputs: | ||
llvm-version: ${{ steps.setup-llvm-version.outputs.llvm-version }} | ||
steps: | ||
- name: Setup | ||
id: setup-llvm-version | ||
run: | | ||
echo "llvm-version=$(cat llvm-version)" >> $GITHUB_OUTPUT | ||
build-musl: | ||
runs-on: ${{ matrix.settings.runs-on }} | ||
needs: setup-llvm-version | ||
name: Build libc++abi for ${{ matrix.settings.arch }} Linux musl | ||
strategy: | ||
matrix: | ||
settings: | ||
- { arch: x86_64, runs-on: ubuntu-latest } | ||
- { arch: aarch64, runs-on: ubuntu-24.04-arm } | ||
steps: | ||
- name: Build in docker | ||
uses: addnab/docker-run-action@v3 | ||
with: | ||
image: node:18-alpine | ||
options: -v ${{ github.workspace }}:/build -w /build | ||
run: | | ||
apk add clang llvm wget unzip cmake ninja xz tar musl-dev python3 | ||
node scripts/build-c++abi.mjs | ||
- uses: actions/attest-build-provenance@v2 | ||
with: | ||
subject-path: | | ||
libc++abi.a | ||
- name: Upload | ||
uses: actions/upload-artifact@v4 | ||
with: | ||
name: libc++abi-${{ matrix.settings.arch }}.a | ||
path: libc++abi.a | ||
|
||
release: | ||
needs: | ||
- setup-llvm-version | ||
- build-musl | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Download x86_64 | ||
uses: actions/download-artifact@v4 | ||
with: | ||
name: libc++abi-x86_64.a | ||
path: . | ||
- name: Rename | ||
run: | | ||
mv libc++abi.a libc++abi-x86_64.a | ||
- name: Download aarch64 | ||
uses: actions/download-artifact@v4 | ||
with: | ||
name: libc++abi-aarch64.a | ||
path: . | ||
- name: Rename | ||
run: | | ||
mv libc++abi.a libc++abi-aarch64.a | ||
- name: Release | ||
uses: softprops/action-gh-release@v2 | ||
with: | ||
files: | | ||
libc++abi-x86_64.a | ||
libc++abi-aarch64.a | ||
name: libc++abi-${{ needs.setup-llvm-version.outputs.llvm-version }} | ||
tag_name: libc++abi-${{ needs.setup-llvm-version.outputs.llvm-version }} | ||
make_latest: false | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
19.1.7 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,37 +1,43 @@ | ||
import { execSync } from "node:child_process"; | ||
import { execSync } from 'node:child_process' | ||
import { readFileSync } from 'node:fs' | ||
import { fileURLToPath } from 'node:url' | ||
import { join } from 'node:path' | ||
|
||
const LLVM_VERSION = "19.1.7"; | ||
const LLVM_VERSION = readFileSync(join(fileURLToPath(import.meta.url), '..', '..', 'llvm-version'), 'utf-8').trim() | ||
|
||
execSync(`wget https://github.com/llvm/llvm-project/archive/refs/tags/llvmorg-${LLVM_VERSION}.zip`, { | ||
stdio: "inherit", | ||
}); | ||
stdio: 'inherit', | ||
}) | ||
|
||
execSync(`unzip llvmorg-${LLVM_VERSION}.zip`, { | ||
stdio: "inherit", | ||
}); | ||
stdio: 'inherit', | ||
}) | ||
|
||
execSync(`mkdir -p build`, { | ||
stdio: "inherit", | ||
stdio: 'inherit', | ||
cwd: `llvm-project-llvmorg-${LLVM_VERSION}`, | ||
}); | ||
}) | ||
|
||
execSync(`cmake -G Ninja -S runtimes -B build -DCMAKE_BUILD_TYPE=Release -DLLVM_ENABLE_RUNTIMES="libcxx;libcxxabi;libunwind" -DLIBCXX_ENABLE_LOCALIZATION=OFF`, { | ||
stdio: "inherit", | ||
cwd: `llvm-project-llvmorg-${LLVM_VERSION}`, | ||
env: { | ||
...process.env, | ||
CXX: "clang++", | ||
CC: "clang", | ||
CXXFLAGS: "-fPIC", | ||
execSync( | ||
`cmake -G Ninja -S runtimes -B build -DCMAKE_BUILD_TYPE=Release -DLLVM_ENABLE_RUNTIMES="libcxx;libcxxabi;libunwind" -DLIBCXX_ENABLE_LOCALIZATION=OFF`, | ||
{ | ||
stdio: 'inherit', | ||
cwd: `llvm-project-llvmorg-${LLVM_VERSION}`, | ||
env: { | ||
...process.env, | ||
CXX: 'clang++', | ||
CC: 'clang', | ||
CXXFLAGS: '-fPIC', | ||
}, | ||
}, | ||
}); | ||
) | ||
|
||
execSync(`ninja -C build cxxabi`, { | ||
stdio: "inherit", | ||
stdio: 'inherit', | ||
cwd: `llvm-project-llvmorg-${LLVM_VERSION}`, | ||
}); | ||
}) | ||
|
||
execSync(`cp build/lib/libc++abi.a /usr/lib/libc++abi.a`, { | ||
stdio: "inherit", | ||
execSync(`cp llvm-project-llvmorg-${LLVM_VERSION}/build/lib/libc++abi.a .`, { | ||
stdio: 'inherit', | ||
cwd: `llvm-project-llvmorg-${LLVM_VERSION}`, | ||
}); | ||
}) |