Skip to contentSkip to conversation

RISC-V: disallow gcc + rust builds

PATCH Applied Conor Dooley 5 participants 10 messages Oct 1, 2024 – Oct 17, 2024

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 RISC-V: disallow gcc + rust builds

From: Conor Dooley <[email protected]>

During the discussion before supporting rust on riscv, it was decided not to support gcc yet, due to differences in extension handling compared to llvm (only the version of libclang matching the c compiler is supported). Recently Jason Montleon reported [1] that building with gcc caused build issues, due to unsupported arguments being passed to libclang. After some discussion between myself and Miguel, it is better to disable gcc + rust builds to match the original intent, and subsequently support it when an appropriate set of extensions can be deduced from the version of libclang.

---

Palmer, this is yours to take.

---
 Documentation/rust/arch-support.rst | 2 +-
 arch/riscv/Kconfig                  | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
Documentation/rust/arch-support.rst +1 -1
index 750ff371570a0..54be7ddf3e57a 100644
@@ -17,7 +17,7 @@ Architecture   Level of support  Constraints
 =============  ================  ==============================================
 ``arm64``      Maintained        Little Endian only.
 ``loongarch``  Maintained        \-
-``riscv``      Maintained        ``riscv64`` only.
+``riscv``      Maintained        ``riscv64`` and LLVM/Clang only.
 ``um``         Maintained        \-
 ``x86``        Maintained        ``x86_64`` only.
 =============  ================  ==============================================
arch/riscv/Kconfig +1 -1
index 22dc5ea4196ce..76843584960c2 100644
@@ -177,7 +177,7 @@ config RISCV
 	select HAVE_REGS_AND_STACK_ACCESS_API
 	select HAVE_RETHOOK if !XIP_KERNEL
 	select HAVE_RSEQ
-	select HAVE_RUST if RUSTC_SUPPORTS_RISCV
+	select HAVE_RUST if RUSTC_SUPPORTS_RISCV && CC_IS_CLANG
 	select HAVE_SAMPLE_FTRACE_DIRECT
 	select HAVE_SAMPLE_FTRACE_DIRECT_MULTI
 	select HAVE_STACKPROTECTOR
Signature · 1 line
2.45.2
Acked-by on v1 1/1
#1 lore raw
Quoted 19 lines · Conor Dooley
Documentation/rust/arch-support.rst +1 -1
index 750ff371570a0..54be7ddf3e57a 100644
@@ -17,7 +17,7 @@ Architecture   Level of support  Constraints
 =============  ================  ==============================================
 ``arm64``      Maintained        Little Endian only.
 ``loongarch``  Maintained        \-
-``riscv``      Maintained        ``riscv64`` only.
+``riscv``      Maintained        ``riscv64`` and LLVM/Clang only.
 ``um``         Maintained        \-
 ``x86``        Maintained        ``x86_64`` only.
 =============  ================  ==============================================
arch/riscv/Kconfig +0 -0
index 22dc5ea4196ce..76843584960c2 100644

arch/riscv/Kconfig config RISCV · line 183

Quoted 8 lines
arch/riscv/Kconfig +1 -1
@@ -177,7 +177,7 @@ config RISCV
        select HAVE_REGS_AND_STACK_ACCESS_API
        select HAVE_RETHOOK if !XIP_KERNEL
        select HAVE_RSEQ
-       select HAVE_RUST if RUSTC_SUPPORTS_RISCV
+       select HAVE_RUST if RUSTC_SUPPORTS_RISCV && CC_IS_CLANG
        select HAVE_SAMPLE_FTRACE_DIRECT
        select HAVE_SAMPLE_FTRACE_DIRECT_MULTI
        select HAVE_STACKPROTECTOR

Cheers,
Miguel

Reviewed-by on v1 1/1
#2 lore raw
In reply to Conor Dooley
Quoted 12 lines · Conor Dooley

From: Conor Dooley <[email protected]>

