Skip to content

Commit 352c3c7

Browse files
authored
Refactor release builds, add aarch64-musl (bytecodealliance#9885)
* Refactor release builds, add aarch64-musl This commit refactors the way release builds are done in CI in terms of configuration and then additionally adds aarch64-musl release artifacts as requested in bytecodealliance#9875. The refactoring here is done to reduce the number of locations to understand release builds. Notably the `binary-compatible-builds` action was removed in favor of direct environment configuration in conjunction with docker images used to build. The `aarch64-musl` build itself happens in a container provided by the `cross` project to ensure that the right toolchain is configured. Closes bytecodealliance#9875 prtest:full * Link musl dynamically
1 parent d477d45 commit 352c3c7

File tree

7 files changed

+49
-104
lines changed

7 files changed

+49
-104
lines changed

.github/actions/binary-compatible-builds/README.md

Lines changed: 0 additions & 9 deletions
This file was deleted.

.github/actions/binary-compatible-builds/action.yml

Lines changed: 0 additions & 10 deletions
This file was deleted.

.github/actions/binary-compatible-builds/main.js

Lines changed: 0 additions & 81 deletions
This file was deleted.

.github/workflows/main.yml

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1072,6 +1072,7 @@ jobs:
10721072
strategy:
10731073
fail-fast: ${{ github.event_name != 'pull_request' }}
10741074
matrix: ${{ fromJson(needs.determine.outputs.build-matrix) }}
1075+
env: ${{ matrix.env || fromJSON('{}') }}
10751076
steps:
10761077
- uses: actions/checkout@v4
10771078
with:
@@ -1089,16 +1090,13 @@ jobs:
10891090
# it everywhere
10901091
- run: ./ci/build-src-tarball.sh
10911092
if: matrix.build == 'x86_64-linux'
1092-
- uses: ./.github/actions/binary-compatible-builds
1093-
with:
1094-
name: ${{ matrix.build }}
10951093

10961094
- uses: ./.github/actions/android-ndk
10971095
if: contains(matrix.target, 'android')
10981096
with:
10991097
target: ${{ matrix.target }}
11001098

1101-
- run: $CENTOS ./ci/build-release-artifacts.sh "${{ matrix.build }}" "${{ matrix.target }}"
1099+
- run: ./ci/build-release-artifacts.sh "${{ matrix.build }}" "${{ matrix.target }}"
11021100

11031101
# Assemble release artifacts appropriate for this platform, then upload them
11041102
# unconditionally to this workflow's files so we have a copy of them.

ci/build-build-matrix.js

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,41 +17,52 @@ const array = [
1717
"os": ubuntu,
1818
// The Rust target that will be used for the build.
1919
"target": "x86_64-unknown-linux-gnu",
20+
"env": { "DOCKER_IMAGE": "./ci/docker/x86_64-linux/Dockerfile" },
2021
},
2122
{
2223
"build": "aarch64-linux",
2324
"os": ubuntu,
2425
"target": "aarch64-unknown-linux-gnu",
26+
"env": { "DOCKER_IMAGE": "./ci/docker/aarch64-linux/Dockerfile" },
2527
},
2628
{
2729
"build": "s390x-linux",
2830
"os": ubuntu,
2931
"target": "s390x-unknown-linux-gnu",
32+
"env": { "DOCKER_IMAGE": "./ci/docker/s390x-linux/Dockerfile" },
3033
},
3134
{
3235
"build": "riscv64gc-linux",
3336
"os": ubuntu,
3437
"target": "riscv64gc-unknown-linux-gnu",
38+
"env": { "DOCKER_IMAGE": "./ci/docker/riscv64gc-linux/Dockerfile" },
3539
},
3640
{
3741
"build": "x86_64-macos",
3842
"os": macos,
3943
"target": "x86_64-apple-darwin",
44+
// On OSX all we need to do is configure our deployment target as old as
45+
// possible. For now 10.9 is the limit.
46+
"env": { "MACOSX_DEPLOYMENT_TARGET": "10.9" },
4047
},
4148
{
4249
"build": "aarch64-macos",
4350
"os": macos,
4451
"target": "aarch64-apple-darwin",
52+
"env": { "MACOSX_DEPLOYMENT_TARGET": "10.9" },
4553
},
4654
{
4755
"build": "x86_64-windows",
4856
"os": windows,
4957
"target": "x86_64-pc-windows-msvc",
58+
// On Windows we build against the static CRT to reduce dll dependencies
59+
"env": { "RUSTFLAGS": "-Ctarget-feature=+crt-static" },
5060
},
5161
{
5262
"build": "x86_64-mingw",
5363
"os": windows,
5464
"target": "x86_64-pc-windows-gnu",
65+
"env": { "RUSTFLAGS": "-Ctarget-feature=+crt-static" },
5566
},
5667
{
5768
"build": "aarch64-android",
@@ -67,11 +78,19 @@ const array = [
6778
"build": "x86_64-musl",
6879
"os": ubuntu,
6980
"target": "x86_64-unknown-linux-musl",
81+
"env": { "DOCKER_IMAGE": "./ci/docker/x86_64-musl/Dockerfile" },
82+
},
83+
{
84+
"build": "aarch64-musl",
85+
"os": ubuntu,
86+
"target": "aarch64-unknown-linux-musl",
87+
"env": { "DOCKER_IMAGE": "./ci/docker/aarch64-musl/Dockerfile" },
7088
},
7189
{
7290
"build": "aarch64-windows",
7391
"os": windows,
7492
"target": "aarch64-pc-windows-msvc",
93+
"env": { "RUSTFLAGS": "-Ctarget-feature=+crt-static" },
7594
},
7695
];
7796

ci/build-release-artifacts.sh

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,29 @@ set -ex
1313

1414
build=$1
1515
target=$2
16+
wrapper=""
17+
18+
# If `$DOCKER_IMAGE` is set then run the build inside of that docker container
19+
# instead of on the host machine. In CI this uses `./ci/docker/*/Dockerfile` to
20+
# have precise glibc requirements for Linux platforms for example.
21+
if [ "$DOCKER_IMAGE" != "" ]; then
22+
if [ -f "$DOCKER_IMAGE" ]; then
23+
docker build --tag build-image --file $DOCKER_IMAGE ci/docker
24+
DOCKER_IMAGE=build-image
25+
fi
26+
27+
# Inherit the environment's rustc and env vars related to cargo/rust, and then
28+
# otherwise re-execute ourselves and we'll be missing `$DOCKER_IMAGE` in the
29+
# container so we'll continue below.
30+
exec docker run --interactive \
31+
--volume `pwd`:`pwd` \
32+
--volume `rustc --print sysroot`:/rust:ro \
33+
--workdir `pwd` \
34+
--interactive \
35+
--env-file <(env | grep 'CARGO\|RUST') \
36+
$DOCKER_IMAGE \
37+
bash -c "PATH=\$PATH:/rust/bin RUSTFLAGS=\"\$RUSTFLAGS \$EXTRA_RUSTFLAGS\" `pwd`/$0 $*"
38+
fi
1639

1740
# Default build flags for release artifacts. Leave debugging for
1841
# builds-from-source which have richer information anyway, and additionally the

ci/docker/aarch64-musl/Dockerfile

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
FROM ghcr.io/cross-rs/aarch64-unknown-linux-musl
2+
3+
RUN apt-get update -y && apt-get install -y ninja-build
4+
RUN git config --global --add safe.directory '*'
5+
ENV EXTRA_RUSTFLAGS=-Ctarget-feature=-crt-static

0 commit comments

Comments
 (0)