Skip to contentSkip to conversation

linux-next: build warning after merge of Linus' tree

DISCUSSION Stephen Rothwell 5 participants 8 messages Apr 22, 2025 – Apr 27, 2025

Subsystems (5)
lore
Share & tools
lore
#0 lore raw

Hi all,

After merging Linus' tree, today's linux-next builds (sparc64 and sparc defconfig) produced this warning:

cc1: note: unrecognized command-line option '-Wno-unterminated-string-initialization' may have been intended to silence earlier diagnostics

Introduced by commit

9d7a0577c9db ("gcc-15: disable '-Wunterminated-string-initialization' entirely for now")

These builds were done with a gcc 11.1.0 cross compiler.

Signature · 2 lines
Cheers,
Stephen Rothwell
#1 lore raw
Quoted 2 lines · Stephen Rothwell

These builds were done with a gcc 11.1.0 cross compiler.

That sounds like there might be some issue with the cross-compiler logic somewhere, because the Makefile logic is using the standard

    KBUILD_CFLAGS += $(call cc-option, xyzzy)

pattern. We literally have seven other occurrences of that same logic just in that same Makefile above it (and many more in other makefiles).

IOW, it's *supposed* to only actually use the flag if the compiler supports it, so having the compiler then say "I don't recognize that option" is kind of odd. We've explicitly tested that the compiler supports it.

Does the warning happen for all files that get built, or just some specific ones? I wonder if we have some issue where we end up using two different compilers (I'd assume native and cross-built), and we use KBUILD_CFLAGS for the wrong compiler (or we use cc-option with the wrong compiler, but I'd expect that to affect *everything* - that 'cc-option' thing is not some kind of unusual pattern).

It may be that the other options we check for have been around for so long that they just don't show the issue (ie the 'cc-option' for the other cases may also be using the wrong compiler, but then it's hidden by the fact that both compiler versions just happen to support all the other options anyway).

Linus

#2 lore raw
Quoted 4 lines · Linus Torvalds
Quoted 2 lines · Stephen Rothwell

These builds were done with a gcc 11.1.0 cross compiler.

Quoted 8 lines

That sounds like there might be some issue with the cross-compiler logic somewhere, because the Makefile logic is using the standard

    KBUILD_CFLAGS += $(call cc-option, xyzzy)

pattern. We literally have seven other occurrences of that same logic just in that same Makefile above it (and many more in other makefiles).

I think -Wno-foo is special here. By default GCC does not emit a warning if it does not recognize a disabled warning. This breaks the logic inside $(cc-option).
-Wfoo in contrast does emit a warning.

The original report said:
"cc1: note: unrecognized command-line option '-Wno-unterminated-string-initialization' may have been intended to silence earlier diagnostics"

Note the "earlier diagnostics" wording. And indeed the real reported issue is "warning: #warning syscall clone3 not implemented [-Wcpp]"

To disable warnings there is a dedicated macro.

$(call cc-disable-warning, unterminated-string-initialization)

Thomas

Quoted 17 lines

IOW, it's *supposed* to only actually use the flag if the compiler supports it, so having the compiler then say "I don't recognize that option" is kind of odd. We've explicitly tested that the compiler supports it.

Does the warning happen for all files that get built, or just some specific ones? I wonder if we have some issue where we end up using two different compilers (I'd assume native and cross-built), and we use KBUILD_CFLAGS for the wrong compiler (or we use cc-option with the wrong compiler, but I'd expect that to affect *everything* - that 'cc-option' thing is not some kind of unusual pattern).

It may be that the other options we check for have been around for so long that they just don't show the issue (ie the 'cc-option' for the other cases may also be using the wrong compiler, but then it's hidden by the fact that both compiler versions just happen to support all the other options anyway).

#3 lore raw

[ Adding Masahiro explicitly in case we can just fix cc-option. See below. ]

Quoted 4 lines · Thomas Weißschuh

To disable warnings there is a dedicated macro.

$(call cc-disable-warning, unterminated-string-initialization)

Heh. We have several other cases of that "disable warning" pattern that does *not* use that cc-disable-warning thing.

In fact, right next to the new unterminated-string-initialization case (just a couple of lines above it), we have a

   $(call cc-option, -Wno-stringop-overflow)

thing, along with several cases in loongarch and riscv.

So they are presumably _also_ broken, but perhaps just happened to silently work due to compiler versions (and that stringop-overflow case is gated by a config option that might also have hidden it from people).

And as you say:

Quoted 2 lines

Note the "earlier diagnostics" wording. And indeed the real reported issue is "warning: #warning syscall clone3 not implemented [-Wcpp]"

