Commit Graph

12697 Commits

Author SHA1 Message Date
Alex Rønne Petersen 6ca52c00d9 std.builtin: remove dead powerpc-darwin handling for VaList 2025-09-26 16:20:24 +02:00
Alex Rønne Petersen 033d251626 std.builtin: define VaList for arc, csky, lanai, m68k, msp430, nvptx, ve, xcore 2025-09-26 16:20:24 +02:00
Alex Rønne Petersen 44c80fc6dc std.builtin: sort VaList prongs a bit 2025-09-26 16:20:24 +02:00
Alex Rønne Petersen 4c798bb0bd std.builtin: define VaList as struct { __ap: *anyopaque } for Arm per AAPCS 2025-09-26 16:20:15 +02:00
Andrew Kelley e0dc2e4e3f Merge pull request #25342 from ziglang/fuzz-limit
fuzzing: implement limited fuzzing
2025-09-26 05:28:46 -07:00
Andrew Kelley 3b365a1f9b Merge pull request #25351 from ziglang/chomp
std.mem: introduce cut functions; rename "index of" to "find"
2025-09-26 01:45:07 -07:00
Andrew Kelley 52a13f6a7f web ui: fix not sending initial context sometimes
This would cause the web ui to crash in js or wasm.
2025-09-25 17:16:41 -07:00
Andrew Kelley 2a88a6a456 Merge pull request #24497 from ziglang/aro-translate-c
compiler: update aro and translate-c to latest; delete clang translate-c
2025-09-25 14:18:49 -07:00
Andrew Kelley 14e227d8a6 std.mem: add cutLast and cutScalarLast 2025-09-25 11:38:38 -07:00
Andrew Kelley 97bef50dc3 std.mem: rename all "index of" functions
Moving towards our function naming convention of having one word per
concept and constructing function names out of concatenated concepts.
In `std.mem` the concepts are:
* "find" - return index of substring
* "pos" - starting index parameter
* "last" - search from the end
* "linear" - simple for loop rather than fancy algo
* "scalar" - substring is a single element
2025-09-25 11:28:58 -07:00
Andrew Kelley 3411b5e499 std.mem: add cut and cutScalar and example usage 2025-09-25 11:11:46 -07:00
Andrew Kelley dd2f1cbebf std.mem: rename chomp to cut 2025-09-25 10:54:28 -07:00
Andrew Kelley ac4d79e322 std.mem: introduce chompPrefix and chompSuffix 2025-09-25 10:50:41 -07:00
Loris Cro 9bb0b43ea3 implement review suggestions 2025-09-25 18:20:19 +02:00
Alex Rønne Petersen a73f246b29 std.Thread: disable test on armeb in addition to thumbeb
Same falky failure on both. See ed7ff0b693.
2025-09-25 17:49:47 +02:00
Andrew Kelley 9ad1e83e63 zig fmt 2025-09-24 20:01:19 -07:00
Andrew Kelley ea169e6ccf std.Build.Cache: clarify parameter is sub path, not basename 2025-09-24 20:01:19 -07:00
Andrew Kelley 328280b566 move translate-c helpers 2025-09-24 20:01:18 -07:00
Alex Rønne Petersen 91b0adc4c1 Merge pull request #25231 from taylordotfish/bugfix/ppc-restore_rt
Fix `restore_rt` on PowerPC and remove unnecessary clobbers
2025-09-25 01:31:24 +02:00
rpkak 4fb08986cb optimize std.mem.swap 2025-09-24 12:29:43 -07:00
Loris Cro 0feacc2b81 fuzzing: implement limited fuzzing
Adds the limit option to `--fuzz=[limit]`. the limit expresses a number
of iterations that *each fuzz test* will perform at maximum before
exiting. The limit argument supports also 'K', 'M', and 'G' suffixeds
(e.g. '10K').

Does not imply `--web-ui` (like unlimited fuzzing does) and prints a
fuzzing report at the end.

