Skip to content

Commit

Permalink
don't depend on binfmt_misc when using a recent toolchain
Browse files Browse the repository at this point in the history
  • Loading branch information
japaric committed Sep 21, 2017
1 parent ee02b3d commit f0a50dc
Show file tree
Hide file tree
Showing 18 changed files with 53 additions and 23 deletions.
16 changes: 5 additions & 11 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
1 change: 1 addition & 0 deletions docker/aarch64-unknown-linux-gnu/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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 \
Expand Down
1 change: 1 addition & 0 deletions docker/arm-unknown-linux-gnueabi/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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 \
Expand Down
1 change: 1 addition & 0 deletions docker/arm-unknown-linux-musleabi/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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
1 change: 1 addition & 0 deletions docker/armv7-unknown-linux-gnueabihf/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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 \
Expand Down
1 change: 1 addition & 0 deletions docker/armv7-unknown-linux-musleabihf/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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
1 change: 1 addition & 0 deletions docker/mips-unknown-linux-gnu/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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 \
Expand Down
1 change: 1 addition & 0 deletions docker/mips64-unknown-linux-gnuabi64/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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 \
Expand Down
1 change: 1 addition & 0 deletions docker/mips64el-unknown-linux-gnuabi64/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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 \
Expand Down
1 change: 1 addition & 0 deletions docker/mipsel-unknown-linux-gnu/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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 \
Expand Down
1 change: 1 addition & 0 deletions docker/powerpc-unknown-linux-gnu/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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 \
Expand Down
1 change: 1 addition & 0 deletions docker/powerpc64-unknown-linux-gnu/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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 \
Expand Down
1 change: 1 addition & 0 deletions docker/powerpc64le-unknown-linux-gnu/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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 \
Expand Down
1 change: 1 addition & 0 deletions docker/s390x-unknown-linux-gnu/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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 \
Expand Down
1 change: 1 addition & 0 deletions docker/sparc64-unknown-linux-gnu/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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 \
Expand Down
14 changes: 8 additions & 6 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)]
Expand Down Expand Up @@ -393,8 +393,9 @@ fn run() -> Result<ExitStatus> {
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
Expand All @@ -418,10 +419,11 @@ fn run() -> Result<ExitStatus> {

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,
Expand Down
30 changes: 25 additions & 5 deletions src/rustc.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use std::path::PathBuf;
use std::process::Command;

use rustc_version;
use rustc_version::{Version, VersionMeta};

use Host;
use errors::*;
Expand All @@ -17,21 +17,41 @@ 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<TargetList> {
Command::new("rustc")
.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<PathBuf> {
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') {
Expand Down

0 comments on commit f0a50dc

Please sign in to comment.