Skip to content

Commit d1911bb

Browse files
committed
docs(bench): section 9 covers bench/projects/mcpp and the two cmake traps
1 parent d727a08 commit d1911bb

1 file changed

Lines changed: 50 additions & 8 deletions

File tree

bench/README.md

Lines changed: 50 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -406,20 +406,62 @@ the original analysis:
406406
407407
---
408408

409-
## 9. The `xmake.lua` at the repository root
409+
## 9. Building mcpp itself — `bench/projects/mcpp/`
410410

411-
Separate from the generated fixtures, the repo root carries an `xmake.lua` that
412-
builds **mcpp itself** — the control arm for "same real project, different
413-
engine". Synthetic fixtures cannot reproduce the dependency shape of a real
414-
137-module codebase, so both exist.
411+
Separate from the generated fixtures, `bench/projects/mcpp/` carries one build
412+
description per foreign engine for **mcpp itself** — the control arm for "same
413+
real project, different engine". Synthetic fixtures cannot reproduce the
414+
dependency shape of a real 138-module codebase, and the difference is not small:
415+
on the fixture mcpp's module cold build is 0.26x cmake, on mcpp's own source it
416+
is **0.85x**. Both arms exist because either alone misleads.
415417

416-
It pins the compiler by reading `[toolchain] default` out of `mcpp.toml`, because
418+
```bash
419+
bench --project . --buildfiles bench/projects/mcpp \
420+
--engines mcpp=<old>,mcpp=<new>,cmake,xmake \
421+
--compiler <path to g++> --baseline cmake \
422+
--hub src/platform/platform.cppm \
423+
--leaf src/version.cppm \
424+
--body src/build/stage.cppm
425+
```
426+
427+
`--buildfiles` is what keeps these files **out of the repository root**. mcpp is
428+
built by mcpp; a CMakeLists.txt and an xmake.lua at the root are files every
429+
contributor has to learn to ignore, and one of them actively broke something:
430+
`scripts/bootstrap-macos.sh` generates its own root `xmake.lua` when none is
431+
present, and a bench-owned file at that path silently pre-empted it. cmake is
432+
pointed at the directory with `-S`, xmake with `-P`; mcpp reads the project's
433+
own manifest and ignores the flag. Copying the descriptions into the tree for
434+
the duration of a run was the alternative, and it writes into the user's
435+
repository, which this harness refuses to do.
436+
437+
| engine | builds mcpp? |
438+
|---|---|
439+
| mcpp | yes — it is mcpp's own manifest |
440+
| cmake 4.0.2 | yes — needs `CMAKE_CXX_MODULE_STD 1` and the CMake-4.0 experimental UUID |
441+
| xmake 3.0.7 | yes |
442+
| meson 1.10.2 | no — no way to declare an interface unit, and no `import std;` |
443+
| bazel 9.2.0 | not in the gcc table. `import std;` **is** buildable (libc++ ships the std module as ordinary source — see `bench/projects/mcpp/MODULE.bazel` for the working recipe), but bazel's modules need clang, so a bazel column belongs in a clang-baselined table or it breaks invariant I1 |
444+
445+
### The cmake description has two traps worth knowing
446+
447+
* **`FILE_SET CXX_MODULES` requires every file under a base directory.** The
448+
`mcpplibs.cmdline` dependency lives in the registry, outside the tree, so it
449+
needs its own file set with an explicit `BASE_DIRS`.
450+
* **`add_compile_options()` does not reach the `std` module.** CMake generates
451+
that target itself, so directory-scope options miss it: the std module then
452+
compiles against the compiler's default libc headers while every mcpp unit
453+
compiles against `--sysroot`, and the build dies on a type that exists in both
454+
(`conflicting type for imported declaration 'char _IO_FILE::_unused2 [20]'`).
455+
The error names neither the flag nor the target that is wrong. Use
456+
`CMAKE_CXX_FLAGS`.
457+
458+
The xmake description pins the compiler by reading `[toolchain] default` out of `mcpp.toml`, because
417459
the registry holds several GCCs and "newest directory wins" only *happens* to
418460
agree with the pin. Verify before quoting anything from it:
419461

420462
```bash
421-
xmake f -y -m release --toolchain=mcpp-gcc
422-
xmake show -t mcpp | grep 'compiler (cxx)' # must be the same binary mcpp uses
463+
xmake f -P bench/projects/mcpp -y -m release --toolchain=mcpp-gcc
464+
xmake show -P bench/projects/mcpp -t mcpp | grep 'compiler (cxx)' # must be mcpp's binary
423465
```
424466

425467
> An earlier revision called `set_toolchains()` unconditionally, which silently

0 commit comments

Comments
 (0)