From 9e5ff25be8ff5e2aa581faee804770dca0f29e0d Mon Sep 17 00:00:00 2001 From: Jiahao XU Date: Sun, 31 Jul 2022 13:12:27 +1000 Subject: [PATCH] Fix release build: Set `RUSTFLAGS` to link with libgcc statically Signed-off-by: Jiahao XU --- .github/workflows/build.yml | 2 ++ ci-scripts/compile-settings.jq | 8 ++++++++ 2 files changed, 10 insertions(+) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 57d04169..93a7af04 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -110,6 +110,8 @@ jobs: - name: Build run: ${{ env.CTOOL }} build ${{ env.CARGS }} + env: + RUSTFLAGS: ${{ env.RUSTFLAGS }} - name: Get output shell: bash diff --git a/ci-scripts/compile-settings.jq b/ci-scripts/compile-settings.jq index ae905cf0..72f45153 100644 --- a/ci-scripts/compile-settings.jq +++ b/ci-scripts/compile-settings.jq @@ -9,9 +9,16 @@ if $for_release then { output: "debug", profile: "dev", args: ($matrix.debug_build_args // ""), + rustflags: "", features: ($matrix.debug_features // ["rustls", "fancy-with-backtrace"]), } end | +.rustflags = ( + if $for_release and $matrix.target == "aarch64-unknown-linux-musl" or $matrix.target == "armv7-unknown-linux-musleabihf" + then "-C link-arg=-lgcc -Clink-arg=-static-libgcc" + else "" end +) +| .features = ( if (.features | length > 0) then "--no-default-features --features \(.features | join(","))" @@ -23,6 +30,7 @@ if $for_release then { CTOOL: (if ($matrix."use-cross" // false) then "cross" else "cargo" end), COUTPUT: .output, CARGS: "--target \($matrix.target) --profile \(.profile) \(.features) \(.args)", + RUSTFLAGS: .rustflags, } | to_entries[] | "\(.key)=\(.value)"