aboutsummaryrefslogtreecommitdiff
path: root/lib/std/Build
AgeCommit message (Collapse)Author
2024-08-28LLVM: disable inline 8-bit counters when using trace pc guardAndrew Kelley
2024-08-28std: update `std.builtin.Type` fields to follow naming conventionsmlugg
The compiler actually doesn't need any functional changes for this: Sema does reification based on the tag indices of `std.builtin.Type` already! So, no zig1.wasm update is necessary. This change is necessary to disallow name clashes between fields and decls on a type, which is a prerequisite of #9938.
2024-08-23fix autodocs regression FTBFSAndrew Kelley
regressed in dffc8c44f9a01aa05ea364ffdc71509d15bc2601 since there is no test coverage for the `zig std` command yet. closes #21180
2024-08-22std.debug: remove allocator from std.debug.writeStackTrace()John Benediktsson
2024-08-21std.Build.Step.TranslateC: propagate target, optimize, link_libc to created ↵mlugg
module
2024-08-19fix various issues related to Path handling in the compiler and stdRobin Voetter
A compilation build step for which the binary is not required could not be compiled previously. There were 2 issues that caused this: - The compiler communicated only the results of the emitted binary and did not properly communicate the result if the binary was not emitted. This is fixed by communicating the final hash of the artifact path (the hash of the corresponding /o/<hash> directory) and communicating this instead of the entire path. This changes the zig build --listen protocol to communicate hashes instead of paths, and emit_bin_path is accordingly renamed to emit_digest. - There was an error related to the default llvm object path when CacheUse.Whole was selected. I'm not really sure why this didn't manifest when the binary is also emitted. This was fixed by improving the path handling related to flush() and emitLlvmObject(). In general, this commit also improves some of the path handling throughout the compiler and standard library.
2024-08-15std.tar: add writer (#19603)Igor Anić
Simplifies code in docs creation where we used `std.tar.output.Header`. Writer uses that Header internally and provides higher level interface. Updates checksum on write, handles long file names, allows setting mtime and file permission mode. Provides handy interface for passing `Dir.WalkerEntry`.
2024-08-14Watch.zig: fixes for windows implementationJarrod Meyer
Using --watch I noticed a couple of issues with my initial attempt. 1) The index I used as 'completion key' was not stable over time, when directories are being added/removed the key no longer corresponds with the intended dir. 2) There exists a race condition in which we receive a completion notification for a directory that was removed. My solution is to generate a key value and associate it with each Directory.
2024-08-13std.Build.Fuzz.WebServer: sort pcs before source location lookupAndrew Kelley
Unfortunately, the PCs do not get sorted during linking.
2024-08-13avoid a branch in resolveAddressesDwarfAndrew Kelley
2024-08-08more optimized and correct management of 8-bit PC countersAndrew Kelley
* Upgrade from u8 to usize element types. - WebAssembly assumes u64. It should probably try to be target-aware instead. * Move the covered PC bits to after the header so it goes on the same page with the other rapidly changing memory (the header stats). depends on the semantics of accepted proposal #19755 closes #20994
2024-08-08fuzzing: comptime assertions to protect the ABIAndrew Kelley
compile errors are nice
2024-08-07build runner: output hint when no --port providedAndrew Kelley
2024-08-07update branch for latest std.sort changesAndrew Kelley
2024-08-07fuzzer web ui: resolve cwd in sources.tarAndrew Kelley
because the wasm code needs to string match against debug information
2024-08-07fuzzer web ui: introduce entry pointsAndrew Kelley
so you can have somewhere to start browsing
2024-08-07fuzzer web UI: receive coverage informationAndrew Kelley
* libfuzzer: track unique runs instead of deduplicated runs - easier for consumers to notice when to recheck the covered bits. * move common definitions to `std.Build.Fuzz.abi`. build runner sends all the information needed to fuzzer web interface client needed in order to display inline coverage information along with source code.
2024-08-07fuzzing: progress towards web UIAndrew Kelley
* libfuzzer: close file after mmap * fuzzer/main.js: connect with EventSource and debug dump the messages. currently this prints how many fuzzer runs have been attempted to console.log. * extract some `std.debug.Info` logic into `std.debug.Coverage`. Prepares for consolidation across multiple different executables which share source files, and makes it possible to send all the PC/SourceLocation mapping data with 4 memcpy'd arrays. * std.Build.Fuzz: - spawn a thread to watch the message queue and signal event subscribers. - track coverage map data - respond to /events URL with EventSource messages on a timer
2024-08-07introduce tool for dumping coverage fileAndrew Kelley
with debug info resolved. begin efforts of providing `std.debug.Info`, a cross-platform abstraction for loading debug information into an in-memory format that supports queries such as "what is the source location of this virtual memory address?" Unlike `std.debug.SelfInfo`, this API does not assume the debug information in question happens to match the host CPU architecture, OS, or other target properties.
2024-08-07fuzzer: share zig to html rendering with autodocsAndrew Kelley
2024-08-07introduce a web interface for fuzzingAndrew Kelley
* new .zig-cache subdirectory: 'v' - stores coverage information with filename of hash of PCs that want coverage. This hash is a hex encoding of the 64-bit coverage ID. * build runner * fixed bug in file system inputs when a compile step has an overridden zig_lib_dir field set. * set some std lib options optimized for the build runner - no side channel mitigations - no Transport Layer Security - no crypto fork safety * add a --port CLI arg for choosing the port the fuzzing web interface listens on. it defaults to choosing a random open port. * introduce a web server, and serve a basic single page application - shares wasm code with autodocs - assets are created live on request, for convenient development experience. main.wasm is properly cached if nothing changes. - sources.tar comes from file system inputs (introduced with the `--watch` feature) * receives coverage ID from test runner and sends it on a thread-safe queue to the WebServer. * test runner - takes a zig cache directory argument now, for where to put coverage information. - sends coverage ID to parent process * fuzzer - puts its logs (in debug mode) in .zig-cache/tmp/libfuzzer.log - computes coverage_id and makes it available with `fuzzer_coverage_id` exported function. - the memory-mapped coverage file is now namespaced by the coverage id in hex encoding, in `.zig-cache/v` * tokenizer - add a fuzz test to check that several properties are upheld
2024-07-28Merge pull request #20667 from jayrod246/windows-watchAndrew Kelley
Build Runner: Initial Implementation for File System Watching on Windows
2024-07-28std.fs.Dir: Refactor atomicSymLink from std.fsCarter Snook
Deprecates std.fs.atomicSymLink and removes the allocator requirement from the new std.fs.Dir.atomicSymLink. Replaces the two usages of this within std. I did not include the TODOs from the original code that were based off of `switch (err) { ..., else => return err }` not having correct inference that cases handled in `...` are impossible in the error union return type because these are not specified in many places but I can add them back if wanted. Thank you @squeek502 for help with fixing buffer overflows!
2024-07-27Watch.zig: add initial windows implementationJarrod Meyer
2024-07-25add --debug-rt CLI arg to the compiler + bonus editsAndrew Kelley
The flag makes compiler_rt and libfuzzer be in debug mode. Also: * fuzzer: override debug logs and disable debug logs for frequently called functions * std.Build.Fuzz: fix bug of rerunning the old unit test binary * report errors from rebuilding the unit tests better * link.Elf: additionally add tsan lib and fuzzer lib to the hash
2024-07-25std.Build.Fuzz: fix progress node hierarchyAndrew Kelley
2024-07-25build runner sends a start_fuzzing message to test runnerAndrew Kelley
2024-07-25build runner: extract logic to std.Build.FuzzAndrew Kelley
2024-07-25add `--fuzz` CLI argument to `zig build`Andrew Kelley
This flag makes the build runner rebuild unit tests after the pipeline finishes, if it finds any unit tests. I did not make this integrate with file system watching yet. The test runner is updated to detect which tests are fuzz tests. Run step is updated to track which test indexes are fuzz tests.
2024-07-24add sub-compilation cache inputs to parents in whole modeAndrew Kelley
closes #20782
2024-07-23default "trace pc guard" coverage offAndrew Kelley
* Add -f(no-)sanitize-coverage-trace-pc-guard CLI flag which defaults to off. This value lowers to TracePCGuard = true (LLVM backend) and -Xclang -fsanitize-coverage-trace-pc-guard. These settings are not automatically included with -ffuzz. * Add `Build.Step.Compile` flag for sanitize_coverage_trace_pc_guard with appropriate documentation. * Add `zig cc` integration for the respective flags. * Avoid crashing in ELF linker code when -ffuzz -femit-llvm-ir used together.
2024-07-23std.Build.Step.Run: Fix invocation syntax for Wasmtime 14+.Alex Rønne Petersen
https://github.com/bytecodealliance/wasmtime/issues/7384
2024-07-23add std.testing.random_seedAndrew Kelley
closes #17609
2024-07-22add the build system API for enabling fuzzingAndrew Kelley
2024-07-21zig build: respect `PKG_CONFIG` environment variableEric Joldasov
`PKG_CONFIG` environment variable is used to override path to pkg-config executable, for example when it's name is prepended by target triple for cross-compilation purposes: ``` PKG_CONFIG=/usr/bin/aarch64-unknown-linux-gnu-pkgconf zig build ``` Signed-off-by: Eric Joldasov <bratishkaerik@landless-city.net>
2024-07-20add std.fmt.hexAndrew Kelley
converts an unsigned integer into an array
2024-07-14build runner: update watch caption to include subprocessesAndrew Kelley
2024-07-14build runner: handle compiler subprocess failures gracefullyAndrew Kelley
Compilation errors now report a failure on rebuilds triggered by file system watches. Compiler crashes now report failure correctly on rebuilds triggered by file system watches. The compiler subprocess is restarted if a broken pipe is encountered on a rebuild.
2024-07-14build system: update std.Progress.Node for long-lived childrenAndrew Kelley
2024-07-14frontend: add -fincremental, -fno-incremental flagAndrew Kelley
Remove --debug-incremental This flag is also added to the build system. Importantly, this tells Compile step whether or not to keep the compiler running between rebuilds. It defaults off because it is currently crashing zirUpdateRefs.
2024-07-14make zig compiler processes live across rebuildsAndrew Kelley
Changes the `make` function signature to take an options struct, which additionally includes `watch: bool`. I intentionally am not exposing this information to configure phase logic. Also adds global zig cache to the compiler cache prefixes. Closes #20600
2024-07-13Compile: Pass the default --zig-lib-dir along to child processeskcbanner
main: print the self_exe_path when `findZigLibDirFromSelfExe` fails in all cases
2024-07-12Merge pull request #20580 from ziglang/watchAndrew Kelley
introduce file system watching features to the zig build system
2024-07-12build runner: refactor fs watch logic for OS abstractionAndrew Kelley
Makes the build runner compile successfully for non-linux targets; printing an error if you ask for --watch rather than making build scripts fail to compile.
2024-07-12update build system unit testAndrew Kelley
need to add another field to initialize now
2024-07-12std.Build.Step.Run: support prefixed artifact argsxtex
Just like how addPrefixedFileArg and addPrefixedDirectoryArg works, we can make it for artifacts. Signed-off-by: Bingwu Zhang <xtexchooser@duck.com>
2024-07-12frontend: add file system inputs for incremental cache modeAndrew Kelley
These are also used for whole cache mode in the case that any compile errors are emitted.
2024-07-12integrate Compile steps with file watchingAndrew Kelley
Updates the build runner to unconditionally require a zig lib directory parameter. This parameter is needed in order to correctly understand file system inputs from zig compiler subprocesses, since they will refer to "the zig lib directory", and the build runner needs to place file system watches on directories in there. The build runner's fanotify file watching implementation now accounts for when two or more Cache.Path instances compare unequal but ultimately refer to the same directory in the file system. Breaking change: std.Build no longer has a zig_lib_dir field. Instead, there is the Graph zig_lib_directory field, and individual Compile steps can still have their zig lib directories overridden. I think this is unlikely to break anyone's build in practice. The compiler now sends a "file_system_inputs" message to the build runner which shares the full set of files that were added to the cache system with the build system, so that the build runner can watch properly and redo the Compile step. This is implemented for whole cache mode but not yet for incremental cache mode.
2024-07-12std.Build.Cache.Path: fix the format methodAndrew Kelley
This function previously wrote a trailing directory separator, but that's not correct if the path refers to a file.
2024-07-12std.Build.Step.ObjCopy: remove random bytes from cache hashAndrew Kelley
The cache hash already has the zig version in there, so it's not really needed.