Skip to content

build.mcpp is not recompiled when a header it includes by a quoted path changes #991

Closed

Description

@dreamyloong2005

Version: mcpp 2026.11.20.1. Windows 11 x64 (msvc@system, MSVC 19.44.35230)
and Linux x86_64 (mcpp's default gcc@16.1.0).

What happens

A build.mcpp that includes a header of its own package by a quoted path is
compiled once. When that header changes, mcpp build / mcpp run keep the old
program and its directives; the package is configured from stale output with no
notice. docs/30 lists what a program's identity covers ("the engine version, the
host toolchain, the standard, the program's text, and every package of its
graph"); a file the program's translation unit includes from its own package
tree is not among them.

Reproduce

# mcpp.toml
[package]
name = "repro"
version = "0.1.0"
standard = "c++23"

[toolchain]
windows = "msvc@system"
// build.mcpp
#include "support/emit.hpp"
int main() { emit(); }

// support/emit.hpp
#pragma once
#include <cstdio>
inline void emit() { std::puts("mcpp:cfg=REPRO_VALUE=\"one\""); }

// src/main.cpp
#include <cstdio>
int main() { std::puts(REPRO_VALUE); }
  1. mcpp run prints one.
  2. In support/emit.hpp, change one to two.
  3. mcpp run prints one again. Expected: two.

Further edits to the header (three, four, ...) keep printing the first value.
Deleting target/.build-mcpp alone does not help: the old result comes back
(from the build cache, as far as I can tell). Deleting all of target/ does: the
next run prints the current value. Same on Windows and Linux.

Expected

Either track the build program's include dependencies (the depfile /
/sourceDependencies record the main build already reads) as part of its
identity, or warn when a quoted include resolves to a file outside the
program's graph, pointing at [build-dependencies].

Workaround

Put the header in a header-only path package and name it in
[build-dependencies]. A path package's content is part of the program's
identity, so an edit recompiles and reruns the program.

Activity

  1. Sunrisepeak commented on Nov 21, 2026

    @Sunrisepeak
    Member

    xlings update mcpp -y to verify

  2. speak-agent commented on Nov 22, 2026

    @speak-agent
    Member

    Released in mcpp 2026.11.21.1 (#984): the files a build program's compile reads are observed from the sub-build's dependency records, recorded with the program and compared by size and time, then content. An edit of a header the program includes by a quoted path compiles and runs it again, also after target/.build-mcpp is deleted; a declared input (rerun_if_changed) is compared the same way.

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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions