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.
* 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`
In order to allow the compiler to default to ReleaseSafe when compiling
for fuzzing, Build.standardOptimizeOption has been changed to return an
optional value.
- 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
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.
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.
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.
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.
- 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