Repository navigation
Description
Two items found while working in several checkouts (git worktrees) of one workspace, with mcpp 2026.11.26.1 (GCC 16.1.0, Linux x86_64). Both are reproduced below in scratch projects.
1. A cache entry shared by two checkouts is removed when one of them is edited — also under the other's running build
What happened
A whole-workspace run (mcpp test --workspace --profile ci) in checkout mui-verify lost 17 members on one run and 20 on another, part-way through, with:
ninja: error: '~/.mcpp/build-cache/v1/tool/omui/gen@0.1.0+path.0e1f74030cd3f3dc/595e8de74d69067a/bin/omui-gen',
needed by '…/mui-verify/target/.build-mcpp/out/ddaf0e16b54c80e8/omui.theme/openmui/retro_style.cppm',
missing and no known rule to make it
Nothing in mui-verify changed during the run. In another checkout of the same commit (mui), a source of the host tool (omui.gen, a path package) was edited and a build was run.
Cause, as the source reads
tool_store::write_entry (mcpp#874) and replace_tree_siblings in dependency_cache.cpp (mcpp#974) write the tree an entry was built from beside it (source) and, when that tree is built under another stamp, remove the entry of the earlier stamp. The stamp is the tree's content, so two checkouts with the same content share one entry — but source names only the one that wrote it. When the writer is edited, the entry goes, though the other checkout still uses it: its plan names the entry's files (the tool's bin/, a dependency's obj/), and a build that is running fails at the next edge that needs them.
Reproduction (a host tool)
R=/tmp/repro; mkdir -p $R/a/tool/src $R/a/app/src; cd $R/a
cat > tool/mcpp.toml <<'EOF'
[package]
name = "sharedgen"
version = "0.1.0"
[targets.gen]
kind = "bin"
main = "src/gen.cpp"
EOF
cat > tool/src/gen.cpp <<'EOF'
#include <cstdio>
int main(int argc, char** argv) {
if (argc < 2) return 2;
FILE* f = std::fopen(argv[1], "w");
if (!f) return 3;
std::fprintf(f, "int app_extra() { return 1; }\n");
return std::fclose(f);
}
EOF
cat > app/mcpp.toml <<'EOF'
[package]
name = "app"
version = "0.1.0"
[targets.main]
kind = "bin"
main = "src/main.cpp"
[build-dependencies]
sharedgen = { path = "../tool", tools = ["gen"] }
EOF
cat > app/src/main.cpp <<'EOF'
#include <cstdio>
int app_extra();
int main() { std::printf("%d\n", app_extra()); }
EOF
cat > app/build.mcpp <<'EOF'
#include <string>
import mcpp;
int main() {
const std::string out = std::string(mcpp::out_dir()) + "/extra.cpp";
mcpp::action made;
made.id = "gen:extra";
made.role = mcpp::roles::source;
made.arg(mcpp::dep_bin("sharedgen", "gen")).arg(out.c_str()).output(out.c_str()).submit();
}
EOF
cp -r $R/a $R/b # a second checkout, the same content
(cd $R/a/app && mcpp build) # 1
(cd $R/b/app && mcpp build) # 2
sed -i 's/return 1; }\\n/return 2; }\\n/' $R/a/tool/src/gen.cpp
(cd $R/a/app && mcpp build) # 3| After | ~/.mcpp/build-cache/v1/tool/mcpplibs/ |
source |
|---|---|---|
| 1 | sharedgen@0.1.0+path.697a649431c2bebc/9a402ce0938235a5 |
…/a/tool |
| 2 | the same entry; b's build.ninja names its bin/gen |
…/a/tool |
| 3 | sharedgen@0.1.0+path.73e509bcaad08ebc/10ebf5f502c6f4ce only |
…/a/tool |
After 3 the file b's plan names does not exist. A later mcpp build in b plans again and builds the tool again (the entry then says source = …/b/tool); a build of b that was running during 3 fails as above.
A path dependency behaves the same (a library dep1025 in place of the tool, [dependencies] dep1025 = { path = "../dep1025" }): after step 3, pkg/mcpplibs/dep1025@0.1.0+path.13edae69a37ad87d/b428f2ba71e1889c/obj/src/dep.o, which b's build.ninja names, is gone.
--cache local does not keep a host tool out of the shared store: b built with --cache local still names ~/.mcpp/build-cache/v1/tool/…/bin/gen, so it is no way round for the tool.
Expected
An entry that another tree uses is not removed by an edit elsewhere, and never under a running build. Possible forms:
sourceholds every tree that used the entry (a hit adds its tree); an edit of one tree removes its own name, and the entry goes when no name is left (the last-use collection stays as it is);- or a build holds the entries its plan names (a lock or a use record that
write_entryandreplace_tree_siblingsrespect), so a superseded entry is removed only when no build is using it.
2. A profile's cflags and cxxflags reach the units of root packages only
opt reaches every unit of the graph; the profile's cflags/cxxflags reach a package only when it is a root of the build. A member or path dependency compiled as a dependency of the selection does not get them, so one unit is compiled two ways under one profile, by what was selected.
R=/tmp/repro2; mkdir -p $R/lib/src $R/app/src; cd $R
cat > mcpp.toml <<'EOF'
[workspace]
members = ["lib", "app"]
[workspace.profile.small]
opt = "z"
debug = false
cxxflags = ["-DPROFILE_WORD=1", "-fno-asynchronous-unwind-tables"]
EOF
printf '[package]\nname = "lib"\nversion = "0.1.0"\n[targets.lib]\nkind = "lib"\n' > lib/mcpp.toml
echo 'int lib_value() { return 41; }' > lib/src/lib.cpp
printf '[package]\nname = "app"\nversion = "0.1.0"\n[targets.main]\nkind = "bin"\nmain = "src/main.cpp"\n[dependencies]\nlib = { path = "../lib" }\n' > app/mcpp.toml
printf '#include <cstdio>\nint lib_value();\nint main() { std::printf("%%d\\n", lib_value()); }\n' > app/src/main.cpp
mcpp build -p app --profile small # then read compile_commands.json
mcpp build --workspace --profile small # and again| Selection | app/src/main.cpp |
lib/src/lib.cpp |
|---|---|---|
-p app --profile small |
-Oz, -DPROFILE_WORD=1, -fno-asynchronous-unwind-tables |
-Oz only |
--workspace --profile small |
all three | all three |
Where it matters:
- a size profile:
-fno-asynchronous-unwind-tables,-ffunction-sectionsand the like have their effect only over the whole graph; with-p <program>they reach the program's own units; - a sanitizer profile (
cxxflags = ["-fsanitize=address,undefined", …]):--workspaceinstruments every member,-p <member>instruments that member's units and none of the members below it.
docs/04-mcpp-toml.md §2.9 calls the three lists a passthrough and gives their order on a command, and says ndebug is "for every unit of the graph"; it does not say which units the lists reach. docs/07-workspace.md says a profile is one value per graph.
Asked for: a profile's cflags/cxxflags reach every unit of the graph (as opt, debug and ndebug do, and as the profile's ldflags reach every image, SPEC-004 §9 item 11) — or, if the scope is meant, a key of the profile that states graph-wide words, and the scope written in §2.9.
Activity
speak-agent commentedon Nov 26, 2026
3.
mcpp testended with SIGSEGV while planning a member (seen once)mcpp 2026.11.26.1 (the released binary, stripped), Linux x86_64, GCC 16.1.0. One run of
in a workspace of 166 members ended, after the first two members were built, while it was planning the third:
The same command run again at once passed (five members, all tests), and it has not happened in the runs since. At that moment two other checkouts of the workspace were building too (each under its own
mcpp), and the member being planned is thepathhost tool of item 1 — so an entry of the shared cache removed between two reads is a candidate, not established. The fault address (0x2e) reads as a member of a null object; the frame ismcpp+0x34e314of the 2026.11.26.1 release for whoever has its symbols.speak-agent commentedon Nov 26, 2026
A fourth item, from the macOS row of the same project (run https://github.com/Sunrisepeak/mui/actions/runs/45883884764, mcpp 2026.11.26.1, llvm@23.1.3, macos-15 arm64).
4.
cxx_runtime = "host-coupled"on macOS with mcpp's llvm: compiled against the toolchain's libc++ headers, linked against the system's libc++ — undefined symbolsTwo members state
[build] cxx_runtime = "host-coupled"(a size fixture whose budget counts on the system's C++ runtime on Linux). On Linux they build and run. On macOSmcpp build --workspacefails at their link:These are symbols of libc++ 23's dylib that macOS 15's
/usr/lib/libc++.1.dylibdoes not have: the units are compiled with the toolchain's headers (which declare them as in the dylib) and the link takes the system's library. A third member of the same build (toolchain-coupled, which this row resolves to host-coupled with the warningthis toolchain ships no libc++.a/libc++abi.a; using host-coupled) links, because it happens to use none of those symbols — so the same fall-back is onestd::hash/from_chars/atomic::waitaway from the same failure.What makes it hard to work around in a manifest: the contract's three values are valid on every platform and the key has no scope by target (docs/20, by design),
[package] platformsis a hint and skips nothing, andmcpp buildhas no flag for the contract. A package that means "the system's runtime, where the system's toolchain is the one building" cannot say so only for Linux.Any one of these would resolve it:
host-coupledon an Apple target, compile with libc++'s availability annotations for the deployment target (so the headers use only what that system's dylib has, inline otherwise), or against the SDK's libc++ headers;toolchain-coupleda toolset cannot deliver is refused), instead of failing at the last link after a 25-minute build;[target.'cfg(…)'.build]), if the first two are not wanted.speak-agent commentedon Nov 27, 2026
Fixed in mcpp 2026.11.27.1 (#1023). Cache and tool-store entries record the trees that use them (
users/). An edit of one checkout withdraws only that tree, on a write or on a hit, and an entry no tree uses is removed. Item 2:[profile.<name>] dialect_cxxflags; SPEC-004 §9 states a profile's scope, and unknown profile keys are reported.