From d0d4a8efe208af700e79cac7ba963ebfc3de14b1 Mon Sep 17 00:00:00 2001 From: Jorge Aparicio Date: Sun, 2 Apr 2017 23:06:11 -0500 Subject: [PATCH 01/35] switch back to a -dev version --- Cargo.lock | 2 +- Cargo.toml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index f8487b0f0..09ff3b789 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1,6 +1,6 @@ [root] name = "cross" -version = "0.1.10" +version = "0.1.11-dev" dependencies = [ "error-chain 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.18 (registry+https://github.com/rust-lang/crates.io-index)", diff --git a/Cargo.toml b/Cargo.toml index d2eaf41e4..e9692292e 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -7,7 +7,7 @@ keywords = ["cross", "compilation", "testing", "tool"] license = "MIT OR Apache-2.0" name = "cross" repository = "https://github.com/japaric/cross" -version = "0.1.10" +version = "0.1.11-dev" [dependencies] error-chain = "0.7.1" From 88eb7e94a9e8d1d1bae2c552f7b4d2f96a18c450 Mon Sep 17 00:00:00 2001 From: Marco A L Barbosa Date: Wed, 5 Apr 2017 10:58:35 -0300 Subject: [PATCH 02/35] Fix package remove --- docker/android-ndk.sh | 8 ++++---- docker/cmake.sh | 8 ++++---- docker/dragonfly.sh | 8 ++++---- docker/freebsd.sh | 8 ++++---- docker/musl.sh | 8 ++++---- docker/netbsd.sh | 8 ++++---- docker/openssl.sh | 8 ++++---- docker/qemu.sh | 8 ++++---- 8 files changed, 32 insertions(+), 32 deletions(-) diff --git a/docker/android-ndk.sh b/docker/android-ndk.sh index dc442fe51..9cc4e21a8 100644 --- a/docker/android-ndk.sh +++ b/docker/android-ndk.sh @@ -15,10 +15,10 @@ main() { apt-get update local purge_list=() for dep in ${dependencies[@]}; do - dpkg -L $dep || ( - apt-get install --no-install-recommends -y $dep && - purge_list+=( $dep ) - ) + if ! dpkg -L $dep; then + apt-get install --no-install-recommends -y $dep + purge_list+=( $dep ) + fi done td=$(mktemp -d) diff --git a/docker/cmake.sh b/docker/cmake.sh index ce901b9de..02668f41d 100644 --- a/docker/cmake.sh +++ b/docker/cmake.sh @@ -12,10 +12,10 @@ main() { apt-get update local purge_list=() for dep in ${dependencies[@]}; do - dpkg -L $dep || ( - apt-get install --no-install-recommends -y $dep && - purge_list+=( $dep ) - ) + if ! dpkg -L $dep; then + apt-get install --no-install-recommends -y $dep + purge_list+=( $dep ) + fi done local td=$(mktemp -d) diff --git a/docker/dragonfly.sh b/docker/dragonfly.sh index 283600a02..8a4914728 100644 --- a/docker/dragonfly.sh +++ b/docker/dragonfly.sh @@ -21,10 +21,10 @@ main() { apt-get update local purge_list=() for dep in ${dependencies[@]}; do - dpkg -L $dep || ( - apt-get install --no-install-recommends -y $dep && - purge_list+=( $dep ) - ) + if ! dpkg -L $dep; then + apt-get install --no-install-recommends -y $dep + purge_list+=( $dep ) + fi done local td=$(mktemp -d) diff --git a/docker/freebsd.sh b/docker/freebsd.sh index 27c16eecc..e78ca86b0 100644 --- a/docker/freebsd.sh +++ b/docker/freebsd.sh @@ -20,10 +20,10 @@ main() { apt-get update local purge_list=() for dep in ${dependencies[@]}; do - dpkg -L $dep || ( - apt-get install --no-install-recommends -y $dep && - purge_list+=( $dep ) - ) + if ! dpkg -L $dep; then + apt-get install --no-install-recommends -y $dep + purge_list+=( $dep ) + fi done local td=$(mktemp -d) diff --git a/docker/musl.sh b/docker/musl.sh index 07ec67e07..6aaa60600 100644 --- a/docker/musl.sh +++ b/docker/musl.sh @@ -13,10 +13,10 @@ main() { apt-get update local purge_list=() for dep in ${dependencies[@]}; do - dpkg -L $dep || ( - apt-get install --no-install-recommends -y $dep && - purge_list+=( $dep ) - ) + if ! dpkg -L $dep; then + apt-get install --no-install-recommends -y $dep + purge_list+=( $dep ) + fi done local td=$(mktemp -d) diff --git a/docker/netbsd.sh b/docker/netbsd.sh index a15d1fae9..f79cd57ea 100644 --- a/docker/netbsd.sh +++ b/docker/netbsd.sh @@ -19,10 +19,10 @@ main() { apt-get update local purge_list=() for dep in ${dependencies[@]}; do - dpkg -L $dep || ( - apt-get install --no-install-recommends -y $dep && - purge_list+=( $dep ) - ) + if ! dpkg -L $dep; then + apt-get install --no-install-recommends -y $dep + purge_list+=( $dep ) + fi done local td=$(mktemp -d) diff --git a/docker/openssl.sh b/docker/openssl.sh index 462dd6253..ce6d664c6 100644 --- a/docker/openssl.sh +++ b/docker/openssl.sh @@ -17,10 +17,10 @@ main() { apt-get update local purge_list=() for dep in ${dependencies[@]}; do - dpkg -L $dep || ( - apt-get install --no-install-recommends -y $dep && - purge_list+=( $dep ) - ) + if ! dpkg -L $dep; then + apt-get install --no-install-recommends -y $dep + purge_list+=( $dep ) + fi done td=$(mktemp -d) diff --git a/docker/qemu.sh b/docker/qemu.sh index 8909635fb..1594a6137 100644 --- a/docker/qemu.sh +++ b/docker/qemu.sh @@ -21,10 +21,10 @@ main() { apt-get update local purge_list=() for dep in ${dependencies[@]}; do - dpkg -L $dep || ( - apt-get install --no-install-recommends -y $dep && - purge_list+=( $dep ) - ) + if ! dpkg -L $dep; then + apt-get install --no-install-recommends -y $dep + purge_list+=( $dep ) + fi done pushd $td From 62b402ac46ae6f667045f1a8229d56bb7ec6e2e3 Mon Sep 17 00:00:00 2001 From: Marco A L Barbosa Date: Wed, 5 Apr 2017 11:03:41 -0300 Subject: [PATCH 03/35] Create a script to install xargo --- docker/aarch64-linux-android/Dockerfile | 13 ++++----- docker/aarch64-unknown-linux-gnu/Dockerfile | 9 ++---- docker/arm-linux-androideabi/Dockerfile | 9 ++---- docker/arm-unknown-linux-gnueabi/Dockerfile | 9 ++---- docker/arm-unknown-linux-musleabi/Dockerfile | 9 ++---- docker/armv7-linux-androideabi/Dockerfile | 9 ++---- .../armv7-unknown-linux-gnueabihf/Dockerfile | 9 ++---- .../armv7-unknown-linux-musleabihf/Dockerfile | 9 ++---- docker/i686-linux-android/Dockerfile | 9 ++---- docker/i686-unknown-freebsd/Dockerfile | 9 ++---- docker/i686-unknown-linux-gnu/Dockerfile | 9 ++---- docker/i686-unknown-linux-musl/Dockerfile | 9 ++---- docker/mips-unknown-linux-gnu/Dockerfile | 9 ++---- .../mips64-unknown-linux-gnuabi64/Dockerfile | 9 ++---- .../Dockerfile | 9 ++---- docker/mipsel-unknown-linux-gnu/Dockerfile | 9 ++---- docker/powerpc-unknown-linux-gnu/Dockerfile | 9 ++---- docker/powerpc64-unknown-linux-gnu/Dockerfile | 9 ++---- .../powerpc64le-unknown-linux-gnu/Dockerfile | 9 ++---- docker/s390x-unknown-linux-gnu/Dockerfile | 9 ++---- docker/sparc64-unknown-linux-gnu/Dockerfile | 9 ++---- docker/thumbv6m-none-eabi/Dockerfile | 9 ++---- docker/thumbv7em-none-eabi/Dockerfile | 9 ++---- docker/thumbv7em-none-eabihf/Dockerfile | 9 ++---- docker/thumbv7m-none-eabi/Dockerfile | 9 ++---- docker/x86_64-unknown-dragonfly/Dockerfile | 9 ++---- docker/x86_64-unknown-freebsd/Dockerfile | 9 ++---- docker/x86_64-unknown-linux-gnu/Dockerfile | 9 ++---- docker/x86_64-unknown-linux-musl/Dockerfile | 9 ++---- docker/x86_64-unknown-netbsd/Dockerfile | 9 ++---- docker/xargo.sh | 28 +++++++++++++++++++ 31 files changed, 120 insertions(+), 182 deletions(-) create mode 100644 docker/xargo.sh diff --git a/docker/aarch64-linux-android/Dockerfile b/docker/aarch64-linux-android/Dockerfile index 60cee4e9b..2ba40d1df 100644 --- a/docker/aarch64-linux-android/Dockerfile +++ b/docker/aarch64-linux-android/Dockerfile @@ -9,6 +9,9 @@ RUN apt-get update && \ make \ pkg-config +COPY xargo.sh / +RUN bash /xargo.sh + COPY android-ndk.sh / RUN bash /android-ndk.sh arm64 21 ENV PATH=$PATH:/android-ndk/bin @@ -16,17 +19,11 @@ ENV PATH=$PATH:/android-ndk/bin COPY openssl.sh / RUN bash /openssl.sh linux-generic64 aarch64-linux-android- -mandroid -fomit-frame-pointer -RUN apt-get install -y --no-install-recommends \ - curl && \ - curl -LSfs http://japaric.github.io/trust/install.sh | \ - sh -s -- --git japaric/xargo --tag v0.3.5 --target x86_64-unknown-linux-gnu --to /usr/bin && \ - apt-get purge --auto-remove -y curl - # Libz is distributed in the android ndk, but for some unknown reason it is not # found in the build process of some crates, so we explicit set the DEP_Z_ROOT ENV CARGO_TARGET_AARCH64_LINUX_ANDROID_LINKER=aarch64-linux-android-gcc \ - CC_AARCH64_linux_android=aarch64-linux-android-gcc \ - CXX_AARCH64_linux_android=aarch64-linux-android-g++ \ + CC_aarch64_linux_android=aarch64-linux-android-gcc \ + CXX_aarch64_linux_android=aarch64-linux-android-g++ \ DEP_Z_ROOT=/android-ndk/sysroot/usr/ \ OPENSSL_STATIC=1 \ OPENSSL_DIR=/openssl \ diff --git a/docker/aarch64-unknown-linux-gnu/Dockerfile b/docker/aarch64-unknown-linux-gnu/Dockerfile index fc430e99b..a65385e94 100644 --- a/docker/aarch64-unknown-linux-gnu/Dockerfile +++ b/docker/aarch64-unknown-linux-gnu/Dockerfile @@ -9,6 +9,9 @@ RUN apt-get update && \ make \ pkg-config +COPY xargo.sh / +RUN bash /xargo.sh + COPY openssl.sh qemu.sh / RUN apt-get install -y --no-install-recommends \ g++-aarch64-linux-gnu \ @@ -16,12 +19,6 @@ RUN apt-get install -y --no-install-recommends \ bash /openssl.sh linux-aarch64 aarch64-linux-gnu- && \ bash /qemu.sh 2.8.0 aarch64 -RUN apt-get install -y --no-install-recommends \ - curl && \ - curl -LSfs http://japaric.github.io/trust/install.sh | \ - sh -s -- --git japaric/xargo --tag v0.3.5 --target x86_64-unknown-linux-gnu --to /usr/bin && \ - apt-get purge --auto-remove -y curl - ENV CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER=aarch64-linux-gnu-gcc \ CC_aarch64_unknown_linux_gnu=aarch64-linux-gnu-gcc \ CXX_aarch64_unknown_linux_gnu=aarch64-linux-gnu-g++ \ diff --git a/docker/arm-linux-androideabi/Dockerfile b/docker/arm-linux-androideabi/Dockerfile index e02a3368e..141a89721 100644 --- a/docker/arm-linux-androideabi/Dockerfile +++ b/docker/arm-linux-androideabi/Dockerfile @@ -9,6 +9,9 @@ RUN apt-get update && \ make \ pkg-config +COPY xargo.sh / +RUN bash /xargo.sh + COPY android-ndk.sh / RUN bash /android-ndk.sh arm 21 ENV PATH=$PATH:/android-ndk/bin @@ -16,12 +19,6 @@ ENV PATH=$PATH:/android-ndk/bin COPY openssl.sh / RUN bash /openssl.sh android arm-linux-androideabi- -RUN apt-get install -y --no-install-recommends \ - curl && \ - curl -LSfs http://japaric.github.io/trust/install.sh | \ - sh -s -- --git japaric/xargo --tag v0.3.5 --target x86_64-unknown-linux-gnu --to /usr/bin && \ - apt-get purge --auto-remove -y curl - # Libz is distributed in the android ndk, but for some unknown reason it is not # found in the build process of some crates, so we explicit set the DEP_Z_ROOT ENV CARGO_TARGET_ARM_LINUX_ANDROIDEABI_LINKER=arm-linux-androideabi-gcc \ diff --git a/docker/arm-unknown-linux-gnueabi/Dockerfile b/docker/arm-unknown-linux-gnueabi/Dockerfile index e5990053b..4244386ea 100644 --- a/docker/arm-unknown-linux-gnueabi/Dockerfile +++ b/docker/arm-unknown-linux-gnueabi/Dockerfile @@ -9,6 +9,9 @@ RUN apt-get update && \ make \ pkg-config +COPY xargo.sh / +RUN bash /xargo.sh + COPY openssl.sh qemu.sh / RUN apt-get install -y --no-install-recommends \ g++-arm-linux-gnueabi \ @@ -16,12 +19,6 @@ RUN apt-get install -y --no-install-recommends \ bash /openssl.sh linux-armv4 arm-linux-gnueabi- && \ bash /qemu.sh 2.8.0 arm -RUN apt-get install -y --no-install-recommends \ - curl && \ - curl -LSfs http://japaric.github.io/trust/install.sh | \ - sh -s -- --git japaric/xargo --tag v0.3.5 --target x86_64-unknown-linux-gnu --to /usr/bin && \ - apt-get purge --auto-remove -y curl - ENV CARGO_TARGET_ARM_UNKNOWN_LINUX_GNUEABI_LINKER=arm-linux-gnueabi-gcc \ CC_arm_unknown_linux_gnueabi=arm-linux-gnueabi-gcc \ CXX_arm_unknown_linux_gnueabi=arm-linux-gnueabi-g++ \ diff --git a/docker/arm-unknown-linux-musleabi/Dockerfile b/docker/arm-unknown-linux-musleabi/Dockerfile index 5cb392193..6e022d60b 100644 --- a/docker/arm-unknown-linux-musleabi/Dockerfile +++ b/docker/arm-unknown-linux-musleabi/Dockerfile @@ -9,18 +9,15 @@ RUN apt-get update && \ make \ pkg-config +COPY xargo.sh / +RUN bash /xargo.sh + COPY qemu.sh / RUN bash /qemu.sh 2.8.0 arm RUN apt-get install -y --no-install-recommends \ gcc-arm-linux-gnueabi -RUN apt-get install -y --no-install-recommends \ - curl && \ - curl -LSfs http://japaric.github.io/trust/install.sh | \ - sh -s -- --git japaric/xargo --tag v0.3.5 --target x86_64-unknown-linux-gnu --to /usr/bin && \ - apt-get purge --auto-remove -y curl - ENV CARGO_TARGET_ARM_UNKNOWN_LINUX_MUSLEABI_LINKER=arm-linux-gnueabi-gcc \ CC_arm_unknown_linux_musleabi=arm-linux-gnueabi-gcc \ RUST_TEST_THREADS=1 diff --git a/docker/armv7-linux-androideabi/Dockerfile b/docker/armv7-linux-androideabi/Dockerfile index 155f369ee..535910add 100644 --- a/docker/armv7-linux-androideabi/Dockerfile +++ b/docker/armv7-linux-androideabi/Dockerfile @@ -9,6 +9,9 @@ RUN apt-get update && \ make \ pkg-config +COPY xargo.sh / +RUN bash /xargo.sh + COPY android-ndk.sh / RUN bash /android-ndk.sh arm 21 ENV PATH=$PATH:/android-ndk/bin @@ -16,12 +19,6 @@ ENV PATH=$PATH:/android-ndk/bin COPY openssl.sh / RUN bash /openssl.sh android-armv7 arm-linux-androideabi- -RUN apt-get install -y --no-install-recommends \ - curl && \ - curl -LSfs http://japaric.github.io/trust/install.sh | \ - sh -s -- --git japaric/xargo --tag v0.3.5 --target x86_64-unknown-linux-gnu --to /usr/bin && \ - apt-get purge --auto-remove -y curl - # Libz is distributed in the android ndk, but for some unknown reason it is not # found in the build process of some crates, so we explicit set the DEP_Z_ROOT ENV CARGO_TARGET_ARMV7_LINUX_ANDROIDEABI_LINKER=arm-linux-androideabi-gcc \ diff --git a/docker/armv7-unknown-linux-gnueabihf/Dockerfile b/docker/armv7-unknown-linux-gnueabihf/Dockerfile index 8d0d814a4..540d1c830 100644 --- a/docker/armv7-unknown-linux-gnueabihf/Dockerfile +++ b/docker/armv7-unknown-linux-gnueabihf/Dockerfile @@ -9,6 +9,9 @@ RUN apt-get update && \ make \ pkg-config +COPY xargo.sh / +RUN bash /xargo.sh + COPY cmake.sh / RUN apt-get purge --auto-remove -y cmake && \ bash /cmake.sh 2.8.11 @@ -20,12 +23,6 @@ RUN apt-get install -y --no-install-recommends \ bash /openssl.sh linux-armv4 arm-linux-gnueabihf- && \ bash /qemu.sh 2.8.0 arm -RUN apt-get install -y --no-install-recommends \ - curl && \ - curl -LSfs http://japaric.github.io/trust/install.sh | \ - sh -s -- --git japaric/xargo --tag v0.3.5 --target x86_64-unknown-linux-gnu --to /usr/bin && \ - apt-get purge --auto-remove -y curl - ENV CARGO_TARGET_ARMV7_UNKNOWN_LINUX_GNUEABIHF_LINKER=arm-linux-gnueabihf-gcc \ CC_armv7_unknown_linux_gnueabihf=arm-linux-gnueabihf-gcc \ CXX_armv7_unknown_linux_gnueabihf=arm-linux-gnueabihf-g++ \ diff --git a/docker/armv7-unknown-linux-musleabihf/Dockerfile b/docker/armv7-unknown-linux-musleabihf/Dockerfile index fab8b051d..55ed93c6e 100644 --- a/docker/armv7-unknown-linux-musleabihf/Dockerfile +++ b/docker/armv7-unknown-linux-musleabihf/Dockerfile @@ -9,18 +9,15 @@ RUN apt-get update && \ make \ pkg-config +COPY xargo.sh / +RUN bash /xargo.sh + COPY qemu.sh / RUN bash /qemu.sh 2.8.0 arm RUN apt-get install -y --no-install-recommends \ gcc-arm-linux-gnueabihf -RUN apt-get install -y --no-install-recommends \ - curl && \ - curl -LSfs http://japaric.github.io/trust/install.sh | \ - sh -s -- --git japaric/xargo --tag v0.3.5 --target x86_64-unknown-linux-gnu --to /usr/bin && \ - apt-get purge --auto-remove -y curl - ENV CARGO_TARGET_ARMV7_UNKNOWN_LINUX_MUSLEABIHF_LINKER=arm-linux-gnueabihf-gcc \ CC_armv7_unknown_linux_musleabihf=arm-linux-gnueabihf-gcc \ RUST_TEST_THREADS=1 diff --git a/docker/i686-linux-android/Dockerfile b/docker/i686-linux-android/Dockerfile index 0afc0c0be..d1f15fa2a 100644 --- a/docker/i686-linux-android/Dockerfile +++ b/docker/i686-linux-android/Dockerfile @@ -9,6 +9,9 @@ RUN apt-get update && \ make \ pkg-config +COPY xargo.sh / +RUN bash /xargo.sh + COPY android-ndk.sh / RUN bash /android-ndk.sh x86 21 ENV PATH=$PATH:/android-ndk/bin @@ -16,12 +19,6 @@ ENV PATH=$PATH:/android-ndk/bin COPY openssl.sh / RUN bash /openssl.sh android-x86 i686-linux-android- -RUN apt-get install -y --no-install-recommends \ - curl && \ - curl -LSfs http://japaric.github.io/trust/install.sh | \ - sh -s -- --git japaric/xargo --tag v0.3.5 --target x86_64-unknown-linux-gnu --to /usr/bin && \ - apt-get purge --auto-remove -y curl - # Libz is distributed in the android ndk, but for some unknown reason it is not # found in the build process of some crates, so we explicit set the DEP_Z_ROOT ENV CARGO_TARGET_I686_LINUX_ANDROID_LINKER=i686-linux-android-gcc \ diff --git a/docker/i686-unknown-freebsd/Dockerfile b/docker/i686-unknown-freebsd/Dockerfile index 41b06ff5a..9cbf85c3d 100644 --- a/docker/i686-unknown-freebsd/Dockerfile +++ b/docker/i686-unknown-freebsd/Dockerfile @@ -9,16 +9,13 @@ RUN apt-get update && \ make \ pkg-config +COPY xargo.sh / +RUN bash /xargo.sh + COPY freebsd.sh openssl.sh / RUN bash /freebsd.sh i686 && \ bash /openssl.sh BSD-x86-elf i686-unknown-freebsd10- -RUN apt-get install -y --no-install-recommends \ - curl && \ - curl -LSfs http://japaric.github.io/trust/install.sh | \ - sh -s -- --git japaric/xargo --tag v0.3.5 --target x86_64-unknown-linux-gnu --to /usr/bin && \ - apt-get purge --auto-remove -y curl - ENV CARGO_TARGET_I686_UNKNOWN_FREEBSD_LINKER=i686-unknown-freebsd10-gcc \ CC_i686_unknown_freebsd=i686-unknown-freebsd10-gcc \ OPENSSL_DIR=/openssl \ diff --git a/docker/i686-unknown-linux-gnu/Dockerfile b/docker/i686-unknown-linux-gnu/Dockerfile index 63a5b48bf..b5143218f 100644 --- a/docker/i686-unknown-linux-gnu/Dockerfile +++ b/docker/i686-unknown-linux-gnu/Dockerfile @@ -9,6 +9,9 @@ RUN apt-get update && \ make \ pkg-config +COPY xargo.sh / +RUN bash /xargo.sh + COPY cmake.sh / RUN apt-get purge --auto-remove -y cmake && \ bash /cmake.sh 2.8.11 @@ -18,12 +21,6 @@ RUN apt-get install -y --no-install-recommends \ g++-multilib && \ bash /openssl.sh linux-elf "" -m32 -RUN apt-get install -y --no-install-recommends \ - curl && \ - curl -LSfs http://japaric.github.io/trust/install.sh | \ - sh -s -- --git japaric/xargo --tag v0.3.5 --target x86_64-unknown-linux-gnu --to /usr/bin && \ - apt-get purge --auto-remove -y curl - ENV OPENSSL_DIR=/openssl \ OPENSSL_INCLUDE_DIR=/openssl/include \ OPENSSL_LIB_DIR=/openssl/lib diff --git a/docker/i686-unknown-linux-musl/Dockerfile b/docker/i686-unknown-linux-musl/Dockerfile index 636c7ed32..f277b0bf7 100644 --- a/docker/i686-unknown-linux-musl/Dockerfile +++ b/docker/i686-unknown-linux-musl/Dockerfile @@ -9,15 +9,12 @@ RUN apt-get update && \ make \ pkg-config +COPY xargo.sh / +RUN bash /xargo.sh + COPY musl.sh / RUN apt-get install -y --no-install-recommends \ gcc-multilib && \ bash /musl.sh 1.1.15 i386 -m32 -RUN apt-get install -y --no-install-recommends \ - curl && \ - curl -LSfs http://japaric.github.io/trust/install.sh | \ - sh -s -- --git japaric/xargo --tag v0.3.5 --target x86_64-unknown-linux-gnu --to /usr/bin && \ - apt-get purge --auto-remove -y curl - ENV CC_i686_unknown_linux_musl=musl-gcc diff --git a/docker/mips-unknown-linux-gnu/Dockerfile b/docker/mips-unknown-linux-gnu/Dockerfile index 0a8611864..2e9125327 100644 --- a/docker/mips-unknown-linux-gnu/Dockerfile +++ b/docker/mips-unknown-linux-gnu/Dockerfile @@ -9,6 +9,9 @@ RUN apt-get update && \ make \ pkg-config +COPY xargo.sh / +RUN bash /xargo.sh + COPY openssl.sh qemu.sh / RUN apt-get install -y --no-install-recommends \ g++-mips-linux-gnu \ @@ -16,12 +19,6 @@ RUN apt-get install -y --no-install-recommends \ bash /openssl.sh linux-mips32 mips-linux-gnu- && \ bash /qemu.sh 2.8.0 mips -RUN apt-get install -y --no-install-recommends \ - curl && \ - curl -LSfs http://japaric.github.io/trust/install.sh | \ - sh -s -- --git japaric/xargo --tag v0.3.5 --target x86_64-unknown-linux-gnu --to /usr/bin && \ - apt-get purge --auto-remove -y curl - ENV CARGO_TARGET_MIPS_UNKNOWN_LINUX_GNU_LINKER=mips-linux-gnu-gcc \ CC_mips_unknown_linux_gnu=mips-linux-gnu-gcc \ CXX_mips_unknown_linux_gnu=mips-linux-gnu-g++ \ diff --git a/docker/mips64-unknown-linux-gnuabi64/Dockerfile b/docker/mips64-unknown-linux-gnuabi64/Dockerfile index 0c3e6f119..6be18738c 100644 --- a/docker/mips64-unknown-linux-gnuabi64/Dockerfile +++ b/docker/mips64-unknown-linux-gnuabi64/Dockerfile @@ -9,6 +9,9 @@ RUN apt-get update && \ make \ pkg-config +COPY xargo.sh / +RUN bash /xargo.sh + COPY openssl.sh qemu.sh / RUN apt-get install -y --no-install-recommends \ g++-mips64-linux-gnuabi64 \ @@ -16,12 +19,6 @@ RUN apt-get install -y --no-install-recommends \ bash /openssl.sh linux64-mips64 mips64-linux-gnuabi64- && \ bash /qemu.sh 2.8.0 mips64 -RUN apt-get install -y --no-install-recommends \ - curl && \ - curl -LSfs http://japaric.github.io/trust/install.sh | \ - sh -s -- --git japaric/xargo --tag v0.3.5 --target x86_64-unknown-linux-gnu --to /usr/bin && \ - apt-get purge --auto-remove -y curl - ENV CARGO_TARGET_MIPS64_UNKNOWN_LINUX_GNUABI64_LINKER=mips64-linux-gnuabi64-gcc \ CC_mips64_unknown_linux_gnuabi64=mips64-linux-gnuabi64-gcc \ CXX_mips64_unknown_linux_gnuabi64=mips64-linux-gnuabi64-g++ \ diff --git a/docker/mips64el-unknown-linux-gnuabi64/Dockerfile b/docker/mips64el-unknown-linux-gnuabi64/Dockerfile index 29f6c8a12..87d0f96fd 100644 --- a/docker/mips64el-unknown-linux-gnuabi64/Dockerfile +++ b/docker/mips64el-unknown-linux-gnuabi64/Dockerfile @@ -9,6 +9,9 @@ RUN apt-get update && \ make \ pkg-config +COPY xargo.sh / +RUN bash /xargo.sh + COPY openssl.sh qemu.sh / RUN apt-get install -y --no-install-recommends \ g++-mips64el-linux-gnuabi64 \ @@ -16,12 +19,6 @@ RUN apt-get install -y --no-install-recommends \ bash /openssl.sh linux64-mips64 mips64el-linux-gnuabi64- && \ bash /qemu.sh 2.8.0 mips64el -RUN apt-get install -y --no-install-recommends \ - curl && \ - curl -LSfs http://japaric.github.io/trust/install.sh | \ - sh -s -- --git japaric/xargo --tag v0.3.5 --target x86_64-unknown-linux-gnu --to /usr/bin && \ - apt-get purge --auto-remove -y curl - ENV CARGO_TARGET_MIPS64EL_UNKNOWN_LINUX_GNUABI64_LINKER=mips64el-linux-gnuabi64-gcc \ CC_mips64el_unknown_linux_gnuabi64=mips64el-linux-gnuabi64-gcc \ CXX_mips64el_unknown_linux_gnuabi64=mips64el-linux-gnuabi64-g++ \ diff --git a/docker/mipsel-unknown-linux-gnu/Dockerfile b/docker/mipsel-unknown-linux-gnu/Dockerfile index 97aff7ee5..ccb982ebe 100644 --- a/docker/mipsel-unknown-linux-gnu/Dockerfile +++ b/docker/mipsel-unknown-linux-gnu/Dockerfile @@ -9,6 +9,9 @@ RUN apt-get update && \ make \ pkg-config +COPY xargo.sh / +RUN bash /xargo.sh + COPY openssl.sh qemu.sh / RUN apt-get install -y --no-install-recommends \ g++-mipsel-linux-gnu \ @@ -16,12 +19,6 @@ RUN apt-get install -y --no-install-recommends \ bash /openssl.sh linux-mips32 mipsel-linux-gnu- && \ bash /qemu.sh 2.8.0 mipsel -RUN apt-get install -y --no-install-recommends \ - curl && \ - curl -LSfs http://japaric.github.io/trust/install.sh | \ - sh -s -- --git japaric/xargo --tag v0.3.5 --target x86_64-unknown-linux-gnu --to /usr/bin && \ - apt-get purge --auto-remove -y curl - ENV CARGO_TARGET_MIPSEL_UNKNOWN_LINUX_GNU_LINKER=mipsel-linux-gnu-gcc \ CC_mipsel_unknown_linux_gnu=mipsel-linux-gnu-gcc \ CXX_mipsel_unknown_linux_gnu=mipsel-linux-gnu-g++ \ diff --git a/docker/powerpc-unknown-linux-gnu/Dockerfile b/docker/powerpc-unknown-linux-gnu/Dockerfile index 21dec87da..d49ddd9d3 100644 --- a/docker/powerpc-unknown-linux-gnu/Dockerfile +++ b/docker/powerpc-unknown-linux-gnu/Dockerfile @@ -9,6 +9,9 @@ RUN apt-get update && \ make \ pkg-config +COPY xargo.sh / +RUN bash /xargo.sh + COPY openssl.sh qemu.sh / RUN apt-get install -y --no-install-recommends \ g++-powerpc-linux-gnu \ @@ -16,12 +19,6 @@ RUN apt-get install -y --no-install-recommends \ bash /openssl.sh linux-ppc powerpc-linux-gnu- && \ bash /qemu.sh 2.7.1 ppc -RUN apt-get install -y --no-install-recommends \ - curl && \ - curl -LSfs http://japaric.github.io/trust/install.sh | \ - sh -s -- --git japaric/xargo --tag v0.3.5 --target x86_64-unknown-linux-gnu --to /usr/bin && \ - apt-get purge --auto-remove -y curl - ENV CARGO_TARGET_POWERPC_UNKNOWN_LINUX_GNU_LINKER=powerpc-linux-gnu-gcc \ CC_powerpc_unknown_linux_gnu=powerpc-linux-gnu-gcc \ CXX_powerpc_unknown_linux_gnu=powerpc-linux-gnu-g++ \ diff --git a/docker/powerpc64-unknown-linux-gnu/Dockerfile b/docker/powerpc64-unknown-linux-gnu/Dockerfile index 4043c7fea..03f8fe376 100644 --- a/docker/powerpc64-unknown-linux-gnu/Dockerfile +++ b/docker/powerpc64-unknown-linux-gnu/Dockerfile @@ -9,6 +9,9 @@ RUN apt-get update && \ make \ pkg-config +COPY xargo.sh / +RUN bash /xargo.sh + COPY openssl.sh qemu.sh / RUN apt-get install -y --no-install-recommends \ g++-powerpc64-linux-gnu \ @@ -16,12 +19,6 @@ RUN apt-get install -y --no-install-recommends \ bash /openssl.sh linux-ppc64 powerpc64-linux-gnu- && \ bash /qemu.sh 2.7.1 ppc64 -RUN apt-get install -y --no-install-recommends \ - curl && \ - curl -LSfs http://japaric.github.io/trust/install.sh | \ - sh -s -- --git japaric/xargo --tag v0.3.5 --target x86_64-unknown-linux-gnu --to /usr/bin && \ - apt-get purge --auto-remove -y curl - ENV CARGO_TARGET_POWERPC64_UNKNOWN_LINUX_GNU_LINKER=powerpc64-linux-gnu-gcc \ CC_powerpc64_unknown_linux_gnu=powerpc64-linux-gnu-gcc \ CXX_powerpc64_unknown_linux_gnu=powerpc64-linux-gnu-g++ \ diff --git a/docker/powerpc64le-unknown-linux-gnu/Dockerfile b/docker/powerpc64le-unknown-linux-gnu/Dockerfile index 9430fa4dd..9f8bc8564 100644 --- a/docker/powerpc64le-unknown-linux-gnu/Dockerfile +++ b/docker/powerpc64le-unknown-linux-gnu/Dockerfile @@ -9,6 +9,9 @@ RUN apt-get update && \ make \ pkg-config +COPY xargo.sh / +RUN bash /xargo.sh + COPY openssl.sh qemu.sh / RUN apt-get install -y --no-install-recommends \ g++-powerpc64le-linux-gnu \ @@ -16,12 +19,6 @@ RUN apt-get install -y --no-install-recommends \ bash /openssl.sh linux-ppc64le powerpc64le-linux-gnu- && \ bash /qemu.sh 2.7.1 ppc64le -RUN apt-get install -y --no-install-recommends \ - curl && \ - curl -LSfs http://japaric.github.io/trust/install.sh | \ - sh -s -- --git japaric/xargo --tag v0.3.5 --target x86_64-unknown-linux-gnu --to /usr/bin && \ - apt-get purge --auto-remove -y curl - ENV CARGO_TARGET_POWERPC64LE_UNKNOWN_LINUX_GNU_LINKER=powerpc64le-linux-gnu-gcc \ CC_powerpc64le_unknown_linux_gnu=powerpc64le-linux-gnu-gcc \ CXX_powerpc64le_unknown_linux_gnu=powerpc64le-linux-gnu-g++ \ diff --git a/docker/s390x-unknown-linux-gnu/Dockerfile b/docker/s390x-unknown-linux-gnu/Dockerfile index 38d38f148..33e3a99cb 100644 --- a/docker/s390x-unknown-linux-gnu/Dockerfile +++ b/docker/s390x-unknown-linux-gnu/Dockerfile @@ -9,6 +9,9 @@ RUN apt-get update && \ make \ pkg-config +COPY xargo.sh / +RUN bash /xargo.sh + COPY openssl.sh qemu.sh / RUN apt-get install -y --no-install-recommends \ g++-s390x-linux-gnu \ @@ -16,12 +19,6 @@ RUN apt-get install -y --no-install-recommends \ bash /openssl.sh linux64-s390x s390x-linux-gnu- && \ bash /qemu.sh 2.8.0 s390x -RUN apt-get install -y --no-install-recommends \ - curl && \ - curl -LSfs http://japaric.github.io/trust/install.sh | \ - sh -s -- --git japaric/xargo --tag v0.3.5 --target x86_64-unknown-linux-gnu --to /usr/bin && \ - apt-get purge --auto-remove -y curl - ENV CARGO_TARGET_S390X_UNKNOWN_LINUX_GNU_LINKER=s390x-linux-gnu-gcc \ CC_s390x_unknown_linux_gnu=s390x-linux-gnu-gcc \ CXX_s390x_unknown_linux_gnu=s390x-linux-gnu-g++ \ diff --git a/docker/sparc64-unknown-linux-gnu/Dockerfile b/docker/sparc64-unknown-linux-gnu/Dockerfile index 716274fb0..0cf3a89df 100644 --- a/docker/sparc64-unknown-linux-gnu/Dockerfile +++ b/docker/sparc64-unknown-linux-gnu/Dockerfile @@ -9,6 +9,9 @@ RUN apt-get update && \ make \ pkg-config +COPY xargo.sh / +RUN bash /xargo.sh + COPY openssl.sh qemu.sh / RUN apt-get install -y --no-install-recommends \ g++-sparc64-linux-gnu \ @@ -16,12 +19,6 @@ RUN apt-get install -y --no-install-recommends \ bash /openssl.sh linux64-sparcv9 sparc64-linux-gnu- && \ bash /qemu.sh 2.8.0 sparc64 -RUN apt-get install -y --no-install-recommends \ - curl && \ - curl -LSfs http://japaric.github.io/trust/install.sh | \ - sh -s -- --git japaric/xargo --tag v0.3.5 --target x86_64-unknown-linux-gnu --to /usr/bin && \ - apt-get purge --auto-remove -y curl - ENV CARGO_TARGET_SPARC64_UNKNOWN_LINUX_GNU_LINKER=sparc64-linux-gnu-gcc \ CC_sparc64_unknown_linux_gnu=sparc64-linux-gnu-gcc \ CXX_sparc64_unknown_linux_gnu=sparc64-linux-gnu-g++ \ diff --git a/docker/thumbv6m-none-eabi/Dockerfile b/docker/thumbv6m-none-eabi/Dockerfile index 12e629683..f148bab3c 100644 --- a/docker/thumbv6m-none-eabi/Dockerfile +++ b/docker/thumbv6m-none-eabi/Dockerfile @@ -9,16 +9,13 @@ RUN apt-get update && \ make \ pkg-config +COPY xargo.sh / +RUN bash /xargo.sh + COPY qemu.sh / RUN apt-get install -y --no-install-recommends \ gcc-arm-none-eabi \ libnewlib-arm-none-eabi && \ bash /qemu.sh 2.8.0 arm -RUN apt-get install -y --no-install-recommends \ - curl && \ - curl -LSfs http://japaric.github.io/trust/install.sh | \ - sh -s -- --git japaric/xargo --tag v0.3.5 --target x86_64-unknown-linux-gnu --to /usr/bin && \ - apt-get purge --auto-remove -y curl - ENV QEMU_CPU=cortex-m3 diff --git a/docker/thumbv7em-none-eabi/Dockerfile b/docker/thumbv7em-none-eabi/Dockerfile index 46299a8b6..9ec937975 100644 --- a/docker/thumbv7em-none-eabi/Dockerfile +++ b/docker/thumbv7em-none-eabi/Dockerfile @@ -9,16 +9,13 @@ RUN apt-get update && \ make \ pkg-config +COPY xargo.sh / +RUN bash /xargo.sh + COPY qemu.sh / RUN apt-get install -y --no-install-recommends \ gcc-arm-none-eabi \ libnewlib-arm-none-eabi && \ bash /qemu.sh 2.8.0 arm -RUN apt-get install -y --no-install-recommends \ - curl && \ - curl -LSfs http://japaric.github.io/trust/install.sh | \ - sh -s -- --git japaric/xargo --tag v0.3.5 --target x86_64-unknown-linux-gnu --to /usr/bin && \ - apt-get purge --auto-remove -y curl - ENV QEMU_CPU=cortex-m4 diff --git a/docker/thumbv7em-none-eabihf/Dockerfile b/docker/thumbv7em-none-eabihf/Dockerfile index 46299a8b6..9ec937975 100644 --- a/docker/thumbv7em-none-eabihf/Dockerfile +++ b/docker/thumbv7em-none-eabihf/Dockerfile @@ -9,16 +9,13 @@ RUN apt-get update && \ make \ pkg-config +COPY xargo.sh / +RUN bash /xargo.sh + COPY qemu.sh / RUN apt-get install -y --no-install-recommends \ gcc-arm-none-eabi \ libnewlib-arm-none-eabi && \ bash /qemu.sh 2.8.0 arm -RUN apt-get install -y --no-install-recommends \ - curl && \ - curl -LSfs http://japaric.github.io/trust/install.sh | \ - sh -s -- --git japaric/xargo --tag v0.3.5 --target x86_64-unknown-linux-gnu --to /usr/bin && \ - apt-get purge --auto-remove -y curl - ENV QEMU_CPU=cortex-m4 diff --git a/docker/thumbv7m-none-eabi/Dockerfile b/docker/thumbv7m-none-eabi/Dockerfile index 12e629683..f148bab3c 100644 --- a/docker/thumbv7m-none-eabi/Dockerfile +++ b/docker/thumbv7m-none-eabi/Dockerfile @@ -9,16 +9,13 @@ RUN apt-get update && \ make \ pkg-config +COPY xargo.sh / +RUN bash /xargo.sh + COPY qemu.sh / RUN apt-get install -y --no-install-recommends \ gcc-arm-none-eabi \ libnewlib-arm-none-eabi && \ bash /qemu.sh 2.8.0 arm -RUN apt-get install -y --no-install-recommends \ - curl && \ - curl -LSfs http://japaric.github.io/trust/install.sh | \ - sh -s -- --git japaric/xargo --tag v0.3.5 --target x86_64-unknown-linux-gnu --to /usr/bin && \ - apt-get purge --auto-remove -y curl - ENV QEMU_CPU=cortex-m3 diff --git a/docker/x86_64-unknown-dragonfly/Dockerfile b/docker/x86_64-unknown-dragonfly/Dockerfile index ab9e3d5b2..1ef78b3aa 100644 --- a/docker/x86_64-unknown-dragonfly/Dockerfile +++ b/docker/x86_64-unknown-dragonfly/Dockerfile @@ -9,16 +9,13 @@ RUN apt-get update && \ make \ pkg-config +COPY xargo.sh / +RUN bash /xargo.sh + COPY dragonfly.sh openssl.sh / RUN bash /dragonfly.sh && \ bash /openssl.sh BSD-x86_64 x86_64-unknown-dragonfly- -RUN apt-get install -y --no-install-recommends \ - curl && \ - curl -LSfs http://japaric.github.io/trust/install.sh | \ - sh -s -- --git japaric/xargo --tag v0.3.5 --target x86_64-unknown-linux-gnu --to /usr/bin && \ - apt-get purge --auto-remove -y curl - ENV CARGO_TARGET_X86_64_UNKNOWN_DRAGONFLY_LINKER=x86_64-unknown-dragonfly-gcc \ CC_x86_64_unknown_dragonfly=x86_64-unknown-dragonfly-gcc \ OPENSSL_DIR=/openssl \ diff --git a/docker/x86_64-unknown-freebsd/Dockerfile b/docker/x86_64-unknown-freebsd/Dockerfile index 302073610..faf5916a0 100644 --- a/docker/x86_64-unknown-freebsd/Dockerfile +++ b/docker/x86_64-unknown-freebsd/Dockerfile @@ -9,16 +9,13 @@ RUN apt-get update && \ make \ pkg-config +COPY xargo.sh / +RUN bash /xargo.sh + COPY freebsd.sh openssl.sh / RUN bash /freebsd.sh x86_64 && \ bash /openssl.sh BSD-x86_64 x86_64-unknown-freebsd10- -RUN apt-get install -y --no-install-recommends \ - curl && \ - curl -LSfs http://japaric.github.io/trust/install.sh | \ - sh -s -- --git japaric/xargo --tag v0.3.5 --target x86_64-unknown-linux-gnu --to /usr/bin && \ - apt-get purge --auto-remove -y curl - ENV CARGO_TARGET_X86_64_UNKNOWN_FREEBSD_LINKER=x86_64-unknown-freebsd10-gcc \ CC_x86_64_unknown_freebsd=x86_64-unknown-freebsd10-gcc \ OPENSSL_DIR=/openssl \ diff --git a/docker/x86_64-unknown-linux-gnu/Dockerfile b/docker/x86_64-unknown-linux-gnu/Dockerfile index 1b980d497..f5fb8dbd4 100644 --- a/docker/x86_64-unknown-linux-gnu/Dockerfile +++ b/docker/x86_64-unknown-linux-gnu/Dockerfile @@ -9,6 +9,9 @@ RUN apt-get update && \ make \ pkg-config +COPY xargo.sh / +RUN bash /xargo.sh + COPY cmake.sh / RUN apt-get purge --auto-remove -y cmake && \ bash /cmake.sh 2.8.11 @@ -19,12 +22,6 @@ RUN apt-get install -y --no-install-recommends \ zlib1g-dev && \ bash /openssl.sh linux-x86_64 -RUN apt-get install -y --no-install-recommends \ - curl && \ - curl -LSfs http://japaric.github.io/trust/install.sh | \ - sh -s -- --git japaric/xargo --tag v0.3.5 --target x86_64-unknown-linux-gnu --to /usr/bin && \ - apt-get purge --auto-remove -y curl - ENV OPENSSL_DIR=/openssl \ OPENSSL_INCLUDE_DIR=/openssl/include \ OPENSSL_LIB_DIR=/openssl/lib diff --git a/docker/x86_64-unknown-linux-musl/Dockerfile b/docker/x86_64-unknown-linux-musl/Dockerfile index eb15f7f77..40ecdf90b 100644 --- a/docker/x86_64-unknown-linux-musl/Dockerfile +++ b/docker/x86_64-unknown-linux-musl/Dockerfile @@ -9,18 +9,15 @@ RUN apt-get update && \ make \ pkg-config +COPY xargo.sh / +RUN bash /xargo.sh + COPY musl.sh openssl.sh / COPY musl-gcc.x86_64-unknown-linux-musl /usr/local/bin/musl-gcc COPY musl-gcc.specs.x86_64-unknown-linux-musl /usr/local/lib/musl-gcc.specs RUN bash /musl.sh 1.1.15 && \ bash /openssl.sh linux-x86_64 musl- -static -RUN apt-get install -y --no-install-recommends \ - curl && \ - curl -LSfs http://japaric.github.io/trust/install.sh | \ - sh -s -- --git japaric/xargo --tag v0.3.5 --target x86_64-unknown-linux-gnu --to /usr/bin && \ - apt-get purge --auto-remove -y curl - ENV CC_x86_64_unknown_linux_musl=musl-gcc \ OPENSSL_DIR=/openssl \ OPENSSL_INCLUDE_DIR=/openssl/include \ diff --git a/docker/x86_64-unknown-netbsd/Dockerfile b/docker/x86_64-unknown-netbsd/Dockerfile index 600a7c4c6..d4de29912 100644 --- a/docker/x86_64-unknown-netbsd/Dockerfile +++ b/docker/x86_64-unknown-netbsd/Dockerfile @@ -9,16 +9,13 @@ RUN apt-get update && \ make \ pkg-config +COPY xargo.sh / +RUN bash /xargo.sh + COPY netbsd.sh openssl.sh / RUN bash /netbsd.sh && \ bash /openssl.sh BSD-x86_64 x86_64-unknown-netbsd- -RUN apt-get install -y --no-install-recommends \ - curl && \ - curl -LSfs http://japaric.github.io/trust/install.sh | \ - sh -s -- --git japaric/xargo --tag v0.3.5 --target x86_64-unknown-linux-gnu --to /usr/bin && \ - apt-get purge --auto-remove -y curl - ENV CARGO_TARGET_X86_64_UNKNOWN_NETBSD_LINKER=x86_64-unknown-netbsd-gcc \ CC_x86_64_unknown_netbsd=x86_64-unknown-netbsd-gcc \ OPENSSL_DIR=/openssl \ diff --git a/docker/xargo.sh b/docker/xargo.sh new file mode 100644 index 000000000..83c32e75b --- /dev/null +++ b/docker/xargo.sh @@ -0,0 +1,28 @@ +set -ex + +main() { + local tag=v0.3.5 + local target=x86_64-unknown-linux-gnu + + local dependencies=( + ca-certificates + curl + ) + + apt-get update + local purge_list=() + for dep in ${dependencies[@]}; do + if ! dpkg -L $dep; then + apt-get install --no-install-recommends -y $dep + purge_list+=( $dep ) + fi + done + + curl -LSfs http://japaric.github.io/trust/install.sh | \ + sh -s -- --git japaric/xargo --tag $tag --target $target --to /usr/bin && \ + + apt-get purge --auto-remove -y ${purge_list[@]} + rm $0 +} + +main "${@}" From b5376feab682ffa566630ed31ac8c4dd91ae8505 Mon Sep 17 00:00:00 2001 From: Marco A L Barbosa Date: Fri, 14 Apr 2017 18:34:21 -0300 Subject: [PATCH 04/35] Fix binfmt_misc link --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 5d9c7b40b..879b534c8 100644 --- a/README.md +++ b/README.md @@ -38,7 +38,7 @@ - A Linux kernel with [binfmt_misc] support is required for cross testing. -[binfmt_misc]: https://www.kernel.org/doc/Documentation/binfmt_misc.txt +[binfmt_misc]: https://www.kernel.org/doc/html/latest/admin-guide/binfmt-misc.html ## Installation From 813aeb808aa1b9ba94365a82ffc8321b8aa768b6 Mon Sep 17 00:00:00 2001 From: Jorge Aparicio Date: Fri, 14 Apr 2017 21:14:51 -0500 Subject: [PATCH 05/35] compiler-builtins test requires the gen-tests Cargo feature --- ci/script.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/ci/script.sh b/ci/script.sh index bfe6d2f03..f4de189a6 100644 --- a/ci/script.sh +++ b/ci/script.sh @@ -93,6 +93,7 @@ EOF pushd $td cross test \ --no-default-features \ + --features gen-tests \ --target $TARGET popd From 47c562e4b4d5a233daa9c57012f33b07bb7d2543 Mon Sep 17 00:00:00 2001 From: Yong Wen Chua Date: Thu, 20 Apr 2017 11:20:39 +0800 Subject: [PATCH 06/35] Fixes permission issues with userns on Docker host Fixes #90 --- Cargo.lock | 23 +++++++++++++++++++++++ Cargo.toml | 2 ++ src/docker.rs | 44 ++++++++++++++++++++++++++++++++++++++++---- src/main.rs | 3 +++ 4 files changed, 68 insertions(+), 4 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 09ff3b789..9fe96a0eb 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3,8 +3,10 @@ name = "cross" version = "0.1.11-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)", + "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)", ] @@ -67,6 +69,11 @@ dependencies = [ "winapi-build 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "lazy_static" +version = "0.2.8" +source = "registry+https://github.com/rust-lang/crates.io-index" + [[package]] name = "libc" version = "0.2.18" @@ -95,6 +102,19 @@ name = "semver" version = "0.1.20" source = "registry+https://github.com/rust-lang/crates.io-index" +[[package]] +name = "semver" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "semver-parser 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "semver-parser" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" + [[package]] name = "toml" version = "0.2.1" @@ -121,11 +141,14 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum error-chain 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)" = "318cb3c71ee4cdea69fdc9e15c173b245ed6063e1709029e8fd32525a881120f" "checksum gcc 0.3.45 (registry+https://github.com/rust-lang/crates.io-index)" = "40899336fb50db0c78710f53e87afc54d8c7266fb76262fecc78ca1a7f09deae" "checksum kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7507624b29483431c0ba2d82aece8ca6cdba9382bff4ddd0f7490560c056098d" +"checksum lazy_static 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)" = "3b37545ab726dd833ec6420aaba8231c5b320814b9029ad585555d2a03e94fbf" "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 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" "checksum winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)" = "167dc9d6949a9b857f3451275e911c3f44255842c1f7a76f33c55103a909087a" "checksum winapi-build 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "2d315eee3b34aca4797b2da6b13ed88266e6d612562a0c46390af8299fc699bc" diff --git a/Cargo.toml b/Cargo.toml index e9692292e..96e433536 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -11,6 +11,8 @@ version = "0.1.11-dev" [dependencies] error-chain = "0.7.1" +lazy_static = "0.2" libc = "0.2.18" rustc_version = "0.1.7" +semver = "0.6.0" toml = "0.2.1" diff --git a/src/docker.rs b/src/docker.rs index 990082455..bde3fd012 100644 --- a/src/docker.rs +++ b/src/docker.rs @@ -3,6 +3,8 @@ use std::path::PathBuf; use std::process::{Command, ExitStatus}; use std::{env, fs}; +use semver::{Version, VersionReq}; + use {Target, Toml}; use cargo::Root; use errors::*; @@ -10,10 +12,45 @@ use extensions::CommandExt; use id; use rustc; +lazy_static! { + /// Retrieve the Docker Daemon version. + /// + /// # Panics + /// Panics if the version cannot be retrieved or parsed + static ref DOCKER_VERSION: Version = { + let version_string = Command::new("docker") + .arg("version") + .arg("--format={{.Server.APIVersion}}") + .run_and_get_stdout(false) + .expect("Unable to obtain Docker version"); + // API versions don't have "patch" version + Version::parse(&format!("{}.0", version_string.trim())) + .expect("Cannot parse Docker engine version") + }; + + /// Version requirements for user namespace. + /// + /// # Panics + /// Panics if the parsing fails + static ref USERNS_REQUIREMENT: VersionReq = { + VersionReq::parse(">= 1.24") + .expect("Unable to parse version requirements") + }; +} + +/// Add the `userns` flag, if needed +pub fn docker_command(subcommand: &str) -> Command { + let mut docker = Command::new("docker"); + docker.arg(subcommand); + if USERNS_REQUIREMENT.matches(&DOCKER_VERSION) { + docker.args(&["--userns", "host"]); + } + docker +} + /// Register QEMU interpreters pub fn register(verbose: bool) -> Result<()> { - Command::new("docker") - .arg("run") + docker_command("run") .arg("--privileged") .arg("--rm") .arg("-it") @@ -64,10 +101,9 @@ pub fn run(target: &Target, .run(verbose) .chain_err(|| "couldn't generate Cargo.lock")?; - let mut docker = Command::new("docker"); + let mut docker = docker_command("run"); docker - .arg("run") .arg("--rm") .args(&["--user", &format!("{}:{}", id::user(), id::group())]) .args(&["-e", "CARGO_HOME=/cargo"]) diff --git a/src/main.rs b/src/main.rs index f8a70251f..a64ded7d5 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,7 +1,10 @@ #[macro_use] extern crate error_chain; +#[macro_use] +extern crate lazy_static; extern crate libc; extern crate rustc_version; +extern crate semver; extern crate toml; mod cargo; From 6bc82386e1f741236e604de3b110c78823d26eeb Mon Sep 17 00:00:00 2001 From: Jorge Aparicio Date: Wed, 17 May 2017 07:17:38 -0500 Subject: [PATCH 07/35] bump qemu version to 2.9.0 --- docker/aarch64-unknown-linux-gnu/Dockerfile | 2 +- docker/arm-unknown-linux-gnueabi/Dockerfile | 2 +- docker/arm-unknown-linux-musleabi/Dockerfile | 2 +- docker/armv7-unknown-linux-gnueabihf/Dockerfile | 2 +- docker/armv7-unknown-linux-musleabihf/Dockerfile | 2 +- docker/mips-unknown-linux-gnu/Dockerfile | 2 +- docker/mips64-unknown-linux-gnuabi64/Dockerfile | 2 +- docker/mips64el-unknown-linux-gnuabi64/Dockerfile | 2 +- docker/mipsel-unknown-linux-gnu/Dockerfile | 2 +- docker/powerpc-unknown-linux-gnu/Dockerfile | 2 +- docker/powerpc64-unknown-linux-gnu/Dockerfile | 2 +- docker/powerpc64le-unknown-linux-gnu/Dockerfile | 2 +- docker/qemu.sh | 7 ++++--- docker/s390x-unknown-linux-gnu/Dockerfile | 2 +- docker/sparc64-unknown-linux-gnu/Dockerfile | 2 +- docker/thumbv6m-none-eabi/Dockerfile | 2 +- docker/thumbv7em-none-eabi/Dockerfile | 2 +- docker/thumbv7em-none-eabihf/Dockerfile | 2 +- docker/thumbv7m-none-eabi/Dockerfile | 2 +- 19 files changed, 22 insertions(+), 21 deletions(-) diff --git a/docker/aarch64-unknown-linux-gnu/Dockerfile b/docker/aarch64-unknown-linux-gnu/Dockerfile index a65385e94..5d2f96466 100644 --- a/docker/aarch64-unknown-linux-gnu/Dockerfile +++ b/docker/aarch64-unknown-linux-gnu/Dockerfile @@ -17,7 +17,7 @@ RUN apt-get install -y --no-install-recommends \ g++-aarch64-linux-gnu \ libc6-dev-arm64-cross && \ bash /openssl.sh linux-aarch64 aarch64-linux-gnu- && \ - bash /qemu.sh 2.8.0 aarch64 + bash /qemu.sh aarch64 ENV CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER=aarch64-linux-gnu-gcc \ CC_aarch64_unknown_linux_gnu=aarch64-linux-gnu-gcc \ diff --git a/docker/arm-unknown-linux-gnueabi/Dockerfile b/docker/arm-unknown-linux-gnueabi/Dockerfile index 4244386ea..66886d420 100644 --- a/docker/arm-unknown-linux-gnueabi/Dockerfile +++ b/docker/arm-unknown-linux-gnueabi/Dockerfile @@ -17,7 +17,7 @@ RUN apt-get install -y --no-install-recommends \ g++-arm-linux-gnueabi \ libc6-dev-armel-cross && \ bash /openssl.sh linux-armv4 arm-linux-gnueabi- && \ - bash /qemu.sh 2.8.0 arm + bash /qemu.sh arm ENV CARGO_TARGET_ARM_UNKNOWN_LINUX_GNUEABI_LINKER=arm-linux-gnueabi-gcc \ CC_arm_unknown_linux_gnueabi=arm-linux-gnueabi-gcc \ diff --git a/docker/arm-unknown-linux-musleabi/Dockerfile b/docker/arm-unknown-linux-musleabi/Dockerfile index 6e022d60b..c94547dd1 100644 --- a/docker/arm-unknown-linux-musleabi/Dockerfile +++ b/docker/arm-unknown-linux-musleabi/Dockerfile @@ -13,7 +13,7 @@ COPY xargo.sh / RUN bash /xargo.sh COPY qemu.sh / -RUN bash /qemu.sh 2.8.0 arm +RUN bash /qemu.sh arm RUN apt-get install -y --no-install-recommends \ gcc-arm-linux-gnueabi diff --git a/docker/armv7-unknown-linux-gnueabihf/Dockerfile b/docker/armv7-unknown-linux-gnueabihf/Dockerfile index 540d1c830..272d37e72 100644 --- a/docker/armv7-unknown-linux-gnueabihf/Dockerfile +++ b/docker/armv7-unknown-linux-gnueabihf/Dockerfile @@ -21,7 +21,7 @@ RUN apt-get install -y --no-install-recommends \ g++-arm-linux-gnueabihf \ libc6-dev-armhf-cross && \ bash /openssl.sh linux-armv4 arm-linux-gnueabihf- && \ - bash /qemu.sh 2.8.0 arm + bash /qemu.sh arm ENV CARGO_TARGET_ARMV7_UNKNOWN_LINUX_GNUEABIHF_LINKER=arm-linux-gnueabihf-gcc \ CC_armv7_unknown_linux_gnueabihf=arm-linux-gnueabihf-gcc \ diff --git a/docker/armv7-unknown-linux-musleabihf/Dockerfile b/docker/armv7-unknown-linux-musleabihf/Dockerfile index 55ed93c6e..c08497b3a 100644 --- a/docker/armv7-unknown-linux-musleabihf/Dockerfile +++ b/docker/armv7-unknown-linux-musleabihf/Dockerfile @@ -13,7 +13,7 @@ COPY xargo.sh / RUN bash /xargo.sh COPY qemu.sh / -RUN bash /qemu.sh 2.8.0 arm +RUN bash /qemu.sh arm RUN apt-get install -y --no-install-recommends \ gcc-arm-linux-gnueabihf diff --git a/docker/mips-unknown-linux-gnu/Dockerfile b/docker/mips-unknown-linux-gnu/Dockerfile index 2e9125327..1c9a6c037 100644 --- a/docker/mips-unknown-linux-gnu/Dockerfile +++ b/docker/mips-unknown-linux-gnu/Dockerfile @@ -17,7 +17,7 @@ RUN apt-get install -y --no-install-recommends \ g++-mips-linux-gnu \ libc6-dev-mips-cross && \ bash /openssl.sh linux-mips32 mips-linux-gnu- && \ - bash /qemu.sh 2.8.0 mips + bash /qemu.sh mips ENV CARGO_TARGET_MIPS_UNKNOWN_LINUX_GNU_LINKER=mips-linux-gnu-gcc \ CC_mips_unknown_linux_gnu=mips-linux-gnu-gcc \ diff --git a/docker/mips64-unknown-linux-gnuabi64/Dockerfile b/docker/mips64-unknown-linux-gnuabi64/Dockerfile index 6be18738c..d46e3b2b7 100644 --- a/docker/mips64-unknown-linux-gnuabi64/Dockerfile +++ b/docker/mips64-unknown-linux-gnuabi64/Dockerfile @@ -17,7 +17,7 @@ RUN apt-get install -y --no-install-recommends \ g++-mips64-linux-gnuabi64 \ libc6-dev-mips64-cross && \ bash /openssl.sh linux64-mips64 mips64-linux-gnuabi64- && \ - bash /qemu.sh 2.8.0 mips64 + bash /qemu.sh mips64 ENV CARGO_TARGET_MIPS64_UNKNOWN_LINUX_GNUABI64_LINKER=mips64-linux-gnuabi64-gcc \ CC_mips64_unknown_linux_gnuabi64=mips64-linux-gnuabi64-gcc \ diff --git a/docker/mips64el-unknown-linux-gnuabi64/Dockerfile b/docker/mips64el-unknown-linux-gnuabi64/Dockerfile index 87d0f96fd..002b0e468 100644 --- a/docker/mips64el-unknown-linux-gnuabi64/Dockerfile +++ b/docker/mips64el-unknown-linux-gnuabi64/Dockerfile @@ -17,7 +17,7 @@ RUN apt-get install -y --no-install-recommends \ g++-mips64el-linux-gnuabi64 \ libc6-dev-mips64el-cross && \ bash /openssl.sh linux64-mips64 mips64el-linux-gnuabi64- && \ - bash /qemu.sh 2.8.0 mips64el + bash /qemu.sh mips64el ENV CARGO_TARGET_MIPS64EL_UNKNOWN_LINUX_GNUABI64_LINKER=mips64el-linux-gnuabi64-gcc \ CC_mips64el_unknown_linux_gnuabi64=mips64el-linux-gnuabi64-gcc \ diff --git a/docker/mipsel-unknown-linux-gnu/Dockerfile b/docker/mipsel-unknown-linux-gnu/Dockerfile index ccb982ebe..d5c361b62 100644 --- a/docker/mipsel-unknown-linux-gnu/Dockerfile +++ b/docker/mipsel-unknown-linux-gnu/Dockerfile @@ -17,7 +17,7 @@ RUN apt-get install -y --no-install-recommends \ g++-mipsel-linux-gnu \ libc6-dev-mipsel-cross && \ bash /openssl.sh linux-mips32 mipsel-linux-gnu- && \ - bash /qemu.sh 2.8.0 mipsel + bash /qemu.sh mipsel ENV CARGO_TARGET_MIPSEL_UNKNOWN_LINUX_GNU_LINKER=mipsel-linux-gnu-gcc \ CC_mipsel_unknown_linux_gnu=mipsel-linux-gnu-gcc \ diff --git a/docker/powerpc-unknown-linux-gnu/Dockerfile b/docker/powerpc-unknown-linux-gnu/Dockerfile index d49ddd9d3..dca3373e7 100644 --- a/docker/powerpc-unknown-linux-gnu/Dockerfile +++ b/docker/powerpc-unknown-linux-gnu/Dockerfile @@ -17,7 +17,7 @@ RUN apt-get install -y --no-install-recommends \ g++-powerpc-linux-gnu \ libc6-dev-powerpc-cross && \ bash /openssl.sh linux-ppc powerpc-linux-gnu- && \ - bash /qemu.sh 2.7.1 ppc + bash /qemu.sh ppc ENV CARGO_TARGET_POWERPC_UNKNOWN_LINUX_GNU_LINKER=powerpc-linux-gnu-gcc \ CC_powerpc_unknown_linux_gnu=powerpc-linux-gnu-gcc \ diff --git a/docker/powerpc64-unknown-linux-gnu/Dockerfile b/docker/powerpc64-unknown-linux-gnu/Dockerfile index 03f8fe376..987fe557f 100644 --- a/docker/powerpc64-unknown-linux-gnu/Dockerfile +++ b/docker/powerpc64-unknown-linux-gnu/Dockerfile @@ -17,7 +17,7 @@ RUN apt-get install -y --no-install-recommends \ g++-powerpc64-linux-gnu \ libc6-dev-ppc64-cross && \ bash /openssl.sh linux-ppc64 powerpc64-linux-gnu- && \ - bash /qemu.sh 2.7.1 ppc64 + bash /qemu.sh ppc64 ENV CARGO_TARGET_POWERPC64_UNKNOWN_LINUX_GNU_LINKER=powerpc64-linux-gnu-gcc \ CC_powerpc64_unknown_linux_gnu=powerpc64-linux-gnu-gcc \ diff --git a/docker/powerpc64le-unknown-linux-gnu/Dockerfile b/docker/powerpc64le-unknown-linux-gnu/Dockerfile index 9f8bc8564..fa6f88845 100644 --- a/docker/powerpc64le-unknown-linux-gnu/Dockerfile +++ b/docker/powerpc64le-unknown-linux-gnu/Dockerfile @@ -17,7 +17,7 @@ RUN apt-get install -y --no-install-recommends \ g++-powerpc64le-linux-gnu \ libc6-dev-ppc64el-cross && \ bash /openssl.sh linux-ppc64le powerpc64le-linux-gnu- && \ - bash /qemu.sh 2.7.1 ppc64le + bash /qemu.sh ppc64le ENV CARGO_TARGET_POWERPC64LE_UNKNOWN_LINUX_GNU_LINKER=powerpc64le-linux-gnu-gcc \ CC_powerpc64le_unknown_linux_gnu=powerpc64le-linux-gnu-gcc \ diff --git a/docker/qemu.sh b/docker/qemu.sh index 1594a6137..b3ae1211e 100644 --- a/docker/qemu.sh +++ b/docker/qemu.sh @@ -1,9 +1,10 @@ set -ex main() { - local arch=$2 \ - td=$(mktemp -d) \ - version=$1 + local version=2.9.0 + + local arch=$1 \ + td=$(mktemp -d) local dependencies=( autoconf diff --git a/docker/s390x-unknown-linux-gnu/Dockerfile b/docker/s390x-unknown-linux-gnu/Dockerfile index 33e3a99cb..05691f110 100644 --- a/docker/s390x-unknown-linux-gnu/Dockerfile +++ b/docker/s390x-unknown-linux-gnu/Dockerfile @@ -17,7 +17,7 @@ RUN apt-get install -y --no-install-recommends \ g++-s390x-linux-gnu \ libc6-dev-s390x-cross && \ bash /openssl.sh linux64-s390x s390x-linux-gnu- && \ - bash /qemu.sh 2.8.0 s390x + bash /qemu.sh s390x ENV CARGO_TARGET_S390X_UNKNOWN_LINUX_GNU_LINKER=s390x-linux-gnu-gcc \ CC_s390x_unknown_linux_gnu=s390x-linux-gnu-gcc \ diff --git a/docker/sparc64-unknown-linux-gnu/Dockerfile b/docker/sparc64-unknown-linux-gnu/Dockerfile index 0cf3a89df..697ed56b5 100644 --- a/docker/sparc64-unknown-linux-gnu/Dockerfile +++ b/docker/sparc64-unknown-linux-gnu/Dockerfile @@ -17,7 +17,7 @@ RUN apt-get install -y --no-install-recommends \ g++-sparc64-linux-gnu \ libc6-dev-sparc64-cross && \ bash /openssl.sh linux64-sparcv9 sparc64-linux-gnu- && \ - bash /qemu.sh 2.8.0 sparc64 + bash /qemu.sh sparc64 ENV CARGO_TARGET_SPARC64_UNKNOWN_LINUX_GNU_LINKER=sparc64-linux-gnu-gcc \ CC_sparc64_unknown_linux_gnu=sparc64-linux-gnu-gcc \ diff --git a/docker/thumbv6m-none-eabi/Dockerfile b/docker/thumbv6m-none-eabi/Dockerfile index f148bab3c..7668e60a4 100644 --- a/docker/thumbv6m-none-eabi/Dockerfile +++ b/docker/thumbv6m-none-eabi/Dockerfile @@ -16,6 +16,6 @@ COPY qemu.sh / RUN apt-get install -y --no-install-recommends \ gcc-arm-none-eabi \ libnewlib-arm-none-eabi && \ - bash /qemu.sh 2.8.0 arm + bash /qemu.sh arm ENV QEMU_CPU=cortex-m3 diff --git a/docker/thumbv7em-none-eabi/Dockerfile b/docker/thumbv7em-none-eabi/Dockerfile index 9ec937975..87bc61976 100644 --- a/docker/thumbv7em-none-eabi/Dockerfile +++ b/docker/thumbv7em-none-eabi/Dockerfile @@ -16,6 +16,6 @@ COPY qemu.sh / RUN apt-get install -y --no-install-recommends \ gcc-arm-none-eabi \ libnewlib-arm-none-eabi && \ - bash /qemu.sh 2.8.0 arm + bash /qemu.sh arm ENV QEMU_CPU=cortex-m4 diff --git a/docker/thumbv7em-none-eabihf/Dockerfile b/docker/thumbv7em-none-eabihf/Dockerfile index 9ec937975..87bc61976 100644 --- a/docker/thumbv7em-none-eabihf/Dockerfile +++ b/docker/thumbv7em-none-eabihf/Dockerfile @@ -16,6 +16,6 @@ COPY qemu.sh / RUN apt-get install -y --no-install-recommends \ gcc-arm-none-eabi \ libnewlib-arm-none-eabi && \ - bash /qemu.sh 2.8.0 arm + bash /qemu.sh arm ENV QEMU_CPU=cortex-m4 diff --git a/docker/thumbv7m-none-eabi/Dockerfile b/docker/thumbv7m-none-eabi/Dockerfile index f148bab3c..7668e60a4 100644 --- a/docker/thumbv7m-none-eabi/Dockerfile +++ b/docker/thumbv7m-none-eabi/Dockerfile @@ -16,6 +16,6 @@ COPY qemu.sh / RUN apt-get install -y --no-install-recommends \ gcc-arm-none-eabi \ libnewlib-arm-none-eabi && \ - bash /qemu.sh 2.8.0 arm + bash /qemu.sh arm ENV QEMU_CPU=cortex-m3 From a5c1aa5e7af66df7870759997645fca47bdf8893 Mon Sep 17 00:00:00 2001 From: Marco A L Barbosa Date: Tue, 18 Apr 2017 08:35:34 -0300 Subject: [PATCH 08/35] Add test support for X86_64-pc-windows-gnu --- ci/script.sh | 6 ++--- docker/windows-entry.sh | 19 ++++++++++++++++ docker/x86_64-pc-windows-gnu/Dockerfile | 30 ++++++++++++++++++++++--- src/cargo.rs | 2 +- src/docker.rs | 16 ++++++++----- src/interpreter.rs | 28 +++++++++++++++++++++++ src/main.rs | 14 ++++++------ src/qemu.rs | 19 ---------------- 8 files changed, 95 insertions(+), 39 deletions(-) create mode 100755 docker/windows-entry.sh create mode 100644 src/interpreter.rs delete mode 100644 src/qemu.rs diff --git a/ci/script.sh b/ci/script.sh index f4de189a6..1001915bd 100644 --- a/ci/script.sh +++ b/ci/script.sh @@ -3,11 +3,11 @@ set -ex main() { local td= - if [ $TRAVIS_OS_NAME = linux ]; then + if [ "$TRAVIS_OS_NAME" = linux ]; then ./build-docker-image.sh $TARGET fi - if [ $TRAVIS_BRANCH = master ] || [ ! -z $TRAVIS_TAG ]; then + if [ "$TRAVIS_BRANCH" = master ] || [ ! -z "$TRAVIS_TAG" ]; then return fi @@ -34,7 +34,7 @@ main() { esac # `cross build` test for targets where `std` is not available - if [ -z $STD ]; then + if [ -z "$STD" ]; then td=$(mktemp -d) git clone \ diff --git a/docker/windows-entry.sh b/docker/windows-entry.sh new file mode 100755 index 000000000..0914919b5 --- /dev/null +++ b/docker/windows-entry.sh @@ -0,0 +1,19 @@ +#!/bin/bash + +set -e + +export HOME=/tmp/home +mkdir -p $HOME + +# Initialize the wine prefix (virtual windows installation) +export WINEPREFIX=/tmp/wine +mkdir -p $WINEPREFIX +# FIXME: Make the wine prefix initialization faster +wineboot &> /dev/null + +# Put libstdc++ and some other mingw dlls in WINEPATH +# This must work for x86_64 and i686 +P1=$(dirname $(find /usr -name libwinpthread-1.dll)) +export WINEPATH="$(ls -d /usr/lib/gcc/*-w64-mingw32/*win32);$P1" + +exec "$@" diff --git a/docker/x86_64-pc-windows-gnu/Dockerfile b/docker/x86_64-pc-windows-gnu/Dockerfile index f0f8ee5a4..e01aaf458 100644 --- a/docker/x86_64-pc-windows-gnu/Dockerfile +++ b/docker/x86_64-pc-windows-gnu/Dockerfile @@ -1,4 +1,5 @@ -FROM ubuntu:16.04 +# wine in ubuntu versions less than 17.04 hangs in the tests +FROM ubuntu:17.04 RUN apt-get update && \ apt-get install -y --no-install-recommends \ @@ -9,8 +10,31 @@ RUN apt-get update && \ make \ pkg-config -RUN apt-get install -y --no-install-recommends \ - g++-mingw-w64-x86-64 +COPY xargo.sh / +RUN bash /xargo.sh + +RUN dpkg --add-architecture i386 && apt-get update && \ + apt-get install -y --no-install-recommends \ + wine-stable \ + wine64 \ + wine32 \ + libz-mingw-w64-dev + +RUN apt-get install -y --no-install-recommends g++-mingw-w64-x86-64 + +# run-detectors are responsible for calling the correct interpreter for exe +# files. For some reason it does not work inside a docker container (it works +# fine in the host). So we replace the usual paths of run-detectors to run wine +# directly. This only affects the guest, we are not messing up with the host. +# +# See /usr/share/doc/binfmt-support/detectors +RUN mkdir -p /usr/lib/binfmt-support/ && \ + rm -f /usr/lib/binfmt-support/run-detectors /usr/bin/run-detectors && \ + ln -s /usr/bin/wine /usr/lib/binfmt-support/run-detectors && \ + ln -s /usr/bin/wine /usr/bin/run-detectors + +COPY windows-entry.sh / +ENTRYPOINT ["/windows-entry.sh"] ENV CARGO_TARGET_X86_64_PC_WINDOWS_GNU_LINKER=x86_64-w64-mingw32-gcc \ CC_x86_64_pc_windows_gnu=x86_64-w64-mingw32-gcc \ diff --git a/src/cargo.rs b/src/cargo.rs index 89bb45f10..10abc8bbf 100644 --- a/src/cargo.rs +++ b/src/cargo.rs @@ -22,7 +22,7 @@ impl Subcommand { } } - pub fn needs_qemu(&self) -> bool { + pub fn needs_interpreter(&self) -> bool { match *self { Subcommand::Run | Subcommand::Test => true, _ => false, diff --git a/src/docker.rs b/src/docker.rs index bde3fd012..b7d089ad4 100644 --- a/src/docker.rs +++ b/src/docker.rs @@ -48,17 +48,21 @@ pub fn docker_command(subcommand: &str) -> Command { docker } -/// Register QEMU interpreters -pub fn register(verbose: bool) -> Result<()> { +/// Register binfmt interpreters +pub fn register(target: &Target, verbose: bool) -> Result<()> { + let cmd = if target.is_windows() { + // https://www.kernel.org/doc/html/latest/admin-guide/binfmt-misc.html + "echo ':DOSWin:M::MZ::/usr/bin/run-detectors' > /proc/sys/fs/binfmt_misc/register" + } else { + "apt-get update && apt-get install --no-install-recommends -y \ + binfmt-support qemu-user-static" + }; docker_command("run") .arg("--privileged") .arg("--rm") .arg("-it") .arg("ubuntu:16.04") - .args(&["sh", - "-c", - "apt-get update && apt-get install --no-install-recommends \ - -y binfmt-support qemu-user-static"]) + .args(&["sh", "-c", cmd]) .run(verbose) } diff --git a/src/interpreter.rs b/src/interpreter.rs new file mode 100644 index 000000000..f7d828742 --- /dev/null +++ b/src/interpreter.rs @@ -0,0 +1,28 @@ +use std::path::Path; + +use errors::*; +use file; +use Target; + +/// Checks if the interpreters have been registered in the host system +pub fn is_registered(target: &Target) -> Result { + if file::read("/proc/sys/fs/binfmt_misc/status")?.trim() != "enabled" { + Err("host system doesn't have binfmt_misc support")? + } + + let ok = if target.is_windows() { + let wine = Path::new("/proc/sys/fs/binfmt_misc/wine"); + wine.exists() && + { + let f = file::read(wine)?; + f.contains("/usr/bin/run-detectors") || + f.contains("/usr/lib/binfmt-support/run-detectors") + } + } else { + // NOTE checking any architecture will do, here we pick arm + let qemu = Path::new("/proc/sys/fs/binfmt_misc/qemu-arm"); + qemu.exists() && file::read(qemu)?.contains("/usr/bin/qemu-arm-static") + }; + + Ok(ok) +} diff --git a/src/main.rs b/src/main.rs index a64ded7d5..b91808279 100644 --- a/src/main.rs +++ b/src/main.rs @@ -14,7 +14,7 @@ mod errors; mod extensions; mod file; mod id; -mod qemu; +mod interpreter; mod rustc; mod rustup; @@ -201,7 +201,7 @@ impl Target { !self.is_builtin() || self.is_windows() } - fn needs_qemu(&self) -> bool { + fn needs_interpreter(&self) -> bool { let not_native = match *self { Target::Custom { ref triple } => { return !triple.starts_with("x86_64") && @@ -215,7 +215,7 @@ impl Target { _ => true, }; - not_native && (self.is_linux() || self.is_bare_metal()) + not_native && (self.is_linux() || self.is_windows() || self.is_bare_metal()) } fn triple(&self) -> &str { @@ -394,10 +394,10 @@ fn run() -> Result { if target.needs_docker() && args.subcommand.map(|sc| sc.needs_docker()).unwrap_or(false) { - if args.subcommand.map(|sc| sc.needs_qemu()).unwrap_or(false) && - target.needs_qemu() && - !qemu::is_registered()? { - docker::register(verbose)? + if 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/qemu.rs b/src/qemu.rs deleted file mode 100644 index 09b9bb6e5..000000000 --- a/src/qemu.rs +++ /dev/null @@ -1,19 +0,0 @@ -use std::path::Path; - -use errors::*; -use file; - -/// Checks if the QEMU interpreters have been registered in the host system -pub fn is_registered() -> Result { - if file::read("/proc/sys/fs/binfmt_misc/status")?.trim() != "enabled" { - Err("host system doesn't have binfmt_misc support")? - } - - // NOTE checking any architecture will do, here we pick arm - let interpreter = Path::new("/proc/sys/fs/binfmt_misc/qemu-arm"); - - Ok(interpreter.exists() && - file::read(interpreter) - ? - .contains("/usr/bin/qemu-arm-static")) -} From aa1f929ad4b4684e4ccbe21020237c01f12601b2 Mon Sep 17 00:00:00 2001 From: Marco A L Barbosa Date: Tue, 18 Apr 2017 09:29:36 -0300 Subject: [PATCH 09/35] Add support for i686-pc-windows-gnu --- docker/i686-pc-windows-gnu/Dockerfile | 43 ++++++++++++ docker/mingw.sh | 98 +++++++++++++++++++++++++++ src/main.rs | 4 ++ 3 files changed, 145 insertions(+) create mode 100644 docker/i686-pc-windows-gnu/Dockerfile create mode 100644 docker/mingw.sh diff --git a/docker/i686-pc-windows-gnu/Dockerfile b/docker/i686-pc-windows-gnu/Dockerfile new file mode 100644 index 000000000..8f6cbb955 --- /dev/null +++ b/docker/i686-pc-windows-gnu/Dockerfile @@ -0,0 +1,43 @@ +# wine in ubuntu versions less than 17.04 hangs in the tests +FROM ubuntu:17.04 + +RUN apt-get update && \ + apt-get install -y --no-install-recommends \ + ca-certificates \ + cmake \ + gcc \ + libc6-dev \ + make \ + pkg-config + +COPY xargo.sh / +RUN bash /xargo.sh + +RUN dpkg --add-architecture i386 && apt-get update && \ + apt-get install -y --no-install-recommends \ + wine-stable \ + wine64 \ + wine32 \ + libz-mingw-w64-dev + +# Build mingw tools using dwarf exceptions +COPY mingw.sh / +RUN bash mingw.sh + +# run-detectors are responsible for calling the correct interpreter for exe +# files. For some reason it does not work inside a docker container (it works +# fine in the host). So we replace the usual paths of run-detectors to run wine +# directly. This only affects the guest, we are not messing up with the host. +# +# See /usr/share/doc/binfmt-support/detectors +RUN mkdir -p /usr/lib/binfmt-support/ && \ + rm -f /usr/lib/binfmt-support/run-detectors /usr/bin/run-detectors && \ + ln -s /usr/bin/wine /usr/lib/binfmt-support/run-detectors && \ + ln -s /usr/bin/wine /usr/bin/run-detectors + +COPY windows-entry.sh / +ENTRYPOINT ["/windows-entry.sh"] + +ENV CARGO_TARGET_I686_PC_WINDOWS_GNU_LINKER=i686-w64-mingw32-gcc \ + CC_i686_pc_windows_gnu=i686-w64-mingw32-gcc \ + CXX_i686_pc_windows_gnu=i686-w64-mingw32-g++ diff --git a/docker/mingw.sh b/docker/mingw.sh new file mode 100644 index 000000000..ec7c2a554 --- /dev/null +++ b/docker/mingw.sh @@ -0,0 +1,98 @@ +set -x + +main() { + # Ubuntu mingw packages for i686 uses sjlj exceptions, but rust target + # i686-pc-windows-gnu uses dwarf exceptions. So we build mingw packages + # that are compatible with rust. + + # Install mingw (with sjlj exceptions) to get the dependencies right + # Later we replace these packages with the new ones + apt-get install -y --no-install-recommends g++-mingw-w64-i686 + + local td=$(mktemp -d) + + local dependencies=( + build-essential + $(apt-cache showsrc gcc-mingw-w64-i686 | grep Build | cut -d: -f2 | tr , '\n' | cut -d' ' -f2 | sort | uniq) + ) + + apt-get update + local purge_list=() + for dep in ${dependencies[@]}; do + if ! dpkg -L $dep; then + apt-get install --no-install-recommends -y $dep + purge_list+=( $dep ) + fi + done + + # The build fails with the default gcc-6-source version (6.3.0-12ubuntu2) + # Downgrading to the previous version makes the build works + echo "deb http://archive.ubuntu.com/ubuntu yakkety main universe" >> /etc/apt/sources.list + apt-get update + apt-get install -y --no-install-recommends --allow-downgrades gcc-6-source=6.2.0-5ubuntu12 + + pushd $td + + apt-get source gcc-mingw-w64-i686 + cd gcc-mingw-w64-* + + # We are using dwarf exceptions instead of sjlj + sed -i -e 's/libgcc_s_sjlj-1/libgcc_s_dw2-1/g' debian/gcc-mingw-w64-i686.install + + # Disable build of fortran,objc,obj-c++ and use configure options + # --disable-sjlj-exceptions --with-dwarf2 + # + # We are building x86_64 packages, this takes time, but disable x86_64 is + # difficult + # + # TODO: disable x86_64 packages creation + patch -p0 <<'EOF' +--- debian/rules.ori 2016-08-20 15:24:54.000000000 +0000 ++++ debian/rules +@@ -57,9 +57,7 @@ + INSTALL_TARGET := install-gcc + else + # Build the full GCC. +- languages := c,c++,fortran,objc,obj-c++ +- debian_extra_langs := ada +- export debian_extra_langs ++ languages := c,c++ + BUILD_TARGET := + INSTALL_TARGET := install install-lto-plugin + endif +@@ -249,12 +247,16 @@ + cat debian/control + echo ====================================================================== + for target in $(targets); do \ ++ extra=""; \ ++ if [ $$target = "i686-w64-mingw32" ]; then \ ++ extra="--disable-sjlj-exceptions --with-dwarf2"; \ ++ fi; \ + for threads in $(threads); do \ + echo $(base_version)-$$threads > $(upstream_dir)/gcc/BASE-VER && \ + dh_auto_configure \ + -B$(build_dir)/$$target-$$threads \ + -D$(upstream_dir) -- \ +- $(CONFFLAGS); \ ++ $(CONFFLAGS) $$extra; \ + done; \ + done + touch $@ +EOF + + # Build the modified mingw packages + dpkg-buildpackage -b + + # Replace installed mingw packages with the new ones + dpkg -i ../g*-mingw-w64-i686*.deb ../gcc-mingw-w64-base*.deb + + # Clean up + apt-get purge --auto-remove -y ${purge_list[@]} + + popd + + rm -rf $td + rm $0 +} + +main "${@}" diff --git a/src/main.rs b/src/main.rs index b91808279..6871f6de2 100644 --- a/src/main.rs +++ b/src/main.rs @@ -119,6 +119,7 @@ pub enum Target { // Windows X86_64PcWindowsGnu, + I686PcWindowsGnu, // Bare metal Thumbv6mNoneEabi, @@ -191,6 +192,7 @@ impl Target { fn is_windows(&self) -> bool { match *self { + Target::I686PcWindowsGnu => true, Target::X86_64PcWindowsGnu => true, _ => false, } @@ -235,6 +237,7 @@ impl Target { Armv7UnknownLinuxMusleabihf => "armv7-unknown-linux-musleabihf", I686AppleDarwin => "i686-apple-darwin", I686LinuxAndroid => "i686-linux-android", + I686PcWindowsGnu => "i686-pc-windows-gnu", I686UnknownFreebsd => "i686-unknown-freebsd", I686UnknownLinuxGnu => "i686-unknown-linux-gnu", I686UnknownLinuxMusl => "i686-unknown-linux-musl", @@ -281,6 +284,7 @@ impl Target { "armv7-unknown-linux-musleabihf" => Armv7UnknownLinuxMusleabihf, "i686-apple-darwin" => I686AppleDarwin, "i686-linux-android" => I686LinuxAndroid, + "i686-pc-windows-gnu" => I686PcWindowsGnu, "i686-unknown-freebsd" => I686UnknownFreebsd, "i686-unknown-linux-gnu" => I686UnknownLinuxGnu, "i686-unknown-linux-musl" => I686UnknownLinuxMusl, From 24fd3dfcd1d0fd3221c7c6fabfd1f11c2cce21a9 Mon Sep 17 00:00:00 2001 From: Marco A L Barbosa Date: Tue, 18 Apr 2017 09:32:47 -0300 Subject: [PATCH 10/35] Enable travis tests for {x86_64, i686}-pc-windows-gnu --- .travis.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index d4ebd3238..a0160b429 100644 --- a/.travis.yml +++ b/.travis.yml @@ -44,7 +44,8 @@ matrix: - env: TARGET=x86_64-unknown-netbsd DYLIB=1 STD=1 OPENSSL=0.7.17 # Windows - - env: TARGET=x86_64-pc-windows-gnu CPP=1 DYLIB=1 STD=1 + - env: TARGET=x86_64-pc-windows-gnu CPP=1 DYLIB=1 STD=1 OPENSSL=0.7.17 RUN=1 + - env: TARGET=i686-pc-windows-gnu CPP=1 DYLIB=1 STD=1 OPENSSL=0.7.17 RUN=1 # Bare metal - env: TARGET=thumbv6m-none-eabi RUN=1 From 17fe723dc4378d3da3c6e1ef221dd029f8719056 Mon Sep 17 00:00:00 2001 From: Marco A L Barbosa Date: Wed, 19 Apr 2017 15:52:21 -0300 Subject: [PATCH 11/35] Update *-pc-windows-gnu info on README.md --- README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 879b534c8..1306a3758 100644 --- a/README.md +++ b/README.md @@ -165,6 +165,7 @@ worst, "hang" (never terminate). | `armv7-unknown-linux-gnueabihf` | 2.15 | 4.6.2 | 1.0.2k | ✓ | 2.8.0 | ✓ | | `armv7-unknown-linux-musleabihf` | 1.1.15 | 5.3.1 | N/A | | 2.8.0 | ✓ | | `i686-linux-android` | N/A | 4.9 | 1.0.2k | ✓ | N/A | | +| `i686-pc-windows-gnu` | N/A | 6.2.0 | N/A | ✓ | N/A | ✓ | | `i686-unknown-freebsd` [1] | 10.2 | 5.3.0 | 1.0.2k | | N/A | | | `i686-unknown-linux-gnu` | 2.15 | 4.6.2 | 1.0.2k | ✓ | N/A | ✓ | | `i686-unknown-linux-musl` | 1.1.15 | 5.3.1 | N/A | | N/A | ✓ | @@ -181,7 +182,7 @@ worst, "hang" (never terminate). | `thumbv7em-none-eabi` [3] | 2.2.0 | 5.3.1 | N/A | | N/A | | | `thumbv7em-none-eabihf` [3] | 2.2.0 | 5.3.1 | N/A | | N/A | | | `thumbv7m-none-eabi` [3] | 2.2.0 | 5.3.1 | N/A | | N/A | | -| `x86_64-pc-windows-gnu`[1] | N/A | 5.3.1 | | ✓ | N/A | | +| `x86_64-pc-windows-gnu` | N/A | 6.2.0 | N/A | ✓ | N/A | ✓ | | `x86_64-unknown-dragonfly` [1] [2] | 4.6.0 | 5.3.0 | 1.0.2k | | N/A | ✓ | | `x86_64-unknown-freebsd` [1] | 10.2 | 5.3.0 | 1.0.2k | | N/A | | | `x86_64-unknown-linux-gnu` | 2.15 | 4.6.2 | 1.0.2k | ✓ | N/A | ✓ | From 2ff5d8a66505510dfb7b0a628424f2a61eabe57f Mon Sep 17 00:00:00 2001 From: Marco A L Barbosa Date: Wed, 19 Apr 2017 15:52:21 -0300 Subject: [PATCH 12/35] Fix wine registration --- src/docker.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/docker.rs b/src/docker.rs index b7d089ad4..5b61612af 100644 --- a/src/docker.rs +++ b/src/docker.rs @@ -52,7 +52,8 @@ pub fn docker_command(subcommand: &str) -> Command { pub fn register(target: &Target, verbose: bool) -> Result<()> { let cmd = if target.is_windows() { // https://www.kernel.org/doc/html/latest/admin-guide/binfmt-misc.html - "echo ':DOSWin:M::MZ::/usr/bin/run-detectors' > /proc/sys/fs/binfmt_misc/register" + "mount binfmt_misc -t binfmt_misc /proc/sys/fs/binfmt_misc && \ + echo ':DOSWin:M::MZ::/usr/bin/run-detectors' > /proc/sys/fs/binfmt_misc/register" } else { "apt-get update && apt-get install --no-install-recommends -y \ binfmt-support qemu-user-static" From 6e8c4102a00eda0c265a8e87c0d9bfe2e63d8315 Mon Sep 17 00:00:00 2001 From: Marco A L Barbosa Date: Thu, 20 Apr 2017 07:51:05 -0300 Subject: [PATCH 13/35] Make gcc-mingw build quieter --- docker/mingw.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docker/mingw.sh b/docker/mingw.sh index ec7c2a554..2541cf02b 100644 --- a/docker/mingw.sh +++ b/docker/mingw.sh @@ -81,7 +81,7 @@ main() { EOF # Build the modified mingw packages - dpkg-buildpackage -b + MAKEFLAGS=--silent dpkg-buildpackage -b # Replace installed mingw packages with the new ones dpkg -i ../g*-mingw-w64-i686*.deb ../gcc-mingw-w64-base*.deb From 3cb5275633bd936539169532b6ed71778dfba81b Mon Sep 17 00:00:00 2001 From: Marco A L Barbosa Date: Thu, 20 Apr 2017 17:59:34 -0300 Subject: [PATCH 14/35] Really fix wine registration --- src/docker.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/docker.rs b/src/docker.rs index 5b61612af..d568c7687 100644 --- a/src/docker.rs +++ b/src/docker.rs @@ -53,7 +53,7 @@ pub fn register(target: &Target, verbose: bool) -> Result<()> { let cmd = if target.is_windows() { // https://www.kernel.org/doc/html/latest/admin-guide/binfmt-misc.html "mount binfmt_misc -t binfmt_misc /proc/sys/fs/binfmt_misc && \ - echo ':DOSWin:M::MZ::/usr/bin/run-detectors' > /proc/sys/fs/binfmt_misc/register" + echo ':wine:M::MZ::/usr/bin/run-detectors:' > /proc/sys/fs/binfmt_misc/register" } else { "apt-get update && apt-get install --no-install-recommends -y \ binfmt-support qemu-user-static" From 1c94fc745adb3a704b1fca6fe0850bb4c4f6d191 Mon Sep 17 00:00:00 2001 From: Marco A L Barbosa Date: Mon, 24 Apr 2017 08:19:59 -0300 Subject: [PATCH 15/35] Do not build x86_64 mingw --- .travis.yml | 4 ++-- ci/script.sh | 1 - docker/mingw.sh | 52 ++++++++++++++++++++++++------------------------- 3 files changed, 27 insertions(+), 30 deletions(-) diff --git a/.travis.yml b/.travis.yml index a0160b429..8876258d6 100644 --- a/.travis.yml +++ b/.travis.yml @@ -44,8 +44,8 @@ matrix: - env: TARGET=x86_64-unknown-netbsd DYLIB=1 STD=1 OPENSSL=0.7.17 # Windows - - env: TARGET=x86_64-pc-windows-gnu CPP=1 DYLIB=1 STD=1 OPENSSL=0.7.17 RUN=1 - - env: TARGET=i686-pc-windows-gnu CPP=1 DYLIB=1 STD=1 OPENSSL=0.7.17 RUN=1 + - env: TARGET=x86_64-pc-windows-gnu CPP=1 STD=1 OPENSSL=0.7.17 RUN=1 + - env: TARGET=i686-pc-windows-gnu CPP=1 STD=1 OPENSSL=0.7.17 RUN=1 # Bare metal - env: TARGET=thumbv6m-none-eabi RUN=1 diff --git a/ci/script.sh b/ci/script.sh index 1001915bd..3057757bf 100644 --- a/ci/script.sh +++ b/ci/script.sh @@ -62,7 +62,6 @@ EOF git clone --depth 1 https://github.com/rust-lang/cargo $td pushd $td - cargo update -p libc cross build --target $TARGET popd diff --git a/docker/mingw.sh b/docker/mingw.sh index 2541cf02b..a6df2bf00 100644 --- a/docker/mingw.sh +++ b/docker/mingw.sh @@ -16,11 +16,9 @@ main() { $(apt-cache showsrc gcc-mingw-w64-i686 | grep Build | cut -d: -f2 | tr , '\n' | cut -d' ' -f2 | sort | uniq) ) - apt-get update local purge_list=() for dep in ${dependencies[@]}; do - if ! dpkg -L $dep; then - apt-get install --no-install-recommends -y $dep + if ! dpkg -L $dep > /dev/null; then purge_list+=( $dep ) fi done @@ -29,7 +27,7 @@ main() { # Downgrading to the previous version makes the build works echo "deb http://archive.ubuntu.com/ubuntu yakkety main universe" >> /etc/apt/sources.list apt-get update - apt-get install -y --no-install-recommends --allow-downgrades gcc-6-source=6.2.0-5ubuntu12 + apt-get install -y --no-install-recommends gcc-6-source=6.2.0-5ubuntu12 ${purge_list[@]} pushd $td @@ -39,13 +37,11 @@ main() { # We are using dwarf exceptions instead of sjlj sed -i -e 's/libgcc_s_sjlj-1/libgcc_s_dw2-1/g' debian/gcc-mingw-w64-i686.install + # Only build i686 packages (disable x86_64) + rm -f debian/*x86-64.install + # Disable build of fortran,objc,obj-c++ and use configure options # --disable-sjlj-exceptions --with-dwarf2 - # - # We are building x86_64 packages, this takes time, but disable x86_64 is - # difficult - # - # TODO: disable x86_64 packages creation patch -p0 <<'EOF' --- debian/rules.ori 2016-08-20 15:24:54.000000000 +0000 +++ debian/rules @@ -60,28 +56,30 @@ main() { BUILD_TARGET := INSTALL_TARGET := install install-lto-plugin endif -@@ -249,12 +247,16 @@ - cat debian/control - echo ====================================================================== - for target in $(targets); do \ -+ extra=""; \ -+ if [ $$target = "i686-w64-mingw32" ]; then \ -+ extra="--disable-sjlj-exceptions --with-dwarf2"; \ -+ fi; \ - for threads in $(threads); do \ - echo $(base_version)-$$threads > $(upstream_dir)/gcc/BASE-VER && \ - dh_auto_configure \ - -B$(build_dir)/$$target-$$threads \ - -D$(upstream_dir) -- \ -- $(CONFFLAGS); \ -+ $(CONFFLAGS) $$extra; \ - done; \ - done +@@ -86,7 +84,7 @@ + sed -i 's/@@VERSION@@/$(target_version)/g' debian/control touch $@ + +-targets := i686-w64-mingw32 x86_64-w64-mingw32 ++targets := i686-w64-mingw32 + threads := posix win32 + + # Hardening on the host, none on the target +@@ -213,6 +211,10 @@ + # Enable libatomic + CONFFLAGS += \ + --enable-libatomic ++# Enable dwarf exceptions ++CONFFLAGS += \ ++ --disable-sjlj-exceptions \ ++ --with-dwarf2 + + spelling = grep -rl "$(1)" $(upstream_dir) | xargs -r sed -i "s/$(1)/$(2)/g" + EOF # Build the modified mingw packages - MAKEFLAGS=--silent dpkg-buildpackage -b + MAKEFLAGS=--silent dpkg-buildpackage -B # Replace installed mingw packages with the new ones dpkg -i ../g*-mingw-w64-i686*.deb ../gcc-mingw-w64-base*.deb From 125db52c2acbc55471e6382e6c516def748dbb8f Mon Sep 17 00:00:00 2001 From: Marco A L Barbosa Date: Mon, 24 Apr 2017 17:15:49 -0300 Subject: [PATCH 16/35] Add x86_64-linux-android target --- .travis.yml | 1 + README.md | 1 + ci/script.sh | 1 - docker/x86_64-linux-android/Dockerfile | 33 ++++++++++++++++++++++++++ src/main.rs | 6 ++++- 5 files changed, 40 insertions(+), 2 deletions(-) create mode 100644 docker/x86_64-linux-android/Dockerfile diff --git a/.travis.yml b/.travis.yml index d4ebd3238..f077bb23c 100644 --- a/.travis.yml +++ b/.travis.yml @@ -30,6 +30,7 @@ matrix: - env: TARGET=arm-linux-androideabi CPP=1 STD=1 OPENSSL=0.5.5 - env: TARGET=armv7-linux-androideabi CPP=1 STD=1 OPENSSL=0.5.5 - env: TARGET=i686-linux-android CPP=1 STD=1 OPENSSL=0.5.5 + - env: TARGET=x86_64-linux-android CPP=1 STD=1 OPENSSL=0.5.5 # OSX - env: TARGET=i686-apple-darwin DYLIB=1 STD=1 RUN=1 diff --git a/README.md b/README.md index 879b534c8..3cc2556e3 100644 --- a/README.md +++ b/README.md @@ -181,6 +181,7 @@ worst, "hang" (never terminate). | `thumbv7em-none-eabi` [3] | 2.2.0 | 5.3.1 | N/A | | N/A | | | `thumbv7em-none-eabihf` [3] | 2.2.0 | 5.3.1 | N/A | | N/A | | | `thumbv7m-none-eabi` [3] | 2.2.0 | 5.3.1 | N/A | | N/A | | +| `x86_64-linux-android` | N/A | 4.9 | 1.0.2k | ✓ | N/A | | | `x86_64-pc-windows-gnu`[1] | N/A | 5.3.1 | | ✓ | N/A | | | `x86_64-unknown-dragonfly` [1] [2] | 4.6.0 | 5.3.0 | 1.0.2k | | N/A | ✓ | | `x86_64-unknown-freebsd` [1] | 10.2 | 5.3.0 | 1.0.2k | | N/A | | diff --git a/ci/script.sh b/ci/script.sh index f4de189a6..a981291cd 100644 --- a/ci/script.sh +++ b/ci/script.sh @@ -62,7 +62,6 @@ EOF git clone --depth 1 https://github.com/rust-lang/cargo $td pushd $td - cargo update -p libc cross build --target $TARGET popd diff --git a/docker/x86_64-linux-android/Dockerfile b/docker/x86_64-linux-android/Dockerfile new file mode 100644 index 000000000..738eeefc9 --- /dev/null +++ b/docker/x86_64-linux-android/Dockerfile @@ -0,0 +1,33 @@ +FROM ubuntu:16.04 + +RUN apt-get update && \ + apt-get install -y --no-install-recommends \ + ca-certificates \ + cmake \ + gcc \ + libc6-dev \ + make \ + pkg-config + +COPY xargo.sh / +RUN bash /xargo.sh + +COPY android-ndk.sh / +RUN bash /android-ndk.sh x86_64 21 +ENV PATH=$PATH:/android-ndk/bin + +COPY openssl.sh / +RUN bash /openssl.sh linux-x86_64 x86_64-linux-android- -mandroid -fomit-frame-pointer + +# Libz is distributed in the android ndk, but for some unknown reason it is not +# found in the build process of some crates, so we explicit set the DEP_Z_ROOT +ENV CARGO_TARGET_X86_64_LINUX_ANDROID_LINKER=x86_64-linux-android-gcc \ + CC_x86_64_linux_android=x86_64-linux-android-gcc \ + CXX_x86_64_linux_android=x86_64-linux-android-g++ \ + DEP_Z_ROOT=/android-ndk/sysroot/usr/ \ + OPENSSL_STATIC=1 \ + OPENSSL_DIR=/openssl \ + OPENSSL_INCLUDE_DIR=/openssl/include \ + OPENSSL_LIB_DIR=/openssl/lib \ + RUST_TEST_THREADS=1 \ + HOME=/tmp/ diff --git a/src/main.rs b/src/main.rs index f8a70251f..b4dbde89f 100644 --- a/src/main.rs +++ b/src/main.rs @@ -87,6 +87,7 @@ pub enum Target { Armv7LinuxAndroideabi, Aarch64LinuxAndroid, I686LinuxAndroid, + X86_64LinuxAndroid, // Linux Aarch64UnknownLinuxGnu, @@ -157,7 +158,8 @@ impl Target { Target::ArmLinuxAndroideabi | Target::Armv7LinuxAndroideabi | Target::Aarch64LinuxAndroid | - Target::I686LinuxAndroid => true, + Target::I686LinuxAndroid | + Target::X86_64LinuxAndroid => true, _ => false, } } @@ -250,6 +252,7 @@ impl Target { Thumbv7mNoneEabi => "thumbv7m-none-eabi", X86_64AppleDarwin => "x86_64-apple-darwin", X86_64PcWindowsGnu => "x86_64-pc-windows-gnu", + X86_64LinuxAndroid => "x86_64-linux-android", X86_64UnknownDragonfly => "x86_64-unknown-dragonfly", X86_64UnknownFreebsd => "x86_64-unknown-freebsd", X86_64UnknownLinuxGnu => "x86_64-unknown-linux-gnu", @@ -295,6 +298,7 @@ impl Target { "thumbv7em-none-eabihf" => Thumbv7emNoneEabihf, "thumbv7m-none-eabi" => Thumbv7mNoneEabi, "x86_64-apple-darwin" => X86_64AppleDarwin, + "x86_64-linux-android" => X86_64LinuxAndroid, "x86_64-pc-windows-gnu" => X86_64PcWindowsGnu, "x86_64-unknown-dragonfly" => X86_64UnknownDragonfly, "x86_64-unknown-freebsd" => X86_64UnknownFreebsd, From 118151c3b0ecc2f40d2ee920d4c9590b0c84f7a9 Mon Sep 17 00:00:00 2001 From: Marco A L Barbosa Date: Fri, 2 Jun 2017 18:57:02 -0300 Subject: [PATCH 17/35] Another attempt to reduce mingw build time --- docker/mingw.sh | 38 ++++++++++++++++++++++++++++++++++++-- 1 file changed, 36 insertions(+), 2 deletions(-) diff --git a/docker/mingw.sh b/docker/mingw.sh index a6df2bf00..a73bbfd93 100644 --- a/docker/mingw.sh +++ b/docker/mingw.sh @@ -38,7 +38,41 @@ main() { sed -i -e 's/libgcc_s_sjlj-1/libgcc_s_dw2-1/g' debian/gcc-mingw-w64-i686.install # Only build i686 packages (disable x86_64) - rm -f debian/*x86-64.install + patch -p0 <<'EOF' +--- debian/control.template.ori 2017-06-02 15:58:53.965834005 -0300 ++++ debian/control.template +@@ -1,7 +1,6 @@ + Package: @@PACKAGE@@-mingw-w64 + Architecture: all + Depends: @@PACKAGE@@-mingw-w64-i686, +- @@PACKAGE@@-mingw-w64-x86-64, + ${misc:Depends} + Recommends: @@RECOMMENDS@@ + Built-Using: gcc-@@VERSION@@ (= ${gcc:Version}) +@@ -32,22 +31,3 @@ + This package contains the @@LANGUAGE@@ compiler, supporting + cross-compiling to 32-bit MinGW-w64 targets. + Build-Profiles: +- +-Package: @@PACKAGE@@-mingw-w64-x86-64 +-Architecture: any +-Depends: @@DEPENDS64@@, +- ${misc:Depends}, +- ${shlibs:Depends} +-Suggests: gcc-@@VERSION@@-locales (>= ${local:Version}) +-Breaks: @@BREAKS64@@ +-Conflicts: @@CONFLICTS64@@ +-Replaces: @@REPLACES64@@ +-Built-Using: gcc-@@VERSION@@ (= ${gcc:Version}) +-Description: GNU @@LANGUAGE@@ compiler for MinGW-w64 targeting Win64 +- MinGW-w64 provides a development and runtime environment for 32- and +- 64-bit (x86 and x64) Windows applications using the Windows API and +- the GNU Compiler Collection (gcc). +- . +- This package contains the @@LANGUAGE@@ compiler, supporting +- cross-compiling to 64-bit MinGW-w64 targets. +-Build-Profiles: +EOF # Disable build of fortran,objc,obj-c++ and use configure options # --disable-sjlj-exceptions --with-dwarf2 @@ -79,7 +113,7 @@ main() { EOF # Build the modified mingw packages - MAKEFLAGS=--silent dpkg-buildpackage -B + MAKEFLAGS=--silent dpkg-buildpackage -nc -B # Replace installed mingw packages with the new ones dpkg -i ../g*-mingw-w64-i686*.deb ../gcc-mingw-w64-base*.deb From b4e47f7991b58ecc3f197898dab720d6d765f7fc Mon Sep 17 00:00:00 2001 From: Marco A L Barbosa Date: Fri, 2 Jun 2017 18:58:56 -0300 Subject: [PATCH 18/35] Do not install cargo-clone This reduces 330 seconds on travis --- .travis.yml | 3 --- ci/script.sh | 14 +++++++++++--- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/.travis.yml b/.travis.yml index 8876258d6..af1f9df8c 100644 --- a/.travis.yml +++ b/.travis.yml @@ -58,9 +58,6 @@ install: - curl https://sh.rustup.rs -sSf | sh -s -- -y --default-toolchain $TRAVIS_RUST_VERSION - source ~/.cargo/env - - test $TRAVIS_OS_NAME = osx || - which cargo clone || - cargo install cargo-clone --vers 0.1.0 script: - bash ci/script.sh diff --git a/ci/script.sh b/ci/script.sh index 3057757bf..925cf3f3f 100644 --- a/ci/script.sh +++ b/ci/script.sh @@ -133,10 +133,18 @@ EOF if [ $OPENSSL ]; then td=$(mktemp -d) + # If tag name v$OPENSSL fails we try openssl-sys-v$OPENSSL + git clone \ + --depth 1 \ + --branch v$OPENSSL \ + https://github.com/sfackler/rust-openssl $td || \ + git clone \ + --depth 1 \ + --branch openssl-sys-v$OPENSSL \ + https://github.com/sfackler/rust-openssl $td + pushd $td - cargo clone openssl-sys --vers $OPENSSL - cd openssl-sys - cross build --target $TARGET + cross build --package openssl-sys --target $TARGET popd rm -rf $td From c66b4b87c42446a1aebbf84606861656c01e6f2c Mon Sep 17 00:00:00 2001 From: Marco A L Barbosa Date: Mon, 5 Jun 2017 15:01:38 -0300 Subject: [PATCH 19/35] Fix openssl-sys build test --- ci/script.sh | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/ci/script.sh b/ci/script.sh index 925cf3f3f..cc582ac30 100644 --- a/ci/script.sh +++ b/ci/script.sh @@ -144,7 +144,9 @@ EOF https://github.com/sfackler/rust-openssl $td pushd $td - cross build --package openssl-sys --target $TARGET + # avoid problems building openssl-sys in a virtual workspace + rm -f Cargo.toml + cd openssl-sys && cross build --target $TARGET popd rm -rf $td From 68c0bc1dd6589d7f8c9016ede573747efc3e0d94 Mon Sep 17 00:00:00 2001 From: Marco A L Barbosa Date: Mon, 5 Jun 2017 15:02:07 -0300 Subject: [PATCH 20/35] Disable openssl on *-pc-windows-gnu --- .travis.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index f9054eb88..e70a403f9 100644 --- a/.travis.yml +++ b/.travis.yml @@ -45,8 +45,8 @@ matrix: - env: TARGET=x86_64-unknown-netbsd DYLIB=1 STD=1 OPENSSL=0.7.17 # Windows - - env: TARGET=x86_64-pc-windows-gnu CPP=1 STD=1 OPENSSL=0.7.17 RUN=1 - - env: TARGET=i686-pc-windows-gnu CPP=1 STD=1 OPENSSL=0.7.17 RUN=1 + - env: TARGET=x86_64-pc-windows-gnu CPP=1 STD=1 RUN=1 + - env: TARGET=i686-pc-windows-gnu CPP=1 STD=1 RUN=1 # Bare metal - env: TARGET=thumbv6m-none-eabi RUN=1 From c828b038b99050e81116d75726292c9a91f26799 Mon Sep 17 00:00:00 2001 From: Marco A L Barbosa Date: Wed, 7 Jun 2017 12:57:22 -0300 Subject: [PATCH 21/35] Add emscripten targets --- docker/asmjs-unknown-emscripten/Dockerfile | 20 ++++++++ docker/emscripten-entry.sh | 11 +++++ docker/emscripten.sh | 54 +++++++++++++++++++++ docker/node-wasm | 19 ++++++++ docker/node.sh | 28 +++++++++++ docker/wasm32-unknown-emscripten/Dockerfile | 24 +++++++++ src/main.rs | 18 ++++++- 7 files changed, 173 insertions(+), 1 deletion(-) create mode 100644 docker/asmjs-unknown-emscripten/Dockerfile create mode 100755 docker/emscripten-entry.sh create mode 100644 docker/emscripten.sh create mode 100755 docker/node-wasm create mode 100644 docker/node.sh create mode 100644 docker/wasm32-unknown-emscripten/Dockerfile diff --git a/docker/asmjs-unknown-emscripten/Dockerfile b/docker/asmjs-unknown-emscripten/Dockerfile new file mode 100644 index 000000000..b812893a8 --- /dev/null +++ b/docker/asmjs-unknown-emscripten/Dockerfile @@ -0,0 +1,20 @@ +FROM ubuntu:16.04 + +RUN apt-get update && \ + apt-get install -y --no-install-recommends \ + ca-certificates \ + cmake \ + gcc \ + libc6-dev \ + make \ + pkg-config + +RUN apt-get install -y --no-install-recommends python + +COPY emscripten.sh / +RUN bash /emscripten.sh + +COPY emscripten-entry.sh / +ENTRYPOINT ["/emscripten-entry.sh"] + +ENV CARGO_TARGET_ASMJS_UNKNOWN_EMSCRIPTEN_RUNNER=node diff --git a/docker/emscripten-entry.sh b/docker/emscripten-entry.sh new file mode 100755 index 000000000..6a91f8e00 --- /dev/null +++ b/docker/emscripten-entry.sh @@ -0,0 +1,11 @@ +#!/bin/bash + +set -e + +export HOME=/tmp/ + +cp /emsdk-portable/.emscripten $HOME/ + +source /emsdk-portable/emsdk_env.sh &> /dev/null + +exec "$@" diff --git a/docker/emscripten.sh b/docker/emscripten.sh new file mode 100644 index 000000000..3ad7dc961 --- /dev/null +++ b/docker/emscripten.sh @@ -0,0 +1,54 @@ +set -ex + +main() { + local dependencies=( + ca-certificates + cmake + curl + git + python + ) + + apt-get update + local purge_list=() + for dep in ${dependencies[@]}; do + if ! dpkg -L $dep; then + apt-get install --no-install-recommends -y $dep + purge_list+=( $dep ) + fi + done + + cd / + curl -L https://s3.amazonaws.com/mozilla-games/emscripten/releases/emsdk-portable.tar.gz | \ + tar -xz + cd /emsdk-portable + + ./emsdk update + ./emsdk install latest + ./emsdk activate latest + + # Make emsdk usable by any user + cp /root/.emscripten /emsdk-portable + chmod a+r -R /emsdk-portable/ + chmod a+x /emsdk-portable/emsdk + chmod a+xw /emsdk-portable/ + + # Compile and cache libc + source ./emsdk_env.sh + echo "main(){}" > a.c + emcc a.c + emcc -s BINARYEN=1 a.c + echo -e "#include \n void hello(){ std::cout << std::endl; }" > a.cpp + emcc a.cpp + emcc -s BINARYEN=1 a.cpp + rm -f a.* + chmod a+rw -R /emsdk-portable/.emscripten_cache/ + rm /emsdk-portable/.emscripten_cache.lock + + # Clean up + apt-get purge --auto-remove -y ${purge_list[@]} + + rm $0 +} + +main "${@}" diff --git a/docker/node-wasm b/docker/node-wasm new file mode 100755 index 000000000..dcfc005fb --- /dev/null +++ b/docker/node-wasm @@ -0,0 +1,19 @@ +#!/bin/bash + +path="$(dirname $1)" +file="$(basename $1)" + +# Workaround for +# https://github.com/kripken/emscripten/issues/4542 + +if [ "$(basename $path)" != "deps" ]; then + path="$path/deps" +fi + +cd "$path" + +if [ -f "$file" ]; then + /node-*/bin/node "$file" +else + /node-*/bin/node "../$file" +fi diff --git a/docker/node.sh b/docker/node.sh new file mode 100644 index 000000000..9f7f81abf --- /dev/null +++ b/docker/node.sh @@ -0,0 +1,28 @@ +set -ex + +main() { + local dependencies=( + ca-certificates + curl + ) + + apt-get update + local purge_list=() + for dep in ${dependencies[@]}; do + if ! dpkg -L $dep; then + apt-get install --no-install-recommends -y $dep + purge_list+=( $dep ) + fi + done + + cd / + curl -L https://nodejs.org/dist/v8.0.0/node-v8.0.0-linux-x64.tar.xz | \ + tar -xJ + + # Clean up + apt-get purge --auto-remove -y ${purge_list[@]} + + rm $0 +} + +main "${@}" diff --git a/docker/wasm32-unknown-emscripten/Dockerfile b/docker/wasm32-unknown-emscripten/Dockerfile new file mode 100644 index 000000000..3c8a21eaf --- /dev/null +++ b/docker/wasm32-unknown-emscripten/Dockerfile @@ -0,0 +1,24 @@ +FROM ubuntu:16.04 + +RUN apt-get update && \ + apt-get install -y --no-install-recommends \ + ca-certificates \ + cmake \ + gcc \ + libc6-dev \ + make \ + pkg-config + +RUN apt-get install -y --no-install-recommends python + +COPY emscripten.sh / +RUN bash /emscripten.sh + +COPY node.sh / +RUN bash /node.sh + +COPY emscripten-entry.sh / +ENTRYPOINT ["/emscripten-entry.sh"] + +COPY node-wasm /usr/local/bin/ +ENV CARGO_TARGET_WASM32_UNKNOWN_EMSCRIPTEN_RUNNER=node-wasm diff --git a/src/main.rs b/src/main.rs index 7bd9afa61..c428c8ff5 100644 --- a/src/main.rs +++ b/src/main.rs @@ -122,6 +122,10 @@ pub enum Target { X86_64PcWindowsGnu, I686PcWindowsGnu, + // Emscripten + AsmjsUnknownEmscripten, + Wasm32UnknownEmscripten, + // Bare metal Thumbv6mNoneEabi, Thumbv7emNoneEabi, @@ -168,6 +172,14 @@ impl Target { } } + fn is_emscripten(&self) -> bool { + match *self { + Target::AsmjsUnknownEmscripten | + Target::Wasm32UnknownEmscripten => true, + _ => false, + } + } + fn is_linux(&self) -> bool { match *self { Target::Aarch64UnknownLinuxGnu | @@ -202,7 +214,7 @@ impl Target { fn needs_docker(&self) -> bool { self.is_linux() || self.is_android() || self.is_bare_metal() || self.is_bsd() || - !self.is_builtin() || self.is_windows() + !self.is_builtin() || self.is_windows() || self.is_emscripten() } fn needs_interpreter(&self) -> bool { @@ -237,6 +249,7 @@ impl Target { Armv7LinuxAndroideabi => "armv7-linux-androideabi", Armv7UnknownLinuxGnueabihf => "armv7-unknown-linux-gnueabihf", Armv7UnknownLinuxMusleabihf => "armv7-unknown-linux-musleabihf", + AsmjsUnknownEmscripten => "asmjs-unknown-emscripten", I686AppleDarwin => "i686-apple-darwin", I686LinuxAndroid => "i686-linux-android", I686PcWindowsGnu => "i686-pc-windows-gnu", @@ -256,6 +269,7 @@ impl Target { Thumbv7emNoneEabi => "thumbv7em-none-eabi", Thumbv7emNoneEabihf => "thumbv7em-none-eabihf", Thumbv7mNoneEabi => "thumbv7m-none-eabi", + Wasm32UnknownEmscripten => "wasm32-unknown-emscripten", X86_64AppleDarwin => "x86_64-apple-darwin", X86_64PcWindowsGnu => "x86_64-pc-windows-gnu", X86_64LinuxAndroid => "x86_64-linux-android", @@ -285,6 +299,7 @@ impl Target { "armv7-linux-androideabi" => Armv7LinuxAndroideabi, "armv7-unknown-linux-gnueabihf" => Armv7UnknownLinuxGnueabihf, "armv7-unknown-linux-musleabihf" => Armv7UnknownLinuxMusleabihf, + "asmjs-unknown-emscripten" => AsmjsUnknownEmscripten, "i686-apple-darwin" => I686AppleDarwin, "i686-linux-android" => I686LinuxAndroid, "i686-pc-windows-gnu" => I686PcWindowsGnu, @@ -304,6 +319,7 @@ impl Target { "thumbv7em-none-eabi" => Thumbv7emNoneEabi, "thumbv7em-none-eabihf" => Thumbv7emNoneEabihf, "thumbv7m-none-eabi" => Thumbv7mNoneEabi, + "wasm32-unknown-emscripten" => Wasm32UnknownEmscripten, "x86_64-apple-darwin" => X86_64AppleDarwin, "x86_64-linux-android" => X86_64LinuxAndroid, "x86_64-pc-windows-gnu" => X86_64PcWindowsGnu, From 2aca86d17f05daa409bb2db4847150c3bf4e821d Mon Sep 17 00:00:00 2001 From: Marco A L Barbosa Date: Wed, 7 Jun 2017 13:02:58 -0300 Subject: [PATCH 22/35] Add rust-itertools as build test for emscripten targets As of now, xargo cannot be build --- ci/script.sh | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/ci/script.sh b/ci/script.sh index cc582ac30..be3d97c4b 100644 --- a/ci/script.sh +++ b/ci/script.sh @@ -65,6 +65,17 @@ EOF cross build --target $TARGET popd + rm -rf $td + elif [ "$TARGET" = "asmjs-unknown-emscripten" -o \ + "$TARGET" = "wasm32-unknown-emscripten" ]; then + td=$(mktemp -d) + + git clone --depth 1 https://github.com/bluss/rust-itertools $td + + pushd $td + cross build --target $TARGET + popd + rm -rf $td else td=$(mktemp -d) From 79446d8aa8a9e50e9d5ac071f8116b6a01908b2d Mon Sep 17 00:00:00 2001 From: Marco A L Barbosa Date: Wed, 7 Jun 2017 13:04:15 -0300 Subject: [PATCH 23/35] Add travis tests for emscripten targets --- .travis.yml | 4 +++ README.md | 74 ++++++++++++++++++++++++++++------------------------- 2 files changed, 43 insertions(+), 35 deletions(-) diff --git a/.travis.yml b/.travis.yml index e70a403f9..da7cf55a0 100644 --- a/.travis.yml +++ b/.travis.yml @@ -48,6 +48,10 @@ matrix: - env: TARGET=x86_64-pc-windows-gnu CPP=1 STD=1 RUN=1 - env: TARGET=i686-pc-windows-gnu CPP=1 STD=1 RUN=1 + # Emscripten + - env: TARGET=asmjs-unknown-emscripten CPP=1 STD=1 RUN=1 + - env: TARGET=wasm32-unknown-emscripten CPP=1 STD=1 RUN=1 + # Bare metal - env: TARGET=thumbv6m-none-eabi RUN=1 - env: TARGET=thumbv7em-none-eabi RUN=1 diff --git a/README.md b/README.md index faa03e553..6927a44fa 100644 --- a/README.md +++ b/README.md @@ -154,41 +154,43 @@ because QEMU gets upset when you spawn several threads. This also means that, if one of your unit tests spawns several threads then it's more likely to fail or, worst, "hang" (never terminate). -| Target | libc | GCC | OpenSSL | C++ | QEMU | `test` | -|--------------------------------------|--------|-------|---------|:---:|-------|:------:| -| `aarch64-linux-android` | N/A | 4.9 | 1.0.2k | ✓ | N/A | | -| `aarch64-unknown-linux-gnu` | 2.19 | 4.8.2 | 1.0.2k | ✓ | 2.8.0 | ✓ | -| `arm-linux-androideabi` | N/A | 4.9 | 1.0.2k | ✓ | N/A | | -| `arm-unknown-linux-gnueabi` | 2.19 | 4.8.2 | 1.0.2k | ✓ | 2.8.0 | ✓ | -| `arm-unknown-linux-musleabi` | 1.1.15 | 5.3.1 | N/A | | 2.8.0 | ✓ | -| `armv7-linux-androideabi` | N/A | 4.9 | 1.0.2k | ✓ | N/A | | -| `armv7-unknown-linux-gnueabihf` | 2.15 | 4.6.2 | 1.0.2k | ✓ | 2.8.0 | ✓ | -| `armv7-unknown-linux-musleabihf` | 1.1.15 | 5.3.1 | N/A | | 2.8.0 | ✓ | -| `i686-linux-android` | N/A | 4.9 | 1.0.2k | ✓ | N/A | | -| `i686-pc-windows-gnu` | N/A | 6.2.0 | N/A | ✓ | N/A | ✓ | -| `i686-unknown-freebsd` [1] | 10.2 | 5.3.0 | 1.0.2k | | N/A | | -| `i686-unknown-linux-gnu` | 2.15 | 4.6.2 | 1.0.2k | ✓ | N/A | ✓ | -| `i686-unknown-linux-musl` | 1.1.15 | 5.3.1 | N/A | | N/A | ✓ | -| `mips-unknown-linux-gnu` | 2.23 | 5.3.1 | 1.0.2k | ✓ | 2.8.0 | ✓ | -| `mips64-unknown-linux-gnuabi64` | 2.23 | 5.3.1 | 1.0.2k | ✓ | 2.8.0 | ✓ | -| `mips64el-unknown-linux-gnuabi64` | 2.23 | 5.3.1 | 1.0.2k | ✓ | 2.8.0 | ✓ | -| `mipsel-unknown-linux-gnu` | 2.23 | 5.3.1 | 1.0.2k | ✓ | 2.8.0 | ✓ | -| `powerpc-unknown-linux-gnu` | 2.19 | 4.8.2 | 1.0.2k | ✓ | 2.7.1 | ✓ | -| `powerpc64-unknown-linux-gnu` | 2.19 | 4.8.2 | 1.0.2k | ✓ | 2.7.1 | ✓ | -| `powerpc64le-unknown-linux-gnu` | 2.19 | 4.8.2 | 1.0.2k | ✓ | 2.7.1 | ✓ | -| `s390x-unknown-linux-gnu` | 2.23 | 5.3.1 | 1.0.2k | ✓ | 2.8.0 | | -| `sparc64-unknown-linux-gnu` [2] | 2.23 | 5.3.1 | 1.0.2k | ✓ | 2.8.0 | ✓ | -| `thumbv6m-none-eabi` [3] | 2.2.0 | 5.3.1 | N/A | | N/A | | -| `thumbv7em-none-eabi` [3] | 2.2.0 | 5.3.1 | N/A | | N/A | | -| `thumbv7em-none-eabihf` [3] | 2.2.0 | 5.3.1 | N/A | | N/A | | -| `thumbv7m-none-eabi` [3] | 2.2.0 | 5.3.1 | N/A | | N/A | | -| `x86_64-linux-android` | N/A | 4.9 | 1.0.2k | ✓ | N/A | | -| `x86_64-pc-windows-gnu` | N/A | 6.2.0 | N/A | ✓ | N/A | ✓ | -| `x86_64-unknown-dragonfly` [1] [2] | 4.6.0 | 5.3.0 | 1.0.2k | | N/A | ✓ | -| `x86_64-unknown-freebsd` [1] | 10.2 | 5.3.0 | 1.0.2k | | N/A | | -| `x86_64-unknown-linux-gnu` | 2.15 | 4.6.2 | 1.0.2k | ✓ | N/A | ✓ | -| `x86_64-unknown-linux-musl` | 1.1.15 | 5.3.1 | 1.0.2k | | N/A | ✓ | -| `x86_64-unknown-netbsd`[1] | 7.0 | 5.3.0 | 1.0.2k | | N/A | | +| Target | libc | GCC | OpenSSL | C++ | QEMU | `test` | +|--------------------------------------|--------|---------|---------|:---:|-------|:------:| +| `aarch64-linux-android` | N/A | 4.9 | 1.0.2k | ✓ | N/A | | +| `aarch64-unknown-linux-gnu` | 2.19 | 4.8.2 | 1.0.2k | ✓ | 2.8.0 | ✓ | +| `arm-linux-androideabi` | N/A | 4.9 | 1.0.2k | ✓ | N/A | | +| `arm-unknown-linux-gnueabi` | 2.19 | 4.8.2 | 1.0.2k | ✓ | 2.8.0 | ✓ | +| `arm-unknown-linux-musleabi` | 1.1.15 | 5.3.1 | N/A | | 2.8.0 | ✓ | +| `armv7-linux-androideabi` | N/A | 4.9 | 1.0.2k | ✓ | N/A | | +| `armv7-unknown-linux-gnueabihf` | 2.15 | 4.6.2 | 1.0.2k | ✓ | 2.8.0 | ✓ | +| `armv7-unknown-linux-musleabihf` | 1.1.15 | 5.3.1 | N/A | | 2.8.0 | ✓ | +| `asmjs-unknown-emscripten` [4] | 1.1.15 | 1.37.13 | N/A | ✓ | N/A | ✓ | +| `i686-linux-android` | N/A | 4.9 | 1.0.2k | ✓ | N/A | | +| `i686-pc-windows-gnu` | N/A | 6.2.0 | N/A | ✓ | N/A | ✓ | +| `i686-unknown-freebsd` [1] | 10.2 | 5.3.0 | 1.0.2k | | N/A | | +| `i686-unknown-linux-gnu` | 2.15 | 4.6.2 | 1.0.2k | ✓ | N/A | ✓ | +| `i686-unknown-linux-musl` | 1.1.15 | 5.3.1 | N/A | | N/A | ✓ | +| `mips-unknown-linux-gnu` | 2.23 | 5.3.1 | 1.0.2k | ✓ | 2.8.0 | ✓ | +| `mips64-unknown-linux-gnuabi64` | 2.23 | 5.3.1 | 1.0.2k | ✓ | 2.8.0 | ✓ | +| `mips64el-unknown-linux-gnuabi64` | 2.23 | 5.3.1 | 1.0.2k | ✓ | 2.8.0 | ✓ | +| `mipsel-unknown-linux-gnu` | 2.23 | 5.3.1 | 1.0.2k | ✓ | 2.8.0 | ✓ | +| `powerpc-unknown-linux-gnu` | 2.19 | 4.8.2 | 1.0.2k | ✓ | 2.7.1 | ✓ | +| `powerpc64-unknown-linux-gnu` | 2.19 | 4.8.2 | 1.0.2k | ✓ | 2.7.1 | ✓ | +| `powerpc64le-unknown-linux-gnu` | 2.19 | 4.8.2 | 1.0.2k | ✓ | 2.7.1 | ✓ | +| `s390x-unknown-linux-gnu` | 2.23 | 5.3.1 | 1.0.2k | ✓ | 2.8.0 | | +| `sparc64-unknown-linux-gnu` [2] | 2.23 | 5.3.1 | 1.0.2k | ✓ | 2.8.0 | ✓ | +| `thumbv6m-none-eabi` [3] | 2.2.0 | 5.3.1 | N/A | | N/A | | +| `thumbv7em-none-eabi` [3] | 2.2.0 | 5.3.1 | N/A | | N/A | | +| `thumbv7em-none-eabihf` [3] | 2.2.0 | 5.3.1 | N/A | | N/A | | +| `thumbv7m-none-eabi` [3] | 2.2.0 | 5.3.1 | N/A | | N/A | | +| `wasm32-unknown-emscripten` [4] | 1.1.15 | 1.37.13 | N/A | ✓ | N/A | ✓ | +| `x86_64-linux-android` | N/A | 4.9 | 1.0.2k | ✓ | N/A | | +| `x86_64-pc-windows-gnu` | N/A | 6.2.0 | N/A | ✓ | N/A | ✓ | +| `x86_64-unknown-dragonfly` [1] [2] | 4.6.0 | 5.3.0 | 1.0.2k | | N/A | ✓ | +| `x86_64-unknown-freebsd` [1] | 10.2 | 5.3.0 | 1.0.2k | | N/A | | +| `x86_64-unknown-linux-gnu` | 2.15 | 4.6.2 | 1.0.2k | ✓ | N/A | ✓ | +| `x86_64-unknown-linux-musl` | 1.1.15 | 5.3.1 | 1.0.2k | | N/A | ✓ | +| `x86_64-unknown-netbsd`[1] | 7.0 | 5.3.0 | 1.0.2k | | N/A | | [1] For *BSD targets, the libc column indicates the OS release version from where libc was extracted. @@ -197,6 +199,8 @@ where libc was extracted. [3] libc = newlib +[4] libc = musl, gcc = emcc + ## Debugging ### QEMU_STRACE (v0.1.9+) From 1a3a59ccf28da1ae37146ae02c174d881af24685 Mon Sep 17 00:00:00 2001 From: Marco A L Barbosa Date: Thu, 8 Jun 2017 19:31:37 -0300 Subject: [PATCH 24/35] Add tests for running examples and tests --- ci/script.sh | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/ci/script.sh b/ci/script.sh index be3d97c4b..2dd3398d8 100644 --- a/ci/script.sh +++ b/ci/script.sh @@ -116,7 +116,12 @@ EOF cargo init --bin --name hello $td pushd $td + mkdir examples tests + echo "fn main() { println!(\"Example!\"); }" > examples/e.rs + echo "#[test] fn t() {}" > tests/t.rs cross run --target $TARGET + cross run --target $TARGET --example e + cross test --target $TARGET popd rm -rf $td From a016a0b2d45335b241194e6218cc994e60336da9 Mon Sep 17 00:00:00 2001 From: Marco A L Barbosa Date: Thu, 8 Jun 2017 19:32:21 -0300 Subject: [PATCH 25/35] Explain how node-wasm works --- docker/node-wasm | 42 +++++++++++++++++++++++++++++++++++------- 1 file changed, 35 insertions(+), 7 deletions(-) diff --git a/docker/node-wasm b/docker/node-wasm index dcfc005fb..3716f20a7 100755 --- a/docker/node-wasm +++ b/docker/node-wasm @@ -6,14 +6,42 @@ file="$(basename $1)" # Workaround for # https://github.com/kripken/emscripten/issues/4542 -if [ "$(basename $path)" != "deps" ]; then - path="$path/deps" -fi +# Consider a project with this struct +# ├── src +# │   ├── bin +# │   │   └── prog.rs +# │   └── lib.rs +# ├── benches +# │   └── b.rs +# ├── examples +# │   └── a.rs +# └── tests +# └── t.rs +# +# We expect that the artifacts will be generated in +# (where ? = release or debug) +# +# target/wasm32-unknown-emscripten/?/deps/ +# for tests and benches +# +# target/wasm32-unknown-emscripten/?/examples/ +# for examples +# +# target/wasm32-unknown-emscripten/?/ +# for main programs (main.rs and bin/*.rs) +# +# Because of https://github.com/kripken/emscripten/issues/4542 +# the script must be executed from where the dependencies are. -cd "$path" -if [ -f "$file" ]; then - /node-*/bin/node "$file" +base="$(basename $path)" +if [ "$base" != "deps" -a "$base" != "examples" ]; then + # main programs requeries the artifacts in $path/deps + cd "$path/deps" + exec /node-*/bin/node "../$file" else - /node-*/bin/node "../$file" + # all deps of tests, benches and examples are in $path dir + cd "$path" + exec /node-*/bin/node "$file" fi + From d1d72537a9052f205e9d1339e139e3751393f5a2 Mon Sep 17 00:00:00 2001 From: Marco A L Barbosa Date: Thu, 8 Jun 2017 19:38:47 -0300 Subject: [PATCH 26/35] Add a note about lib problems on emscripten --- README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 6927a44fa..1734a99b9 100644 --- a/README.md +++ b/README.md @@ -199,7 +199,8 @@ where libc was extracted. [3] libc = newlib -[4] libc = musl, gcc = emcc +[4] libc = musl, gcc = emcc; Some projects that use libc may fail due to wrong + definitions (will be fixed by https://github.com/rust-lang/libc/pull/610) ## Debugging From e9c42c054ef73550c5bc93abfd79efa1d06657d9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Flemstr=C3=B6m?= Date: Sat, 11 Mar 2017 13:31:34 +0100 Subject: [PATCH 27/35] Add configuration support for env var whitelisting --- src/main.rs | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/src/main.rs b/src/main.rs index c428c8ff5..e1ebfa4cf 100644 --- a/src/main.rs +++ b/src/main.rs @@ -477,6 +477,37 @@ impl Toml { Ok(None) } } + + /// Returns the `build.env.whitelist` part of `Cross.toml` + pub fn env_whitelist(&self) -> Result> { + if let Some(value) = self.table.lookup("build.env.whitelist") { + if let Some(arr) = value.as_slice() { + arr.iter() + .map(|v| { + v.as_str() + .ok_or_else(|| { + "every build.env.whitelist element must be a string".into() + }) + }) + .collect() + } else { + Err("build.env.whitelist must be an array".into()) + } + } else { + Ok(Vec::new()) + } + } + + /// Returns the `build.env.whitelist_all` part of `Cross.toml` + pub fn env_whitelist_all(&self) -> Result> { + if let Some(value) = self.table.lookup("build.env.whitelist_all") { + value.as_bool() + .ok_or_else(|| "build.env.whitelist_all must be a boolean".into()) + .map(Some) + } else { + Ok(None) + } + } } /// Parses the `Cross.toml` at the root of the Cargo project (if any) From f1703b5cb52d5f8c52ba3604dc37a669b4f22779 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Flemstr=C3=B6m?= Date: Sat, 11 Mar 2017 13:31:42 +0100 Subject: [PATCH 28/35] Forward whitelisted env vars to docker --- src/docker.rs | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/src/docker.rs b/src/docker.rs index d568c7687..36ecd348e 100644 --- a/src/docker.rs +++ b/src/docker.rs @@ -119,6 +119,26 @@ pub fn run(target: &Target, docker.args(&["-e", &format!("QEMU_STRACE={}", strace)]); } + if let Some(toml) = toml { + if toml.env_whitelist_all()?.unwrap_or(false) { + for (var, _) in env::vars() { + // Only specifying the environment variable name in the "-e" + // flag forwards the value from the parent shell + docker.args(&["-e", &var]); + } + } else { + for var in toml.env_whitelist()? { + if var.contains("=") { + return Err("environment variable names must not contain the '=' character".into()) + } + + // Only specifying the environment variable name in the "-e" + // flag forwards the value from the parent shell + docker.args(&["-e", var]); + } + } + } + docker .args(&["-e", "XARGO_HOME=/xargo"]) .args(&["-v", &format!("{}:/xargo", xargo_dir.display())]) From b2b5a094729a2ce1559f22437540191bac118f29 Mon Sep 17 00:00:00 2001 From: Kamal Marhubi Date: Mon, 17 Apr 2017 23:07:47 -0400 Subject: [PATCH 29/35] Remove whitelist_all This addresses comments on #77. --- src/docker.rs | 22 +++++++--------------- src/main.rs | 11 ----------- 2 files changed, 7 insertions(+), 26 deletions(-) diff --git a/src/docker.rs b/src/docker.rs index 36ecd348e..e04eeb68e 100644 --- a/src/docker.rs +++ b/src/docker.rs @@ -120,22 +120,14 @@ pub fn run(target: &Target, } if let Some(toml) = toml { - if toml.env_whitelist_all()?.unwrap_or(false) { - for (var, _) in env::vars() { - // Only specifying the environment variable name in the "-e" - // flag forwards the value from the parent shell - docker.args(&["-e", &var]); - } - } else { - for var in toml.env_whitelist()? { - if var.contains("=") { - return Err("environment variable names must not contain the '=' character".into()) - } - - // Only specifying the environment variable name in the "-e" - // flag forwards the value from the parent shell - docker.args(&["-e", var]); + for var in toml.env_whitelist()? { + if var.contains("=") { + bail!("environment variable names must not contain the '=' character"); } + + // Only specifying the environment variable name in the "-e" + // flag forwards the value from the parent shell + docker.args(&["-e", var]); } } diff --git a/src/main.rs b/src/main.rs index e1ebfa4cf..9373823c4 100644 --- a/src/main.rs +++ b/src/main.rs @@ -497,17 +497,6 @@ impl Toml { Ok(Vec::new()) } } - - /// Returns the `build.env.whitelist_all` part of `Cross.toml` - pub fn env_whitelist_all(&self) -> Result> { - if let Some(value) = self.table.lookup("build.env.whitelist_all") { - value.as_bool() - .ok_or_else(|| "build.env.whitelist_all must be a boolean".into()) - .map(Some) - } else { - Ok(None) - } - } } /// Parses the `Cross.toml` at the root of the Cargo project (if any) From 9a1a91f2043a14bde7e3c1ad8e23ec93854d9ff9 Mon Sep 17 00:00:00 2001 From: Kamal Marhubi Date: Wed, 19 Apr 2017 21:47:40 -0400 Subject: [PATCH 30/35] Support target-specific whitelisted environment variables Add support for environment variables to be specified in `Cross.toml` under the `target..env.whitelist` key. --- src/docker.rs | 2 +- src/main.rs | 29 ++++++++++++++++++++++++++++- 2 files changed, 29 insertions(+), 2 deletions(-) diff --git a/src/docker.rs b/src/docker.rs index e04eeb68e..4d422d084 100644 --- a/src/docker.rs +++ b/src/docker.rs @@ -120,7 +120,7 @@ pub fn run(target: &Target, } if let Some(toml) = toml { - for var in toml.env_whitelist()? { + for var in toml.env_whitelist(target)? { if var.contains("=") { bail!("environment variable names must not contain the '=' character"); } diff --git a/src/main.rs b/src/main.rs index 9373823c4..21f3e44a9 100644 --- a/src/main.rs +++ b/src/main.rs @@ -478,8 +478,18 @@ impl Toml { } } + /// Returns the environment variable whitelist for `target`, including variables sepcified + /// under `build` and under `target`. + pub fn env_whitelist(&self, target: &Target) -> Result> { + let mut bwl = self.build_env_whitelist()?; + let mut twl = self.target_env_whitelist(target)?; + bwl.extend(twl.drain(..)); + + Ok(bwl) + } + /// Returns the `build.env.whitelist` part of `Cross.toml` - pub fn env_whitelist(&self) -> Result> { + fn build_env_whitelist(&self) -> Result> { if let Some(value) = self.table.lookup("build.env.whitelist") { if let Some(arr) = value.as_slice() { arr.iter() @@ -497,6 +507,23 @@ impl Toml { Ok(Vec::new()) } } + + /// Returns the `target..env.whitelist` part of `Cross.toml` for `target`. + fn target_env_whitelist(&self, target: &Target) -> Result> { + let triple = target.triple(); + + let key = format!("target.{}.env.whitelist", triple); + + match self.table.lookup(&key) { + Some(&Value::Array(ref vec)) => { + if vec.iter().any(|val| val.as_str().is_none()) { + bail!("every {} element must be a string", key); + } + Ok(vec.iter().map(|val| val.as_str().unwrap()).collect()) + }, + _ => Ok(Vec::new()), + } + } } /// Parses the `Cross.toml` at the root of the Cargo project (if any) From 20d934bd8ef3aad390e3e7118f658028d41517d7 Mon Sep 17 00:00:00 2001 From: Kamal Marhubi Date: Wed, 19 Apr 2017 21:59:16 -0400 Subject: [PATCH 31/35] Document how to pass environemnt variables through --- README.md | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/README.md b/README.md index 1734a99b9..2e8d1bad9 100644 --- a/README.md +++ b/README.md @@ -113,6 +113,33 @@ RUN dpkg --add-architecture arm64 && \ $ docker build -t my/image:tag path/to/where/the/Dockerfile/resides ``` +### Passing environment variables into the build environemnt + +By default, `cross` does not pass any environment variables into the build +environment from the calling shell. Sometimes this is really useful, for +example to pass in environment variables set by your CI system. + +To whitelist some variables, you can specify them in your `Cross.toml` +like so + +```toml +[build.env] +whitelist = [ + "TRAVIS", + "RUST_LOG", +] +``` + +To whitelist some variables for one target but not others, you can use +this syntax instead + +```toml +[target.aarch64-unknown-linux-gnu.env] +whitelist = [ + "RUST_DEBUG", +] +``` + ### Use Xargo instead of Cargo By default, `cross` uses `cargo` to build your Cargo project *unless* you are From 878596966dbb20dcf42813f51e2943e59c8bbd7d Mon Sep 17 00:00:00 2001 From: Kamal Marhubi Date: Wed, 19 Apr 2017 22:13:18 -0400 Subject: [PATCH 32/35] Refactor Toml::build_env_whitelist Use nested matching to make it easier to see what's going on. --- src/main.rs | 23 ++++++++--------------- 1 file changed, 8 insertions(+), 15 deletions(-) diff --git a/src/main.rs b/src/main.rs index 21f3e44a9..232d4b731 100644 --- a/src/main.rs +++ b/src/main.rs @@ -490,21 +490,14 @@ impl Toml { /// Returns the `build.env.whitelist` part of `Cross.toml` fn build_env_whitelist(&self) -> Result> { - if let Some(value) = self.table.lookup("build.env.whitelist") { - if let Some(arr) = value.as_slice() { - arr.iter() - .map(|v| { - v.as_str() - .ok_or_else(|| { - "every build.env.whitelist element must be a string".into() - }) - }) - .collect() - } else { - Err("build.env.whitelist must be an array".into()) - } - } else { - Ok(Vec::new()) + match self.table.lookup("build.env.whitelist") { + Some(&Value::Array(ref vec)) => { + if vec.iter().any(|val| val.as_str().is_none()) { + bail!("every build.env.whitelist element must be a string"); + } + Ok(vec.iter().map(|val| val.as_str().unwrap()).collect()) + }, + _ => Ok(Vec::new()), } } From 63144fdb4aa4ed019c674a4922f3a93e01eaea02 Mon Sep 17 00:00:00 2001 From: Kamal Marhubi Date: Tue, 2 May 2017 09:31:04 -0400 Subject: [PATCH 33/35] Address review comments - rename `whitelist` to `passthrough` - reword description of feature in readme - add `RUST_BACKTRACE` to the example in readme --- README.md | 21 ++++++++++++--------- src/main.rs | 24 ++++++++++++------------ 2 files changed, 24 insertions(+), 21 deletions(-) diff --git a/README.md b/README.md index 2e8d1bad9..cf6e08933 100644 --- a/README.md +++ b/README.md @@ -116,26 +116,29 @@ $ docker build -t my/image:tag path/to/where/the/Dockerfile/resides ### Passing environment variables into the build environemnt By default, `cross` does not pass any environment variables into the build -environment from the calling shell. Sometimes this is really useful, for -example to pass in environment variables set by your CI system. +environment from the calling shell. This is chosen as a safe default as most use +cases will not want the calling environment leaking into the inner execution +environment. + +In the instances that you do want to pass through environment variables, this +can be done via `build.env.passthrough` in your `Cross.toml`: -To whitelist some variables, you can specify them in your `Cross.toml` -like so ```toml [build.env] -whitelist = [ - "TRAVIS", +passthrough = [ + "RUST_BACKTRACE", "RUST_LOG", + "TRAVIS", ] ``` -To whitelist some variables for one target but not others, you can use -this syntax instead +To pass variables through for one target but not others, you can use +this syntax instead: ```toml [target.aarch64-unknown-linux-gnu.env] -whitelist = [ +passthrough = [ "RUST_DEBUG", ] ``` diff --git a/src/main.rs b/src/main.rs index 232d4b731..100b0a9d6 100644 --- a/src/main.rs +++ b/src/main.rs @@ -478,22 +478,22 @@ impl Toml { } } - /// Returns the environment variable whitelist for `target`, including variables sepcified - /// under `build` and under `target`. - pub fn env_whitelist(&self, target: &Target) -> Result> { - let mut bwl = self.build_env_whitelist()?; - let mut twl = self.target_env_whitelist(target)?; + /// Returns the list of environment variables to pass through for `target`, + /// including variables sepcified under `build` and under `target`. + pub fn env_passthrough(&self, target: &Target) -> Result> { + let mut bwl = self.build_env_passthrough()?; + let mut twl = self.target_env_passthrough(target)?; bwl.extend(twl.drain(..)); Ok(bwl) } - /// Returns the `build.env.whitelist` part of `Cross.toml` - fn build_env_whitelist(&self) -> Result> { - match self.table.lookup("build.env.whitelist") { + /// Returns the `build.env.passthrough` part of `Cross.toml` + fn build_env_passthrough(&self) -> Result> { + match self.table.lookup("build.env.passthrough") { Some(&Value::Array(ref vec)) => { if vec.iter().any(|val| val.as_str().is_none()) { - bail!("every build.env.whitelist element must be a string"); + bail!("every build.env.passthrough element must be a string"); } Ok(vec.iter().map(|val| val.as_str().unwrap()).collect()) }, @@ -501,11 +501,11 @@ impl Toml { } } - /// Returns the `target..env.whitelist` part of `Cross.toml` for `target`. - fn target_env_whitelist(&self, target: &Target) -> Result> { + /// Returns the `target..env.passthrough` part of `Cross.toml` for `target`. + fn target_env_passthrough(&self, target: &Target) -> Result> { let triple = target.triple(); - let key = format!("target.{}.env.whitelist", triple); + let key = format!("target.{}.env.passthrough", triple); match self.table.lookup(&key) { Some(&Value::Array(ref vec)) => { From 280917f13ce5e47c8283ad26f9023c1f758eaee0 Mon Sep 17 00:00:00 2001 From: Kamal Marhubi Date: Sat, 10 Jun 2017 04:51:47 -0400 Subject: [PATCH 34/35] Fix missing rename and a typo --- src/docker.rs | 2 +- src/main.rs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/docker.rs b/src/docker.rs index 4d422d084..9afb27e9b 100644 --- a/src/docker.rs +++ b/src/docker.rs @@ -120,7 +120,7 @@ pub fn run(target: &Target, } if let Some(toml) = toml { - for var in toml.env_whitelist(target)? { + for var in toml.env_passthrough(target)? { if var.contains("=") { bail!("environment variable names must not contain the '=' character"); } diff --git a/src/main.rs b/src/main.rs index 100b0a9d6..ce95cb2a5 100644 --- a/src/main.rs +++ b/src/main.rs @@ -479,7 +479,7 @@ impl Toml { } /// Returns the list of environment variables to pass through for `target`, - /// including variables sepcified under `build` and under `target`. + /// including variables specified under `build` and under `target`. pub fn env_passthrough(&self, target: &Target) -> Result> { let mut bwl = self.build_env_passthrough()?; let mut twl = self.target_env_passthrough(target)?; From 78cb2954bcb34972ff60619e818ae2272ba7e6fe Mon Sep 17 00:00:00 2001 From: Jorge Aparicio Date: Sat, 10 Jun 2017 20:29:24 -0500 Subject: [PATCH 35/35] v0.1.11 --- CHANGELOG.md | 22 +++++++++++++++++++++- Cargo.lock | 2 +- Cargo.toml | 2 +- 3 files changed, 23 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6de91895a..7f6e838f8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,24 @@ This project adheres to [Semantic Versioning](http://semver.org/). ## [Unreleased] +## [v0.1.11] - 2017-06-10 + +### Added + +- Build and test support for `i686-pc-windows-gnu`, `x86_64-pc-windows-gnu`, + `asmjs-unknown-emscripten` and `wasm-unknown-emscripten`. + +- Build support for `aarch64-linux-android`, `arm-linux-androideabi`, + `armv7-linux-androideabi`, `x86_64-linux-android` and `i686-linux-android` + +- A `build.env.passthrough` / `build.target.*.passthrough` option to Cross.toml + to support passing environment variables from the host to the Docker image. + +### Changed + +- Bumped OpenSSL version to 1.0.2k +- Bumped QEMU version to 2.9.0 + ## [v0.1.10] - 2017-04-02 ### Added @@ -135,7 +153,9 @@ This project adheres to [Semantic Versioning](http://semver.org/). - Initial release. Supports 12 targets. -[Unreleased]: https://github.com/japaric/cross/compare/v0.1.9...HEAD +[Unreleased]: https://github.com/japaric/cross/compare/v0.1.11...HEAD +[v0.1.11]: https://github.com/japaric/cross/compare/v0.1.10...v0.1.11 +[v0.1.10]: https://github.com/japaric/cross/compare/v0.1.9...v0.1.10 [v0.1.9]: https://github.com/japaric/cross/compare/v0.1.8...v0.1.9 [v0.1.8]: https://github.com/japaric/cross/compare/v0.1.7...v0.1.8 [v0.1.7]: https://github.com/japaric/cross/compare/v0.1.6...v0.1.7 diff --git a/Cargo.lock b/Cargo.lock index 9fe96a0eb..7ecc6544a 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1,6 +1,6 @@ [root] name = "cross" -version = "0.1.11-dev" +version = "0.1.11" 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)", diff --git a/Cargo.toml b/Cargo.toml index 96e433536..80942574e 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -7,7 +7,7 @@ keywords = ["cross", "compilation", "testing", "tool"] license = "MIT OR Apache-2.0" name = "cross" repository = "https://github.com/japaric/cross" -version = "0.1.11-dev" +version = "0.1.11" [dependencies] error-chain = "0.7.1"