aboutsummaryrefslogtreecommitdiff
path: root/lib/std/Build/Step
AgeCommit message (Collapse)Author
2025-07-30std.crypto: support for hashes without optionssha1-streamAndrew Kelley
2025-07-26std.Build: Deprecate `Step.Compile` APIs that mutate the root moduleCarl Åstholm
Not only are `Step.Compile` methods like `linkLibC()` redundant because `Module` exposes the same APIs, it also might not be immediately obvious to users that these methods modify the underlying root module, which can be a footgun and lead to unintended results if the module is exported to package consumers or shared by multiple compile steps. Using `compile.root_module.link_libc = true` makes it more clear to users which of the compile step and the module owns which options.
2025-07-23std.Io.poll: update to new I/O APIAndrew Kelley
2025-07-21std.fs.File: delete writeFileAll and friendsAndrew Kelley
please use File.Writer for these use cases also breaking API changes to std.fs.AtomicFile
2025-07-20Merge pull request #24488 from ziglang/moreAndrew Kelley
std.zig: finish updating to new I/O API
2025-07-20std.Build.Step.Run: fix up 681d324c49e7cdc773cc891ea49ed69dd03c23c7Alex Rønne Petersen
https://github.com/ziglang/zig/pull/24151/files#r2217494741
2025-07-19std.Io.Writer: fix writeSliceSwapAndrew Kelley
tried to be too clever, wrote bad code
2025-07-17std.Build.Step.ConfigHeader: add the lazy file styled input as a dependencyTristan Ross
2025-07-12std.Build.Step.Run: Set WINEDEBUG=-all for -fwine by default.Alex Rønne Petersen
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-11Remove numerous things deprecated during the 0.14 release cycleLinus Groh
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-07std.Build.Step.CheckObject: mostly revert to master branchAndrew Kelley
the updated code to use new std.io API is crashing
2025-07-07fix 32-bit compilationAndrew Kelley
2025-07-07std.Build.Step.Options: fix build failureAndrew Kelley
2025-07-07std.io.Writer.printValue: rework logicAndrew Kelley
Alignment and fill options only apply to numbers. Rework the implementation to mainly branch on the format string rather than the type information. This is more straightforward to maintain and more straightforward for comptime evaluation. Enums support being printed as decimal, hexadecimal, octal, and binary. `formatInteger` is another possible format method that is unconditionally called when the value type is struct and one of the integer-printing format specifiers are used.
2025-07-07fix build runnerAndrew Kelley
2025-07-07std.io.Writer.Allocating: rename interface to writerAndrew Kelley
2025-07-07std.Build.Step.CheckObject: fix the TODOAndrew Kelley
2025-07-07std.fmt: breaking API changesAndrew Kelley
added adapter to AnyWriter and GenericWriter to help bridge the gap between old and new API make std.testing.expectFmt work at compile-time std.fmt no longer has a dependency on std.unicode. Formatted printing was never properly unicode-aware. Now it no longer pretends to be. Breakage/deprecations: * std.fs.File.reader -> std.fs.File.deprecatedReader * std.fs.File.writer -> std.fs.File.deprecatedWriter * std.io.GenericReader -> std.io.Reader * std.io.GenericWriter -> std.io.Writer * std.io.AnyReader -> std.io.Reader * std.io.AnyWriter -> std.io.Writer * std.fmt.format -> std.fmt.deprecatedFormat * std.fmt.fmtSliceEscapeLower -> std.ascii.hexEscape * std.fmt.fmtSliceEscapeUpper -> std.ascii.hexEscape * std.fmt.fmtSliceHexLower -> {x} * std.fmt.fmtSliceHexUpper -> {X} * std.fmt.fmtIntSizeDec -> {B} * std.fmt.fmtIntSizeBin -> {Bi} * std.fmt.fmtDuration -> {D} * std.fmt.fmtDurationSigned -> {D} * {} -> {f} when there is a format method * format method signature - anytype -> *std.io.Writer - inferred error set -> error{WriteFailed} - options -> (deleted) * std.fmt.Formatted - now takes context type explicitly - no fmt string
2025-07-07std.io: move getStdIn, getStdOut, getStdErr functions to fs.FileAndrew Kelley
preparing to rearrange std.io namespace into an interface how to upgrade: std.io.getStdIn() -> std.fs.File.stdin() std.io.getStdOut() -> std.fs.File.stdout() std.io.getStdErr() -> std.fs.File.stderr()
2025-06-30std.Build.Step.CheckObject: Truncate st_other before interpreting itAlex Rønne Petersen
Tools are free to use the upper bits of this field for whatever; thus, tools that want to interpret the visibility type should truncate to 2 bits.
2025-06-20Merge pull request #24227 from mlugg/misc-build-stuffMatthew Lugg
`std.Build`: more miscellaneous bits
2025-06-20std.Build.Step.Run: pass correct relative cache dir to testsmlugg
Fixes an additional bug reported in the closed #24216.
2025-06-19Target: pass and use locals by pointer instead of by valueJacob Young
This struct is larger than 256 bytes and code that copies it consistently shows up in profiles of the compiler.
2025-06-19Build: add install commands to `--verbose` outputJacob Young
2025-06-19Build: change how the target is printed in step namesJacob Young
e.g. `x86_64-windows.win10...win11_dt-gnu` -> `x86_64-windows-gnu` When the OS version is the default this is redundant with checking the default in the standard library.
2025-06-18std.Build.Step.Run: prefix relative path arguments with './'mlugg
This is necessary in two cases: * On POSIX, the exe path (`argv[0]`) must contain a path separator * Some programs might treat a file named e.g. `-foo` as a flag, which can be avoided by passing `./-foo` Rather than detecting these two cases, just always include the prefix; there's no harm in it. Also, if the cwd is specified, include it in the manifest. If the user has set the cwd of a Run step, it is clearly because this affects the behavior of the executable somehow, so that cwd path should be a part of the step's manifest. Resolves: #24216
2025-06-17std.Build: introduce `ConfigHeader.getOutputDir`, small refactormlugg
`std.Build.Step.ConfigHeader` emits a *directory* containing a config header under a given sub path, but there's no good way to actually access that directory as a `LazyPath` in the configure phase. This is silly; it's perfectly valid to refer to that directory, perhaps to explicitly pass as a "-I" flag to a different toolchain invoked via a `Step.Run`. So now, instead of the `GeneratedFile` being the actual *file*, it should be that *directory*, i.e. `cache/o/<digest>`. We can then easily get the *file* if needed just by using `LazyPath.path` to go "deeper", which there is a helper function for. The legacy `getOutput` function is now a deprecated alias for `getOutputFile`, and `getOutputDir` is introduced. `std.Build.Module.IncludeDir.appendZigProcessFlags` needed a fix after this change, so I took the opportunity to refactor it a little. I was looking at this function while working on ziglang/translate-c yesterday and realised it could be expressed much more simply -- particularly after the `ConfigHeader` change here. I had to update the test `standalone/cmakedefine/` -- it turns out this test was well and truly reaching into build system internals, and doing horrible not-really-allowed stuff like overriding the `makeFn` of a `TopLevelStep`. To top it all off, the test forgot to set `b.default_step` to its "test" step, so the test never even ran. I've refactored it to follow accepted practices and to actually, like, work.
2025-06-13std.Build.Step.Run: convert relative paths to be relative to child cwdmlugg
Because any `LazyPath` might be resolved to a relative path, it's incorrect to pass that directly to a child process whose cwd might differ. Instead, if the child has an overriden cwd, we need to convert such paths to be relative to the child cwd using `std.fs.path.relative`.
2025-06-12compiler: rework emit paths and cache modesmlugg
Previously, various doc comments heavily disagreed with the implementation on both what lives where on the filesystem at what time, and how that was represented in code. Notably, the combination of emit paths outside the cache and `disable_lld_caching` created a kind of ad-hoc "cache disable" mechanism -- which didn't actually *work* very well, 'most everything still ended up in this cache. There was also a long-standing issue where building using the LLVM backend would put a random object file in your cwd. This commit reworks how emit paths are specified in `Compilation.CreateOptions`, how they are represented internally, and how the cache usage is specified. There are now 3 options for `Compilation.CacheMode`: * `.none`: do not use the cache. The paths we have to emit to are relative to the compiler cwd (they're either user-specified, or defaults inferred from the root name). If we create any temporary files (e.g. the ZCU object when using the LLVM backend) they are emitted to a directory in `local_cache/tmp/`, which is deleted once the update finishes. * `.whole`: cache the compilation based on all inputs, including file contents. All emit paths are computed by the compiler (and will be stored as relative to the local cache directory); it is a CLI error to specify an explicit emit path. Artifacts (including temporary files) are written to a directory under `local_cache/tmp/`, which is later renamed to an appropriate `local_cache/o/`. The caller (who is using `--listen`; e.g. the build system) learns the name of this directory, and can get the artifacts from it. * `.incremental`: similar to `.whole`, but Zig source file contents, and anything else which incremental compilation can handle changes for, is not included in the cache manifest. We don't need to do the dance where the output directory is initially in `tmp/`, because our digest is computed entirely from CLI inputs. To be clear, the difference between `CacheMode.whole` and `CacheMode.incremental` is unchanged. `CacheMode.none` is new (previously it was sort of poorly imitated with `CacheMode.whole`). The defined behavior for temporary/intermediate files is new. `.none` is used for direct CLI invocations like `zig build-exe foo.zig`. The other cache modes are reserved for `--listen`, and the cache mode in use is currently just based on the presence of the `-fincremental` flag. There are two cases in which `CacheMode.whole` is used despite there being no `--listen` flag: `zig test` and `zig run`. Unless an explicit `-femit-bin=xxx` argument is passed on the CLI, these subcommands will use `CacheMode.whole`, so that they can put the output somewhere without polluting the cwd (plus, caching is potentially more useful for direct usage of these subcommands). Users of `--listen` (such as the build system) can now use `std.zig.EmitArtifact.cacheName` to find out what an output will be named. This avoids having to synchronize logic between the compiler and all users of `--listen`.
2025-06-09std.Build.Step.Run: add addDecoratedDirectoryArg functionAndrew Kelley
For directory arguments that need both prefix and suffix strings appended. Needed to unbreak ffmpeg package after fe855691f6f742a14678cb617422977c2a55be39
2025-06-04std.Build.Step.Compile: clarify step nameAndrew Kelley
In particular this makes it more obvious what step is compiling a unit test versus which is running it.
2025-05-25compiler: introduce incremental debug servermlugg
In a compiler built with debug extensions, pass `--debug-incremental` to spawn the "incremental debug server". This is a TCP server exposing a REPL which allows querying a bunch of compiler state, some of which is stored only when that flag is passed. Eventually, this will probably move into `std.zig.Server`/`std.zig.Client`, but this is easier to work with right now. The easiest way to interact with the server is `telnet`.
2025-05-21std.Build.Step.Run: inherit build runner cwdmlugg
Right now, if you override the build root with `--build-root`, then `Run` steps can fail to execute because of incorrect path handling in the compiler: `std.process.Child` gets a cwd-relative path, but also has its cwd set to the build root. The latter behavior is really weird; it doesn't match my expectations, nor does it match how we spawn child `zig` processes. So, this commit makes the child process inherit the build runner's cwd, as `LazyPath.getPath2` *expects* it to. After investigating, this behavior dates all the way back to 2017; it was introduced in 4543413. So, there isn't any clear/documented reason for this; it should be safe to revert, since under the modern `LazyPath` system it is strictly a bug AFAICT.
2025-05-13Merge pull request #21882 from alexrp/compiler-fixesAlex Rønne Petersen
compiler: Fix some real and theoretical miscompilations with `allowzero` and `volatile`
2025-05-13std.meta.intToEnum -> std.enums.fromIntwooster0
Also use an optional as the return type instead of an error code.
2025-05-12std.Build: Make no_builtin a property of Module instead of Step.Compile.Alex Rønne Petersen
This reflects how the compiler actually treats it. Closes #23424.
2025-05-12std.Build: Change Step.Compile.no_builtin from bool to ?bool.Alex Rønne Petersen
To be in line with other, similar options.
2025-05-06std.Build: Rename --glibc-runtimes to --libc-runtimes and enable it for musl.Alex Rønne Petersen
2025-04-22compiler: allow emitting tests to an object filemlugg
This is fairly straightforward; the actual compiler changes are limited to the CLI, since `Compilation` already supports this combination. A new `std.Build` API is introduced to allow representing this. By passing the `emit_object` option to `std.Build.addTest`, you get a `Step.Compile` which emits an object file; you can then use that as you would any other object, such as either installing it for external use, or linking it into another step. A standalone test is added to cover the build system API. It builds a test into an object, and links it into a final executable, which it then runs. Using this build system mechanism prevents the build system from noticing that you're running a `zig test`, so the build runner and test runner do not communicate over stdio. However, that's okay, because the real-world use cases for this feature don't want to do that anyway! Resolves: #23374
2025-04-13std: eradicate u29 and embrace std.mem.AlignmentAndrew Kelley
2025-04-11Merge pull request #22516 from Jan200101/PR/build_id_optionAndrew Kelley
std.Build: add build-id option
2025-04-09Merge pull request #23501 from imreallybadatnames/masterimreallybadatnames™️
Step.Compile: use LtoMode enum for lto option
2025-03-27std.Build: implement addEmbedPath for adding C #embed search directoriesGalaxyShard
2025-03-26Enables parsing for '-Wl,-rpath,' in pkg-config output, allows better ↵Felix "xq" Queißner
support for NixOS linking.
2025-03-26zig build: add env_map entries to hash for Step.Rundweiller
This change fixes false-positive cache hits for run steps that get run with different sets of environment variables due the the environment map being excluded from the cache hash.
2025-03-07fix InstallArtifact opening empty stringAndrew Kelley
this appears to have been a problem since 43f73af3595c3174b8e67e9f2792c3774f2192e9
2025-03-07std.Build: add build-id optionJan200101
2025-02-28Revert "Merge pull request #22898 from kristoff-it/deprecated-proposal"Andrew Kelley
This reverts commit dea72d15da4fba909dc3ccb2e9dc5286372ac023, reversing changes made to ab381933c87bcc744058d25a876cfdc0d23fc674. The changeset does not work as advertised and does not have sufficient test coverage. Reopens #22822
2025-02-26fix regressed build system unit testLoris Cro
2025-02-25build: add `bundle_ubsan_rt`David Rubin