diff --git a/src/bootstrap/configure.py b/src/bootstrap/configure.py index 907983d43ade7..298330869b684 100755 --- a/src/bootstrap/configure.py +++ b/src/bootstrap/configure.py @@ -125,7 +125,9 @@ def v(*args): "arm-unknown-linux-musleabihf install directory") v("musl-root-armv5te", "target.armv5te-unknown-linux-musleabi.musl-root", "armv5te-unknown-linux-musleabi install directory") -v("musl-root-armv7", "target.armv7-unknown-linux-musleabihf.musl-root", +v("musl-root-armv7", "target.armv7-unknown-linux-musleabi.musl-root", + "armv7-unknown-linux-musleabi install directory") +v("musl-root-armv7hf", "target.armv7-unknown-linux-musleabihf.musl-root", "armv7-unknown-linux-musleabihf install directory") v("musl-root-aarch64", "target.aarch64-unknown-linux-musl.musl-root", "aarch64-unknown-linux-musl install directory") diff --git a/src/ci/docker/dist-various-1/Dockerfile b/src/ci/docker/dist-various-1/Dockerfile index 2a81de75a69b9..c60fe18749fd2 100644 --- a/src/ci/docker/dist-various-1/Dockerfile +++ b/src/ci/docker/dist-various-1/Dockerfile @@ -64,7 +64,7 @@ RUN env \ env \ CC=arm-linux-gnueabihf-gcc CFLAGS="-march=armv7-a" \ CXX=arm-linux-gnueabihf-g++ CXXFLAGS="-march=armv7-a" \ - bash musl.sh armv7 && \ + bash musl.sh armv7hf && \ env \ CC=aarch64-linux-gnu-gcc \ CXX=aarch64-linux-gnu-g++ \ @@ -135,7 +135,7 @@ ENV RUST_CONFIGURE_ARGS \ --musl-root-armv5te=/musl-armv5te \ --musl-root-arm=/musl-arm \ --musl-root-armhf=/musl-armhf \ - --musl-root-armv7=/musl-armv7 \ + --musl-root-armv7hf=/musl-armv7hf \ --musl-root-aarch64=/musl-aarch64 \ --musl-root-mips=/musl-mips \ --musl-root-mipsel=/musl-mipsel \ diff --git a/src/ci/docker/dist-various-2/Dockerfile b/src/ci/docker/dist-various-2/Dockerfile index 53523d41a5580..2ae6c58941e4c 100644 --- a/src/ci/docker/dist-various-2/Dockerfile +++ b/src/ci/docker/dist-various-2/Dockerfile @@ -8,7 +8,8 @@ RUN sed -i 's/^# deb-src/deb-src/' /etc/apt/sources.list RUN apt-get update && apt-get build-dep -y clang llvm && apt-get install -y --no-install-recommends \ build-essential \ - gcc-multilib \ +# gcc-multilib can not be installed together with gcc-arm-linux-gnueabi + gcc-7-multilib \ libedit-dev \ libgmp-dev \ libisl-dev \ @@ -21,11 +22,20 @@ RUN apt-get update && apt-get build-dep -y clang llvm && apt-get install -y --no unzip \ # Needed for apt-key to work: dirmngr \ - gpg-agent + gpg-agent \ + g++-7-arm-linux-gnueabi RUN apt-key adv --batch --yes --keyserver keyserver.ubuntu.com --recv-keys 74DA7924C5513486 RUN add-apt-repository -y 'deb http://apt.dilos.org/dilos dilos2 main' +WORKDIR /build +COPY scripts/musl.sh /build +RUN env \ + CC=arm-linux-gnueabi-gcc-7 CFLAGS="-march=armv7-a" \ + CXX=arm-linux-gnueabi-g++-7 CXXFLAGS="-march=armv7-a" \ + bash musl.sh armv7 && \ + rm -rf /build/* + WORKDIR /tmp COPY dist-various-2/shared.sh /tmp/ COPY dist-various-2/build-cloudabi-toolchain.sh /tmp/ @@ -58,7 +68,11 @@ ENV \ CXX_sparcv9_sun_solaris=sparcv9-sun-solaris2.10-g++ \ AR_x86_64_sun_solaris=x86_64-sun-solaris2.10-ar \ CC_x86_64_sun_solaris=x86_64-sun-solaris2.10-gcc \ - CXX_x86_64_sun_solaris=x86_64-sun-solaris2.10-g++ + CXX_x86_64_sun_solaris=x86_64-sun-solaris2.10-g++ \ + CC_armv7_unknown_linux_gnueabi=arm-linux-gnueabi-gcc-7 \ + CXX_armv7_unknown_linux_gnueabi=arm-linux-gnueabi-g++-7 \ + CC=gcc-7 \ + CXX=g++-7 ENV CARGO_TARGET_X86_64_FUCHSIA_AR /usr/local/bin/llvm-ar ENV CARGO_TARGET_X86_64_FUCHSIA_RUSTFLAGS \ @@ -81,9 +95,19 @@ ENV TARGETS=$TARGETS,x86_64-unknown-linux-gnux32 ENV TARGETS=$TARGETS,x86_64-unknown-cloudabi ENV TARGETS=$TARGETS,x86_64-fortanix-unknown-sgx ENV TARGETS=$TARGETS,nvptx64-nvidia-cuda +ENV TARGETS=$TARGETS,armv7-unknown-linux-gnueabi +ENV TARGETS=$TARGETS,armv7-unknown-linux-musleabi ENV X86_FORTANIX_SGX_LIBS="/x86_64-fortanix-unknown-sgx/lib/" +# As per https://bugs.launchpad.net/ubuntu/+source/gcc-defaults/+bug/1300211 +# we need asm in the search path for gcc-7 (for gnux32) but not in the search path of the +# cross compilers. +# Luckily one of the folders is /usr/local/include so symlink /usr/include/asm-generic there +RUN ln -s /usr/include/asm-generic /usr/local/include/asm + ENV RUST_CONFIGURE_ARGS --enable-extended --enable-lld --disable-docs \ - --set target.wasm32-wasi.wasi-root=/wasm32-wasi + --set target.wasm32-wasi.wasi-root=/wasm32-wasi \ + --musl-root-armv7=/musl-armv7 + ENV SCRIPT python2.7 ../x.py dist --target $TARGETS diff --git a/src/librustc_target/spec/armv7_unknown_linux_gnueabi.rs b/src/librustc_target/spec/armv7_unknown_linux_gnueabi.rs new file mode 100644 index 0000000000000..441cb9bfff3eb --- /dev/null +++ b/src/librustc_target/spec/armv7_unknown_linux_gnueabi.rs @@ -0,0 +1,29 @@ +use crate::spec::{LinkerFlavor, Target, TargetOptions, TargetResult}; + +// This target is for glibc Linux on ARMv7 without thumb-mode, NEON or +// hardfloat. + +pub fn target() -> TargetResult { + let base = super::linux_base::opts(); + Ok(Target { + llvm_target: "armv7-unknown-linux-gnueabi".to_string(), + target_endian: "little".to_string(), + target_pointer_width: "32".to_string(), + target_c_int_width: "32".to_string(), + data_layout: "e-m:e-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64".to_string(), + arch: "arm".to_string(), + target_os: "linux".to_string(), + target_env: "gnu".to_string(), + target_vendor: "unknown".to_string(), + linker_flavor: LinkerFlavor::Gcc, + + options: TargetOptions { + features: "+v7,+thumb2,+soft-float,-neon".to_string(), + cpu: "generic".to_string(), + max_atomic_width: Some(64), + abi_blacklist: super::arm_base::abi_blacklist(), + target_mcount: "\u{1}__gnu_mcount_nc".to_string(), + .. base + } + }) +} diff --git a/src/librustc_target/spec/armv7_unknown_linux_musleabi.rs b/src/librustc_target/spec/armv7_unknown_linux_musleabi.rs new file mode 100644 index 0000000000000..c0368e5f0768a --- /dev/null +++ b/src/librustc_target/spec/armv7_unknown_linux_musleabi.rs @@ -0,0 +1,34 @@ +use crate::spec::{LinkerFlavor, Target, TargetOptions, TargetResult}; + +// This target is for musl Linux on ARMv7 without thumb-mode, NEON or +// hardfloat. + +pub fn target() -> TargetResult { + let base = super::linux_musl_base::opts(); + // Most of these settings are copied from the armv7_unknown_linux_gnueabi + // target. + Ok(Target { + // It's important we use "gnueabi" and not "musleabi" here. LLVM uses it + // to determine the calling convention and float ABI, and it doesn't + // support the "musleabi" value. + llvm_target: "armv7-unknown-linux-gnueabi".to_string(), + target_endian: "little".to_string(), + target_pointer_width: "32".to_string(), + target_c_int_width: "32".to_string(), + data_layout: "e-m:e-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64".to_string(), + arch: "arm".to_string(), + target_os: "linux".to_string(), + target_env: "musl".to_string(), + target_vendor: "unknown".to_string(), + linker_flavor: LinkerFlavor::Gcc, + + options: TargetOptions { + features: "+v7,+thumb2,+soft-float,-neon".to_string(), + cpu: "generic".to_string(), + max_atomic_width: Some(64), + abi_blacklist: super::arm_base::abi_blacklist(), + target_mcount: "\u{1}mcount".to_string(), + .. base + } + }) +} diff --git a/src/librustc_target/spec/mod.rs b/src/librustc_target/spec/mod.rs index 54e3cad6a6149..c43f8156dbedb 100644 --- a/src/librustc_target/spec/mod.rs +++ b/src/librustc_target/spec/mod.rs @@ -359,8 +359,10 @@ supported_targets! { ("armv4t-unknown-linux-gnueabi", armv4t_unknown_linux_gnueabi), ("armv5te-unknown-linux-gnueabi", armv5te_unknown_linux_gnueabi), ("armv5te-unknown-linux-musleabi", armv5te_unknown_linux_musleabi), + ("armv7-unknown-linux-gnueabi", armv7_unknown_linux_gnueabi), ("armv7-unknown-linux-gnueabihf", armv7_unknown_linux_gnueabihf), ("thumbv7neon-unknown-linux-gnueabihf", thumbv7neon_unknown_linux_gnueabihf), + ("armv7-unknown-linux-musleabi", armv7_unknown_linux_musleabi), ("armv7-unknown-linux-musleabihf", armv7_unknown_linux_musleabihf), ("aarch64-unknown-linux-gnu", aarch64_unknown_linux_gnu), ("aarch64-unknown-linux-musl", aarch64_unknown_linux_musl), diff --git a/src/tools/build-manifest/src/main.rs b/src/tools/build-manifest/src/main.rs index a935bc6a4ded9..2d1a52c920bae 100644 --- a/src/tools/build-manifest/src/main.rs +++ b/src/tools/build-manifest/src/main.rs @@ -56,8 +56,10 @@ static TARGETS: &[&str] = &[ "armv7-apple-ios", "armv7-linux-androideabi", "thumbv7neon-linux-androideabi", + "armv7-unknown-linux-gnueabi", "armv7-unknown-linux-gnueabihf", "thumbv7neon-unknown-linux-gnueabihf", + "armv7-unknown-linux-musleabi", "armv7-unknown-linux-musleabihf", "armebv7r-none-eabi", "armebv7r-none-eabihf",