Commit Graph

33874 Commits

Author SHA1 Message Date
Andrew Kelley faab6d5cbf fix hello world 2025-07-01 16:35:26 -07:00
Jacob Young 1501734747 io: fix compile errors 2025-07-01 16:35:26 -07:00
Jacob Young 5d22c588e2 ubsan_rt: port to new std.io.BufferedWriter API 2025-07-01 16:35:26 -07:00
Jacob Young d76c8d0bd2 Dwarf: cleanup and port to new std.io.BufferedReader API 2025-07-01 16:35:26 -07:00
Andrew Kelley 9dc0b4a98f back to the anyerror!usize vtable 2025-07-01 16:35:26 -07:00
Andrew Kelley 6ac7931bec std: hacking around with buffered reader / writer semantics
I think I'm going to back out these vtable changes in the next commit
2025-07-01 16:35:26 -07:00
Andrew Kelley 890a02c345 std.io: move getStdIn, getStdOut, getStdErr functions to fs.File
preparing to rearrange std.io namespace into an interface
2025-07-01 16:35:26 -07:00
Andrew Kelley 6c48aad991 update some more std lib API to new Reader/Writer
std.compress needs an audit, I see some problems
2025-07-01 16:35:26 -07:00
Andrew Kelley 31e0b5c3c7 fix merge conflicts
partially reapply b636d56d6a
2025-07-01 16:35:26 -07:00
Andrew Kelley 57e1fc29d2 reader interface vecs and bufferedwriter arraylist 2025-07-01 16:35:26 -07:00
Andrew Kelley 5aa8573f2b redo reader 2025-07-01 16:35:26 -07:00
Andrew Kelley 2fb6ce2f92 update some more compiler code 2025-07-01 16:35:26 -07:00
Andrew Kelley 4aed226e07 zig fmt compiling 2025-07-01 16:35:26 -07:00
Andrew Kelley 5ada2e3937 std.http tests passing with updated writer API
fix splat implementation in std.fs.File

update http.Client, with caveats:
 * TODO: only 1 underlying write call
 * TODO: don't rely on max_buffers_len exceeding the caller
 * TODO: handle splat

update net.Stream API. also make it use WSASend on windows
2025-07-01 16:35:26 -07:00
Andrew Kelley 6c7b103122 std.crypto.tls.Client: upgrade to std.io.BufferedWriter
This is pretty clearly a better API.
2025-07-01 16:35:26 -07:00
Andrew Kelley d87b59f5a5 std.fmt.format: support base 64 encoding 2025-07-01 16:35:26 -07:00
Andrew Kelley 8464efa5dd std.posix.sendfile: don't write trailers on linux
After sending the file, better to return total bytes written. The caller
will decide if they want to do another syscall with the trailers. Maybe
the caller would rather buffer them.
2025-07-01 16:35:26 -07:00
Nameless a500651370 os: fix missing and incorrect msghdr definitions
Macos uses the BSD definition of msghdr

All linux architectures share a single msghdr definition. Many
architectures had manually inserted padding fields that were endian
specific and some had fields with different integers. This unifies all
architectures to use a single correct msghdr definition.
2025-07-01 16:35:26 -07:00
Andrew Kelley bf00eb3006 more of the compiler updated to new Writer API 2025-07-01 16:35:26 -07:00
Andrew Kelley 09af68de80 fix duration formatting 2025-07-01 16:35:26 -07:00
Andrew Kelley 051c7af49a get std lib json tests passing 2025-07-01 16:35:26 -07:00
Andrew Kelley e154b62d63 give std.json an API spanking
Avoid Redundant Names in Fully-Qualified Namespaces
2025-07-01 16:35:26 -07:00
Andrew Kelley 7569494b45 fix byte formatted printing 2025-07-01 16:35:26 -07:00
Andrew Kelley bb1dffcf32 much of the compiler upgraded to new API 2025-07-01 16:35:26 -07:00
Andrew Kelley f3be721785 build runner compiling 2025-07-01 16:35:26 -07:00
Andrew Kelley 716b4489be update more of the std lib to new API 2025-07-01 16:35:26 -07:00
Andrew Kelley e60adb97d0 AllocatingWriter passing unit test 2025-07-01 16:35:26 -07:00
Andrew Kelley fced9467e8 std ArrayList unit tests passing 2025-07-01 16:35:26 -07:00
Andrew Kelley 221b194f28 std.io.BufferedWriter: implement hex string printing 2025-07-01 16:35:26 -07:00
Andrew Kelley 824216b1d4 remove legacy writer from array list 2025-07-01 16:35:25 -07:00
Andrew Kelley ff3581ca2d update some of the build system to new API 2025-07-01 16:35:25 -07:00
Andrew Kelley 1d0495678d fixes
writeFile should be split into two
2025-07-01 16:35:25 -07:00
Andrew Kelley 35824e4822 writeSplat 2025-07-01 16:35:25 -07:00
Andrew Kelley b26aceba7d thinking about splat being the only function 2025-07-01 16:35:25 -07:00
Andrew Kelley 5356f3a307 migrate some std lib 2025-07-01 16:35:25 -07:00
Andrew Kelley c2fc6b0b6c ArrayListWriter 2025-07-01 16:35:25 -07:00
Andrew Kelley 00c6c836a6 std: start reworking std.io
hello world is compiling
2025-07-01 16:35:25 -07:00
Ivan Stepanov ee6d19480d spirv: fix signed overflow detection for safe subtraction
The overflow check for safe signed subtraction was using the formula (rhs < 0) == (lhs > result). This logic is flawed and incorrectly reports an overflow when the right-hand side is zero.
For the expression 42 - 0, this check evaluated to (0 < 0) == (42 > 42), which is false == false, resulting in true. This caused the generated SPIR-V to incorrectly branch to an OpUnreachable instruction, preventing the result from being stored.

