diff --git a/src/bootstrap/configure.py b/src/bootstrap/configure.py index 2438be89776..67337bf4421 100755 --- a/src/bootstrap/configure.py +++ b/src/bootstrap/configure.py @@ -109,6 +109,8 @@ v("musl-root-armhf", "target.arm-unknown-linux-musleabihf.musl-root", "arm-unknown-linux-musleabihf install directory") v("musl-root-armv7", "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") v("qemu-armhf-rootfs", "target.arm-unknown-linux-gnueabihf.qemu-rootfs", "rootfs in qemu testing, you probably don't want to use this") v("qemu-aarch64-rootfs", "target.aarch64-unknown-linux-gnu.qemu-rootfs", diff --git a/src/bootstrap/native.rs b/src/bootstrap/native.rs index 99077d03dbe..84e98de09dd 100644 --- a/src/bootstrap/native.rs +++ b/src/bootstrap/native.rs @@ -399,6 +399,7 @@ impl Step for Openssl { let os = match &*target { "aarch64-linux-android" => "linux-aarch64", "aarch64-unknown-linux-gnu" => "linux-aarch64", + "aarch64-unknown-linux-musl" => "linux-aarch64", "arm-linux-androideabi" => "android", "arm-unknown-linux-gnueabi" => "linux-armv4", "arm-unknown-linux-gnueabihf" => "linux-armv4", diff --git a/src/ci/docker/cross/Dockerfile b/src/ci/docker/cross/Dockerfile index a83bbe9c60e..05745709a07 100644 --- a/src/ci/docker/cross/Dockerfile +++ b/src/ci/docker/cross/Dockerfile @@ -14,6 +14,7 @@ RUN apt-get update && apt-get install -y --no-install-recommends \ zlib1g-dev \ g++-arm-linux-gnueabi \ g++-arm-linux-gnueabihf \ + g++-aarch64-linux-gnu \ gcc-sparc64-linux-gnu \ libc6-dev-sparc64-cross \ bzip2 \ @@ -46,6 +47,7 @@ ENV TARGETS=$TARGETS,mipsel-unknown-linux-musl ENV TARGETS=$TARGETS,arm-unknown-linux-musleabi ENV TARGETS=$TARGETS,arm-unknown-linux-musleabihf ENV TARGETS=$TARGETS,armv7-unknown-linux-musleabihf +ENV TARGETS=$TARGETS,aarch64-unknown-linux-musl ENV TARGETS=$TARGETS,sparc64-unknown-linux-gnu ENV TARGETS=$TARGETS,x86_64-unknown-redox @@ -62,7 +64,8 @@ ENV RUST_CONFIGURE_ARGS \ --target=$TARGETS \ --musl-root-arm=/usr/local/arm-linux-musleabi \ --musl-root-armhf=/usr/local/arm-linux-musleabihf \ - --musl-root-armv7=/usr/local/armv7-linux-musleabihf + --musl-root-armv7=/usr/local/armv7-linux-musleabihf \ + --musl-root-aarch64=/usr/local/aarch64-linux-musl ENV SCRIPT python2.7 ../x.py dist --target $TARGETS # sccache diff --git a/src/ci/docker/cross/build-arm-musl.sh b/src/ci/docker/cross/build-arm-musl.sh index 938e69834e4..780099e2ec1 100755 --- a/src/ci/docker/cross/build-arm-musl.sh +++ b/src/ci/docker/cross/build-arm-musl.sh @@ -65,11 +65,24 @@ CFLAGS="-march=armv7-a" \ hide_output make -j$(nproc) hide_output make install cd .. +rm -rf musl-$MUSL + +tar xf musl-$MUSL.tar.gz +cd musl-$MUSL +CC=aarch64-linux-gnu-gcc \ +CFLAGS="" \ + hide_output ./configure \ + --prefix=/usr/local/aarch64-linux-musl \ + --enable-wrapper=gcc +hide_output make -j$(nproc) +hide_output make install +cd .. rm -rf musl-$MUSL* ln -nsf ../arm-linux-musleabi/bin/musl-gcc /usr/local/bin/arm-linux-musleabi-gcc ln -nsf ../arm-linux-musleabihf/bin/musl-gcc /usr/local/bin/arm-linux-musleabihf-gcc ln -nsf ../armv7-linux-musleabihf/bin/musl-gcc /usr/local/bin/armv7-linux-musleabihf-gcc +ln -nsf ../aarch64-linux-musl/bin/musl-gcc /usr/local/bin/aarch64-unknown-linux-musl-gcc curl -L https://github.com/llvm-mirror/llvm/archive/release_39.tar.gz | tar xzf - curl -L https://github.com/llvm-mirror/libunwind/archive/release_39.tar.gz | tar xzf - @@ -116,5 +129,19 @@ cp lib/libunwind.a /usr/local/armv7-linux-musleabihf/lib cd .. rm -rf libunwind-build +mkdir libunwind-build +cd libunwind-build +cmake ../libunwind-release_39 \ + -DLLVM_PATH=/tmp/llvm-release_39 \ + -DLIBUNWIND_ENABLE_SHARED=0 \ + -DCMAKE_C_COMPILER=aarch64-linux-gnu-gcc \ + -DCMAKE_CXX_COMPILER=aarch64-linux-gnu-g++ \ + -DCMAKE_C_FLAGS="" \ + -DCMAKE_CXX_FLAGS="" +make -j$(nproc) +cp lib/libunwind.a /usr/local/aarch64-linux-musl/lib +cd .. +rm -rf libunwind-build + rm -rf libunwind-release_39 rm -rf llvm-release_39 diff --git a/src/librustc_back/target/aarch64_unknown_linux_musl.rs b/src/librustc_back/target/aarch64_unknown_linux_musl.rs new file mode 100644 index 00000000000..1edac616366 --- /dev/null +++ b/src/librustc_back/target/aarch64_unknown_linux_musl.rs @@ -0,0 +1,36 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +use LinkerFlavor; +use target::{Target, TargetOptions, TargetResult}; + +pub fn target() -> TargetResult { + let mut base = super::linux_musl_base::opts(); + base.max_atomic_width = Some(128); + + // see #36994 + base.exe_allocation_crate = None; + + Ok(Target { + llvm_target: "aarch64-unknown-linux-musl".to_string(), + target_endian: "little".to_string(), + target_pointer_width: "64".to_string(), + target_env: "musl".to_string(), + data_layout: "e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128".to_string(), + arch: "aarch64".to_string(), + target_os: "linux".to_string(), + target_vendor: "unknown".to_string(), + linker_flavor: LinkerFlavor::Gcc, + options: TargetOptions { + abi_blacklist: super::arm_base::abi_blacklist(), + .. base + }, + }) +} diff --git a/src/librustc_back/target/mod.rs b/src/librustc_back/target/mod.rs index 301cf3f8c82..27a0855dc29 100644 --- a/src/librustc_back/target/mod.rs +++ b/src/librustc_back/target/mod.rs @@ -153,6 +153,7 @@ supported_targets! { ("armv7-unknown-linux-gnueabihf", armv7_unknown_linux_gnueabihf), ("armv7-unknown-linux-musleabihf", armv7_unknown_linux_musleabihf), ("aarch64-unknown-linux-gnu", aarch64_unknown_linux_gnu), + ("aarch64-unknown-linux-musl", aarch64_unknown_linux_musl), ("x86_64-unknown-linux-musl", x86_64_unknown_linux_musl), ("i686-unknown-linux-musl", i686_unknown_linux_musl), ("mips-unknown-linux-musl", mips_unknown_linux_musl), diff --git a/src/tools/build-manifest/src/main.rs b/src/tools/build-manifest/src/main.rs index 028ef729960..9598266a8de 100644 --- a/src/tools/build-manifest/src/main.rs +++ b/src/tools/build-manifest/src/main.rs @@ -50,6 +50,7 @@ static TARGETS: &'static [&'static str] = &[ "aarch64-unknown-fuchsia", "aarch64-linux-android", "aarch64-unknown-linux-gnu", + "aarch64-unknown-linux-musl", "arm-linux-androideabi", "arm-unknown-linux-gnueabi", "arm-unknown-linux-gnueabihf",