1029 Commits
Author SHA1 Message Date
Matthew Lugg f6751410e9 build: run some tests with -flegalize-all
It's useful to run both a little-endian and a big-endian target here,
because some legalizations are susceptible to endianness bugs, e.g. any
related to bitwise operations or to `packed` (aka `bitpack`) types.

When modifying legalizations or adding new ones, they can be tested by
running `zig build test-modules -Donly-legalize` to limit to the targets
which pass `-flegalize-all`.

This makes it much easier to facilitate external contributions towards
https://codeberg.org/ziglang/zig/issues/36719, and will prevent
legalization passes from bit-rotting in the future.
2026-10-26 14:17:03 +00:00
Alex Rønne Petersen 2d6ff903a1 std.Target: add z80 arch tag and ABI info
Also fix cCharSignedness() for ez80.
2026-10-26 11:02:44 +01:00
Alex Rønne Petersen 766840daf1 std.Target: remove the kalimba arch tag
What little target info we had for this was incomplete/wrong, and it's
annoyingly difficult to get reliable information about it because Qualcomm
doesn't publish the documentation. So just delete it.
2026-10-26 11:02:44 +01:00
Alex Rønne Petersen 0d142b9e17 std.Target: remove amdpal and mesa3d OS tags
* mesa3d is for internal use in Mesa's shader compilation pipeline. This never
  really made sense to have in Zig.
* amdpal is for LLPC, part of AMDVLK, which AMD discontinued development of in
  favor of RADV in 2025.

Follow-up work: Removing the amdgcn_cs calling convention.
2026-10-26 11:02:43 +01:00
Alex Rønne Petersen 9092424fc3 make -ffunction-sections and -fdata-sections resolved config options
In preparation for giving them defaults that depend on the target and backend.
2026-10-26 11:02:42 +01:00
Andrew Kelley 70c86e11c4 Merge pull request 'wasm: static archive + codegen fixes' (#37308) from pavelverigo/zig:wasm-fix-comp into master
Reviewed-on: https://codeberg.org/ziglang/zig/pulls/37308
Reviewed-by: Andrew Kelley <andrew@ziglang.org>
2026-10-23 03:20:59 +02:00
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
Pavel Verigo 2d361f612b wasm: test and fix compilation of mvp/lime1/wasm_v3_0 mcpu 2026-10-20 23:10:13 +02: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