From e7e5eca2101d46daa9d8d6072afdc073738c4e54 Mon Sep 17 00:00:00 2001 From: Graydon Hoare Date: Fri, 25 Aug 2023 15:37:10 -0700 Subject: [PATCH] re-enable linux arm64 builds (#1060) Fix https://github.com/stellar/rs-soroban-sdk/issues/1011 by avoiding the use of `crate-type = ["cdylib"]` in native builds. It was causing some linker errors when cross-compiling from x64-linux to aarch64-linux, I believe the root cause is https://github.com/rust-lang/cargo/issues/4133 i.e. cargo failing to select the right target linker during cross builds. The `cdylib` crate type is only relevant when building wasms, so this change just lowers that functionality into the specific commands that build wasms. --------- Co-authored-by: Leigh McCulloch <351529+leighmcculloch@users.noreply.github.com> --- .github/workflows/rust.yml | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index 8ddf21672..b4ba32451 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -61,10 +61,14 @@ jobs: sys: - os: ubuntu-latest target: x86_64-unknown-linux-gnu - # TODO: Figure out why builds are broken for linux arm64 and reenable. - # https://github.com/stellar/rs-soroban-sdk/issues/1011 - # - os: ubuntu-latest - # target: aarch64-unknown-linux-gnu + - os: ubuntu-latest + target: aarch64-unknown-linux-gnu + # Fix #1011 by avoiding the use of crate-type = ["cdylib"] in native + # builds that cross-compile. It causes linker errors. The root cause + # is rust-lang/cargo#4133. This workaround uses rustc to build for a + # specific crate-type, lib, such that the Cargo.toml crate-type is + # ignored. + cdylib-cross-compile-workaround: true - os: macos-latest target: x86_64-apple-darwin - os: macos-latest @@ -85,7 +89,10 @@ jobs: name: cargo-hack version: 0.5.16 - run: cargo-hack hack build --target wasm32-unknown-unknown --profile release - - run: cargo-hack hack --feature-powerset --exclude-features docs build --target ${{ matrix.sys.target }} + - if: "!matrix.sys.cdylib-cross-compile-workaround" + run: cargo-hack hack --feature-powerset --exclude-features docs build --target ${{ matrix.sys.target }} + - if: "matrix.sys.cdylib-cross-compile-workaround" + run: cargo-hack hack --feature-powerset --exclude-features docs rustc --workspace --exclude soroban-sdk-macros --crate-type lib --target ${{ matrix.sys.target }} - if: startsWith(matrix.sys.target, 'x86_64') run: cargo-hack hack --feature-powerset --ignore-unknown-features --features testutils --exclude-features docs test --target ${{ matrix.sys.target }}