Commit graph

452 commits

Author SHA1 Message Date
hemisputnik
99229ceb55 std.Io.{Writer|Duration}: move duration formatting to a format method
Remove the `{D}` format specifier. It is moved into `std.Io.Duration` as
a format method.

Migration plan:

```diff
-writer.print("{D}", .{ns});
+writer.print("{f}", .{std.Io.Duration{ .nanoseconds = ns }});
```

All instances where `{D}` was used have been changed to use
`std.Io.Duration` and `{f}`.

Fixes #31281
2026-02-28 02:46:04 +01:00
Kendall Condon
e40557b1f7 allow specifying mode in --debug-rt
The motivation is that libfuzzer is slow in Debug mode and bugs usually
manifest late into fuzzing, which makes testing it in ReleaseSafe
useful.
2026-02-13 17:58:09 -05:00
Kendall Condon
af1e196db3 align end of elf archives
The end of the archive needs to also be aligned to a two-byte boundary,
not just the start of records. This was causing lld to reject archives.

Notably, this was happening with compiler_rt when rebuilding in fuzz
mode, which is why this commit is included in this patchset.
2026-02-13 17:58:09 -05:00
antme0
fb18f2096a Allow build.zig scripts to define module definition files (.def) when building win32 dlls. 2026-02-09 07:58:13 +01:00
Andrew Kelley
922ab8b8bc std: finish moving time to Io interface
Importantly, adds ability to get Clock resolution, which may be zero.
This allows error.Unexpected and error.ClockUnsupported to be removed
from timeout and clock reading error sets.
2026-02-02 23:02:31 -08:00
Ryan Liptak
05346e123b Add process.Child.Cwd, use it for cwd and remove cwd_dir field
The user must now explicitly choose between inheriting the current CWD, passing a path for the CWD, or passing a Dir for the CWD.
2026-02-02 01:41:35 -08:00
Matthew Lugg
f8828e543a std.Build: fully upgrade Step.Run to std.Io timing (and fix a typo) 2026-01-30 22:03:14 -08:00
Andrew Kelley
6a1fd3c69d std.Io.File.MultiReader: make checkAnyError exclude EndOfStream 2026-01-30 22:03:14 -08:00
Andrew Kelley
efa502a1cd std.Build.Step.Run: gracefully handle test runner misbehavior
specifically if it misbehaves after sending a message header but not the
body
2026-01-30 22:03:14 -08:00
Andrew Kelley
523aa213c9 std.Io.Threaded: batchWait and batchCancel for Windows 2026-01-30 22:03:14 -08:00
Andrew Kelley
e56563ce3f std.Io.File.MultiReader: implementation fixes 2026-01-30 22:03:14 -08:00
Andrew Kelley
12cfc96e1b std: update rest of build runner to new File.MultiReader API 2026-01-30 22:03:14 -08:00
Andrew Kelley
377bb8f237 Merge pull request 'std: migrate getcwd to Io' (#31047) from getcwd into master
Reviewed-on: https://codeberg.org/ziglang/zig/pulls/31047
2026-01-30 06:38:08 +01:00
Pablo Alessandro Santos Hugen
ad0458f582 std.Build: Fix wrong error enum
Signed-off-by: Pablo Alessandro Santos Hugen <phugen@redhat.com>
2026-01-30 06:19:49 +01:00
Andrew Kelley
b1d1806fef std.process: currentDir -> currentPath
In Zig standard library, Dir means an open directory handle. path
represents a file system identifier string. This function is better
named after "current path" than "current dir". "get" and "working" are
superfluous.
2026-01-29 18:47:58 -08:00
Andrew Kelley
649aaf4814 std: migrate getcwd to Io
progress towards #30150
2026-01-29 18:40:55 -08:00
Pablo Alessandro Santos Hugen
951ab1b18b std.Build.Step.Compile: pass target by pointer to isLibC*LibName 2026-01-27 05:29:04 +01:00
InKryption
305fd06756 Build: check if dynamic lib installed for symlinks
If the library isn't actually installed, `generated_bin` will be null,
causing this to panic about a missing dependency for itself; checking
for this state avoids this.
2026-01-22 22:28:28 +01: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
3bc22dbd94 std.Build.Step.Options: exploit Io.File.Atomic 2026-01-07 11:03:36 -08:00
Andrew Kelley
b4dbe483a7 std.Build: adjust temp files API
Remove the RemoveDir step with no replacement. This step had no valid
purpose. Mutating source files? That should be done with
UpdateSourceFiles step. Deleting temporary directories? That required
creating the tmp directories in the configure phase which is broken.
Deleting cached artifacts? That's going to cause problems.

Similarly, remove the `Build.makeTempPath` function. This was used to
create a temporary path in the configure place which, again, is the
wrong place to do it.

Instead, the WriteFile step has been updated with more functionality:

tmp mode: In this mode, the directory will be placed inside "tmp" rather
than "o", and caching will be skipped. During the `make` phase, the step
will always do all the file system operations, and on successful build
completion, the dir will be deleted along with all other tmp
directories. The directory is therefore eligible to be used for
mutations by other steps. `Build.addTempFiles` is introduced to
initialize a WriteFile step with this mode.

mutate mode: The operations will not be performed against a freshly
created directory, but instead act against a temporary directory.
`Build.addMutateFiles` is introduced to initialize a WriteFile step with
this mode.

`Build.tmpPath` is introduced, which is a shortcut for
`Build.addTempFiles` followed by `WriteFile.getDirectory`.

* give Cache a gpa rather than arena because that's what it asks for
2026-01-04 17:23:45 -08:00
Andrew Kelley
2fee64ceb0 update init template for new main API 2026-01-04 00:27:09 -08:00
Andrew Kelley
1070c2a71a rename env_map to environ_map
For naming consistency with `std.process.Environ.Map`.
2026-01-04 00:27:09 -08:00
Andrew Kelley
e149c0e2aa std.Build.Step.Run: fix wrong environment passed 2026-01-04 00:27:08 -08:00
Andrew Kelley
af164b3f3c std.Build.Step.Run: no need to sort the environment
since we now use ArrayHashMap, the order is deterministic, and in fact,
observable by applications.
2026-01-04 00:27:08 -08:00
Andrew Kelley
08447ca47e std.fs.path: make relative a pure function
Instead of querying the operating system for current working directory
and environment variables, this function now accepts those things as
inputs.
2026-01-04 00:27:08 -08:00
Andrew Kelley
32af0f6154 std: move child process APIs to std.Io
this gets the build runner compiling again on linux

this work is incomplete; it only moves code around so that environment
variables can be wrangled properly. a future commit will need to audit
the cancelation and error handling of this moved logic.
2026-01-04 00:27:08 -08:00
Andrew Kelley
d6a1e73142 std: start wrangling environment variables and process args
this commit is unfinished. It marks a spot where I wanted to start
moving child process stuff below the std.Io.VTable
2026-01-04 00:27:07 -08:00
Matthew Lugg
d024d9f005
std.Build: crashes in the test runner are fatal errors 2026-01-03 14:52:11 +00:00
Andrew Kelley
a8088306f6 std: rename other Dir "make" functions to "create" 2025-12-23 22:15:11 -08:00
Andrew Kelley
608145c2f0 fix more fallout from locking stderr 2025-12-23 22:15:10 -08:00
Andrew Kelley
1925e0319f update lockStderrWriter sites
use the application's Io implementation where possible. This correctly
makes writing to stderr cancelable, fallible, and participate in the
application's event loop. It also removes one more hard-coded
dependency on a secondary Io implementation.
2025-12-23 22:15:09 -08:00
Andrew Kelley
c4cefd6835 std.Build.Step.Run: restore Color.inherit logic 2025-12-23 22:15:09 -08:00
Andrew Kelley
b042e93522 std: update tty config references in the build system 2025-12-23 22:15:09 -08:00
Andrew Kelley
bee8005fe6 std.heap.DebugAllocator: never detect TTY config
instead, allow the user to set it as a field.

this fixes a bug where leak printing and error printing would run tty
config detection for stderr, and then emit a log, which is not necessary
going to print to stderr.

however, the nice defaults are gone; the user must explicitly assign the
tty_config field during initialization or else the logging will not have
color.

related: https://github.com/ziglang/zig/issues/24510
2025-12-23 22:15:08 -08:00
Andrew Kelley
4a53e5b0b4 fix a handful of compilation errors related to std.fs migration 2025-12-23 22:15:08 -08:00
Andrew Kelley
ebdbbd20ac update makeDir() sites to specify permissions 2025-12-23 22:15:08 -08:00
Andrew Kelley
1dcfc8787e update all readFileAlloc() to accept Io instance 2025-12-23 22:15:08 -08:00
Andrew Kelley
4be8be1d2b update all rename() to rename(io) 2025-12-23 22:15:08 -08:00
Andrew Kelley
4218344dd3 std.Build.Cache: remove readSmallFile and writeSmallFile
These were to support optimizations involving detecting when to avoid
calling into LLD, which are no longer implemented.
2025-12-23 22:15:08 -08:00
Andrew Kelley
950d18ef69 update all access() to access(io) 2025-12-23 22:15:08 -08:00
Andrew Kelley
9ccd68de0b std: move abort and exit from posix into process
and delete the unit tests that called fork()

no forking allowed in the std lib, including unit tests, except to implement child process spawning.
2025-12-23 22:15:08 -08:00
Andrew Kelley
7f5bb118d4 std.Io: make all the close functions batched 2025-12-23 22:15:08 -08:00
Andrew Kelley
264d714321 update all openDir() sites to accept io instance 2025-12-23 22:15:08 -08:00
Andrew Kelley
f53248a409 update all std.fs.cwd() to std.Io.Dir.cwd() 2025-12-23 22:15:08 -08:00
Andrew Kelley
8328de24f1 update all occurrences of openFile to receive an io instance 2025-12-23 22:15:08 -08:00
Andrew Kelley
3204fb7569 update all occurrences of std.fs.File to std.Io.File 2025-12-23 22:15:07 -08:00
Andrew Kelley
aafddc2ea1 update all occurrences of close() to close(io) 2025-12-23 22:15:07 -08:00
Andrew Kelley
d1d2c37af2 std: all Dir functions moved to std.Io 2025-12-23 22:15:07 -08:00