116 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
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
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 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 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
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 872e8c8f7d std.Build.Cache: fix some compilation errors from rewrite 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
Andrew Kelley c6204ba3c2 Merge pull request 'spork8 backend' (#36627) from spork8 into master
Reviewed-on: https://codeberg.org/ziglang/zig/pulls/36627
2026-08-27 21:18:14 +02:00
Kleshzz c3723c05f0 std.Target: add gba os tag 2026-08-27 14:35:44 +02:00
Andrew Kelley 03cc522fc0 spork8: object format is .bin extension (raw machine code) 2026-08-26 20:54:49 -07:00
Andrew Kelley 3cd05f8a1b init spork8 backend 2026-08-26 20:54:49 -07:00
K4 2c93c6e91b std.lang.OptimizeMode -> std.lang.Optimize migration progress 2026-08-23 14:30:48 +02:00
Pavel Verigo 7051f8e73b wasm: add --growable-table 2026-08-18 17:43:59 +02:00
Andrew Kelley 5d7cf3f34d zig build: revert package related changes to Configuration
partial revert of 8e48a5c524
partial revert of 8380531aec

fixes regression in the build system causing crash when trying to build
ffmpeg project from the ecosystem.

upon closer inspection, I don't think this is the right direction for
adding this data to Configuration. Let's try again and be a little more
careful about it.
2026-08-14 12:40:19 +02:00
Andrew Kelley e0f7e43a54 build system: rework user input options
followups from 8e48a5c524 along with
other related changes.

- user input options should not be serialized into Configuration.
- more helpful log messages when invalid -D arguments are provided
- use array hash maps in various places, simplifying iteration and
  sorting.
- when creating a package instance, sort the user input options once,
  before the lookup, rather than creating a fresh hash map and sorting
  it on every call to hash (wtf!)
  - when sorting, don't use ascii case insensitivity (wtf!!)
- simplify the detection of invalid arguments passed to zig build
- use package hash rather than file system path in package instance key
2026-08-13 23:40:03 -07:00
Andrew Kelley e82505d5dc std.Build.Configuration: rename PackageInstance to Package.Instance 2026-08-13 23:40:03 -07:00
hemisputnik e98205bd17 std.Build.Configuration: serialize package instance public modules 2026-08-10 11:20:46 +03:00
hemisputnik 3d50222f9b std.Build.Configuration: reintroduce serialization of std.Build instances 2026-08-10 11:20:19 +03:00
hemisputnik 27bf90f12b std.Build.Configuration: use IndexType where appropriate 2026-08-10 11:17:07 +03:00
Andrew Kelley 8380531aec Merge pull request 'Serialize packages and root dependencies into configuration file' (#36419) from hemisputnik/zig:work/36387-configuration-deps into master
Reviewed-on: https://codeberg.org/ziglang/zig/pulls/36419
Reviewed-by: Andrew Kelley <andrew@ziglang.org>
2026-08-08 21:48:00 +02:00
hemisputnik 0f332fd536 std.Build.Configuration: serialize packages and their dependencies
The serializer now traverses the builder's available_deps and their
dependencies recursively, and serializes them into Configuration.packages.
2026-08-08 09:02:31 +03:00
Andrew Kelley 127e2d8088 ability to forward third party integration arguments to child processes
This provides a way to forward, e.g. the `-fqemu` argument from
`zig build` to a child process during Maker execution without providing
the information to the configuration logic.
2026-08-07 11:19:55 -07:00
Techatrix cbf00af868 std.Build: remove unused libc flag from compile step
Whether libc and libcpp need to be linked is resolved on the maker side
in `Maker/Step/Compile.zig`.
2026-08-06 19:54:20 +02:00
hemisputnik 800fc5d25a std.Build.Configuration: use inline else to simplify long switches 2026-08-05 21:46:56 +03:00
Krzysztof Wolicki ab4028d579 Update usages of most deprecated APIs
In particular renames of `std.mem.indexOf` family to `std.mem.find`
and generic unmanaged containers
2026-08-05 03:40:30 +02:00
Techatrix 988613be67 std.Build.Configuration: improve storage of preopens in run steps 2026-08-04 19:48:09 +02:00
Bernard Assan 8523ee09ae Implement Meson ConfigHeader support
updated PR for the new build system changes

add standalone tests for meson config_header

Signed-off-by: Bernard Assan <mega.alpha100@gmail.com>
2026-08-02 06:32:19 +02:00
Andrew Kelley ae4e835a66 std.lang: rename OptimizeMode to Optimize
and remove "release" from the enum tag names.

no functional change, however, despite the addition of
backwards-compatibile declarations in this patch, it is breaking because
expressions that use `==` or `!=` operators will not able to use the
deprecated names.

I predict these names to survive until the 1.0 tag without any more
breakage.
2026-07-20 17:26:50 -07:00
Justus Klausecker 69a26976ed zig fmt
Converts usages of `@intFromEnum` and `@enumFromInt` to instead use the
new `@backingInt` and `@fromBackingInt` builtins.
2026-07-17 23:30:26 +02:00
Alex Rønne Petersen 164578636c std.Target: add switch (Nintendo Switch) Os tag
contributes to https://codeberg.org/ziglang/zig/issues/31341
2026-07-07 15:34:40 +02:00
Krzysztof Wolicki 8219c86100 std.Target: add ashetos tag (#35954)
Reviewed-on: https://codeberg.org/ziglang/zig/pulls/35954
2026-07-07 15:19:20 +02:00
Andrew Kelley 779b6cc63c Maker: partially implement configurer cache invalidation
progress towards #35473
2026-06-29 23:50:20 -07:00
Andrew Kelley 98854a673e Maker: it's compiling again 2026-06-29 23:50:19 -07:00
Andrew Kelley 0c978ba957 WIP: migrate build and fetch commands to Maker process 2026-06-29 23:50:18 -07:00
Andrew Kelley a04f90c35b introduce std.Build API for making configure script depend on fs 2026-06-29 23:50:18 -07:00
Andrew Kelley cd3288a3f6 Merge pull request 'Coff linker enhancements, new linker testing framework, and COFF objdump implementation' (#35674) from kcbanner/zig:coff_linker_wip into master
Reviewed-on: https://codeberg.org/ziglang/zig/pulls/35674
Reviewed-by: Jacob Young <jacobly@ziglang.org>
Reviewed-by: Andrew Kelley <andrew@ziglang.org>
2026-06-25 19:20:51 +02:00