https://gcc.gnu.org/bugzilla/show_bug.cgi?id=122614

            Bug ID: 122614
           Summary: Dependency file created when using import std causes
                    full rebuilds even if nothing has changed
           Product: gcc
           Version: 15.2.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: jussi.pakkanen at mailbox dot org
  Target Milestone: ---

Take this source file:

import std;

int main() {
    std::println("Hello");
    return 0;
}

compile it with the following two commands:

g++ -std=c++23 -c -fmodules -fmodule-only -fsearch-include-path bits/std.cc
g++ -std=c++23 -fmodules standalone.cpp -o standalone -MD -MF standalone.deps

The output of the deps file looks like this:

standalone: standalone.cpp /usr/include/stdc-predef.h gcm.cache/std.gcm
standalone: std.c++-module
CXX_IMPORTS += std.c++-module

This dependency file specifies that `standalone` depends on a file called
`std.c++-module`. As such a file does not exist, the dependency is always out
of date and thus running `ninja` will always rebuild the std module and by
extension every source file that uses `import std`. Effectively this causes a
full rebuild every time, even when nothing has changed.

To fix this the output file should not contain the line `standalone:
std.c++-module`.
  • [Bug c++/122614] New: Depen... jussi.pakkanen at mailbox dot org via Gcc-bugs

Reply via email to