aboutsummaryrefslogtreecommitdiff
path: root/src
AgeCommit message (Collapse)Author
2025-02-06x86_64: rewrite vector `@truncate`Jacob Young
2025-02-06x86_64: rewrite scalar `@truncate`Jacob Young
2025-02-06std.process: adding hasNonEmptyEnvVar() and using for NO_COLORJohn Benediktsson
2025-02-06incremental: codegen types which are recreatedmlugg
Unfortunately, I can't easily add a test for this, because the repro depends on some details of DWARF layout; but I've confirmed that it fixes a bug repro on another branch.
2025-02-06Sema: add missing `validateRuntimeValue` callsmlugg
Resolves: #13791
2025-02-06Merge pull request #19614 from jedisct1/wasi-libc-updateAlex Rønne Petersen
Update wasi-libc to d03829489904d38c624f6de9983190f1e5e7c9c5
2025-02-05incremental: fix crash when introducing syntax errormlugg
Clearing the analysis roots was very clever and all, but not actually valid. We need to avoid *any* reference to the analysis errors if there were any fatal files, and that includes sorting the errors! Resolves: #22774
2025-02-05Sema: fix `@typeInfo` of function with generic return type and IESmlugg
Resolves: #20088
2025-02-05Sema: fix `@errorCast` with error unionsmlugg
Resolves: #20169
2025-02-05Sema: disable runtime safety checks in comptime blocksmlugg
Sometimes we emit runtime instructions in comptime scopes. These instructions will be discarded, but they allow comptime blocks to contain intermediate runtime-known values, which is necessary for expressions like `runtime_array.len` to work. Since we will always throw away these runtime instructions, including safety checks is a time waste at best and trips an assertion at worst! Resolves: #20064
2025-02-05Sema: fix comparison between error set and comptime-known error unionmlugg
Resolves: #20613
2025-02-05Sema: add fast path to PTR when all types are the samemlugg
I have no idea why I didn't add this when I first implemented this PTR logic.
2025-02-05Sema: fix PTR of slice of sentinel-terminated arraymlugg
Resolves: #20901
2025-02-05compiler: provide result type to sentinel expression in slice operationmlugg
Resolves: #21867
2025-02-05Sema: fix crash on `@tagName` of undefined enum literalmlugg
Resolves: #20826
2025-02-05Sema: fix incorrectly succeeding type resolutionmlugg
Resolves: #21436
2025-02-04Zcu: fix bug clearing compile errorsmlugg
And add an assertion in safe builds that our initial check is actually correct.
2025-02-04compiler: integrate importing ZON with incremental compilationmlugg
The changes from a few commits earlier, where semantic analysis no longer occurs if any Zig files failed to lower to ZIR, mean `file` dependencies are no longer necessary! However, we now need them for ZON files, to be invalidated whenever a ZON file changes.
2025-02-04compiler: integrate ZON with the ZIR caching systemmlugg
This came with a big cleanup to `Zcu.PerThread.updateFile` (formerly `astGenFile`). Also, change how the cache manifest works for files in the import table. Instead of being added to the manifest when we call `semaFile` on them, we iterate the import table after running the AstGen workers and add all the files to the cache manifest then. The downside is that this is a bit more eager to include files in the manifest; in particular, files which are imported but not actually referenced are now included in analysis. So, for instance, modifying any standard library file will invalidate all Zig compilations using that standard library, even if they don't use that file. The original motivation here was simply that the old logic in `semaFile` didn't translate nicely to ZON. However, it turns out to actually be necessary for correctness. Because `@import("foo.zig")` is an AstGen-level error if `foo.zig` does not exist, we need to invalidate the cache when an imported but unreferenced file is removed to make sure this error is triggered when it needs to be. Resolves: #22746
2025-02-04compiler: a few renamesmlugg
This is mainly in preparation for integrating ZonGen into the pipeline properly, although these names are better because `astGenFile` isn't *necessarily* running AstGen; it may determine that the current ZIR is up-to-date, or load cached ZIR.
2025-02-04compiler: don't perform semantic analysis if there are files without ZIRmlugg
2025-02-04Zcu: remove unused `parse_failure` field from `File.Status`mlugg
These are reported as `astgen_failure` instead.
2025-02-04Zcu: remove `*_loaded` fields on `File`mlugg
Instead, `source`, `tree`, and `zir` should all be optional. This is precisely what we're actually trying to model here; and `File` isn't optimized for memory consumption or serializability anyway, so it's fine to use a couple of extra bytes on actual optionals here.
2025-02-03compiler,std: implement ZON supportMason Remaley
This commit allows using ZON (Zig Object Notation) in a few ways. * `@import` can be used to load ZON at comptime and convert it to a normal Zig value. In this case, `@import` must have a result type. * `std.zon.parse` can be used to parse ZON at runtime, akin to the parsing logic in `std.json`. * `std.zon.stringify` can be used to convert arbitrary data structures to ZON at runtime, again akin to `std.json`.
2025-02-02fix: error on non-exhaustive enums with zero width backing type (#21374)Will Lillis
Co-authored-by: WillLillis <wlillis@umass.edu>
2025-02-01Merge pull request #22672 from jacobly0/x86_64-rewriteAndrew Kelley
x86_64: rewrite float conversions
2025-02-01compiler: do not propagate result type to `try` operandmlugg
This commit effectively reverts 9e683f0, and hence un-accepts #19777. While nice in theory, this proposal turned out to have a few problems. Firstly, supplying a result type implicitly coerces the operand to this type -- that's the main point of result types! But for `try`, this is actually a bad idea; we want a redundant `try` to be a compile error, not to silently coerce the non-error value to an error union. In practice, this didn't always happen, because the implementation was buggy anyway; but when it did, it was really quite silly. For instance, `try try ... try .{ ... }` was an accepted expression, with the inner initializer being initially coerced to `E!E!...E!T`. Secondly, the result type inference here didn't play nicely with `return`. If you write `return try`, the operand would actually receive a result type of `E!E!T`, since the `return` gave a result type of `E!T` and the `try` wrapped it in *another* error union. More generally, the problem here is that `try` doesn't know when it should or shouldn't nest error unions. This occasionally broke code which looked like it should work. So, this commit prevents `try` from propagating result types through to its operand. A key motivation for the original proposal here was decl literals; so, as a special case, `try .foo(...)` is still an allowed syntax form, caught by AstGen and specially lowered. This does open the doors to allowing other special cases for decl literals in future, such as `.foo(...) catch ...`, but those proposals are for another time. Resolves: #21991 Resolves: #22633
2025-02-01Sema: skip aliasing check and runtime operation for `@memcpy` of zero-bit typemlugg
This check isn't valid in such cases, because the source and destination pointers both refer to zero bits of memory, meaning they effectively never alias. Resolves: #21655
2025-02-01Sema: fix `@splat` of OPV arraysmlugg
2025-01-31x86_64: rewrite vector `@intCast`Jacob Young
2025-01-31x86_64: rewrite scalar `@intCast`Jacob Young
2025-01-31x86_64: rewrite float vector conversionsJacob Young
2025-01-31Sema: introduce all_vector_instructions backend featureJacob Young
Sema is arbitrarily scalarizing some operations, which means that when I try to implement vectorized versions of those operations in a backend, they are impossible to test due to Sema not producing them. Now, I can implement them and then temporarily enable the new feature for that backend in order to test them. Once the backend supports all of them, the feature can be permanently enabled. This also deletes the Air instructions `int_from_bool` and `int_from_ptr`, which are just bitcasts with a fixed result type, since changing `un_op` to `ty_op` takes up the same amount of memory.
2025-01-31x86_64: rewrite scalar float conversionsJacob Young
2025-01-30compiler: add `intcast_safe` AIR instructionmlugg
This instruction is like `intcast`, but includes two safety checks: * Checks that the int is in range of the destination type * If the destination type is an exhaustive enum, checks that the int is a named enum value This instruction is locked behind the `safety_checked_instructions` backend feature; if unsupported, Sema will emit a fallback, as with other safety-checked instructions. This instruction is used to add a missing safety check for `@enumFromInt` truncating bits. This check also has a fallback for backends which do not yet support `safety_checked_instructions`. Resolves: #21946
2025-01-30main: accept and ignore auto-image-base linker optionsAlex Rønne Petersen
Closes #19613.
2025-01-30main: ensure --whole-archive is passed down to linker for -l argumentsAman Karmani
fixes #21971
2025-01-30main: better error message if the global cache dir is unusableachan1989
Fixes #19400
2025-01-29x86_64: rewrite comparisonsJacob Young
2025-01-29Sema: explain why we tried to call an `extern fn` at comptimemlugg
I recently saw a user hit the "comptime call of extern function" error, and get confused because they didn't know why the scope was `comptime`. So, use `explainWhyBlockIsComptime` on this and related errors to add all the relevant notes. The added test case shows the motivating situation.
2025-01-29Add libdl shims from wasi-libcFrank Denis
2025-01-29Re-add lazy preopen changesFrank Denis
2025-01-29Update wasi-libc to d03829489904d38c624f6de9983190f1e5e7c9c5Frank Denis
2025-01-29fix(cc): make link and preprocessor logic to be more consistent withzhylmzr
clang's behavior. 1. `zig cc main.c -o /dev/null` shouldn't emit a.out 2. `zig cc -E main.c` and `zig cc -E main -o -` should output to stdout
2025-01-29Sema: `@memcpy` changesmlugg
* The langspec definition of `@memcpy` has been changed so that the source and destination element types must be in-memory coercible, allowing all such calls to be raw copying operations, not actually applying any coercions. * Implement aliasing check for comptime `@memcpy`; a compile error will now be emitted if the arguments alias. * Implement more efficient comptime `@memcpy` by loading and storing a whole array at once, similar to how `@memset` is implemented.
2025-01-27frontend: use main Compilation code_model when building libxxAndrew Kelley
as well as libtsan, libunwind, and libc files
2025-01-27Merge pull request #22610 from jacobly0/x86_64-rewriteAndrew Kelley
x86_64: rewrite `@min`/`@max` for scalar floats
2025-01-27main: classify empty environment variables as unsetCarter Snook
This matches existing well-specified conventions for e.g. NO_COLOR. Closes #22380.
2025-01-26fix: Only suggest try on destructure of error union if payload type can be ↵Will Lillis
destructured (#21510)
2025-01-26x86_64: rewrite `@min`/`@max` for float vectorsJacob Young