0
Fork 0
mirror of https://codeberg.org/ziglang/zig synced 2026-11-18 07:05:05 +00:00
Commit graph

1,022 commits

Author SHA1 Message Date
Jacob Young
f08a8f0fc2 main: reimplement compiler debug flags
* Add `.llvmbc`/`.llvmir` to `ObjectFormat` for emitting unoptimized IR
* Replace `--verbose-air`, `--verbose-intern-pool`,
  `--verbose-generic-instances`, `--verbose-llvm-ir`, and
  `--verbose-llvm-bc` with various `--debug-log` scopes
  * `--debug-log illegal-air`: pre-legalized Air
  * `--debug-log legal-air`: post-legalized Air
  * `--debug-log air`: final Air with liveness
  * `--debug-log ip-stats`: InternPool statistics
  * `--debug-log ip-values`: InternPool values
  * `--debug-log ip-generic-instances`: InternPool generic instances
  * `--debug-log llvm-ir`: pre-optimized LLVM IR
  * `--debug-log opt-llvm-ir`: post-optimized LLVM IR
* Delete `--verbose-cimport` which does nothing
* Delete `--verbose-llvm-cpu-features` which is equivalent to looking at
  the outputs of `--show-builtin` and `--debug-log llvm-ir`
2026-10-21 10:04:01 -07:00
Matthew Lugg
067f8dcb37
std.Build.Cache: support depending on nonexistent file/directory 2026-10-19 18:30:35 +01:00
Matthew Lugg
c3b8abfc26
std.Build.Cache: fix diagnostic printing 2026-10-19 18:30:35 +01:00
Andrew Kelley
3a5777b6b1 zig build: put interesting cache statuses in build summary
build summary now tells why a cache miss occurred, if it was an uncommon
case:
* invalid cache manifest
* a specific file was invalidated
* directory contents changed
* metadata changed

Cache miss due to it being the first time a particular build step is
being executed remains silent.

Not all kinds of build steps have this extra data about which files
caused cache invalidation, most notably Compile steps.
2026-10-18 02:16:37 +02:00
Isaac Freund
f2f0d97a9b std.Build.Configuration: add $DESTDIR-relative LazyPaths
The new deployed_prefix and related paths exist to support the use-case
of embedding absolute paths to other build artifacts in the build
artifacts themselves. For example pkg-config files are artifacts which
must contain absolute paths to the other library/header artifacts they
describe. Note that this feature is only supported to faciliate
interoperability with such legacy systems. In general, embedding
absolute paths in build artifacts should be avoided.

This patch also fixes a bug: currently passing an absolute path to
e.g. --prefix-lib-dir will cause $DESTDIR to be ignored for build
artifacts installed to that path.

I'm not entirely satisfied with the new "deployed" naming convention,
I want to avoid the breaking change of renaming "installed" to something
else and this is the best option I came up with.

Closes: https://codeberg.org/ziglang/zig/issues/37124
2026-10-17 20:12:39 +02:00
Andrew Kelley
c3cdf48407 Configuration: store unlazy dependencies differently
steps are many; unlazy dependencies are few
2026-10-15 16:37:06 -07:00
Andrew Kelley
2c18bccf44 std.Build: lazy dependencies can associate with steps
and serialize the configuration
2026-10-15 16:00:57 -07:00
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