Commit Graph

36639 Commits

Author SHA1 Message Date
Alex Rønne Petersen cc38acfea3 ci: skip incremental tests on loongarch64-linux
https://codeberg.org/ziglang/zig/issues/30748
2026-01-08 07:01:57 +01:00
moriazoso 514b103edb std.Io.Threaded: correctly initialize PosixAddress/WsaAddress from sockaddr (#30722)
Resolves ziglang/zig#30672 - UB caused by `std.Io.Threaded.netLookupFallible` incorrectly initializing `PosixAddress`/`WsaAddress` from `*sockaddr`.

Reviewed-on: https://codeberg.org/ziglang/zig/pulls/30722
Co-authored-by: moriazoso <greysonmurray.dev@gmail.com>
Co-committed-by: moriazoso <greysonmurray.dev@gmail.com>
2026-01-08 06:01:44 +01:00
Andrew Kelley 6a5bb3ede3 std: find a better home for the "preopens" concept 2026-01-08 05:06:31 +01:00
pentuppup d2d8b969a1 fix redundant safety checks being emitted for slicing 2026-01-08 05:05:39 +01:00
Bingwu Zhang cdaf279314 link.Elf2: fix incorrect expected node length
Change-Id: Iba9c4bf2cfa4ff1b82dd5f0828c57711f238f1bf
2026-01-08 04:54:49 +01:00
Bingwu Zhang 8d06d8dca2 link.Elf: allow multiple relocs at the same location
RISC-V and LoongArch ELF psABIs define a kind of
RELAX relocations which are expected to have a normal
relocation at the same address.

Change-Id: I5737bfcfd3e5041fb6ab7d193c9fc57eeca1eec8
2026-01-08 04:53:16 +01:00
David Rubin 938efe4aab compiler-rt: fix f80 ceil/floor optimization
Our implementation did the classic add-sub rounding trick `(y = x +/- C =+ C - x)`
with `C = 1 / eps(T) = 2^(mantissa - 1)`. This approach only works for values whose
magnitude is below the rounding capacity of the constant. For a 64-bit mantissa
(like f80 has), `C = 2^63` only rounds for `|x| < 2^63`. Before we allowed this to
be ran on `e < bias + 64` aka `|x| < 2^64`. And because it isn't large enough,
we lose a bit to rounding.

For reference, the musl implementation does the same thing, using `mantissa - 1`:
https://git.musl-libc.org/cgit/musl/tree/src/math/ceill.c#n18
where `LDBL_MANT_DIG` is 64 for `long double` on x86.

This commit also combines the floor and ceil implementations into one generic one.
2026-01-08 00:45:52 +01:00
Steven Casper 52e0f78706 byteSwapAllFieldsAligned: use std.mem.Alignment API (#30724)
Following up on #30571

Reviewed-on: https://codeberg.org/ziglang/zig/pulls/30724
Reviewed-by: Andrew Kelley <andrew@ziglang.org>
Co-authored-by: Steven Casper <sebastiancasper3@gmail.com>
Co-committed-by: Steven Casper <sebastiancasper3@gmail.com>
2026-01-08 00:44:08 +01:00
GasInfinity 335c0fcba1 feat(libzigc): add div, ldiv, lldiv and imaxdiv
* also remove musl implementation
2026-01-07 21:53:40 +01:00
Andrew Kelley 62d6bbc7dc Merge pull request 'std.Io: implement entropy (randomness)' (#30709) from random into master
Reviewed-on: https://codeberg.org/ziglang/zig/pulls/30709
2026-01-07 20:04:26 +01:00
Andrew Kelley 006afece53 std.crypto.tls.Client.Options: expose entropy_len 2026-01-07 11:03:37 -08:00
Andrew Kelley 5d0929c40d std.Io.Threaded.randomSecure: eliminate dead code 2026-01-07 11:03:37 -08:00
Andrew Kelley 5e5b328dac test-standalone: update cases from posix.getrandom 2026-01-07 11:03:37 -08:00
Andrew Kelley 1ddae8585a std.Io.Threaded: add procfs fallback for fileHardLink
oof what a clunky set of functionality we have here
2026-01-07 11:03:37 -08:00
Andrew Kelley 7e8c7e5696 std.Io: fix AT_SYMLINK_FOLLOW flags
hard linking has the backwards default, which uses a different flag
2026-01-07 11:03:37 -08:00
Andrew Kelley ee574f665c std.Io.Dir: introduce renamePreserve and use it in File.Atomic.link
breaking change: the error for renaming over a non-empty directory now
returns error.DirNotEmpty rather than error.PathAlreadyExists.
2026-01-07 11:03:37 -08:00
Andrew Kelley 8e1850e277 std.Io.Threaded: tweak logic for use_dev_urandom 2026-01-07 11:03:37 -08:00
Andrew Kelley 61cb5e4af9 compiler: fix unit tests 2026-01-07 11:03:37 -08:00
Andrew Kelley 0529fe3411 std.Io.Threaded: fix implementation of getRandomFd 2026-01-07 11:03:37 -08:00
Andrew Kelley 1eddc1737c std: add test coverage for Io.File.Atomic.link 2026-01-07 11:03:37 -08:00
Andrew Kelley a136890acc std.Io.random: clarify doc comments 2026-01-07 11:03:37 -08:00
Andrew Kelley e23bec700c build: delete some wrong max_rss values
these aren't even checking the correct target, it's checking based on
the host so when cross compiling the numbers don't even make sense.
2026-01-07 11:03:37 -08:00
Andrew Kelley 90f0d7d0da std.Io.Threaded: implement random seed fallback for WASI 2026-01-07 11:03:37 -08:00
Andrew Kelley 7bd033275e std.Io.Threaded: implement Windows random seed fallback 2026-01-07 11:03:37 -08:00
Andrew Kelley 1f1381a866 update API usage of std.crypto.random to io.random 2026-01-07 11:03:36 -08:00
Andrew Kelley 81a35a86ea std.Io: introduce random and randomSecure
and use a thread-local CSPRNG for the former.
2026-01-07 11:03:36 -08:00
Andrew Kelley e3e9c7c33c std.Build.Step.Compile: take advantage of std lib atomic files 2026-01-07 11:03:36 -08:00
Andrew Kelley 2f639a45b4 std.Io.Threaded: implement windows random with \Device\CNG 2026-01-07 11:03:36 -08:00
Andrew Kelley 42ca9e5d8e std.Build: remove no longer needed workaround
now that definitions of networking addresses are arch-independent
2026-01-07 11:03:36 -08:00
Andrew Kelley 3bc22dbd94 std.Build.Step.Options: exploit Io.File.Atomic 2026-01-07 11:03:36 -08:00
Andrew Kelley 816565dd07 std: move entropy to Io 2026-01-07 11:03:36 -08:00
Alex Rønne Petersen 867501d9d2 ci: bump loongarch64-linux timeouts by 1 hour
https://codeberg.org/ziglang/zig/actions/runs/611/jobs/5/attempt/1
2026-01-07 16:04:46 +01:00
Matthew Lugg cd963ba38d Io.Threaded: fix bad assertion
Resolves: https://codeberg.org/ziglang/zig/issues/30717
2026-01-07 11:27:21 +01:00
Alex Rønne Petersen 28b83e3b02 compiler: recognize and ignore -rpath-link linker option
The option should probably still be implemented properly at some point, but LLD
has ignored this for years and nobody seems to mind, so just do the same for
now.

This unblocks using zig cc with CMake on OpenBSD, among other use cases.

ref https://github.com/ziglang/zig/issues/18713
2026-01-07 02:25:10 +01:00
mlugg 1bef876636 Merge pull request 'std.Thread: mask all signals before unmapping stack' (#30713) from detached-thread-exit-signal-race into master
Reviewed-on: https://codeberg.org/ziglang/zig/pulls/30713
Reviewed-by: Andrew Kelley <andrew@ziglang.org>
2026-01-07 01:11:25 +01:00
GasInfinity fa625e878f feat(libzigc): add qsort
* also remove musl implementation
2026-01-07 00:06:57 +01:00
Alex Rønne Petersen 6412aebc90 compiler: fix build 2026-01-06 23:58:30 +01:00
ptrstr 764764465b std.os.emscripten: make emscripten_run_script_string return optional
Signed-off-by: ptrstr <ptrstr@protonmail.com>
2026-01-06 23:49:29 +01:00
Andrew Kelley 5e002910df Merge pull request '@extern: add support for SPIR-V locations and descriptors' (#30570) from ashpil/zig:extern-bindings-locations into master
Reviewed-on: https://codeberg.org/ziglang/zig/pulls/30570
Reviewed-by: Andrew Kelley <andrew@ziglang.org>
2026-01-06 23:44:10 +01:00
pentuppup c475f1fcd5 Ast: disallow bit alignment on many-item and C pointers 2026-01-06 23:40:01 +01:00
David Rubin 8b71ec6db7 crypto: correctly disallow non-digits in time
Previously these functions made the assumption that
when performing a  on the input digits,
there could be no collisions between the less
significant digits being larger than '9', and the
upper digits being small enough to get past the
 checks.

Now we perform a correct check across all of the
digits to ensure they're in between '0'-'9', at
a minimal cost, since all digits are checked in
parallel.
2026-01-06 23:37:43 +01:00
Kristoffer 9c55776d25 std.crypto: mem.trimLeft -> mem.trimStart 2026-01-06 23:28:01 +01:00
Alex Rønne Petersen b5df5391aa Merge pull request 'enable powerpc64le-linux CI' (#30704) from alexrp/zig:powerpc64le into master
Reviewed-on: https://codeberg.org/ziglang/zig/pulls/30704
2026-01-06 21:16:47 +01:00
Alex Rønne Petersen 43a8e9ee80 ci: enable powerpc64le-linux 2026-01-06 21:15:38 +01:00
Alex Rønne Petersen 63eb395729 ci: build test stage3 on powerpc64le-linux with long calls
Necessary to work around this:

    error: ld.lld: /home/ci/.cache/act/f23fdcb74e58cd75/hostexecutor/zig-global-cache/o/c67e3042d116da0f73d3129d377044bf/libc++abi.a(/home/ci/.cache/act/f23fdcb74e58cd75/hostexecutor/zig-global-cache/o/61dd7765ab891b4db54a5e49b8ab8c86/cxa_thread_atexit.o):(function __cxa_thread_atexit: .text.__cxa_thread_atexit+0x40): relocation R_PPC64_REL24_NOTOC out of range: -251925824 is not in [-33554432, 33554431]; references '__cxa_thread_atexit_impl'
        note: referenced by cxa_thread_atexit.cpp:116 (/home/ci/.cache/act/f23fdcb74e58cd75/hostexecutor/lib/libcxxabi/src/cxa_thread_atexit.cpp:116)
        note: defined in /home/ci/.cache/act/f23fdcb74e58cd75/hostexecutor/zig-global-cache/o/c67e3042d116da0f73d3129d377044bf/libc++abi.a(/home/ci/.cache/act/f23fdcb74e58cd75/hostexecutor/zig-global-cache/o/61dd7765ab891b4db54a5e49b8ab8c86/cxa_thread_atexit.o)

This is only a problem for now because we link libLLVM; once we start invoking
llc instead, we won't need this workaround anymore.
2026-01-06 21:15:38 +01:00
Alex Rønne Petersen 64f5ef8880 ci: add powerpc64le-linux scripts 2026-01-06 21:15:38 +01:00
Alex Rønne Petersen 6a1fecea67 build: bump max_rss for test-behavior on powerpc64le-linux to 627_431_833 2026-01-06 21:15:35 +01:00
Alex Rønne Petersen 7daf0b6f46 build: use -ffunction-sections -fdata-sections for the Zig compiler on PowerPC
It has been observed in practice on powerpc64(le)-linux that zig.o (in various
stages and build modes) is large enough that the +/- 32MB branch range of
PowerPC is insufficient to reach from one end of the code section to the other.
With LLVM 21, this leads to silent miscompiles that then crash at runtime. With
LLVM 22, it will at least lead to branch range errors that fail the compilation,
but that gets us no closer to a working compiler.

By using these options, we give the linker much greater flexibility to move code
and data around to satisfy these range constraints; without them, the linker is
not allowed to split up the huge code and data sections of zig.o to do so.

Similar issues have also been observed on powerpc-linux (32-bit), hexagon-linux,
and some variations of mips(64)(el)-linux. But let's be conservative for now;
those other targets can be added to the condition later.

As a data point to support this change, it's worth noting that LLD started
enabling these options for LTO precisely because the resulting large compilation
units ran into these range issues. In some abstract sense, Zig can be seen as
doing a limited form of "LTO" in the frontend, so it's not surprising that we
would hit the same issues.
2026-01-06 21:15:02 +01:00
Alex Rønne Petersen a996a75e06 compiler: make all Zig-provided libraries use -ffunction-sections -fdata-sections
We already did this for some of them; this just makes us consistent. Doing this
gives the linker more flexibility to rearrange code/data, but more importantly,
allows --gc-sections to get rid of all the unused code, which is a real concern
for these libraries in particular.
2026-01-06 21:15:02 +01:00
Alex Rønne Petersen 312b231da9 ci: bump riscv64-linux timeouts by a further 2 hours
See 962903e0fa.
2026-01-06 21:00:03 +01:00