Commit Graph

31792 Commits

Author SHA1 Message Date
Andrew Kelley
3ce6de8765 revert langref section "common errdefer slip ups"
Some checks are pending
ci / x86_64-linux-debug (push) Waiting to run
ci / x86_64-linux-release (push) Waiting to run
ci / aarch64-linux-debug (push) Waiting to run
ci / aarch64-linux-release (push) Waiting to run
ci / x86_64-macos-release (push) Waiting to run
ci / aarch64-macos-debug (push) Waiting to run
ci / aarch64-macos-release (push) Waiting to run
ci / x86_64-windows-debug (push) Waiting to run
ci / x86_64-windows-release (push) Waiting to run
ci / aarch64-windows (push) Waiting to run
This does not belong in the language reference.

reverts 91a88a789f
2024-11-26 15:03:24 -08:00
Andrew Kelley
11bf2d92de diversify "unable to spawn" failure messages
to help understand where a spurious failure is occurring
2024-11-26 13:56:40 -08:00
Andrew Kelley
68b3f50866
Merge pull request #22070 from Rexicon226/fix-crc32
add `crc32` as a feature dep of `sse4.2` and refactor `update_cpu_feature.zig`
2024-11-26 16:29:51 -05:00
Alex Rønne Petersen
047311a76a std.math: Disable isSignalNan test on mips32.
https://github.com/ziglang/zig/issues/14366
2024-11-26 18:29:13 +01:00
Chris Boesch
87863a834b
std.math.complex: Add squared magnitude function (#21998)
Some checks are pending
ci / x86_64-linux-debug (push) Waiting to run
ci / x86_64-linux-release (push) Waiting to run
ci / aarch64-linux-debug (push) Waiting to run
ci / aarch64-linux-release (push) Waiting to run
ci / x86_64-macos-release (push) Waiting to run
ci / aarch64-macos-debug (push) Waiting to run
ci / aarch64-macos-release (push) Waiting to run
ci / x86_64-windows-debug (push) Waiting to run
ci / x86_64-windows-release (push) Waiting to run
ci / aarch64-windows (push) Waiting to run
2024-11-26 13:03:48 +00:00
Andrew Kelley
b0dcce93f7
Merge pull request #22075 from ziglang/fix-broken-pipe
Some checks are pending
ci / x86_64-linux-debug (push) Waiting to run
ci / x86_64-linux-release (push) Waiting to run
ci / aarch64-linux-debug (push) Waiting to run
ci / aarch64-linux-release (push) Waiting to run
ci / x86_64-macos-release (push) Waiting to run
ci / aarch64-macos-debug (push) Waiting to run
ci / aarch64-macos-release (push) Waiting to run
ci / x86_64-windows-debug (push) Waiting to run
ci / x86_64-windows-release (push) Waiting to run
ci / aarch64-windows (push) Waiting to run
std.io.Poller: handle EPIPE as EOF
2024-11-26 00:36:33 -05:00
David Rubin
a6af55cc6e ip: cleanup @constCast usages 2024-11-25 18:41:36 -05:00
Andrew Kelley
f6392b9526 cmake: don't add an unnecessary curses static lib dependency 2024-11-25 15:05:42 -08:00
Andrew Kelley
21f0fce28b CI: update macOS runner to 13
Apple has already dropped support for macOS 12.
GitHub Actions is dropping macOS 12 support now.
The Zig project is also dropping macOS 12 support now.

This commit also bumps default minimum macos version to 13.
2024-11-25 15:00:10 -08:00
Andrew Kelley
775b48dd10 std.io.Poller: handle EPIPE as EOF
closes #17483
2024-11-25 14:18:55 -08:00
Andrew Kelley
aa5341bf85 std.process.Child: explicit error set for wait 2024-11-25 14:18:55 -08:00
Andrew Kelley
f4e042a4c3
Merge pull request #21858 from francescoalemanno/patch-1
Some checks are pending
ci / x86_64-linux-debug (push) Waiting to run
ci / x86_64-linux-release (push) Waiting to run
ci / aarch64-linux-debug (push) Waiting to run
ci / aarch64-linux-release (push) Waiting to run
ci / x86_64-macos-release (push) Waiting to run
ci / aarch64-macos-debug (push) Waiting to run
ci / aarch64-macos-release (push) Waiting to run
ci / x86_64-windows-debug (push) Waiting to run
ci / x86_64-windows-release (push) Waiting to run
ci / aarch64-windows (push) Waiting to run
add improved std.hash.int - deprecate std.hash.uint32
2024-11-25 17:00:17 -05:00
David Rubin
f36f7d54a7
refactor update_cpu_features.zig
Most of this commit is whitespace changes, moving to use RLS
for assigning the `CpuModel`
2024-11-25 01:11:15 -08:00
David Rubin
9e17e097e5
make crc32 a featdep of sse4.2
To my knowledge there isn't an implementation of `sse4.2` that doesn't have `crc32`.
The Clang driver also sets `crc32` to be implicitly enabled when an explicit `-crc32`
wasn't provided. This matches that behaviour.

We need this behaviour to compile libraries like `rocksdb` which currently guard against
`crc32` intrinsics by checking for `sse4.2`.
2024-11-25 01:11:15 -08:00
David Rubin
bc3ed51b7f
cleanup update_cpu_feature.zig
* Cleanup the argument handling logic to allow for optional arguments.
* Add a filter for which `llvm_target` to process.
* Switch to using a threadpool, needed for skipping llvm targets cleanly
  and better distributes the work.
* Remove a seemingly useless piece of logic. I re-ran the script and it gave identical outputs.
2024-11-25 01:11:06 -08:00
Andrew Kelley
ca67f80b6e std.hash.int: avoid words like "easy" and "fast" in doc comments 2024-11-24 15:30:52 -08:00
Francesco Alemanno
ae6c24b490 std.hash.int: better handle odd bit sizes
Uses the non rational solution of a quadratic, I made it work up to 256
bits, added Mathematica code in case anyone wants to verify the magic
constant.

integers between sizes 3...15 were affected by fatal bias, it is best to
make them pass through the generic solution.

Thanks to RetroDev256 & Andrew feedback.
2024-11-24 15:29:20 -08:00
Andrew Kelley
d09fd249c0 std.hash.int: restore previous behavior
In the parent commit, I handled odd bit sizes by upcasting and
truncating. However it seems the else branch is intended to handle
those cases instead, so this commit reverts that behavior.
2024-11-24 15:27:03 -08:00
Andrew Kelley
5ad44c14b0 std.hash.int: use anytype instead of explicit type parameter
also
* allow signed ints, simply bitcast them to unsigned
* handle odd bit sizes by upcasting and then truncating
* naming conventions
* remove redundant code
* better use of testing API
2024-11-24 15:27:03 -08:00
Francesco Alemanno
aee6f7d7ee std.hash: improve simple hashing of unsigned integers
Before, the default bit mixer was very biased, and after a
lot of searching it turns out that selecting a better solution is hard.

I wrote a custom statistical analysis taylored for bit mixers in order
to select the best one at each size (u64/u32/u16), compared a lot of
mixers, and packaged the best ones in this commit.
2024-11-24 15:27:03 -08:00
Ilia Choly
e2f24a2d70 Allocator.free: document zero-length behavior
Some checks are pending
ci / x86_64-linux-debug (push) Waiting to run
ci / x86_64-linux-release (push) Waiting to run
ci / aarch64-linux-debug (push) Waiting to run
ci / aarch64-linux-release (push) Waiting to run
ci / x86_64-macos-release (push) Waiting to run
ci / aarch64-macos-debug (push) Waiting to run
ci / aarch64-macos-release (push) Waiting to run
ci / x86_64-windows-debug (push) Waiting to run
ci / x86_64-windows-release (push) Waiting to run
ci / aarch64-windows (push) Waiting to run
It wasn't immediately clear from the implementation whether passing
zero-length memory to free() was undefined behavior or intentionally
supported. Since ArrayList and other core data structures rely on
this behavior working correctly, this should be explicitly documented
as part of the public API contract.
2024-11-24 18:19:11 -05:00
Bruno Reis
c2db5d9cd1 treat errno(6) (NXIO) as expected error in openatZ 2024-11-24 18:17:56 -05:00
Andrew Barchuk
1f37b70344
Remove unused buf field from std.fmt.Parser (#21994)
And make the initialization less error prone by removing a default for
iter, which is required for a functional parser

std: Add a brief doc comment for `std.fmt.Parser`
2024-11-24 15:09:36 -08:00
Fri3dNstuff
b2030cb9ab
std.meta.eql: use == directly when comparing packed structs (#21982) 2024-11-24 14:29:44 -08:00
Jacob Young
c894ac09a3 dwarf: fix stepping through an inline loop containing one statement
Previously, stepping from the single statement within the loop would
always exit the loop because all of the code unrolled from the loop is
associated with the same line and treated by the debugger as one line.
2024-11-24 17:28:12 -05:00
Alex Rønne Petersen
6d781e0955
Merge pull request #22062 from alexrp/hexagon-fixes
Some checks are pending
ci / x86_64-linux-debug (push) Waiting to run
ci / x86_64-linux-release (push) Waiting to run
ci / aarch64-linux-debug (push) Waiting to run
ci / aarch64-linux-release (push) Waiting to run
ci / x86_64-macos-release (push) Waiting to run
ci / aarch64-macos-debug (push) Waiting to run
ci / aarch64-macos-release (push) Waiting to run
ci / x86_64-windows-debug (push) Waiting to run
ci / x86_64-windows-release (push) Waiting to run
ci / aarch64-windows (push) Waiting to run
Some follow-up fixes for #22029
2024-11-24 18:47:21 +01:00
Alex Rønne Petersen
e163ae794b ci: Update to QEMU 9.2.0-rc1 in x86_64-linux scripts.
Some checks are pending
ci / x86_64-linux-debug (push) Waiting to run
ci / x86_64-linux-release (push) Waiting to run
ci / aarch64-linux-debug (push) Waiting to run
ci / aarch64-linux-release (push) Waiting to run
ci / x86_64-macos-release (push) Waiting to run
ci / aarch64-macos-debug (push) Waiting to run
ci / aarch64-macos-release (push) Waiting to run
ci / x86_64-windows-debug (push) Waiting to run
ci / x86_64-windows-release (push) Waiting to run
ci / aarch64-windows (push) Waiting to run
2024-11-24 08:35:08 +01:00
Alex Rønne Petersen
aa19e71a27
zig.h: Add zig_trap() and zig_breakpoint() implementations for Hexagon. 2024-11-24 08:19:15 +01:00
Alex Rønne Petersen
62074ec61b
compiler-rt: Fix Hexagon routines to use the new @export() pointer semantics. 2024-11-24 08:19:15 +01:00
Alex Rønne Petersen
47f84acc12
compiler-rt: Remove duplicate __hexagon_divsf3 export. 2024-11-24 08:19:15 +01:00
Alex Rønne Petersen
1285d41186
compiler-rt: Fix duplicate labels in Hexagon routines. 2024-11-24 08:19:15 +01:00
Jacob Young
70ad7dcd48 lldb: implement tuple types
Some checks are pending
ci / x86_64-linux-debug (push) Waiting to run
ci / x86_64-linux-release (push) Waiting to run
ci / aarch64-linux-debug (push) Waiting to run
ci / aarch64-linux-release (push) Waiting to run
ci / x86_64-macos-release (push) Waiting to run
ci / aarch64-macos-debug (push) Waiting to run
ci / aarch64-macos-release (push) Waiting to run
ci / x86_64-windows-debug (push) Waiting to run
ci / x86_64-windows-release (push) Waiting to run
ci / aarch64-windows (push) Waiting to run
2024-11-23 23:51:35 -05:00
Andrew Kelley
ed8955cea6
Merge pull request #22049 from alexrp/musl-gen-stubs
`gen_stubs`: No compiler-rt hacks, more compact output, and more arch support
2024-11-23 23:50:36 -05:00
Brian Cain
4aa6246345
compiler_rt: Add hexagon builtins (#22029)
Signed-off-by: Brian Cain <bcain@quicinc.com>
Signed-off-by: Brian Cain <brian.cain@oss.qualcomm.com>
Co-authored-by: Alex Rønne Petersen <alex@alexrp.com>
2024-11-24 01:17:21 +00:00
Alex Rønne Petersen
aef5c75602 compiler: Disallow align(0) everywhere in the language.
Thus leaving the design space for this alignment value open, e.g. for packing.
2024-11-23 18:44:07 -05:00
Alex Rønne Petersen
2742ab4b5a compiler-rt: Fix R_ARM_ABS32 relocation error in __clzsi2_thumb1().
Some checks are pending
ci / x86_64-linux-debug (push) Waiting to run
ci / x86_64-linux-release (push) Waiting to run
ci / aarch64-linux-debug (push) Waiting to run
ci / aarch64-linux-release (push) Waiting to run
ci / x86_64-macos-release (push) Waiting to run
ci / aarch64-macos-debug (push) Waiting to run
ci / aarch64-macos-release (push) Waiting to run
ci / x86_64-windows-debug (push) Waiting to run
ci / x86_64-windows-release (push) Waiting to run
ci / aarch64-windows (push) Waiting to run
Closes #22050.
2024-11-23 17:53:31 +01:00
Alex Rønne Petersen
67e524da54
musl: Update libc.S against musl 1.2.5.
All supported architectures included except for x32 (currently broken).
2024-11-23 03:10:58 +01:00
Alex Rønne Petersen
57e4fa14bb
musl: Define TIME32 and FAMILY_* macros for libc.S as appropriate.
Also adjust ARCH_* logic for the updated gen_stubs.zig tool.
2024-11-23 03:10:58 +01:00
Alex Rønne Petersen
fc8a4c445d
gen_stubs: Require less manual intervention and produce better output.
The tool will now skip over undefined symbols. These can only occur as a result
of building musl without compiler-rt, i.e. -rtlib=none. Thanks to this, it's no
longer necessary to patch Zig's compiler-rt, nor is it necessary to maintain a
symbol blacklist.

See the updated instructions here: https://github.com/ziglang/zig/wiki/Updating-libc#updating-the-libcs-file

Additionally, the tool now produces slightly more compact output by recognizing
symbols that are defined for a single arch, for a family of arches, or only for
arches using 32-bit or 64-bit time as their primary ABI.

Finally, the tool now supports all architectures that we can emit code for, with
the single exception of x86_64-linux-muslx32. (x32 currently fails with a ton of
relocation errors, leading me to believe that it might be an LLVM or LLD bug.)
2024-11-23 03:10:58 +01:00
Alex Rønne Petersen
cc73d7ad74
musl: Mark __tls_get_addr as hidden before invoking it on s390x.
https://www.openwall.com/lists/musl/2024/11/23/3
2024-11-23 03:10:54 +01:00
David Rubin
66a7c09def link: use target to determine risc-v eflag validity
Some checks are pending
ci / x86_64-linux-debug (push) Waiting to run
ci / x86_64-linux-release (push) Waiting to run
ci / aarch64-linux-debug (push) Waiting to run
ci / aarch64-linux-release (push) Waiting to run
ci / x86_64-macos-release (push) Waiting to run
ci / aarch64-macos-debug (push) Waiting to run
ci / aarch64-macos-release (push) Waiting to run
ci / x86_64-windows-debug (push) Waiting to run
ci / x86_64-windows-release (push) Waiting to run
ci / aarch64-windows (push) Waiting to run
2024-11-22 19:34:47 -05:00
Alex Rønne Petersen
4972a871c5
musl: Mark __restore(_rt) functions hidden on riscv.
https://www.openwall.com/lists/musl/2024/11/23/2
2024-11-23 01:24:35 +01:00
Alex Rønne Petersen
ea26af0b9d
musl: Set symbol type for the START function on i386 and x86_64.
https://www.openwall.com/lists/musl/2024/11/23/1
2024-11-23 01:23:02 +01:00
Alex Rønne Petersen
8b2b9aa019
Compilation: Consider *.lo files to be object files.
Fixes musl libc.so compilation with zig cc.
2024-11-23 01:22:20 +01:00
Scott Redig
b2c62bcbf6 add assertLocked to std.debug.SafetyLock 2024-11-22 18:39:17 -05:00
Frank Denis
73dcd19140
std.crypto.bcrypt: implement the actual OpenSSH KDF (#22027)
Some checks are pending
ci / x86_64-linux-debug (push) Waiting to run
ci / x86_64-linux-release (push) Waiting to run
ci / aarch64-linux-debug (push) Waiting to run
ci / aarch64-linux-release (push) Waiting to run
ci / x86_64-macos-release (push) Waiting to run
ci / aarch64-macos-debug (push) Waiting to run
ci / aarch64-macos-release (push) Waiting to run
ci / x86_64-windows-debug (push) Waiting to run
ci / x86_64-windows-release (push) Waiting to run
ci / aarch64-windows (push) Waiting to run
They way OpenSSH does key derivation to protect keys using a password
is not the standard PBKDF2, but something funky, picking key material
non-linearly.
2024-11-22 10:02:14 +01:00
Frank Denis
636308a17d
std.crypto.aes: introduce AES block vectors (#22023)
* std.crypto.aes: introduce AES block vectors

Modern Intel CPUs with the VAES extension can handle more than a
single AES block per instruction.

So can some ARM and RISC-V CPUs. Software implementations with
bitslicing can also greatly benefit from this.

Implement low-level operations on AES block vectors, and the
parallel AEGIS variants on top of them.

AMD Zen4:

      aegis-128x4:      73225 MiB/s
      aegis-128x2:      51571 MiB/s
       aegis-128l:      25806 MiB/s
      aegis-256x4:      46742 MiB/s
      aegis-256x2:      30227 MiB/s
        aegis-256:       8436 MiB/s
       aes128-gcm:       5926 MiB/s
       aes256-gcm:       5085 MiB/s

AES-GCM, and anything based on AES-CTR are also going to benefit
from this later.

* Make AEGIS-MAC twice a fast
2024-11-22 10:00:49 +01:00
Alex Rønne Petersen
f845fa04a0 std.debug: Gracefully handle process_vm_readv() EPERM in MemoryAccessor.read().
Some checks failed
ci / x86_64-linux-debug (push) Has been cancelled
ci / x86_64-linux-release (push) Has been cancelled
ci / aarch64-linux-debug (push) Has been cancelled
ci / aarch64-linux-release (push) Has been cancelled
ci / x86_64-macos-release (push) Has been cancelled
ci / aarch64-macos-debug (push) Has been cancelled
ci / aarch64-macos-release (push) Has been cancelled
ci / x86_64-windows-debug (push) Has been cancelled
ci / x86_64-windows-release (push) Has been cancelled
ci / aarch64-windows (push) Has been cancelled
Closes #21815.
2024-11-20 23:07:46 +01:00
Frank Denis
a5d4ad17b7
crypto.keccak.State: add checks to prevent insecure transitions (#22020)
Some checks are pending
ci / x86_64-linux-debug (push) Waiting to run
ci / x86_64-linux-release (push) Waiting to run
ci / aarch64-linux-debug (push) Waiting to run
ci / aarch64-linux-release (push) Waiting to run
ci / x86_64-macos-release (push) Waiting to run
ci / aarch64-macos-debug (push) Waiting to run
ci / aarch64-macos-release (push) Waiting to run
ci / x86_64-windows-debug (push) Waiting to run
ci / x86_64-windows-release (push) Waiting to run
ci / aarch64-windows (push) Waiting to run
* crypto.keccak.State: don't unconditionally permute after a squeeze()

Now, squeeze() behaves like absorb()

Namely,

squeeze(x[0..t]);
squeeze(x[t..n)); with t <= n

becomes equivalent to squeeze(x[0..n]).

* keccak: in debug mode, track transitions to prevent insecure ones.

Fixes #22019
2024-11-20 11:16:09 +01:00
Shawn Gao
dafe1a910d Append disabled LLVM CPU features after enabled ones 2024-11-20 10:09:03 +01:00