From fce27c76eb9c180a7eef37c584badb1cc81da476 Mon Sep 17 00:00:00 2001 From: "C.Lee Taylor" <47312074+leet4tari@users.noreply.github.com> Date: Thu, 4 Jul 2024 14:21:30 +0200 Subject: [PATCH] ci(fix): resolve x86 linux build (#10) Description Resolve x86 linux builds Add cross-compile options that mostly work - need to resolve arm64 cross-compile from x86 Motivation and Context Provide runtime assets How Has This Been Tested? Builds locally and in local fork What process can a PR reviewer use to test or verify this change? --- Breaking Changes --- - [x] None - [ ] Requires data directory on base node to be deleted - [ ] Requires hard fork - [ ] Other - Please specify --- .cargo/audit.toml | 9 ++++++ .cargo/config.toml | 8 ++++- .github/workflows/build_binaries.json | 3 +- .github/workflows/build_binaries.yml | 20 +++++------- Cross.toml | 45 ++++++++++++++++++++++++--- rust-toolchain.toml | 2 ++ 6 files changed, 67 insertions(+), 20 deletions(-) create mode 100644 .cargo/audit.toml create mode 100644 rust-toolchain.toml diff --git a/.cargo/audit.toml b/.cargo/audit.toml new file mode 100644 index 00000000..c186ffc7 --- /dev/null +++ b/.cargo/audit.toml @@ -0,0 +1,9 @@ +[advisories] +ignore = [ + + # We are not using a special allocator and will not suffer this issue + "RUSTSEC-2021-0145", + # We are not using RSA + "RUSTSEC-2023-0071" + +] \ No newline at end of file diff --git a/.cargo/config.toml b/.cargo/config.toml index 4a90b60a..2bae7a23 100644 --- a/.cargo/config.toml +++ b/.cargo/config.toml @@ -1,3 +1,9 @@ +[target.aarch64-unknown-linux-gnu] +linker = "aarch64-linux-gnu-gcc" + +[target.riscv64gc-unknown-linux-gnu] +linker = "riscv64-linux-gnu-gcc" + [alias] ci-fmt = "fmt --all -- --check" ci-fmt-fix = "fmt --all" @@ -5,4 +11,4 @@ ci-clippy = "lints clippy --all-targets --all-features" ci-test-compile = "test --no-run --workspace --all-features --no-default-features" ci-test = "nextest run --all-features --release --workspace --exclude integration_tests --profile ci" ci-cucumber = "test --all-features --release --package integration_tests" -ci-check = "check --workspace --release --all-features --all-targets --locked" \ No newline at end of file +ci-check = "check --workspace --release --all-features --all-targets --locked" diff --git a/.github/workflows/build_binaries.json b/.github/workflows/build_binaries.json index 9bf9a4a1..57d916b0 100644 --- a/.github/workflows/build_binaries.json +++ b/.github/workflows/build_binaries.json @@ -44,8 +44,7 @@ "runs-on": "windows-2019", "rust": "stable", "target": "x86_64-pc-windows-msvc", - "cross": false, - "features": "safe" + "cross": false }, { "name": "windows-arm64", diff --git a/.github/workflows/build_binaries.yml b/.github/workflows/build_binaries.yml index 1cff433d..f068ca21 100644 --- a/.github/workflows/build_binaries.yml +++ b/.github/workflows/build_binaries.yml @@ -23,7 +23,6 @@ env: TS_SIG_FN: "sha256-unsigned.txt" ## Must be a JSon string TS_FILES: '["sha_p2pool"]' - TS_FEATURES: "default" toolchain: nightly-2024-03-01 matrix-json-file: ".github/workflows/build_binaries.json" CARGO_HTTP_MULTIPLEXING: false @@ -116,11 +115,6 @@ jobs: "$GITHUB_WORKSPACE/Cargo.toml") echo "TARI_VERSION=${TARI_VERSION}" >> $GITHUB_ENV echo "TARI_VERSION=${TARI_VERSION}" >> $GITHUB_OUTPUT - if [[ "${{ matrix.builds.features }}" == "" ]]; then - echo "BUILD_FEATURES=${{ env.TS_FEATURES }}" >> $GITHUB_ENV - else - echo "BUILD_FEATURES=${{ matrix.builds.features }}" >> $GITHUB_ENV - fi TARGET_BINS="" if [[ "${{ matrix.builds.target_bins }}" == "" ]]; then ARRAY_BINS=( $(echo ${TS_FILES} | jq --raw-output '.[]' | awk '{ print $1 }') ) @@ -275,7 +269,6 @@ jobs: run: | ${{ env.CARGO }} build ${{ env.CARGO_OPTIONS }} \ --target ${{ matrix.builds.target }} \ - --features "${{ env.BUILD_FEATURES }}" \ ${{ env.TARGET_BINS }} \ ${{ matrix.builds.flags }} --locked @@ -316,7 +309,6 @@ jobs: ls -alhtR ${{ env.MTS_SOURCE }} - name: Pre/unsigned OSX Artifact upload for Archive - # Debug if: ${{ false }} # if: startsWith(runner.os,'macOS') continue-on-error: true @@ -326,7 +318,8 @@ jobs: path: "${{ env.MTS_SOURCE }}/*" - name: Build the macOS pkg - if: startsWith(runner.os,'macOS') + if: ${{ false }} + # if: startsWith(runner.os,'macOS') continue-on-error: true env: MACOS_KEYCHAIN_PASS: ${{ secrets.MACOS_KEYCHAIN_PASS }} @@ -422,7 +415,8 @@ jobs: ${SHARUN} --check "${{ env.TS_FILENAME }}-${{ matrix.builds.name }}-${{ env.TARI_VERSION }}.pkg.sha256" - name: Artifact upload for macOS pkg - if: startsWith(runner.os,'macOS') + if: ${{ false }} + # if: startsWith(runner.os,'macOS') continue-on-error: true uses: actions/upload-artifact@v4 with: @@ -430,7 +424,8 @@ jobs: path: "${{ env.distDirPKG }}/${{ env.TS_FILENAME }}-${{ matrix.builds.name }}-${{ env.TARI_VERSION }}*.pkg*" - name: Build the Windows installer - if: startsWith(runner.os,'Windows') + if: ${{ false }} + # if: startsWith(runner.os,'Windows') continue-on-error: true shell: cmd run: | @@ -445,7 +440,8 @@ jobs: ${{ env.SHARUN }} --check "${{ env.TS_FILENAME }}-${{ env.TARI_VERSION }}-${{ env.VSHA_SHORT }}-${{ matrix.builds.name }}-installer.exe.sha256" - name: Artifact upload for Windows installer - if: startsWith(runner.os,'Windows') + if: ${{ false }} + # if: startsWith(runner.os,'Windows') continue-on-error: true uses: actions/upload-artifact@v4 with: diff --git a/Cross.toml b/Cross.toml index 029accd1..4ac14306 100644 --- a/Cross.toml +++ b/Cross.toml @@ -1,6 +1,41 @@ +[build.env] +passthrough = [ + "CFLAGS", + "TARGET", + "RUST_TARGET", + "BUILD_TARGET", + "CARGO_BUILD_TARGET", + "TARGET_CFLAGS", + "CC_aarch64_unknown_linux_gnu", + "PKG_CONFIG_SYSROOT_DIR", + "PKG_CONFIG_ALLOW_CROSS", + "RUSTFLAGS", + "RUST_BACKTRACE", + "RUST_DEBUG", + "RUST_LOG", + "ARCH", + "FEATURES", + "ROARING_ARCH", + "TARI_NETWORK", + "TARI_TARGET_NETWORK", + "TARI_NETWORK_DIR", +] + +# Currently needs cross-rs from git +# ```cargo install cross --git https://github.com/cross-rs/cross``` +[target.aarch64-unknown-linux-gnu] +image.name = "ubuntu:18.04" +# targetting is needed for apple silicon +image.toolchain = ["linux/arm64=aarch64-unknown-linux-gnu", "linux/amd64=x86_64-unknown-linux-gnu"] +pre-build = "./scripts/cross_compile_ubuntu_18-pre-build.sh" + +[target.aarch64-unknown-linux-gnu.env] +passthrough = [ + "CC_aarch64_unknown_linux_gnu=aarch64-linux-gnu-gcc", + "PKG_CONFIG_SYSROOT_DIR=/usr/lib/aarch64-linux-gnu/", + "PKG_CONFIG_ALLOW_CROSS=true", +] + [target.x86_64-unknown-linux-gnu] -pre-build = [ - "dpkg --add-architecture $CROSS_DEB_ARCH", - "apt-get update", - "apt-get install --no-install-recommends --assume-yes apt-transport-https ca-certificates curl gpg bash less openssl libssl-dev pkg-config libsqlite3-dev:$CROSS_DEB_ARCH libsqlite3-0:$CROSS_DEB_ARCH libreadline-dev git cmake dh-autoreconf clang g++ libc++-dev libc++abi-dev libprotobuf-dev protobuf-compiler:$CROSS_DEB_ARCH libncurses5-dev libncursesw5-dev libudev-dev libhidapi-dev zip" -] \ No newline at end of file +image = "ubuntu:18.04" +pre-build = "./scripts/cross_compile_ubuntu_18-pre-build.sh" diff --git a/rust-toolchain.toml b/rust-toolchain.toml new file mode 100644 index 00000000..292fe499 --- /dev/null +++ b/rust-toolchain.toml @@ -0,0 +1,2 @@ +[toolchain] +channel = "stable"