Commit Graph
1015 Commits
Author SHA1 Message Date
Andrew Kelley 9343d0fe4b std.Build.Cache: fix cache miss when metadata changes
adds test for "changed metadata of input file but same digest causes hit"

closes #37200
2026-10-15 08:17:27 +02:00
Alex Rønne Petersen 963d4466d5 std.Target: remove contiki OS tag
Contiki-NG is really more like a freestanding library for driving MCUs and
peripherals; it's not an OS with an ABI as such. So a dedicated OS tag isn't
really doing anything useful over `freestanding`.
2026-10-12 14:43:32 +02:00
Alex Rønne Petersen 7a7b944ef8 std.Target: remove hermit OS tag
Hermit is a unikernel with no stable syscall ABI; you must link its syscall
library statically to perform syscalls. Due to the way the project's build
system works, that means using Rust/Cargo. As such, it makes essentially zero
sense for Zig to support this target.
2026-10-12 14:35:23 +02:00
Jacob Young 4dd645fddd Runner: add --libc-runtimes support 2026-09-26 19:08:50 -04:00
Jacob Young 4e4e8902e5 Build: fix UAF of step names 2026-09-26 19:08:50 -04:00
Jacob Young 11958a306f test: implement new runner 2026-09-26 19:08:50 -04:00
Andrew Kelley b844605c52 build system: translate-c supports arbitrary c flags
closes #35568
2026-09-22 08:57:25 +02:00
Andrew Kelley 177e62218e std.Build.Serialize: serialize step extended data
before calculating capacity for appending steps
2026-09-19 19:08:25 +02:00
Andrew Kelley c106e27595 std.Build.Step.Options: add addOptionPathDirectory
Now, when adding an option that is a file path, one must explicitly
choose between:
* `addOptionPath` (must be a file)
* `addOptionPathDirectory` (must be a directory)
* `addOptionPathUntracked` (opt out of dependency tracking)

closes #35766
2026-09-17 21:04:22 -07:00
Andrew Kelley b27aacf820 std.Build.Cache: fix handling of empty sub paths
when a sub path relative to a given prefix is length zero, it needs to
be treated as "." when doing actual file system operations.
2026-09-17 21:03:29 -07:00
Andrew Kelley 9d0fb12a8f std.Build.Step.Option: clarify addOptionPathUntracked
in particular, that it may be a file or directory
2026-09-17 20:19:18 -07:00
Brandon Black 5ede6a167e Build.Step.Options: addOptionPathUntracked
This interface is like `addOptionPath`, but does not assume that
the provided `LazyPath` represents a generated file, and does not
set up any further dependencies on whatever the path represents.

This supports use-cases like setting an `.install_prefix` -based
default directory path option for the application to use as a
fallback when the user does not provide an override.  Example:

    options.addOptionPathUntracked(
        "DefaultConfigDir",
        b.graph.path(
            .install_prefix,
            b.pathJoin(&.{ "etc", "myapp" }),
        ),
    );
2026-09-18 04:31:03 +02:00
Andrew Kelley 56571a70d9 std.Build.Cache: fix flagsAndPath implementation
it was scanning for sentinel starting from flags rather than flags + 1,
which could lead to the scenario where the path is empty because flags
is zero
2026-09-16 16:05:26 -07:00
Andrew Kelley 597306838d frontend: better error reporting for cache check failures 2026-09-16 13:12:47 -07:00
Andrew Kelley e8882ffcf0 std.Build.Cache: fix compilation on 32-bit 2026-09-16 13:12:47 -07:00
Andrew Kelley 5eb4a5d4b4 std.Build.Cache: use Io.File.INode type
rather than u64. fixes build on Windows
2026-09-16 13:12:47 -07:00
Andrew Kelley 28feeaf778 link: pass request_handle=true to addInputPath
when passing already open handle, this is now required when the caller
wants the cache system to keep the file handle open.
2026-09-16 13:12:47 -07:00
Andrew Kelley b9794c89ac std.Build.Cache: remove stray hash mutation 2026-09-16 13:12:47 -07:00
Andrew Kelley 3e3b0b835c std.Build.Cache: fix addDiscoveredManifest 2026-09-16 13:12:47 -07:00
Andrew Kelley 3bb9f1847b std.Build.Cache: add transitionToMissDiscovered in addDiscoveredManifest 2026-09-16 13:12:47 -07:00
Andrew Kelley a014c1a287 std.Build.Cache.DepTokenizer: slightly modernize 2026-09-16 13:12:47 -07:00
Andrew Kelley 92439e73d0 std.Build.Cache: don't preemptively truncate the manifest 2026-09-16 13:12:47 -07:00
Andrew Kelley d1b961c9eb std.Build.Cache: introduce State enum 2026-09-16 13:12:47 -07:00
Andrew Kelley e38052663c std.Build.Cache: fix writing digest to wrong place 2026-09-16 13:12:47 -07:00
Andrew Kelley 228178c151 std.Build.Cache: simplify hashing logic 2026-09-16 13:12:47 -07:00
Andrew Kelley 43397f2251 std.Build.Cache: implement populated requested contents 2026-09-16 13:12:47 -07:00
Jacob Young 9c325be987 This assertion cannot be true on later iterations.
And tautologically true on the first iteration.
2026-09-16 13:12:47 -07:00
Jacob Young 29531cc9c0 finish fixing one unit test 2026-09-16 13:12:47 -07:00
Andrew Kelley 30c3c666ab starting to fix the unit test failures 2026-09-16 13:12:47 -07:00
Andrew Kelley b91a6dc5b1 update to newest std.Build.Cache API 2026-09-16 13:12:47 -07:00
Andrew Kelley a24b4758f4 std.Build.Cache: rework the core logic again
- implement the logic for populating remaining input file digests when a
  miss occurs while checking one of the input files
