34167 Commits

Author SHA1 Message Date
Andrew Kelley
34d7cf075e std.posix: skip flaky test
tracked by #24380
2025-07-14 18:38:50 -07:00
Alex Rønne Petersen
3473e6dc26
ci: skip building and checking stage4 on riscv64-linux 2025-07-15 02:37:26 +02:00
Alex Rønne Petersen
96ad898ab8
ci: skip some test steps on riscv64-linux
Specifically:

* test-fmt
* test-translate-c
* test-run-translated-c
* test-cli
* test-incremental
2025-07-15 02:36:46 +02:00
Alex Rønne Petersen
a885e8370a
ci: partial revert of f3f2a56859f96cee6f9bc8e8fe14b99ec653abaf
While I experiment with ways to cut down run times, run on master only.
2025-07-15 02:27:58 +02:00
Andrew Kelley
148befdaa3
Merge pull request #24409 from ziglang/net
std.net: update to new I/O API
2025-07-15 01:42:40 +02:00
Alex Rønne Petersen
f3f2a56859 ci: make changes to riscv64-linux to try to avoid timeouts
The idea is to have 2 runners per machine, since a lot of time is spent building
stage3 and stage4, both of which are largely single-core affairs. This will make
the test steps take longer, however, so the timeouts have been bumped a bit, and
max RSS for the test step has been lowered from 64G to 32G to prevent OOM.
Finally, we now only run a single ReleaseSafe job on PRs; Debug and Release jobs
are limited to pushes.
2025-07-15 01:30:46 +02:00
Andrew Kelley
d66f13c90d
Merge pull request #24433 from Justus2308/switch-label-halt
Sema: Fix invalid AIR generation for switch loop with comptime discarded tag
2025-07-14 19:04:19 +02:00
Andrew Kelley
b993728f10 make it a behavior test instead
It's important to check for correct runtime behavior, rather than only
checking that the compiler does not crash.
2025-07-14 10:02:37 -07:00
Justus Klausecker
29ac68b253 Sema: Fix invalid AIR generation for switch loop with comptime discarded tag
Add an additional check before emitting `.loop_switch_br` instead
of `.switch_br` in a tagged switch statement for whether any of the
continues referencing its tag are actually runtime reachable.
This fixes triggering an assertion in Liveness caused by the invalid
assumption that every tagged switch must be a loop if its tag is
referenced in any way even if this reference is not runtime reachable.
2025-07-14 09:59:13 -07:00
Andrew Kelley
e4ebbdb354 std.c: add missing netbsd and freebsd MSG flags 2025-07-14 09:35:38 -07:00
Alex Kladov
d90646d8fb langref: remove dead code 2025-07-14 17:34:52 +01:00
Alex Kladov
96bb1137c2 langref: don't encourage printing to stderr in tests
The rule: `pub fn main` owns file descriptors 0, 1, and 2. If you didn't
write `pub fn main()` it is, in general, not your business to print to
stderr.
2025-07-14 17:32:50 +01:00
Alex Kladov
d045eb7a4a langref: make example more interesting.
As written, I think langref's example is actually a poor reason to use
`inline`.

If you have

     if (foo(1200, 34) != 1234) {
         @compileError("bad");
     }

and you want to make sure that the call is executed at compile time, the
right way to fix it is to add comptime

     if (comptime foo(1200, 34) != 1234) {
         @compileError("bad");
     }

and not to make the function `inline`. I _think_ that inlining functions
just to avoid `comptime` at a call-site is an anti-pattern. When the
reader sees `foo(123)` at the call-site, they _expect_ this to be a
runtime call, as that's the normal rule in Zig.

Inline is still necessary when you can't make the _whole_ call
`comptime`, because it has some runtime effects, but you still want
comptime-known result.

