Skip to content

Commit 2c2a65e

Browse files
Merge #1047
1047: Provide fallback for rustc version when envvars not present. r=Emilgardis a=Alexhuszagh Fixes an issue where `CROSS_RUSTC_MINOR_VERSION` is not present when using older versions of cross but newer images. This only uses the fallback if the minor version is not provided as an environment variable by cross itself. Co-authored-by: Alex Huszagh <[email protected]>
2 parents da60329 + 1ef58f0 commit 2c2a65e

9 files changed

+71
-4
lines changed

docker/Dockerfile.aarch64-unknown-linux-musl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ COPY musl-symlink.sh /
2121
RUN /musl-symlink.sh $CROSS_MUSL_SYSROOT aarch64
2222

2323
COPY aarch64-linux-musl-gcc.sh /usr/bin/
24+
COPY rustc_info.sh /
2425

2526
COPY qemu-runner base-runner.sh /
2627

docker/Dockerfile.armv5te-unknown-linux-musleabi

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ RUN /musl-symlink.sh $CROSS_MUSL_SYSROOT arm
2727
COPY qemu-runner base-runner.sh /
2828

2929
COPY arm-linux-musleabi-gcc.sh /usr/bin/
30+
COPY rustc_info.sh /
3031

3132
ENV CARGO_TARGET_ARMV5TE_UNKNOWN_LINUX_MUSLEABI_LINKER=arm-linux-musleabi-gcc.sh \
3233
CARGO_TARGET_ARMV5TE_UNKNOWN_LINUX_MUSLEABI_RUNNER="/qemu-runner arm" \

docker/Dockerfile.mips64-unknown-linux-muslabi64

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ RUN ln -s $CROSS_MUSL_SYSROOT/usr/lib/libc.so $CROSS_MUSL_SYSROOT/usr/lib64/libc
2828
RUN ln -s $CROSS_MUSL_SYSROOT/usr/lib/libc.so.1 $CROSS_MUSL_SYSROOT/usr/lib64/libc.so.1
2929

3030
COPY mips64-linux-musl-gcc.sh /usr/bin/
31+
COPY rustc_info.sh /
3132

3233
COPY qemu-runner base-runner.sh /
3334

docker/Dockerfile.mips64el-unknown-linux-muslabi64

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ RUN ln -s $CROSS_MUSL_SYSROOT/usr/lib/libc.so $CROSS_MUSL_SYSROOT/usr/lib64/libc
2828
RUN ln -s $CROSS_MUSL_SYSROOT/usr/lib/libc.so.1 $CROSS_MUSL_SYSROOT/usr/lib64/libc.so.1
2929

3030
COPY mips64el-linux-musl-gcc.sh /usr/bin/
31+
COPY rustc_info.sh /
3132

3233
COPY qemu-runner base-runner.sh /
3334

docker/aarch64-linux-musl-gcc.sh

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,14 @@
77
set -x
88
set -euo pipefail
99

10+
# shellcheck disable=SC1091
11+
. /rustc_info.sh
12+
1013
main() {
11-
if (( CROSS_RUSTC_MINOR_VERSION >= 48 )) || [[ $# -eq 0 ]]; then
14+
local minor
15+
minor=$(rustc_minor_version)
16+
17+
if (( minor >= 48 )) || [[ $# -eq 0 ]]; then
1218
# no workaround
1319
exec aarch64-linux-musl-gcc "${@}"
1420
else

docker/arm-linux-musleabi-gcc.sh

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,14 @@
99
set -x
1010
set -euo pipefail
1111

12+
# shellcheck disable=SC1091
13+
. /rustc_info.sh
14+
1215
main() {
13-
if (( CROSS_RUSTC_MINOR_VERSION >= 65 )) || [[ $# -eq 0 ]]; then
16+
local minor
17+
minor=$(rustc_minor_version)
18+
19+
if (( minor >= 65 )) || [[ $# -eq 0 ]]; then
1420
exec arm-linux-musleabi-gcc "${@}"
1521
else
1622
exec arm-linux-musleabi-gcc "${@}" -lgcc -static-libgcc

docker/mips64-linux-musl-gcc.sh

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,14 @@
99
set -x
1010
set -euo pipefail
1111

12+
# shellcheck disable=SC1091
13+
. /rustc_info.sh
14+
1215
main() {
13-
if (( CROSS_RUSTC_MINOR_VERSION >= 65 )) || [[ $# -eq 0 ]]; then
16+
local minor
17+
minor=$(rustc_minor_version)
18+
19+
if (( minor >= 65 )) || [[ $# -eq 0 ]]; then
1420
exec mips64-linux-musl-gcc "${@}"
1521
else
1622
exec mips64-linux-musl-gcc "${@}" -lgcc -static-libgcc

docker/mips64el-linux-musl-gcc.sh

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,14 @@
99
set -x
1010
set -euo pipefail
1111

12+
# shellcheck disable=SC1091
13+
. /rustc_info.sh
14+
1215
main() {
13-
if (( CROSS_RUSTC_MINOR_VERSION >= 65 )) || [[ $# -eq 0 ]]; then
16+
local minor
17+
minor=$(rustc_minor_version)
18+
19+
if (( minor >= 65 )) || [[ $# -eq 0 ]]; then
1420
exec mips64el-linux-musl-gcc "${@}"
1521
else
1622
exec mips64el-linux-musl-gcc "${@}" -lgcc -static-libgcc

docker/rustc_info.sh

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
#!/usr/bin/env bash
2+
# FIXME: remove this file further on, especially after
3+
# 0.2.5 has been released and we've had a weeks of
4+
# releases on main so people can update images.
5+
# people may use newer versions of cross with older
6+
# images for backwards compatibility, but we don't
7+
# need to guarantee newer images work with older cross
8+
# versions.
9+
# https://github.com/cross-rs/cross/issues/1046
10+
11+
# NOTE: this will fail if rustc does not provide version
12+
# info, which may happen with a custom toolchain.
13+
rustc_version() {
14+
rustc -Vv | grep '^release:' | cut -d ':' -f2
15+
}
16+
17+
rustc_major_version() {
18+
if [[ -z "${CROSS_RUSTC_MAJOR_VERSION:-}" ]]; then
19+
CROSS_RUSTC_MAJOR_VERSION=$(rustc_version | cut -d '.' -f1)
20+
export CROSS_RUSTC_MAJOR_VERSION
21+
fi
22+
echo "${CROSS_RUSTC_MAJOR_VERSION}"
23+
}
24+
25+
rustc_minor_version() {
26+
if [[ -z "${CROSS_RUSTC_MINOR_VERSION:-}" ]]; then
27+
CROSS_RUSTC_MINOR_VERSION=$(rustc_version | cut -d '.' -f2)
28+
export CROSS_RUSTC_MINOR_VERSION
29+
fi
30+
echo "${CROSS_RUSTC_MINOR_VERSION}"
31+
}
32+
33+
rustc_patch_version() {
34+
if [[ -z "${CROSS_RUSTC_PATCH_VERSION:-}" ]]; then
35+
CROSS_RUSTC_PATCH_VERSION=$(rustc_version | cut -d '.' -f3)
36+
export CROSS_RUSTC_PATCH_VERSION
37+
fi
38+
echo "${CROSS_RUSTC_PATCH_VERSION}"
39+
}

0 commit comments

Comments
 (0)