Repository navigation
One tree, one compiler binary, in any worktree: WITH_FILE_PREFIX_MAP (D50) - #1226
Merged
Merged
Conversation
added 2 commits
September 20, 2026 07:49
…(D50) The compiler named its checkout in three places, so the same commit built in two worktrees gave two different compilers and nothing built in one could be shared with another (test verdicts, artifacts, a warm start for a new worktree): - the DWARF compile unit: /Users/eric/with/rt (16x) and .../out/gen (2x); - module link names: `__with_mod_<hash>__name` hashed the module's absolute path, so rt_core's alloc_* and channel_runtime's chan_* had a different name per checkout (176 bytes of __const, shifting 36 MB of the binary); - the linker's debug map: 23 N_OSO stabs naming each linked object by absolute path (48 bytes of the string table between `path-free` and `path-free-b`). WITH_FILE_PREFIX_MAP=<from>=<to>, after clang's -ffile-prefix-map and Rust's remap-debuginfo, beside #949's canonical stdlib paths: the mapped root is what codegen_canonical_module_path returns (so both the link-name hash and the compile unit use it), the darwin lld link passes -oso_prefix <from>/, and dsymutil gets -oso-prepend-path <from> to find the objects again. The build passes <project root>=/with-src to the compiler's own compiles. Evidence, one commit built at the same time in two worktrees (path-free, path-free-b): out/release/bin/with.unstamped 56f47bd93c2ab7bc in both, out/release/bin/with 7de3cf4dad34c38e in both, both unit-digest lists identical. The .dSYM is whole (22 MB, 8496 subprograms). lldb with `settings set target.source-map /with-src $PWD` sets rt_core.w:1500 and lists the source; without the map it lists nothing, so CLAUDE.md's LLDB recipe carries it. with-stage2 still differs between worktrees (136 symbols, all rt_core's alloc_*): it links the bootstrap runtime objects, which the pinned seed compiles and the seed does not know the option; that ends at the next seed. behav_file_prefix_map_objects_match: a two-module program compiled in two directories gives identical objects under the map and different ones without it. D50 records the survey, what Go, Zig, Rust, Scala 3, Bazel and Vale do, the three decisions landed so far (#1224, #1225, this) and what remains.
…e convention is unchanged abi-hash-check asks for a conscious decision when an ABI-defining source changes. src/FnAbi.w changed (fn_abi_file_prefix_mapped, and codegen_canonical_module_path applying it); the calling convention did not. The mapping changes a module's link-name hash only when WITH_FILE_PREFIX_MAP is set and only for a module outside the stdlib tree; a .wo bundle's modules are named <embedded-std>/..., which the mapping never sees. No WITH_ABI_VERSION bump; every .wo rebuilds once, as the gate says.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Third item of the build-redo survey (D50, recorded here with the survey, the reference comparison, what landed and what remains).
The problem. The compiler named its checkout in three places, so one commit built in two worktrees gave two different compilers, and nothing built in one worktree could be shared with another (test verdicts, artifacts, a warm start for a new worktree):
/Users/eric/with/rt(16×),…/out/gen(2×)__with_mod_<hash>__namehashed the module's absolute pathalloc_*and channel_runtime'schan_*had a different name per checkout: 176 bytes of__const, shifting 36 MBN_OSOstabs naming each object by absolute pathWhat the others do (checked in
.reference/): Go passes-trimpathalways and normalizes the work dir; Rust hasremap-debuginfo(/rustc/<sha>); Zig's manifests store prefix-relative paths; Scala 3 has-sourceroot. We already did this for bundle objects (#949).The change.
WITH_FILE_PREFIX_MAP=<from>=<to>, after clang's-ffile-prefix-map. The mapped root is whatcodegen_canonical_module_pathreturns, so the link-name hash and the compile unit both use it; the darwin lld link passes-oso_prefix <from>/;dsymutilgets-oso-prepend-path <from>. The build passes<project root>=/with-srcto the compiler's own compiles.Evidence. One commit built at the same time in two worktrees (
path-free,path-free-b):Debugging:
lldb -o "settings set target.source-map /with-src $PWD" -- <binary>setsrt_core.w:1500and lists the source; without the map it lists nothing, so the LLDB recipe in CLAUDE.md/AGENTS.md now carries the line.behav_file_prefix_map_objects_match: a two-module program compiled in two directories gives identical objects under the map and different ones without it.ABI hash.
abi-hash-checkwent red on the first battery becausesrc/FnAbi.wchanged. The convention did not: the mapping changes a link-name hash only when the option is set and only for a module outside the stdlib tree, and a.wobundle's modules are named<embedded-std>/…, which the mapping never sees. Re-recorded as the gate prescribes, noWITH_ABI_VERSIONbump; every.worebuilds once.Until the next seed.
with-stage2still differs between worktrees (136 symbols, all rt_core'salloc_*): it links the bootstrap runtime objects, which the pinned seed compiles, and the seed does not know the option. The release binary is unaffected.Battery (pinned seed, head 1b744b4):