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 cfba005
Browse filesBrowse the repository at this point in the historyBrowse files
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