Skip to content

Commit

Permalink
fix: armv7 glibc version
Browse files Browse the repository at this point in the history
  • Loading branch information
Brooooooklyn committed Feb 1, 2025
1 parent 4c616fe commit 0c0e6f0
Show file tree
Hide file tree
Showing 9 changed files with 141 additions and 86 deletions.
137 changes: 107 additions & 30 deletions .github/workflows/CI.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -133,20 +133,6 @@ jobs:
export CXXFLAGS="-std=c++20 -stdlib=libc++ -static -fPIC -fno-cxx-exceptions -fno-exceptions -I/usr/include/c++/v1" &&
export CARGO_TARGET_AARCH64_UNKNOWN_LINUX_MUSL_LINKER=aarch64-alpine-linux-musl-gcc &&
CC=clang CXX=clang++ yarn build --target aarch64-unknown-linux-musl
- host: ubuntu-latest
target: 'armv7-unknown-linux-gnueabihf'
downloadTarget: 'armv7-unknown-linux-gnueabihf'
setup: |
sudo apt-get update
sudo apt-get install gcc-arm-linux-gnueabihf g++-arm-linux-gnueabihf libatomic1-armhf-cross -y
docker run --rm --privileged multiarch/qemu-user-static --reset -p yes
docker buildx build --load --platform linux/arm/v7 -t ubuntu:noble-armv7 . -f noble-armv7.Dockerfile
docker run --rm -dt --name ubuntu-noble-armv7 ubuntu:noble-armv7
sudo mkdir -p /usr/arm-linux-gnueabihf/lib/llvm-18
sudo docker cp ubuntu-noble-armv7:/usr/lib/llvm-18/lib /usr/arm-linux-gnueabihf/lib/llvm-18/lib
sudo docker cp ubuntu-noble-armv7:/usr/lib/llvm-18/include /usr/arm-linux-gnueabihf/lib/llvm-18/include
docker stop ubuntu-noble-armv7
build: yarn build --target armv7-unknown-linux-gnueabihf --use-napi-cross
- host: ubuntu-latest
target: 'aarch64-linux-android'
downloadTarget: 'aarch64-linux-android'
Expand Down Expand Up @@ -184,22 +170,6 @@ jobs:
node-version: 20
cache: 'yarn'

- name: Set up QEMU
if: ${{ matrix.settings.target == 'armv7-unknown-linux-gnueabihf' }}
uses: docker/setup-qemu-action@v3
with:
platforms: linux/arm/v7
- name: Set up Docker Buildx
if: ${{ matrix.settings.target == 'armv7-unknown-linux-gnueabihf' }}
uses: docker/setup-buildx-action@v3
with:
platforms: linux/arm/v7

- uses: goto-bus-stop/setup-zig@v2
if: ${{ matrix.settings.target == 'armv7-unknown-linux-gnueabihf' }}
with:
version: 0.13.0

- name: Set env
if: matrix.settings.host == 'windows-latest'
run: echo "C:\\msys64\\mingw64\\bin" >> $GITHUB_PATH
Expand Down Expand Up @@ -242,6 +212,60 @@ jobs:
name: bindings-${{ matrix.settings.target }}
path: ${{ env.APP_NAME }}.*.node

build-armv7-linux-gnueabihf:
name: Build armv7-unknown-linux-gnueabihf
runs-on: ubuntu-latest
container:
image: debian:buster

steps:
- name: Setup tools
run: |
apt-get update
apt-get install -y gcc-arm-linux-gnueabihf g++-arm-linux-gnueabihf libatomic1-armhf-cross git build-essential cmake ninja-build wget curl gnupg
echo "deb http://apt.llvm.org/buster/ llvm-toolchain-buster-18 main" >> /etc/apt/sources.list
echo "deb-src http://apt.llvm.org/buster/ llvm-toolchain-buster-18 main" >> /etc/apt/sources.list
wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key | apt-key add -
apt-get update
apt-get install -y clang-18
ln -s /usr/bin/clang-18 /usr/bin/clang
ln -s /usr/bin/clang++-18 /usr/bin/clang++
- uses: actions/checkout@v4
with:
submodules: true

- name: Setup node
uses: actions/setup-node@v4
with:
node-version: 20

- name: Install
uses: ./.github/actions/setup-rust
with:
targets: "armv7-unknown-linux-gnueabihf"

