Skip to content

Commit cdf43d3

Browse files
committed
feat: the kernel headers are the kernel-abi layer's, platform keys hold on every row, a row states its interfaces, a generated unit names its origin
- [target.<selector>.layers] kernel-abi takes "xim:linux-headers@<version>" or { path } on a system whose row states how its kernel headers are measured; the headers are decided once after the target side, measured by preprocessing, wired ahead of the base with -isystem, and reported (layers[].version). Without a statement the base's own headers answer, then the toolchain's declaration; the shared view is no longer read or written (mcpp#988). - The project's and the machine's [target.<selector>] layers, tools and link take effect on a row without a platform; carrier there is a warning. - System and target rows state interfaces; cfg(interface = ...) and layers[].interfaces read the provider's list, else the row's, else the system's (mcpp#1005). - mcpp::action::origin() and ide.generated[].origin; a generated unit that declares a module's primary name is its interface (mcpp#1004).
1 parent 53b80e1 commit cdf43d3

57 files changed

Lines changed: 2172 additions & 204 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎.agents/docs/2026-11-22-kernel-interface-and-derived-state-ecosystem-design.md‎

Lines changed: 634 additions & 0 deletions
Large diffs are not rendered by default.

‎.agents/docs/README.md‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ superseded_by: 2026-09-07-....md # when status is superseded
1818
---
1919
```
2020

21-
372 records.
21+
373 records.
2222

2323
## By subject
2424

@@ -60,6 +60,7 @@ Records that declare one. Everything else is listed by date below.
6060

6161
### design
6262

63+
- [生态级方案:内核接口的供给与能力,派生状态的核对,存储的引用](2026-11-22-kernel-interface-and-derived-state-ecosystem-design.md) — active
6364
- [程序起点模型:启动者、两层入口与 `main` 的三种陈述(mcpp#845、mcpp#981)](2026-11-20-program-start-model.md) — landed
6465
- [升级的连续性:打包修订不在使用路径上替换载荷、替换失败不拆掉可用状态、home 中的悬空记录自愈、真实的升级 lane](2026-10-17-upgrade-continuity-design.md) — active
6566
- [一处来源,一种含义:工作空间的传递语义、生成输出、模块角色与首次运行(#786、#785、#778、#790)](2026-10-10-one-source-one-meaning-design.md) — landed
@@ -215,6 +216,7 @@ Records that declare one. Everything else is listed by date below.
215216
### 2026-11
216217

217218
- [测试与 CI 一轮的收尾:平台列未命中的刷新条件(mcpp#996)、`i686-windows-msvc` 行、工作区索引与引号键的迁移、索引的全量验证](2026-11-22-test-round-wrap-up-plan.md) — active
219+
- [生态级方案:内核接口的供给与能力,派生状态的核对,存储的引用](2026-11-22-kernel-interface-and-derived-state-ecosystem-design.md) — active
218220
- [包的特性作为机器可读的回答:一个目录项,两种来源,三种状态(mcpp#992)](2026-11-21-package-features-query-design.md) — active
219221
- [离线、宿主输入与工具链的缺省:按内容取归档的来源、项目的取齐、宿主输入的声明、工具链的解析与锁、缺省版本的规则(mcpp#988、#989、#990)](2026-11-21-offline-host-inputs-and-toolchain-defaults-design.md) — active
220222
- [构建程序的输入由观测给出:编译读到的文件、三道闸门的同一份记录、头文件的用法提示、提示的统一机制、契约中名字的歧义(mcpp#991、#852)](2026-11-21-build-program-observed-inputs-design.md) — active

‎.github/tools/system-names.baseline‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# One number per word: its occurrences in the engine's sources
22
# (.github/tools/check_system_names.py). The numbers only fall.
3-
linux 62
3+
linux 58
44
macos 49
55
windows 70
66
freebsd 1

‎CHANGELOG.md‎

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,49 @@
44
> Each `## [<version>]` section is that release's notes. Entries are written in English
55
> from 2026.9.28.3 on; earlier entries remain as written.
66

7+
## [@RELEASE@] - @DATE@
8+
9+
### Added
10+
11+
- On a Linux row, `[target.<selector>.layers] kernel-abi` states the kernel headers:
12+
`"xim:linux-headers@<version>"` (an ecosystem payload, always with its version) or
13+
`{ path = "<dir>" }` (a header directory without `mcpp.toml`). The statement holds with or
14+
without a platform. Its directories reach every unit and the std module with `-isystem`, ahead
15+
of the base. The headers in effect are measured by preprocessing `<linux/version.h>`, and the
16+
report, `mcpp why toolchain` and `layers[].version` give the version. A stated version the
17+
measurement contradicts is refused (`target-base`). So is a prebuilt form on any other layer,
18+
on a row whose system publishes its kernel interface with its C library (macOS, Windows,
19+
FreeBSD), and a second supplier on an openkal row. Which systems take the form, and how the
20+
version is read, are the system row's data (`kernel-abi`), not the engine's (docs/22)
21+
(mcpp#988).
22+
- A system row and a target row state the interfaces of their kernel-abi layer (`interfaces`):
23+
every openkal interface on Linux, macOS, FreeBSD and Windows, fewer on the iOS rows (no program
24+
start) and on `wasm32-emscripten`. `cfg(interface = "...")` reads the provider's list, else the
25+
row's, else the system's, so it holds on a row without openkal as well. The same list is in
26+
`layers[].interfaces` and `MCPP_KERNEL_ABI_INTERFACES` (mcpp#1005).
27+
- `mcpp::action::origin(path)` names the authored file a generated unit is a transformed copy
28+
of, one of the action's inputs, on a `source` action. The build database gives it as
29+
`ide.generated[].origin`. A generated unit that declares a module's primary name is a
30+
`module-interface`. When the authored file is also among the sources, the duplicate-provider
31+
error names the relation (S1 0.4.0, mcpp#1004).
32+
33+
### Changed
34+
35+
- Without a statement, the kernel headers are the base's own (a stated sysroot, a toolchain's own
36+
sysroot such as `musl-gcc`'s, the host's root), else the version the toolchain's payload
37+
declares. A build under gcc 16.2.0 now compiles against linux-headers 6.18.64, the version it
38+
was built with, instead of the 5.11.1 the home's shared view linked to. The shared view is no
39+
longer read for kernel headers, and mcpp no longer writes kernel headers into it; with neither
40+
answer the build is refused before it compiles and names the statement to write.
41+
42+
### Fixed
43+
44+
- `layers`, `tools` and `link` in a `[target.<selector>]` table of the project or of
45+
`config.toml` were accepted and had no effect on a row without a platform, with no report even
46+
under `--strict`. They now complete the graph and reach the link on every row (docs/35);
47+
`link.flags` that reaches no program says so, and `carrier`, a form of a platform's image, is a
48+
warning there (`platform/carrier`).
49+
750
## [2026.11.22.1] - 2026-11-22
851

952
### Added

‎docs/20-toolchains.md‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -237,8 +237,10 @@ The build installs the package, says `Companion binutils 2.47 (<dir>)`, and
237237
passes its directory to the driver. A binutils older than the one the GCC
238238
payload declares is refused (`companion-too-old`): GCC chose its assembler
239239
features by that binutils when it was built. `companions` names binutils only;
240-
the kernel headers follow the toolchain payload's declaration, since the
241-
default base is the home's sysroot, which every project shares.
240+
the kernel headers are the target's `kernel-abi` layer, stated with
241+
`[target.<selector>.layers] kernel-abi` ([22 — The Target
242+
Side](22-target-side.md)); without a statement, over a base that carries none,
243+
they follow the toolchain payload's declaration (mcpp @RELEASE@+).
242244

243245
## Switching the Default Toolchain
244246

‎docs/22-target-side.md‎

Lines changed: 52 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1207,9 +1207,11 @@ conditions and combinators. mcpp before 2026.11.10.2 reads only `linux`, `macos`
12071207
`accelerator = "none"` is how a section says "this build named no backend"
12081208
without enumerating the ones it is not. `interface` (mcpp 2026.11.13.1) is the kernel-abi
12091209
layer's second answer: an interface its provider states in `[kernel-abi]
1210-
provides-interfaces`, compared by membership as `accelerator` is. A provider
1211-
that states no list provides every interface; a graph without the layer
1212-
provides none. A package selects its sources by what the implementation
1210+
provides-interfaces`, or, where the layer is the system itself, the system
1211+
row's `interfaces` (mcpp @RELEASE@), compared by membership as `accelerator`
1212+
is. A provider or a system that states no list provides every interface; a
1213+
graph without the layer provides none. On `aarch64-ios` the answer for
1214+
`openkal.process` is false: an application of iOS starts no program. A package selects its sources by what the implementation
12131215
beneath it provides, and names no implementation:
12141216
`[target.'cfg(not(interface = "openkal.fs"))'.build] sources = [...]`. Barewords `linux` / `macos` /
12151217
`windows` / `unix` are sugar for the matching `os` / `family` test. A key
@@ -1378,6 +1380,53 @@ this returns. To branch on the resolved layer, use a layer predicate:
13781380
Side](22-target-side.md)). This paragraph said "which C library was resolved"
13791381
until 2026.9.1.1, which was the wrong one of the two.
13801382

1383+
### `layers.kernel-abi` — the kernel headers (mcpp @RELEASE@+)
1384+
1385+
Linux publishes its kernel headers apart from its C library, so on a Linux row
1386+
they are a prebuilt supplier of the `kernel-abi` layer and can be stated:
1387+
1388+
```toml
1389+
[target.x86_64-linux-gnu.layers]
1390+
kernel-abi = "xim:linux-headers@6.18.64" # an ecosystem payload, always with its version
1391+
# kernel-abi = { path = "third_party/uapi" } # or a header directory (no mcpp.toml in it)
1392+
```
1393+
1394+
The statement is read from the project, then this machine's `config.toml`, then
1395+
the platform, key by key; it applies whether or not the row has a platform. With
1396+
no statement, and a C library from a prebuilt base, the build takes the first
1397+
of two answers: the base's own headers (a stated sysroot, a toolchain's own
1398+
sysroot such as `musl-gcc`'s, the host's root), then the version the
1399+
toolchain's payload declares (gcc 16.2.0 declares 6.18.64; the bundled LLVM
1400+
5.11.1). The home's shared view is not an answer: it is shared by toolchains
1401+
that declare different versions. With neither, the build is refused before it
1402+
compiles and names the statement to write.
1403+
`kernel-abi = false` states that the build has no such layer (a freestanding
1404+
arrangement): no headers are decided or measured.
1405+
1406+
The headers in effect are measured, as the C library is: the compiler
1407+
preprocesses a unit that includes `<linux/version.h>` with the build's search
1408+
path, and the report shows the result:
1409+
1410+
```
1411+
Target x86_64-linux-gnu
1412+
kernel-abi linux 6.18.64 (xim:linux-headers@6.18.64, mcpp.toml:10, prebuilt)
1413+
```
1414+
1415+
A stated version that the measurement contradicts is refused. The directories
1416+
are given to every unit and to the std module with `-isystem`, ahead of the
1417+
base; a header the supplier lacks (`<scsi/sg.h>`, which glibc ships) is still
1418+
the base's. A payload that carries each architecture's headers
1419+
(`arch/<arch>/include`, linux-headers 6.18.64 revision 1 and 7.3.5) serves a
1420+
cross build too; one that carries its installing machine's only is refused for
1421+
another architecture, with the remedy.
1422+
1423+
The forms are refused where they do not apply (`target-base`): on macOS,
1424+
Windows and FreeBSD the kernel interface is part of the base (`sysroot`), and no
1425+
other layer takes a prebuilt form. On an openkal row the layer is the openkal
1426+
implementation: a second supplier is refused by rule one. A manifest that uses
1427+
the forms states `[package] mcpp = ">=@RELEASE@"`; an older mcpp ignores the
1428+
key on a row without a platform.
1429+
13811430
### `abi` — a switch the whole artefact shares (mcpp 2026.9.12.2+)
13821431

