Skip to content

sparc/build: Rework CFLAGS for clang compatibility

Koakuma b4-sent linux-doc linux-kbuild lkml llvm sparclinux 3 versions – In review

Get series with b4
b4 am [email protected] change-id 20240620-sparc-cflags-e7f2dbbd4b9d

Versions newest first

  1. v3 Latest2 patches 6 repliesIn review
  2. v22 patches 17 repliesSuperseded
  3. v11 patch 8 repliesSuperseded

Changes in v3 from the cover letter

- Use cc-option to allow GCC to still use -fcall-used-* flags.
- Add documentation on building on SPARC, along with required LLVM version.
- Link to v2: https://lore.kernel.org/r/[email protected]

Patches in v3 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/2sparc/build: Put usage of -fcall-used* flags behind cc-optionarch/sparc/Makefile arch/sparc/vdso/Makefile+3 -33 replies
2/2sparc/build: Add SPARC target flags for compiling with clangDocumentation/kbuild/llvm.rst scripts/Makefile.clang+4 -02 replies

Reviews trailers per patch

All 2 patches have a Reviewed-by or Acked-by of their own; the series has one for all of them.

PatchNathan ChancellorMasahiro YamadaAndreas Larsson
SeriesR-b
1/2R-b T-b
2/2A-b A-b

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes. Scroll the table sideways for all 3 reviewers.

Read the v3 thread

Cover letter [PATCH v3 0/2] sparc/build: Rework CFLAGS for clang compatibility

Hello~

This changes the CFLAGS for building the SPARC kernel so that it can be built with clang, as a follow up from the discussion in this thread:

https://lore.kernel.org/lkml/JAYB7uS-EdLABTR4iWZdtFOVa5MvlKosIrD_cKTzgeozCOGRM7lhxeLigFB1g3exX445I_W5VKB-tAzl2_G1zCVJRQjp67ODfsSqiZWOZ9o=@protonmail.com/T/#u

The changes are removal of various -fcall-used-* flags, and adding clang target flags for SPARC:

- -fcall-used-* flags is gated behind cc-option as it is
not supported in clang. It should be safe; clang won't use the registers specified as temporaries, but it is a safe change wrt. the ABI. Assembly code can still use those registers as needed.
A cursory look at the assembly generated by GCC 13.2 shows that the compiler was able to reallocate uses of those registers into other temporary registers without adding extra spills, so there should be no change in performance.

- More trivial is to add CLANG_TARGET_FLAGS for SPARC target.

Building with these changes still result in a working kernel, at least for Sun T5120, Oracle T4-1, and qemu virtual machines.

On the LLVM side, the effort for building Linux/SPARC is tracked here:
https://github.com/llvm/llvm-project/issues/40792

---
Changes in v3:
- Use cc-option to allow GCC to still use -fcall-used-* flags.
- Add documentation on building on SPARC, along with required LLVM version.
- Link to v2: https://lore.kernel.org/r/[email protected]

Changes in v2:
- Remove the -mv8plus change; it will be handled on clang side:
https://github.com/llvm/llvm-project/pull/98713
- Add CLANG_TARGET_FLAGS as suggested in v1 review.
- Link to v1: https://lore.kernel.org/r/[email protected]

---
Koakuma (2):
sparc/build: Put usage of -fcall-used* flags behind cc-option sparc/build: Add SPARC target flags for compiling with clang

 Documentation/kbuild/llvm.rst | 3 +++
 arch/sparc/Makefile           | 4 ++--
 arch/sparc/vdso/Makefile      | 2 +-
 scripts/Makefile.clang        | 1 +
 4 files changed, 7 insertions(+), 3 deletions(-)

---
base-commit: c2ee9f594da826bea183ed14f2cc029c719bf4da
change-id: 20240620-sparc-cflags-e7f2dbbd4b9d

Best regards,

Signature · 1 line
Koakuma <[email protected]>