-
Notifications
You must be signed in to change notification settings - Fork 13.4k
-Zregparm=3
support in rustc
#116972
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Comments
At present, Rust in the kernel only supports 64-bit x86, so UML has followed suit. However, it's significantly easier to support 32-bit i386 on UML than on bare metal, as UML does not use the -mregparm option (which alters the ABI), which is not yet supported by rustc[1]. Add support for CONFIG_RUST on um/i386, by adding a new target config to generate_rust_target, and replacing various checks on CONFIG_X86_64 to also support CONFIG_X86_32. We still use generate_rust_target, rather than a built-in rustc target, in order to match x86_64, provide a future place for -mregparm, and more easily disable floating point instructions. With these changes, the KUnit tests pass with: kunit.py run --make_options LLVM=1 --kconfig_add CONFIG_RUST=y --kconfig_add CONFIG_64BIT=n --kconfig_add CONFIG_FORTIFY_SOURCE=n An earlier version of these changes was proposed on the Rust-for-Linux github[2]. [1]: rust-lang/rust#116972 [2]: Rust-for-Linux#966 Signed-off-by: David Gow <davidgow@google.com>
At present, Rust in the kernel only supports 64-bit x86, so UML has followed suit. However, it's significantly easier to support 32-bit i386 on UML than on bare metal, as UML does not use the -mregparm option (which alters the ABI), which is not yet supported by rustc[1]. Add support for CONFIG_RUST on um/i386, by adding a new target config to generate_rust_target, and replacing various checks on CONFIG_X86_64 to also support CONFIG_X86_32. We still use generate_rust_target, rather than a built-in rustc target, in order to match x86_64, provide a future place for -mregparm, and more easily disable floating point instructions. With these changes, the KUnit tests pass with: kunit.py run --make_options LLVM=1 --kconfig_add CONFIG_RUST=y --kconfig_add CONFIG_64BIT=n --kconfig_add CONFIG_FORTIFY_SOURCE=n An earlier version of these changes was proposed on the Rust-for-Linux github[2]. [1]: rust-lang/rust#116972 [2]: Rust-for-Linux#966 Signed-off-by: David Gow <davidgow@google.com> Link: https://patch.msgid.link/20240604224052.3138504-1-davidgow@google.com Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Indeed, something like this has to be done for stabilization -- we have to make sure we detect linking crates that use different values for this flag. (Also, that means without stable |
Thanks @RalfJung and yes I think we can go through a stabilization process, I have some draft code for just llvm here vincenzopalazzo@84945fd |
…jubilee,pnkfelix rust_for_linux: -Zregparm=<N> commandline flag for X86 (rust-lang#116972) Command line flag `-Zregparm=<N>` for X86 (32-bit) for rust-for-linux: rust-lang#116972 Implemented in the similar way as fastcall/vectorcall support (args are marked InReg if fit).
Rollup of 6 pull requests Successful merges: - rust-lang#129935 (make unsupported_calling_conventions a hard error) - rust-lang#130432 (rust_for_linux: -Zregparm=<N> commandline flag for X86 (rust-lang#116972)) - rust-lang#131697 (`rt::Argument`: elide lifetimes) - rust-lang#131954 (shave 150ms off bootstrap) - rust-lang#131982 (Represent `hir::TraitBoundModifiers` as distinct parts in HIR) - rust-lang#132017 (Update triagebot.toml) r? `@ghost` `@rustbot` modify labels: rollup
…jubilee,pnkfelix rust_for_linux: -Zregparm=<N> commandline flag for X86 (rust-lang#116972) Command line flag `-Zregparm=<N>` for X86 (32-bit) for rust-for-linux: rust-lang#116972 Implemented in the similar way as fastcall/vectorcall support (args are marked InReg if fit).
…kingjubilee Rollup of 6 pull requests Successful merges: - rust-lang#130432 (rust_for_linux: -Zregparm=<N> commandline flag for X86 (rust-lang#116972)) - rust-lang#131697 (`rt::Argument`: elide lifetimes) - rust-lang#131807 (Always specify `llvm_abiname` for RISC-V targets) - rust-lang#131954 (shave 150ms off bootstrap) - rust-lang#132015 (Move const trait tests from `ui/rfcs/rfc-2632-const-trait-impl` to `ui/traits/const-traits`) - rust-lang#132017 (Update triagebot.toml) r? `@ghost` `@rustbot` modify labels: rollup
Rollup merge of rust-lang#130432 - azhogin:azhogin/regparm, r=workingjubilee,pnkfelix rust_for_linux: -Zregparm=<N> commandline flag for X86 (rust-lang#116972) Command line flag `-Zregparm=<N>` for X86 (32-bit) for rust-for-linux: rust-lang#116972 Implemented in the similar way as fastcall/vectorcall support (args are marked InReg if fit).
See #131749. |
…nkfelix rust_for_linux: -Zregparm=<N> commandline flag for X86 (#116972) Command line flag `-Zregparm=<N>` for X86 (32-bit) for rust-for-linux: rust-lang/rust#116972 Implemented in the similar way as fastcall/vectorcall support (args are marked InReg if fit).
Uh oh!
There was an error while loading. Please reload this page.
i.e. the equivalent of Clang's/GCC's
-mregparm=3
. The kernel needs it to support the x86 32-bit architecture, together with-Zreg-struct-return
.It could potentially be a "global target feature", i.e. a target feature that is required to be set the same way for all compilation units.
https://gcc.gnu.org/onlinedocs/gcc/x86-Function-Attributes.html#index-regparm-function-attribute_002c-x86
https://clang.llvm.org/docs/ClangCommandLineReference.html#cmdoption-clang-mregparm
The text was updated successfully, but these errors were encountered: