Commit graph

17061 commits

Author SHA1 Message Date
mlugg
8adabaa4ed Zcu: don't tell linkers about exports if there are compile errors
In the best case, this is redundant work, because we aren't actually
going to emit a working binary this update. In the worst case, it causes
bugs because the linker may not have *seen* the thing being exported due
to the compile errors.

Resolves: #24417
2025-08-15 20:00:30 +01:00
Andrew Kelley
ce2c9399dd zig translate-c: don't forget to flush
fixes #24672
2025-08-15 11:46:17 -07:00
Jacob Young
56d62395d1 aarch64: more assembler instructions
Closes #24848
2025-08-15 06:12:45 -04:00
Will Lillis
e9eee8dace fix: print error set members in a consistent order
Co-authored-by: Matthew Lugg <mlugg@mlugg.co.uk>
2025-08-15 07:43:46 +01:00
Alex Rønne Petersen
27d6614f81
Merge pull request #24825 from alexrp/freebsd-fixes 2025-08-14 01:00:30 +02:00
Matthew Lugg
b87b958687
Merge pull request #24816 from mlugg/small-fixes
two small fixes
2025-08-13 23:55:21 +01:00
mlugg
3736aac778 Dwarf: handle noreturn union fields in more places
A little clunky -- maybe the frontend should give an answer here -- but
this patch makes sense with the surrounding logic just to fix the crash.

Resolves: #24265
2025-08-13 23:52:40 +01:00
Matthew Lugg
a495628862
Merge pull request #24674 from Justus2308/undef-shift-bitwise
Sema: Improve comptime arithmetic undef handling
2025-08-13 14:04:59 +01:00
David Rubin
8e02f9f70d sema: strip @splat operand result type before checking it 2025-08-13 13:55:57 +01:00
Matthew Lugg
6e90ce2536
Merge pull request #24381 from Justus2308/switch-better-underscore
Enhance switch on non-exhaustive enums
2025-08-13 13:54:15 +01:00
mlugg
ba6abd71c2
llvm: unions which are equivalent to enums are not by-ref
The LLVM backend lowers unions where all fields are zero-bit as
equivalent to their backing enum, and expects them to have the same
by-ref-ness in at least one place in the backend, probably more.

Resolves: #23577
2025-08-13 11:36:16 +01:00
mlugg
38ba425b26
llvm: support small error limits
Resolves: #23533
2025-08-13 11:36:16 +01:00
Isaac Freund
b8124d9c0b std.io.Writer.Allocating: rename getWritten() to written()
This "get" is useless noise and was copied from FixedBufferWriter.
Since this API has not yet landed in a release, now is a good time
to make the breaking change to fix this.
2025-08-13 01:43:52 -07:00
Alex Rønne Petersen
662303d7e7
Merge pull request #24734 from Rexicon226/tsan-fix 2025-08-13 08:57:52 +02:00
Alex Rønne Petersen
b7602a17f8
freebsd: correctly define __FreeBSD_version to the first stable release
See: https://docs.freebsd.org/en/books/porters-handbook/versions

