* Re: [PATCH] rust: add intrinsics to fix `-Os` builds
2024-08-06 15:06 [PATCH] rust: add intrinsics to fix `-Os` builds Miguel Ojeda
@ 2024-08-06 15:41 ` Alice Ryhl
2024-08-06 17:27 ` Boqun Feng
` (3 subsequent siblings)
4 siblings, 0 replies; 8+ messages in thread
From: Alice Ryhl @ 2024-08-06 15:41 UTC (permalink / raw)
To: Miguel Ojeda
Cc: Alex Gaynor, Wedson Almeida Filho, Nathan Chancellor, Boqun Feng,
Gary Guo, Björn Roy Baron, Benno Lossin, Andreas Hindborg,
rust-for-linux, Nick Desaulniers, Bill Wendling, Justin Stitt,
llvm, linux-kernel, patches
On Tue, Aug 6, 2024 at 5:06 PM Miguel Ojeda <ojeda@kernel.org> wrote:
>
> 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.
>
> Cc: Gary Guo <gary@garyguo.net>
> Reported-by: Alice Ryhl <aliceryhl@google.com>
> Closes: https://rust-for-linux.zulipchat.com/#narrow/stream/288089-General/topic/v6.2E11-rc1.20doesn't.20build.20for.20arm64/near/455637364
> Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
This fixes the issue I ran into.
Tested-by: Alice Ryhl <aliceryhl@google.com>
^ permalink raw reply [flat|nested] 8+ messages in thread* Re: [PATCH] rust: add intrinsics to fix `-Os` builds
2024-08-06 15:06 [PATCH] rust: add intrinsics to fix `-Os` builds Miguel Ojeda
2024-08-06 15:41 ` Alice Ryhl
@ 2024-08-06 17:27 ` Boqun Feng
2024-08-06 17:30 ` Miguel Ojeda
2024-08-06 18:30 ` Trevor Gross
` (2 subsequent siblings)
4 siblings, 1 reply; 8+ messages in thread
From: Boqun Feng @ 2024-08-06 17:27 UTC (permalink / raw)
To: Miguel Ojeda
Cc: Alex Gaynor, Wedson Almeida Filho, Nathan Chancellor, Gary Guo,
Björn Roy Baron, Benno Lossin, Andreas Hindborg, Alice Ryhl,
rust-for-linux, Nick Desaulniers, Bill Wendling, Justin Stitt,
llvm, linux-kernel, patches
On Tue, Aug 06, 2024 at 05:06:19PM +0200, Miguel Ojeda wrote:
> 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.
>
> Cc: Gary Guo <gary@garyguo.net>
> Reported-by: Alice Ryhl <aliceryhl@google.com>
> Closes: https://rust-for-linux.zulipchat.com/#narrow/stream/288089-General/topic/v6.2E11-rc1.20doesn't.20build.20for.20arm64/near/455637364
> Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
Put this one into rust-dev and confirm this could fix the issue with
Rust 1.80. I also add a test with CONFIG_CC_OPTIMIZE_FOR_SIZE=y in my
rust-dev script, so we can catch the similar issues earlier.
Tested-by: Boqun Feng <boqun.feng@gmail.com>
Regards,
Boqun
> ---
> rust/Makefile | 4 ++--
> rust/compiler_builtins.rs | 3 +++
> 2 files changed, 5 insertions(+), 2 deletions(-)
>
> diff --git a/rust/Makefile b/rust/Makefile
> index 1f10f92737f2..77836388377d 100644
> --- a/rust/Makefile
> +++ b/rust/Makefile
> @@ -354,8 +354,8 @@ rust-analyzer:
> $(if $(KBUILD_EXTMOD),$(extmod_prefix),$(objtree))/rust-project.json
>
> redirect-intrinsics = \
> - __addsf3 __eqsf2 __gesf2 __lesf2 __ltsf2 __mulsf3 __nesf2 __unordsf2 \
> - __adddf3 __ledf2 __ltdf2 __muldf3 __unorddf2 \
> + __addsf3 __eqsf2 __extendsfdf2 __gesf2 __lesf2 __ltsf2 __mulsf3 __nesf2 __truncdfsf2 __unordsf2 \
> + __adddf3 __eqdf2 __ledf2 __ltdf2 __muldf3 __unorddf2 \
> __muloti4 __multi3 \
> __udivmodti4 __udivti3 __umodti3
>
> diff --git a/rust/compiler_builtins.rs b/rust/compiler_builtins.rs
> index bba2922c6ef7..f14b8d7caf89 100644
> --- a/rust/compiler_builtins.rs
> +++ b/rust/compiler_builtins.rs
> @@ -40,16 +40,19 @@ pub extern "C" fn $ident() {
> define_panicking_intrinsics!("`f32` should not be used", {
> __addsf3,
> __eqsf2,
> + __extendsfdf2,
> __gesf2,
> __lesf2,
> __ltsf2,
> __mulsf3,
> __nesf2,
> + __truncdfsf2,
> __unordsf2,
> });
>
> define_panicking_intrinsics!("`f64` should not be used", {
> __adddf3,
> + __eqdf2,
> __ledf2,
> __ltdf2,
> __muldf3,
>
> base-commit: de9c2c66ad8e787abec7c9d7eff4f8c3cdd28aed
> --
> 2.46.0
>
>
^ permalink raw reply [flat|nested] 8+ messages in thread* Re: [PATCH] rust: add intrinsics to fix `-Os` builds
2024-08-06 17:27 ` Boqun Feng
@ 2024-08-06 17:30 ` Miguel Ojeda
0 siblings, 0 replies; 8+ messages in thread
From: Miguel Ojeda @ 2024-08-06 17:30 UTC (permalink / raw)
To: Boqun Feng
Cc: Miguel Ojeda, Alex Gaynor, Wedson Almeida Filho,
Nathan Chancellor, Gary Guo, Björn Roy Baron, Benno Lossin,
Andreas Hindborg, Alice Ryhl, rust-for-linux, Nick Desaulniers,
Bill Wendling, Justin Stitt, llvm, linux-kernel, patches
On Tue, Aug 6, 2024 at 7:28 PM Boqun Feng <boqun.feng@gmail.com> wrote:
>
> Put this one into rust-dev and confirm this could fix the issue with
> Rust 1.80. I also add a test with CONFIG_CC_OPTIMIZE_FOR_SIZE=y in my
> rust-dev script, so we can catch the similar issues earlier.
+1, same on my side.
Cheers,
Miguel
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] rust: add intrinsics to fix `-Os` builds
2024-08-06 15:06 [PATCH] rust: add intrinsics to fix `-Os` builds Miguel Ojeda
2024-08-06 15:41 ` Alice Ryhl
2024-08-06 17:27 ` Boqun Feng
@ 2024-08-06 18:30 ` Trevor Gross
2024-08-06 21:14 ` Miguel Ojeda
2024-08-07 13:03 ` Gary Guo
2024-08-09 22:10 ` Miguel Ojeda
4 siblings, 1 reply; 8+ messages in thread
From: Trevor Gross @ 2024-08-06 18:30 UTC (permalink / raw)
To: Miguel Ojeda
Cc: Alex Gaynor, Wedson Almeida Filho, Nathan Chancellor, Boqun Feng,
Gary Guo, Björn Roy Baron, Benno Lossin, Andreas Hindborg,
Alice Ryhl, rust-for-linux, Nick Desaulniers, Bill Wendling,
Justin Stitt, llvm, linux-kernel, patches
On Tue, Aug 6, 2024 at 11:06 AM Miguel Ojeda <ojeda@kernel.org> wrote:
>
> 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.
>
> Cc: Gary Guo <gary@garyguo.net>
> Reported-by: Alice Ryhl <aliceryhl@google.com>
> Closes: https://rust-for-linux.zulipchat.com/#narrow/stream/288089-General/topic/v6.2E11-rc1.20doesn't.20build.20for.20arm64/near/455637364
Should this link have the `[1]`?
> Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
> ---
> rust/Makefile | 4 ++--
> rust/compiler_builtins.rs | 3 +++
> 2 files changed, 5 insertions(+), 2 deletions(-)
Reviewed-by: Trevor Gross <tmgross@umich.edu>
Also submitted a fix upstream https://github.com/rust-lang/rust/pull/128749.
- Trevor
^ permalink raw reply [flat|nested] 8+ messages in thread* Re: [PATCH] rust: add intrinsics to fix `-Os` builds
2024-08-06 18:30 ` Trevor Gross
@ 2024-08-06 21:14 ` Miguel Ojeda
0 siblings, 0 replies; 8+ messages in thread
From: Miguel Ojeda @ 2024-08-06 21:14 UTC (permalink / raw)
To: Trevor Gross
Cc: Miguel Ojeda, Alex Gaynor, Wedson Almeida Filho,
Nathan Chancellor, Boqun Feng, Gary Guo, Björn Roy Baron,
Benno Lossin, Andreas Hindborg, Alice Ryhl, rust-for-linux,
Nick Desaulniers, Bill Wendling, Justin Stitt, llvm, linux-kernel,
patches
On Tue, Aug 6, 2024 at 8:30 PM Trevor Gross <tmgross@umich.edu> wrote:
>
> Should this link have the `[1]`?
Yeah, good eyes :)
> Reviewed-by: Trevor Gross <tmgross@umich.edu>
>
> Also submitted a fix upstream https://github.com/rust-lang/rust/pull/128749.
Thanks a lot! Linked in the `core` sublist in issue #2.
Cheers,
Miguel
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] rust: add intrinsics to fix `-Os` builds
2024-08-06 15:06 [PATCH] rust: add intrinsics to fix `-Os` builds Miguel Ojeda
` (2 preceding siblings ...)
2024-08-06 18:30 ` Trevor Gross
@ 2024-08-07 13:03 ` Gary Guo
2024-08-09 22:10 ` Miguel Ojeda
4 siblings, 0 replies; 8+ messages in thread
From: Gary Guo @ 2024-08-07 13:03 UTC (permalink / raw)
To: Miguel Ojeda
Cc: Alex Gaynor, Wedson Almeida Filho, Nathan Chancellor, Boqun Feng,
Björn Roy Baron, Benno Lossin, Andreas Hindborg, Alice Ryhl,
rust-for-linux, Nick Desaulniers, Bill Wendling, Justin Stitt,
llvm, linux-kernel, patches
On Tue, 6 Aug 2024 17:06:19 +0200
Miguel Ojeda <ojeda@kernel.org> wrote:
> 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.
>
> Cc: Gary Guo <gary@garyguo.net>
> Reported-by: Alice Ryhl <aliceryhl@google.com>
> Closes: https://rust-for-linux.zulipchat.com/#narrow/stream/288089-General/topic/v6.2E11-rc1.20doesn't.20build.20for.20arm64/near/455637364
> Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
Reviewed-by: Gary Guo <gary@garyguo.net>
> ---
> rust/Makefile | 4 ++--
> rust/compiler_builtins.rs | 3 +++
> 2 files changed, 5 insertions(+), 2 deletions(-)
^ permalink raw reply [flat|nested] 8+ messages in thread* Re: [PATCH] rust: add intrinsics to fix `-Os` builds
2024-08-06 15:06 [PATCH] rust: add intrinsics to fix `-Os` builds Miguel Ojeda
` (3 preceding siblings ...)
2024-08-07 13:03 ` Gary Guo
@ 2024-08-09 22:10 ` Miguel Ojeda
4 siblings, 0 replies; 8+ messages in thread
From: Miguel Ojeda @ 2024-08-09 22:10 UTC (permalink / raw)
To: Miguel Ojeda
Cc: Alex Gaynor, Wedson Almeida Filho, Nathan Chancellor, Boqun Feng,
Gary Guo, Björn Roy Baron, Benno Lossin, Andreas Hindborg,
Alice Ryhl, rust-for-linux, Nick Desaulniers, Bill Wendling,
Justin Stitt, llvm, linux-kernel, patches
On Tue, Aug 6, 2024 at 5:06 PM Miguel Ojeda <ojeda@kernel.org> wrote:
>
> 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.
>
> Cc: Gary Guo <gary@garyguo.net>
> Reported-by: Alice Ryhl <aliceryhl@google.com>
> Closes: https://rust-for-linux.zulipchat.com/#narrow/stream/288089-General/topic/v6.2E11-rc1.20doesn't.20build.20for.20arm64/near/455637364
> Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
Applied to `rust-fixes` -- thanks everyone!
[ 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 ]
[ Shortened Zulip link. - Miguel ]
Cheers,
Miguel
^ permalink raw reply [flat|nested] 8+ messages in thread