Skip to content

Commit 37e3a22

Browse files
committed
Auto merge of #1034 - Amanieu:musl_libgcc, r=alexcrichton
Link to libgcc when statically linking musl On some architectures (e.g. aarch64) musl depends on some libgcc functions (`__addtf3`, `__multf3`, `__subtf3`) for `long double` arithmetic that it uses internally. Unfortunately we don't provide these functions in compiler-builtins, so we instead need to get them from libgcc. Fixes: rust-lang/rust#46651 rust-lang/compiler-builtins#201 rust-lang/compiler-builtins#217
2 parents 9f54322 + 920cfea commit 37e3a22

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

src/unix/mod.rs

+12
Original file line numberDiff line numberDiff line change
@@ -285,6 +285,18 @@ cfg_if! {
285285
// cargo build, don't pull in anything extra as the libstd dep
286286
// already pulls in all libs.
287287
} else if #[cfg(target_env = "musl")] {
288+
// On some architectures (e.g. aarch64) musl depends on some libgcc
289+
// functions (__addtf3, __multf3, __subtf3) for long double arithmetic
290+
// that it uses internally. Unfortunately we don't provide these
291+
// functions in compiler-builtins, so we instead need to get them from
292+
// libgcc.
293+
//
294+
// This is not a problem if we are linking to libc dynamically since the
295+
// libgcc dependency will automatically get picked up by the linker
296+
// then.
297+
#[cfg_attr(feature = "stdbuild",
298+
link(name = "gcc", kind = "static",
299+
cfg(target_feature = "crt-static")))]
288300
#[cfg_attr(feature = "stdbuild",
289301
link(name = "c", kind = "static",
290302
cfg(target_feature = "crt-static")))]

0 commit comments

Comments
 (0)