Fixes #24281.
2025-07-01 19:26:21 +02:00
Micah Switzer b8ac740a1b Fix zig std regression FTBFS
Regressed in 9176408
2025-06-30 18:06:14 +02:00
Andrew Kelley 79db39307b Merge pull request #24297 from ziglang/optional-empty-error-set
Sema: correct OPV for optional empty error set
2025-06-30 15:25:35 +02:00
Andrew Kelley d9742acc23 Sema: detect one-possible-value types after function calls
produces better Air for backends
2025-06-29 17:53:52 -07:00
Andrew Kelley 7999374b21 Sema: correct OPV for optional empty error set
prevents crashes in backends; improves codegen; provides more
comptime-ness.
2025-06-29 17:20:23 -07:00
Alex Rønne Petersen e837765956 zig rc: Fix include directory detection when cross-compiling from certain host archs (#24288)
* resinator: Only preprocess when the input is an .rc file

* resinator: Fix include directory detection when cross-compiling from certain host archs

Previously, resinator would use the host arch as the target arch when looking for windows-gnu include directories. However, Zig only thinks it can provide a libc for targets specified in the `std.zig.target.available_libcs` array, which only includes a few for windows-gnu. Therefore, when cross-compiling from a host architecture that doesn't have a windows-gnu target in the available_libcs list, resinator would fail to detect the MinGW include directories.

Now, the custom option `/:target` is passed to `zig rc` which is intended for the COFF object file target, but can be re-used for the include directory target as well. For the include directory target, resinator will convert the MachineType to the relevant arch, or fail if there is no  equivalent arch/no support for detecting the includes for the MachineType (currently 64-bit Itanium and EBC).

Fixes the `windows_resources` standalone test failing when the host is, for example, `riscv64-linux`.
2025-06-29 09:59:38 +02:00
Ryan Liptak d3363b7a61 Replace unreachable with error return for non-standard Windows targets
This new error mirrors the error returned from the Elf struct (error.UnsupportedElfArchitecture):

https://github.com/ziglang/zig/blob/0adcfd60f4fcfd01c74a6477cbcef187ce06f533/src/link/Lld.zig#L112

Before:

```
$ zig build-exe -target riscv64-windows-gnu main.zig
thread 543087 panic: reached unreachable code
```

After:

```
$ zig build-exe -target riscv64-windows-gnu main.zig
error: unable to create compilation: UnsupportedCoffArchitecture
```

Closes #24287
2025-06-29 08:32:19 +02:00
Alex Rønne Petersen 6322dbd5bf compiler: test runner: fix tests never fails on crippled architectures (#24180)
* compiler: test runner: fix tests never fails on crippled architectures

* riscv64: skip failing tests

* riscv64: enable test summary printing
2025-06-29 08:03:59 +02:00
Ryan Liptak 09f4e2d9d1 resinator: Fix include directory detection when cross-compiling from certain host archs
Previously, resinator would use the host arch as the target arch when looking for windows-gnu include directories. However, Zig only thinks it can provide a libc for targets specified in the `std.zig.target.available_libcs` array, which only includes a few for windows-gnu. Therefore, when cross-compiling from a host architecture that doesn't have a windows-gnu target in the available_libcs list, resinator would fail to detect the MinGW include directories.

Now, the custom option `/:target` is passed to `zig rc` which is intended for the COFF object file target, but can be re-used for the include directory target as well. For the include directory target, resinator will convert the MachineType to the relevant arch, or fail if there is no  equivalent arch/no support for detecting the includes for the MachineType (currently 64-bit Itanium and EBC).

Fixes the `windows_resources` standalone test failing when the host is, for example, `riscv64-linux`.
2025-06-28 19:52:18 -07:00
Ryan Liptak 761783f54d resinator: Only preprocess when the input is an .rc file 2025-06-28 19:43:22 -07:00
Bingwu Zhang ff06de4c89 riscv64: enable test summary printing 2025-06-28 06:47:09 +08:00
Bingwu Zhang e8d6ecb9ce riscv64: skip failing tests 2025-06-28 06:47:09 +08:00
Bingwu Zhang 5db395f20b compiler: test runner: fix tests never fails on crippled architectures 2025-06-27 19:12:16 +08:00