During the discussion before supporting rust on riscv, it was decided not to support gcc yet, due to differences in extension handling compared to llvm (only the version of libclang matching the c compiler is supported). Recently Jason Montleon reported [1] that building with gcc caused build issues, due to unsupported arguments being passed to libclang. After some discussion between myself and Miguel, it is better to disable gcc + rust builds to match the original intent, and subsequently support it when an appropriate set of extensions can be deduced from the version of libclang.

Quoted 5 lines

Seems like a reasonable restriction to me.

I assume the difficulty is not in getting the libclang version itself but actually mapping extensions to the versions and then deciding how to make that available to the build system? Or is it more that a solution is somewhat known but someone has to actually implement it? Sorry if this has been talked about before.

Quoted 56 lines

---

Palmer, this is yours to take.

---
 Documentation/rust/arch-support.rst | 2 +-
 arch/riscv/Kconfig                  | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
Documentation/rust/arch-support.rst +1 -1
index 750ff371570a0..54be7ddf3e57a 100644
@@ -17,7 +17,7 @@ Architecture   Level of support  Constraints
 =============  ================  ==============================================
 ``arm64``      Maintained        Little Endian only.
 ``loongarch``  Maintained        \-
-``riscv``      Maintained        ``riscv64`` only.
+``riscv``      Maintained        ``riscv64`` and LLVM/Clang only.
 ``um``         Maintained        \-
 ``x86``        Maintained        ``x86_64`` only.
 =============  ================  ==============================================
arch/riscv/Kconfig +1 -1
index 22dc5ea4196ce..76843584960c2 100644
@@ -177,7 +177,7 @@ config RISCV
 	select HAVE_REGS_AND_STACK_ACCESS_API
 	select HAVE_RETHOOK if !XIP_KERNEL
 	select HAVE_RSEQ
-	select HAVE_RUST if RUSTC_SUPPORTS_RISCV
+	select HAVE_RUST if RUSTC_SUPPORTS_RISCV && CC_IS_CLANG
 	select HAVE_SAMPLE_FTRACE_DIRECT
 	select HAVE_SAMPLE_FTRACE_DIRECT_MULTI
 	select HAVE_STACKPROTECTOR
Signature · 1 line
2.45.2
#3 lore raw
Quoted 21 lines · Nathan Chancellor
Quoted 12 lines · Conor Dooley

From: Conor Dooley <[email protected]>

During the discussion before supporting rust on riscv, it was decided not to support gcc yet, due to differences in extension handling compared to llvm (only the version of libclang matching the c compiler is supported). Recently Jason Montleon reported [1] that building with gcc caused build issues, due to unsupported arguments being passed to libclang. After some discussion between myself and Miguel, it is better to disable gcc + rust builds to match the original intent, and subsequently support it when an appropriate set of extensions can be deduced from the version of libclang.

Quoted 5 lines

Seems like a reasonable restriction to me.

Quoted 7 lines

I assume the difficulty is not in getting the libclang version itself but actually mapping extensions to the versions and then deciding how to make that available to the build system? Or is it more that a solution is somewhat known but someone has to actually implement it? Sorry if this has been talked about before.

It's mostly that someone has to take the time to go and do it. Miguel and I discussed getting the libclang version a bit in [2] and mapping the versions to extensions is no different (AFAIU) to mapping the versions to extensions for Clang, so the work in figuring that out is mostly done. It's a matter of going off and doing it, and testing the various mixed tool configurations and versions to make sure it works correctly.

#4 lore raw
In reply to Conor Dooley

Hi Conor,

Quoted 8 lines · Conor Dooley

From: Conor Dooley <[email protected]>

During the discussion before supporting rust on riscv, it was decided not to support gcc yet, due to differences in extension handling compared to llvm (only the version of libclang matching the c compiler is supported). Recently Jason Montleon reported [1] that building with gcc caused build issues, due to unsupported arguments being passed to libclang. After some discussion between myself and Miguel

I have just added "[2]" here as it seemed to be missing.

Thanks,

Alex

Quoted 63 lines

, it is better
to disable gcc + rust builds to match the original intent, and subsequently support it when an appropriate set of extensions can be deduced from the version of libclang.

---

