Skip to content

Commit a74e56a

Browse files
committed
rust: add intrinsics to fix -Os builds
Alice reported [1] that an arm64 build failed with: ld.lld: error: undefined symbol: __extendsfdf2 >>> referenced by core.a6f5fc5794e7b7b3-cgu.0 >>> rust/core.o:(<f32>::midpoint) in archive vmlinux.a >>> referenced by core.a6f5fc5794e7b7b3-cgu.0 >>> rust/core.o:(<f32>::midpoint) in archive vmlinux.a ld.lld: error: undefined symbol: __truncdfsf2 >>> referenced by core.a6f5fc5794e7b7b3-cgu.0 >>> rust/core.o:(<f32>::midpoint) in archive vmlinux.a Rust 1.80.0 or later together with `CONFIG_CC_OPTIMIZE_FOR_SIZE=y` is what triggers it. In addition, x86_64 builds also fail the same way. Similarly, compiling with Rust 1.82.0 (currently in nightly) makes another one appear, possibly due to the LLVM 19 upgrade there: ld.lld: error: undefined symbol: __eqdf2 >>> referenced by core.20495ea57a9f069d-cgu.0 >>> rust/core.o:(<f64>::next_up) in archive vmlinux.a >>> referenced by core.20495ea57a9f069d-cgu.0 >>> rust/core.o:(<f64>::next_down) in archive vmlinux.a Gary adds [1]: > Usually the fix on rustc side is to mark those functions as `#[inline]` > > All of {midpoint,next_up,next_down} are indeed unstable functions not > marked as inline... Fix all those by adding those intrinsics to our usual workaround. [ Trevor quickly submitted a fix to upstream Rust [2] that has already been merged, to be released in Rust 1.82.0 (2024-10-17). - Miguel ] Cc: Gary Guo <gary@garyguo.net> Reported-by: Alice Ryhl <aliceryhl@google.com> Closes: https://rust-for-linux.zulipchat.com/#narrow/stream/x/topic/x/near/455637364 [1] Reviewed-by: Trevor Gross <tmgross@umich.edu> Tested-by: Alice Ryhl <aliceryhl@google.com> Tested-by: Boqun Feng <boqun.feng@gmail.com> Reviewed-by: Gary Guo <gary@garyguo.net> Link: rust-lang/rust#128749 [2] Link: https://lore.kernel.org/r/20240806150619.192882-1-ojeda@kernel.org [ Shortened Zulip link. - Miguel ] Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
1 parent 00d781e commit a74e56a

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

rust/Makefile

+2-2
Original file line numberDiff line numberDiff line change
@@ -354,8 +354,8 @@ rust-analyzer:
354354
$(if $(KBUILD_EXTMOD),$(extmod_prefix),$(objtree))/rust-project.json
355355

356356
redirect-intrinsics = \
357-
__addsf3 __eqsf2 __gesf2 __lesf2 __ltsf2 __mulsf3 __nesf2 __unordsf2 \
358-
__adddf3 __ledf2 __ltdf2 __muldf3 __unorddf2 \
357+
__addsf3 __eqsf2 __extendsfdf2 __gesf2 __lesf2 __ltsf2 __mulsf3 __nesf2 __truncdfsf2 __unordsf2 \
358+
__adddf3 __eqdf2 __ledf2 __ltdf2 __muldf3 __unorddf2 \
359359
__muloti4 __multi3 \
360360
__udivmodti4 __udivti3 __umodti3
361361

rust/compiler_builtins.rs

+3
Original file line numberDiff line numberDiff line change
@@ -40,16 +40,19 @@ macro_rules! define_panicking_intrinsics(
4040
define_panicking_intrinsics!("`f32` should not be used", {
4141
__addsf3,
4242
__eqsf2,
43+
__extendsfdf2,
4344
__gesf2,
4445
__lesf2,
4546
__ltsf2,
4647
__mulsf3,
4748
__nesf2,
49+
__truncdfsf2,
4850
__unordsf2,
4951
});
5052

5153
define_panicking_intrinsics!("`f64` should not be used", {
5254
__adddf3,
55+
__eqdf2,
5356
__ledf2,
5457
__ltdf2,
5558
__muldf3,

0 commit comments

Comments
 (0)