[PATCH AUTOSEL 6.19-5.10] s390/purgatory: Add -Wno-default-const-init-unsafe to KBUILD_CFLAGS

Sasha Levin sashal at kernel.org
Wed Feb 11 04:30:14 PST 2026


From: Heiko Carstens <hca at linux.ibm.com>

[ Upstream commit b4780fe4ddf04b51127a33d705f4a2e224df00fa ]

Add -Wno-default-const-init-unsafe to purgatory KBUILD_CFLAGS, similar
to scripts/Makefile.extrawarn, since clang generates warnings for the
dummy variable in typecheck():

    CC      arch/s390/purgatory/purgatory.o
      arch/s390/include/asm/ptrace.h:221:9: warning: default initialization of an object of type 'typeof (regs->psw)' (aka 'const psw_t') leaves the object uninitialized [-Wdefault-const-init-var-unsafe]
        221 |         return psw_bits(regs->psw).pstate;
            |                ^
      arch/s390/include/asm/ptrace.h:98:2: note: expanded from macro 'psw_bits'
         98 |         typecheck(psw_t, __psw);                \
            |         ^
      include/linux/typecheck.h:11:12: note: expanded from macro 'typecheck'
         11 |         typeof(x) __dummy2; \
            |                   ^

Signed-off-by: Heiko Carstens <hca at linux.ibm.com>
Signed-off-by: Sasha Levin <sashal at kernel.org>
---

LLM Generated explanations, may be completely bogus:

Now I have a thorough understanding. Let me compile my analysis.

## Analysis: s390/purgatory: Add -Wno-default-const-init-unsafe to
KBUILD_CFLAGS

### 1. Commit Message Analysis

The commit adds the `-Wno-default-const-init-unsafe` compiler flag to
the s390 purgatory's `KBUILD_CFLAGS`. The commit message clearly
explains the problem: **clang 21+** introduced a new on-by-default
warning (`-Wdefault-const-init-var-unsafe`) that triggers on the
`typecheck()` macro's dummy variable. The warning fires in
`arch/s390/include/asm/ptrace.h:221` via `psw_bits()` -> `typecheck()`
-> `__dummy2` (line 11 of `include/linux/typecheck.h`).

The commit author is Heiko Carstens, the s390 subsystem maintainer.

### 2. Code Change Analysis

The change is exactly **one line** added to
`arch/s390/purgatory/Makefile`:

```
+KBUILD_CFLAGS += $(call cc-option, -Wno-default-const-init-unsafe)
```

This is wrapped in `$(call cc-option, ...)`, which means it's only
applied when the compiler supports the flag, providing backward
compatibility.

### 3. Root Cause: Why s390 Purgatory Needs Its Own Fix

This is the critical technical detail. The s390 purgatory Makefile
**completely replaces** `KBUILD_CFLAGS` from scratch (line 16):

```16:16:arch/s390/purgatory/Makefile
KBUILD_CFLAGS := -std=gnu11 -fms-extensions -fno-strict-aliasing -Wall
-Wstrict-prototypes
```