Palmer, this is yours to take.

---
  Documentation/rust/arch-support.rst | 2 +-
  arch/riscv/Kconfig                  | 2 +-
  2 files changed, 2 insertions(+), 2 deletions(-)
Documentation/rust/arch-support.rst +1 -1
index 750ff371570a0..54be7ddf3e57a 100644
@@ -17,7 +17,7 @@ Architecture   Level of support  Constraints
  =============  ================  ==============================================
  ``arm64``      Maintained        Little Endian only.
  ``loongarch``  Maintained        \-
-``riscv``      Maintained        ``riscv64`` only.
+``riscv``      Maintained        ``riscv64`` and LLVM/Clang only.
  ``um``         Maintained        \-
  ``x86``        Maintained        ``x86_64`` only.
  =============  ================  ==============================================
arch/riscv/Kconfig +1 -1
index 22dc5ea4196ce..76843584960c2 100644
@@ -177,7 +177,7 @@ config RISCV
  	select HAVE_REGS_AND_STACK_ACCESS_API
  	select HAVE_RETHOOK if !XIP_KERNEL
  	select HAVE_RSEQ
-	select HAVE_RUST if RUSTC_SUPPORTS_RISCV
+	select HAVE_RUST if RUSTC_SUPPORTS_RISCV && CC_IS_CLANG
  	select HAVE_SAMPLE_FTRACE_DIRECT
  	select HAVE_SAMPLE_FTRACE_DIRECT_MULTI
  	select HAVE_STACKPROTECTOR
#5 lore raw
Quoted 13 lines · Alexandre Ghiti

Hi Conor,

Quoted 8 lines · Conor Dooley

From: Conor Dooley <[email protected]>

During the discussion before supporting rust on riscv, it was decided not to support gcc yet, due to differences in extension handling compared to llvm (only the version of libclang matching the c compiler is supported). Recently Jason Montleon reported [1] that building with gcc caused build issues, due to unsupported arguments being passed to libclang. After some discussion between myself and Miguel

Quoted 15 lines

I have just added "[2]" here as it seemed to be missing.

Thanks,

Alex

Quoted 8 lines

, it is better
to disable gcc + rust builds to match the original intent, and subsequently support it when an appropriate set of extensions can be deduced from the version of libclang.

Fixes 70a57b247251a ("RISC-V: enable building 64-bit kernels with rust support")

I also fixed the Fixes tag ^, it contains 13 characters instead of 12 and added a cc: stable tag.

Quoted 1 line
Quoted 1 line

And I moved this tag above the Closes tag.

Thanks,

Alex

Quoted 59 lines
Quoted 46 lines

---

Palmer, this is yours to take.

---
  Documentation/rust/arch-support.rst | 2 +-
  arch/riscv/Kconfig                  | 2 +-

  2 files changed, 2 insertions(+), 2 deletions(-)
Documentation/rust/arch-support.rst +0 -0
index 750ff371570a0..54be7ddf3e57a 100644
@@ -17,7 +17,7 @@ Architecture   Level of support  Constraints

  =============  ================ ============================================== ``arm64``      Maintained        Little Endian only. ``loongarch``  Maintained        \-
-``riscv``      Maintained        ``riscv64`` only.
+``riscv``      Maintained        ``riscv64`` and LLVM/Clang only. ``um``         Maintained        \-
  ``x86``        Maintained        ``x86_64`` only.
  =============  ================ ==============================================

arch/riscv/Kconfig +0 -0
index 22dc5ea4196ce..76843584960c2 100644
@@ -177,7 +177,7 @@ config RISCV
Quoted 8 lines

      select HAVE_REGS_AND_STACK_ACCESS_API
      select HAVE_RETHOOK if !XIP_KERNEL
      select HAVE_RSEQ
-    select HAVE_RUST if RUSTC_SUPPORTS_RISCV
+    select HAVE_RUST if RUSTC_SUPPORTS_RISCV && CC_IS_CLANG select HAVE_SAMPLE_FTRACE_DIRECT
      select HAVE_SAMPLE_FTRACE_DIRECT_MULTI select HAVE_STACKPROTECTOR

