Commit Graph

857 Commits

Author SHA1 Message Date
Andrew Kelley affe5ed867 std.Build: port UpdateSourceFiles step to new system 2026-05-25 18:54:35 -07:00
Andrew Kelley d3ec255a1f more progress towards zig's build.zig compiling 2026-05-25 18:54:35 -07:00
Andrew Kelley 3d78589765 std.Build: port Fmt step to new system
and integrate properly with LazyPath
2026-05-25 18:54:35 -07:00
Andrew Kelley ddabd57743 progress towards compiling zig's build script 2026-05-25 18:54:35 -07:00
Andrew Kelley fa26566867 configurer: get InstallDir and Options steps compiling 2026-05-25 18:54:35 -07:00
Andrew Kelley c57bf99043 Configuration: implement Storage.UnionList.tag 2026-05-25 18:54:35 -07:00
Andrew Kelley 364a1400ff configurer: fix compilation in the presence of dependencies 2026-05-25 18:54:35 -07:00
Andrew Kelley ac0b1bfda2 build system: implement options
options which are passed to configurer and therefore observable by the
build script are added to the cache hash. A sorted list is hashed since
they are unordered.
2026-05-25 18:54:35 -07:00
Andrew Kelley aec708ce25 build system: remove unneeded args from configurer
not needed:
* zig exe path
* zig lib dir
* build root
* local cache root
* global cache root
2026-05-25 18:54:35 -07:00
Andrew Kelley 7819e4dea7 rename addCliExtras to addPassthruArgs
finally, a good name
2026-05-25 18:54:35 -07:00
Andrew Kelley 8f224bc3f0 rename addBuildPositionals to addCliExtras
they don't have to be positionals
2026-05-25 18:54:35 -07:00
Andrew Kelley 0d95b44a1c build system: implement cli positionals 2026-05-25 18:54:35 -07:00
Andrew Kelley 0f3471eb66 maker: finish porting over run step 2026-05-25 18:54:34 -07:00
Andrew Kelley c8b583885d maker: port Run step logic up to spawnChildAndCollect 2026-05-25 18:54:34 -07:00
Andrew Kelley 378b790ee2 maker: port more of Run step over 2026-05-25 18:54:34 -07:00
Andrew Kelley 7c718fc72e fix compilation errors from rebase conflicts 2026-05-25 18:54:34 -07:00
Andrew Kelley a399d37886 maker: upgrade some of the run step logic 2026-05-25 18:54:34 -07:00
Andrew Kelley 81ee4ab32c configurer: serialize all data from run steps 2026-05-25 18:54:34 -07:00
Andrew Kelley 8bc0913212 compiler: fix compilation errors 2026-05-25 18:54:34 -07:00
Andrew Kelley e436d9c4ad configurer: back out the string interning from prev commit
partial revert of 2d3fbb687fba1ed52b42998ac4dcbf2a042644ea - see its
commit message for reasoning
2026-05-25 18:54:34 -07:00
Andrew Kelley c6d37f3895 configurer: make string duplication also intern
I had this idea to make b.dupe() also intern the strings since they will
be ultimately serialized to Configuration. Unfortunately the idea does
not work, because although a process-lived arena is used for the
string_bytes ArrayList of the Configuration.Wip, when the ArrayList is
resized, Allocator.free() memsets the freed memory to undefined, even
though it still technically lives due to being in a process-scoped
arena. So this commit will need to be partially reverted. However, I
kept it for posterity, and there are some more changes which I will now
note below.

- dupePaths: don't rewrite backslashes to forward slashes. backslashes
  are valid in filenames on non-windows systems.
- always compile configurer in single-threaded mode
- use arena allocator for everything, no gpa for anything
- construct the Configuration.Wip instance earlier, so some stuff can be
  prepopulated as desired.
