rust: remove x86 panicking intrinsics.
RFC PATCH 1/1 rust: remove x86 panicking intrinsics.
This removes the panicking implementation of the x86 intrinsics.
This requires a PR [0] for the rust core library to remove the need for the __udivti3 intrinsic. This PR disables formatting support for the i/u128 rust primitives when the no_iu128_fmt config option is set.
In order to remove the need for the other intrinsics a recent rust version is required (Tested with 1.84).
---
This patch removes the need to use define_panicking_intrinsics for adding stub intrinsics implementations on x86.
This came up in a discussion [0] on my 32-bit arm support. The define_panicking_intrinsics macro is kept, because it will still be needed for 32-bit arm (and possibly other architecures).
Removing the __udivti3 intrinsic requires a Rust PR [1] and the other intrinsics only require a recent rust version (tested with 1.84), so when building with older rust versions would still require these intrinsics.
For now this is mostly done as a demonstration that this should be possible to do once the MSRV is bumped high enough (and possibly my Rust PR is merged).
I have tested building a x86_64 kernel and running the rust samples in qemu.
--- rust/Makefile | 15 +-------------- rust/compiler_builtins.rs | 37 +------------------------------------ 2 files changed, 2 insertions(+), 50 deletions(-)
rust/Makefile +1 -14
@@ -53,7 +53,7 @@ rustdoc_test_kernel_quiet=>/dev/null endif core-cfgs = \ - --cfg no_fp_fmt_parse + --cfg no_fp_fmt_parse --cfg no_iu128_fmt quiet_cmd_rustdoc = RUSTDOC $(if $(rustdoc_host),H, ) $< cmd_rustdoc = \
@@ -388,19 +388,6 @@ rust-analyzer: $(rustc_sysroot) $(RUST_LIB_SRC) $(if $(KBUILD_EXTMOD),$(srcroot)) \ > rust-project.json -redirect-intrinsics = \ - __addsf3 __eqsf2 __extendsfdf2 __gesf2 __lesf2 __ltsf2 __mulsf3 __nesf2 __truncdfsf2 __unordsf2 \ - __adddf3 __eqdf2 __ledf2 __ltdf2 __muldf3 __unorddf2 \ - __muloti4 __multi3 \ - __udivmodti4 __udivti3 __umodti3 - -ifneq ($(or $(CONFIG_ARM64),$(and $(CONFIG_RISCV),$(CONFIG_64BIT))),) - # These intrinsics are defined for ARM64 and RISCV64 - redirect-intrinsics += \ - __ashrti3 \ - __ashlti3 __lshrti3 -endif - define rule_rustc_library $(call cmd_and_fixdep,rustc_library) $(call cmd,gen_objtooldep)
rust/compiler_builtins.rs +1 -36
@@ -25,6 +25,7 @@#![no_builtins] #![no_std] +#[expect(unused_macros)] macro_rules! define_panicking_intrinsics( ($reason: tt, { $($ident: ident, )* }) => { $(
@@ -37,41 +38,5 @@ 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, - __unorddf2, -}); - -define_panicking_intrinsics! ("`i128` should not be used" , { - __ashrti3, - __muloti4, - __multi3, -}); - -define_panicking_intrinsics! ("`u128` should not be used" , { - __ashlti3, - __lshrti3, - __udivmodti4, - __udivti3, - __umodti3, -}); -// NOTE: if you are adding a new intrinsic here, you should also add it to // `redirect-intrinsics` in `rust/Makefile`.
---
base-commit: ffd294d346d185b70e28b1a28abe367bbfe53c04
change-id: 20250201-remove_intrinsic-27749d5f93ac
Best regards,
Signature · 1 line
Christian Schrefl <[email protected]>