Skip to content

Commit beb434b

Browse files
bors[bot]japaric
andauthored
Merge #497
497: don't set RUSTFLAGS in aarch64-musl image r=reitermarkus a=japaric instead use a linker wrapper to work around issue rust-lang/rust#46651 not setting RUSTFLAGS inside the container lets end users pass rustc flags via `.cargo/config` this is an alternative to #464 that doesn't require bumping the MSRV of the `aarch64-unknown-linux-musl` target (that is the aarch64-musl image will continue to work with Rust 1.42 where bug rust-lang/rust#46651 is still presen ) Co-authored-by: Jorge Aparicio <[email protected]>
2 parents d84e4f4 + cfa30b8 commit beb434b

File tree

2 files changed

+27
-3
lines changed

2 files changed

+27
-3
lines changed

docker/Dockerfile.aarch64-unknown-linux-musl

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,9 @@ RUN ln -sf \
2121
/usr/local/aarch64-linux-musl/lib/ld-musl-aarch64.so.1
2222
ENV QEMU_LD_PREFIX=/usr/local/aarch64-linux-musl
2323

24-
# Workaround for https://github.com/rust-lang/rust/issues/46651
25-
ENV RUSTFLAGS="-C link-arg=-lgcc"
24+
COPY aarch64-linux-musl-gcc.sh /usr/bin/
2625

27-
ENV CARGO_TARGET_AARCH64_UNKNOWN_LINUX_MUSL_LINKER=aarch64-linux-musl-gcc \
26+
ENV CARGO_TARGET_AARCH64_UNKNOWN_LINUX_MUSL_LINKER=aarch64-linux-musl-gcc.sh \
2827
CARGO_TARGET_AARCH64_UNKNOWN_LINUX_MUSL_RUNNER=qemu-aarch64 \
2928
CC_aarch64_unknown_linux_musl=aarch64-linux-musl-gcc \
3029
CXX_aarch64_unknown_linux_musl=aarch64-linux-musl-g++ \

docker/aarch64-linux-musl-gcc.sh

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
#!/bin/bash
2+
3+
# this linker wrapper works around issue https://github.com/rust-lang/rust/issues/46651
4+
# which affects toolchains older than 1.48
5+
# older toolchains require the `-lgcc` linker flag otherwise they fail to link
6+
7+
set -euo pipefail
8+
9+
main() {
10+
local release=
11+
release=$(rustc -Vv | grep '^release:' | cut -d ':' -f2)
12+
# NOTE we assume `major` is always "1"
13+
local minor=
14+
minor=$(echo "$release" | cut -d '.' -f2)
15+
16+
if (( minor >= 48 )); then
17+
# no workaround
18+
aarch64-linux-musl-gcc "${@}"
19+
else
20+
# apply workaround
21+
aarch64-linux-musl-gcc "${@}" -lgcc
22+
fi
23+
}
24+
25+
main "${@}"

0 commit comments

Comments
 (0)