724 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 9df8804bf4 compiler: use -ffunction-sections by default on LLVM targets with short branches 2026-10-26 11:02:42 +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
Alex Rønne Petersen 457e906bb3 build: add -Dskip-cbe option for skipping CBE tests 2026-10-23 11:04:37 +02:00
Jacob Young 6148ec9f43 test/llvm: combine test-llvm-ir and test-llvm-targets
The IR tests should be run on the same target matrix anyway.
2026-10-21 10:05:31 -07:00
Jacob Young 3cc4f2f0dc test/llvm-targets: convert to new runner 2026-10-21 10:05:31 -07:00
Jacob Young 1157dd9571 test/llvm-ir: convert to new runner 2026-10-21 10:05:30 -07:00
Jacob Young 809fcd4910 test/Runner: support more syntax for command contents 2026-10-21 10:05:29 -07: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
Matthew Lugg f67c5e92fc build.zig: add file/directory dependencies searching for config.h 2026-10-19 18:30:35 +01:00
Andrew Kelley 722aa2a8ab Revert "build.zig: enable debug extensions if optimize is null"
This reverts commit 40fd34fe7b.

This should have been included also in previous commit.
2026-10-17 12:47:45 -07:00
Andrew Kelley 21141cb88a Revert "allow standardOptimizeOption to return null"
This reverts commit aa8c774e0f.

