From 86bdd2b6023a825749c597d640c67c5191f8e39c Mon Sep 17 00:00:00 2001 From: Lukas Taegert-Atkinson Date: Sat, 18 Nov 2023 06:31:45 +0100 Subject: [PATCH] Error for armv7 musl build (#5255) * Sort build targets * Add error for missing arm musl build * Cancel in-progress REPL builds --- .github/workflows/build-and-tests.yml | 75 +++++++++++++++------------ .github/workflows/repl-artefacts.yml | 4 ++ native.js | 19 +++++-- 3 files changed, 60 insertions(+), 38 deletions(-) diff --git a/.github/workflows/build-and-tests.yml b/.github/workflows/build-and-tests.yml index 25310fd32..c723626ac 100644 --- a/.github/workflows/build-and-tests.yml +++ b/.github/workflows/build-and-tests.yml @@ -59,6 +59,7 @@ jobs: fail-fast: false matrix: settings: + # WASM - host: windows-latest target: x86_64-pc-windows-msvc name: wasm @@ -81,12 +82,8 @@ jobs: path: | wasm-node/ .empty - - host: macos-latest - target: x86_64-apple-darwin - build: >- - set -e && - npm run build:napi -- --release && - strip -x *.node + + # Windows - host: windows-latest build: npm run build:napi -- --release target: x86_64-pc-windows-msvc @@ -96,6 +93,26 @@ jobs: rustup target add i686-pc-windows-msvc && npm run build:napi -- --release --target i686-pc-windows-msvc target: i686-pc-windows-msvc + - host: windows-latest + target: aarch64-pc-windows-msvc + build: npm run build:napi -- --release --target aarch64-pc-windows-msvc + + # MacOS + - host: macos-latest + target: x86_64-apple-darwin + build: >- + set -e && + npm run build:napi -- --release && + strip -x *.node + - host: macos-latest + target: aarch64-apple-darwin + build: >- + set -e && + rustup target add aarch64-apple-darwin && + npm run build:napi -- --release --target aarch64-apple-darwin && + strip -x *.node + + # Linux - host: ubuntu-latest target: x86_64-unknown-linux-gnu docker: ghcr.io/napi-rs/napi-rs/nodejs-rust:lts-debian @@ -110,13 +127,16 @@ jobs: build: >- set -e && npm run build:napi -- --release && strip *.node - - host: macos-latest - target: aarch64-apple-darwin + - host: ubuntu-latest + target: armv7-unknown-linux-gnueabihf + zig: true + setup: | + sudo apt-get update + sudo apt-get install gcc-arm-linux-gnueabihf -y build: >- set -e && - rustup target add aarch64-apple-darwin && - npm run build:napi -- --release --target aarch64-apple-darwin && - strip -x *.node + npm run build:napi -- --release --target armv7-unknown-linux-gnueabihf && + arm-linux-gnueabihf-strip *.node - host: ubuntu-latest target: aarch64-unknown-linux-gnu docker: ghcr.io/napi-rs/napi-rs/nodejs-rust:lts-debian-aarch64 @@ -128,21 +148,15 @@ jobs: npm run build:napi -- --release --target aarch64-unknown-linux-gnu && aarch64-unknown-linux-gnu-strip *.node - host: ubuntu-latest - target: armv7-unknown-linux-gnueabihf - zig: true - setup: | - sudo apt-get update - sudo apt-get install gcc-arm-linux-gnueabihf -y - build: >- - set -e && - npm run build:napi -- --release --target armv7-unknown-linux-gnueabihf && - arm-linux-gnueabihf-strip *.node - - host: ubuntu-latest - target: aarch64-linux-android + target: aarch64-unknown-linux-musl + docker: ghcr.io/napi-rs/napi-rs/nodejs-rust:lts-alpine build: >- set -e && - npm run build:napi -- --release --target aarch64-linux-android && - ${ANDROID_NDK_LATEST_HOME}/toolchains/llvm/prebuilt/linux-x86_64/bin/llvm-strip *.node + export JEMALLOC_SYS_WITH_LG_PAGE=16 && + rustup default nightly-2023-10-05 && + rustup target add aarch64-unknown-linux-musl && + RUSTFLAGS='-C target-feature=-crt-static -C linker=aarch64-linux-musl-gcc' npm run build:napi -- --release --target aarch64-unknown-linux-musl && + /aarch64-linux-musl-cross/bin/aarch64-linux-musl-strip *.node - host: ubuntu-latest target: armv7-linux-androideabi build: >- @@ -150,18 +164,11 @@ jobs: npm run build:napi -- --release --target armv7-linux-androideabi && ${ANDROID_NDK_LATEST_HOME}/toolchains/llvm/prebuilt/linux-x86_64/bin/llvm-strip *.node - host: ubuntu-latest - target: aarch64-unknown-linux-musl - docker: ghcr.io/napi-rs/napi-rs/nodejs-rust:lts-alpine + target: aarch64-linux-android build: >- set -e && - export JEMALLOC_SYS_WITH_LG_PAGE=16 && - rustup default nightly-2023-10-05 && - rustup target add aarch64-unknown-linux-musl && - RUSTFLAGS='-C target-feature=-crt-static -C linker=aarch64-linux-musl-gcc' npm run build:napi -- --release --target aarch64-unknown-linux-musl && - /aarch64-linux-musl-cross/bin/aarch64-linux-musl-strip *.node - - host: windows-latest - target: aarch64-pc-windows-msvc - build: npm run build:napi -- --release --target aarch64-pc-windows-msvc + npm run build:napi -- --release --target aarch64-linux-android && + ${ANDROID_NDK_LATEST_HOME}/toolchains/llvm/prebuilt/linux-x86_64/bin/llvm-strip *.node name: Build ${{ matrix.settings.name || matrix.settings.target }} runs-on: ${{ matrix.settings.host }} timeout-minutes: 30 diff --git a/.github/workflows/repl-artefacts.yml b/.github/workflows/repl-artefacts.yml index bff6ac64f..38a100902 100644 --- a/.github/workflows/repl-artefacts.yml +++ b/.github/workflows/repl-artefacts.yml @@ -8,6 +8,10 @@ on: - reopened - labeled +concurrency: + group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} + cancel-in-progress: true + permissions: contents: read diff --git a/native.js b/native.js index 733612c15..8df65b964 100644 --- a/native.js +++ b/native.js @@ -14,7 +14,7 @@ const bindingsByPlatformAndArch = { x64: { base: 'darwin-x64' } }, linux: { - arm: { base: 'linux-arm-gnueabihf' }, + arm: { base: 'linux-arm-gnueabihf', musl: null }, arm64: { base: 'linux-arm64-gnu', musl: 'linux-arm64-musl' }, x64: { base: 'linux-x64-gnu', musl: 'linux-x64-musl' } }, @@ -25,8 +25,9 @@ const bindingsByPlatformAndArch = { } }; -const imported = bindingsByPlatformAndArch[platform]?.[arch]; -if (!imported) { +const packageBase = getPackageBase(); + +if (!packageBase) { throw new Error( `Your current platform "${platform}" and architecture "${arch}" combination is not yet supported by the native Rollup build. Please use the WASM build "@rollup/wasm-node" instead. @@ -44,7 +45,17 @@ If this is important to you, please consider supporting Rollup to make a native ); } -const packageBase = imported.musl && isMusl() ? imported.musl : imported.base; +function getPackageBase() { + const imported = bindingsByPlatformAndArch[platform]?.[arch]; + if (!imported) { + return null; + } + if ('musl' in imported && isMusl()) { + return imported.musl; + } + return imported.base; +} + const localName = `./rollup.${packageBase}.node`; const { parse, parseAsync, xxhashBase64Url } = require( existsSync(join(__dirname, localName)) ? localName : `@rollup/rollup-${packageBase}`