Auto merge of #35060 - japaric:arm-musl, r=alexcrichton

Add ARM MUSL targets

Rebase of #33189.

I tested this by producing a std for `arm-unknown-linux-musleabi` then I cross compiled Hello world to said target. Checked that the produced binary was statically linked and verified that the binary worked under QEMU.

This depends on rust-lang/libc#341. I'll have to update this PR after that libc PR is merged.

I'm also working on generating ARM musl cross toolchain via crosstool-ng. Once I verified those work, I'll send a PR to rust-buildbot.

r? @alexcrichton
cc @timonvo
This commit is contained in:
bors 2016-07-30 23:21:46 -07:00 committed by GitHub
commit 724f811794
20 changed files with 144 additions and 21 deletions

2
configure vendored
View File

@ -1192,7 +1192,7 @@ do
;;
x86_64-*-musl)
x86_64-*-musl | arm-*-musleabi)
if [ ! -f $CFG_MUSL_ROOT/lib/libc.a ]
then
err "musl libc $CFG_MUSL_ROOT/lib/libc.a not found"

View File

@ -0,0 +1,3 @@
# This file is intentially left empty to indicate that, while this target is
# supported, it's not supported using plain GNU Make builds. Use a --rustbuild
# instead.

View File

@ -0,0 +1,3 @@
# This file is intentially left empty to indicate that, while this target is
# supported, it's not supported using plain GNU Make builds. Use a --rustbuild
# instead.

View File

@ -0,0 +1,3 @@
# This file is intentially left empty to indicate that, while this target is
# supported, it's not supported using plain GNU Make builds. Use a --rustbuild
# instead.

View File

