Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

sparc/build: Put usage of -fcall-used* flags behind cc-option

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>
Reviewed-by: Nathan Chancellor <nathan@kernel.org>
Tested-by: Nathan Chancellor <nathan@kernel.org>
Reviewed-by: Andreas Larsson <andreas@gaisler.com>
Link: https://lore.kernel.org/r/20241029-sparc-cflags-v3-1-b28745a6bd71@protonmail.com
Signed-off-by: Andreas Larsson <andreas@gaisler.com>

authored by

Koakuma and committed by
Andreas Larsson
69114be1 9852d85e

+3 -3
+2 -2
arch/sparc/Makefile
··· 29 29 # versions of gcc. Some gcc versions won't pass -Av8 to binutils when you 30 30 # give -mcpu=v8. This silently worked with older bintutils versions but 31 31 # does not any more. 32 - KBUILD_CFLAGS += -m32 -mcpu=v8 -pipe -mno-fpu -fcall-used-g5 -fcall-used-g7 32 + KBUILD_CFLAGS += -m32 -mcpu=v8 -pipe -mno-fpu $(call cc-option,-fcall-used-g5) $(call cc-option,-fcall-used-g7) 33 33 KBUILD_CFLAGS += -Wa,-Av8 34 34 35 35 KBUILD_AFLAGS += -m32 -Wa,-Av8 ··· 45 45 UTS_MACHINE := sparc64 46 46 47 47 KBUILD_CFLAGS += -m64 -pipe -mno-fpu -mcpu=ultrasparc -mcmodel=medlow 48 - KBUILD_CFLAGS += -ffixed-g4 -ffixed-g5 -fcall-used-g7 -Wno-sign-compare 48 + KBUILD_CFLAGS += -ffixed-g4 -ffixed-g5 $(call cc-option,-fcall-used-g7) -Wno-sign-compare 49 49 KBUILD_CFLAGS += -Wa,--undeclared-regs 50 50 KBUILD_CFLAGS += $(call cc-option,-mtune=ultrasparc3) 51 51 KBUILD_AFLAGS += -m64 -mcpu=ultrasparc -Wa,--undeclared-regs
+1 -1
arch/sparc/vdso/Makefile
··· 46 46 -fno-omit-frame-pointer -foptimize-sibling-calls \ 47 47 -DDISABLE_BRANCH_PROFILING -DBUILD_VDSO 48 48 49 - SPARC_REG_CFLAGS = -ffixed-g4 -ffixed-g5 -fcall-used-g5 -fcall-used-g7 49 + SPARC_REG_CFLAGS = -ffixed-g4 -ffixed-g5 $(call cc-option,-fcall-used-g5) $(call cc-option,-fcall-used-g7) 50 50 51 51 $(vobjs): KBUILD_CFLAGS := $(filter-out $(RANDSTRUCT_CFLAGS) $(GCC_PLUGINS_CFLAGS) $(SPARC_REG_CFLAGS),$(KBUILD_CFLAGS)) $(CFL) 52 52