Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add ARM MUSL targets #35060

Merged
merged 9 commits into from
Jul 31, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion configure
Original file line number Diff line number Diff line change
@@ -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"
3 changes: 3 additions & 0 deletions mk/cfg/arm-unknown-linux-musleabi.mk
Original file line number Diff line number Diff line change
@@ -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.
3 changes: 3 additions & 0 deletions mk/cfg/arm-unknown-linux-musleabihf.mk
Original file line number Diff line number Diff line change
@@ -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.
3 changes: 3 additions & 0 deletions mk/cfg/armv7-unknown-linux-musleabihf.mk
Original file line number Diff line number Diff line change
@@ -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.
12 changes: 6 additions & 6 deletions src/bootstrap/Cargo.lock

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

3 changes: 1 addition & 2 deletions src/bootstrap/compile.rs
Original file line number Diff line number Diff line change
@@ -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);
}
}
2 changes: 1 addition & 1 deletion src/bootstrap/sanity.rs
Original file line number Diff line number Diff line change
@@ -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() {
2 changes: 1 addition & 1 deletion src/liballoc_jemalloc/Cargo.toml
Original file line number Diff line number Diff line change
@@ -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 = []
11 changes: 10 additions & 1 deletion src/liballoc_jemalloc/build.rs
Original file line number Diff line number Diff line change
@@ -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()));

2 changes: 1 addition & 1 deletion src/libflate/Cargo.toml
Original file line number Diff line number Diff line change
@@ -11,4 +11,4 @@ crate-type = ["dylib"]

[build-dependencies]
build_helper = { path = "../build_helper" }
gcc = "0.3"
gcc = "0.3.27"
34 changes: 34 additions & 0 deletions src/librustc_back/target/arm_unknown_linux_musleabi.rs
Original file line number Diff line number Diff line change
@@ -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,
})
}
34 changes: 34 additions & 0 deletions src/librustc_back/target/arm_unknown_linux_musleabihf.rs
Original file line number Diff line number Diff line change
@@ -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,
})
}
35 changes: 35 additions & 0 deletions src/librustc_back/target/armv7_unknown_linux_musleabihf.rs
Original file line number Diff line number Diff line change
@@ -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,
})
}
3 changes: 3 additions & 0 deletions src/librustc_back/target/mod.rs
Original file line number Diff line number Diff line change
@@ -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),
2 changes: 1 addition & 1 deletion src/librustc_llvm/Cargo.toml
Original file line number Diff line number Diff line change
@@ -17,4 +17,4 @@ rustc_bitflags = { path = "../librustc_bitflags" }

[build-dependencies]
build_helper = { path = "../build_helper" }
gcc = "0.3"
gcc = "0.3.27"
2 changes: 1 addition & 1 deletion src/librustdoc/Cargo.toml
Original file line number Diff line number Diff line change
@@ -28,4 +28,4 @@ log = { path = "../liblog" }

[build-dependencies]
build_helper = { path = "../build_helper" }
gcc = "0.3"
gcc = "0.3.27"
2 changes: 1 addition & 1 deletion src/libstd/Cargo.toml
Original file line number Diff line number Diff line change
@@ -24,7 +24,7 @@ unwind = { path = "../libunwind" }

[build-dependencies]
build_helper = { path = "../build_helper" }
gcc = "0.3"
gcc = "0.3.27"

[features]
backtrace = []
2 changes: 1 addition & 1 deletion src/libunwind/build.rs
Original file line number Diff line number Diff line change
@@ -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");
6 changes: 3 additions & 3 deletions src/rustc/std_shim/Cargo.lock

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