so apparently it *also* requires other warnings to actually trigger problems, which is presumably why Stephen only sees this issue on sparc* targets.

And which is probably the main reason why the problems with other cases of this same issue haven't been noted.

Now, the obvious fix is to just convert all these cases to 'cc-disable-warning', and I'll do that.

But exactly because we have at least nine cases of this, maybe we could make cc-option actually work for this by forcing that "earlier diagnostics" case in the cc-option test?

Right now cc-option uses -Werror to turn all the warnings into errors, and thus causes a "unrecognized compiler option" warning to be fatal.

But what if we were to add an intentional warning to the cc-options test-case, and use -Wno-error-XYZ to make just *that* warning be harmless, and then 'cc-option' would work for the unrecognized command-line options for the -Wno-xyz case too?

Because even after I fix all the nine cases we've now accumulated, I bet we'll have more in the future - just because 'cc-option' is so much more common (a quick grep shows 429 vs 40 occurrences).

Linus

#4 lore raw
Quoted 6 lines · Linus Torvalds

Heh. We have several other cases of that "disable warning" pattern that does *not* use that cc-disable-warning thing.

In fact, right next to the new unterminated-string-initialization case (just a couple of lines above it), we have a

Quoted 8 lines
   $(call cc-option, -Wno-stringop-overflow)

thing, along with several cases in loongarch and riscv.

So they are presumably _also_ broken, but perhaps just happened to silently work due to compiler versions (and that stringop-overflow case is gated by a config option that might also have hidden it from people).

Indeed, there were a couple of patches that flew by recently fixing some of those instances for that reason but I guess Masahiro may have missed them:

https://lore.kernel.org/[email protected]/
https://lore.kernel.org/[email protected]/

Cheers,
Nathan

#5 lore raw
In reply to Linus Torvalds
Quoted 3 lines · Linus Torvalds

Heh. We have several other cases of that "disable warning" pattern that does *not* use that cc-disable-warning thing.

Bah. I did the obvious sed-script to fix this up, and the result just feels oh-so-wrong.

It feels so wrong because the CC_NO_STRINGOP_OVERFLOW case in the main Makefile goes from having

... += $(call cc-option, -Wno-stringop-overflow)

to having the (obviously fixed)

... += $(call cc-disable-warning, stringop-overflow)

and the patch is clearly *right*.

But the "feels wrong" part is because the very next (unchanged) line in the patch is then using

... += $(call cc-option, -Wstringop-overflow)

for the CC_STRINGOP_OVERFLOW case.

So that patch (full patch attached if somebody wants to see it) really makes it obvious just how unbalanced that cc-option vs cc-disable-warning thing is.

No wonder we had this pattern wrong in several places, in other words.

Linus

 Makefile                       | 4 ++--
 arch/loongarch/kernel/Makefile | 8 ++++----
 arch/loongarch/kvm/Makefile    | 2 +-
 arch/riscv/kernel/Makefile     | 4 ++--
 4 files changed, 9 insertions(+), 9 deletions(-)
Makefile +2 -2
index e94bbb2298c8..07f818186151 100644
@@ -1053,11 +1053,11 @@ NOSTDINC_FLAGS += -nostdinc
 KBUILD_CFLAGS += $(call cc-option, -fstrict-flex-arrays=3)
 
 #Currently, disable -Wstringop-overflow for GCC 11, globally.
-KBUILD_CFLAGS-$(CONFIG_CC_NO_STRINGOP_OVERFLOW) += $(call cc-option, -Wno-stringop-overflow)
+KBUILD_CFLAGS-$(CONFIG_CC_NO_STRINGOP_OVERFLOW) += $(call cc-disable-warning, stringop-overflow)
 KBUILD_CFLAGS-$(CONFIG_CC_STRINGOP_OVERFLOW) += $(call cc-option, -Wstringop-overflow)
 
 #Currently, disable -Wunterminated-string-initialization as broken
-KBUILD_CFLAGS += $(call cc-option, -Wno-unterminated-string-initialization)
+KBUILD_CFLAGS += $(call cc-disable-warning, unterminated-string-initialization)
 
 # disable invalid "can't wrap" optimizations for signed / pointers
 KBUILD_CFLAGS	+= -fno-strict-overflow
arch/loongarch/kernel/Makefile +4 -4
index 4853e8b04c6f..84b1d8b36a47 100644
@@ -21,10 +21,10 @@ obj-$(CONFIG_CPU_HAS_LBT)	+= lbt.o
 
 obj-$(CONFIG_ARCH_STRICT_ALIGN)	+= unaligned.o
 
