Skip to content

Commit

Permalink
Merge #497 #500
Browse files Browse the repository at this point in the history
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 )

500: use runner setting specified in Cross.toml r=reitermarkus a=japaric

fixes #499 

Co-authored-by: Jorge Aparicio <jorge.aparicio@ferrous-systems.com>
  • Loading branch information
bors[bot] and japaric committed Dec 12, 2020
3 parents d84e4f4 + cfa30b8 + 35ec4e1 commit 46d253d
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 4 deletions.
5 changes: 2 additions & 3 deletions docker/Dockerfile.aarch64-unknown-linux-musl
Original file line number Diff line number Diff line change
Expand Up @@ -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++ \
Expand Down
25 changes: 25 additions & 0 deletions docker/aarch64-linux-musl-gcc.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#!/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=
release=$(rustc -Vv | grep '^release:' | cut -d ':' -f2)
# NOTE we assume `major` is always "1"
local minor=
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 "${@}"
4 changes: 3 additions & 1 deletion src/docker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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")?;

Expand Down Expand Up @@ -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"]);
Expand Down

0 comments on commit 46d253d

Please sign in to comment.