Skip to content

Commit e940ffb

Browse files
committed
Link to libgcc when statically linking musl
1 parent 460fb13 commit e940ffb

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

src/unix/mod.rs

+10
Original file line numberDiff line numberDiff line change
@@ -285,6 +285,16 @@ 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 that
290+
// it uses internally. Unfortunately we don't provide these functions in
291+
// compiler-builtins, so we instead need to get them from libgcc.
292+
//
293+
// This is not a problem if we are linking to libc dynamically since the
294+
// libgcc dependency will automatically get picked up by the linker then.
295+
#[cfg_attr(feature = "stdbuild",
296+
link(name = "gcc", kind = "static",
297+
cfg(target_feature = "crt-static")))]
288298
#[cfg_attr(feature = "stdbuild",
289299
link(name = "c", kind = "static",
290300
cfg(target_feature = "crt-static")))]

0 commit comments

Comments
 (0)