-CFLAGS_module.o		+= $(call cc-option,-Wno-override-init,)
-CFLAGS_syscall.o	+= $(call cc-option,-Wno-override-init,)
-CFLAGS_traps.o		+= $(call cc-option,-Wno-override-init,)
-CFLAGS_perf_event.o	+= $(call cc-option,-Wno-override-init,)
+CFLAGS_module.o		+= $(call cc-disable-warning,override-init,)
+CFLAGS_syscall.o	+= $(call cc-disable-warning,override-init,)
+CFLAGS_traps.o		+= $(call cc-disable-warning,override-init,)
+CFLAGS_perf_event.o	+= $(call cc-disable-warning,override-init,)
 
 ifdef CONFIG_FUNCTION_TRACER
   ifndef CONFIG_DYNAMIC_FTRACE
arch/loongarch/kvm/Makefile +1 -1
index f4c8e35c216a..e3f0225602ff 100644
@@ -21,4 +21,4 @@ kvm-y += intc/eiointc.o
 kvm-y += intc/pch_pic.o
 kvm-y += irqfd.o
 
-CFLAGS_exit.o	+= $(call cc-option,-Wno-override-init,)
+CFLAGS_exit.o	+= $(call cc-disable-warning,override-init,)
arch/riscv/kernel/Makefile +2 -2
index 8d186bfced45..c6f9b419359c 100644
@@ -9,8 +9,8 @@ CFLAGS_REMOVE_patch.o	= $(CC_FLAGS_FTRACE)
 CFLAGS_REMOVE_sbi.o	= $(CC_FLAGS_FTRACE)
 CFLAGS_REMOVE_return_address.o	= $(CC_FLAGS_FTRACE)
 endif
-CFLAGS_syscall_table.o	+= $(call cc-option,-Wno-override-init,)
-CFLAGS_compat_syscall_table.o += $(call cc-option,-Wno-override-init,)
+CFLAGS_syscall_table.o	+= $(call cc-disable-warning,override-init,)
+CFLAGS_compat_syscall_table.o += $(call cc-disable-warning,override-init,)
 
 ifdef CONFIG_KEXEC_CORE
 AFLAGS_kexec_relocate.o := -mcmodel=medany $(call cc-option,-mno-relax)
#6 lore raw
In reply to Linus Torvalds

On Tue, 22 Apr 2025 11:20:21 -0700
Linus Torvalds <[email protected]> wrote:

...

Quoted 2 lines

Right now cc-option uses -Werror to turn all the warnings into errors, and thus causes a "unrecognized compiler option" warning to be fatal.

I think that gcc only warns for unknown -Wno-xxx if there are other error messages.
So even with -Werror they don't cause a compilations failure.

David

#7 lore raw
In reply to Linus Torvalds

Hi Linus,

Quoted 10 lines · On Tue, 22 Apr 2025 08:59:00 -0700 Linus Torvalds…
Quoted 2 lines · Stephen Rothwell

These builds were done with a gcc 11.1.0 cross compiler.

That sounds like there might be some issue with the cross-compiler logic somewhere, because the Makefile logic is using the standard

    KBUILD_CFLAGS += $(call cc-option, xyzzy)
Quoted 8 lines

pattern. We literally have seven other occurrences of that same logic just in that same Makefile above it (and many more in other makefiles).

IOW, it's *supposed* to only actually use the flag if the compiler supports it, so having the compiler then say "I don't recognize that option" is kind of odd. We've explicitly tested that the compiler supports it.

Yeah, I thought it was strange.

Quoted 6 lines

Does the warning happen for all files that get built, or just some specific ones? I wonder if we have some issue where we end up using two different compilers (I'd assume native and cross-built), and we use KBUILD_CFLAGS for the wrong compiler (or we use cc-option with the wrong compiler, but I'd expect that to affect *everything* - that 'cc-option' thing is not some kind of unusual pattern).

It happens only for a couple of files. Here is the full sparc64 build log:

------------------------------------------------------------------------
<stdin>:1519:2: warning: #warning syscall clone3 not implemented [-Wcpp]
cc1: note: unrecognized command-line option '-Wno-unterminated-string-initialization' may have been intended to silence earlier diagnostics /home/sfr/next/next/arch/sparc/vdso/vclock_gettime.c:274:1: warning: no previous prototype for '__vdso_clock_gettime' [-Wmissing-prototypes]
274 | __vdso_clock_gettime(clockid_t clock, struct __kernel_old_timespec *ts)

      | ^~~~~~~~~~~~~~~~~~~~
