Commit graph

34663 commits

Author SHA1 Message Date
Ryan Liptak
acd6ffdf69 Reader.peekDelimiterInclusive: Fix handling of stream implementations that return 0
Previously, the logic in peekDelimiterInclusive (when the delimiter was not found in the existing buffer) used the `n` returned from `r.vtable.stream` as the length of the slice to check, but it's valid for `vtable.stream` implementations to return 0 if they wrote to the buffer instead of `w`. In that scenario, the `indexOfScalarPos` would be given a 0-length slice so it would never be able to find the delimiter.

This commit changes the logic to assume that `r.vtable.stream` can both:
- return 0, and
- modify seek/end (i.e. it's also valid for a `vtable.stream` implementation to rebase)

Also introduces `std.testing.ReaderIndirect` which helps in being able to test against Reader implementations that return 0 from `stream`/`readVec`

Fixes #25428
2025-10-09 12:01:51 -07:00
tehlordvortex
ff16a7c3fa
std.Build: duplicate sub_path for LazyPath's dependency variant 2025-10-08 18:12:48 +02:00
Linus Groh
08b2fd46ab
std.c: Add missing SIG constants for serenity 2025-10-06 23:29:11 +02:00
Alex Rønne Petersen
bc7cdc2b6b
libcxxabi: don't build cxa_noexception.cpp if exceptions are enabled 2025-10-06 23:28:58 +02:00
Alex Rønne Petersen
03078bfa41
libcxxabi: sort file list according to upstream CMakeLists.txt 2025-10-06 23:28:52 +02:00
Alex Rønne Petersen
b2591d50c7
libcxxabi: define _LIBCPP_BUILDING_LIBRARY in addition to _LIBCXXABI_BUILDING_LIBRARY 2025-10-06 23:28:39 +02:00
Alex Rønne Petersen
9377cc6eef
std.zig.system: handle or1k in getExternalExecutor() 2025-10-06 23:27:20 +02:00
xdBronch
57f45cc87c
fix read of undefined in http tests 2025-10-06 23:26:15 +02:00
xdBronch
cfb5350ed4
don't pass zero-length @memset to the backend 2025-10-06 23:26:05 +02:00
Jacob Young
7de67e6802 InternPool: use sequential string indices instead of byte offsets
This allows more bytes to be referenced by a smaller index range.

Closes #22867
Closes #25297
Closes #25339
2025-10-05 00:27:39 -04:00
Jacob Young
2700af2aeb x86_64: fix bool vector init register clobber
Closes #25439
2025-10-03 23:26:21 -04:00
mlugg
e6e93d82b0
Lld: fix implib emit path
Resolves: https://github.com/ziglang/zig/issues/24993
2025-10-02 10:55:16 +02:00
Ryan Liptak
78012b4845
resinator: fix an alignment problem 2025-10-02 00:13:35 +02:00
Jacob
ab6dbfe1a3 translate_c: fix ternary operator output in C macros 2025-10-01 14:23:54 +02:00
Timothy Bess
0795e2b2ef
Fix zig build lazy -> eager dependency promotion
Before, this had a subtle ordering bug where duplicate
deps that are specified as both lazy and eager in different
parts of the dependency tree end up not getting fetched
depending on the ordering. I modified it to resubmit lazy
deps that were promoted to eager for fetching so that it will
be around for the builds that expect it to be eager downstream
of this.
2025-10-01 04:36:15 +02:00
Alex Rønne Petersen
4fd78f9c26
libcxx: respond to some feature macro changes in LLVM 20
ba87515fea

closes #25376
2025-09-28 15:31:22 +02:00
Alex Rønne Petersen
ebaec8e03f
test: remove pie test case from test-standalone
We already have test/cases/pie_linux.zig covering this.
2025-09-28 08:19:49 +02:00
Andrew Kelley
135f1915da
Compilation: --debug-rt always Debug
--debug-rt previously would make rt libs match the root module. Now they
are always debug when --debug-rt is passed. This includes compiler-rt,
fuzzer lib, and others.
2025-09-28 08:19:39 +02:00
Ryan Liptak
c40dbd6ff0
Update descriptions of -f[no-]error-tracing to match the actual behavior
Before https://github.com/ziglang/zig/pull/18160, error tracing defaulted to true in ReleaseSafe, but that is no longer the case. These option descriptions were never updating accordingly.
2025-09-28 08:18:45 +02:00
Michael Neumann
65af34b1bf
bootstrap: Add support for DragonFly 2025-09-28 08:18:37 +02:00
Michael Neumann
8b5e4e032b
lib/std/c: sync "struct stat" for DragonFly
* Add missing functions like ISDIR() or ISREG(). This is required to
  build the zig compiler

* Use octal notation for the S_ constants. This is how it is done for
  ".freebsd" and it is also the notation used by DragonFly in
  "sys/stat.h"

* Reorder S_ constants in the same order as ".freebsd" does. Again, this
  follows the ordering within "sys/stat.h"
2025-09-28 08:18:31 +02:00
Alex Rønne Petersen
6b1d94c539
musl: add missing fenv C dummy functions for loongarch64-linux-muslsf
https://www.openwall.com/lists/musl/2025/09/27/1

closes #25367
2025-09-28 08:18:18 +02:00
Alex Rønne Petersen
a1c410d512
Revert "x86_64: improve support for large enums"
This reverts commit 8520e4e286.
2025-09-26 00:19:47 +02:00
Jacob Young
8520e4e286
x86_64: improve support for large enums
Closes #25247
2025-09-25 07:44:58 +02:00
taylor.fish
9f2a200a3f
Fix PowerPC restore_rt
Clang fails to compile the CBE translation of this code ("non-ASM
statement in naked function"). Similar to the implementations of
`restore_rt` on x86 and ARM, when the CBE is in use, this commit employs
alternative inline assembly that avoids using non-immediate input
operands.
2025-09-25 03:58:58 +02:00
Jacob Young
a430be097b
x86_64: support more in/out forms
Closes #25303
2025-09-25 01:11:05 +02:00
taylor.fish
427f0025db
Fix PowerPC syscalls causing invalid code from CBE
Fixes #25209.

On PowerPC, some registers are both inputs to syscalls and clobbered by
them. An example is r0, which initially contains the syscall number, but
may be overwritten during execution of the syscall.

musl and glibc use a `+` (read-write) constraint to indicate this, which
isn't supported in Zig. The current implementation of PowerPC syscalls
in the Zig standard library instead lists these registers as both inputs
and clobbers, but this results in the C backend generating code that is
invalid for at least some C compilers, like GCC, which doesn't support
the specifying the same register as both an input and a clobber.

This PR changes the PowerPC syscall functions to list such registers as
inputs and outputs rather than inputs and clobbers. Thanks to jacobly0
who pointed out that it's possible to have multiple outputs; I had
gotten the wrong idea from the documentation.
2025-09-24 03:50:34 +02:00
Kyle Schwarz
1f0cf7c551
glibc: guard inet-fortified.h 2025-09-24 03:50:29 +02:00
rpkak
bc567312bf
use copy_file_range syscall on linux 2025-09-24 03:50:22 +02:00
Carter Snook
6069f908e9
std: always allow spawning processes when an env map is explicitly provided (#25092)
In a library, the two `builtin.link_libc` and `builtin.output_mode ==
.Exe` checks could both be false. Thus, you would get a compile error
even if you specified an `env_map` at runtime. This change turns the
compile error into a runtime panic and updates the documentation to
reflect the runtime requirement.
2025-09-24 03:50:16 +02:00
alexrp
e526d65f5e
compiler: don't use self-hosted backend on any BSD yet
There are some blocking bugs in the self-hosted ELF linker.
2025-09-24 01:11:42 +02:00
alexrp
0e673fdab2
std.posix: remove bogus assert that SIGRTMAX < NSIG 2025-09-24 01:11:33 +02:00
alexrp
d6d1fefae9
test: disable test-link on FreeBSD
https://github.com/ziglang/zig/issues/25323
2025-09-24 01:11:27 +02:00
alexrp
a569c7d664
test: disable some stack trace tests on FreeBSD 2025-09-24 01:11:20 +02:00
Alex Rønne Petersen
b8f2fec0f2
std.pie: fix register constraint in getDynamicSymbol() for s390x (#25327)
If the compiler happens to pick `ret = r0`, then this will assemble to
`ag r0, 0` which is obviously not what we want. Using `a` instead of `r` will
ensure that we get an appropriate address register, i.e. `r1` through `r15`.

Re-enable pie_linux for s390x-linux which was disabled in
ed7ff0b693.
2025-09-24 01:11:02 +02:00
Alex Rønne Petersen
9694c83b95
Revert "frontend: another packedStructFieldPtrInfo fix"
This reverts commit 3ab845e028.
2025-09-22 04:56:46 +02:00
Alex Rønne Petersen
d07b67a55c
Revert "x86_64: fix safety crashes in storeRegs"
This reverts commit 37985613c7.
2025-09-21 21:42:39 +02:00
Jacob Young
e647d1a570
x86_64: rewrite vector element pointer access 2025-09-21 21:36:23 +02:00
Alex Rønne Petersen
92b0ec989c
ci: temporarily disable riscv64-linux
GitHub sucks:

    Sep 20 20:49:21 ganymede runsvc.sh[82817]: An error occured: Runner version v2.326.0 is deprecated and cannot receive messages.
    Sep 20 20:49:21 ganymede runsvc.sh[82817]: Runner listener exited with error code 1
    Sep 20 20:49:21 ganymede runsvc.sh[82817]: Runner listener exit with terminated error, stop the service, no retry needed.
2025-09-21 21:12:20 +02:00
Jacob Young
ab3e34b09b
standalone: fix misaligned stack crash 2025-09-21 21:08:52 +02:00
Jacob Young
80eacd6003
aarch64: fix behavior failures 2025-09-21 21:08:52 +02:00
Frank Denis
798acd932e
aarch64/zonCast: don't return a pointer to a stack element
Elements are computed at comptime, so don't declare them as "var".
2025-09-21 21:08:52 +02:00
Andrew Kelley
3da6a19011
x86 codegen: handle spilled tuples 2025-09-21 21:08:52 +02:00
Jacob Young
37985613c7
x86_64: fix safety crashes in storeRegs 2025-09-21 21:08:52 +02:00
Andrew Kelley
670c4fae61
frontend: additionally handle C pointers in ptrOptPayload 2025-09-21 21:08:52 +02:00
Andrew Kelley
4d102751b6
frontend: fix too strict assertion
field ptr can be based on C pointer
2025-09-21 21:08:52 +02:00
Andrew Kelley
3ab845e028
frontend: another packedStructFieldPtrInfo fix
it was calculating host integer size in a wrong way. just use integer
abi size
2025-09-21 21:08:52 +02:00
mlugg
b4394412bb
Zcu: fix analysis of type of decl with inferred type
If the `nav_ty` is resolved by the `nav_val`, then we need to also mark
the `nav_ty` as in progress when we begin resolving the `nav_val`.
2025-09-21 21:08:51 +02:00
Andrew Kelley
582b96c361
std.zon.parse: fix not initializing array sentinel 2025-09-21 21:08:51 +02:00
Ryan Liptak
8d5b651c3a
Reader.defaultReadVec: Workaround bad r.end += r.vtable.stream() behavior
If `r.end` is updated in the `stream` implementation, then it's possible that `r.end += ...` will behave unexpectedly. What seems to happen is that it reverts back to its value before the function call and then the increment happens. Here's a reproduction:

```zig
test "fill when stream modifies `end` and returns 0" {
    var buf: [3]u8 = undefined;
    var zero_reader = infiniteZeroes(&buf);

    _ = try zero_reader.fill(1);
    try std.testing.expectEqual(buf.len, zero_reader.end);
}

pub fn infiniteZeroes(buf: []u8) std.Io.Reader {
    return .{
        .vtable = &.{
            .stream = stream,
        },
        .buffer = buf,
        .end = 0,
        .seek = 0,
    };
}

fn stream(r: *std.Io.Reader, _: *std.Io.Writer, _: std.Io.Limit) std.Io.Reader.StreamError!usize {
    @memset(r.buffer[r.seek..], 0);
    r.end = r.buffer.len;
    return 0;
}
```

When `fill` is called, it will call into `vtable.readVec` which in this case is `defaultReadVec`. In `defaultReadVec`:

- Before the `r.end += r.vtable.stream` line, `r.end` will be 0
- In `r.vtable.stream`, `r.end` is modified to 3 and it returns 0
- After the `r.end += r.vtable.stream` line, `r.end` will be 0 instead of the expected 3

Separating the `r.end += stream();` into two lines fixes the problem (and this separation is done elsewhere in `Reader` so it seems possible that this class of bug has been encountered before).

Potentially related issues:

- https://github.com/ziglang/zig/issues/4021
- https://github.com/ziglang/zig/issues/12064
2025-09-21 21:08:51 +02:00