authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2026-05-19 16:58:07-07:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2026-05-25 18:54:35-07:00
logec65f129d8cfdba6c15f0ea5cda5acea5c8d3ada
treeb455952f55ac843dcde00fcbdf0f7645254e52de
parent5c133c5765f3c4e80d46c35c104edc23d883c60e

Maker: lower -target arguments


2 files changed, 6 insertions(+), 120 deletions(-)

BRANCH_TODO deleted-114
...@@ -1,114 +0,0 @@
1* Run step getting wrong path_directory values
2* double check when targets get resolved (should be at configure time)
3* finish migrating the rest of the build steps
4* pass overridden pkg-dir to maker
5* inspect b4ffb402c082605c4b324e88120306fc8fb3cf32 diff and apply changes as needed (merge conflict)
6* make zig-pkg path root configurable in maker (make sure --system still works)
7* eliminate calls to getPath, getPath2, getPath3
8* test lazyImport
9* get zig tests passing
10* solve the TODOs added in this branch
11* test a bunch of third party projects / help people migrate
12 * tetris
13
14* [handle missing cache hits when chaining two run steps](https://codeberg.org/ziglang/zig/pulls/30762)
15* [Absolute and cwd-relative paths in build cache](https://codeberg.org/ziglang/zig/issues/32097)
16
17
18* implement {q} or delete {q} uses
19* make the generated dependencies.zig be dependencies.zon and don't put absolute paths in there
20 - and adjust dependencyInner to not openDir()
21
22* re-evaluate https://codeberg.org/ziglang/zig/pulls/35224
23
24## Followup Issues
25* make more stuff use IndexType
26* make addExtra return Index using reflection
27* refactor with DefaultingEnum
28* get the target from the parent process instead
29* stop leaking into global process arena
30* reduce the size of Maker.Step.Extended (make Run smaller) probably by using an arena per make
31* link_eh_frame_hdr should be DefaultingBool
32* make --foo, --no-foo CLI args uniform (make them -f args instead)
33* install steps should provide generated files for installed things, then delete the run step hack
34 - but artifact install steps also add paths for dyn libs on windows
35* no more "artifact arg" to run step. if you want to run the post-install binary, get the lazy path
36 from the install step.
37* fmt step: import zig fmt code directly rather than child proc
38* UpdateSourceFiles: introduce Group
39* WriteFiles: introduce Group
40* re-examine the use case of adding file paths to Options steps
41* extract the reusable Configure abstractions and reuse it for Zir etc
42* add the ability to delete files to UpdateSourceFiles
43
44## Already Filed Followup Issues
45* build system fmt step with check=false does not acquire a write lock on source files #35204
46* enhance CheckFile step output when there is not a match #35208
47* missing truncate functionality #35353
48
49## Release Notes
50
51### Run Step: Passthru Args
52
53In the Run step, passthru args are all together now, not observable in
54configure phase whether run args are provided.
55
56```zig
57if (b.args) |args| {
58 run_cmd.addArgs(args);
59}
60```
61
62⬇️
63
64```zig
65run_cmd.addPassthruArgs();
66```
67
68This removes a capability from build scripts since they can no longer observe
69those arguments. In exchange, it means that when changing those arguments,
70build scripts no longer must be rebuilt from source.
71
72closes #31397
73
74### Fmt Step: Options
75
76`paths` and `exclude_paths` are now LazyPath lists. There is a convenience method to create them: `b.pathList`.
77
78```diff
79- const fmt_include_paths = &.{ "lib", "src", "test", "tools", "build.zig", "build.zig.zon" };
80- const fmt_exclude_paths = &.{ "test/cases", "test/behavior/zon" };
81+ const fmt_include_paths = b.pathList(&.{ "lib", "src", "test", "tools", "build.zig", "build.zig.zon" });
82+ const fmt_exclude_paths = b.pathList(&.{ "test/cases", "test/behavior/zon" });
83```
84
85### std.Build API
86
87* `b.build_root` (Directory) -> `b.root` (Path)
88* `ConfigHeader.Options`: `include_guard_override` -> `include_guard`
89* `LazyPath`: `getDisplayName` -> `format` or `fmt`
90* `LazyPath.basename` no longer takes parameters. The returned basename might
91 be unknown until make phase in which case returned string is length zero.
92
93### Perf Data Point: `zig build -h` (cached)
94
95```
96Benchmark 1 (34 runs): master/zig build -h
97 measurement mean ± σ min … max outliers delta
98 wall_time 150ms ± 5.52ms 145ms … 165ms 4 (12%) 0%
99 peak_rss 84.8MB ± 275KB 84.2MB … 85.1MB 0 ( 0%) 0%
100 cpu_cycles 593M ± 4.01M 588M … 608M 2 ( 6%) 0%
101 instructions 995M ± 52.5K 995M … 995M 0 ( 0%) 0%
102 cache_references 25.8M ± 165K 25.4M … 26.1M 0 ( 0%) 0%
103 cache_misses 651K ± 20.1K 619K … 697K 0 ( 0%) 0%
104 branch_misses 918K ± 7.44K 906K … 935K 0 ( 0%) 0%
105Benchmark 2 (348 runs): branch/zig build -h
106 measurement mean ± σ min … max outliers delta
107 wall_time 14.3ms ± 744us 13.2ms … 23.3ms 8 ( 2%) ⚡- 90.4% ± 0.4%
108 peak_rss 78.5MB ± 562KB 77.1MB … 81.4MB 7 ( 2%) ⚡- 7.4% ± 0.2%
109 cpu_cycles 24.1M ± 821K 22.8M … 27.1M 3 ( 1%) ⚡- 95.9% ± 0.1%
110 instructions 43.7M ± 23.8K 43.7M … 43.8M 56 (16%) ⚡- 95.6% ± 0.0%
111 cache_references 1.46M ± 14.6K 1.40M … 1.50M 19 ( 5%) ⚡- 94.3% ± 0.1%
112 cache_misses 142K ± 4.87K 127K … 157K 2 ( 1%) ⚡- 78.1% ± 0.4%
113 branch_misses 126K ± 1.37K 120K … 129K 12 ( 3%) ⚡- 86.3% ± 0.1%
114```
lib/compiler/Maker/Step/Compile.zig+6-6
...@@ -1274,21 +1274,21 @@ fn appendModuleFlags(...@@ -1274,21 +1274,21 @@ fn appendModuleFlags(
12741274
1275 if (m.resolved_target.get(conf)) |target| {1275 if (m.resolved_target.get(conf)) |target| {
1276 // Communicate the query via CLI since it's more compact.1276 // Communicate the query via CLI since it's more compact.
1277 if (target.query.get(conf)) |query| {1277 if (target.query.get(conf)) |compact_query| {
1278 try zig_args.ensureUnusedCapacity(gpa, 6);1278 try zig_args.ensureUnusedCapacity(gpa, 6);
12791279
1280 if (true) @panic("TODO appendModuleFlags");1280 const query = compact_query.unwrap(conf);
12811281
1282 zig_args.appendAssumeCapacity("-target");1282 zig_args.appendAssumeCapacity("-target");
1283 zig_args.appendAssumeCapacity(try query.zigTriple(arena));1283 zig_args.appendAssumeCapacity(try query.zigTriple(arena));
1284
1284 zig_args.appendAssumeCapacity("-mcpu");1285 zig_args.appendAssumeCapacity("-mcpu");
1285 zig_args.appendAssumeCapacity(try query.serializeCpuAlloc(arena));1286 zig_args.appendAssumeCapacity(try query.serializeCpuAlloc(arena));
12861287
1287 if (query.dynamic_linker) |dynamic_linker| {1288 if (query.dynamic_linker) |*dynamic_linker| {
1288 const dynamic_linker_slice = dynamic_linker.slice(conf);1289 if (dynamic_linker.get()) |dynamic_linker_path| {
1289 if (dynamic_linker_slice.len != 0) {
1290 zig_args.appendAssumeCapacity("--dynamic-linker");1290 zig_args.appendAssumeCapacity("--dynamic-linker");
1291 zig_args.appendAssumeCapacity(dynamic_linker_slice);1291 zig_args.appendAssumeCapacity(dynamic_linker_path);
1292 } else {1292 } else {
1293 zig_args.appendAssumeCapacity("--no-dynamic-linker");1293 zig_args.appendAssumeCapacity("--no-dynamic-linker");
1294 }1294 }