Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
03c2c3e
e2e graph/834 runs in a home of its own: a replay holds only while no…
Sunrisepeak Dec 6, 2026
91049e9
Design: the uses of a path, one table of roots, and tools named by th…
Sunrisepeak Dec 6, 2026
ea95be9
The path module answers each use of a path: an address, a key, an obj…
Sunrisepeak Dec 6, 2026
735d80f
Every resolution of a path to its physical spelling moves to the path…
Sunrisepeak Dec 6, 2026
0c9d130
SPEC-020 states the uses of a path; docs/25 and docs/05 describe ever…
Sunrisepeak Dec 6, 2026
13cfc24
The roots of a build are one table: the trim_paths map and the link's…
Sunrisepeak Dec 6, 2026
be42c7f
Every build a command runs follows the command's verbosity; a build p…
Sunrisepeak Dec 6, 2026
a2619f4
The documentation indices list SPEC-020, and SPEC-020 keeps a change …
Sunrisepeak Dec 6, 2026
0ba5b1b
A clang tree's linker is one fact named by its address, handed to the…
Sunrisepeak Dec 6, 2026
f1016e4
Every clang driver mcpp starts sees itself by the path it was started…
Sunrisepeak Dec 6, 2026
5b36f47
On the MSVC ABI, -nostdlib in [build] ldflags is noted once: each obj…
Sunrisepeak Dec 6, 2026
a2371ea
The test kit gives a directory a second spelling and reads a compile …
Sunrisepeak Dec 6, 2026
4725ed2
SPEC-006 §3.12 states the linker named by its address; SPEC-020 §9, d…
Sunrisepeak Dec 6, 2026
32ce837
2026.12.7.1: the uses of a path, one table of roots, and tools named …
Sunrisepeak Dec 6, 2026
86e71dd
A directory's address carries no trailing separator; the root of the …
Sunrisepeak Dec 6, 2026
25c9262
SPEC-020 states that a directory's address has no trailing separator …
Sunrisepeak Dec 6, 2026
a1002e9
A drive alias is asked through the entry beneath its root, since a ro…
Sunrisepeak Dec 6, 2026
a9914b1
SPEC-020 §6 states that a volume's root is asked through the entry be…
Sunrisepeak Dec 6, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
397 changes: 397 additions & 0 deletions .agents/docs/2026-12-07-path-uses-roots-and-tool-addresses-design.md

Large diffs are not rendered by default.

