From: Simon Glass <simon.glass@canonical.com> The regparm=3 calling convention is incompatible with Rust's extern "C" ABI, which uses cdecl (all arguments on the stack). Rather than adding an inline-assembly bridge for every non-variadic C call, automatically disable regparm when CONFIG_RUST_EXAMPLES is set by defaulting X86_NO_REGPARM to y. Also update setjmp.S to use the stack-based calling convention when regparm is disabled, since its _REGPARM define was unconditional. This is somewhat less efficient but is a worthwhile trade-off when using Rust. Signed-off-by: Simon Glass <simon.glass@canonical.com> --- arch/x86/Kconfig | 11 +++++------ arch/x86/cpu/i386/setjmp.S | 2 ++ 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig index 4fdfe5b90fe..14ee4a6d400 100644 --- a/arch/x86/Kconfig +++ b/arch/x86/Kconfig @@ -755,16 +755,15 @@ config X86_HARDFP config X86_NO_REGPARM bool "Disable register parameters (regparm=3)" depends on !X86_64 + default y if RUST_EXAMPLES help By default, U-Boot on 32-bit x86 uses -mregparm=3 to pass the first three function arguments in registers (EAX, EDX, ECX) rather than on - the stack. This is more efficient but can cause issues with debugging - tools or when interfacing with code that expects the standard calling - convention. + the stack. This is more efficient but is incompatible with Rust's + extern "C" ABI which uses the standard cdecl convention. - Select this option to disable regparm and use the standard i386 - calling convention where all arguments are passed on the stack. This - may be useful for debugging or for running in certain emulators. + This is automatically enabled when RUST_EXAMPLES is set. It may + also be useful for debugging or for running in certain emulators. config HAVE_ITSS bool "Enable ITSS" diff --git a/arch/x86/cpu/i386/setjmp.S b/arch/x86/cpu/i386/setjmp.S index eceeafa7c8b..f699850680c 100644 --- a/arch/x86/cpu/i386/setjmp.S +++ b/arch/x86/cpu/i386/setjmp.S @@ -5,7 +5,9 @@ * From Linux arch/um/sys-i386/setjmp.S */ +#ifndef CONFIG_X86_NO_REGPARM #define _REGPARM +#endif /* * The jmp_buf is assumed to contain the following, in order: -- 2.43.0