Skip to content

GCC 16.1 segfaults compiling src/main.cpp when the module graph gains one module #863

Open

Description

@Sunrisepeak

What happens

GCC 16.1.0 (the gcc@16.1.0 toolchain mcpp builds itself with) segfaults while compiling src/main.cpp (import mcpp.cli;) once the tree's module graph grows by one module. Measured while implementing the target sets of design 2026-10-29 (release/2026.10.30.1):

  • adding a new module to the tree, whatever its content, makes the compile of src/main.cpp end with an internal compiler error (segmentation fault);
  • the same happens with the unchanged src/cli/cmd_build.cppm plus one import of an existing, unrelated module (import mcpp.build.advice;);
  • removing that one import makes the tree compile again.

The failure follows the number of modules reachable from main.cpp, not the code added, which points at GCC's handling of a large transitive module graph rather than at any construct of ours.

Workaround in mcpp

The target-set code, the leg API and the test archive were placed in existing modules (mcpp.toolchain.triple, mcpp.build.prepare with prepare/legs.cpp as a partition implementation unit, mcpp.build.execute) rather than in new ones, so the module count reachable from main.cpp is unchanged.

To do

Reduce to a self-contained reproducer (a generated chain of N modules imported by one TU) and report it to GCC Bugzilla; record the GCC bug here; remove the placement constraint when a fixed GCC is the toolchain mcpp builds with.

Co-authored-by: speak-agent 248744407+speak-agent@users.noreply.github.com

Activity

  1. added
    upstream-bug根因在上游(编译器/构建工具/依赖),mcpp 只能绕过或声明为缺口
    on Oct 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    upstream-bug根因在上游(编译器/构建工具/依赖),mcpp 只能绕过或声明为缺口

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions