Repository navigation
Description
mcpp 2026.11.27.1, Linux x86_64.
A [toolchain] entry in table form states more than a directory: family, prefix, sysroot, launcher and tools. The project's own units are compiled as the table states. The build programs (build.mcpp and the packages of [build-dependencies]) are compiled by a sub-build that is told path:<dir> and nothing else, so every other field of the table is absent there and the directory's layout answers instead.
Reproduce
/opt/gcc-16 is any GCC tree (here the 16.1.0 payload, named by its path). The two scripts record their arguments and run what they are given.
# mcpp.toml
[package]
name = "tcrepro"
version = "0.1.0"
[targets.tcrepro]
kind = "bin"
main = "src/main.cpp"
[toolchain.linux]
path = "/opt/gcc-16"
family = "gcc"
launcher = "/opt/tools/launcher.sh"
tools = { cxx = "/opt/tools/cxx.sh" }# /opt/tools/cxx.sh
#!/bin/sh
echo "cxx-wrapper: $*" >> /tmp/tc.log
exec /opt/gcc-16/bin/g++ "$@"
# /opt/tools/launcher.sh
#!/bin/sh
echo "launcher: $*" >> /tmp/tc.log
exec "$@"build.mcpp and src/main.cpp are int main() { return 0; }.
$ mcpp build -v
build.mcpp tcrepro compiled 0.46s · ran 0.00s
[1/2] … -- /opt/tools/launcher.sh /opt/tools/cxx.sh -std=c++23 … -c src/main.cpp -o obj/main.o
[2/2] … -- /opt/tools/launcher.sh /opt/tools/cxx.sh @bin/tcrepro.rsp -o bin/tcrepro …
$ grep -c 'build.mcpp' /tmp/tc.log
0
$ cat target/.build-mcpp/host/<id>/.mcpp-build-programs
toolchain=path:/opt/gcc-16
profile=build-program
$ grep -E '^(cxx|cc) ' target/.build-mcpp/host/<id>/target/x86_64-linux-gnu/<hash>/build.ninja
cxx = /opt/gcc-16/bin/g++
cc = /opt/gcc-16/bin/gcc
src/main.cpp is compiled and linked through the launcher and the stated driver; build.mcpp is compiled by <path>/bin/g++ with neither. The workspace written for the build programs has no [workspace.toolchain].
Cause
src/build/prepare/host_graph.cpp: the sub-build's request carries the toolchain as one string,sub.toolchain = tc.spec, and for a table that string ispath:<dir>(modules/manifest/src/types.cppm: "the table is recorded there aspath:<dir>… and this record carries the rest").src/build/prepare/local_toolchain.cpp(step1_local_toolchain): a spec handed in by a consumer (tcFromConsumer) reads no table,lt.path = state.tcSpec->substr(5), and the record starts empty.
What each absent field changes for a build program
| field | in the project's build | in the build programs' sub-build |
|---|---|---|
tools.cxx, launcher |
used (measured above) | <path>/bin/<driver>, no launcher (measured above) |
family |
as stated | read from the drivers present in <path>/bin; a tree that holds both g++ and clang++ can compile the two with different compilers (read from the code) |
sysroot |
--sysroot for the compile and the link |
none: the build program is compiled against, and linked with, another C library than the project (read from the code) |
prefix |
<prefix><driver> |
<driver> (read from the code) |
tools.ld on a clang tree |
reaches the link as --ld-path |
absent, so the link names -fuse-ld=lld, which a tree without lld does not have (read from the code) |
tools.ar and the other roles |
as stated | the layout's lookup (read from the code) |
A project can work around it only by putting a directory of wrapper drivers in its own tree and naming that directory as path, so that the one field the sub-build receives carries what the others said.
Expected
docs/20 states that with no bootstrap "a native build uses its own toolchain" for its build programs. The build programs of a native build are compiled with the toolchain the project states, the whole table; a project that wants another one states bootstrap. The sub-build's identity (host_toolchain) includes the fields, so a change of one of them rebuilds the programs.
No e2e case builds a build program under a table-form toolchain (804 covers a path host tool, 901 the library path of the tools); the tree of a runner ({ path = "/usr", family = "gcc", sysroot = "/" }) with a build.mcpp would hold it.
Activity