- don't forget to flush
2026-05-25 18:54:34 -07:00
Andrew Kelley aa0652ff8d maker: implement InstallArtifact and InstallFile 2026-05-25 18:54:34 -07:00
Andrew Kelley dd51fc30f8 maker: finish migrating compile step make logic 2026-05-25 18:54:34 -07:00
Andrew Kelley c60d33f167 Configuration: refactor maxInt(u32) 2026-05-25 18:54:34 -07:00
Andrew Kelley 6ad6a58e5d Configuration: fix bad serialization of PrefixedList and MultiList
Length zero is still serialized because there is no flag bit to hide the
length.
2026-05-25 18:54:34 -07:00
Andrew Kelley a60ffaf5b3 maker: finish migrating most of CLI lowering code 2026-05-25 18:54:34 -07:00
Andrew Kelley cc4f205fc3 maker: progress towards lowering zig cli args 2026-05-25 18:54:34 -07:00
Andrew Kelley ec2b156720 std: rename zig.Configuration to Build.Configuration 2026-05-25 18:54:34 -07:00
Andrew Kelley 71ac3f15b3 build system: implement LazyPath
Number of generated files is recorded in serialized Configuration. Maker
preallocates array of generated files so that loads and stores can be
synchronization-free (protected by the dependency tree ordering).

More progress on Compile Step Zig CLI lowering.
2026-05-25 18:54:34 -07:00
Andrew Kelley eaffd55513 maker: progress towards lowering Compile Step CLI args
next thing to do is figure out how LazyPath is supposed to work now.
something like this:
* each Step that provides LazyPath objects has a setLazyPath and
  getLazyPath function which takes a tagged union identifying which one
  to access
* steps that fulfill LazyPath objects can freely call setLazyPath
  without obtaining a lock because the dependency graph prevents
  simultaneous access.
* similarly, steps that access LazyPath results can freely call
  getLazyPath without obtaining a lock, because after modification,
  there may be simultaneous reads from dependencies but they will all be
  read-only
* a fulfilled LazyPath object is a read-only std.Build.Cache.Path.
2026-05-25 18:54:34 -07:00
Andrew Kelley 8aec13b6ab Configuration: serialize remaining Module information
also handle properly Module circular references and introduce a general
deduplication mechanism.
2026-05-25 18:54:34 -07:00
Andrew Kelley 6925a57d2f Configuration: implement UnionList storage 2026-05-25 18:54:34 -07:00
Andrew Kelley 612560d019 std.Build.Configure: implement FlagOptional serialization 2026-05-25 18:54:34 -07:00
Andrew Kelley 74b018ceb3 zig build: make --error-limit globally configurable
still overridable by individual Compile steps
2026-05-25 18:54:34 -07:00
Andrew Kelley 959103c3fd Maker.Step.Compile: progress towards lowering zig args 2026-05-25 18:54:34 -07:00
Andrew Kelley 6b7ce1fa22 massage Step code into compiling 2026-05-25 18:54:34 -07:00
Andrew Kelley afd7507a19 make runner: prepare steps for execution 2026-05-25 18:54:33 -07:00
Andrew Kelley 3e6bebbbca configure runner: serialization of Module 2026-05-25 18:54:33 -07:00
Andrew Kelley 648e0e0cc0 configure runner: serialization of compile step 2026-05-25 18:54:33 -07:00
Andrew Kelley 6b040d631f configure runner: add Step.Run serialization 2026-05-25 18:54:33 -07:00
Andrew Kelley 83a3475887 configure runner: implement serialization of InstallArtifact 2026-05-25 18:54:33 -07:00
Andrew Kelley 2e88ac8842 zig build: configure runner basics implemented 2026-05-25 18:54:33 -07:00
Andrew Kelley e10cbf08ee configure/make phase process separation sketch
`zig build` CLI kicks off async task to compile optimized make runner
executable, does fetch, compiles configure process in debug mode, then
checks cache for the CLI options that affect configuration only. On hit,
skips building/running the configure script. On miss, runs it, saves
result in cache.

