From 305aca86f9d8d132650b495f610f9abe5239fec6 Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Tue, 21 Feb 2017 14:18:50 -0800 Subject: [PATCH 1/2] travis: Compile a more compatible libc.a for musl The mitigations for #34978 involve passing `-Wa,-mrelax-relocations=no` to all C code we compile, and we just forgot to pass it when compiling musl itself. Closes #39979 --- src/ci/docker/linux-tested-targets/build-musl.sh | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/ci/docker/linux-tested-targets/build-musl.sh b/src/ci/docker/linux-tested-targets/build-musl.sh index 260dc11509f47..ce62c392241d8 100644 --- a/src/ci/docker/linux-tested-targets/build-musl.sh +++ b/src/ci/docker/linux-tested-targets/build-musl.sh @@ -11,7 +11,10 @@ set -ex -export CFLAGS="-fPIC" +# We need to mitigate rust-lang/rust#34978 when compiling musl itself as well +export CFLAGS="-fPIC -Wa,-mrelax-relocations=no" +export CXXFLAGS="-Wa,-mrelax-relocations=no" + MUSL=musl-1.1.14 curl https://www.musl-libc.org/releases/$MUSL.tar.gz | tar xzf - cd $MUSL From 9a08f40349c3c3182845b31b1d7a26b7af5245a3 Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Tue, 21 Feb 2017 14:22:10 -0800 Subject: [PATCH 2/2] travis: Move -mrelax-relocations to Docker config This doesn't belong in rustbuild itself, and now that we have only rustbuild we can move this out of the build system. --- src/bootstrap/lib.rs | 11 ----------- src/ci/docker/linux-tested-targets/Dockerfile | 8 ++++++++ 2 files changed, 8 insertions(+), 11 deletions(-) diff --git a/src/bootstrap/lib.rs b/src/bootstrap/lib.rs index 7bd611eb53e3c..b9c8e08de11db 100644 --- a/src/bootstrap/lib.rs +++ b/src/bootstrap/lib.rs @@ -828,17 +828,6 @@ impl Build { if target.contains("apple-darwin") { base.push("-stdlib=libc++".into()); } - // This is a hack, because newer binutils broke things on some vms/distros - // (i.e., linking against unknown relocs disabled by the following flag) - // See: https://github.com/rust-lang/rust/issues/34978 - match target { - "i586-unknown-linux-gnu" | - "i686-unknown-linux-musl" | - "x86_64-unknown-linux-musl" => { - base.push("-Wa,-mrelax-relocations=no".into()); - }, - _ => {}, - } return base } diff --git a/src/ci/docker/linux-tested-targets/Dockerfile b/src/ci/docker/linux-tested-targets/Dockerfile index feb73bebbdbec..c47e5a9f43c92 100644 --- a/src/ci/docker/linux-tested-targets/Dockerfile +++ b/src/ci/docker/linux-tested-targets/Dockerfile @@ -34,6 +34,14 @@ ENV RUST_CONFIGURE_ARGS \ --musl-root-x86_64=/musl-x86_64 \ --musl-root-i686=/musl-i686 +# Newer binutils broke things on some vms/distros (i.e., linking against +# unknown relocs disabled by the following flag), so we need to go out of our +# way to produce "super compatible" binaries. +# +# See: https://github.com/rust-lang/rust/issues/34978 +ENV CFLAGS_i686_unknown_linux_gnu=-Wa,-mrelax-relocations=no \ + CFLAGS_x86_64_unknown_linux_gnu=-Wa,-mrelax-relocations=no + ENV SCRIPT \ python2.7 ../x.py test \ --target x86_64-unknown-linux-musl \