Skip to content

Commit 8ed29b9

Browse files
committed
Link to libgcc when statically linking musl
Fixes rust-lang#46651
1 parent 9363342 commit 8ed29b9

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

src/librustc_target/spec/linux_musl_base.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,15 @@ pub fn opts() -> TargetOptions {
6060
base.pre_link_objects_exe_crt.push("crti.o".to_string());
6161
base.post_link_objects_crt.push("crtn.o".to_string());
6262

63+
// On some architectures (e.g. aarch64) musl depends on some libgcc
64+
// functions (__addtf3, __multf3, __subtf3) for long double arithmetic that
65+
// it uses internally. Unfortunately we don't provide these functions in
66+
// compiler-builtins, so we instead need to get them from libgcc.
67+
//
68+
// This is not a problem if we are linking to libc dynamically since the
69+
// libgcc dependency will automatically get picked up by the linker then.
70+
base.post_link_objects_crt.push("-lgcc".to_string());
71+
6372
// These targets statically link libc by default
6473
base.crt_static_default = true;
6574
// These targets allow the user to choose between static and dynamic linking.

0 commit comments

Comments
 (0)