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

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.

Suggested-by: Nick Desaulniers <ndesaulniers@google.com>
Signed-off-by: Nathan Chancellor <nathan@kernel.org>
Signed-off-by: Thomas Bogendoerfer <tsbogend@alpha.franken.de>

authored by

Nathan Chancellor and committed by
Thomas Bogendoerfer
d49fc692 0e96ea5c

+8 -2
+4
arch/mips/Kconfig
··· 3202 3202 3203 3203 If unsure, say N. 3204 3204 3205 + config CC_HAS_MNO_BRANCH_LIKELY 3206 + def_bool y 3207 + depends on $(cc-option,-mno-branch-likely) 3208 + 3205 3209 menu "Power management options" 3206 3210 3207 3211 config ARCH_HIBERNATION_POSSIBLE
+2 -1
arch/mips/loongson2ef/Platform
··· 41 41 # Loongson Machines' Support 42 42 # 43 43 44 - cflags-$(CONFIG_MACH_LOONGSON2EF) += -I$(srctree)/arch/mips/include/asm/mach-loongson2ef -mno-branch-likely 44 + cflags-$(CONFIG_MACH_LOONGSON2EF) += -I$(srctree)/arch/mips/include/asm/mach-loongson2ef 45 + cflags-$(CONFIG_CC_HAS_MNO_BRANCH_LIKELY) += -mno-branch-likely 45 46 load-$(CONFIG_LEMOTE_FULOONG2E) += 0xffffffff80100000 46 47 load-$(CONFIG_LEMOTE_MACH2F) += 0xffffffff80200000
+2 -1
arch/mips/loongson64/Platform
··· 18 18 # Loongson Machines' Support 19 19 # 20 20 21 - cflags-$(CONFIG_MACH_LOONGSON64) += -I$(srctree)/arch/mips/include/asm/mach-loongson64 -mno-branch-likely 21 + cflags-$(CONFIG_MACH_LOONGSON64) += -I$(srctree)/arch/mips/include/asm/mach-loongson64 22 + cflags-$(CONFIG_CC_HAS_MNO_BRANCH_LIKELY) += -mno-branch-likely 22 23 load-$(CONFIG_CPU_LOONGSON64) += 0xffffffff80200000