- name: Install dependencies
run: |
corepack enable
yarn install --immutable --mode=skip-build
- name: Download skia binary
run: |
git config --global --add safe.directory "$(pwd)"
git config --global --add safe.directory "$(pwd)/skia"
node ./scripts/release-skia-binary.mjs --download --target=armv7-unknown-linux-gnueabihf
- name: Build
run: |
export CARGO_TARGET_ARMV7_UNKNOWN_LINUX_GNUEABIHF_LINKER=arm-linux-gnueabihf-gcc
yarn build --target armv7-unknown-linux-gnueabihf
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: bindings-armv7-unknown-linux-gnueabihf
path: ${{ env.APP_NAME }}.*.node

test-macOS-windows-binding:
name: Test bindings on ${{ matrix.settings.target }} - node@${{ matrix.node }}
needs:
Expand Down Expand Up @@ -535,6 +559,58 @@ jobs:
name: failure-images-aarch64-unknown-linux-musl-lts
path: __test__/failure/**

test-linux-arm-gnueabihf-binding:
name: Test bindings on armv7-unknown-linux-gnueabihf - node@${{ matrix.node }}
needs:
- build-armv7-linux-gnueabihf
strategy:
fail-fast: false
matrix:
node: ['18', '20', '22']
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Download Apple Emoji font
uses: robinraju/release-downloader@v1
with:
repository: 'PoomSmart/EmojiLibrary'
tag: '0.15.4'
fileName: [email protected]
token: ${{ secrets.GITHUB_TOKEN }}
out-file-path: __test__/fonts/
- name: Download artifacts
uses: actions/download-artifact@v4
with:
name: bindings-armv7-unknown-linux-gnueabihf
path: .
- name: List packages
run: ls -R .
shell: bash
- name: Install dependencies
run: |
yarn config set supportedArchitectures.cpu "arm"
yarn install --immutable --mode=skip-build
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
with:
platforms: arm
- run: docker run --rm --privileged multiarch/qemu-user-static --reset -p yes
- name: Setup and run tests
uses: addnab/docker-run-action@v3
with:
image: node:${{ matrix.node }}-bookworm-slim
options: '--platform linux/arm/v7 -v ${{ github.workspace }}:/skia -w /skia'
run: |
set -e && \
yarn test:ci && \
ls -la
- name: Test failed
if: ${{ failure() }}
uses: actions/upload-artifact@v4
with:
name: failure-images-armv7-unknown-linux-gnueabihf-${{ matrix.node }}
path: __test__/failure/**

rust-test:
name: stable - macOS - cargo - test
runs-on: macos-latest
Expand Down Expand Up @@ -607,6 +683,7 @@ jobs:
- test-linux-x64-musl-binding
- test-linux-aarch64-gnu-binding
- test-linux-aarch64-musl-binding
- test-linux-arm-gnueabihf-binding
- test-macOS-windows-binding

steps:
Expand Down
17 changes: 1 addition & 16 deletions .github/workflows/skia.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,7 @@ jobs:
- name: Install build tools
run: |
sudo apt-get update
sudo apt-get install ninja-build -y
sudo apt-get install ninja-build gcc-arm-linux-gnueabihf g++-arm-linux-gnueabihf -y
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
Expand All @@ -313,21 +313,6 @@ jobs:
with:
platforms: linux/arm/v7

- name: Install cross compile tools
run: |
wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key | sudo apt-key add -
echo "deb http://apt.llvm.org/noble/ llvm-toolchain-noble-19 main" | sudo tee -a /etc/apt/sources.list > /dev/null
echo "deb-src http://apt.llvm.org/noble/ llvm-toolchain-noble-19 main" | sudo tee -a /etc/apt/sources.list > /dev/null
sudo apt-get update
sudo apt-get install llvm-19 clang-19 lld-19 gcc-arm-linux-gnueabihf g++-arm-linux-gnueabihf -y
docker run --rm --privileged multiarch/qemu-user-static --reset -p yes
docker buildx build --load --platform linux/arm/v7 -t ubuntu:noble-armv7 . -f noble-armv7.Dockerfile
docker run --rm -dt --name ubuntu-noble-armv7 ubuntu:noble-armv7
sudo mkdir -p /usr/arm-linux-gnueabihf/lib/llvm-18
sudo docker cp ubuntu-noble-armv7:/usr/lib/llvm-18/lib /usr/arm-linux-gnueabihf/lib/llvm-18/lib
sudo docker cp ubuntu-noble-armv7:/usr/lib/llvm-18/include /usr/arm-linux-gnueabihf/lib/llvm-18/include
docker stop ubuntu-noble-armv7
- name: Compile skia
run: node ./scripts/build-skia.js --target=armv7-unknown-linux-gnueabihf

Expand Down
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,4 @@ napi-build = "2"
[profile.release]
codegen-units = 1
lto = true
strip = "symbols"
# strip = "symbols"
17 changes: 6 additions & 11 deletions build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ fn main() {

if compile_target_os != "windows" {
build
.flag("-std=c++20")
.flag("-std=c++17")
.flag("-fPIC")
.flag("-fno-exceptions")
.flag("-fno-rtti")
Expand Down Expand Up @@ -156,18 +156,13 @@ fn main() {
println!("cargo:rustc-link-lib=static=atomic");
}
"arm" => {
link_libcxx(&mut build);
env::set_var("CC", "clang");
env::set_var("CXX", "clang++");
env::set_var("TARGET_CC", "clang");
env::set_var("TARGET_CXX", "clang++");
env::set_var("CC", "arm-linux-gnueabihf-gcc");
env::set_var("CXX", "arm-linux-gnueabihf-g++");
build
.flag_if_supported("-static-libstdc++")
.include("/usr/arm-linux-gnueabihf/include")
.include(format!(
"/usr/arm-linux-gnueabihf/lib/llvm-18/include/c++/v1"
));
println!("cargo:rustc-link-search=/usr/arm-linux-gnueabihf/lib");
println!("cargo:rustc-link-search=/usr/arm-linux-gnueabihf/lib/llvm-18/lib");
.include(format!("/usr/arm-linux-gnueabihf/include/c++/8"));
println!("cargo:rustc-link-search=/usr/lib/gcc-cross/arm-linux-gnueabihf/8");
}
_ => {}
}
Expand Down
5 changes: 0 additions & 5 deletions noble-armv7.Dockerfile

This file was deleted.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@
"@jimp/custom": "^0.22.10",
"@jimp/jpeg": "^0.22.10",
"@jimp/png": "^0.22.10",
"@napi-rs/cli": "^3.0.0-alpha.69",
"@napi-rs/cli": "^3.0.0-alpha.70",
"@octokit/rest": "^21.0.0",
"@swc-node/register": "^1.8.0",
"@swc/core": "^1.4.0",
Expand Down
6 changes: 5 additions & 1 deletion scripts/build-c++abi.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,15 @@ execSync(
},
)

execSync(`ninja -C build cxxabi`, {
execSync(`ninja -C build cxx cxxabi`, {
stdio: 'inherit',
cwd: `llvm-project-llvmorg-${LLVM_VERSION}`,
})

execSync(`cp llvm-project-llvmorg-${LLVM_VERSION}/build/lib/libc++abi.a .`, {
stdio: 'inherit',
})

execSync(`cp llvm-project-llvmorg-${LLVM_VERSION}/build/lib/libc++.a .`, {
stdio: 'inherit',
})
26 changes: 8 additions & 18 deletions scripts/build-skia.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,8 @@ const GN_ARGS = [
`skia_enable_fontmgr_custom_embedded=false`,
`skia_enable_fontmgr_custom_empty=true`,
`skia_enable_fontmgr_android=false`,
`skunicode_tests_enabled=false`
`skunicode_tests_enabled=false`,
`skia_enable_skshaper_tests=false`
]

switch (PLATFORM_NAME) {
Expand Down Expand Up @@ -113,7 +114,7 @@ switch (PLATFORM_NAME) {
case 'linux':
case 'darwin':
ExtraCflagsCC =
'"-std=c++20",' +
'"-std=c++17",' +
'"-fno-exceptions",' +
'"-DSK_FORCE_RASTER_PIPELINE_BLITTER",' +
'"-DSK_ENABLE_SVG",' +
Expand Down Expand Up @@ -180,21 +181,10 @@ switch (TARGET_TRIPLE) {
)
break
case 'armv7-unknown-linux-gnueabihf':
CC='"arm-linux-gnueabihf-gcc"'
CXX='"arm-linux-gnueabihf-g++"'
ExtraSkiaBuildFlag += ' target_cpu="armv7a" target_os="linux"'
ExtraCflags = `"--target=arm-unknown-linux-gnueabihf", "-I/usr/arm-linux-gnueabihf/lib/llvm-18/include/c++/v1", "-march=armv7-a", "-mthumb"`
ExtraCflagsCC += `,"-stdlib=libc++", "-static", "--target=arm-unknown-linux-gnueabihf", "-I/usr/arm-linux-gnueabihf/lib/llvm-18/include/c++/v1", "-march=armv7-a", "-mthumb"`
ExtraLdFlags =
'"--target=arm-unknown-linux-gnueabihf", "-B/usr/arm-linux-gnueabihf/bin", "-L/usr/arm-linux-gnueabihf/lib", "-L/usr/arm-linux-gnueabihf/lib/llvm-18/lib"'
ExtraAsmFlags =
'"--sysroot=/usr/arm-linux-gnueabihf", "--target=arm-unknown-linux-gnueabihf", "-march=armv7-a", "-mthumb", "-mfpu=neon"'

GN_ARGS.push(
`extra_ldflags=[${ExtraLdFlags}]`,
`ar="llvm-ar-18"`,
`extra_asmflags=[${ExtraAsmFlags}]`,
`extra_cflags=[${ExtraCflags}]`,
`extra_cflags_c=[${ExtraCflags}]`,
)
ExtraCflags = `"-march=armv7-a", "-mthumb", "-mfpu=neon"`
break
case 'aarch64-apple-darwin':
ExtraSkiaBuildFlag += ' target_cpu="arm64" target_os="mac"'
Expand Down Expand Up @@ -232,13 +222,13 @@ switch (TARGET_TRIPLE) {
`extra_cflags_c=[${ExtraCflags}]`,
)
break
case '':
break
case 'riscv64gc-unknown-linux-gnu':
ExtraSkiaBuildFlag += ' target_cpu="riscv64" target_os="linux"'
CC = '"riscv64-linux-gnu-gcc"'
CXX = '"riscv64-linux-gnu-g++"'
break;
case '':
break
default:
throw new TypeError(`[${TARGET_TRIPLE}] is not a valid target`)
}
Expand Down
15 changes: 12 additions & 3 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -426,7 +426,7 @@ __metadata:
"@jimp/custom": "npm:^0.22.10"
"@jimp/jpeg": "npm:^0.22.10"
"@jimp/png": "npm:^0.22.10"
"@napi-rs/cli": "npm:^3.0.0-alpha.69"
"@napi-rs/cli": "npm:^3.0.0-alpha.70"
"@octokit/rest": "npm:^21.0.0"
"@swc-node/register": "npm:^1.8.0"
"@swc/core": "npm:^1.4.0"
Expand Down Expand Up @@ -458,7 +458,7 @@ __metadata:
languageName: unknown
linkType: soft

"@napi-rs/cli@npm:^3.0.0-alpha.69":
"@napi-rs/cli@npm:^3.0.0-alpha.70":
version: 3.0.0-alpha.70
resolution: "@napi-rs/cli@npm:3.0.0-alpha.70"
dependencies:
Expand Down Expand Up @@ -1190,7 +1190,7 @@ __metadata:
languageName: node
linkType: hard

"@octokit/types@npm:^13.6.2, @octokit/types@npm:^13.7.0, @octokit/types@npm:^13.8.0":
"@octokit/types@npm:^13.6.2, @octokit/types@npm:^13.8.0":
version: 13.8.0
resolution: "@octokit/types@npm:13.8.0"
dependencies:
Expand All @@ -1199,6 +1199,15 @@ __metadata:
languageName: node
linkType: hard

"@octokit/types@npm:^13.7.0":
version: 13.7.0
resolution: "@octokit/types@npm:13.7.0"
dependencies:
"@octokit/openapi-types": "npm:^23.0.1"
checksum: 10c0/62ed4f00304360cc31e99a9dc97ac4f48075d1d5c09a272f09b1fd3dfcc7a6169b7fab109030319ef121b0cd880c85bdb20363f4992104e07a98bd8323beeeb5
languageName: node
linkType: hard

"@oxc-resolver/binding-darwin-arm64@npm:1.12.0":
version: 1.12.0
resolution: "@oxc-resolver/binding-darwin-arm64@npm:1.12.0"
Expand Down

0 comments on commit 0c0e6f0

Please sign in to comment.