/home/sfr/next/next/arch/sparc/vdso/vclock_gettime.c:302:1: warning: no previous prototype for '__vdso_clock_gettime_stick' [-Wmissing-prototypes]
  302 | __vdso_clock_gettime_stick(clockid_t clock, struct __kernel_old_timespec *ts)
      | ^~~~~~~~~~~~~~~~~~~~~~~~~~
/home/sfr/next/next/arch/sparc/vdso/vclock_gettime.c:327:1: warning: no previous prototype for '__vdso_gettimeofday' [-Wmissing-prototypes]
  327 | __vdso_gettimeofday(struct __kernel_old_timeval *tv, struct timezone *tz)
      | ^~~~~~~~~~~~~~~~~~~
/home/sfr/next/next/arch/sparc/vdso/vclock_gettime.c:363:1: warning: no previous prototype for '__vdso_gettimeofday_stick' [-Wmissing-prototypes]
  363 | __vdso_gettimeofday_stick(struct __kernel_old_timeval *tv, struct timezone *tz)
      | ^~~~~~~~~~~~~~~~~~~~~~~~~

cc1: note: unrecognized command-line option '-Wno-unterminated-string-initialization' may have been intended to silence earlier diagnostics In file included from /home/sfr/next/next/arch/sparc/vdso/vdso32/vclock_gettime.c:22:
/home/sfr/next/next/arch/sparc/vdso/vdso32/../vclock_gettime.c:274:1: warning: no previous prototype for '__vdso_clock_gettime' [-Wmissing-prototypes]
274 | __vdso_clock_gettime(clockid_t clock, struct __kernel_old_timespec *ts)

      | ^~~~~~~~~~~~~~~~~~~~
/home/sfr/next/next/arch/sparc/vdso/vdso32/../vclock_gettime.c:302:1: warning: no previous prototype for '__vdso_clock_gettime_stick' [-Wmissing-prototypes]
  302 | __vdso_clock_gettime_stick(clockid_t clock, struct __kernel_old_timespec *ts)
      | ^~~~~~~~~~~~~~~~~~~~~~~~~~
/home/sfr/next/next/arch/sparc/vdso/vdso32/../vclock_gettime.c:327:1: warning: no previous prototype for '__vdso_gettimeofday' [-Wmissing-prototypes]
  327 | __vdso_gettimeofday(struct __kernel_old_timeval *tv, struct timezone *tz)
      | ^~~~~~~~~~~~~~~~~~~
/home/sfr/next/next/arch/sparc/vdso/vdso32/../vclock_gettime.c:363:1: warning: no previous prototype for '__vdso_gettimeofday_stick' [-Wmissing-prototypes]
  363 | __vdso_gettimeofday_stick(struct __kernel_old_timeval *tv, struct timezone *tz)
      | ^~~~~~~~~~~~~~~~~~~~~~~~~

cc1: note: unrecognized command-line option '-Wno-unterminated-string-initialization' may have been intended to silence earlier diagnostics /home/sfr/next/next/kernel/fork.c: In function '__do_sys_clone3':
/home/sfr/next/next/kernel/fork.c:3150:2: warning: #warning clone3() entry point is missing, please fix [-Wcpp]
3150 | #warning clone3() entry point is missing, please fix

      |  ^~~~~~~

/home/sfr/next/next/kernel/fork.c: At top level:
cc1: note: unrecognized command-line option '-Wno-unterminated-string-initialization' may have been intended to silence earlier diagnostics /home/sfr/next/next/kernel/fork.c:3150:2: warning: #warning clone3() entry point is missing, please fix [-Wcpp]
3150 | #warning clone3() entry point is missing, please fix

      |  ^~~~~~~

cc1: note: unrecognized command-line option '-Wno-unterminated-string-initialization' may have been intended to silence earlier diagnostics
WARNING: modpost: EXPORT symbol "_mcount" [vmlinux] version generation failed, symbol will not be versioned.
Is "_mcount" prototyped in <asm/asm-prototypes.h>?
------------------------------------------------------------------------

However:

$ /opt/cross/gcc-11.1.0-nolibc/sparc64-linux/bin/sparc64-linux-gcc -Werror -Wno-unterminated-string-initialization -c -x c /dev/null
$ echo $?
0
$ /opt/cross/gcc-11.1.0-nolibc/sparc64-linux/bin/sparc64-linux-gcc -Werror -Wunterminated-string-initialization -c -x c /dev/null
sparc64-linux-gcc: error: unrecognized command-line option '-Wunterminated-string-initialization'
$ echo $?
1
Signature · 2 lines
Cheers,
Stephen Rothwell