[PATCH] RISC-V: Fix building rust when using GCC toolchain

Conor Dooley conor at kernel.org
Tue Sep 17 02:35:12 PDT 2024



On 17 September 2024 01:08:48 IST, Jason Montleon <jmontleo at redhat.com> wrote:
>Clang does not support '-mno-riscv-attribute' resulting in the error
>error: unknown argument: '-mno-riscv-attribute'

This appears to conflict with your subject, which cities gcc, but I suspect that's due to poor wording of the body of the commit message than a mistake in the subject.
I'd rather disable rust on riscv when building with gcc, I've never been satisfied with the interaction between gcc and rustc's libclang w.r.t. extensions.

Cheers,
Conor.

>
>Not setting BINDGEN_TARGET_riscv results in the in the error
>error: unsupported argument 'medany' to option '-mcmodel=' for target \
>'unknown'
>error: unknown target triple 'unknown'
>
>Signed-off-by: Jason Montleon <jmontleo at redhat.com>
>Cc: stable at vger.kernel.org
>---
> rust/Makefile | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
>
>diff --git a/rust/Makefile b/rust/Makefile
>index f168d2c98a15..73eceaaae61e 100644
>--- a/rust/Makefile
>+++ b/rust/Makefile
>@@ -228,11 +228,12 @@ bindgen_skip_c_flags := -mno-fp-ret-in-387 -mpreferred-stack-boundary=% \
> 	-fzero-call-used-regs=% -fno-stack-clash-protection \
> 	-fno-inline-functions-called-once -fsanitize=bounds-strict \
> 	-fstrict-flex-arrays=% -fmin-function-alignment=% \
>-	--param=% --param asan-%
>+	--param=% --param asan-% -mno-riscv-attribute
> 
> # Derived from `scripts/Makefile.clang`.
> BINDGEN_TARGET_x86	:= x86_64-linux-gnu
> BINDGEN_TARGET_arm64	:= aarch64-linux-gnu
>+BINDGEN_TARGET_riscv	:= riscv64-linux-gnu
> BINDGEN_TARGET		:= $(BINDGEN_TARGET_$(SRCARCH))
> 
> # All warnings are inhibited since GCC builds are very experimental,
>
>base-commit: ad060dbbcfcfcba624ef1a75e1d71365a98b86d8



More information about the linux-riscv mailing list