Subject: Bug#1104745: gcc-15 ICE compiling linux kernel 6.14.5 with CONFIG_RANDSTRUCT

From: Ingo Saitz <[email-masked]>
Date: Mon, 05 May 2025 17:40:57 +0200

Package: gcc-15
Version: 15.1.0-3
Severity: normal

Dear Maintainer,

When compiling the linux kernel (tested on 6.15-rc5 and 6.14.5 from
kernel.org) with CONFIG_RANDSTRUCT enabled, gcc-15 throws an ICE:

arch/x86/kernel/cpu/proc.c:174:14: internal compiler error: in comptypes_check_enum_int, at c/c-typeck.cc:1516
  174 | const struct seq_operations cpuinfo_op = {
      |              ^~~~~~~~~~~~~~

I have attached a minmal config for 6.14.5 (make allnoconfig and then
enable CONFIG_RANDSTRUCT_PERFORMANCE) that exibits this behaviour plus
the full dump produced by gcc-15 -freport-bug. I build the kernel with

    make CC="gcc-15 -freport-bug" HOSTCC=gcc-15 V=1

Also CONFIG_RANDSTRUCT_FULL produces the same dump, the only
difference being the option
"-fplugin-arg-randomize_layout_plugin-performance-mode" left out.

The same config build on gcc-14 (Debian 14.2.0-19) 14.2.0 without ICE.

Thanks
    Ingo

-- System Information:
Distributor ID:	Devuan
Description:	Devuan GNU/Linux 6 (excalibur/ceres)
Release:	6
Codename:	excalibur ceres
Architecture: x86_64

Kernel: Linux 6.14.2-spatz20250410 (SMP w/4 CPU threads; PREEMPT)
Kernel taint flags: TAINT_FIRMWARE_WORKAROUND, TAINT_OOT_MODULE, TAINT_RANDSTRUCT
Locale: LANG=en_GB.UTF-8, LC_CTYPE=en_GB.UTF-8 (charmap=UTF-8), LANGUAGE=en_US:en
Shell: /bin/sh linked to /usr/bin/dash
Init: sysvinit (via /sbin/init)

Versions of packages gcc-15 depends on:
ii  binutils                 2.44-3
ii  cpp-15                   15.1.0-3
ii  gcc-15-base              15.1.0-3
ii  gcc-15-x86-64-linux-gnu  15.1.0-3

Versions of packages gcc-15 recommends:
ii  libc6-dev  2.41-7

Versions of packages gcc-15 suggests:
pn  gcc-15-doc       <none>
pn  gcc-15-locales   <none>
pn  gcc-15-multilib  <none>

-- no debconf information

---

From: Ingo Saitz <[email-masked]>
Date: Fri, 9 May 2025 09:13:37 +0200

I can build the Linux 6.14.5 kernel with CONFIG_RANDSTRUCT_PERFORMANCE
successfully using upstream gcc 15.1.0, so the bug seems to be
introduced by some of Debians patches (or pulls from upstream
development). See attached build.log and minimal config.

    Ingo
-- 
const_cast<long double>(Λ)

---

From: Matthias Klose <[email-masked]>
Date: Mon, 12 May 2025 14:25:24 +0200

Control: tags -1 + moreinfo

from the attached preprocessed source ...

please can you report the issue, where you got this plugin from?

// gcc version 15.1.0 (Debian 15.1.0-3)
//
// *** WARNING *** there are active plugins, do not report this as a bug 
unless you can reproduce it without enabling any plugins.
// Event                            | Plugins
// PLUGIN_FINISH_TYPE               | randomize_layout_plugin
// PLUGIN_FINISH_DECL               | randomize_layout_plugin
// PLUGIN_ATTRIBUTES                | randomize_layout_plugin
// PLUGIN_ALL_IPA_PASSES_START      | randomize_layout_plugin
// arch/x86/kernel/cpu/proc.c:174:14: internal compiler error: in 
comptypes_check_enum_int, at c/c-typeck.cc:1516
//   174 | const struct seq_operations cpuinfo_op = {
//       |              ^~~~~~~~~~~~~~
// 0x1cf8479 internal_error(char const*, ...)
// 	../../src/gcc/diagnostic-global-context.cc:517
// 0x1cf85eb fancy_abort(char const*, int, char const*)
// 	../../src/gcc/diagnostic.cc:1749
// 0x750e68 comptypes_check_enum_int(tree_node*, tree_node*, bool*)
// 	../../src/gcc/c/c-typeck.cc:1516
// 0x750e68 comptypes_check_enum_int(tree_node*, tree_node*, bool*)
// 	../../src/gcc/c/c-typeck.cc:1510
// 0x24161fd diagnose_mismatched_decls
// 	../../src/gcc/c/c-decl.cc:2170
// 0x24148ff duplicate_decls
// 	../../src/gcc/c/c-decl.cc:3169
// 0x1d93668 pushdecl(tree_node*)
// 	../../src/gcc/c/c-decl.cc:3376
// 0x1df85c4 start_decl(c_declarator*, c_declspecs*, bool, tree_node*, 
bool, unsigned long*)
// 	../../src/gcc/c/c-decl.cc:5773
// 0x2409a09 c_parser_declaration_or_fndef
// 	../../src/gcc/c/c-parser.cc:2846
// 0x2408fbc c_parser_external_declaration
// 	../../src/gcc/c/c-parser.cc:2105
// 0x2405314 c_parser_translation_unit
// 	../../src/gcc/c/c-parser.cc:1959
// 0x2405314 c_parse_file()
// 	../../src/gcc/c/c-parser.cc:29790
// 0x240237d c_common_parse_file()
// 	../../src/gcc/c-family/c-opts.cc:1379

---

From: Ingo Saitz <[email-masked]>
Date: Mon, 12 May 2025 18:21:08 +0200

> please can you report the issue, where you got this plugin from?

The plugin is part of the linux kernel compilation process to randomize
structure layout. This plugin was from vanilla 6.14.5 linux kernel sources,
in scripts/gcc-plugins/randomize_layout_plugin.c . It gets build and used
automatically when CONFIG_RANDSTRUCT_PERFORMANCE (or _FULL) is enabled.

    Ingo

---

From: Matthias Klose <[email-masked]>
Date: Tue, 13 May 2025 10:33:09 +0200

Control: reassign -1 src:linux

> automatically when CONFIG_RANDSTRUCT_PERFORMANCE (or _FULL) is enabled.

according to GCC upstream developers, this should be forwarded upstream 
for linux.

---

From: Ingo Saitz <[email-masked]>
Date: Tue, 13 May 2025 23:49:07 +0200

On Tue, May 13, 2025 at 10:33:09AM +0200, Matthias Klose wrote:
> according to GCC upstream developers, this should be forwarded upstream for
> linux.

Do you have any reference on this, because the ICE does not occur when
building the kernel with a vanilla gcc 15.1.0 build from git. (see
Message #10)

OTOH I do get the ICE with all Debians gcc-15 versions I tested (15.1.0-1 to
15.1.0-4).

    Ingo