linux/arch/riscv
Linus Torvalds 3f856d5d84 Fix mis-uses of 'cc-option' for warning disablement
commit a79be02bba upstream.

This was triggered by one of my mis-uses causing odd build warnings on
sparc in linux-next, but while figuring out why the "obviously correct"
use of cc-option caused such odd breakage, I found eight other cases of
the same thing in the tree.

The root cause is that 'cc-option' doesn't work for checking negative
warning options (ie things like '-Wno-stringop-overflow') because gcc
will silently accept options it doesn't recognize, and so 'cc-option'
ends up thinking they are perfectly fine.

And it all works, until you have a situation where _another_ warning is
emitted.  At that point the compiler will go "Hmm, maybe the user
intended to disable this warning but used that wrong option that I
didn't recognize", and generate a warning for the unrecognized negative
option.

Which explains why we have several cases of this in the tree: the
'cc-option' test really doesn't work for this situation, but most of the
time it simply doesn't matter that ity doesn't work.

The reason my recently added case caused problems on sparc was pointed
out by Thomas Weißschuh: the sparc build had a previous explicit warning
that then triggered the new one.

I think the best fix for this would be to make 'cc-option' a bit smarter
about this sitation, possibly by adding an intentional warning to the
test case that then triggers the unrecognized option warning reliably.

But the short-term fix is to replace 'cc-option' with an existing helper
designed for this exact case: 'cc-disable-warning', which picks the
negative warning but uses the positive form for testing the compiler
support.

Reported-by: Stephen Rothwell <sfr@canb.auug.org.au>
Link: https://lore.kernel.org/all/20250422204718.0b4e3f81@canb.auug.org.au/
Explained-by: Thomas Weißschuh <linux@weissschuh.net>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Nathan Chancellor <nathan@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
History 2025-05-29 11:03:25 +02:00
..
boot riscv: dts: sophgo: fix DMA data-width configuration for CV18xx 2025-05-22 14:29:35 +02:00
configs timekeeping: Remove CONFIG_DEBUG_TIMEKEEPING 2024-12-14 20:04:16 +01:00
crypto crypto: lib/Kconfig - Hide arch options from user 2025-05-02 07:59:32 +02:00
errata RISC-V: errata: Use medany for relocatable builds 2025-04-10 14:39:32 +02:00
include riscv: Allow NOMMU kernels to access all of RAM 2025-05-29 11:02:05 +02:00
kernel Fix mis-uses of 'cc-option' for warning disablement 2025-05-29 11:03:25 +02:00
kvm RISC-V: KVM: Disable the kernel perf counter during configure 2025-04-10 14:39:11 +02:00
lib Merge patch series "riscv: Improve KASAN coverage to fix unit tests" 2024-09-19 01:10:44 -07:00
mm riscv: Call secondary mmu notifier when flushing the tlb 2025-05-29 11:02:14 +02:00
net riscv, bpf: Make BPF_CMPXCHG fully ordered 2024-10-17 17:14:48 +02:00
purgatory riscv/purgatory: 4B align purgatory_start 2025-04-10 14:39:33 +02:00
tools riscv: Check relocations at compile time 2023-04-19 07:46:32 -07:00
Kbuild RISC-V: hook new crypto subdir into build-system 2024-01-22 17:55:17 -08:00
Kconfig crash, powerpc: default to CRASH_DUMP=n on PPC_BOOK3S_32 2024-11-14 22:43:48 -08:00
Kconfig.debug riscv: Add tests for riscv module loading 2023-11-07 14:59:32 -08:00
Kconfig.errata riscv: thead: Rename T-Head PBMT to MAE 2024-04-25 10:22:33 -07:00
Kconfig.socs RISC-V: drop SOC_VIRT for ARCH_VIRT 2024-04-10 11:37:50 +01:00
Kconfig.vendor riscv: Extend cpufeature.c to detect vendor extensions 2024-07-22 15:36:54 -07:00
Makefile riscv: boot: add Image.xz support 2024-09-01 20:43:27 -07:00
Makefile.postlink kbuild: remove ARCH_POSTLINK from module builds 2023-10-28 21:10:08 +09:00