Skip to content

Commit 470b62f

Browse files
committed
C library usage is not conditional upon architecture
These were conditioned on architecture because traditionally MIPS was dynamically linked, while other arches used musl for static linking. Now that we support both methods of linking on all architectures, these special cases no longer make sense Add a comment explaining why copying startup files is always necessary
1 parent 8edfb35 commit 470b62f

File tree

3 files changed

+8
-5
lines changed

3 files changed

+8
-5
lines changed

src/bootstrap/compile.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,14 +106,17 @@ pub fn std_link(build: &Build,
106106
t!(fs::create_dir_all(&libdir));
107107
add_to_sysroot(&out_dir, &libdir);
108108

109-
if target.contains("musl") && !target.contains("mips") {
109+
if target.contains("musl") {
110110
copy_musl_third_party_objects(build, target, &libdir);
111111
}
112112
}
113113

114114
/// Copies the crt(1,i,n).o startup objects
115115
///
116-
/// Only required for musl targets that statically link to libc
116+
/// Since musl supports fully static linking, we can cross link for it even
117+
/// with a glibc-targeting toolchain, given we have the appropriate startup
118+
/// files. As those shipped with glibc won't work, copy the ones provided by
119+
/// musl so we have them on linux-gnu hosts.
117120
fn copy_musl_third_party_objects(build: &Build, target: &str, into: &Path) {
118121
for &obj in &["crt1.o", "crti.o", "crtn.o"] {
119122
copy(&build.musl_root(target).unwrap().join("lib").join(obj), &into.join(obj));

src/bootstrap/sanity.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -157,8 +157,8 @@ pub fn check(build: &mut Build) {
157157
panic!("the iOS target is only supported on OSX");
158158
}
159159

160-
// Make sure musl-root is valid if specified
161-
if target.contains("musl") && !target.contains("mips") {
160+
// Make sure musl-root is valid
161+
if target.contains("musl") {
162162
match build.musl_root(target) {
163163
Some(root) => {
164164
if fs::metadata(root.join("lib/libc.a")).is_err() {

src/libunwind/build.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ fn main() {
1515
let target = env::var("TARGET").expect("TARGET was not set");
1616

1717
if target.contains("linux") {
18-
if target.contains("musl") && !target.contains("mips") {
18+
if target.contains("musl") {
1919
// musl is handled in lib.rs
2020
} else if !target.contains("android") {
2121
println!("cargo:rustc-link-lib=gcc_s");

0 commit comments

Comments
 (0)