13831432
```toml

‎docs/30-build-mcpp.md‎

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -871,6 +871,33 @@ relative path among them is relative to `cwd`. A variable's value is part of
871871
the edge's command line, and changing it re-runs the action. An action that
872872
declares neither keeps the protocol 12 command line byte for byte.
873873

874+
#### The authored file of a generated unit: `.origin()` (@RELEASE@+)
875+
876+
An action that writes a transformed copy of a file a person edits (a source
877+
with its imports rewritten, a module unit with a prologue added) names that
878+
file with `.origin(...)`. The file is one of the action's inputs, and the
879+
action's role is `source`:
880+
881+
```cpp
882+
const std::string in = std::string(mcpp::manifest_dir()) + "/templates/core.cppm";
883+
a.role = mcpp::roles::source;
884+
a.arg("rewrite").arg(in.c_str()).arg(out.c_str())
885+
.input(in.c_str())
886+
.origin(in.c_str())
887+
.output(out.c_str())
888+
.provides("app.core")
889+
.submit();
890+
```
891+
892+
The build database states the relation as `ide.generated[].origin`
893+
([50](50-machine-output.md)), so an editor shows the authored file as the
894+
unit's source. The engine does not infer the relation from the inputs. An
895+
`origin` that is not among the inputs, or one stated on an action of another
896+
role, is refused when the build program runs. A unit that declares the primary
897+
name of a module in `.provides(...)` is that module's interface unit. When the
898+
authored file is also listed in `sources`, both provide the module, and the
899+
error that refuses the second provider names this relation.
900+
874901
#### A dependency's program in an action: `${mcpp.artifact:}` (2026.9.27.1+)
875902

876903
A dependency edge with `artifacts = ["<bin>"]` builds that program for the

‎docs/35-platforms.md‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,12 @@ a package of the graph already provides is left to that package and reported
109109
`graph`. The package of the C++ run-time also provides the compiler run-time, so
110110
`"c++-abi" = false` takes effect only with `compiler-runtime = false` beside it.
111111

112+
The tables apply on a row without a platform too (mcpp @RELEASE@): such a row
113+
has an empty platform statement, and `layers`, `tools` and `link` written for
114+
it complete the graph and reach the link as they would over a platform. Before,
115+
they were accepted and had no effect. `carrier` is a form of a platform's image,
116+
so on such a row it is reported as a warning (`platform/carrier`) and not used.
117+
112118
## Selecting a platform, or none
113119

114120
The first of these that answers selects the target's platform:

‎docs/50-machine-output.md‎

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -593,7 +593,7 @@ It resolves and reports; it does not build. `data` is:
593593
| `compiler` | `{family, version, driver, chosenBy}` — the driver that would run, and why |
594594
| `triple` | `{requested, toolchain, llvm}` |
595595
| `cLibrary` | `{mode, path, origin, suppliesTarget}` — `mode` is `sysroot` / `payload-first` / `none`; `origin` is `payload` / `subos` / `host` / `none` |
596-
| `layers[]` | the five target-side layers: `{layer, interface, impl, origin, subset}` |
596+
| `layers[]` | the five target-side layers: `{layer, interface, impl, origin, subset, version, interfaces}`; `version` is the kernel-abi layer's measured version where the system publishes its kernel headers as a package (empty otherwise), `interfaces` the layer's interfaces (`null`: unstated, every one) *(@RELEASE@+)* |
597597

598598
**`compiler.chosenBy` answers "why this one".** `{origin, requiredBy,
599599
replaced}` — `origin` is the same phrase the build's status line uses
@@ -657,7 +657,7 @@ a program classifying the outcome reads `reason`:
657657
| `payload-request` | a build program asked for a payload no manifest of this build declares `provision = "on-request"`, or asked again in three consecutive runs *(2026.10.1.3+)* |
658658
| `lto-export-discovery` | a PE shared library whose exports are discovered would be compiled by cl.exe into `/GL` objects, which hold no symbol table: `windows_auto_export = true` stated under `lto = true`, or `/GL` written into the flags of a package it links *(2026.10.5.2+)* |
659659
| `local-toolchain` | a toolchain named by path, or stated by a build program's toolchain phase, cannot be used: no driver, a contradicting family, a missing tool, or `spec` stated with a key only a toolchain named by path has *(2026.10.1.3+)* |
660-
| `target-base` | the target base (`sysroot`) cannot serve this build: a spelling the row does not take, a path that does not exist, a directory that supplies no C library, a C library older than the compiler's runtime requires, a native base without its loader, or a second C library supplier in the graph *(2026.10.24.1+)* |
660+
| `target-base` | the target base (`sysroot`) cannot serve this build: a spelling the row does not take, a path that does not exist, a directory that supplies no C library, a C library older than the compiler's runtime requires, a native base without its loader, or a second C library supplier in the graph *(2026.10.24.1+)*; the kernel headers: a prebuilt `layers` form on a row or layer that takes none, a payload without the target architecture's headers, no headers to answer the default, or a measurement that contradicts the statement *(@RELEASE@+)* |
661661
| `convention-unreplaced` | the convention was overridden and nothing replaced it |
662662
| `os-mismatch` | the requested and resolved triples name different systems |
663663
| `layer-requirement` | a package requires a layer the resolution did not give it |
@@ -753,6 +753,9 @@ action, so such a file does not exist yet in the directory the document names.
753753
Each entry gives the path a `mcpp build` of the same selection writes
754754
(`build-path`) and the step that writes it, so that an editor can say "generated,
755755
build once" instead of reporting a missing header.
756+
Since @RELEASE@ an entry of `kind` `source` also carries `origin` when its
757+
action states one with `.origin(...)` ([30](30-build-mcpp.md)): the authored
758+
file the generated unit is a transformed copy of (S1 0.4.0 section 7.2).
756759

757760
`emit` plans every selected member on its own (#699 item 1): one member's
758761
planning failure does not cost its siblings'. Outside a project, or when

‎docs/91-toolchain-internals.md‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ resolve toolchain payload ← project/default/install paths share one pip
2727
▼
2828
ensure_declared_runtime() ← exact glibc@version installed; the payload is never written
2929
▼
30-
detect / probe ← triple, sysroot, payload paths (glibc, linux-headers)
30+
detect / probe ← triple, sysroot, payload paths (glibc)
3131
▼
3232
ToolchainLinkModel (single resolver for the C-library axis)
3333
├──► flags.cppm (main build compile/link flags)
@@ -77,7 +77,7 @@ is resolved/auto-installed via the xlings backend into the sandbox
7777
|---|---|
7878
| `targetTriple` | `<compiler> -dumpmachine` |
7979
| `sysroot` | `-print-sysroot` (validated: must actually carry libc headers), with a remap fallback for xlings-built GCC whose baked build-time path doesn't exist locally |
80-
| `payloadPaths` | the resolved runtime binding (§2.1) names the glibc payload exactly; linux-headers is still discovered as a sibling. No binding ⇒ no payload-first, by design |
80+
| `payloadPaths` | the resolved runtime binding (§2.1) names the glibc payload exactly. No binding ⇒ no payload-first, by design. The kernel headers are decided after the target side (`base.kernel`, the kernel-abi layer) and wired ahead of the base in every mode |
8181
| runtime dirs | toolchain-private lib dirs for produced binaries' `-L`/`-rpath` |
8282

8383
Note the probe deliberately does **not** mine the clang cfg for `--sysroot`

0 commit comments

Comments
 (0)