Note the `:=` assignment operator — this discards ALL previously-set
global flags, including the `-Wno-default-const-init-unsafe` that was
already added to `scripts/Makefile.warn` (formerly
`scripts/Makefile.extrawarn`) by commit `d0afcfeb9e381` ("kbuild:
Disable -Wdefault-const-init-unsafe").

In contrast, other purgatory Makefiles (x86, riscv, powerpc) use
`filter-out` patterns like:
```
KBUILD_CFLAGS := $(filter-out -fprofile-sample-use=%
...,$(KBUILD_CFLAGS))
```
which **preserve** the global flags (including the warning suppression).
Only s390's purgatory builds from scratch and needs this companion fix.

### 4. Is This a Build Fix?

**Yes, definitively.** With `CONFIG_WERROR=y` (enabled in many distro
configs and CI systems), the clang 21+ warning becomes a build error.
The commit message shows the exact warning output from `CC
arch/s390/purgatory/purgatory.o`. The trigger path is:

- `purgatory.o` includes `asm/ptrace.h`
- `ptrace.h:221` calls `psw_bits(regs->psw).pstate`
- `psw_bits` macro (line 98) calls `typecheck(psw_t, __psw)`
- `typecheck` macro (`include/linux/typecheck.h:11`) declares `typeof(x)
  __dummy2;` — an uninitialized const variable
- clang 21+ flags this with `-Wdefault-const-init-var-unsafe`

### 5. Relationship to Parent Commit

The parent commit `d0afcfeb9e381` ("kbuild: Disable -Wdefault-const-
init-unsafe") was explicitly tagged with `Cc: stable at vger.kernel.org`,
indicating the kernel community considers this warning fix important for
stable. That commit fixed the global build system, but the s390
purgatory was missed because it builds its own CFLAGS from scratch. This
commit is the necessary companion fix.

However, this commit is **self-contained** — it doesn't depend on
`d0afcfeb9e381` being present in stable. The s390 purgatory always
builds its own CFLAGS independently.

### 6. Risk Assessment

- **Lines changed**: 1
- **Files changed**: 1 Makefile
- **Runtime risk**: **Zero**. This is purely a compile-time flag that
  suppresses a spurious compiler warning. No runtime behavior change
  whatsoever.
- **Backward compatibility**: The `$(call cc-option, ...)` wrapper
  ensures the flag is silently ignored on compilers that don't support
  it (older clang, all gcc).
- **Side effects**: None. The warning being suppressed (`-Wdefault-
  const-init-var-unsafe`) is well-audited — the `typecheck()` macro's
  dummy variable is never used; it exists solely for compile-time type
  checking.

### 7. Stable Relevance

- The s390 purgatory (kexec code) exists in all stable kernel trees
  going back many years.
- The `psw_bits()` / `typecheck()` code path exists in all these trees.
- Users building stable kernels with newer clang + `CONFIG_WERROR=y`
  **will** get build failures.
- Build fixes are explicitly listed as appropriate for stable in
  `Documentation/process/stable-kernel-rules.rst`.

### 8. Dependency Check

The commit is fully self-contained. The only "dependency" is the s390
purgatory Makefile itself, which has existed unchanged (in terms of the
KBUILD_CFLAGS structure) for many kernel versions. The `$(call cc-
option, ...)` mechanism is available in all stable trees.

### Summary

This is a textbook build fix for stable:
- **One line**, zero risk, zero runtime impact
- Fixes a **real build failure** with newer clang + CONFIG_WERROR
- Self-contained, no dependencies
- Companion to a commit already tagged `Cc: stable at vger.kernel.org`
- Uses `cc-option` for backward compatibility
- Written by the s390 subsystem maintainer

**YES**

 arch/s390/purgatory/Makefile | 1 +
 1 file changed, 1 insertion(+)

diff --git a/arch/s390/purgatory/Makefile b/arch/s390/purgatory/Makefile
index 0c196a5b194af..61d240a37633d 100644
--- a/arch/s390/purgatory/Makefile
+++ b/arch/s390/purgatory/Makefile
@@ -23,6 +23,7 @@ KBUILD_CFLAGS += -D__DISABLE_EXPORTS
 KBUILD_CFLAGS += $(CLANG_FLAGS)
 KBUILD_CFLAGS += $(if $(CONFIG_CC_IS_CLANG),-Wno-microsoft-anon-tag)
 KBUILD_CFLAGS += $(call cc-option,-fno-PIE)
+KBUILD_CFLAGS += $(call cc-option, -Wno-default-const-init-unsafe)
 KBUILD_AFLAGS := $(filter-out -DCC_USING_EXPOLINE,$(KBUILD_AFLAGS))
 KBUILD_AFLAGS += -D__DISABLE_EXPORTS
 
-- 
2.51.0




More information about the linux-riscv mailing list