aboutsummaryrefslogtreecommitdiff
path: root/src
AgeCommit message (Collapse)Author
2025-11-20system specific errnorpkak
2025-11-20update deprecated ArrayListUnmanaged usage (#25958)Benjamin Jurk
2025-11-20Merge pull request #25780 from Vexu/translate-cAndrew Kelley
Update Aro and translate-c to latest
2025-11-20Merge pull request #25981 from mlugg/macos-fuzz-2Matthew Lugg
make the fuzzer vaguely work on macOS
2025-11-20Merge pull request #25898 from jacobly0/elfv2-progressAndrew Kelley
Elf2: more progress
2025-11-20update Aro and translate-c to latestVeikka Tuominen
2025-11-20std.debug: split up Mach-O debug info handlingMatthew Lugg
Like ELF, we now have `std.debug.MachOFile` for the host-independent parts, and `std.debug.SelfInfo.MachO` for logic requiring the file to correspond to the running program.
2025-11-19Elf2: revert incorrect endian fixJacob Young
2025-11-19Merge pull request #25965 from alexrp/s390xAlex Rønne Petersen
`s390x-linux` and general big-endian stuff
2025-11-19compiler: fix crash if file contents change during updateMatthew Lugg
When reporting a compile error, we would load the new file, but assume we could apply old AST/token indices (etc) to it, potentially causing crashes. Instead, if the file stat has changed since it was loaded, just emit an error that the file was modified mid-update.
2025-11-19compiler: don't use self-hosted backends on big-endian hostsAlex Rønne Petersen
https://github.com/ziglang/zig/issues/25961
2025-11-19llvm: fix lowering of packed struct constantsMatthew Lugg
The big-endian logic here was simply incorrect. Luckily, it was also overcomplicated; after calling `Value.writeToPackedMemory`, there is a method on `std.math.big.int.Mutable` which just does the correct endianness load for us.
2025-11-18cbe: fix big-endian unnatural integer bitcastMatthew Lugg
Integers with padding bits on big-endian targets cannot quite be bitcast with a trivial memcpy, because the padding bits (which are zext or sext) are the most-significant, so are at the *lowest* addresses. So to bitcast to something which doesn't have padding bits, we need to offset past the padding. The logic I've added here definitely doesn't handle all possibilities correctly; I think that would actually be quite complicated. However, it handles a common case, and so prevents the Zig compiler itself from being miscompiled on big-endian targets (hence fixing a bootstrapping problem on big-endian).
2025-11-17sema: fix UAF in type mismatch errorxdBronch
2025-11-16sema: improve codegen of for loop safety checksxdBronch
2025-11-16Merge pull request #25929 from alexrp/maccatalystAlex Rønne Petersen
`std.zig.target`: support `aarch64-maccatalyst` and `x86_64-maccatalyst` cross libc
2025-11-16Dedupe types when printing error messagesProkop Randáček
2025-11-16improve assembly error test coveragexdBronch
2025-11-15Merge pull request #25936 from Traxar/masterAndrew Kelley
Add some missing features to `std.Io.Timestamp` and `spirv/CodeGen.zig`
2025-11-15Legalize: implement soft-float legalizationsMatthew Lugg
A new `Legalize.Feature` tag is introduced for each float bit width (16/32/64/80/128). When e.g. `soft_f16` is enabled, all arithmetic and comparison operations on `f16` are converted to calls to the appropriate compiler_rt function using the new AIR tag `.legalize_compiler_rt_call`. This includes casts where the source *or* target type is `f16`, or integer<=>float conversions to or from `f16`. Occasionally, operations are legalized to blocks because there is extra code required; for instance, legalizing `@floatFromInt` where the integer type is larger than 64 bits requires calling an arbitrary-width integer conversion function which accepts a pointer to the integer, so we need to use `alloc` to create such a pointer, and store the integer there (after possibly zero-extending or sign-extending it). No backend currently uses these new legalizations (and as such, no backend currently needs to implement `.legalize_compiler_rt_call`). However, for testing purposes, I tried modifying the self-hosted x86_64 backend to enable all of the soft-float features (and implement the AIR instruction). This modified backend was able to pass all of the behavior tests (except for one `@mod` test where the LLVM backend has a bug resulting in incorrect compiler-rt behavior!), including the tests specific to the self-hosted x86_64 backend. `f16` and `f80` legalizations are likely of particular interest to backend developers, because most architectures do not have instructions to operate on these types. However, enabling *all* of these legalization passes can be useful when developing a new backend to hit the ground running and pass a good amount of tests more easily.
2025-11-15src/codegen/spirv/CodeGen.zig: add missing unary Opstraxar
2025-11-14Sema: fix illegal multi level pointer coercionsJustus Klausecker
Moves a premature check that allowed pointers to mutable pointers to coerce to any other pointer to a mutable pointer.
2025-11-14link.MachO.Dylib: allow maccatalyst output to link macos libraries in TBDsAlex Rønne Petersen
This is the logic that LLD uses. It is pretty silly, but it is what it is.
2025-11-14represent Mac Catalyst as aarch64-maccatalyst-none rather than ↵Alex Rønne Petersen
aarch64-ios-macabi Apple's own headers and tbd files prefer to think of Mac Catalyst as a distinct OS target. Earlier, when DriverKit support was added to LLVM, it was represented a distinct OS. So why Apple decided to only represent Mac Catalyst as an ABI in the target triple is beyond me. But this isn't the first time they've ignored established target triple norms (see: armv7k and aarch64_32) and it probably won't be the last. While doing this, I also audited all Darwin OS prongs throughout the codebase and made sure they cover all the tags.
2025-11-12Merge pull request #25772 from mlugg/kill-dead-codeMatthew Lugg
compiler: rewrite some legalizations, and remove a bunch of dead code
2025-11-12std.Target: remove Abi.cygnusAlex Rønne Petersen
There is approximately zero chance of the Zig team ever spending any effort on supporting Cygwin; the MSVC and MinGW-w64 ABIs are superior in every way that matters, and not least because they lead to binaries that just run natively on Windows without needing a POSIX emulation environment installed.
2025-11-12Sema: fix inline fn compiler crash (#25586)So1aric
Resolves: https://github.com/ziglang/zig/issues/25581
2025-11-12cbe: work around some miscompilationsMatthew Lugg
The changes to `codegen.c` are blatant hacks, but the problem they work around isn't a regression: it's an existing miscompilation. This branch happened to *expose* that miscompilation in more cases by changing how an incorrect result is *used*.
2025-11-12Air.Legalize: revert to loops for scalarizationsMatthew Lugg
I had tried unrolling the loops to avoid requiring the `vector_store_elem` instruction, but it's arguably a problem to generate O(N) code for an operation on `@Vector(N, T)`. In addition, that lowering emitted a lot of `.aggregate_init` instructions, which is itself a quite difficult operation to codegen. This requires reintroducing runtime vector indexing internally. However, I've put it in a couple of instructions which are intended only for use by `Air.Legalize`, named `legalize_vec_elem_val` (like `array_elem_val`, but for indexing a vector with a runtime-known index) and `legalize_vec_store_elem` (like the old `vector_store_elem` instruction). These are explicitly documented as *not* being emitted by Sema, so need only be implemented by backends if they actually use an `Air.Legalize.Feature` which emits them (otherwise they can be marked as `unreachable`).
2025-11-12x86_64: spill eflags when initializing bool vectorMatthew Lugg
2025-11-12compiler: spring cleaningMatthew Lugg
I started this diff trying to remove a little dead code from the C backend, but ended up finding a bunch of dead code sprinkled all over the place: * `packed` handling in the C backend which was made dead by `Legalize` * Representation of pointers to runtime-known vector indices * Handling for the `vector_store_elem` AIR instruction (now removed) * Old tuple handling from when they used the InternPool repr of structs * Straightforward unused functions * TODOs in the LLVM backend for features which Zig just does not support
2025-11-12Legalize: rewrite several legalizationsMatthew Lugg
The main goal of this change was to avoid emitting the `vector_store_elem` AIR tag, because this represents an operation which Zig no longer supports (and hence Sema no longer emits) as of 010d9a6 (because runtime vector indices are now forbidden). Backends should not need to lower this operation, so I rewrote the legalizations which emitted it (scalarizations of vector operations) to instead unroll the loop and hence emit comptime-known vector indices. In doing this, I actually reworked those legalizations to use a different strategy; instead of using an `alloc` and storing to individual vector elements, the vector is constructed by-val, for instance by performing the scalar operation on all elements and passing them to an `aggregate_init`. This is vastly simpler to implement in Legalize, conceptually simpler, and doesn't severely pessimise memory usage, because a non-optimizing backend will store the full vector on the stack either way. Given the above rationale, I also ended up reworking several other legalizations to use simpler lowerings. The legalizations in question were bitcast scalarization, `struct_field_val` of `packed struct`s (where we just bitcast to an integer and perform the appropriate shift/trunc sequence), and `aggregate_init` of a `packed struct` (also implemented in terms of integer bitwise operations with bitcasts to and from the actual types). This hugely simplified some parts of `Legalize`. So, `Legalize` is now much simpler, and the `vector_store_elem` instruction is no longer emitted by any part of the compiler so can be removed in a future commit.
2025-11-11Elf2: implement PLTJacob Young
2025-11-11Elf2: fix relocations against untyped symbolsJacob Young
2025-11-11aarch64: cleanup register lockJacob Young
2025-11-10Merge pull request #25889 from mlugg/incremental-llvm-warnMatthew Lugg
compiler: warn when using -fincremental with LLVM backend
2025-11-10Merge pull request #25886 from alexrp/kvxAlex Rønne Petersen
beginnings of KVX target support (via CBE)
2025-11-10sema: print @panic message at comptimexdBronch
2025-11-10compiler: warn when using -fincremental with LLVM backendMatthew Lugg
This configuration hasn't had much work put into it yet, so is all but guaranteed to miscompile or crash. Since users are starting to try out `-fincremental`, and LLVM is still the default backend in many cases, it's worth having this warning to avoid bug reports like https://github.com/ziglang/zig/issues/25873.
2025-11-10compiler: update logFn to use colorMatthew Lugg
To match the new default implementation. In fact, I implemented this by simply dispatching *to* the default implementation after the debug log guard; no need to complicate things!
2025-11-10llvm: set sub-arch for spirv 1.6Alex Rønne Petersen
2025-11-10cbe: kvx uses $-prefixed registersAlex Rønne Petersen
2025-11-10compiler: kvx requires 8-byte aligned functionsAlex Rønne Petersen
2025-11-10std.Target: add Arch tag and info for kvxAlex Rønne Petersen
2025-11-10Merge pull request #25819 from jacobly0/elfv2-emit-objJacob Young
2025-11-09std.zig.Zir: remove ref_start_index from enum fields of Index and OptionalIndexMateusz Poliwczak
This change removes the ref_start_index from the possible enum values of Index and OptionalIndex. It is not really a index, but a constant that tells the offset of static Refs, so lets move it where such constant belongs i.e. to the Ref.
2025-11-09MappedFile: avoid allocating file space with inconsistent stateJacob Young
2025-11-09Elf2: incrementally update object relocsJacob Young
2025-11-09Elf2: implement object relocsJacob Young
2025-11-09Elf2: elide unused nodes when emitting objectsJacob Young