From cbe87d5098aac2f47f87b3094b599f7fcafa1f98 Mon Sep 17 00:00:00 2001 From: Ford Date: Thu, 28 Apr 2022 12:20:25 -0700 Subject: [PATCH 01/12] node-plugin: ARM support --- .cargo/config | 2 + .github/workflows/publish.yaml | 81 +++++++++++++++++++++++++++------- node-plugin/package.json | 3 ++ 3 files changed, 69 insertions(+), 17 deletions(-) create mode 100644 .cargo/config diff --git a/.cargo/config b/.cargo/config new file mode 100644 index 0000000..6fed3ab --- /dev/null +++ b/.cargo/config @@ -0,0 +1,2 @@ +[target.aarch64-unknown-linux-gnu] +linker = "gcc-aarch64-linux-gnu" diff --git a/.github/workflows/publish.yaml b/.github/workflows/publish.yaml index b8f0fb7..6aee4ca 100644 --- a/.github/workflows/publish.yaml +++ b/.github/workflows/publish.yaml @@ -5,8 +5,9 @@ name: "Publish binaries" on: push: - tags: - - '*' + branches: [ master ] + pull_request: + branches: [ master ] jobs: publish-github: @@ -15,35 +16,81 @@ jobs: # (https://github.com/bchr02/node-pre-gyp-github/issues/42) fail-fast: false matrix: - node_version: [12, 14, 16, 17] + node_version: [16] system: - os: macos-latest - target: x86_64-apple-darwin + target: aarch64-apple-darwin + linker: aarch64-darwin-gcc + cross: false - os: ubuntu-latest - target: x86_64-unknown-linux-gnu - include: - - node_version: 16 - system: - os: macos-latest - target: aarch64-apple-darwin + target: aarch64-unknown-linux-gnu + linker: gcc-aarch64-linux-gnu + cross: true +# system: +# - os: macos-latest +# target: x86_64-apple-darwin +# - os: ubuntu-latest +# target: x86_64-unknown-linux-gnu +# include: +# - node_version: 16 +# system: +# os: macos-latest +# target: aarch64-apple-darwin +# - node_version: 16 +# system: +# os: ubuntu-latest +# target: aarch64-unknown-linux-gnu runs-on: ${{ matrix.system.os }} steps: - name: Checkout the repo uses: actions/checkout@v2 + + - name: Rust cache + uses: actions/cache@v2 + with: + path: | + ~/.cargo/registry + ~/.cargo/git + ~/.rustup + target + key: ${{ runner.os }} + + - name: Install Linker + if: matrix.system.cross + run: | + sudo apt update + sudo apt install ${{ matrix.system.linker }} + + - name: Install Rust + run: | + rustup install stable + rustup target add ${{ matrix.system.target }} + rustup show + +# - name: Install Linker +# if: matrix.system.cross +# run: | +# sudo apt update +# sudo apt install build-essential +# sudo apt install ${{ matrix.system.linker }} +# +# - name: Setup Rust +# uses: actions-rs/toolchain@v1 +# with: +# profile: minimal +# toolchain: stable +# target: ${{ matrix.system.target }} +# override: true + - name: Set up Node.js ${{ matrix.node-version }} uses: actions/setup-node@v2.1.5 with: node-version: ${{ matrix.node_version }} - - name: Setup Rust - uses: actions-rs/toolchain@v1 - with: - profile: minimal - toolchain: stable - target: ${{ matrix.system.target }} - override: true + - name: Install dependencies working-directory: ./node-plugin run: yarn install --ignore-scripts + - name: Compile binary, test, package, and publish to Github release page env: NODE_PRE_GYP_GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/node-plugin/package.json b/node-plugin/package.json index 68bf748..7310a2b 100644 --- a/node-plugin/package.json +++ b/node-plugin/package.json @@ -21,6 +21,9 @@ "x64", "arm" ], + "engines": { + "node": ">=12.22.0" + }, "scripts": { "build": "cargo-cp-artifact -a cdylib node_plugin ./native/index.node -- cargo build --message-format=json-render-diagnostics", "build-debug": "yarn build --", From ce1db531ebbe38ced5343ad4c64aab1c04467af5 Mon Sep 17 00:00:00 2001 From: hopeyen Date: Thu, 5 May 2022 09:49:04 -0700 Subject: [PATCH 02/12] .cargo: change linker target --- .cargo/config | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.cargo/config b/.cargo/config index 6fed3ab..3c32d25 100644 --- a/.cargo/config +++ b/.cargo/config @@ -1,2 +1,2 @@ [target.aarch64-unknown-linux-gnu] -linker = "gcc-aarch64-linux-gnu" +linker = "aarch64-linux-gnu-gcc" From 4be374cc300c44c320d30a2bf2e51b8633144404 Mon Sep 17 00:00:00 2001 From: hopeyen Date: Thu, 5 May 2022 10:35:29 -0700 Subject: [PATCH 03/12] .github: rust file format --- .github/workflows/publish.yaml | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/.github/workflows/publish.yaml b/.github/workflows/publish.yaml index 6aee4ca..072b180 100644 --- a/.github/workflows/publish.yaml +++ b/.github/workflows/publish.yaml @@ -19,10 +19,12 @@ jobs: node_version: [16] system: - os: macos-latest + rust: stable target: aarch64-apple-darwin linker: aarch64-darwin-gcc cross: false - os: ubuntu-latest + rust: stable target: aarch64-unknown-linux-gnu linker: gcc-aarch64-linux-gnu cross: true @@ -63,9 +65,16 @@ jobs: - name: Install Rust run: | - rustup install stable + rustup install ${{ matrix.system.rust }} rustup target add ${{ matrix.system.target }} rustup show + - name: Setup Rust + uses: actions-rs/toolchain@v1 + with: + profile: minimal + toolchain: stable + target: ${{ matrix.system.target }} + override: true # - name: Install Linker # if: matrix.system.cross @@ -74,13 +83,13 @@ jobs: # sudo apt install build-essential # sudo apt install ${{ matrix.system.linker }} # -# - name: Setup Rust -# uses: actions-rs/toolchain@v1 -# with: -# profile: minimal -# toolchain: stable -# target: ${{ matrix.system.target }} -# override: true + # - name: Setup Rust + # uses: actions-rs/toolchain@v1 + # with: + # profile: minimal + # toolchain: stable + # target: ${{ matrix.system.target }} + # override: true - name: Set up Node.js ${{ matrix.node-version }} uses: actions/setup-node@v2.1.5 From 6ffc4bbbdc1a33927296460f48bec22600aa0543 Mon Sep 17 00:00:00 2001 From: hopeyen Date: Thu, 5 May 2022 12:44:40 -0700 Subject: [PATCH 04/12] package.json: add cargo build target --- .github/workflows/publish.yaml | 22 +++++++--------------- node-plugin/package.json | 5 +++-- 2 files changed, 10 insertions(+), 17 deletions(-) diff --git a/.github/workflows/publish.yaml b/.github/workflows/publish.yaml index 072b180..7523894 100644 --- a/.github/workflows/publish.yaml +++ b/.github/workflows/publish.yaml @@ -63,6 +63,13 @@ jobs: sudo apt update sudo apt install ${{ matrix.system.linker }} +# - name: Install Linker +# if: matrix.system.cross +# run: | +# sudo apt update +# sudo apt install build-essential +# sudo apt install ${{ matrix.system.linker }} + - name: Install Rust run: | rustup install ${{ matrix.system.rust }} @@ -76,21 +83,6 @@ jobs: target: ${{ matrix.system.target }} override: true -# - name: Install Linker -# if: matrix.system.cross -# run: | -# sudo apt update -# sudo apt install build-essential -# sudo apt install ${{ matrix.system.linker }} -# - # - name: Setup Rust - # uses: actions-rs/toolchain@v1 - # with: - # profile: minimal - # toolchain: stable - # target: ${{ matrix.system.target }} - # override: true - - name: Set up Node.js ${{ matrix.node-version }} uses: actions/setup-node@v2.1.5 with: diff --git a/node-plugin/package.json b/node-plugin/package.json index 7310a2b..c92a624 100644 --- a/node-plugin/package.json +++ b/node-plugin/package.json @@ -19,13 +19,14 @@ ], "cpu": [ "x64", - "arm" + "arm", + "arm64" ], "engines": { "node": ">=12.22.0" }, "scripts": { - "build": "cargo-cp-artifact -a cdylib node_plugin ./native/index.node -- cargo build --message-format=json-render-diagnostics", + "build": "cargo-cp-artifact -a cdylib node_plugin ./native/index.node -- cargo build --target aarch64-unknown-linux-gnu --message-format=json-render-diagnostics", "build-debug": "yarn build --", "build-release": "yarn build --release", "package": "node-pre-gyp package", From b1926b8b978b05a772c049c8428f1b9f6c4828e4 Mon Sep 17 00:00:00 2001 From: hopeyen Date: Thu, 5 May 2022 14:09:28 -0700 Subject: [PATCH 05/12] publish.yaml: add explicit build --- .github/workflows/publish.yaml | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/.github/workflows/publish.yaml b/.github/workflows/publish.yaml index 7523894..deff956 100644 --- a/.github/workflows/publish.yaml +++ b/.github/workflows/publish.yaml @@ -75,13 +75,21 @@ jobs: rustup install ${{ matrix.system.rust }} rustup target add ${{ matrix.system.target }} rustup show - - name: Setup Rust - uses: actions-rs/toolchain@v1 + + - name: Build + run: cargo build --release --target ${{ matrix.system.target }} with: profile: minimal toolchain: stable target: ${{ matrix.system.target }} override: true + # - name: Setup Rust + # uses: actions-rs/toolchain@v1 + # with: + # profile: minimal + # toolchain: stable + # target: ${{ matrix.system.target }} + # override: true - name: Set up Node.js ${{ matrix.node-version }} uses: actions/setup-node@v2.1.5 From 195c2b49e322b44f4fed903d15a69782aad0e7a9 Mon Sep 17 00:00:00 2001 From: hopeyen Date: Thu, 5 May 2022 18:27:52 -0700 Subject: [PATCH 06/12] publish.yaml: install neon --- .github/workflows/publish.yaml | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/.github/workflows/publish.yaml b/.github/workflows/publish.yaml index deff956..9a6dad7 100644 --- a/.github/workflows/publish.yaml +++ b/.github/workflows/publish.yaml @@ -76,20 +76,13 @@ jobs: rustup target add ${{ matrix.system.target }} rustup show - - name: Build - run: cargo build --release --target ${{ matrix.system.target }} + - name: Setup Rust + uses: actions-rs/toolchain@v1 with: profile: minimal toolchain: stable target: ${{ matrix.system.target }} override: true - # - name: Setup Rust - # uses: actions-rs/toolchain@v1 - # with: - # profile: minimal - # toolchain: stable - # target: ${{ matrix.system.target }} - # override: true - name: Set up Node.js ${{ matrix.node-version }} uses: actions/setup-node@v2.1.5 @@ -99,6 +92,17 @@ jobs: - name: Install dependencies working-directory: ./node-plugin run: yarn install --ignore-scripts + + - run: npm@5 install + - run: npm ci --ignore-scripts + - name: Compile all non-rust code + run: npm run ci-build-no-rust + - name: Cross compile rust code + run: npx lerna run --stream build-rust-release -- -- --target ${{ matrix.target }} + - run: npm install neon + - run: npm run build + env: + BUILD_CORE_RELEASE: false - name: Compile binary, test, package, and publish to Github release page env: From 4036c68f880c86c18214599e5421a39c026e14bf Mon Sep 17 00:00:00 2001 From: hopeyen Date: Fri, 6 May 2022 08:17:31 -0700 Subject: [PATCH 07/12] remove npm builds --- .github/workflows/publish.yaml | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/.github/workflows/publish.yaml b/.github/workflows/publish.yaml index 9a6dad7..ee1f50b 100644 --- a/.github/workflows/publish.yaml +++ b/.github/workflows/publish.yaml @@ -93,17 +93,6 @@ jobs: working-directory: ./node-plugin run: yarn install --ignore-scripts - - run: npm@5 install - - run: npm ci --ignore-scripts - - name: Compile all non-rust code - run: npm run ci-build-no-rust - - name: Cross compile rust code - run: npx lerna run --stream build-rust-release -- -- --target ${{ matrix.target }} - - run: npm install neon - - run: npm run build - env: - BUILD_CORE_RELEASE: false - - name: Compile binary, test, package, and publish to Github release page env: NODE_PRE_GYP_GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} From 7e0f9ace313d1a1fc3587f6d921c4116de3a7550 Mon Sep 17 00:00:00 2001 From: hopeyen Date: Fri, 6 May 2022 09:08:44 -0700 Subject: [PATCH 08/12] frozen lockfile --- .github/workflows/publish.yaml | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/.github/workflows/publish.yaml b/.github/workflows/publish.yaml index ee1f50b..d449876 100644 --- a/.github/workflows/publish.yaml +++ b/.github/workflows/publish.yaml @@ -26,7 +26,7 @@ jobs: - os: ubuntu-latest rust: stable target: aarch64-unknown-linux-gnu - linker: gcc-aarch64-linux-gnu + linker: aarch64-linux-gnu-gcc cross: true # system: # - os: macos-latest @@ -90,8 +90,17 @@ jobs: node-version: ${{ matrix.node_version }} - name: Install dependencies + env: + NPM_CONFIG_FOREGROUND_SCRIPTS: true npm ci working-directory: ./node-plugin - run: yarn install --ignore-scripts + run: | + yarn autoclean --init + rm -rf node_modules && yarn install --frozen-lockfile --ignore-scripts + + # - name: Cross compile rust code + # run: | + # lerna init + # lerna run --stream build-rust-release -- -- --target ${{ matrix.system.target }} - name: Compile binary, test, package, and publish to Github release page env: From f5ac2d13d451bd830e028725dbe7da6cefc95b58 Mon Sep 17 00:00:00 2001 From: hopeyen Date: Fri, 6 May 2022 10:43:14 -0700 Subject: [PATCH 09/12] cargo flash --- .github/workflows/publish.yaml | 18 ++++++------------ node-plugin/package.json | 2 +- 2 files changed, 7 insertions(+), 13 deletions(-) diff --git a/.github/workflows/publish.yaml b/.github/workflows/publish.yaml index d449876..7dd46a2 100644 --- a/.github/workflows/publish.yaml +++ b/.github/workflows/publish.yaml @@ -26,7 +26,7 @@ jobs: - os: ubuntu-latest rust: stable target: aarch64-unknown-linux-gnu - linker: aarch64-linux-gnu-gcc + linker: gcc-aarch64-linux-gnu cross: true # system: # - os: macos-latest @@ -61,15 +61,10 @@ jobs: if: matrix.system.cross run: | sudo apt update + sudo apt install build-essential + sudo apt install libudev-dev sudo apt install ${{ matrix.system.linker }} -# - name: Install Linker -# if: matrix.system.cross -# run: | -# sudo apt update -# sudo apt install build-essential -# sudo apt install ${{ matrix.system.linker }} - - name: Install Rust run: | rustup install ${{ matrix.system.rust }} @@ -97,10 +92,9 @@ jobs: yarn autoclean --init rm -rf node_modules && yarn install --frozen-lockfile --ignore-scripts - # - name: Cross compile rust code - # run: | - # lerna init - # lerna run --stream build-rust-release -- -- --target ${{ matrix.system.target }} + - name: Cross compile rust code + run: | + cargo install cargo-flash - name: Compile binary, test, package, and publish to Github release page env: diff --git a/node-plugin/package.json b/node-plugin/package.json index c92a624..9bc7537 100644 --- a/node-plugin/package.json +++ b/node-plugin/package.json @@ -26,7 +26,7 @@ "node": ">=12.22.0" }, "scripts": { - "build": "cargo-cp-artifact -a cdylib node_plugin ./native/index.node -- cargo build --target aarch64-unknown-linux-gnu --message-format=json-render-diagnostics", + "build": "cargo-cp-artifact -a cdylib node_plugin ./native/index.node -- cargo flash --target aarch64-unknown-linux-gnu", "build-debug": "yarn build --", "build-release": "yarn build --release", "package": "node-pre-gyp package", From b389b40dc2673f704ef9e545a853144405a45b1b Mon Sep 17 00:00:00 2001 From: hopeyen Date: Mon, 9 May 2022 08:23:32 -0700 Subject: [PATCH 10/12] publish.yaml: CC flag --- .github/workflows/publish.yaml | 7 ++++--- node-plugin/package.json | 2 +- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/.github/workflows/publish.yaml b/.github/workflows/publish.yaml index 7dd46a2..8c6fe50 100644 --- a/.github/workflows/publish.yaml +++ b/.github/workflows/publish.yaml @@ -92,13 +92,14 @@ jobs: yarn autoclean --init rm -rf node_modules && yarn install --frozen-lockfile --ignore-scripts - - name: Cross compile rust code - run: | - cargo install cargo-flash + # - name: Cross compile rust code + # run: | + # cargo install cargo-flash - name: Compile binary, test, package, and publish to Github release page env: NODE_PRE_GYP_GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} CARGO_BUILD_TARGET: ${{ matrix.system.target }} + CC_aarch64-unknown-linux-gnu: aarch64-linux-gnu-gcc working-directory: ./node-plugin run: yarn build-test-pack-publish diff --git a/node-plugin/package.json b/node-plugin/package.json index 9bc7537..5e787ff 100644 --- a/node-plugin/package.json +++ b/node-plugin/package.json @@ -26,7 +26,7 @@ "node": ">=12.22.0" }, "scripts": { - "build": "cargo-cp-artifact -a cdylib node_plugin ./native/index.node -- cargo flash --target aarch64-unknown-linux-gnu", + "build": "cargo-cp-artifact -a cdylib node_plugin ./native/index.node -- cargo build --target aarch64-unknown-linux-gnu", "build-debug": "yarn build --", "build-release": "yarn build --release", "package": "node-pre-gyp package", From 36197ff426b8215e64fa705c1f6e036cae73aca5 Mon Sep 17 00:00:00 2001 From: hopeyen Date: Mon, 9 May 2022 08:39:06 -0700 Subject: [PATCH 11/12] sad attempt with arm-unknown-linux-gnueabihf --- .cargo/config | 4 ++-- .github/workflows/publish.yaml | 7 ++++--- node-plugin/package.json | 2 +- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/.cargo/config b/.cargo/config index 3c32d25..112515e 100644 --- a/.cargo/config +++ b/.cargo/config @@ -1,2 +1,2 @@ -[target.aarch64-unknown-linux-gnu] -linker = "aarch64-linux-gnu-gcc" +[target.arm-unknown-linux-gnueabihf] +linker = "arm-linux-gnueabihf-gcc" diff --git a/.github/workflows/publish.yaml b/.github/workflows/publish.yaml index 8c6fe50..4d3069f 100644 --- a/.github/workflows/publish.yaml +++ b/.github/workflows/publish.yaml @@ -25,8 +25,8 @@ jobs: cross: false - os: ubuntu-latest rust: stable - target: aarch64-unknown-linux-gnu - linker: gcc-aarch64-linux-gnu + target: arm-unknown-linux-gnueabihf + linker: gcc-arm-linux-gnueabihf cross: true # system: # - os: macos-latest @@ -100,6 +100,7 @@ jobs: env: NODE_PRE_GYP_GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} CARGO_BUILD_TARGET: ${{ matrix.system.target }} - CC_aarch64-unknown-linux-gnu: aarch64-linux-gnu-gcc + GCC_arm-unknown-linux-gnueabihf: arm-linux-gnueabihf-gcc + GCC_arm_unknown_linux_gnueabihf: arm-linux-gnueabihf-gcc working-directory: ./node-plugin run: yarn build-test-pack-publish diff --git a/node-plugin/package.json b/node-plugin/package.json index 5e787ff..f05c620 100644 --- a/node-plugin/package.json +++ b/node-plugin/package.json @@ -26,7 +26,7 @@ "node": ">=12.22.0" }, "scripts": { - "build": "cargo-cp-artifact -a cdylib node_plugin ./native/index.node -- cargo build --target aarch64-unknown-linux-gnu", + "build": "cargo-cp-artifact -a cdylib node_plugin ./native/index.node -- cargo build --target arm-unknown-linux-gnueabihf", "build-debug": "yarn build --", "build-release": "yarn build --release", "package": "node-pre-gyp package", From 1b7c0a19ab19e8fcdb3f5912d6e7f7cc4ba35e70 Mon Sep 17 00:00:00 2001 From: hopeyen Date: Mon, 9 May 2022 09:14:39 -0700 Subject: [PATCH 12/12] -flto for link optimization --- .cargo/config | 4 ++-- .github/workflows/publish.yaml | 8 ++++---- node-plugin/package.json | 2 +- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/.cargo/config b/.cargo/config index 112515e..3c32d25 100644 --- a/.cargo/config +++ b/.cargo/config @@ -1,2 +1,2 @@ -[target.arm-unknown-linux-gnueabihf] -linker = "arm-linux-gnueabihf-gcc" +[target.aarch64-unknown-linux-gnu] +linker = "aarch64-linux-gnu-gcc" diff --git a/.github/workflows/publish.yaml b/.github/workflows/publish.yaml index 4d3069f..0b35433 100644 --- a/.github/workflows/publish.yaml +++ b/.github/workflows/publish.yaml @@ -25,8 +25,8 @@ jobs: cross: false - os: ubuntu-latest rust: stable - target: arm-unknown-linux-gnueabihf - linker: gcc-arm-linux-gnueabihf + target: aarch64-unknown-linux-gnu + linker: gcc-aarch64-linux-gnu cross: true # system: # - os: macos-latest @@ -100,7 +100,7 @@ jobs: env: NODE_PRE_GYP_GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} CARGO_BUILD_TARGET: ${{ matrix.system.target }} - GCC_arm-unknown-linux-gnueabihf: arm-linux-gnueabihf-gcc - GCC_arm_unknown_linux_gnueabihf: arm-linux-gnueabihf-gcc + GCC_aarch64-unknown-linux-gnu: aarch64-linux-gnu-gcc + GCC_aarch64_unknown_linux_gnu: aarch64-linux-gnu-gcc working-directory: ./node-plugin run: yarn build-test-pack-publish diff --git a/node-plugin/package.json b/node-plugin/package.json index f05c620..59b8d46 100644 --- a/node-plugin/package.json +++ b/node-plugin/package.json @@ -26,7 +26,7 @@ "node": ">=12.22.0" }, "scripts": { - "build": "cargo-cp-artifact -a cdylib node_plugin ./native/index.node -- cargo build --target arm-unknown-linux-gnueabihf", + "build": "cargo-cp-artifact -a cdylib node_plugin ./native/index.node -- cargo build --target aarch64-unknown-linux-gnu -flto /home/runner/work/agora/agora/target/aarch64-unknown-linux-gnu/release/deps/libneon_sys-dd4bb8d7de746e37.rlib", "build-debug": "yarn build --", "build-release": "yarn build --release", "package": "node-pre-gyp package",