* [PATCH v3 0/2] sparc/build: Rework CFLAGS for clang compatibility @ 2024-10-29 14:49 Koakuma via B4 Relay 2024-10-29 14:49 ` [PATCH v3 1/2] sparc/build: Put usage of -fcall-used* flags behind cc-option Koakuma via B4 Relay ` (2 more replies) 0 siblings, 3 replies; 9+ messages in thread From: Koakuma via B4 Relay @ 2024-10-29 14:49 UTC (permalink / raw) To: David S. Miller, Andreas Larsson, Nathan Chancellor, Nick Desaulniers, Bill Wendling, Justin Stitt, glaubitz, Masahiro Yamada, Nicolas Schier, Jonathan Corbet Cc: sparclinux, linux-kernel, llvm, linux-kbuild, linux-doc, Koakuma 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 Signed-off-by: Koakuma <koachan@protonmail.com> --- 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/20240717-sparc-cflags-v2-0-259407e6eb5f@protonmail.com 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/20240620-sparc-cflags-v1-1-bba7d0ff7d42@protonmail.com --- 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, -- Koakuma <koachan@protonmail.com> ^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH v3 1/2] sparc/build: Put usage of -fcall-used* flags behind cc-option 2024-10-29 14:49 [PATCH v3 0/2] sparc/build: Rework CFLAGS for clang compatibility Koakuma via B4 Relay @ 2024-10-29 14:49 ` Koakuma via B4 Relay 2024-10-29 22:24 ` Nathan Chancellor 2024-10-29 14:49 ` [PATCH v3 2/2] sparc/build: Add SPARC target flags for compiling with clang Koakuma via B4 Relay 2024-11-16 8:31 ` [PATCH v3 0/2] sparc/build: Rework CFLAGS for clang compatibility Andreas Larsson 2 siblings, 1 reply; 9+ messages in thread From: Koakuma via B4 Relay @ 2024-10-29 14:49 UTC (permalink / raw) To: David S. Miller, Andreas Larsson, Nathan Chancellor, Nick Desaulniers, Bill Wendling, Justin Stitt, glaubitz, Masahiro Yamada, Nicolas Schier, Jonathan Corbet Cc: sparclinux, linux-kernel, llvm, linux-kbuild, linux-doc, Koakuma From: Koakuma <koachan@protonmail.com> Place -fcall-used* flags behind cc-option so that clang (which doesn't support them) can still compile the kernel. This is a safe change, the reasoning is as follows: In the (normal) 32-bit ABI, %g5 and %g7 is normally reserved, and in the 64-bit ABI, %g7 is the reserved one. Linux turns them into volatile registers by the way of -fcall-used-*, but on the other hand, omitting the flags shouldn't be harmful; compilers will now simply refuse to touch them, and any assembly code that happens to touch them would still work like usual (because Linux' conventions already treats them as volatile anyway). Signed-off-by: Koakuma <koachan@protonmail.com> --- arch/sparc/Makefile | 4 ++-- arch/sparc/vdso/Makefile | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/arch/sparc/Makefile b/arch/sparc/Makefile index 757451c3ea1df63b948e68a45988c78f5974f9ea..0400078076e588be93a702d1c64eb9fd34466075 100644 --- a/arch/sparc/Makefile +++ b/arch/sparc/Makefile @@ -29,7 +29,7 @@ UTS_MACHINE := sparc # versions of gcc. Some gcc versions won't pass -Av8 to binutils when you # give -mcpu=v8. This silently worked with older bintutils versions but # does not any more. -KBUILD_CFLAGS += -m32 -mcpu=v8 -pipe -mno-fpu -fcall-used-g5 -fcall-used-g7 +KBUILD_CFLAGS += -m32 -mcpu=v8 -pipe -mno-fpu $(call cc-option,-fcall-used-g5) $(call cc-option,-fcall-used-g7) KBUILD_CFLAGS += -Wa,-Av8 KBUILD_AFLAGS += -m32 -Wa,-Av8 @@ -45,7 +45,7 @@ export BITS := 64 UTS_MACHINE := sparc64 KBUILD_CFLAGS += -m64 -pipe -mno-fpu -mcpu=ultrasparc -mcmodel=medlow -KBUILD_CFLAGS += -ffixed-g4 -ffixed-g5 -fcall-used-g7 -Wno-sign-compare +KBUILD_CFLAGS += -ffixed-g4 -ffixed-g5 $(call cc-option,-fcall-used-g7) -Wno-sign-compare KBUILD_CFLAGS += -Wa,--undeclared-regs KBUILD_CFLAGS += $(call cc-option,-mtune=ultrasparc3) KBUILD_AFLAGS += -m64 -mcpu=ultrasparc -Wa,--undeclared-regs diff --git a/arch/sparc/vdso/Makefile b/arch/sparc/vdso/Makefile index 243dbfc4609d804fc221c3591eebe891107ffdab..50ec2978cda5397841daad6ffdc9682811b9b38e 100644 --- a/arch/sparc/vdso/Makefile +++ b/arch/sparc/vdso/Makefile @@ -46,7 +46,7 @@ CFL := $(PROFILING) -mcmodel=medlow -fPIC -O2 -fasynchronous-unwind-tables -m64 -fno-omit-frame-pointer -foptimize-sibling-calls \ -DDISABLE_BRANCH_PROFILING -DBUILD_VDSO -SPARC_REG_CFLAGS = -ffixed-g4 -ffixed-g5 -fcall-used-g5 -fcall-used-g7 +SPARC_REG_CFLAGS = -ffixed-g4 -ffixed-g5 $(call cc-option,-fcall-used-g5) $(call cc-option,-fcall-used-g7) $(vobjs): KBUILD_CFLAGS := $(filter-out $(RANDSTRUCT_CFLAGS) $(GCC_PLUGINS_CFLAGS) $(SPARC_REG_CFLAGS),$(KBUILD_CFLAGS)) $(CFL) -- 2.47.0 ^ permalink raw reply related [flat|nested] 9+ messages in thread
* Re: [PATCH v3 1/2] sparc/build: Put usage of -fcall-used* flags behind cc-option 2024-10-29 14:49 ` [PATCH v3 1/2] sparc/build: Put usage of -fcall-used* flags behind cc-option Koakuma via B4 Relay @ 2024-10-29 22:24 ` Nathan Chancellor 2024-11-07 4:59 ` Koakuma 0 siblings, 1 reply; 9+ messages in thread From: Nathan Chancellor @ 2024-10-29 22:24 UTC (permalink / raw) To: koachan Cc: David S. Miller, Andreas Larsson, Nick Desaulniers, Bill Wendling, Justin Stitt, glaubitz, Masahiro Yamada, Nicolas Schier, Jonathan Corbet, sparclinux, linux-kernel, llvm, linux-kbuild, linux-doc On Tue, Oct 29, 2024 at 09:49:07PM +0700, Koakuma via B4 Relay wrote: > From: Koakuma <koachan@protonmail.com> > > Place -fcall-used* flags behind cc-option so that clang (which doesn't > support them) can still compile the kernel. > > This is a safe change, the reasoning is as follows: > > In the (normal) 32-bit ABI, %g5 and %g7 is normally reserved, and in > the 64-bit ABI, %g7 is the reserved one. > Linux turns them into volatile registers by the way of -fcall-used-*, > but on the other hand, omitting the flags shouldn't be harmful; > compilers will now simply refuse to touch them, and any assembly > code that happens to touch them would still work like usual (because > Linux' conventions already treats them as volatile anyway). > > Signed-off-by: Koakuma <koachan@protonmail.com> Clang builds now succeed with this series and builds with GCC 14.2.0 continue to pass and boot successfully. Reviewed-by: Nathan Chancellor <nathan@kernel.org> Tested-by: Nathan Chancellor <nathan@kernel.org> One comment below, please carry these tags forward if there are future revisions without substantial technical changes. > --- > arch/sparc/Makefile | 4 ++-- > arch/sparc/vdso/Makefile | 2 +- > 2 files changed, 3 insertions(+), 3 deletions(-) > > diff --git a/arch/sparc/Makefile b/arch/sparc/Makefile > index 757451c3ea1df63b948e68a45988c78f5974f9ea..0400078076e588be93a702d1c64eb9fd34466075 100644 > --- a/arch/sparc/Makefile > +++ b/arch/sparc/Makefile > @@ -29,7 +29,7 @@ UTS_MACHINE := sparc > # versions of gcc. Some gcc versions won't pass -Av8 to binutils when you > # give -mcpu=v8. This silently worked with older bintutils versions but > # does not any more. > -KBUILD_CFLAGS += -m32 -mcpu=v8 -pipe -mno-fpu -fcall-used-g5 -fcall-used-g7 > +KBUILD_CFLAGS += -m32 -mcpu=v8 -pipe -mno-fpu $(call cc-option,-fcall-used-g5) $(call cc-option,-fcall-used-g7) Small nit, this (and the one in the vdso) could probably be one cc-option call? Is it likely that one flag would be implemented in the compiler without the other? $(call cc-option,-fcall-used-g5 -fcall-used-g7) > KBUILD_CFLAGS += -Wa,-Av8 > > KBUILD_AFLAGS += -m32 -Wa,-Av8 > @@ -45,7 +45,7 @@ export BITS := 64 > UTS_MACHINE := sparc64 > > KBUILD_CFLAGS += -m64 -pipe -mno-fpu -mcpu=ultrasparc -mcmodel=medlow > -KBUILD_CFLAGS += -ffixed-g4 -ffixed-g5 -fcall-used-g7 -Wno-sign-compare > +KBUILD_CFLAGS += -ffixed-g4 -ffixed-g5 $(call cc-option,-fcall-used-g7) -Wno-sign-compare > KBUILD_CFLAGS += -Wa,--undeclared-regs > KBUILD_CFLAGS += $(call cc-option,-mtune=ultrasparc3) > KBUILD_AFLAGS += -m64 -mcpu=ultrasparc -Wa,--undeclared-regs > diff --git a/arch/sparc/vdso/Makefile b/arch/sparc/vdso/Makefile > index 243dbfc4609d804fc221c3591eebe891107ffdab..50ec2978cda5397841daad6ffdc9682811b9b38e 100644 > --- a/arch/sparc/vdso/Makefile > +++ b/arch/sparc/vdso/Makefile > @@ -46,7 +46,7 @@ CFL := $(PROFILING) -mcmodel=medlow -fPIC -O2 -fasynchronous-unwind-tables -m64 > -fno-omit-frame-pointer -foptimize-sibling-calls \ > -DDISABLE_BRANCH_PROFILING -DBUILD_VDSO > > -SPARC_REG_CFLAGS = -ffixed-g4 -ffixed-g5 -fcall-used-g5 -fcall-used-g7 > +SPARC_REG_CFLAGS = -ffixed-g4 -ffixed-g5 $(call cc-option,-fcall-used-g5) $(call cc-option,-fcall-used-g7) > > $(vobjs): KBUILD_CFLAGS := $(filter-out $(RANDSTRUCT_CFLAGS) $(GCC_PLUGINS_CFLAGS) $(SPARC_REG_CFLAGS),$(KBUILD_CFLAGS)) $(CFL) > > > -- > 2.47.0 > > > ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH v3 1/2] sparc/build: Put usage of -fcall-used* flags behind cc-option 2024-10-29 22:24 ` Nathan Chancellor @ 2024-11-07 4:59 ` Koakuma 2024-11-07 16:01 ` Nathan Chancellor 0 siblings, 1 reply; 9+ messages in thread From: Koakuma @ 2024-11-07 4:59 UTC (permalink / raw) To: Nathan Chancellor Cc: David S. Miller, Andreas Larsson, Nick Desaulniers, Bill Wendling, Justin Stitt, glaubitz, Masahiro Yamada, Nicolas Schier, Jonathan Corbet, sparclinux, linux-kernel, llvm, linux-kbuild, linux-doc Nathan Chancellor <nathan@kernel.org> wrote: > > Clang builds now succeed with this series and builds with GCC 14.2.0 > continue to pass and boot successfully. > > Reviewed-by: Nathan Chancellor nathan@kernel.org > > Tested-by: Nathan Chancellor nathan@kernel.org > > One comment below, please carry these tags forward if there are future > revisions without substantial technical changes. Forgive me for still being unfamiliar with the term, but does this mean that when I send a v4 I should paste the Reviewed-by and Tested-by lines into the commit message of the patch? > > -KBUILD_CFLAGS += -m32 -mcpu=v8 -pipe -mno-fpu -fcall-used-g5 -fcall-used-g7 > > +KBUILD_CFLAGS += -m32 -mcpu=v8 -pipe -mno-fpu $(call cc-option,-fcall-used-g5) $(call cc-option,-fcall-used-g7) > > > Small nit, this (and the one in the vdso) could probably be one > cc-option call? Is it likely that one flag would be implemented in the > compiler without the other? > > $(call cc-option,-fcall-used-g5 -fcall-used-g7) Ah, didn't know it's possible to do that, the other uses of it I see seem to use one flag per call. I'll test and send a new revision, thanks. ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH v3 1/2] sparc/build: Put usage of -fcall-used* flags behind cc-option 2024-11-07 4:59 ` Koakuma @ 2024-11-07 16:01 ` Nathan Chancellor 0 siblings, 0 replies; 9+ messages in thread From: Nathan Chancellor @ 2024-11-07 16:01 UTC (permalink / raw) To: Koakuma Cc: David S. Miller, Andreas Larsson, Nick Desaulniers, Bill Wendling, Justin Stitt, glaubitz, Masahiro Yamada, Nicolas Schier, Jonathan Corbet, sparclinux, linux-kernel, llvm, linux-kbuild, linux-doc On Thu, Nov 07, 2024 at 04:59:14AM +0000, Koakuma wrote: > Nathan Chancellor <nathan@kernel.org> wrote: > > > > Clang builds now succeed with this series and builds with GCC 14.2.0 > > continue to pass and boot successfully. > > > > Reviewed-by: Nathan Chancellor nathan@kernel.org > > > > Tested-by: Nathan Chancellor nathan@kernel.org > > > > One comment below, please carry these tags forward if there are future > > revisions without substantial technical changes. > > Forgive me for still being unfamiliar with the term, but does this mean that No worries, it is definitely a customary thing. > when I send a v4 I should paste the Reviewed-by and Tested-by lines into the > commit message of the patch? Yes, you should add them either right above or right below your signoff. It is up to the submitter to add tags that have been sent on prior revisions when sending an updated version, assuming that there has not been a reason to drop them, such as substantial changes from a prior version that might require a new review or testing. In that case, I typically add a note in the changelog as to why I did not carry them forward. The tip documentation 4.2.3 through 4.2.6 has some good information about some other Linux kernel commit message expectations if you find yourself submitting more patches in the future: https://docs.kernel.org/process/maintainer-tip.html#changelog > > > -KBUILD_CFLAGS += -m32 -mcpu=v8 -pipe -mno-fpu -fcall-used-g5 -fcall-used-g7 > > > +KBUILD_CFLAGS += -m32 -mcpu=v8 -pipe -mno-fpu $(call cc-option,-fcall-used-g5) $(call cc-option,-fcall-used-g7) > > > > > > Small nit, this (and the one in the vdso) could probably be one > > cc-option call? Is it likely that one flag would be implemented in the > > compiler without the other? > > > > $(call cc-option,-fcall-used-g5 -fcall-used-g7) > > Ah, didn't know it's possible to do that, the other uses of it I see seem > to use one flag per call. I'll test and send a new revision, thanks. Yeah, I would agree that it is typical to use cc-option for one flag at a time but the entire string just gets passed to $(CC), so there is technically no limitation for how many flags can be tested. This happens to be a rare instance where the flags share a common internal compiler implementation so we know that one cannot be implemented without the other. Cheers, Nathan ^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH v3 2/2] sparc/build: Add SPARC target flags for compiling with clang 2024-10-29 14:49 [PATCH v3 0/2] sparc/build: Rework CFLAGS for clang compatibility Koakuma via B4 Relay 2024-10-29 14:49 ` [PATCH v3 1/2] sparc/build: Put usage of -fcall-used* flags behind cc-option Koakuma via B4 Relay @ 2024-10-29 14:49 ` Koakuma via B4 Relay 2024-10-29 22:24 ` Nathan Chancellor 2024-11-02 8:06 ` Masahiro Yamada 2024-11-16 8:31 ` [PATCH v3 0/2] sparc/build: Rework CFLAGS for clang compatibility Andreas Larsson 2 siblings, 2 replies; 9+ messages in thread From: Koakuma via B4 Relay @ 2024-10-29 14:49 UTC (permalink / raw) To: David S. Miller, Andreas Larsson, Nathan Chancellor, Nick Desaulniers, Bill Wendling, Justin Stitt, glaubitz, Masahiro Yamada, Nicolas Schier, Jonathan Corbet Cc: sparclinux, linux-kernel, llvm, linux-kbuild, linux-doc, Koakuma From: Koakuma <koachan@protonmail.com> clang only supports building 64-bit kernel, so we use the sparc64-linux-gnu target. See also: https://lore.kernel.org/lkml/e26PTXUXEz8OYXmaeKn4Mpuejr4IOlFfFwdB5vpsluXlYiqDdlyQTYcDtdAny_o4gO4SfPeQCCN2qpyT6e0nog5EaP3xk2SeUPTrF54p1gM=@protonmail.com/T/#m068e010dcf8b99d3510a90d7532bcdb70e2e2c6b Signed-off-by: Koakuma <koachan@protonmail.com> --- Documentation/kbuild/llvm.rst | 3 +++ scripts/Makefile.clang | 1 + 2 files changed, 4 insertions(+) diff --git a/Documentation/kbuild/llvm.rst b/Documentation/kbuild/llvm.rst index 6dc66b4f31a7bb62ba5bb6174730dc0a69ee0bba..bc8a283bc44bbfa9948ad3c9fe8031269ce10be4 100644 --- a/Documentation/kbuild/llvm.rst +++ b/Documentation/kbuild/llvm.rst @@ -179,6 +179,9 @@ yet. Bug reports are always welcome at the issue tracker below! * - s390 - Maintained - ``LLVM=1`` (LLVM >= 18.1.0), ``CC=clang`` (LLVM < 18.1.0) + * - sparc (sparc64 only) + - Maintained + - ``CC=clang LLVM_IAS=0`` (LLVM >= 20) * - um (User Mode) - Maintained - ``LLVM=1`` diff --git a/scripts/Makefile.clang b/scripts/Makefile.clang index 6c23c6af797fb016232914589c948208345417ad..2435efae67f53a26d55a1c0f1bf254a49d9fc731 100644 --- a/scripts/Makefile.clang +++ b/scripts/Makefile.clang @@ -10,6 +10,7 @@ CLANG_TARGET_FLAGS_mips := mipsel-linux-gnu CLANG_TARGET_FLAGS_powerpc := powerpc64le-linux-gnu CLANG_TARGET_FLAGS_riscv := riscv64-linux-gnu CLANG_TARGET_FLAGS_s390 := s390x-linux-gnu +CLANG_TARGET_FLAGS_sparc := sparc64-linux-gnu CLANG_TARGET_FLAGS_x86 := x86_64-linux-gnu CLANG_TARGET_FLAGS_um := $(CLANG_TARGET_FLAGS_$(SUBARCH)) CLANG_TARGET_FLAGS := $(CLANG_TARGET_FLAGS_$(SRCARCH)) -- 2.47.0 ^ permalink raw reply related [flat|nested] 9+ messages in thread
* Re: [PATCH v3 2/2] sparc/build: Add SPARC target flags for compiling with clang 2024-10-29 14:49 ` [PATCH v3 2/2] sparc/build: Add SPARC target flags for compiling with clang Koakuma via B4 Relay @ 2024-10-29 22:24 ` Nathan Chancellor 2024-11-02 8:06 ` Masahiro Yamada 1 sibling, 0 replies; 9+ messages in thread From: Nathan Chancellor @ 2024-10-29 22:24 UTC (permalink / raw) To: koachan Cc: David S. Miller, Andreas Larsson, Nick Desaulniers, Bill Wendling, Justin Stitt, glaubitz, Masahiro Yamada, Nicolas Schier, Jonathan Corbet, sparclinux, linux-kernel, llvm, linux-kbuild, linux-doc On Tue, Oct 29, 2024 at 09:49:08PM +0700, Koakuma via B4 Relay wrote: > From: Koakuma <koachan@protonmail.com> > > clang only supports building 64-bit kernel, so we use the > sparc64-linux-gnu target. > > See also: https://lore.kernel.org/lkml/e26PTXUXEz8OYXmaeKn4Mpuejr4IOlFfFwdB5vpsluXlYiqDdlyQTYcDtdAny_o4gO4SfPeQCCN2qpyT6e0nog5EaP3xk2SeUPTrF54p1gM=@protonmail.com/T/#m068e010dcf8b99d3510a90d7532bcdb70e2e2c6b > > Signed-off-by: Koakuma <koachan@protonmail.com> Acked-by: Nathan Chancellor <nathan@kernel.org> > --- > Documentation/kbuild/llvm.rst | 3 +++ > scripts/Makefile.clang | 1 + > 2 files changed, 4 insertions(+) > > diff --git a/Documentation/kbuild/llvm.rst b/Documentation/kbuild/llvm.rst > index 6dc66b4f31a7bb62ba5bb6174730dc0a69ee0bba..bc8a283bc44bbfa9948ad3c9fe8031269ce10be4 100644 > --- a/Documentation/kbuild/llvm.rst > +++ b/Documentation/kbuild/llvm.rst > @@ -179,6 +179,9 @@ yet. Bug reports are always welcome at the issue tracker below! > * - s390 > - Maintained > - ``LLVM=1`` (LLVM >= 18.1.0), ``CC=clang`` (LLVM < 18.1.0) > + * - sparc (sparc64 only) > + - Maintained > + - ``CC=clang LLVM_IAS=0`` (LLVM >= 20) > * - um (User Mode) > - Maintained > - ``LLVM=1`` > diff --git a/scripts/Makefile.clang b/scripts/Makefile.clang > index 6c23c6af797fb016232914589c948208345417ad..2435efae67f53a26d55a1c0f1bf254a49d9fc731 100644 > --- a/scripts/Makefile.clang > +++ b/scripts/Makefile.clang > @@ -10,6 +10,7 @@ CLANG_TARGET_FLAGS_mips := mipsel-linux-gnu > CLANG_TARGET_FLAGS_powerpc := powerpc64le-linux-gnu > CLANG_TARGET_FLAGS_riscv := riscv64-linux-gnu > CLANG_TARGET_FLAGS_s390 := s390x-linux-gnu > +CLANG_TARGET_FLAGS_sparc := sparc64-linux-gnu > CLANG_TARGET_FLAGS_x86 := x86_64-linux-gnu > CLANG_TARGET_FLAGS_um := $(CLANG_TARGET_FLAGS_$(SUBARCH)) > CLANG_TARGET_FLAGS := $(CLANG_TARGET_FLAGS_$(SRCARCH)) > > -- > 2.47.0 > > ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH v3 2/2] sparc/build: Add SPARC target flags for compiling with clang 2024-10-29 14:49 ` [PATCH v3 2/2] sparc/build: Add SPARC target flags for compiling with clang Koakuma via B4 Relay 2024-10-29 22:24 ` Nathan Chancellor @ 2024-11-02 8:06 ` Masahiro Yamada 1 sibling, 0 replies; 9+ messages in thread From: Masahiro Yamada @ 2024-11-02 8:06 UTC (permalink / raw) To: koachan Cc: David S. Miller, Andreas Larsson, Nathan Chancellor, Nick Desaulniers, Bill Wendling, Justin Stitt, glaubitz, Nicolas Schier, Jonathan Corbet, sparclinux, linux-kernel, llvm, linux-kbuild, linux-doc On Tue, Oct 29, 2024 at 11:49 PM Koakuma via B4 Relay <devnull+koachan.protonmail.com@kernel.org> wrote: > > From: Koakuma <koachan@protonmail.com> > > clang only supports building 64-bit kernel, so we use the > sparc64-linux-gnu target. > > See also: https://lore.kernel.org/lkml/e26PTXUXEz8OYXmaeKn4Mpuejr4IOlFfFwdB5vpsluXlYiqDdlyQTYcDtdAny_o4gO4SfPeQCCN2qpyT6e0nog5EaP3xk2SeUPTrF54p1gM=@protonmail.com/T/#m068e010dcf8b99d3510a90d7532bcdb70e2e2c6b > > Signed-off-by: Koakuma <koachan@protonmail.com> Acked-by: Masahiro Yamada <masahiroy@kernel.org> -- Best Regards Masahiro Yamada ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH v3 0/2] sparc/build: Rework CFLAGS for clang compatibility 2024-10-29 14:49 [PATCH v3 0/2] sparc/build: Rework CFLAGS for clang compatibility Koakuma via B4 Relay 2024-10-29 14:49 ` [PATCH v3 1/2] sparc/build: Put usage of -fcall-used* flags behind cc-option Koakuma via B4 Relay 2024-10-29 14:49 ` [PATCH v3 2/2] sparc/build: Add SPARC target flags for compiling with clang Koakuma via B4 Relay @ 2024-11-16 8:31 ` Andreas Larsson 2 siblings, 0 replies; 9+ messages in thread From: Andreas Larsson @ 2024-11-16 8:31 UTC (permalink / raw) To: koachan, David S. Miller, Nathan Chancellor, Nick Desaulniers, Bill Wendling, Justin Stitt, glaubitz, Masahiro Yamada, Nicolas Schier, Jonathan Corbet Cc: sparclinux, linux-kernel, llvm, linux-kbuild, linux-doc On 2024-10-29 15:49, Koakuma via B4 Relay wrote: > 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 > > Signed-off-by: Koakuma <koachan@protonmail.com> > --- > 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/20240717-sparc-cflags-v2-0-259407e6eb5f@protonmail.com > > 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/20240620-sparc-cflags-v1-1-bba7d0ff7d42@protonmail.com > > --- > 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 Reviewed-by: Andreas Larsson <andreas@gaisler.com> I see no pressing need for a v4. Picking the series up to my for-next. Thanks, Andreas ^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2024-11-16 8:31 UTC | newest] Thread overview: 9+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2024-10-29 14:49 [PATCH v3 0/2] sparc/build: Rework CFLAGS for clang compatibility Koakuma via B4 Relay 2024-10-29 14:49 ` [PATCH v3 1/2] sparc/build: Put usage of -fcall-used* flags behind cc-option Koakuma via B4 Relay 2024-10-29 22:24 ` Nathan Chancellor 2024-11-07 4:59 ` Koakuma 2024-11-07 16:01 ` Nathan Chancellor 2024-10-29 14:49 ` [PATCH v3 2/2] sparc/build: Add SPARC target flags for compiling with clang Koakuma via B4 Relay 2024-10-29 22:24 ` Nathan Chancellor 2024-11-02 8:06 ` Masahiro Yamada 2024-11-16 8:31 ` [PATCH v3 0/2] sparc/build: Rework CFLAGS for clang compatibility Andreas Larsson
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).