From ff6c698cb80e67436cb9d8b33e584d1edfc760c6 Mon Sep 17 00:00:00 2001 From: tangowithfoxtrot <5676771+tangowithfoxtrot@users.noreply.github.com> Date: Mon, 11 Mar 2024 09:31:57 -0700 Subject: [PATCH 1/7] fix: linux arm64 cross-compilation (hopefully) --- .github/workflows/build-rust-cross-platform.yml | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/.github/workflows/build-rust-cross-platform.yml b/.github/workflows/build-rust-cross-platform.yml index 67c41c6f9..590fc5559 100644 --- a/.github/workflows/build-rust-cross-platform.yml +++ b/.github/workflows/build-rust-cross-platform.yml @@ -25,6 +25,8 @@ jobs: target: x86_64-pc-windows-msvc - os: ubuntu-22.04 target: x86_64-unknown-linux-gnu + - os: ubuntu-22.04 + target: aarch64-unknown-linux-gnu steps: - name: Checkout @@ -44,8 +46,18 @@ jobs: - name: Build Rust env: RUSTFLAGS: "-D warnings" + if: ${{ matrix.settings.target }} != aarch64-unknown-linux-gnu run: cargo build --target ${{ matrix.settings.target }} --release + - name: Build Rust + env: + RUSTFLAGS: "-D warnings" + if: ${{ matrix.settings.target }} == aarch64-unknown-linux-gnu + run: | + sudo apt update + sudo apt install -y crossbuild-essential-arm64 + cargo build --target ${{ matrix.settings.target }} --release + - name: Upload Artifact uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1 with: From be03087f123511668469417f6c104b77e2058918 Mon Sep 17 00:00:00 2001 From: tangowithfoxtrot <5676771+tangowithfoxtrot@users.noreply.github.com> Date: Thu, 14 Mar 2024 05:54:43 -0700 Subject: [PATCH 2/7] Update build-rust-cross-platform.yml --- .github/workflows/build-rust-cross-platform.yml | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/.github/workflows/build-rust-cross-platform.yml b/.github/workflows/build-rust-cross-platform.yml index 590fc5559..1a853e6eb 100644 --- a/.github/workflows/build-rust-cross-platform.yml +++ b/.github/workflows/build-rust-cross-platform.yml @@ -40,6 +40,10 @@ jobs: - name: Cache cargo registry uses: Swatinem/rust-cache@23bce251a8cd2ffc3c1075eaa2367cf899916d84 # v2.7.3 + - name: Install Cross (aarch64-unknown-linux-gnu) + if: ${{ matrix.settings.target == 'aarch64-unknown-linux-gnu' }} + run: cargo install cross --locked --git https://github.com/cross-rs/cross.git --rev 185398b1b885820515a212de720a306b08e2c8c9 + - name: Add build architecture run: rustup target add ${{ matrix.settings.target }} @@ -49,15 +53,12 @@ jobs: if: ${{ matrix.settings.target }} != aarch64-unknown-linux-gnu run: cargo build --target ${{ matrix.settings.target }} --release - - name: Build Rust + - name: Build Rust (aarch64-unknown-linux-gnu) env: RUSTFLAGS: "-D warnings" if: ${{ matrix.settings.target }} == aarch64-unknown-linux-gnu - run: | - sudo apt update - sudo apt install -y crossbuild-essential-arm64 - cargo build --target ${{ matrix.settings.target }} --release - + run: cross build --target ${{ matrix.settings.target }} --release + - name: Upload Artifact uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1 with: From 5347de429fbcc20d646c96a0fcfc5f75f3092995 Mon Sep 17 00:00:00 2001 From: tangowithfoxtrot <5676771+tangowithfoxtrot@users.noreply.github.com> Date: Thu, 14 Mar 2024 06:12:29 -0700 Subject: [PATCH 3/7] try specifying build toolchain in cargofile --- crates/bitwarden-c/Cargo.toml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/crates/bitwarden-c/Cargo.toml b/crates/bitwarden-c/Cargo.toml index 211a482e9..9c653d938 100644 --- a/crates/bitwarden-c/Cargo.toml +++ b/crates/bitwarden-c/Cargo.toml @@ -15,3 +15,6 @@ bitwarden-json = { path = "../bitwarden-json", features = ["secrets"] } [dependencies] env_logger = ">=0.10.0, <0.12" + +[target.aarch64-unknown-linux-gnu] +image.toolchain = ["aarch64-linux-gnu-gcc"] From af97c555e0941ef9457a7e91a618434e5e547e9b Mon Sep 17 00:00:00 2001 From: tangowithfoxtrot <5676771+tangowithfoxtrot@users.noreply.github.com> Date: Thu, 14 Mar 2024 06:18:40 -0700 Subject: [PATCH 4/7] try configuring cross from cargofile --- crates/bitwarden-c/Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/bitwarden-c/Cargo.toml b/crates/bitwarden-c/Cargo.toml index 9c653d938..3ca7de53d 100644 --- a/crates/bitwarden-c/Cargo.toml +++ b/crates/bitwarden-c/Cargo.toml @@ -16,5 +16,5 @@ bitwarden-json = { path = "../bitwarden-json", features = ["secrets"] } [dependencies] env_logger = ">=0.10.0, <0.12" -[target.aarch64-unknown-linux-gnu] +[package.metadata.cross.target.aarch64-unknown-linux-gnu] image.toolchain = ["aarch64-linux-gnu-gcc"] From 25267e7315939ad1559215dda778dd3fe730a3da Mon Sep 17 00:00:00 2001 From: tangowithfoxtrot <5676771+tangowithfoxtrot@users.noreply.github.com> Date: Thu, 14 Mar 2024 06:23:58 -0700 Subject: [PATCH 5/7] use crossfile instead --- crates/bitwarden-c/Cargo.toml | 3 --- crates/bitwarden-c/Cross.toml | 2 ++ 2 files changed, 2 insertions(+), 3 deletions(-) create mode 100644 crates/bitwarden-c/Cross.toml diff --git a/crates/bitwarden-c/Cargo.toml b/crates/bitwarden-c/Cargo.toml index 3ca7de53d..211a482e9 100644 --- a/crates/bitwarden-c/Cargo.toml +++ b/crates/bitwarden-c/Cargo.toml @@ -15,6 +15,3 @@ bitwarden-json = { path = "../bitwarden-json", features = ["secrets"] } [dependencies] env_logger = ">=0.10.0, <0.12" - -[package.metadata.cross.target.aarch64-unknown-linux-gnu] -image.toolchain = ["aarch64-linux-gnu-gcc"] diff --git a/crates/bitwarden-c/Cross.toml b/crates/bitwarden-c/Cross.toml new file mode 100644 index 000000000..84bea2db5 --- /dev/null +++ b/crates/bitwarden-c/Cross.toml @@ -0,0 +1,2 @@ +[target.aarch64-unknown-linux-gnu] +image.toolchain = ["aarch64-linux-gnu-gcc"] From 93a15211143dc4dedfd52d162465dbc6dbeae487 Mon Sep 17 00:00:00 2001 From: tangowithfoxtrot <5676771+tangowithfoxtrot@users.noreply.github.com> Date: Thu, 14 Mar 2024 06:54:32 -0700 Subject: [PATCH 6/7] fix `if` condition syntax --- .github/workflows/build-rust-cross-platform.yml | 4 ++-- crates/bitwarden-c/Cross.toml | 2 -- 2 files changed, 2 insertions(+), 4 deletions(-) delete mode 100644 crates/bitwarden-c/Cross.toml diff --git a/.github/workflows/build-rust-cross-platform.yml b/.github/workflows/build-rust-cross-platform.yml index 1a853e6eb..81c725c48 100644 --- a/.github/workflows/build-rust-cross-platform.yml +++ b/.github/workflows/build-rust-cross-platform.yml @@ -50,13 +50,13 @@ jobs: - name: Build Rust env: RUSTFLAGS: "-D warnings" - if: ${{ matrix.settings.target }} != aarch64-unknown-linux-gnu + if: ${{ matrix.settings.target != 'aarch64-unknown-linux-gnu' }} run: cargo build --target ${{ matrix.settings.target }} --release - name: Build Rust (aarch64-unknown-linux-gnu) env: RUSTFLAGS: "-D warnings" - if: ${{ matrix.settings.target }} == aarch64-unknown-linux-gnu + if: ${{ matrix.settings.target == 'aarch64-unknown-linux-gnu' }} run: cross build --target ${{ matrix.settings.target }} --release - name: Upload Artifact diff --git a/crates/bitwarden-c/Cross.toml b/crates/bitwarden-c/Cross.toml deleted file mode 100644 index 84bea2db5..000000000 --- a/crates/bitwarden-c/Cross.toml +++ /dev/null @@ -1,2 +0,0 @@ -[target.aarch64-unknown-linux-gnu] -image.toolchain = ["aarch64-linux-gnu-gcc"] From 57a7591d9e7a13d37fb8e14ee9807d7191860886 Mon Sep 17 00:00:00 2001 From: tangowithfoxtrot <5676771+tangowithfoxtrot@users.noreply.github.com> Date: Fri, 22 Mar 2024 09:20:42 -0700 Subject: [PATCH 7/7] try to fix `libc` and `serde` compilation errors --- .github/workflows/build-rust-cross-platform.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build-rust-cross-platform.yml b/.github/workflows/build-rust-cross-platform.yml index 81c725c48..38b4a90f1 100644 --- a/.github/workflows/build-rust-cross-platform.yml +++ b/.github/workflows/build-rust-cross-platform.yml @@ -57,7 +57,9 @@ jobs: env: RUSTFLAGS: "-D warnings" if: ${{ matrix.settings.target == 'aarch64-unknown-linux-gnu' }} - run: cross build --target ${{ matrix.settings.target }} --release + run: | + cargo clean + cross build --target ${{ matrix.settings.target }} --release - name: Upload Artifact uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1