aboutsummaryrefslogtreecommitdiff
path: root/src
AgeCommit message (Collapse)Author
2025-03-30Sema: convert slice sentinel to single pointer correctlyDavid Rubin
2025-03-29Zcu: resolve layout of analyzed declaration typemlugg
Resolves: #19888
2025-03-29compiler: "illegal behavior", not "undefined behavior", in errorsmlugg
2025-03-27std.Build: implement addEmbedPath for adding C #embed search directoriesGalaxyShard
2025-03-27std.meta.FieldType -> @FieldTypeАндрей Краевский
2025-03-26zig build: allow to choose "lazy mode" for fetching processEric Joldasov
`--fetch` flag now has additional optional parameter, which specifies how lazy dependencies should be fetched: * `needed` — lazy dependencies are fetched only if they are required for current build configuration to work. Default and works same as old `--fetch` flag. * `all` — lazy dependencies are always fetched. If `--system` flag is used after that, it's guaranteed that **any** build configuration will not require additional download of dependencies during build. Helpful for distro packagers and CI systems: https://www.github.com/ziglang/zig/issues/14597#issuecomment-1426827495 If none is passed, behaviour is same as if `needed` was passed. Signed-off-by: Eric Joldasov <bratishkaerik@landless-city.net>
2025-03-26Zcu: include named tests in resolved referencesmlugg
Oops, a little typo from yours truly! No test for this one, because we don't have any way of testing the reference trace.
2025-03-25Merge pull request #23310 from Rexicon226/fix-23309Alex Rønne Petersen
big.int: return normalized results from `{add,sub}Carry`
2025-03-25Merge pull request #23007 from rootbeer/posix-eaccess-epermAlex Rønne Petersen
lib/std: Make usage of PermissionDenied & AccessDenied consistent
2025-03-24Sema: use unwrapped generic owner in `getFuncInstanceIes`David Rubin
2025-03-24lib/std: PermissionDenied/AccessDenied cleanup and falloutPat Tullmann
This PR consistently maps .ACCES into AccessDenied and .PERM into PermissionDenied. AccessDenied is returned if the file mode bit (user/group/other rwx bits) disallow access (errno was `EACCES`). PermissionDenied is returned if something else denies access (errno was `EPERM`) (immutable bit, SELinux, capabilities, etc). This somewhat subtle distinction is a POSIX thing. Most of the change is updating std.posix Error Sets to contain both errors, and then propagating the pair up through caller Error Sets. Fixes #16782
2025-03-24stage2-wasm: packed store/load 128 bitsPavel Verigo
2025-03-24stage2-wasm: behavior tests pass with ReleaseFast/SmallPavel Verigo
2025-03-24stage2-wasm: pass field_parent_ptr testsPavel Verigo
Handle packed containers, also fixes packed union lowering for non int type + union field pointer logic fix
2025-03-24stage2-wasm: enable undef test + ignore undef store/memset with safety offPavel Verigo
2025-03-24stage2-wasm: fix error union handlingPavel Verigo
2025-03-24stage2-wasm: clean memcpy + fix another bug in aggr_init for optionals arrPavel Verigo
2025-03-24stage2-wasm: clz fixPavel Verigo
2025-03-24stage2-wasm: fix comparing and storing optionalsPavel Verigo
2025-03-24big.int: return normalized results from `{add,sub}Carry`David Rubin
2025-03-24Use `-unknown` when converting WASI/Emscripten target triples into LLVM triplesCarl Åstholm
The "musl" part of the Zig target triples `wasm32-wasi-musl` and `wasm32-emscripten-musl` refers to the libc, not really the ABI. For WASM, most LLVM-based tooling uses `wasm32-wasi`, which is normalized into `wasm32-unknown-wasi`, with an implicit `-unknown` and without `-musl`. Similarly, Emscripten uses `wasm32-unknown-emscripten` without `-musl`. By using `-unknown` instead of `-musl` we get better compatibility with external tooling.
2025-03-24Sema: fix in-memory coercion of functions introducing new generic parametersmlugg
While it is not allowed for a function coercion to change whether a function is generic, it *is* okay to make existing concrete parameters of a generic function also generic, or vice versa. Either of these cases implies that the result is a generic function, so comptime type checks will happen when the function is ultimately called. Resolves: #21099
2025-03-23Merge pull request #23209 from jacobly0/x86_64-rewriteJacob Young
x86_64: rewrite wrapping multiplication
2025-03-23Merge pull request #23256 from xtexx/fix-gh-20113Jacob Young
x86_64: fix packedStore miscomp by spilling EFLAGS
2025-03-23codegen: fix packed byte-aligned relocationsJacob Young
Closes #23131
2025-03-23Lower `@returnAddress` to a constant 0 in Emscripten release buildsCarl Åstholm
Emscripten currently implements `emscripten_return_address()` by calling out into JavaScript and parsing a stack trace, which introduces significant overhead that we would prefer to avoid in release builds. This is especially problematic for allocators because the generic parts of `std.mem.Allocator` make frequent use of `@returnAddress`, even though very few allocator implementations even observe the return address, which makes allocators nigh unusable for performance-critical applications like games if the compiler is unable to devirtualize the allocator calls.
2025-03-22link: mark prelink tasks as procesed under `-fno-emit-bin`mlugg
The old logic only decremented `remaining_prelink_tasks` if `bin_file` was not `null`. This meant that on `-fno-emit-bin` builds with registered prelink tasks (e.g. C source files), we exited from `Compilation.performAllTheWorkInner` early, assuming a prelink error. Instead, when `bin_file` is `null`, we still decrement `remaining_prelink_tasks`; we just don't do any actual work. Resolves: #22682
2025-03-22x86_64: fix rare miscomp that clobbers memoryJacob Young
2025-03-22x86_64: fix packedStore miscomp by spilling EFLAGSBingwu Zhang
Fixes #20113 and #20581. AND instructions in packedStore clobbers EFLAGS. Bug: https://github.com/ziglang/zig/issues/20113 Bug: https://github.com/ziglang/zig/issues/20581 Signed-off-by: Bingwu Zhang <xtex@aosc.io>
2025-03-21x86_64: rewrite scalar shiftsJacob Young
2025-03-21x86_64: rewrite wrapping multiplicationJacob Young
2025-03-21big.int: fix yet another truncate bugJacob Young
Too many bugs have been found with `truncate` at this point, so it was rewritten from scratch. Based on the doc comment, the utility of `convertToTwosComplement` over `r.truncate(a, .unsigned, bit_count)` is unclear and it has a subtle behavior difference that is almost certainly a bug, so it was deleted.
2025-03-19spirv: Assemble OpTypeRuntimeArray.dan
2025-03-19compiler: Support more GCC code models and fix the mapping to LLVM code models.Alex Rønne Petersen
Closes #22517.
2025-03-18Merge pull request #23158 from alichraghi/ali_spirvRobin Voetter
spirv: miscellaneous stuff #2
2025-03-18mingw: Rename mingw32.lib to libmingw32.lib.Alex Rønne Petersen
LLD expects the library file name (minus extension) to be exactly libmingw32. By calling it mingw32 previously, we prevented it from being detected as being in LLD's list of libraries that are excluded from the MinGW-specific auto-export mechanism. https://github.com/llvm/llvm-project/blob/b9d27ac252265839354fffeacaa8f39377ed7424/lld/COFF/MinGW.cpp#L30-L56 As a result, a DLL built for *-windows-gnu with Zig would export a bunch of internal MinGW symbols. This sometimes worked out fine, but it could break at link or run time when linking an EXE with a DLL, where both are targeting *-windows-gnu and thus linking separate copies of mingw32.lib. In #23204, this manifested as the linker getting confused about _gnu_exception_handler() because it was incorrectly exported by the DLL while also being defined in the mingw32.lib that was being linked into the EXE. Closes #23204.
2025-03-18spirv: require int8/int16 capabilitiesAli Cheraghi
2025-03-18spirv: aligned load for physical storage variablesAli Cheraghi
Resolves #23212
2025-03-18spirv: packed struct init + field val accessAli Cheraghi
2025-03-17spirv/target: arbitrary_precision_integers feature supportAli Cheraghi
2025-03-17spirv: lower more types in assemblerAli Cheraghi
2025-03-17target: split `addresses` and `physical_storage_buffer` featuresAli Cheraghi
2025-03-17Sema: error on illegal code when targeting spirvAli Cheraghi
2025-03-17spirv: don't hardcode test error type alignmentAli Cheraghi
2025-03-16Sema: rewrite comptime arithmeticmlugg
This commit reworks how Sema handles arithmetic on comptime-known values, fixing many bugs in the process. The general pattern is that arithmetic on comptime-known values is now handled by the new namespace `Sema.arith`. Functions handling comptime arithmetic no longer live on `Value`; this is because some of them can emit compile errors, so some *can't* go on `Value`. Only semantic analysis should really be doing arithmetic on `Value`s anyway, so it makes sense for it to integrate more tightly with `Sema`. This commit also implements more coherent rules surrounding how `undefined` interacts with comptime and mixed-comptime-runtime arithmetic. The rules are as follows. * If an operation cannot trigger Illegal Behavior, and any operand is `undefined`, the result is `undefined`. This includes operations like `0 *| undef`, where the LHS logically *could* be used to determine a defined result. This is partly to simplify the language, but mostly to permit codegen backends to represent `undefined` values as completely invalid states. * If an operation *can* trigger Illegal Behvaior, and any operand is `undefined`, then Illegal Behavior results. This occurs even if the operand in question isn't the one that "decides" illegal behavior; for instance, `undef / 1` is undefined. This is for the same reasons as described above. * An operation which would trigger Illegal Behavior, when evaluated at comptime, instead triggers a compile error. Additionally, if one operand is comptime-known undef, such that the other (runtime-known) operand isn't needed to determine that Illegal Behavior would occur, the compile error is triggered. * The only situation in which an operation with one comptime-known operand has a comptime-known result is if that operand is undefined, in which case the result is either undefined or a compile error per the above rules. This could potentially be loosened in future (for instance, `0 * rt` could be comptime-known 0 with a runtime assertion that `rt` is not undefined), but at least for now, defining it more conservatively simplifies the language and allows us to easily change this in future if desired. This commit fixes many bugs regarding the handling of `undefined`, particularly in vectors. Along with a collection of smaller tests, two very large test cases are added to check arithmetic on `undefined`. The operations which have been rewritten in this PR are: * `+`, `+%`, `+|`, `@addWithOverflow` * `-`, `-%`, `-|`, `@subWithOverflow` * `*`, `*%`, `*|`, `@mulWithOverflow` * `/`, `@divFloor`, `@divTrunc`, `@divExact` * `%`, `@rem`, `@mod` Other arithmetic operations are currently unchanged. Resolves: #22743 Resolves: #22745 Resolves: #22748 Resolves: #22749 Resolves: #22914
2025-03-16Sema: correctly handle empty by-ref initializersmlugg
Resolves: #23210
2025-03-15posix/write: catch MSGSIZE error (#23238)Rémy Mathieu
2025-03-12Merge pull request #22397 from Techatrix/type-safe-astMatthew Lugg
improve type safety of std.zig.Ast
2025-03-11Zcu: rename `skip_analysis_errors` to `skip_analysis_this_update` and respect itmlugg
On updates with failed files, we should refrain from doing any semantic analysis, or even touching codegen/link. That way, incremental compilation state is untouched for when the user fixes the AstGen errors. Resolves: #23205
2025-03-11Merge pull request #23188 from jacobly0/fix-23143Andrew Kelley
x86_64: fix crashes with symbols