In retrospect, the breaking change is quite invasive and I don't think
we have fully considered the alternatives.
2026-10-17 12:25:32 -07:00
hixuyuming 093d28dfae Remove deprecated aliases of ArrayList and update usage sites. 2026-10-17 19:29:37 +02:00
rpkak 40fd34fe7b build.zig: enable debug extensions if optimize is null 2026-10-12 10:58:50 +02:00
Alex Rønne Petersen 38c1536b96 test-standalone: respect -Dskip-non-native in cross-compiling tests
closes https://github.com/ziglang/zig/issues/25471
2026-10-10 08:36:08 +02:00
Kendall Condon aa8c774e0f allow standardOptimizeOption to return null
In order to allow the compiler to default to ReleaseSafe when compiling
for fuzzing, Build.standardOptimizeOption has been changed to return an
optional value.
2026-10-09 10:14:16 +02:00
Alex Rønne Petersen 37b8e4fc8f build: update to LLVM 23 2026-10-07 00:30:51 +02:00
Alex Rønne Petersen 5e754304de remove support for wasi-libc
closes https://github.com/ziglang/zig/issues/9342
closes https://github.com/ziglang/zig/issues/15005
closes https://github.com/ziglang/zig/issues/20747
closes https://github.com/ziglang/zig/issues/22570
closes https://codeberg.org/ziglang/zig/issues/30977
2026-10-04 18:23:18 +02:00
Jacob Young 655bee8c75 test: convert debugger tests to new runner 2026-10-02 09:10:10 -04:00
Andrew Kelley a6c6412a8f start the 0.18.0 release cycle 2026-10-01 14:59:12 -07:00
Jacob Young b6f68ca4ba Runner: implement cbe backend 2026-09-26 19:08:50 -04:00
Jacob Young ec261c5e8d test-incremental: convert tests to new format 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 4cfd256330 build.zig: metadata dependency on .git/logs/HEAD 2026-09-16 13:12:47 -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
Alex Rønne Petersen e771c6d66a build: bump test-c-abi max_rss to 4_300_000_000
error: memory usage peaked at 4.16GB (4164247552 bytes), exceeding the declared upper bound of 3.30GB (3300000000 bytes)
2026-09-05 16:27:19 +02:00
Alex Rønne Petersen 6493a3b831 build: bump test-libc-nsz max_rss to 4_300_000_000
error: memory usage peaked at 4.16GB (4156260352 bytes), exceeding the declared upper bound of 3.50GB (3500000000 bytes)
2026-09-05 16:27:17 +02:00
Alex Rønne Petersen 8a3fc2fecf build: bump maxrss for test-std to 9_600_000_000
Seen on an AmpereOne A192-32X.
2026-09-04 05:28:23 +02:00
Alex Rønne Petersen 6534993573 test-link: respect various skip options properly
Also use the smarter isNative() function.
2026-08-30 09:00:59 +02:00
Alex Rønne Petersen ceca6cca16 test-incremental: respect -Dskip-non-native and other similar options 2026-08-30 08:46:46 +02:00
K4 2c93c6e91b std.lang.OptimizeMode -> std.lang.Optimize migration progress 2026-08-23 14:30:48 +02:00
Pavel Verigo 23541774d6 wasm: enable incremental tests for selfhosted
Closes #31810
2026-08-16 19:01:56 +02:00
Alex Rønne Petersen ad120ff12f test: refine the list of targets that get run in stack/error trace tests
Stack trace tests now run for most of the targets that we build module tests
for. However, we omit explicit targets that have no meaningful way of executing
on a non-native platform - whether through an emulator or 32-bit compatibility
layer. (There's no point building them if we cannot run them.) We also omit soft
float targets because there's nothing about float ABI that would affect stack
tracing. Finally, we currently omit Thumb targets because it turns out the stack
trace code does not work well at all on Thumb, and fixing this will likely
require us to implement ARM EHABI unwinding (#30931).

Error trace tests run on an even further reduced set of targets because we don't
care if libc is linked for those. Thumb is enabled here, though, since error
tracing seems unaffected by the aforementioned issue.

Also make these tests respect the various build options.

As far as CI goes, x86_64-linux will run the full set of tests (modulo
-Dtest-extra-targets) while all other machines only run native-compatible tests.
2026-08-10 22:19:02 +02:00
Alex Rønne Petersen 6ee0ef96fe build: bump max_rss of test-unit to 3_000_000_000
error: memory usage peaked at 2.74GB (2744430592 bytes), exceeding the declared upper bound of 2.70GB (2700000000 bytes)
2026-08-01 19:13:10 +02:00
Ennui Langeweile b6361fa84a Enable extended-const extension in stage1
Considering Debian 12 has Binaryen 108, we can now remove the explicit exclusion of `extended-const` (v107).
2026-07-30 19:06:55 +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
Isaac Freund b2c3c33eef build: check if parser oracle must be regenerated 2026-07-08 15:49:43 +02:00
Isaac Freund 06b1896a61 build: add gen-parser-oracle step 2026-07-08 15:49:43 +02:00
Isaac Freund 8229720726 langref: move grammar.peg to separate file
This improves the developer experience, especially with the new
gen_parser_oracle tool. My intent is for doc/langref/grammar.peg
to be the single source of truth, at least until we have an actual
language spec.

The separate copy in the separate zig-spec repo should not be considered
canonical as it is not tested against by CI.
2026-07-08 11:48:57 +02:00
Jacob Young 580135241b build: update how changing the currently checked out commit is detected
Add support for building from a git worktree.

Previously, the compiler configure script was only rerun on changing
which branch is currently checked out. Now, any changes to the `HEAD`
reflog will be detected, which, happens to contain the commit hash of
the currently checked out commit on the last line, so will necessarily
have unique contents for any given commit. While there could be false
negatives due to the reflog being cleaned after a couple months, this
is not only unlikely to actually occur, involving a specific series
of steps over the course of a third of a year, the end result is that
the compiled compiler reports the wrong version, and can easily be
fixed by simply e.g. changing to another commit and back, something
which developers already frequently do. Additionally, the alternative
of having to hash longer and longer reflogs to detect a change on the
last line would hardly be preferable.
2026-06-30 21:41:44 -04:00
Andrew Kelley 779b6cc63c Maker: partially implement configurer cache invalidation
progress towards #35473
2026-06-29 23:50:20 -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
Andrew Kelley b52a2ff73b build: compiler no longer depends on aro module
Thanks to 0b22111bc9 there is no more
`@import("aro")`.
2026-06-24 20:09:42 +02:00
kcbanner 411e5099e5 link: remove debug_link_snapshots in favour of enable_debug_extensions
MappedFile: use opts struct for realign
Coff: fixup not reserving enough string capacity in loadObject
2026-06-23 00:27:18 -04:00
kcbanner ab46b82354 test: Starting work on the new linker tests 2026-06-23 00:26:57 -04:00
xtex 2dca73595f build: use new linker if both new-linker and use-llvm are true 2026-06-22 01:44:45 +02:00
Ali Cheraghi 3a48f4bb40 spirv: drive capability and extension emission from target features
- Emitting `OpCapability` and `OpExtension` from assembly is no longer allowed (tbh it never was because we silently ignored them).
  They now `fail` with a message pointing users at `-mcpu`.

- `tools/gen_spirv_spec.zig` now also emits `Extension` and the `Capability.dependencies()`.
  Also To keep the feature set a reasonable size, the generator filters to an allowlist of `KHR` and `EXT` entries.
  We can decide which vendors to allow later if a use-case is found.

- `tools/update_cpu_features.zig` now uses the generated `spec.zig` and emits a  feature for every
  capability and extension, with the capability's `.deps` populated from `Capability.dependencies()`.

- `Module.finalize`, `Module.entryPoints`, `Module.addCapability`, `Module.addExtension`
  and `sections.capabilities`/`sections.extensions` are deleted.

- Linker now verifies that an `.spv` object declares the `Linkage` capability
2026-06-20 09:38:20 +02:00
Arthur Teixeira 0b22111bc9 MinGW: remove dependency on a C preprocessor for MinGW .def.in files (#35679)
closes #31955

Reviewed-on: https://codeberg.org/ziglang/zig/pulls/35679
Reviewed-by: Ryan Liptak <squeek502@noreply.codeberg.org>
2026-06-18 00:01:17 +02:00