- make `Manifest.check` return not just "miss" but also explain why it
  was a miss and which file caused it
- fix fundamental design flaw which clobbered input file digest, path,
  and stat information that was needed to compare against on disk
  manifest entries
- implement the logic for when the Manifest API user provides an already
  available handle, stat, or contents, and when they request the handle
  or contents.
- rename `Manifest.writeManifest` to `Manifest.finalize`
- rename `Manifest.manifest_dirty` to `Manifest.dirty`
2026-09-16 13:12:47 -07:00
Andrew Kelley 3f092f8c28 std.Build.Cache: add missing resource deallocation 2026-09-16 13:12:47 -07:00
Andrew Kelley 31b86e53aa std: update to new std.Build.Cache API 2026-09-16 13:12:47 -07:00
Andrew Kelley 0334f14a13 compiler: update to new std.Build.Cache API 2026-09-16 13:12:47 -07:00
Andrew Kelley 5b57dca62d std.build.Cache: fix regressions from the branch 2026-09-16 13:12:47 -07:00
Andrew Kelley 2c605872fc std.Build.Cache: non-async checking
Empirically this went from 29% slower than status quo on my machine to
15% faster, for `zig build` on the `zig init` project.
2026-09-16 13:12:47 -07:00
Andrew Kelley 28e360fb61 std.Build.Cache: eliminate unbounded concurrency
would be nice if Io.Select.async had a variant where it returned the
eager result rather than trying to put it in the queue so that the queue
buffer doesn't need to be dynamically allocated
2026-09-16 13:12:47 -07:00
Andrew Kelley b422974322 std.Build.Cache: add missing hash-computing logic 2026-09-16 13:12:47 -07:00
Andrew Kelley f7bdb939e1 add cache-cat subcommand
for printing .zig-cache/h/* files to zon format
2026-09-16 13:12:47 -07:00
Andrew Kelley 2a82193af4 std.Build.Cache: fix deadlock from using Io.Select
Io.Select.async has a fatal flaw: if the queue size isn't big enough to
hold the result of an eager async call, then it deadlocks.

The workaround in this thread is using concurrent() which should be
reverted because it will spawn too many threads.
2026-09-16 13:12:47 -07:00
Andrew Kelley 4dbe872dfe std.Build.Cache: fix calculation of File size when reading manifest 2026-09-16 13:12:47 -07:00
Andrew Kelley 48d6b1aa4a std.Build.Cache: rename addPathPost to addDiscoveredPath 2026-09-16 13:12:47 -07:00
Andrew Kelley d142f63f89 std.Build.Cache: fix adding files
no longer adding unwanted padding bytes
2026-09-16 13:12:47 -07:00
Andrew Kelley d3231ad090 std.Build.Cache: get it compiling again 2026-09-16 13:12:46 -07:00
Andrew Kelley 0b561847c1 std.Build.Cache: make IsDirectoryAmbiguous an assertion not error 2026-09-16 13:12:46 -07:00
Andrew Kelley 872e8c8f7d std.Build.Cache: fix some compilation errors from rewrite 2026-09-16 13:12:46 -07:00
Andrew Kelley 9ad1a6be17 std.Build.Cache: implement is_directory and metadata_only 2026-09-16 13:12:46 -07:00
Andrew Kelley ec7805b867 WIP: rework std.Build.Cache
- implement std.Build functions:
  - `dependOnDirectoryMetadata`
  - `dependOnDirectoryContents`
  - `dependOnFileMetadata`
  - `dependOnFileContents`
- switch cache manifest to binary format. saves about 25% of file size,
  which is not a ton, but this is in the really hot path, so any amount
  we can reduce file system cache pressure is going to help a lot.
  - also means saving and loading is simpler - just copying bytes in and
    out of memory plus a tiny bit of validation.
- batch cache manifest memory allocations together. one big allocation
  for the entire manifest file contents, with the files hash map only
  tracking starting offsets for each entry, and the input files as a
  simple array list with the extra information needed for input files
  (so they can be lazily loaded only on cache miss)
- remove the manifest file size limit
- input files that have requested content to be loaded is loaded
  together into one big allocation rather than separately tracked.
- each file entry in the cache now tracks two additional bits:
  - kind: file or directory
  - tracking mode: contents or metadata
    - when tracking a directory, "contents" are considered to be the
      sorted list of file names contained in the directory (non recursive)
- rename "hit" to "check" and make it return enum instead of bool
- merge most "add...File" function variants together into one that has
  an "options bag" parameter.
- take advantage of async I/O when checking for cache hit to compute
  hashes concurrently. Care is taken to never cancel useful work, and
  never wait for unnecessary work to complete.

bonus:
- build.zig: use std.log for printing log messages
2026-09-16 13:12:46 -07:00
lg 39512c3e55 compiler: add support for patchable functions 2026-09-16 19:21:21 +02:00
Krzysztof Wolicki 36dd7e9c37 Change usages of fmt.bufPrint* to mem.print* (#36263)
This PR doesn't touch usages inside `lib/compiler/aro`

Reviewed-on: https://codeberg.org/ziglang/zig/pulls/36263
Reviewed-by: Ryan Liptak <squeek502@noreply.codeberg.org>
2026-09-01 02:21:28 +02:00