Skip to content

Commit 9cc430d

Browse files
authored
Auto merge of #36144 - japaric:rustbuild-musl, r=alexcrichton
rustbuild: fix building std for musl targets closes #36143 r? @alexcrichton
2 parents 987b475 + 25145b2 commit 9cc430d

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

src/bootstrap/compile.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -93,16 +93,16 @@ pub fn std_link(build: &Build,
9393
add_to_sysroot(&out_dir, &libdir);
9494

9595
if target.contains("musl") && !target.contains("mips") {
96-
copy_third_party_objects(build, target, &libdir);
96+
copy_musl_third_party_objects(build, &libdir);
9797
}
9898
}
9999

100100
/// Copies the crt(1,i,n).o startup objects
101101
///
102102
/// Only required for musl targets that statically link to libc
103-
fn copy_third_party_objects(build: &Build, target: &str, into: &Path) {
103+
fn copy_musl_third_party_objects(build: &Build, into: &Path) {
104104
for &obj in &["crt1.o", "crti.o", "crtn.o"] {
105-
copy(&compiler_file(build.cc(target), obj), &into.join(obj));
105+
copy(&build.config.musl_root.as_ref().unwrap().join("lib").join(obj), &into.join(obj));
106106
}
107107
}
108108

src/libstd/build.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ fn main() {
3535
println!("cargo:rustc-link-lib=dl");
3636
println!("cargo:rustc-link-lib=log");
3737
println!("cargo:rustc-link-lib=gcc");
38-
} else {
38+
} else if !target.contains("musl") || target.contains("mips") {
3939
println!("cargo:rustc-link-lib=dl");
4040
println!("cargo:rustc-link-lib=rt");
4141
println!("cargo:rustc-link-lib=pthread");

0 commit comments

Comments
 (0)