The cached artifact is a "configuration" file - a serialized build step
graph, which also includes unlazy package dependencies and additional
file system dependencies.

Next, awaits task for compiling optimized make runner executable, passes
configuration file to it. Make runner is responsible for the CLI after
that point.

For the use case of detecting when `git describe` needs to be rerun, we
can allow the configure process to manually add a file system mtime
dependencies, in this case it would be on `.git/index` and `.git/HEAD`.

This will enable two optimizations:

1. The bulk of the build system will not be rebuilt when user changes
   their configure script.

2. The user logic can be completely bypassed when the CLI options
   provided do not affect the configure phase - even if they affect the
   make phase.

Remaining tasks in the branch:

* some stuff in `zig build` CLI is `@panic("TODO")`.
* configure runner needs to implement serialization of build graph using
  std.zig.Configuration
* build runner needs to be transformed into make runner, consuming
  configuration file as input and deserializing the step graph.
* introduce depending only on a file's metadata and *not* its contents
  into the cache system, and add a std.Build API for using it.
2026-05-25 18:54:33 -07:00
Matthew Lugg 989b6a1b93 std.Build: clear step inputs when resetting the step
Previously, when using `zig build -fincremental --watch some-run-step`,
if the binary initially builds fine but a future update introduces a
compile error, the old file system inputs of the `Step.Run`---containing
the executable file itself---would remain. This is a bug, because that
file *has* changed since the input was registered (due to incremental
compilation), and yet the `Run` step is not out-of-date because it was
skipped due to a transitive failure.

A simple reproduction for this issue was:

  $ zig init
  $ zig build test --watch -fincremental

Then, in another terminal, introduce a compile error:

  $ sed -i 's/const/onst/' src/main.zig

Before this commit, this would cause the `zig build` command to repeat
updates forever, separated only by the 50ms debounce interval.

To fix this, when we reset a step with intent to re-run it, we should
clear its inputs immediately, so that if the step is skipped, it is
correctly marked as having no inputs.

This relates to a more general problem with the file system watching
logic which is that the set of inputs includes files in the cache which
are actually artifacts of other steps. Eventually, the build system
should learn to identify such files and exclude them from the set of
file system inputs. In other words, the fact that a `Run` step depends
on the executable generated by a `Compile` step should be modeled by a
dependency in the build step graph, *not* by a dependency on the path
where the `Compile` step happens to have emitted its executable file.
2026-05-07 19:45:37 +02:00
Andrew Kelley cd23f7a814 Merge pull request 'std.meta: Remove Int/Tuple in favor of @Int/@Tuple' (#35188) from linus/zig:deprecated-std-meta into master
Reviewed-on: https://codeberg.org/ziglang/zig/pulls/35188
Reviewed-by: Andrew Kelley <andrew@ziglang.org>
2026-05-06 19:35:40 +02:00
Andrew Kelley 3d56df1716 Merge pull request 'std.fmt, std.mem.Allocator: Remove bufPrintZ()/dupeZ() in favor of bufPrintSentinel()/dupeSentinel()' (#35190) from linus/zig:deprecated-std-fmt-mem into master
Reviewed-on: https://codeberg.org/ziglang/zig/pulls/35190
Reviewed-by: Andrew Kelley <andrew@ziglang.org>
2026-05-06 19:34:52 +02:00
Linus Groh 0add2dfc41 std.Io.File: Remove deprecated option types 2026-05-05 04:12:52 +02:00
Linus Groh fcc0a5a913 std.mem.Allocator: Remove dupeZ() in favor of dupeSentinel() 2026-05-03 21:42:16 +01:00
Linus Groh 991f56fd6b std.meta: Remove Int in favor of @Int 2026-05-03 21:42:06 +01:00
GasInfinity 1deb029a66 std: rename bit_set variants and deprecate the managed one.
* aliases and deprecates the previous names.
* also update callsites to use the non-deprecated declarations.
2026-04-27 16:46:26 +02:00