@ -7,8 +7,8 @@ dependencies = [
"filetime 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)",
"gcc 0.3.31 (git+https://github.com/alexcrichton/gcc-rs)",
"getopts 0.2.14 (registry+https://github.com/rust-lang/crates.io-index)",
"kernel32-sys 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.2.9 (registry+https://github.com/rust-lang/crates.io-index)",
"kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.2.10 (registry+https://github.com/rust-lang/crates.io-index)",
"md5 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
"num_cpus 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)",
"rustc-serialize 0.3.19 (registry+https://github.com/rust-lang/crates.io-index)",
@ -33,7 +33,7 @@ name = "filetime"
version = "0.1.10"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"libc 0.2.9 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.2.10 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
@ -53,7 +53,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "kernel32-sys"
version = "0.2.1"
version = "0.2.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"winapi 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)",
@ -62,7 +62,7 @@ dependencies = [
[[package]]
name = "libc"
version = "0.2.9"
version = "0.2.10"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
@ -75,7 +75,7 @@ name = "num_cpus"
version = "0.2.11"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"libc 0.2.9 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.2.10 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]

View File

@ -92,8 +92,7 @@ pub fn std_link(build: &Build,
}
add_to_sysroot(&out_dir, &libdir);
if target.contains("musl") &&
(target.contains("x86_64") || target.contains("i686")) {
if target.contains("musl") && !target.contains("mips") {
copy_third_party_objects(build, target, &libdir);
}
}

View File

@ -109,7 +109,7 @@ pub fn check(build: &mut Build) {
}
// Make sure musl-root is valid if specified
if target.contains("musl") && (target.contains("x86_64") || target.contains("i686")) {
if target.contains("musl") && !target.contains("mips") {
match build.config.musl_root {
Some(ref root) => {
if fs::metadata(root.join("lib/libc.a")).is_err() {

View File

@ -16,7 +16,7 @@ libc = { path = "../rustc/libc_shim" }
[build-dependencies]
build_helper = { path = "../build_helper" }
gcc = "0.3.17"
gcc = "0.3.27"
[features]
debug = []

View File

@ -73,7 +73,16 @@ fn main() {
.replace("\\", "/"))
.current_dir(&build_dir)
.env("CC", compiler.path())
.env("EXTRA_CFLAGS", cflags)
.env("EXTRA_CFLAGS", cflags.clone())
// jemalloc generates Makefile deps using GCC's "-MM" flag. This means
// that GCC will run the preprocessor, and only the preprocessor, over
// jemalloc's source files. If we don't specify CPPFLAGS, then at least
// on ARM that step fails with a "Missing implementation for 32-bit
// atomic operations" error. This is because no "-march" flag will be
// passed to GCC, and then GCC won't define the
// "__GCC_HAVE_SYNC_COMPARE_AND_SWAP_4" macro that jemalloc needs to
// select an atomic operation implementation.
.env("CPPFLAGS", cflags.clone())
.env("AR", &ar)
.env("RANLIB", format!("{} s", ar.display()));

View File

@ -11,4 +11,4 @@ crate-type = ["dylib"]
[build-dependencies]
build_helper = { path = "../build_helper" }
gcc = "0.3"
gcc = "0.3.27"

@ -1 +1 @@
Subproject commit b0d62534d48b711c8978d1bbe8cca0558ae7b1cb
Subproject commit 5066b7dcab7e700844b0e2ba71b8af9dc627a59b

View File

@ -0,0 +1,34 @@
// Copyright 2016 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 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.
use target::{Target, TargetResult};
pub fn target() -> TargetResult {
let mut base = super::linux_musl_base::opts();
// Most of these settings are copied from the arm_unknown_linux_gnueabi
// target.
base.features = "+v6".to_string();
base.max_atomic_width = 64;
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: "arm-unknown-linux-gnueabi".to_string(),
target_endian: "little".to_string(),
target_pointer_width: "32".to_string(),
data_layout: "e-m:e-p:32:32-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(),
options: base,
})
}

View File

@ -0,0 +1,34 @@
// Copyright 2016 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 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.
use target::{Target, TargetResult};
pub fn target() -> TargetResult {
let mut base = super::linux_musl_base::opts();
// Most of these settings are copied from the arm_unknown_linux_gnueabihf
// target.
base.features = "+v6,+vfp2".to_string();
base.max_atomic_width = 64;
Ok(Target {
// It's important we use "gnueabihf" and not "musleabihf" here. LLVM
// uses it to determine the calling convention and float ABI, and it
// doesn't support the "musleabihf" value.
llvm_target: "arm-unknown-linux-gnueabihf".to_string(),
target_endian: "little".to_string(),
target_pointer_width: "32".to_string(),
data_layout: "e-m:e-p:32:32-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(),
options: base,
})
}

View File

@ -0,0 +1,35 @@
// Copyright 2016 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 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.
use target::{Target, TargetResult};
pub fn target() -> TargetResult {
let mut base = super::linux_musl_base::opts();
// Most of these settings are copied from the armv7_unknown_linux_gnueabihf
// target.
base.features = "+v7,+vfp3,+neon".to_string();
base.cpu = "cortex-a8".to_string();
base.max_atomic_width = 64;
Ok(Target {
// It's important we use "gnueabihf" and not "musleabihf" here. LLVM
// uses it to determine the calling convention and float ABI, and LLVM
// doesn't support the "musleabihf" value.
llvm_target: "armv7-unknown-linux-gnueabihf".to_string(),
target_endian: "little".to_string(),
target_pointer_width: "32".to_string(),
data_layout: "e-m:e-p:32:32-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(),
options: base,
})
}

View File

@ -134,7 +134,10 @@ supported_targets! {
("powerpc64le-unknown-linux-gnu", powerpc64le_unknown_linux_gnu),
("arm-unknown-linux-gnueabi", arm_unknown_linux_gnueabi),
("arm-unknown-linux-gnueabihf", arm_unknown_linux_gnueabihf),
("arm-unknown-linux-musleabi", arm_unknown_linux_musleabi),
("arm-unknown-linux-musleabihf", arm_unknown_linux_musleabihf),
("armv7-unknown-linux-gnueabihf", armv7_unknown_linux_gnueabihf),
("armv7-unknown-linux-musleabihf", armv7_unknown_linux_musleabihf),
("aarch64-unknown-linux-gnu", aarch64_unknown_linux_gnu),
("x86_64-unknown-linux-musl", x86_64_unknown_linux_musl),
("i686-unknown-linux-musl", i686_unknown_linux_musl),

View File

@ -17,4 +17,4 @@ rustc_bitflags = { path = "../librustc_bitflags" }
[build-dependencies]
build_helper = { path = "../build_helper" }
gcc = "0.3"
gcc = "0.3.27"

View File

@ -28,4 +28,4 @@ log = { path = "../liblog" }
[build-dependencies]
build_helper = { path = "../build_helper" }
gcc = "0.3"
gcc = "0.3.27"

View File

@ -24,7 +24,7 @@ unwind = { path = "../libunwind" }
[build-dependencies]
build_helper = { path = "../build_helper" }
gcc = "0.3"
gcc = "0.3.27"
[features]
backtrace = []

View File

@ -16,7 +16,7 @@ fn main() {
let target = env::var("TARGET").unwrap();
if target.contains("linux") {
if target.contains("musl") && (target.contains("x86_64") || target.contains("i686")) {
if target.contains("musl") && !target.contains("mips") {
println!("cargo:rustc-link-lib=static=unwind");
} else if !target.contains("android") {
println!("cargo:rustc-link-lib=gcc_s");

View File

@ -18,7 +18,7 @@ version = "0.0.0"
dependencies = [
"build_helper 0.1.0",
"core 0.0.0",
"gcc 0.3.26 (registry+https://github.com/rust-lang/crates.io-index)",
"gcc 0.3.27 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.0.0",
]
@ -49,7 +49,7 @@ version = "0.0.0"
[[package]]
name = "gcc"
version = "0.3.26"
version = "0.3.27"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
@ -101,7 +101,7 @@ dependencies = [
"build_helper 0.1.0",
"collections 0.0.0",
"core 0.0.0",
"gcc 0.3.26 (registry+https://github.com/rust-lang/crates.io-index)",
"gcc 0.3.27 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.0.0",
"panic_abort 0.0.0",
"panic_unwind 0.0.0",