MIPS: Loongson64: Clean up use of cc-ifversion
Subsystems (3)
PATCH v2 1/2 MIPS: Loongson64: Clean up use of cc-ifversion
This Makefile checks that GCC is 4.9 or newer, which is redundant after commit 76ae847497bc ("Documentation: raise minimum supported version of GCC to 5.1"), so cc-option can be removed.
Clang does not support -march=loongson3a so it needs to continue to use -march=mips64r2, which no longer needs cc-option because all supported clang versions recognize this flag.
-march=loonson3a can be used unconditionally with GCC because the minimum supported GCC version has been bumped past 4.9.0, which won't have the bug mentioned in the comment. The _MIPS_ISA macro redefinition can be removed at the same time for the same reason.
---
v1 -> v2: https://lore.kernel.org/r/[email protected]/
* Eliminate ld-option call (Jiaxun).
* Eliminate _MIPS_ISA macro redefinitions (Nick).
arch/mips/loongson64/Platform | 21 +++------------------ 1 file changed, 3 insertions(+), 18 deletions(-)
arch/mips/loongson64/Platform +3 -18
@@ -5,24 +5,9 @@ cflags-$(CONFIG_CPU_LOONGSON64) += -Wa,--trap -# -# binutils from v2.25 on and gcc starting from v4.9.0 treat -march=loongson3a -# as MIPS64 R2; older versions as just R1. This leaves the possibility open -# that GCC might generate R2 code for -march=loongson3a which then is rejected -# by GAS. The cc-option can't probe for this behaviour so -march=loongson3a -# can't easily be used safely within the kbuild framework. -# -ifeq ($(call cc-ifversion, -ge, 0409, y), y) - ifeq ($(call ld-ifversion, -ge, 22500, y), y) - cflags-$(CONFIG_CPU_LOONGSON64) += \ - $(call cc-option,-march=loongson3a -U_MIPS_ISA -D_MIPS_ISA=_MIPS_ISA_MIPS64) - else - cflags-$(CONFIG_CPU_LOONGSON64) += \ - $(call cc-option,-march=mips64r2,-mips64r2 -U_MIPS_ISA -D_MIPS_ISA=_MIPS_ISA_MIPS64) - endif -else - cflags-$(CONFIG_CPU_LOONGSON64) += \ - $(call cc-option,-march=mips64r2,-mips64r2 -U_MIPS_ISA -D_MIPS_ISA=_MIPS_ISA_MIPS64) +ifdef CONFIG_CPU_LOONGSON64 +cflags-$(CONFIG_CC_IS_GCC) += -march=loongson3a +cflags-$(CONFIG_CC_IS_CLANG) += -march=mips64r2 endif # Some -march= flags enable MMI instructions, and GCC complains about that
base-commit: e783362eb54cd99b2cac8b3a9aeac942e6f6ac07
Signature · 1 line
2.35.0
PATCH v2 2/2 MIPS: Loongson{2ef,64}: Wrap -mno-branch-likely with cc-option
This flag is not supported by clang, which results in a warning:
clang-14: warning: argument unused during compilation: '-mno-branch-likely' [-Wunused-command-line-argument]
This breaks cc-option, which adds -Werror to make this warning fatal and catch flags that are not supported.
Wrap this flag in cc-option so that it does not cause cc-option to fail, which can cause randconfigs to be really noisy, due to warnings not getting disabled that should be.
Additionally, move the cc-option check to Kconfig so that the check is done at configuration time, rather than build time, as builds with no configuration change will be quicker because the cc-option call will not need to happen in those instances.
---
v1 -> v2: https://lore.kernel.org/r/[email protected]/
* Move cc-option call to Kconfig (Nick).
* Also apply to loongson2ef, even though this will not currently build with clang.
arch/mips/Kconfig | 4 ++++ arch/mips/loongson2ef/Platform | 3 ++- arch/mips/loongson64/Platform | 3 ++- 3 files changed, 8 insertions(+), 2 deletions(-)
arch/mips/Kconfig +4 -0
@@ -3202,6 +3202,10 @@ config MIPS32_N32 If unsure, say N. +config CC_HAS_MNO_BRANCH_LIKELY + def_bool y + depends on $(cc-option,-mno-branch-likely) + menu "Power management options" config ARCH_HIBERNATION_POSSIBLE
arch/mips/loongson2ef/Platform +2 -1
@@ -41,6 +41,7 @@ cflags-y += $(call cc-option,-mno-loongson-mmi) # Loongson Machines' Support # -cflags-$(CONFIG_MACH_LOONGSON2EF) += -I$(srctree)/arch/mips/include/asm/mach-loongson2ef -mno-branch-likely +cflags-$(CONFIG_MACH_LOONGSON2EF) += -I$(srctree)/arch/mips/include/asm/mach-loongson2ef +cflags-$(CONFIG_CC_HAS_MNO_BRANCH_LIKELY) += -mno-branch-likely load-$(CONFIG_LEMOTE_FULOONG2E) += 0xffffffff80100000 load-$(CONFIG_LEMOTE_MACH2F) += 0xffffffff80200000
arch/mips/loongson64/Platform +2 -1
@@ -18,5 +18,6 @@ cflags-y += $(call cc-option,-mno-loongson-mmi) # Loongson Machines' Support # -cflags-$(CONFIG_MACH_LOONGSON64) += -I$(srctree)/arch/mips/include/asm/mach-loongson64 -mno-branch-likely +cflags-$(CONFIG_MACH_LOONGSON64) += -I$(srctree)/arch/mips/include/asm/mach-loongson64 +cflags-$(CONFIG_CC_HAS_MNO_BRANCH_LIKELY) += -mno-branch-likely load-$(CONFIG_CPU_LOONGSON64) += 0xffffffff80200000
Signature · 1 line
2.35.0
Re: [PATCH v2 2/2] MIPS: Loongson{2ef,64}: Wrap -mno-branch-likely with cc-option
Quoted 22 lines · Nathan Chancellor
This flag is not supported by clang, which results in a warning:
clang-14: warning: argument unused during compilation: '-mno-branch-likely' [-Wunused-command-line-argument]
This breaks cc-option, which adds -Werror to make this warning fatal and catch flags that are not supported.
Wrap this flag in cc-option so that it does not cause cc-option to fail, which can cause randconfigs to be really noisy, due to warnings not getting disabled that should be.
Additionally, move the cc-option check to
Kconfigso that the check is done at configuration time, rather than build time, as builds with no configuration change will be quicker because the cc-option call will not need to happen in those instances.Suggested-by Nick Desaulniers <[email protected]>Signed-off-by Nathan Chancellor <[email protected]>---
Quoted 8 lines
* Move cc-option call to
Kconfig(Nick).
* Also apply to loongson2ef, even though this will not currently build with clang.arch/mips/Kconfig | 4 ++++ arch/mips/loongson2ef/Platform | 3 ++- arch/mips/loongson64/Platform | 3 ++- 3 files changed, 8 insertions(+), 2 deletions(-)
applied to mips-next.
Thomas.
Signature · 2 lines
Crap can work. Given enough thrust pigs will fly, but it's not necessarily a good idea. [ RFC1925, 2.3 ]
Quoted 18 lines · Nathan Chancellor
This
Makefilechecks that GCC is 4.9 or newer, which is redundant after commit76ae847497bc("Documentation: raise minimum supported version of GCC to 5.1"), so cc-option can be removed.Clang does not support -march=loongson3a so it needs to continue to use -march=mips64r2, which no longer needs cc-option because all supported clang versions recognize this flag.
-march=loonson3a can be used unconditionally with GCC because the minimum supported GCC version has been bumped past 4.9.0, which won't have the bug mentioned in the comment. The
_MIPS_ISAmacro redefinition can be removed at the same time for the same reason.Suggested-by Jiaxun Yang <[email protected]>Suggested-by Nick Desaulniers <[email protected]>Signed-off-by Nathan Chancellor <[email protected]>---
Quoted 7 lines
v1 -> v2: https://lore.kernel.org/r/[email protected]/
* Eliminate ld-option call (Jiaxun).
* Eliminate_MIPS_ISAmacro redefinitions (Nick).arch/mips/loongson64/Platform | 21 +++------------------ 1 file changed, 3 insertions(+), 18 deletions(-)
applied to mips-next.
Thomas.
Signature · 2 lines
Crap can work. Given enough thrust pigs will fly, but it's not necessarily a good idea. [ RFC1925, 2.3 ]