Skip to content

Commit 2f34986

Browse files
committed
Auto merge of #32078 - japaric:rustbuild-i686-musl, r=alexcrichton
- 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. --- r? @alexcrichton
2 parents e079afa + f164433 commit 2f34986

File tree

6 files changed

+25
-6
lines changed

6 files changed

+25
-6
lines changed

src/bootstrap/build/compile.rs

+13
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,19 @@ pub fn std_link(build: &Build,
8383
libdir.join(staticlib("compiler-rt", target))));
8484
}
8585
add_to_sysroot(&out_dir, &libdir);
86+
87+
if target.contains("musl") && (target.contains("x86_64") || target.contains("i686")) {
88+
copy_third_party_objects(build, target, &libdir);
89+
}
90+
}
91+
92+
/// Copies the crt(1,i,n).o startup objects
93+
///
94+
/// Only required for musl targets that statically link to libc
95+
fn copy_third_party_objects(build: &Build, target: &str, into: &Path) {
96+
for &obj in &["crt1.o", "crti.o", "crtn.o"] {
97+
t!(fs::copy(compiler_file(build.cc(target), obj), into.join(obj)));
98+
}
8699
}
87100

88101
/// Build and prepare startup objects like rsbegin.o and rsend.o

src/bootstrap/build/sanity.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ pub fn check(build: &mut Build) {
7979
}
8080

8181
// Make sure musl-root is valid if specified
82-
if target.contains("musl") && target.contains("x86_64") {
82+
if target.contains("musl") && (target.contains("x86_64") || target.contains("i686")) {
8383
match build.config.musl_root {
8484
Some(ref root) => {
8585
if fs::metadata(root.join("lib/libc.a")).is_err() {

src/liballoc_jemalloc/build.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ fn main() {
111111
println!("cargo:rustc-link-search=native={}/lib", build_dir.display());
112112
if target.contains("android") {
113113
println!("cargo:rustc-link-lib=gcc");
114-
} else if !target.contains("windows") {
114+
} else if !target.contains("windows") && !target.contains("musl") {
115115
println!("cargo:rustc-link-lib=pthread");
116116
}
117117
}

src/libstd/build.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ fn main() {
2828
}
2929

3030
if target.contains("unknown-linux") {
31-
if target.contains("musl") && target.contains("x86_64") {
31+
if target.contains("musl") && (target.contains("x86_64") || target.contains("i686")) {
3232
println!("cargo:rustc-link-lib=static=unwind");
3333
} else {
3434
println!("cargo:rustc-link-lib=dl");

src/libstd/sys/common/libunwind.rs

+8-2
Original file line numberDiff line numberDiff line change
@@ -106,9 +106,15 @@ pub type _Unwind_Exception_Cleanup_Fn =
106106
#[cfg_attr(any(all(target_os = "linux", not(target_env = "musl")),
107107
target_os = "freebsd",
108108
target_os = "solaris",
109-
all(target_os = "linux", target_env = "musl", not(target_arch = "x86_64"))),
109+
all(target_os = "linux",
110+
target_env = "musl",
111+
not(target_arch = "x86"),
112+
not(target_arch = "x86_64"))),
110113
link(name = "gcc_s"))]
111-
#[cfg_attr(all(target_os = "linux", target_env = "musl", target_arch = "x86_64", not(test)),
114+
#[cfg_attr(all(target_os = "linux",
115+
target_env = "musl",
116+
any(target_arch = "x86", target_arch = "x86_64"),
117+
not(test)),
112118
link(name = "unwind", kind = "static"))]
113119
#[cfg_attr(any(target_os = "android", target_os = "openbsd"),
114120
link(name = "gcc"))]

0 commit comments

Comments
 (0)