diff options
| author | Jorge Aparicio <japaricious@gmail.com> | 2016-03-06 08:19:51 -0500 |
|---|---|---|
| committer | Jorge Aparicio <japaricious@gmail.com> | 2016-03-06 08:19:51 -0500 |
| commit | 0b7fc0653bfd19f650a2fbad987b2fe03715e6b4 (patch) | |
| tree | 5d778f54cf1fa06d0382944ed47a68a93c74367f | |
| parent | c116ae35cf49b55bd8d82e31f1ba030cf7e63867 (diff) | |
| download | rust-0b7fc0653bfd19f650a2fbad987b2fe03715e6b4.tar.gz rust-0b7fc0653bfd19f650a2fbad987b2fe03715e6b4.zip | |
rustbuild: fix cross compilation of libstd to i686-unknown-linux-musl
- make sure we copy the third party objects (crt*.o) to the target stage directory. - apply the x86_64-musl logic also to the i686-musl target.
| -rw-r--r-- | src/bootstrap/build/compile.rs | 13 | ||||
| -rw-r--r-- | src/bootstrap/build/sanity.rs | 2 | ||||
| -rw-r--r-- | src/liballoc_jemalloc/build.rs | 2 | ||||
| -rw-r--r-- | src/libstd/build.rs | 2 | ||||
| -rw-r--r-- | src/libstd/sys/common/libunwind.rs | 10 |
5 files changed, 24 insertions, 5 deletions
diff --git a/src/bootstrap/build/compile.rs b/src/bootstrap/build/compile.rs index 3be4199352c..fb0a840bfa2 100644 --- a/src/bootstrap/build/compile.rs +++ b/src/bootstrap/build/compile.rs @@ -83,6 +83,19 @@ pub fn std_link(build: &Build, libdir.join(staticlib("compiler-rt", target)))); } add_to_sysroot(&out_dir, &libdir); + + if target.contains("musl") && (target.contains("x86_64") || target.contains("i686")) { + copy_third_party_objects(build, target, &libdir); + } +} + +/// Copies the crt(1,i,n).o startup objects +/// +/// Only required for musl targets that statically link to libc +fn copy_third_party_objects(build: &Build, target: &str, into: &Path) { + for &obj in &["crt1.o", "crti.o", "crtn.o"] { + t!(fs::copy(compiler_file(build.cc(target), obj), into.join(obj))); + } } /// Build and prepare startup objects like rsbegin.o and rsend.o diff --git a/src/bootstrap/build/sanity.rs b/src/bootstrap/build/sanity.rs index 6ac581a7c69..be4416c697c 100644 --- a/src/bootstrap/build/sanity.rs +++ b/src/bootstrap/build/sanity.rs @@ -79,7 +79,7 @@ pub fn check(build: &mut Build) { } // Make sure musl-root is valid if specified - if target.contains("musl") && target.contains("x86_64") { + if target.contains("musl") && (target.contains("x86_64") || target.contains("i686")) { match build.config.musl_root { Some(ref root) => { if fs::metadata(root.join("lib/libc.a")).is_err() { diff --git a/src/liballoc_jemalloc/build.rs b/src/liballoc_jemalloc/build.rs index c9508322a31..9e2090c3246 100644 --- a/src/liballoc_jemalloc/build.rs +++ b/src/liballoc_jemalloc/build.rs @@ -111,7 +111,7 @@ fn main() { println!("cargo:rustc-link-search=native={}/lib", build_dir.display()); if target.contains("android") { println!("cargo:rustc-link-lib=gcc"); - } else if !target.contains("windows") { + } else if !target.contains("windows") && !target.contains("musl") { println!("cargo:rustc-link-lib=pthread"); } } diff --git a/src/libstd/build.rs b/src/libstd/build.rs index c60ec4d3655..1c8375479ca 100644 --- a/src/libstd/build.rs +++ b/src/libstd/build.rs @@ -28,7 +28,7 @@ fn main() { } if target.contains("unknown-linux") { - if target.contains("musl") && target.contains("x86_64") { + if target.contains("musl") && (target.contains("x86_64") || target.contains("i686")) { println!("cargo:rustc-link-lib=static=unwind"); } else { println!("cargo:rustc-link-lib=dl"); diff --git a/src/libstd/sys/common/libunwind.rs b/src/libstd/sys/common/libunwind.rs index 3f70afe6ad7..c1e9782852a 100644 --- a/src/libstd/sys/common/libunwind.rs +++ b/src/libstd/sys/common/libunwind.rs @@ -106,9 +106,15 @@ pub type _Unwind_Exception_Cleanup_Fn = #[cfg_attr(any(all(target_os = "linux", not(target_env = "musl")), target_os = "freebsd", target_os = "solaris", - all(target_os = "linux", target_env = "musl", not(target_arch = "x86_64"))), + all(target_os = "linux", + target_env = "musl", + not(target_arch = "x86"), + not(target_arch = "x86_64"))), link(name = "gcc_s"))] -#[cfg_attr(all(target_os = "linux", target_env = "musl", target_arch = "x86_64", not(test)), +#[cfg_attr(all(target_os = "linux", + target_env = "musl", + any(target_arch = "x86", target_arch = "x86_64"), + not(test)), link(name = "unwind", kind = "static"))] #[cfg_attr(any(target_os = "android", target_os = "openbsd"), link(name = "gcc"))] |
