Commit Graph

36359 Commits

Author SHA1 Message Date
Andrew Kelley 691afee786 langref: fix build failure 2025-12-23 22:15:12 -08:00
Andrew Kelley 33e302d67a update remaining calls to std.Io.Threaded.init 2025-12-23 22:15:12 -08:00
Andrew Kelley 187d0a692d compiler: handle cancelation from finishPrelinkQueue 2025-12-23 22:15:12 -08:00
Andrew Kelley 7c1236e267 std: different way of doing some options
to avoid dependency loops
2025-12-23 22:15:12 -08:00
Andrew Kelley 9aee45be97 fix "zig std" compilation errors 2025-12-23 22:15:12 -08:00
Andrew Kelley 9158d3b281 std: remove ability to override Io.File.Permissions
This is causing another compiler dependency loop. I'll tackle these
overrides separately.
2025-12-23 22:15:12 -08:00
Andrew Kelley c98157a3c9 std.Io.Threaded: implement environment variable scanning 2025-12-23 22:15:12 -08:00
Andrew Kelley 0992f1204e std.debug: delete nosuspend blocks
now that the application can choose an Io implementation these might
actually suspend.
2025-12-23 22:15:12 -08:00
Andrew Kelley 78c4fcfcd8 std.debug.lockStderr: cancel protection rather than recancel
because we need to return the value
2025-12-23 22:15:12 -08:00
Andrew Kelley 3c2f5adf41 std: integrate Io.Threaded with environment variables
* std.option allows overriding the debug Io instance
* if the default is used, start code initializes environ and argv0

also fix some places that needed recancel(), thanks mlugg!

See #30562
2025-12-23 22:15:12 -08:00
Andrew Kelley 86e9e32cf0 std.Io: fix missing try in waitTimeout 2025-12-23 22:15:12 -08:00
Andrew Kelley a29d79313a std.Io.Threaded: accept argv and environ on init
This is needed unfortunately for OpenBSD and Haiku for process
executable path.

I made it so that you can omit the options usually, but you get a
compile error if you omit the options on those targets.
2025-12-23 22:15:12 -08:00
Michael Dusan 60481b8223 std.Io: trim terminating NUL from exe path on BSDs 2025-12-23 22:15:12 -08:00
Andrew Kelley 1132e329d3 std.Io.Threaded: fix up processExecutablePath OpenBSD
* policy is to always handle EINTR from all syscalls
* assert the result of realpath
* don't ignore errors from realpath
* hard-code path separators for code simplicity
2025-12-23 22:15:11 -08:00
Michael Dusan 7014976d3d openbsd: avoid error.OperationUnsupported
- realPathPosix does not support OpenBSD
- change processExecutablePath OpenBSD section to use std.c.realpath
2025-12-23 22:15:11 -08:00
Michael Dusan 8fdfeb624d openbsd: fix OS version detection
- do not include resulting nullz from sysctl MIB fetch
- fixes bug: "7.8<NULL>" is a std.Target.Query.parseVersion error
2025-12-23 22:15:11 -08:00
Michael Dusan 90bc371f56 openbsd: use Io.Dir.realPathFileAbsolute 2025-12-23 22:15:11 -08:00
Michael Dusan 486ed907f7 dragonfly: define std.c.nlink_t 2025-12-23 22:15:11 -08:00
Andrew Kelley 70e19ea353 update more "realpath" callsites 2025-12-23 22:15:11 -08:00
Ryan Liptak 51a6f3a525 Update a few more callsites for std.Io changes 2025-12-23 22:15:11 -08:00
Ryan Liptak 8968d75fb1 fileStat needs read permissions on Windows 2025-12-23 22:15:11 -08:00
Ryan Liptak bb788cd392 dirOpenFileWtf16: Disallow opening directories when requesting write permissions
This matches the behavior of POSIX
2025-12-23 22:15:11 -08:00
Ryan Liptak e442a0ecc2 Dir.readFile/readFileAlloc: take advantage of .allow_directory = false on Windows
Since we know the read will fail for directories, we can take advantage
of Windows being able to fail with IsDir during open to avoid needing to
wait until the read to find out about the directory-ness of the file.
2025-12-23 22:15:11 -08:00
Ryan Liptak ad08117e9d Fix sizing of buffer/reservation size for dirReadWindows 2025-12-23 22:15:11 -08:00
Andrew Kelley fd0c324cb0 std.debug: fix simple_panic 2025-12-23 22:15:11 -08:00
Andrew Kelley debf307594 update all incremental tests to new std API
they're still not passing on windows for some reason though
2025-12-23 22:15:11 -08:00
Andrew Kelley 77d2ad8c92 std: consolidate all instances of std.Io.Threaded into a singleton
It's better to avoid references to this global variable, but, in the
cases where it's needed, such as in std.debug.print and collecting stack
traces, better to share the same instance.
2025-12-23 22:15:11 -08:00
Andrew Kelley 50c585227e fix compilation of incr-check 2025-12-23 22:15:11 -08:00
Andrew Kelley 7d955274bb update the init templates to new std API 2025-12-23 22:15:11 -08:00
Andrew Kelley 2e4a6c88b5 compiler: fix test-unit compilation failures 2025-12-23 22:15:11 -08:00
Andrew Kelley 99f25bfc23 std.Io: implement directory reading for WASI 2025-12-23 22:15:11 -08:00
Andrew Kelley 98f05a0f53 compiler: update calls to realpath 2025-12-23 22:15:11 -08:00
Andrew Kelley 7423d6a404 fix "hello world"
14K -> 57K
2025-12-23 22:15:11 -08:00
Andrew Kelley e41342af83 std.Io.Threaded: reinstate fchmodat fallback
Stephen Gregoratto (original author of the fallback) says:

