From 4660285984dff8549bb5589f8fa14e3df88bc5b2 Mon Sep 17 00:00:00 2001 From: Jorge Aparicio Date: Tue, 8 Dec 2020 17:51:08 +0100 Subject: [PATCH 1/3] don't set RUSTFLAGS in aarch64-musl image --- docker/Dockerfile.aarch64-unknown-linux-musl | 5 ++--- docker/aarch64-linux-musl-gcc.sh | 23 ++++++++++++++++++++ 2 files changed, 25 insertions(+), 3 deletions(-) create mode 100755 docker/aarch64-linux-musl-gcc.sh diff --git a/docker/Dockerfile.aarch64-unknown-linux-musl b/docker/Dockerfile.aarch64-unknown-linux-musl index 507de85d6..255471268 100644 --- a/docker/Dockerfile.aarch64-unknown-linux-musl +++ b/docker/Dockerfile.aarch64-unknown-linux-musl @@ -21,10 +21,9 @@ RUN ln -sf \ /usr/local/aarch64-linux-musl/lib/ld-musl-aarch64.so.1 ENV QEMU_LD_PREFIX=/usr/local/aarch64-linux-musl -# Workaround for https://github.com/rust-lang/rust/issues/46651 -ENV RUSTFLAGS="-C link-arg=-lgcc" +COPY aarch64-linux-musl-gcc.sh /usr/bin/ -ENV CARGO_TARGET_AARCH64_UNKNOWN_LINUX_MUSL_LINKER=aarch64-linux-musl-gcc \ +ENV CARGO_TARGET_AARCH64_UNKNOWN_LINUX_MUSL_LINKER=aarch64-linux-musl-gcc.sh \ CARGO_TARGET_AARCH64_UNKNOWN_LINUX_MUSL_RUNNER=qemu-aarch64 \ CC_aarch64_unknown_linux_musl=aarch64-linux-musl-gcc \ CXX_aarch64_unknown_linux_musl=aarch64-linux-musl-g++ \ diff --git a/docker/aarch64-linux-musl-gcc.sh b/docker/aarch64-linux-musl-gcc.sh new file mode 100755 index 000000000..635641ff8 --- /dev/null +++ b/docker/aarch64-linux-musl-gcc.sh @@ -0,0 +1,23 @@ +#!/bin/bash + +# this linker wrapper works around issue https://github.com/rust-lang/rust/issues/46651 +# which affects toolchains older than 1.48 +# older toolchains require the `-lgcc` linker flag otherwise they fail to link + +set -euo pipefail + +main() { + local release=$(rustc -Vv | grep '^release:' | cut -d ':' -f2) + # NOTE we assume `major` is always "1" + local minor=$(echo $release | cut -d '.' -f2) + + if (( $minor >= 48 )); then + # no workaround + aarch64-linux-musl-gcc "${@}" + else + # apply workaround + aarch64-linux-musl-gcc "${@}" -lgcc + fi +} + +main "${@}" From cfa30b8d7c72b388794c37caca129f5006e7b569 Mon Sep 17 00:00:00 2001 From: Jorge Aparicio Date: Tue, 8 Dec 2020 18:23:37 +0100 Subject: [PATCH 2/3] make shellcheck happy --- docker/aarch64-linux-musl-gcc.sh | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/docker/aarch64-linux-musl-gcc.sh b/docker/aarch64-linux-musl-gcc.sh index 635641ff8..6d0aa1e63 100755 --- a/docker/aarch64-linux-musl-gcc.sh +++ b/docker/aarch64-linux-musl-gcc.sh @@ -7,11 +7,13 @@ set -euo pipefail main() { - local release=$(rustc -Vv | grep '^release:' | cut -d ':' -f2) + local release= + release=$(rustc -Vv | grep '^release:' | cut -d ':' -f2) # NOTE we assume `major` is always "1" - local minor=$(echo $release | cut -d '.' -f2) + local minor= + minor=$(echo "$release" | cut -d '.' -f2) - if (( $minor >= 48 )); then + if (( minor >= 48 )); then # no workaround aarch64-linux-musl-gcc "${@}" else From 35ec4e157a4fa4250c3ccf5beab2b50d3ea13ee0 Mon Sep 17 00:00:00 2001 From: Jorge Aparicio Date: Fri, 11 Dec 2020 18:36:32 +0100 Subject: [PATCH 3/3] use runner setting specified in Cross.toml --- src/docker.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/docker.rs b/src/docker.rs index a07bd3c12..2b6412304 100644 --- a/src/docker.rs +++ b/src/docker.rs @@ -103,7 +103,7 @@ pub fn run(target: &Target, cmd.args(args); - let runner = None; + let mut runner = None; let mut docker = docker_command("run")?; @@ -140,6 +140,8 @@ pub fn run(target: &Target, docker.args(&["-e", &format!("{}={}", var, mount_path.display())]); } } + + runner = toml.runner(target)?; } docker.args(&["-e", "PKG_CONFIG_ALLOW_CROSS=1"]);