All of lore.kernel.org
 help / color / mirror / Atom feed
From: Gary Guo <gary@garyguo.net>
To: Conor Dooley <conor@kernel.org>
Cc: Jason Montleon <jmontleo@redhat.com>,
	ojeda@kernel.org, alex.gaynor@gmail.com, boqun.feng@gmail.com,
	bjorn3_gh@protonmail.com, benno.lossin@proton.me,
	a.hindborg@kernel.org, aliceryhl@google.com,
	paul.walmsley@sifive.com, palmer@dabbelt.com,
	aou@eecs.berkeley.edu, nathan@kernel.org,
	ndesaulniers@google.com, morbo@google.com,
	justinstitt@google.com, rust-for-linux@vger.kernel.org,
	linux-kernel@vger.kernel.org, linux-riscv@lists.infradead.org,
	llvm@lists.linux.dev, stable@vger.kernel.org
Subject: Re: [PATCH] RISC-V: Fix building rust when using GCC toolchain
Date: Tue, 17 Sep 2024 14:29:50 +0100	[thread overview]
Message-ID: <20240917142950.48d800ac@eugeo> (raw)
In-Reply-To: <334EBB3A-6ABF-4FBF-89D2-DF3A6DCCCEA2@kernel.org>

On Tue, 17 Sep 2024 10:35:12 +0100
Conor Dooley <conor@kernel.org> wrote:

> On 17 September 2024 01:08:48 IST, Jason Montleon <jmontleo@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.

Hi Conor,

What happens is that when building against GCC, Kbuild gathers flag
assuming CC is GCC, but bindgen uses clang instead. In this case, the
CC is GCC and all C code is built by GCC. We have a filtering mechanism
to only give bindgen (libclang) flags that it can understand.

While I do think this is a bit fragile, this is what I think all
distros that enable Rust use. They still prefer to build C code with
GCC. So I hope we can still keep that option around.

Best,
Gary


> 
> >
> >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@redhat.com>
> >Cc: stable@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  


_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv

WARNING: multiple messages have this Message-ID (diff)
From: Gary Guo <gary@garyguo.net>
To: Conor Dooley <conor@kernel.org>
Cc: Jason Montleon <jmontleo@redhat.com>,
	ojeda@kernel.org, alex.gaynor@gmail.com, boqun.feng@gmail.com,
	bjorn3_gh@protonmail.com, benno.lossin@proton.me,
	a.hindborg@kernel.org, aliceryhl@google.com,
	paul.walmsley@sifive.com, palmer@dabbelt.com,
	aou@eecs.berkeley.edu, nathan@kernel.org,
	ndesaulniers@google.com, morbo@google.com,
	justinstitt@google.com, rust-for-linux@vger.kernel.org,
	linux-kernel@vger.kernel.org, linux-riscv@lists.infradead.org,
	llvm@lists.linux.dev, stable@vger.kernel.org
Subject: Re: [PATCH] RISC-V: Fix building rust when using GCC toolchain
Date: Tue, 17 Sep 2024 14:29:50 +0100	[thread overview]
Message-ID: <20240917142950.48d800ac@eugeo> (raw)
In-Reply-To: <334EBB3A-6ABF-4FBF-89D2-DF3A6DCCCEA2@kernel.org>

On Tue, 17 Sep 2024 10:35:12 +0100
Conor Dooley <conor@kernel.org> wrote:

> On 17 September 2024 01:08:48 IST, Jason Montleon <jmontleo@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.

Hi Conor,

What happens is that when building against GCC, Kbuild gathers flag
assuming CC is GCC, but bindgen uses clang instead. In this case, the
CC is GCC and all C code is built by GCC. We have a filtering mechanism
to only give bindgen (libclang) flags that it can understand.

While I do think this is a bit fragile, this is what I think all
distros that enable Rust use. They still prefer to build C code with
GCC. So I hope we can still keep that option around.

Best,
Gary


> 
> >
> >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@redhat.com>
> >Cc: stable@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  


  reply	other threads:[~2024-09-17 13:30 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-09-17  0:08 [PATCH 0/1] RISC-V: Fix building rust when using GCC toolchain Jason Montleon
2024-09-17  0:08 ` Jason Montleon
2024-09-17  0:08 ` [PATCH] " Jason Montleon
2024-09-17  0:08   ` Jason Montleon
2024-09-17  9:35   ` Conor Dooley
2024-09-17  9:35     ` Conor Dooley
2024-09-17 13:29     ` Gary Guo [this message]
2024-09-17 13:29       ` Gary Guo
2024-09-17 15:26       ` Conor Dooley
2024-09-17 15:26         ` Conor Dooley
2024-09-26 15:40         ` Miguel Ojeda
2024-09-26 15:40           ` Miguel Ojeda
2024-09-26 15:56           ` Conor Dooley
2024-09-26 15:56             ` Conor Dooley
2024-09-26 16:11             ` Miguel Ojeda
2024-09-26 16:11               ` Miguel Ojeda
2024-09-26 16:21               ` Conor Dooley
2024-09-26 16:21                 ` Conor Dooley
2024-09-26 16:29                 ` Miguel Ojeda
2024-09-26 16:29                   ` Miguel Ojeda
2024-09-17 13:32   ` Gary Guo
2024-09-17 13:32     ` Gary Guo

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240917142950.48d800ac@eugeo \
    --to=gary@garyguo.net \
    --cc=a.hindborg@kernel.org \
    --cc=alex.gaynor@gmail.com \
    --cc=aliceryhl@google.com \
    --cc=aou@eecs.berkeley.edu \
    --cc=benno.lossin@proton.me \
    --cc=bjorn3_gh@protonmail.com \
    --cc=boqun.feng@gmail.com \
    --cc=conor@kernel.org \
    --cc=jmontleo@redhat.com \
    --cc=justinstitt@google.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-riscv@lists.infradead.org \
    --cc=llvm@lists.linux.dev \
    --cc=morbo@google.com \
    --cc=nathan@kernel.org \
    --cc=ndesaulniers@google.com \
    --cc=ojeda@kernel.org \
    --cc=palmer@dabbelt.com \
    --cc=paul.walmsley@sifive.com \
    --cc=rust-for-linux@vger.kernel.org \
    --cc=stable@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.