You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit e50177d
Browse filesBrowse the repository at this point in the historyBrowse files
2026.11.26.1: a private fragment after conditions, the purview read as C++ tokens, a tip for the optimization a failure may be (#1014)
Release 2026.11.26.1. Design record: `.agents/docs/2026-11-26-clang-bmi-cutoff-and-private-fragment-refinement-design.md` (v4).
**A private module fragment after conditions (SPEC-019 §5).** `#if`, `#ifdef`, `#ifndef`, `#elif`, `#elifdef`, `#elifndef`, `#else`, `#endif`, `#error` and `#warning` before `module :private;` no longer keep the source from being built as two units: a condition only decides which declarations exist, and the implementation unit receives them from the interface. A condition still open at the module declaration or at the fragment, and any directive that changes the fragment's meaning (`#define`, `#undef`, `#include`, `#pragma`, `#line`, `_Pragma`), leave the source as written. `private_fragment = "conservative"` keeps the rule before this change, and is the check available on GCC.
**The purview is read as C++ tokens.** A digit separator (`1'000`) no longer hides the rest of its line, a raw string may run over lines and hold `module :private;`, a `static` inside `extern "C" { … }` is at namespace scope, and a line continuation between the module declaration and the fragment leaves the source as written. Each only makes more sources built as written.
**A failure says how to check the optimization (SPEC-019 §9).** When a build fails at a step an entry acted on (a source built as two units; a unit that imports a BMI kept with earlier lines; a link where either is present), it ends with a `tip:` giving the one invocation that turns that entry off. The text is made of the register's key, environment name and new `check` value. A failure of another step, a successful build and `--quiet` say nothing.
**Found on the way.** `MCPP_PRIVATE_FRAGMENT`, `MCPP_BMI_SCHEDULE` and `MCPP_BUILDOPT` were not part of the request a recorded build is replayed for: a build with no edit after changing one replayed the graph the other value had written. They are now.
**Not implemented: a reader for clang's `.pcm` (design item A).** Measured with clang 20.1.7, 22.1.8, 23.1.3 and 23.1.6: the operand that holds a function's hash is at an index that varies with the declaration (26, 27 and 29 for member functions of one version) and the version, and a third of the edits change the VBR width of that 32-bit value, which moves the bit offsets and three offset tables. A reader could not tell the field from an interface change, so SPEC-018 §2.2 and SPEC-019 §8 record the measurement and the conditions under which it becomes possible.
**Tests.** `modules/buildopt`: about 55 verdicts of the purview (directives, conditions, lexical forms, `conservative`), a reassembly property, noise invariance, 400 random texts, the tip rules R1 to R4, the register's `check`, the `FAILED:` reader. `tests/e2e/build/basics.cpp` 1161 to 1164: conditions and macros, `conservative` and the first build after a value changes, the tip on clang and GCC with the check taking effect, an unrelated failure and `--quiet` saying nothing, a kept BMI.
**Also on this branch.** The `mingw-cross-wine` job takes Wine from the `wine@11.0` package the engine's runner row names instead of apt (the step exceeded its 20 minutes three times on main on 2026-11-24): it installs the package through xlings, puts its `bin` on `PATH`, drops the i386 architecture and the `wine-debs` cache, and moves the xlings cache key to `v4`.
Two checks of this pull request fail on main as well, without this change (run 45718748639): test 992 (`mcpp pack --target openkal --pkg-format polyglot` reaches its 600 s limit) and `binding-own-home/200` (the runtime binding selects the runner home's glibc). They are not part of this change.
Copy file name to clipboardExpand all lines: docs/26-build-optimizations.md
+41-5Lines changed: 41 additions & 5 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -27,7 +27,7 @@ by default; the others are stated by a parameter.
27
27
|`gcm-locations`| on |`[profile.<name>] bmi_cutoff`, `MCPP_BMI_CUTOFF`| GCC: a BMI whose line maps alone moved is kept; importers name the earlier lines |
28
28
|`scan-pass`| on | — | The scans of a graph run before its compiles, as a pass of their own |
29
29
|`split-schedule`| off |`[build] bmi_schedule`, `MCPP_BMI_SCHEDULE`| Importers start when a BMI exists, not when its compiler exits |
30
-
|`private-fragment`| on |`[build] private_fragment`, `MCPP_PRIVATE_FRAGMENT`| A private module fragment is built as a unit of its own |
30
+
|`private-fragment`| on |`[build] private_fragment` (`unit`, `conservative`, `as-written`), `MCPP_PRIVATE_FRAGMENT`| A private module fragment is built as a unit of its own |
31
31
32
32
`MCPP_BUILDOPT=off mcpp build` is the standard build for one invocation: every entry
33
33
off. An entry with no parameter produces the bytes the standard build produces, so
@@ -68,10 +68,20 @@ links; an edit above it reaches the importers, as it must.
68
68
- GCC does not implement `module :private;`. Built as a unit of its own, the file builds
69
69
with GCC as well.
70
70
- A fragment that reads what is local to the interface's translation unit — a macro
71
-
defined in the module's purview, an unnamed namespace, a `static` at namespace scope,
72
-
a using-directive at namespace scope — is built as written, and `--verbose` says which
73
-
line decided it. With a compiler that builds no fragment as written, that is a warning.
71
+
defined in the module's purview (`#define`, `#undef`, `#include`, `#pragma`, `#line`), an
72
+
unnamed namespace, a `static` at namespace scope (`extern "C" { … }` is namespace scope), a
73
+
using-directive at namespace scope, a line continuation between the module declaration and
74
+
the fragment — is built as written, and `--verbose` says which line decided it. With a
75
+
compiler that builds no fragment as written, that is a warning.
76
+
- A condition (`#if`, `#ifdef`, `#ifndef`, `#elif`, `#else`, `#endif`) and `#error` or
77
+
`#warning` before the fragment do not keep it from being a unit: a condition only decides
78
+
which declarations exist, and the implementation unit receives them from the interface. A
79
+
condition still open at the module declaration or at the fragment does.
80
+
- The text is read as C++ tokens: comments and the contents of string, character and raw
81
+
string literals are not code, and a digit separator (`1'000`) is part of a number.
74
82
- `[build] private_fragment = "as-written"` hands the file to the compiler unchanged.
83
+
`"conservative"` builds the fragment as a unit of its own and refuses any directive in the
84
+
purview, as before conditions were let through; it is the check available on GCC.
75
85
76
86
## The notes of a build
77
87
@@ -86,6 +96,32 @@ The note is given when the rebuild started at a module of one file with at least
86
96
importing units, once a build directory. Beside it, a build that replaced or kept BMIs
87
97
states which ([04](04-mcpp-toml.md), `bmi_cutoff`).
88
98
99
+
## Checking whether an optimization is the cause
100
+
101
+
Every entry is on because most projects build the same with it and sooner. When a build
102
+
fails at a step an entry acted on, it ends with a `tip:` that names the entry and the one
103
+
invocation that checks it:
104
+
105
+
```
106
+
tip: src/c.cppm was built as two units (private-fragment), and one of them failed.
107
+
To check whether that is the cause: MCPP_PRIVATE_FRAGMENT=as-written mcpp build ([build] private_fragment = "as-written" keeps it)
108
+
If it builds, report the file; MCPP_BUILDOPT=off turns every optimization off for one run.
109
+
```
110
+
111
+
The tip is given for the step that failed, so a failure of another file says nothing. The
112
+
ladder is the same for every entry:
113
+
114
+
1. Turn off the one entry for one invocation: `MCPP_PRIVATE_FRAGMENT=as-written mcpp build`
115
+
(`conservative` on GCC), `MCPP_BMI_CUTOFF=exact mcpp build` (it removes the BMIs kept with
116
+
earlier lines first, so the products are those of a build from nothing).
117
+
2. Turn off every entry: `MCPP_BUILDOPT=off mcpp build`.
118
+
3. A failure that remains after both is not an entry's. A failure that goes with one is worth
119
+
a report naming the file, and the manifest keys above keep the statement.
120
+
121
+
Three tips exist: a source built as two units that failed, a unit that imports a BMI kept
122
+
with earlier lines that failed, and a failed link where either is in the graph (which cannot
123
+
say which unit). A test program that fails when it runs gives none.
124
+
89
125
## What the home's cache places (2026.11.21.1+)
90
126
91
127
Beside the entries, the home's build cache (`build-cache/v1/`, [25](25-home-indices-and-store.md))
@@ -125,7 +161,7 @@ run for a minute is named once on a `Running` line, with the package and source
0 commit comments