From f0a50dc9d3063596c10344b178e89a833734bb64 Mon Sep 17 00:00:00 2001 From: Jorge Aparicio Date: Thu, 21 Sep 2017 15:33:09 +0200 Subject: [PATCH] don't depend on binfmt_misc when using a recent toolchain --- Cargo.lock | 16 ++++------ Cargo.toml | 2 +- docker/aarch64-unknown-linux-gnu/Dockerfile | 1 + docker/arm-unknown-linux-gnueabi/Dockerfile | 1 + docker/arm-unknown-linux-musleabi/Dockerfile | 1 + .../armv7-unknown-linux-gnueabihf/Dockerfile | 1 + .../armv7-unknown-linux-musleabihf/Dockerfile | 1 + docker/mips-unknown-linux-gnu/Dockerfile | 1 + .../mips64-unknown-linux-gnuabi64/Dockerfile | 1 + .../Dockerfile | 1 + docker/mipsel-unknown-linux-gnu/Dockerfile | 1 + docker/powerpc-unknown-linux-gnu/Dockerfile | 1 + docker/powerpc64-unknown-linux-gnu/Dockerfile | 1 + .../powerpc64le-unknown-linux-gnu/Dockerfile | 1 + docker/s390x-unknown-linux-gnu/Dockerfile | 1 + docker/sparc64-unknown-linux-gnu/Dockerfile | 1 + src/main.rs | 14 +++++---- src/rustc.rs | 30 +++++++++++++++---- 18 files changed, 53 insertions(+), 23 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 7ecc6544a..9ff1a5df1 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1,11 +1,11 @@ [root] name = "cross" -version = "0.1.11" +version = "0.1.12-dev" dependencies = [ "error-chain 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.18 (registry+https://github.com/rust-lang/crates.io-index)", - "rustc_version 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", + "rustc_version 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", "semver 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)", "toml 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -91,17 +91,12 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "rustc_version" -version = "0.1.7" +version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "semver 0.1.20 (registry+https://github.com/rust-lang/crates.io-index)", + "semver 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)", ] -[[package]] -name = "semver" -version = "0.1.20" -source = "registry+https://github.com/rust-lang/crates.io-index" - [[package]] name = "semver" version = "0.6.0" @@ -145,8 +140,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum libc 0.2.18 (registry+https://github.com/rust-lang/crates.io-index)" = "a51822fc847e7a8101514d1d44e354ba2ffa7d4c194dcab48870740e327cac70" "checksum rustc-demangle 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "1430d286cadb237c17c885e25447c982c97113926bb579f4379c0eca8d9586dc" "checksum rustc-serialize 0.3.22 (registry+https://github.com/rust-lang/crates.io-index)" = "237546c689f20bb44980270c73c3b9edd0891c1be49cc1274406134a66d3957b" -"checksum rustc_version 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)" = "c5f5376ea5e30ce23c03eb77cbe4962b988deead10910c372b226388b594c084" -"checksum semver 0.1.20 (registry+https://github.com/rust-lang/crates.io-index)" = "d4f410fedcf71af0345d7607d246e7ad15faaadd49d240ee3b24e5dc21a820ac" +"checksum rustc_version 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "b9743a7670d88d5d52950408ecdb7c71d8986251ab604d4689dd2ca25c9bca69" "checksum semver 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)" = "7a3186ec9e65071a2095434b1f5bb24838d4e8e130f584c790f6033c79943537" "checksum semver-parser 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3" "checksum toml 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "736b60249cb25337bc196faa43ee12c705e426f3d55c214d73a4e7be06f92cb4" diff --git a/Cargo.toml b/Cargo.toml index 6cc36ec8f..599b72a89 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -13,6 +13,6 @@ version = "0.1.12-dev" error-chain = "0.7.1" lazy_static = "0.2" libc = "0.2.18" -rustc_version = "0.1.7" +rustc_version = "0.2.1" semver = "0.6.0" toml = "0.2.1" diff --git a/docker/aarch64-unknown-linux-gnu/Dockerfile b/docker/aarch64-unknown-linux-gnu/Dockerfile index 5d2f96466..66bddf7a8 100644 --- a/docker/aarch64-unknown-linux-gnu/Dockerfile +++ b/docker/aarch64-unknown-linux-gnu/Dockerfile @@ -20,6 +20,7 @@ RUN apt-get install -y --no-install-recommends \ bash /qemu.sh aarch64 ENV CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER=aarch64-linux-gnu-gcc \ + CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_RUNNER=qemu-aarch64 \ CC_aarch64_unknown_linux_gnu=aarch64-linux-gnu-gcc \ CXX_aarch64_unknown_linux_gnu=aarch64-linux-gnu-g++ \ OPENSSL_DIR=/openssl \ diff --git a/docker/arm-unknown-linux-gnueabi/Dockerfile b/docker/arm-unknown-linux-gnueabi/Dockerfile index 66886d420..158d801dd 100644 --- a/docker/arm-unknown-linux-gnueabi/Dockerfile +++ b/docker/arm-unknown-linux-gnueabi/Dockerfile @@ -20,6 +20,7 @@ RUN apt-get install -y --no-install-recommends \ bash /qemu.sh arm ENV CARGO_TARGET_ARM_UNKNOWN_LINUX_GNUEABI_LINKER=arm-linux-gnueabi-gcc \ + CARGO_TARGET_ARM_UNKNOWN_LINUX_GNUEABI_RUNNER=qemu-arm \ CC_arm_unknown_linux_gnueabi=arm-linux-gnueabi-gcc \ CXX_arm_unknown_linux_gnueabi=arm-linux-gnueabi-g++ \ OPENSSL_DIR=/openssl \ diff --git a/docker/arm-unknown-linux-musleabi/Dockerfile b/docker/arm-unknown-linux-musleabi/Dockerfile index c94547dd1..0a5315180 100644 --- a/docker/arm-unknown-linux-musleabi/Dockerfile +++ b/docker/arm-unknown-linux-musleabi/Dockerfile @@ -19,5 +19,6 @@ RUN apt-get install -y --no-install-recommends \ gcc-arm-linux-gnueabi ENV CARGO_TARGET_ARM_UNKNOWN_LINUX_MUSLEABI_LINKER=arm-linux-gnueabi-gcc \ + CARGO_TARGET_ARM_UNKNOWN_LINUX_MUSLEABI_RUNNER=qemu-arm \ CC_arm_unknown_linux_musleabi=arm-linux-gnueabi-gcc \ RUST_TEST_THREADS=1 diff --git a/docker/armv7-unknown-linux-gnueabihf/Dockerfile b/docker/armv7-unknown-linux-gnueabihf/Dockerfile index 272d37e72..873c7f677 100644 --- a/docker/armv7-unknown-linux-gnueabihf/Dockerfile +++ b/docker/armv7-unknown-linux-gnueabihf/Dockerfile @@ -24,6 +24,7 @@ RUN apt-get install -y --no-install-recommends \ bash /qemu.sh arm ENV CARGO_TARGET_ARMV7_UNKNOWN_LINUX_GNUEABIHF_LINKER=arm-linux-gnueabihf-gcc \ + CARGO_TARGET_ARMV7_UNKNOWN_LINUX_GNUEABIHF_RUNNER=qemu-arm \ CC_armv7_unknown_linux_gnueabihf=arm-linux-gnueabihf-gcc \ CXX_armv7_unknown_linux_gnueabihf=arm-linux-gnueabihf-g++ \ OPENSSL_DIR=/openssl \ diff --git a/docker/armv7-unknown-linux-musleabihf/Dockerfile b/docker/armv7-unknown-linux-musleabihf/Dockerfile index c08497b3a..944ed8c4f 100644 --- a/docker/armv7-unknown-linux-musleabihf/Dockerfile +++ b/docker/armv7-unknown-linux-musleabihf/Dockerfile @@ -19,5 +19,6 @@ RUN apt-get install -y --no-install-recommends \ gcc-arm-linux-gnueabihf ENV CARGO_TARGET_ARMV7_UNKNOWN_LINUX_MUSLEABIHF_LINKER=arm-linux-gnueabihf-gcc \ + CARGO_TARGET_ARMV7_UNKNOWN_LINUX_MUSLEABIHF_RUNNER=qemu-arm \ CC_armv7_unknown_linux_musleabihf=arm-linux-gnueabihf-gcc \ RUST_TEST_THREADS=1 diff --git a/docker/mips-unknown-linux-gnu/Dockerfile b/docker/mips-unknown-linux-gnu/Dockerfile index 1c9a6c037..cff70d41d 100644 --- a/docker/mips-unknown-linux-gnu/Dockerfile +++ b/docker/mips-unknown-linux-gnu/Dockerfile @@ -20,6 +20,7 @@ RUN apt-get install -y --no-install-recommends \ bash /qemu.sh mips ENV CARGO_TARGET_MIPS_UNKNOWN_LINUX_GNU_LINKER=mips-linux-gnu-gcc \ + CARGO_TARGET_MIPS_UNKNOWN_LINUX_GNU_RUNNER=qemu-mips \ CC_mips_unknown_linux_gnu=mips-linux-gnu-gcc \ CXX_mips_unknown_linux_gnu=mips-linux-gnu-g++ \ OPENSSL_DIR=/openssl \ diff --git a/docker/mips64-unknown-linux-gnuabi64/Dockerfile b/docker/mips64-unknown-linux-gnuabi64/Dockerfile index d46e3b2b7..8221ee035 100644 --- a/docker/mips64-unknown-linux-gnuabi64/Dockerfile +++ b/docker/mips64-unknown-linux-gnuabi64/Dockerfile @@ -20,6 +20,7 @@ RUN apt-get install -y --no-install-recommends \ bash /qemu.sh mips64 ENV CARGO_TARGET_MIPS64_UNKNOWN_LINUX_GNUABI64_LINKER=mips64-linux-gnuabi64-gcc \ + CARGO_TARGET_MIPS64_UNKNOWN_LINUX_GNUABI64_RUNNER=qemu-mips64 \ CC_mips64_unknown_linux_gnuabi64=mips64-linux-gnuabi64-gcc \ CXX_mips64_unknown_linux_gnuabi64=mips64-linux-gnuabi64-g++ \ OPENSSL_DIR=/openssl \ diff --git a/docker/mips64el-unknown-linux-gnuabi64/Dockerfile b/docker/mips64el-unknown-linux-gnuabi64/Dockerfile index 002b0e468..d54a04040 100644 --- a/docker/mips64el-unknown-linux-gnuabi64/Dockerfile +++ b/docker/mips64el-unknown-linux-gnuabi64/Dockerfile @@ -20,6 +20,7 @@ RUN apt-get install -y --no-install-recommends \ bash /qemu.sh mips64el ENV CARGO_TARGET_MIPS64EL_UNKNOWN_LINUX_GNUABI64_LINKER=mips64el-linux-gnuabi64-gcc \ + CARGO_TARGET_MIPS64EL_UNKNOWN_LINUX_GNUABI64_RUNNER=qemu-mips64el \ CC_mips64el_unknown_linux_gnuabi64=mips64el-linux-gnuabi64-gcc \ CXX_mips64el_unknown_linux_gnuabi64=mips64el-linux-gnuabi64-g++ \ OPENSSL_DIR=/openssl \ diff --git a/docker/mipsel-unknown-linux-gnu/Dockerfile b/docker/mipsel-unknown-linux-gnu/Dockerfile index d5c361b62..c941b9522 100644 --- a/docker/mipsel-unknown-linux-gnu/Dockerfile +++ b/docker/mipsel-unknown-linux-gnu/Dockerfile @@ -20,6 +20,7 @@ RUN apt-get install -y --no-install-recommends \ bash /qemu.sh mipsel ENV CARGO_TARGET_MIPSEL_UNKNOWN_LINUX_GNU_LINKER=mipsel-linux-gnu-gcc \ + CARGO_TARGET_MIPSEL_UNKNOWN_LINUX_GNU_RUNNER=qemu-mipsel \ CC_mipsel_unknown_linux_gnu=mipsel-linux-gnu-gcc \ CXX_mipsel_unknown_linux_gnu=mipsel-linux-gnu-g++ \ OPENSSL_DIR=/openssl \ diff --git a/docker/powerpc-unknown-linux-gnu/Dockerfile b/docker/powerpc-unknown-linux-gnu/Dockerfile index dca3373e7..00a16b06e 100644 --- a/docker/powerpc-unknown-linux-gnu/Dockerfile +++ b/docker/powerpc-unknown-linux-gnu/Dockerfile @@ -20,6 +20,7 @@ RUN apt-get install -y --no-install-recommends \ bash /qemu.sh ppc ENV CARGO_TARGET_POWERPC_UNKNOWN_LINUX_GNU_LINKER=powerpc-linux-gnu-gcc \ + CARGO_TARGET_POWERPC_UNKNOWN_LINUX_GNU_RUNNER=qemu-ppc \ CC_powerpc_unknown_linux_gnu=powerpc-linux-gnu-gcc \ CXX_powerpc_unknown_linux_gnu=powerpc-linux-gnu-g++ \ OPENSSL_DIR=/openssl \ diff --git a/docker/powerpc64-unknown-linux-gnu/Dockerfile b/docker/powerpc64-unknown-linux-gnu/Dockerfile index 987fe557f..7b858e02b 100644 --- a/docker/powerpc64-unknown-linux-gnu/Dockerfile +++ b/docker/powerpc64-unknown-linux-gnu/Dockerfile @@ -20,6 +20,7 @@ RUN apt-get install -y --no-install-recommends \ bash /qemu.sh ppc64 ENV CARGO_TARGET_POWERPC64_UNKNOWN_LINUX_GNU_LINKER=powerpc64-linux-gnu-gcc \ + CARGO_TARGET_POWERPC64_UNKNOWN_LINUX_GNU_RUNNER=qemu-ppc64 \ CC_powerpc64_unknown_linux_gnu=powerpc64-linux-gnu-gcc \ CXX_powerpc64_unknown_linux_gnu=powerpc64-linux-gnu-g++ \ OPENSSL_DIR=/openssl \ diff --git a/docker/powerpc64le-unknown-linux-gnu/Dockerfile b/docker/powerpc64le-unknown-linux-gnu/Dockerfile index fa6f88845..0531bd0aa 100644 --- a/docker/powerpc64le-unknown-linux-gnu/Dockerfile +++ b/docker/powerpc64le-unknown-linux-gnu/Dockerfile @@ -20,6 +20,7 @@ RUN apt-get install -y --no-install-recommends \ bash /qemu.sh ppc64le ENV CARGO_TARGET_POWERPC64LE_UNKNOWN_LINUX_GNU_LINKER=powerpc64le-linux-gnu-gcc \ + CARGO_TARGET_POWERPC64LE_UNKNOWN_LINUX_GNU_RUNNER=qemu-ppc64le \ CC_powerpc64le_unknown_linux_gnu=powerpc64le-linux-gnu-gcc \ CXX_powerpc64le_unknown_linux_gnu=powerpc64le-linux-gnu-g++ \ OPENSSL_DIR=/openssl \ diff --git a/docker/s390x-unknown-linux-gnu/Dockerfile b/docker/s390x-unknown-linux-gnu/Dockerfile index 05691f110..4ebd51e76 100644 --- a/docker/s390x-unknown-linux-gnu/Dockerfile +++ b/docker/s390x-unknown-linux-gnu/Dockerfile @@ -20,6 +20,7 @@ RUN apt-get install -y --no-install-recommends \ bash /qemu.sh s390x ENV CARGO_TARGET_S390X_UNKNOWN_LINUX_GNU_LINKER=s390x-linux-gnu-gcc \ + CARGO_TARGET_S390X_UNKNOWN_LINUX_GNU_RUNNER=qemu-s390x \ CC_s390x_unknown_linux_gnu=s390x-linux-gnu-gcc \ CXX_s390x_unknown_linux_gnu=s390x-linux-gnu-g++ \ OPENSSL_DIR=/openssl \ diff --git a/docker/sparc64-unknown-linux-gnu/Dockerfile b/docker/sparc64-unknown-linux-gnu/Dockerfile index 697ed56b5..7c49be012 100644 --- a/docker/sparc64-unknown-linux-gnu/Dockerfile +++ b/docker/sparc64-unknown-linux-gnu/Dockerfile @@ -20,6 +20,7 @@ RUN apt-get install -y --no-install-recommends \ bash /qemu.sh sparc64 ENV CARGO_TARGET_SPARC64_UNKNOWN_LINUX_GNU_LINKER=sparc64-linux-gnu-gcc \ + CARGO_TARGET_SPARC64_UNKNOWN_LINUX_GNU_LINKER=qemu-sparc64 \ CC_sparc64_unknown_linux_gnu=sparc64-linux-gnu-gcc \ CXX_sparc64_unknown_linux_gnu=sparc64-linux-gnu-g++ \ OPENSSL_DIR=/openssl \ diff --git a/src/main.rs b/src/main.rs index ce95cb2a5..12eccebc3 100644 --- a/src/main.rs +++ b/src/main.rs @@ -26,7 +26,7 @@ use toml::{Parser, Value}; use cargo::Root; use errors::*; -use rustc::TargetList; +use rustc::{TargetList, VersionMetaExt}; #[allow(non_camel_case_types)] #[derive(Clone, Copy, PartialEq)] @@ -393,8 +393,9 @@ fn run() -> Result { let verbose = args.all.iter().any(|a| a == "--verbose" || a == "-v" || a == "-vv"); + let version_meta = rustc_version::version_meta().chain_err(|| "couldn't fetch the `rustc` version")?; if let Some(root) = cargo::root()? { - let host = rustc::host(); + let host = version_meta.host(); if host.is_supported(args.target.as_ref()) { let target = args.target @@ -418,10 +419,11 @@ fn run() -> Result { if target.needs_docker() && args.subcommand.map(|sc| sc.needs_docker()).unwrap_or(false) { - if args.subcommand.map(|sc| sc.needs_interpreter()).unwrap_or(false) && - target.needs_interpreter() && - !interpreter::is_registered(&target)? { - docker::register(&target, verbose)? + if version_meta.needs_interpreter() && + args.subcommand.map(|sc| sc.needs_interpreter()).unwrap_or(false) && + target.needs_interpreter() && + !interpreter::is_registered(&target)? { + docker::register(&target, verbose)? } return docker::run(&target, diff --git a/src/rustc.rs b/src/rustc.rs index 66b46c26c..fcf30d820 100644 --- a/src/rustc.rs +++ b/src/rustc.rs @@ -1,7 +1,7 @@ use std::path::PathBuf; use std::process::Command; -use rustc_version; +use rustc_version::{Version, VersionMeta}; use Host; use errors::*; @@ -17,8 +17,25 @@ impl TargetList { } } -pub fn host() -> Host { - Host::from(&*rustc_version::version_meta().host) +pub trait VersionMetaExt { + fn host(&self) -> Host; + fn needs_interpreter(&self) -> bool; +} + +impl VersionMetaExt for VersionMeta { + fn host(&self) -> Host { + Host::from(&*self.host) + } + + fn needs_interpreter(&self) -> bool { + self.semver >= Version { + major: 1, + minor: 18, + patch: 0, + pre: vec![], + build: vec![], + } + } } pub fn target_list(verbose: bool) -> Result { @@ -26,12 +43,15 @@ pub fn target_list(verbose: bool) -> Result { .args(&["--print", "target-list"]) .run_and_get_stdout(verbose) .map(|s| { - TargetList { triples: s.lines().map(|l| l.to_owned()).collect() } + TargetList { + triples: s.lines().map(|l| l.to_owned()).collect(), + } }) } pub fn sysroot(verbose: bool) -> Result { - let mut stdout = Command::new("rustc").args(&["--print", "sysroot"]) + let mut stdout = Command::new("rustc") + .args(&["--print", "sysroot"]) .run_and_get_stdout(verbose)?; if stdout.ends_with('\n') {