_______________________________________________
linux-riscv mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-riscv

#6 lore raw
Quoted 15 lines · Alexandre Ghiti
Quoted 5 lines
Quoted 5 lines

, it is better
to disable gcc + rust builds to match the original intent, and subsequently support it when an appropriate set of extensions can be deduced from the version of libclang.

Quoted 8 lines
Quoted 8 lines

Closes:
https://lore.kernel.org/all/[email protected]/
[1]
Link:
https://lore.kernel.org/all/20240926-battering-revolt-6c6a7827413e@spud/

[2]
Fixes 70a57b247251a ("RISC-V: enable building 64-bit kernels with

rust support")

Quoted 2 lines

I also fixed the Fixes tag ^, it contains 13 characters instead of 12 and added a cc: stable tag.

FYI, checkpatch is not an arbiter of truth, and I intentionally left the 13th character that git determined it needed to have there. Apparently the kernel now has enough objects that there can be 12 character collisions.

#7 lore raw
Quoted 16 lines · Conor Dooley
Quoted 14 lines · Alexandre Ghiti
Quoted 13 lines
Quoted 13 lines

, it is better
to disable gcc + rust builds to match the original intent, and subsequently support it when an appropriate set of extensions can be deduced from the version of libclang.

Closes:
https://lore.kernel.org/all/[email protected]/
[1]
Link:
https://lore.kernel.org/all/20240926-battering-revolt-6c6a7827413e@spud/

[2]
Fixes 70a57b247251a ("RISC-V: enable building 64-bit kernels with

rust support")

Quoted 6 lines
Quoted 2 lines

I also fixed the Fixes tag ^, it contains 13 characters instead of 12 and added a cc: stable tag.

FYI, checkpatch is not an arbiter of truth, and I intentionally left the 13th character that git determined it needed to have there. Apparently the kernel now has enough objects that there can be 12 character collisions.

Ok, thanks for the explanation: do checkpatch and the documentation need to be updated then? Is that a known issue?

From https://docs.kernel.org/process/submitting-patches.html:

"If your patch fixes a bug in a specific commit, e.g. you found an issue using git bisect, please use the ‘Fixes:’ tag with the first 12 characters of the SHA-1 ID, and the one line summary."

Quoted 5 lines

_______________________________________________
linux-riscv mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-riscv

#8 lore raw
Quoted 9 lines · Alexandre Ghiti

Ok, thanks for the explanation: do checkpatch and the documentation need to be updated then? Is that a known issue?

From https://docs.kernel.org/process/submitting-patches.html:

"If your patch fixes a bug in a specific commit, e.g. you found an issue using git bisect, please use the ‘Fixes:’ tag with the first 12 characters of the SHA-1 ID, and the one line summary."

I think Geert (Cc'd) wanted to change those docs -- I am not sure if the idea is to go with 13 or more, though.

In any case, even if there is a conflict, we have the title.

Cheers,
Miguel

#9 lore raw
In reply to Conor Dooley
This patch was applied to riscv/linux.git (fixes) by Palmer Dabbelt <[email protected]>:

Hello:

This patch was applied to riscv/linux.git (fixes)
by Palmer Dabbelt <[email protected]>:

Quoted 12 lines · On Tue, 1 Oct 2024 12:28:13 +0100 you wrote:

From: Conor Dooley <[email protected]>

During the discussion before supporting rust on riscv, it was decided not to support gcc yet, due to differences in extension handling compared to llvm (only the version of libclang matching the c compiler is supported). Recently Jason Montleon reported [1] that building with gcc caused build issues, due to unsupported arguments being passed to libclang. After some discussion between myself and Miguel, it is better to disable gcc + rust builds to match the original intent, and subsequently support it when an appropriate set of extensions can be deduced from the version of libclang.

Quoted 1 line

[...]

Here is the summary with links:
- [v1] RISC-V: disallow gcc + rust builds

    https://git.kernel.org/riscv/c/e52d5050a0d2

You are awesome, thank you!

Signature · 2 lines
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html