A good example here is

    inline fn findImportPkgHashOrFatal(b: *Build, comptime asking_build_zig: type, comptime dep_name: []const u8) []const u8 {

from Build.zig, where the `b` argument is runtime, and is used for
side-effects, but where the result is comptime.

I don't know of a good small example to demonstrate the subtelty here,
so I went ahead with just adding a runtime print to `foo`. Hopefully
it'll be enough for motivated reader to appreciate the subtelty!
2025-07-14 16:20:33 +01:00
Ali Cheraghi
f43f89a705 spirv: snake-case the spec 2025-07-14 15:16:17 +02:00
Andrew Kelley
2f3cd175d3 compiler: raise the bar for backend contributions 2025-07-14 09:26:24 +02:00
Andrew Kelley
b510482525 std.fs.File.Reader.seekTo: add missing int cast 2025-07-14 00:21:20 -07:00
Andrew Kelley
524e2e19a5 std.Io.Writer.Discarding: fix drain calculation 2025-07-14 00:18:13 -07:00
Andrew Kelley
0c0d94a6da std.net: wasi does not have unix sockets 2025-07-14 00:16:49 -07:00
Andrew Kelley
36f356254c align those @fieldParentPtr casts 2025-07-14 00:16:49 -07:00
Andrew Kelley
890f1fa848 make msghdr.iovlen unsigned
I don't care what C headers say. This value is never supposed to be
negative.
2025-07-14 00:16:49 -07:00
Andrew Kelley
9a1f4cb011 std.net: update to new I/O API 2025-07-14 00:16:49 -07:00
Andrew Kelley
5496901e71 std.Io.Reader.appendRemaining: add missing assert 2025-07-14 00:14:21 -07:00
Andrew Kelley
093fe02b75 add adaptToNewApi to std.Io.Reader as well 2025-07-14 00:14:21 -07:00
Andrew Kelley
96a4e9b866 std.crypto: fix Sha1 namespace 2025-07-14 00:14:21 -07:00
xdBronch
5a8acc9115 fix some llvm ir printer bugs 2025-07-14 08:31:54 +02:00
Brandon Black
e8a4e47d38 Add setsid to std.(c|posix)
The interface and errors for this seem to be very universal and
generic. Note Linux already has this defined as a syscall as well.
2025-07-14 07:26:49 +02:00
Alex Rønne Petersen
c6a18e9534 libcxx: fix building for wasm32-wasi by disabling exceptions
I accidentally regressed this in the LLVM 20 upgrade.

Closes #24437.
2025-07-14 07:12:34 +02:00
Andrew Kelley
5696bbb307
Merge pull request #23552 from alichraghi
Progress towards support for running LLVM backend in a separate thread
2025-07-14 04:19:13 +02:00
Andrew Kelley
a558885321 LLVM backend: fixes
* delete dead code
* don't access stack trace too early
* revert unintended edit
2025-07-13 12:16:31 -07:00
Ali Cheraghi
041bcbd109 Do not store StackTrace type 2025-07-13 12:16:31 -07:00
antlilja
e3b79d65d8 LLVM: Move pt field from Object to NavGen
* LLVM: Pass correct tid to emit
* Store stack trace type in Zcu
* Don't use pt.errorIntType in LLVM backend
2025-07-13 12:16:17 -07:00
Andrew Kelley
e7b18a7ce6 std.crypto: remove inline from most functions
To quote the language reference,

It is generally better to let the compiler decide when to inline a
function, except for these scenarios:

* To change how many stack frames are in the call stack, for debugging
  purposes.
* To force comptime-ness of the arguments to propagate to the return
  value of the function, as in the above example.
* Real world performance measurements demand it. Don't guess!

Note that inline actually restricts what the compiler is allowed to do.
This can harm binary size, compilation speed, and even runtime
performance.

`zig run lib/std/crypto/benchmark.zig -OReleaseFast`
[-before-] vs {+after+}

              md5:        [-990-]        {+998+} MiB/s
             sha1:       [-1144-]       {+1140+} MiB/s
           sha256:       [-2267-]       {+2275+} MiB/s
           sha512:        [-762-]        {+767+} MiB/s
         sha3-256:        [-680-]        {+683+} MiB/s
         sha3-512:        [-362-]        {+363+} MiB/s
        shake-128:        [-835-]        {+839+} MiB/s
        shake-256:        [-680-]        {+681+} MiB/s
   turboshake-128:       [-1567-]       {+1570+} MiB/s
   turboshake-256:       [-1276-]       {+1282+} MiB/s
          blake2s:        [-778-]        {+789+} MiB/s
          blake2b:       [-1071-]       {+1086+} MiB/s
           blake3:       [-1148-]       {+1137+} MiB/s
            ghash:      [-10044-]      {+10033+} MiB/s
          polyval:       [-9726-]      {+10033+} MiB/s
         poly1305:       [-2486-]       {+2703+} MiB/s
         hmac-md5:        [-991-]        {+998+} MiB/s
        hmac-sha1:       [-1134-]       {+1137+} MiB/s
      hmac-sha256:       [-2265-]       {+2288+} MiB/s
      hmac-sha512:        [-765-]        {+764+} MiB/s
      siphash-2-4:       [-4410-]       {+4438+} MiB/s
      siphash-1-3:       [-7144-]       {+7225+} MiB/s
   siphash128-2-4:       [-4397-]       {+4449+} MiB/s
   siphash128-1-3:       [-7281-]       {+7374+} MiB/s
  aegis-128x4 mac:      [-73385-]      {+74523+} MiB/s
  aegis-256x4 mac:      [-30160-]      {+30539+} MiB/s
  aegis-128x2 mac:      [-66662-]      {+67267+} MiB/s
  aegis-256x2 mac:      [-16812-]      {+16806+} MiB/s
   aegis-128l mac:      [-33876-]      {+34055+} MiB/s
    aegis-256 mac:       [-8993-]       {+9087+} MiB/s
         aes-cmac:       2036 MiB/s
           x25519:      [-20670-]      {+16844+} exchanges/s
          ed25519:      [-29763-]      {+29576+} signatures/s
       ecdsa-p256:       [-4762-]       {+4900+} signatures/s
       ecdsa-p384:       [-1465-]       {+1500+} signatures/s
  ecdsa-secp256k1:       [-5643-]       {+5769+} signatures/s
          ed25519:      [-21926-]      {+21721+} verifications/s
          ed25519:      [-51200-]      {+50880+} verifications/s (batch)
 chacha20Poly1305:       [-1189-]       {+1109+} MiB/s
xchacha20Poly1305:       [-1196-]       {+1107+} MiB/s
 xchacha8Poly1305:       [-1466-]       {+1555+} MiB/s
 xsalsa20Poly1305:        [-660-]        {+620+} MiB/s
      aegis-128x4:      [-76389-]      {+78181+} MiB/s
      aegis-128x2:      [-53946-]      {+53495+} MiB/s
       aegis-128l:      [-27219-]      {+25621+} MiB/s
      aegis-256x4:      [-49351-]      {+49542+} MiB/s
      aegis-256x2:      [-32390-]      {+32366+} MiB/s
        aegis-256:       [-8881-]       {+8944+} MiB/s
       aes128-gcm:       [-6095-]       {+6205+} MiB/s
       aes256-gcm:       [-5306-]       {+5427+} MiB/s
       aes128-ocb:       [-8529-]      {+13974+} MiB/s
       aes256-ocb:       [-7241-]       {+9442+} MiB/s
        isapa128a:        [-204-]        {+214+} MiB/s
    aes128-single:  [-133857882-]  {+134170944+} ops/s
    aes256-single:   [-96306962-]   {+96408639+} ops/s
         aes128-8: [-1083210101-] {+1073727253+} ops/s
         aes256-8:  [-762042466-]  {+767091778+} ops/s
           bcrypt:      0.009 s/ops
           scrypt:      [-0.018-]      {+0.017+} s/ops
           argon2:      [-0.037-]      {+0.060+} s/ops
      kyber512d00:     [-206057-]     {+205779+} encaps/s
      kyber768d00:     [-156074-]     {+150711+} encaps/s
     kyber1024d00:     [-116626-]     {+115469+} encaps/s
      kyber512d00:     [-181149-]     {+182046+} decaps/s
      kyber768d00:     [-136965-]     {+135676+} decaps/s
     kyber1024d00:     [-101307-]     {+100643+} decaps/s
      kyber512d00:     [-123624-]     {+123375+} keygen/s
      kyber768d00:      [-69465-]      {+70828+} keygen/s
     kyber1024d00:      [-43117-]      {+43208+} keygen/s
2025-07-13 18:26:13 +02:00
Marcos Gutiérrez Alonso
f97baca6f6
Add documentation to std.crypto.aes_gcm.AesGcm.encrypt (#24427) 2025-07-13 07:33:08 +00:00
Joost Doornbos
3974540e5a Fix memory leak in CObject.Diag.Bundle.destroy() 2025-07-13 04:38:58 +02:00
mlugg
549a466dd1 std.Io.Reader: encourage inlining hot buffer check
Resolves: #24424
2025-07-12 23:52:13 +02:00
Carmen
5b4e982169
std.os.uefi.tables: ziggify boot and runtime services (#23441)
* std.os.uefi.tables: ziggify boot and runtime services

* avoid T{} syntax

Co-authored-by: linusg <mail@linusgroh.de>

* misc fixes

* work

* self-review quickfixes

* dont make MemoryMapSlice generic

* more review fixes, work

* more work

* more work

* review fixes

* update boot/runtime services references throughout codebase

* self-review fixes

* couple of fixes i forgot to commit earlier

* fixes from integrating in my own project

* fixes from refAllDeclsRecursive

* Apply suggestions from code review

Co-authored-by: truemedian <truemedian@gmail.com>

* more fixes from review

* fixes from project integration

* make natural alignment of Guid align-8

* EventRegistration is a new opaque type

* fix getNextHighMonotonicCount

* fix locateProtocol

* fix exit

* partly revert 7372d65

* oops exit data_len is num of bytes

* fixes from project integration

* MapInfo consistency, MemoryType update per review

* turn EventRegistration back into a pointer

* forgot to finish updating MemoryType methods

* fix IntFittingRange calls

* set uefi.Page nat alignment

* Back out "set uefi.Page nat alignment"

This backs out commit cdd9bd6f7f5fb763f994b8fbe3e1a1c2996a2393.

* get rid of some error.NotFound-s

* fix .exit call in panic

* review comments, add format method

* fix resetSystem data alignment

* oops, didnt do a final refAllDeclsRecursive i guess

* review comments

* writergate update MemoryType.format

* fix rename

---------

Co-authored-by: linusg <mail@linusgroh.de>
Co-authored-by: truemedian <truemedian@gmail.com>
2025-07-12 17:18:53 +00:00
Alex Rønne Petersen
bd97b66186 ci: Add riscv64-linux-debug and riscv64-linux-release 2025-07-12 03:24:28 +02:00
Alex Rønne Petersen
681d324c49 std.Build.Step.Run: Set WINEDEBUG=-all for -fwine by default.
This silences the excessive default stderr logging from Wine. The user can still
override this by setting WINEDEBUG in the environment; this just provides a more
sensible default.

Closes #24139.
2025-07-12 00:03:02 +02:00
Alex Rønne Petersen
f4ed35f800 test: disable non-native loongarch64 behavior and std tests
https://github.com/ziglang/zig/issues/24405
2025-07-11 21:31:27 +02:00
mochalins
61eff7b6dd std: Fix Io.Reader.Limited and add test 2025-07-11 17:46:14 +02:00
Atlas Yu
2cda4cfb39 std.posix.send: should expect ConnectionRefused
Closes: #20219
2025-07-11 13:06:13 +02:00
Andrew Kelley
b60e9f2e85
Merge pull request #24394 from ziglang/fixes
buffering fixes
2025-07-11 10:56:24 +02:00
Linus Groh
eb37552536 Remove numerous things deprecated during the 0.14 release cycle
Basically everything that has a direct replacement or no uses left.

Notable omissions:

- std.ArrayHashMap: Too much fallout, needs a separate cleanup.
- std.debug.runtime_safety: Too much fallout.
- std.heap.GeneralPurposeAllocator: Lots of references to it remain, not
  a simple find and replace as "debug allocator" is not equivalent to
  "general purpose allocator".
- std.io.Reader: Is being reworked at the moment.
- std.unicode.utf8Decode(): No replacement, needs a new API first.
- Manifest backwards compat options: Removal would break test data used
  by TestFetchBuilder.
- panic handler needs to be a namespace: Many tests still rely on it
  being a function, needs a separate cleanup.
2025-07-11 08:17:43 +02:00
Anton Serov
d83b95cbf4 fixed .fixed flush recursion 2025-07-11 05:17:31 +02:00
Isaac Freund
f551c7c581 link.Elf: check files in archives for ELF magic
Apparently raw LLVM IR Bitcode files ("Bitstreams") may appear in
archives with LTO enabled. I observed this in the wild on
Chimera Linux.

I'm not yet sure if it's in scope for Zig to support these special
archives, but we should at least give a correct error message.
2025-07-11 04:57:54 +02:00
Andrew Kelley
e255415498 std: add some missing doc comments 2025-07-10 16:52:29 -07:00
Andrew Kelley
88e50b30c3 std.debug.print: provide a small buffer 2025-07-10 16:52:29 -07:00
Andrew Kelley
bd5745ddf2 std.log.defaultLog: provide a small buffer 2025-07-10 16:52:29 -07:00
Andrew Kelley
5360968e03 std: rename io to Io in preparation
This commit is non-breaking.

std.io is deprecated in favor of std.Io, in preparation for that
namespace becoming an interface.
2025-07-11 01:16:27 +02:00
Andrew Kelley
43fba5ea83
Merge pull request #24387 from ziglang/std.log.default_level
std.log: adjust default level for ReleaseSmall to include info + bonus cleanup
2025-07-10 14:56:33 +02:00