Skip to content

Commit eda72c5

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 2a93336 commit eda72c5

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
@@ -112,14 +112,17 @@ pub fn std_link(build: &Build,
112112
t!(fs::create_dir_all(&libdir));
113113
add_to_sysroot(&out_dir, &libdir);
114114

115-
if target.contains("musl") && !target.contains("mips") {
115+
if target.contains("musl") {
116116
copy_musl_third_party_objects(build, target, &libdir);
117117
}
118118
}
119119

120120
/// Copies the crt(1,i,n).o startup objects
121121
///
122-
/// Only required for musl targets that statically link to libc
122+
/// Since musl supports fully static linking, we can cross link for it even
123+
/// with a glibc-targeting toolchain, given we have the appropriate startup
124+
/// files. As those shipped with glibc won't work, copy the ones provided by
125+
/// musl so we have them on linux-gnu hosts.
123126
fn copy_musl_third_party_objects(build: &Build, target: &str, into: &Path) {
124127
for &obj in &["crt1.o", "crti.o", "crtn.o"] {
125128
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 macOS");
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)