Closes #24819.
2025-08-13 08:46:52 +02:00
Alex Rønne Petersen
e089d21439
freebsd: fix PIC macro not being defined for crt1_s.S
Closes #24818.
2025-08-13 08:40:56 +02:00
Rue
dd4e25cf44
optimize @intCast in llvm backend (#24739) 2025-08-13 00:56:31 +00:00
Justus Klausecker
8fda49ea8a fix: remove incorrect '&' 2025-08-12 16:33:58 +02:00
Justus Klausecker
277e4a8337 fix: emit vector instead of scalar u1_zero in shl_with_overflow logic 2025-08-12 16:33:58 +02:00
Justus Klausecker
4ec421372f add remaining undef value tests ; fix @truncate undef retval type 2025-08-12 16:33:58 +02:00
Justus Klausecker
f0ffe30f2f add undef shift tests ; mirror zirShl logic for @shlWithOverflow 2025-08-12 16:33:58 +02:00
Justus Klausecker
8f5ec2a1fb Sema: replace all remaining aggregate interns related to @typeInfo 2025-08-12 16:33:58 +02:00
Justus Klausecker
79756e681d remove redundant test cases 2025-08-12 16:33:58 +02:00
Justus Klausecker
76d2782149 replace most aggregate interns in x86_64/CodeGen 2025-08-12 16:33:57 +02:00
Justus Klausecker
79e5c138c6 replace even more aggregate interns 2025-08-12 16:33:57 +02:00
Justus Klausecker
7756fa6641 Sema: replace most aggregate interns with pt.aggregateValue 2025-08-12 16:33:57 +02:00
Justus Klausecker
05762ca02f address most comments 2025-08-12 16:33:57 +02:00
Justus Klausecker
0ef26d113a make >> a compile error with any undef arg ; add a bunch of test cases 2025-08-12 16:33:57 +02:00
Justus Klausecker
d0586da18e Sema: Improve comptime arithmetic undef handling
This commit expands on the foundations laid by https://github.com/ziglang/zig/pull/23177
and moves even more `Sema`-only functionality from `Value`
to `Sema.arith`. Specifically all shift and bitwise operations,
`@truncate`, `@bitReverse` and `@byteSwap` have been moved and
adapted to the new rules around `undefined`.

Especially the comptime shift operations have been basically
rewritten, fixing many open issues in the process.

New rules applied to operators:
* `<<`, `@shlExact`, `@shlWithOverflow`, `>>`, `@shrExact`: compile error if any operand is undef
* `<<|`, `~`, `^`, `@truncate`, `@bitReverse`, `@byteSwap`: return undef if any operand is undef
* `&`, `|`: Return undef if both operands are undef, turn undef into actual `0xAA` bytes otherwise

Additionally this commit canonicalizes the representation of
aggregates with all-undefined members in the `InternPool` by
disallowing them and enforcing the usage of a single typed
`undef` value instead. This reduces the amount of edge cases
and fixes a bunch of bugs related to partially undefined vecs.

List of operations directly affected by this patch:
* `<<`, `<<|`, `@shlExact`, `@shlWithOverflow`
* `>>`, `@shrExact`
* `&`, `|`, `~`, `^` and their atomic rmw + reduce pendants
* `@truncate`, `@bitReverse`, `@byteSwap`
2025-08-12 16:33:57 +02:00
Andrew Kelley
749f10af49 std.ArrayList: make unmanaged the default 2025-08-11 15:52:49 -07:00
Jacob Young
d625158354 aarch64: implement more assembler instructions 2025-08-11 15:47:51 -07:00
Jacob Young
60f8584927 Dwarf: port to new Writer API 2025-08-11 12:00:50 -07:00
Jacob Young
38dfa6537e cbe: emit nonstring attribute
Closes #24545
2025-08-11 11:30:51 -07:00
Andrew Kelley
0b3c3c02e3 linker: delete plan9 support
This experimental target was never fully completed. The operating system
is not that interesting or popular anyway, and the maintainer is no
longer around.

Not worth the maintenance burden. This code can be resurrected later if
it is worth it. In such case it will be subject to greater scrutiny.
2025-08-11 10:56:20 -07:00
Will Lillis
d1917b5c3a fix(fmt): return correct exit code for zig fmt --stdin --check 2025-08-11 07:34:26 +02:00
David Rubin
20486c4a81 elf: fix potential overflow in got emission 2025-08-11 03:02:54 +02:00
Alex Rønne Petersen
6bb6013d3a
Merge pull request #24768 from alichraghi/spv5
spirv: remove prune_unused ISel
2025-08-10 19:45:16 +02:00
Techatrix
2983285815 zig fmt: flush stdout before exiting with error 2025-08-10 19:42:54 +02:00
Andrew Kelley
0a1a738320
Merge pull request #24743 from ziglang/BufferedWriter
std.Io: delete BufferedWriter
2025-08-09 16:28:19 -07:00
Ali Cheraghi
bed99e1ecd
spirv: remove prune_unused ISel 2025-08-09 13:27:04 +03:30
Ian Johnson
14f11377cb Fetch.git: fix FetchStream packet reading
Progress towards #24732
2025-08-08 19:37:33 -07:00
Andrew Kelley
8c9dfcbd0f std.Io: remove BufferedWriter 2025-08-08 17:17:53 -07:00
mlugg
5f7a0bbabf Sema: fix unreasonable progress node numbers
The "completed" count in the "Semantic Analysis" progress node had
regressed since 0.14.0: the number got crazy big very fast, even on
simple cases. For instance, an empty `pub fn main` got to ~59,000 where
on 0.14 it only reached ~4,000. This was happening because I was
unintentionally introducing a node every time type resolution was
*requested*, even if (as is usually the case) it turned out to already
be done. The fix is simply to start the progress node a little later,
once we know we are actually doing semantic analysis. This brings the
number for that empty test case down to ~5,000, which makes perfect
sense. It won't exactly match 0.14, because the standard library has
changed, and also because the compiler's progress output does have some
*intentional* changes.
2025-08-08 23:14:26 +01:00
Andrew Kelley
2a8751e37f Fetch.git: replace a toss with discardAll
toss is only valid following a peek.
2025-08-08 15:03:05 -07:00
mlugg
1440519239 compiler: improve error reporting
The functions `Compilation.create` and `Compilation.update` previously
returned inferred error sets, which had built up a lot of crap over
time. This meant that certain error conditions -- particularly certain
filesystem errors -- were not being reported properly (at best the CLI
would just print the error name). This was also a problem in
sub-compilations, where at times only the error name -- which might just
be something like `LinkFailed` -- would be visible.

This commit makes the error handling here more disciplined by
introducing concrete error sets to these functions (and a few more as a
consequence). These error sets are small: errors in `update` are almost
all reported via compile errors, and errors in `create` are reported
through a new `Compilation.CreateDiagnostic` type, a tagged union of
possible error cases. This allows for better error reporting.

Sub-compilations also report errors more correctly in several cases,
leading to more informative errors in the case of compiler bugs.

Also fixes some race conditions in library building by replacing calls
to `setMiscFailure` with calls to `lockAndSetMiscFailure`. Compilation
of libraries such as libc happens on the thread pool, so the logic must
synchronize its access to shared `Compilation` state.
2025-08-08 22:37:27 +01:00
Andrew Kelley
1ba6838bc3
Merge pull request #24740 from ziglang/http-plus-fixes
fetch, tls, and http fixes
2025-08-08 12:33:53 -07:00
Andrew Kelley
9a538e0d54 link.Dwarf: minimal changes to remove CountingWriter 2025-08-07 22:26:42 -07:00
Andrew Kelley
281f657377 Revert "random patches from another branch"
This reverts commit 76ed05523d6327789a8365571b67a214ac527ef9.

they don't work
2025-08-07 22:26:42 -07:00
Andrew Kelley
c5a5983150 random patches from another branch 2025-08-07 22:26:42 -07:00
Andrew Kelley
94dd28b7f7 std.Io: delete CountingWriter 2025-08-07 22:26:42 -07:00