I read through both libcs again to compare:

Musl:
- `stat` path. Check error.
- If path is a symlink, return `OPNOTSUPP`.
- `openat` path as `O_PATH|O_NOFOLLOW|O_CLOEXEC`. Return `OPNOTSUPP` if we got `ELOOP`.
- Build procfs filename.
- `stat` procfs file.
- If procfs file is a symlink, return `OPNOTSUPP`.
- close path fd.

Glibc:
- open path as `O_PATH|O_NOFOLLOW|O_CLOEXEC`.
- fstatat path fd.
- If path is a symlink, return `OPNOTSUPP`.
- Build procfs filename.
- chmod procfs filename. Return `OPNOTSUPP` if we got `ENOENT`.
- close path fd.

I prefer glibc since you open the path first, which avoids a possible
TOCTOU race.
2025-12-23 22:15:11 -08:00
Andrew Kelley 64de4a7371 std.Io.Threaded: remove handling of ECANCELED
The only known situation in which this occurs is when using musl with
the undocumented extension PTHREAD_CANCEL_MASKED, causing the next
syscall to return ECANCELED.

However zig std lib does not use this mechanism, even when targeting
musl libc because it would require each async task to be on a fresh
pthread.

For the same reason, if third party code were to cause ECANCELED to be
returned from any of these syscalls, it would cause subsequent tasks to
be incorrectly canceled since they cannot be rearmed.

Thus, this Io implementation cannot handle this error code correctly,
expecting never to receive it.
2025-12-23 22:15:11 -08:00
Andrew Kelley a8088306f6 std: rename other Dir "make" functions to "create" 2025-12-23 22:15:11 -08:00
Andrew Kelley 6e0c7ed865 std: rename makeDir to createDir for consistency with createFile 2025-12-23 22:15:11 -08:00
Andrew Kelley 52ba2a4c72 std.Io.Threaded: don't assume dirents are aligned
Linux kernel seems to do it but qemu user mode seems not to.
2025-12-23 22:15:11 -08:00
Andrew Kelley 6cfd2df695 don't skip test for closed issue 2025-12-23 22:15:11 -08:00
Andrew Kelley bf81666beb std.fs.test: don't try to test nonexistent API 2025-12-23 22:15:11 -08:00
Andrew Kelley 88110139fe std.Io.Threaded: fix NetBSD compilation 2025-12-23 22:15:11 -08:00
Andrew Kelley 4025af9c05 std.Io.Threaded: fix fchmodat on linux with libc 2025-12-23 22:15:11 -08:00
Andrew Kelley 6aa31cedb7 std.Io.Dir.Reader: fix min_buffer_len on 32-bit linux
dirents64 still uses 8 byte alignment on 32-bit systems
2025-12-23 22:15:11 -08:00
Andrew Kelley 3e624e17a4 std: fix compilation errors on FreeBSD 2025-12-23 22:15:11 -08:00
Andrew Kelley 405db921dc std: fix compilation targeting WASI 2025-12-23 22:15:11 -08:00
Andrew Kelley 1381f9f612 std.debug: fix printLineFromFile
by using streamDelimiter and discardDelimiter functions that don't
depend on the buffer size being large enough
2025-12-23 22:15:11 -08:00
Andrew Kelley ac11b82738 std.Io.Threaded: fix splat buffer calculations 2025-12-23 22:15:11 -08:00
Andrew Kelley d060cb8cd6 std: fix test "max file name component lengths" 2025-12-23 22:15:11 -08:00
Andrew Kelley 002d444964 std: fix Io.Dir.min_buffer_len on Linux 2025-12-23 22:15:11 -08:00
Andrew Kelley 018e34271f std.fs.test: fix rebase conflicts 2025-12-23 22:15:11 -08:00