Closes #22900 but does not implement the time based limit, as after
internal discussions we concluded to be problematic to both implement
and use correctly.
2025-09-24 12:46:48 +02:00
taylor.fish c73df65ded Don't specify clobbers in restore_rt
Per @alexrp, this is unnecessary in naked functions.
2025-09-23 21:03:28 -07:00
taylor.fish 7f49dae284 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-23 20:47:34 -07:00
Carter Snook 5bf52a6f50 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:12:28 +02:00
rpkak bc512648db use copy_file_range syscall on linux 2025-09-24 03:08:12 +02:00
taylor.fish bdca0f93c4 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 02:54:55 +02:00
Andrew Kelley ba137783ed forbid trivial local address returned from functions (#25333)
progress towards #25312
2025-09-23 23:37:53 +00:00
Alex Rønne Petersen 7b92d5f405 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-22 18:36:47 +02:00
Alex Rønne Petersen 26825e9506 Merge pull request #25324 from alexrp/freebsd
Some changes to prepare for FreeBSD CI
2025-09-22 05:04:31 +02:00
alexrp f7d62009ff std.posix: remove bogus assert that SIGRTMAX < NSIG 2025-09-22 01:37:32 +02:00
Jacob Young f58200e3f2 Elf2: create a new linker from scratch
This iteration already has significantly better incremental support.

Closes #24110
2025-09-21 14:09:14 -07:00
Andrew Kelley 594cb38fcb Merge pull request #25302 from ziglang/growCapacity
std: remove loop from growCapacity
2025-09-21 04:55:39 -07:00
Andrew Kelley ed7ff0b693 allow some test cases to regress
tracked by #24061 - these should be re-enabled once that is solved.
2025-09-20 18:33:01 -07:00
Andrew Kelley 5ec0a7d8a5 coerce vectors to arrays rather than inline for 2025-09-20 18:33:00 -07:00
Andrew Kelley 9afa6835df frontend: replace elem_val_node with elem_ptr_load
avoids unnecessary copies
2025-09-20 18:33:00 -07:00
Andrew Kelley 95439c9820 std.Progress: avoid problematic catch syntax 2025-09-20 18:33:00 -07:00
Andrew Kelley 354c17869a frontend: replace field_val and field_val_named
with field_ptr_load and field_ptr_named_load.

These avoid doing by-val load operations for structs that are
runtime-known while keeping the previous semantics for comptime-known
values.
2025-09-20 18:33:00 -07:00
Andrew Kelley 09e4fc4dcf std.zon.parse: fix not initializing array sentinel 2025-09-20 18:33:00 -07:00
Andrew Kelley 426af68b7d compiler: require comptime vector indexes 2025-09-20 18:33:00 -07:00
Ryan Liptak 3fbb88c4bd 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-20 18:31:38 -07:00
Andrew Kelley 3cc0fc601a std.json: delete test tightly coupled to ArrayList growth
This test works by assuming that std.ArrayList will grow with a specific
capacity increasing pattern, which is an invalid assumption. Delete the
offending test.
2025-09-20 14:38:01 -07:00
Andrew Kelley 0c1fbc4ea6 std: remove loop from growCapacity
I measured this against master branch and found no statistical
difference. Since this code is simpler and logically superior due to
always leaving sufficient unused capacity when growing, it is preferred
over status quo.
2025-09-20 14:34:18 -07:00
Andrew Kelley 4d1b15bd9d Merge pull request #25298 from ziglang/SegmentedList-orphaned-again
std: delete SegmentedList again
2025-09-20 10:29:02 -07:00
John Benediktsson 14fc4d4811 std.c: add MSG support for dragonfly 2025-09-20 19:21:14 +02:00
Alex Rønne Petersen 7857bbd116 std.crypto.ascon: disable Ascon-AEAD128 test on RISC-V with V support 2025-09-20 19:05:32 +02:00
John Benediktsson 1ac4c27d74 std.c: adjust shm_open to be variadic on darwin 2025-09-20 07:33:50 +02:00
Justus Klausecker be571f32c3 std.Build.Step.Run: Enable passing (generated) file content as args
Adds `addFileContentArg` and `addPrefixedFileContentArg` to pass the content
of a file with a lazy path as an argument to a `std.Build.Step.Run`.
This enables replicating shell `$()` / cmake `execute_process` with `OUTPUT_VARIABLE`
as an input to another `execute_process` in conjuction with `captureStdOut`/`captureStdErr`.

To also be able to replicate `$()` automatically trimming trailing newlines and cmake
`OUTPUT_STRIP_TRAILING_WHITESPACE`, this patch adds an `options` arg to those functions
which allows specifying the desired handling of surrounding whitespace.

The `options` arg also allows to specify a custom `basename` for the output. e.g.
to add a file extension (concrete use case: Zig `@import()` requires files to have a
`.zig`/`.zon` extension to recognize them as valid source files).
2025-09-19 17:38:40 -07:00
Andrew Kelley 1eeb8fabe5 std: delete SegmentedList again
The data structure was originally added in
41e1cd185b and then removed in
50a336fff8, but brought back in
711bf55eaa for Decl in the compiler
frontend, and then the last reference to it was eliminated in
548a087faf which removed Decl in favor of
Nav and Cau.
2025-09-19 16:40:00 -07:00
Andrew Kelley 164c598cd8 Merge pull request #23416 from gooncreeper/improved-fuzzer
greatly improve capabilities of the fuzzer
2025-09-19 09:27:25 -07:00
Alex Rønne Petersen 97df4ae3ce Merge pull request #25268 from alexrp/loongarch
Miscellaneous LoongArch work to prepare for CI
2025-09-19 12:09:48 +02:00