rust-lang / rust

Empowering everyone to build reliable and efficient software.
https://www.rust-lang.org
Other
96.89k stars 12.52k forks source link

`-Zregparm=3` support in `rustc` #116972

Open ojeda opened 11 months ago

ojeda commented 11 months ago

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

RalfJung commented 2 days ago

It could potentially be a https://github.com/rust-lang/rust/issues/121970#issuecomment-1978605782, i.e. a target feature that is required to be set the same way for all compilation units.

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 -Zbuild-std, this can't actually be used on stable.)

vincenzopalazzo commented 2 days ago

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.

Thanks @RalfJung and yes I think we can go through a stabilization process, I have some draft code for just llvm here https://github.com/vincenzopalazzo/rust/commit/84945fde8fad24c567afd90e58527965feba1303