4 changes: 3 additions & 1 deletion .agents/docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ superseded_by: 2026-09-07-....md # when status is superseded
---
```

377 records.
378 records.

## By subject

Expand Down Expand Up @@ -61,6 +61,7 @@ Records that declare one. Everything else is listed by date below.

### design

- [路径的四种用途、根目录表与工具的地址:受限视图下的一致性](2026-12-07-path-uses-roots-and-tool-addresses-design.md) — active
- [陈述的闭包、单一读者与六项功能:十四项缺陷的收敛设计](2026-11-27-stated-closure-single-reader-and-feature-designs.md) — landed
- [生态级方案:内核接口的供给与能力,派生状态的核对,存储的引用](2026-11-22-kernel-interface-and-derived-state-ecosystem-design.md) — active
- [程序起点模型:启动者、两层入口与 `main` 的三种陈述(mcpp#845、mcpp#981)](2026-11-20-program-start-model.md) — landed
Expand Down Expand Up @@ -219,6 +220,7 @@ Records that declare one. Everything else is listed by date below.

### 2026-12

- [路径的四种用途、根目录表与工具的地址:受限视图下的一致性](2026-12-07-path-uses-roots-and-tool-addresses-design.md) — active
- [命令行表面的两种读者:帮助与固定输出的版式和样式、包的种类与信息、包自带的 agent 说明](2026-12-06-cli-surface-people-and-agents-design.md) — active
### 2026-11

Expand Down
17 changes: 17 additions & 0 deletions .agents/skills/mcpp-contributing/SKILL.md
Original file line number Diff line number Diff line change
Expand Up @@ -366,6 +366,23 @@ Windows 上 `std::filesystem::path::string()` 会把 native(宽)名经**进
UTF-8 ACP(65001),这类用例会静默变成永远绿的装饰品。参见
`tests/unit/test_modgraph.cpp` 的 `Scanner.GlobWalkSurvivesNamesTheCodePageCannotSpell`。

## 路径的用途(SPEC-020)

写下一个路径的用法之前,先判定它属于哪一种用途,再用 `mcpp.libs.path_identity` 中对应的函数;规则本身见
[SPEC-020](../../../docs/specs/paths.md),此处只列判断的步骤。

1. 打开它、交给程序、写进记录:地址,`given(p)`。
2. 作为缓存条目或记录中的键:`key(p)`。
3. 问两个路径是否同一对象、一个对象是否在某目录下:`same`、`within`、`beneath`;问一个**名字**是否在某目录下
(不问对象):`mcpplibs::os::fs::within`。
4. 遍历时去环、去重:`object(p)` 作集合的键;内存中以路径为键的映射:`resolved(p)`。
5. 要的是链接指向的文件(soname 链、加载器):`resolved(p)`。
6. 只为在诊断中给出物理路径:`describe(p)`。

`canonical` 与 `weakly_canonical`(`std::filesystem` 与 mcpplibs.os)只出现在路径模块中:
`.github/tools/check_path_identity.sh` 在其他位置为零,没有基线。clang 驱动的每条命令带上
`driver_self_words(tc)`(`-no-canonical-prefixes`);新增一处探测时一并加上。

## 注意事项

- C++23 模块项目,修改模块时注意 import 依赖顺序
Expand Down
45 changes: 16 additions & 29 deletions .github/tools/check_path_identity.sh
Original file line number Diff line number Diff line change
@@ -1,35 +1,22 @@
#!/usr/bin/env bash
# The resolutions of a path to its canonical form only fall (design 2026-11-27 §4.6, mcpp#1024).
# No path is resolved to its canonical form outside mcpp.libs.path_identity (SPEC-020).
#
# A path the user or the environment gives is opened and handed to a program as it is spelled; its
# canonical form is an identity, asked of mcpp.libs.path_identity, which reports when it cannot be
# read. Each file's count of `canonical(` and `weakly_canonical(` called on std::filesystem is at
# most its line in path-identity.baseline; a file not listed has none. A line falls as its calls
# move to the identity module (an identity) or to the given spelling (an address).
# A path the user, the environment or the system gives is an address, opened and handed to a
# program as it is spelled; whether two paths name one object is answered by the path package
# (`same`, `within`, `beneath`, `object`), and a path whose links are to be followed is its
# `resolved` form. The physical spelling serves none of these uses: a call of `canonical(` or
# `weakly_canonical(` on std::filesystem or on mcpplibs.os's fs anywhere else is an error.
set -u
cd "$(dirname "$0")/../.."

baseline=.github/tools/path-identity.baseline
[ -f "$baseline" ] || { echo "::error::missing $baseline"; exit 1; }
found=$(grep -rnE '(filesystem|fs)::(weakly_)?canonical\(' src modules \
--include='*.cpp' --include='*.cppm' 2>/dev/null \
| grep -v '^modules/libs/src/path_identity.cppm:' | grep -v '/tests/')

current=$(grep -rcE '(filesystem|fs)::(weakly_)?canonical\(' src modules \
--include='*.cpp' --include='*.cppm' 2>/dev/null \
| grep -v ':0$' | grep -v '^modules/libs/src/path_identity.cppm:' | grep -v '/tests/' \
| sed 's/:/ /' | sort)

rc=0
while read -r file n; do
[ -n "$file" ] || continue
allowed=$(awk -v f="$file" '$1 == f { print $2 }' "$baseline")
if [ -z "$allowed" ]; then
echo "::error::$file resolves a path to its canonical form $n time(s); ask mcpp.libs.path_identity, or open the given spelling"
rc=1
elif [ "$n" -gt "$allowed" ]; then
echo "::error::$file resolves a path to its canonical form $n times, more than the $allowed of $baseline"
rc=1
elif [ "$n" -lt "$allowed" ]; then
echo "note: $file resolves $n times, fewer than the $allowed of $baseline; lower its line"
fi
done <<< "$current"
[ "$rc" = 0 ] && echo "OK: no file resolves a path to its canonical form more often than $baseline states"
exit "$rc"
if [ -n "$found" ]; then
echo "::error::a path is resolved to its canonical form outside mcpp.libs.path_identity:"
echo "$found"
echo "an address is given(p); an object is same/within/beneath/object; links are followed by resolved(p)"
exit 1
fi
echo "OK: no path is resolved to its canonical form outside mcpp.libs.path_identity"
30 changes: 0 additions & 30 deletions .github/tools/path-identity.baseline

This file was deleted.

5 changes: 4 additions & 1 deletion AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ linked document holds.
| Tree | States | Rule |
|---|---|---|
| [`docs/`](docs/README.md), [`docs/zh/`](docs/zh/README.md) | how to use what mcpp implements | describes the current implementation only; English and Chinese stay in parity |
| [`docs/specs/`](docs/specs/README.md) | semantics and constraints (SPEC-001 to SPEC-016) | RFC 2119 wording; every clause carries its implementation status and the version it holds from |
| [`docs/specs/`](docs/specs/README.md) | semantics and constraints (SPEC-001 to SPEC-020) | RFC 2119 wording; every clause carries its implementation status and the version it holds from |
| [`.agents/docs/`](.agents/docs/README.md) | design records: measurements, decisions, what was refuted | front matter `subject`, `status`; the index is generated (`.github/tools/gen_agents_index.py`) |
| [`.agents/skills/`](.agents/skills/) | procedures: [contributing](.agents/skills/mcpp-contributing/SKILL.md), [docs style](.agents/skills/mcpp-docs-style/SKILL.md), [release](.agents/skills/mcpp-release/SKILL.md), [usage](.agents/skills/mcpp-usage/SKILL.md) (a pointer to [`docs/mcpp-skills/`](docs/mcpp-skills/mcpp/SKILL.md), the sheets `--agent-skill-doc` prints) | ordered steps with criteria |
| [`CHANGELOG.md`](CHANGELOG.md) | one section per release; release.yml publishes it as the release notes | English, Keep a Changelog |
Expand Down Expand Up @@ -69,6 +69,9 @@ CHANGELOG in the same pull request.
- A comment states why, from what was measured, not what the next line does.
- A path from a directory walk is never narrowed with `.string()`: compare as `path`, hash
`u8string()`, hand to tools through `try_narrow` ([contributing](.agents/skills/mcpp-contributing/SKILL.md)).
- A path is opened and handed on under the spelling it was given; whether two paths are one
object, and links followed, are asked of `mcpp.libs.path_identity`, and a physical spelling
is printed in a diagnostic only ([SPEC-020](docs/specs/paths.md); `check_path_identity.sh`).

## 5. Build and test

Expand Down
42 changes: 41 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,53 @@
> Each `## [<version>]` section is that release's notes. Entries are written in English
> from 2026.9.28.3 on; earlier entries remain as written.

## [Unreleased]
## [2026.12.7.1] - 2026-12-07

### Changed

- A path the user, the environment or the system gives is kept in the spelling it was given: an
address is made absolute and lexically normal, and no link or drive alias along it is resolved.
Whether two paths are one object is answered by their spellings, then by their spellings with
every link followed, then by the identity the system reads for the deepest part that exists
(mcpplibs.os); a question whose identity cannot be read is decided by the spellings and reported
once as a degradation (`path`). A path's physical spelling appears in diagnostics only, and a CI
check holds every other resolution of a path to its canonical form at zero (SPEC-020).
- The working directory of a compiler run and its lock are opened by the given spelling, and a
compiler registration publishes its endpoint and transport record under the runtime directory as
the system reports it; before, both were resolved to physical paths, which a process granted
only the given spelling cannot open (mcpp#1048, mcpp#1049).
- The linker of a clang toolchain named by path is one fact, decided once: `tools.ld`, else the
tree's lld of the link's flavour, named by its address. It reaches the driver in the form each
link route reads: `--ld-path` for ELF, Mach-O and MinGW, an absolute `-fuse-ld` for wasm, and
`-B<directory> -fuse-ld=<name>` on the MSVC ABI, where `--ld-path` was reported unused and a
stated linker took no part in the link. On the MSVC ABI a stated linker named `link` or `lld` is
refused, since the driver finds those names by its own rules (SPEC-006 §3.12; mcpp#1050,
mcpp#1053).
- Every clang driver mcpp starts, for a compile, a link or a probe, is given
`-no-canonical-prefixes`: it derives its installation, resource and program directories from
the path it was started by. A tree of links finds its resource directory and programs in itself,
not in the tree its links lead to. A project built with clang compiles once more after the
upgrade, its std module included (SPEC-020 §9).
- The roots of a build are one table: the `trim_paths` prefix map and the link's hermetic check
read it, and the check allows every store of the home, as the map names them (SPEC-020 §8).
- `--verbose` applies to every build a command runs: `mcpp test --verbose` prints its compile
commands, as `mcpp build --verbose` and `mcpp pack --verbose` do. A build program's inner build
prints them only under `MCPP_TOOL_BUILD_VERBOSE` (docs/09).

### Added

- On the MSVC ABI, `-nostdlib` in `[build] ldflags` is noted once (`build/msvc-nostdlib`): it drops
the driver's `-defaultlib:` words, and each object still names the default libraries of the CRT
model. A program without the CRT also states `-fms-omit-default-lib` (clang) or `/Zl` (cl) in its
compile flags; the build is otherwise unchanged (mcpp#1051).

### Fixed

- `mcpp pack --verbose` forwards verbosity to every pack-owned build, including
library packages, additional legs and distribution-format builds (mcpp#1052).
Builds without `--verbose` retain their normal output.
- The link's hermetic check compares its allowed directories by path components; before, a
directory whose name extended an allowed one (`store2` beside `store`) was taken as inside it.

## [2026.12.6.2] - 2026-12-06

Expand Down
2 changes: 1 addition & 1 deletion docs/05-dependencies.md
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ requester of the same identity gets.
| any | same kind, same reference | Unchanged: the second declaration becomes an edge to the identity already resolved. Nothing is reported. |
| `version` | `version`, a different constraint | The two constraints are AND-combined by SemVer, as above; an unsatisfiable pair is refused, naming both constraints and both requesters. |
| `git` | `git`, a different `rev`/`tag`/`branch` | The root's declaration wins when the root is one of the two requesters; otherwise the declaration resolved first wins. A `dependency/source-override` warning names both requesters and both references, states which one is used and why, and how to take the other. This is never silent. |
| `path` | `path`, a different directory | The same rule and the same warning as the row above, compared by canonical absolute directory rather than by git reference. |
| `path` | `path`, a different directory | The same rule and the same warning as the row above, compared by the absolute directory with its links followed rather than by git reference ([SPEC-020](specs/paths.md) §4). |
| a root `path` or `git` declaration | a dependency's `git` or `version` declaration (a kind clash) | The root's declaration wins, with the same warning. When the losing declaration is a `version` requirement, it is checked against the `[package] version` of the root's resolved checkout; a violated requirement is refused, naming the pin, the requester and the requirement. The index is not asked to select or pin a request the root has answered, so the root's checkout serves a version no index carries yet (2026.10.26.2+). |
| a dependency's `path`/`git` declaration | another dependency's declaration of a different kind (a kind clash, and neither party is the root) | Refused: "requested as both a … dep … and a … dep …. Pick one." The message adds one sentence: declare the identity in the root to settle it. |

Expand Down
6 changes: 4 additions & 2 deletions docs/09-commands-by-scenario.md
Original file line number Diff line number Diff line change
Expand Up @@ -504,8 +504,10 @@ proceeds.
`--verbose` names every package: `Fresh` for those with nothing to do, and
`Compiled` with the steps and span of each that did work. It also states each
build program's compile and run times, and prints every step as ninja reports
it (`[f/t] <command>` and its output). `--quiet` prints none of this. Machine
output (`--message-format json`) is unchanged.
it (`[f/t] <command>` and its output). It applies to every build a command
runs: `build`, `run`, `test` and `pack` alike. A build program's own inner build
prints its steps only when `MCPP_TOOL_BUILD_VERBOSE` is set. `--quiet` prints
none of this. Machine output (`--message-format json`) is unchanged.

## Output streams

Expand Down
29 changes: 21 additions & 8 deletions docs/20-toolchains.md
Original file line number Diff line number Diff line change
Expand Up @@ -598,11 +598,14 @@ whether `import std` is available are read from the driver itself. The tools
beside them are found as `<prefix><tool>`, then `llvm-<tool>`, then `<tool>`;
`tools` names any the tree does not have.

`tools = { ld = … }` is read by a clang tree, where the linker reaches the link
as `--ld-path`. A gcc tree that states `ld` is refused: gcc chooses its linker by
the name `ld` inside a directory it is given with `-B`, so a program under any
other name could not be selected, and a stated tool that took no part in the
build is what this mechanism exists to prevent.
`tools = { ld = … }` is read by a clang tree, which hands the linker to the
driver by its address, in the form the target's link reads
([SPEC-006 §3.12](specs/toolchain-management.md)). On the MSVC ABI a linker whose
file name is `link` or `lld` is refused: the driver takes those two names for
programs it finds by its own rules. A gcc tree that states `ld` is refused: gcc
chooses its linker by the name `ld` inside a directory it is given with `-B`, so
a program under any other name could not be selected, and a stated tool that
took no part in the build is what this mechanism exists to prevent.

**What the tree can do is stated or probed (2026.12.4.1+).** A managed payload's
shape is the index's data; a tree's is read from the tree:
Expand All @@ -611,12 +614,15 @@ shape is the index's data; a tree's is read from the tree:
|---|---|
| archiver | `tools.ar`; else the tree (`<prefix>ar`, `llvm-ar`, `ar`); else the same names on `PATH`, reported as `build/archiver-from-host` (a degradation, refused under `--strict`); none anywhere is refused with `[toolchain-has-no-archiver]` |
| response files | asked of the archiver once; one that reads `@file` as a member's name is given the expanded words, in batches when they exceed the host's command line |
| linker (clang) | `tools.ld` through `--ld-path`; else `-fuse-ld=lld` when the tree has lld; else the driver's default |
| linker (clang) | `tools.ld`; else the tree's lld of the link's flavour (`ld.lld`, `ld64.lld`, `wasm-ld`, `lld-link`), named by its address; else the driver's default |
| compiler runtime, unwinder (clang) | `--rtlib=compiler-rt` and `--unwindlib=libunwind` only when the driver names the library |
| C++ modules (clang) | a two-line module unit compiled once; a driver that refuses it builds the units that use no module, and a unit that declares or imports one is refused with `[compiler-without-modules]`, naming the file |

The project's links and the build programs' links take the same words. Each
answer is kept under the program's identity, and `mcpp why toolchain` lists each
The project's links and the build programs' links take the same words. Every
command mcpp starts gives a clang driver `-no-canonical-prefixes`, so the driver
of a tree of links finds its resource directory and programs in the tree it was
started from, not in the tree its links lead to
([SPEC-020 §9](specs/paths.md)). Each answer is kept under the program's identity, and `mcpp why toolchain` lists each
fact with its source; the layer report writes `custom` for the layers the tree
supplies. A tree that holds both `clang++` and `g++` with no `family` stated is
noted once (`toolchain/tree-holds-two-families`), naming the one used.
Expand Down Expand Up @@ -1937,6 +1943,13 @@ not warned, because `cxx_runtime` is the root's key. A debug word (`/MTd`,
axis, and the standard library module and the link use the release CRT. The
engine never lets the last word on the command line decide silently.

**`-nostdlib` does not remove the CRT on the MSVC ABI.** In `[build] ldflags` it
drops the `-defaultlib:` words the driver adds to the link, and each object
still names the default libraries of the CRT model, which the linker reads. A
note says so once (`build/msvc-nostdlib`); the build is otherwise unchanged. A
program built without the CRT also states `-fms-omit-default-lib` (clang) or
`/Zl` (cl) in its compile flags.

> **Upgrading to 2026.9.28.2?** A program whose runtime search directories
> hold an older copy of the MSVC C++ runtime now receives the toolset's copy,
> where it received the directory's; the difference is stated once as a note
Expand Down
Loading
Loading