aboutsummaryrefslogtreecommitdiff
path: root/lib/std/Build
AgeCommit message (Collapse)Author
2023-05-10fix 'zig build test' crashing with no tests0x5a4
fixes #15553
2023-05-07convert s[start..start+len] to s[start..][0..len]dweiller
2023-05-03std.Build: use Step.* instead of *StepVeikka Tuominen
Follow up to 13eb7251d37759bd47403db304c6120c706fe353
2023-05-03build: rename std.Build.*Step to std.Build.Step.*Nicolas Sterchele
Follow-up actions from #14647 Fixes #14947
2023-04-30std: fix a bunch of typosLinus Groh
The majority of these are in comments, some in doc comments which might affect the generated documentation, and a few in parameter names - nothing that should be breaking, however.
2023-04-28std.Build.RunStep: show test name on process terminationAndrew Kelley
This is a small change to help when reading failure logs which makes the "exited with code 1" and similar message include the test name. Further enhancements could do the following: * even if one unit test crashes the process, the parent process continues running the other unit tests * ability to test for expected panics (#1356) * timeouts on individual tests
2023-04-28update codebase to use `@memset` and `@memcpy`Andrew Kelley
2023-04-23Improvements to docs and textzooster
* docs(std.math): elaborate on difference between absCast and absInt * docs(std.rand.Random.weightedIndex): elaborate on likelihood I think this makes it easier to understand. * langref: add small reminder * docs(std.fs.path.extension): brevity * docs(std.bit_set.StaticBitSet): mention the specific types * std.debug.TTY: explain what purpose this struct serves This should also make it clearer that this struct is not supposed to provide unrelated terminal manipulation functionality such as setting the cursor position or something because terminals are complicated and we should keep this struct simple and focused on debugging. * langref(package listing): brevity * langref: explain what exactly `threadlocal` causes to happen * std.array_list: link between swapRemove and orderedRemove Maybe this can serve as a TLDR and make it easier to decide. * PrefetchOptions.locality: clarify docs that this is a range This confused me previously and I thought I can only use either 0 or 3. * fix typos and more * std.builtin.CallingConvention: document some CCs * langref: explain possibly cryptic names I think it helps knowing what exactly these acronyms (@clz and @ctz) and abbreviations (@popCount) mean. * variadic function error: add missing preposition * std.fmt.format docs: nicely hyphenate * help menu: say what to optimize for I think this is slightly more specific than just calling it "optimizations". These are speed optimizations. I used the word "performance" here.
2023-04-21std.Build.RunStep: fix captureStdOut function return typeManlio Perillo
The return type of the captureStdOut function is incorrect. Replace *std.Build.GeneratedFile with std.Build.FileSource.
2023-04-20fixes to the previous commitAndrew Kelley
* CompileStep: Avoid calling producesPdbFile() to determine whether the option should be respected. If the user asks for it, put it on the command line and let the Zig CLI deal with it appropriately. * Make the namespace of `std.dwarf.Format.dwarf32` no longer have a redundant "dwarf" in it. * Add `zig cc` integration for `-gdwarf32` and `-gdwarf64`. * Toss in a bonus bug fix for `-gdwarf-2`, `-gdwarf-3`, etc. * Avoid using default init values for struct fields unnecessarily. * Add missing cache hash addition for the new option.
2023-04-20Expose an option for producing 64-bit DWARF formatDavid Gonzalez Martin
This commit enables producing 64-bit DWARF format for Zig executables that are produced through the LLVM backend. This is achieved by exposing both command-line flags and CompileStep flags. The production of the 64-bit format only affects binaries that use the DWARF format and it is disabled on MacOS due to it being problematic. This commit, despite generating the interface for the Zig user to be able to tell the compile which format is wanted, is just implemented for the LLVM backend, so clang and the self-hosted backends will need this to be implemented in a future commit. This is an effort to work around #7962, since the emission of the 64-bit format automatically produces 64-bit relocations. Further investigation will be needed to make DWARF 32-bit format to emit bigger relocations when needed and not make the linker angry.
2023-04-18Cache: fix multi-process race condition on macOSAndrew Kelley
This fixes `.INVAL => unreachable` being triggered by the cache system on macOS when multiple processes race to create the same compilation. The problem is that when two processes race to create a file, it sometimes returns ENOENT even though that error code is nonsensical for this situation. Commit 2b0929929d67e222ca6a9523a3a594ed456c4a51 purportedly solved this, but it did not open the file with write permissions, leading to the EINVAL panic later on. This commit remedies the situation by introducing a loop and simply retrying when the ENOENT occurs.
2023-04-15CI: more C backend test coverageAndrew Kelley
The CI now runs C backend tests in addition to compiling them. It uses -std=c99 -pedantic -Werror in order to catch non-conformant C code. This necessitated disabling a test case that caused a C compile error, in addition to disabling a handful of warnings that are already being triggered by Zig's C backend output for the behavior tests. The upshot is that I was able to, very cleanly, integrate the C backend tests into the build system, so that it communicates via the test runner protocol along with all the other behavior tests.
2023-04-15std.Build: add some more init options to CompileStepAndrew Kelley
2023-04-14std.Build.CompileStep: fix installLibraryHeaders regressionAndrew Kelley
reverts regression introduced in d2ad3f5074877475c8f0ec0fbbb323a05fe8cf78. The commit correctly removed dest_builder from InstallArtifactStep, but the change to installLibraryHeaders was incorrect since it affected different steps than that one.
2023-04-12Zir: implement explicit block_comptime instructionmlugg
Resolves: #7056
2023-04-11fix build logic due to state mutations and break the API accordinglyAndrew Kelley
* remove setName, setFilter, and setTestRunner. Please set these options directly when creating the CompileStep. * removed unused field * remove computeOutFileNames and inline the logic, making clear the goal of avoiding state mutations after the build step is created.
2023-04-11std.Build.CompileStep: remove output_dirAndrew Kelley
Build scripts must instead use the FileSource abstraction rather than telling the compiler directly where to output files. closes #14951
2023-04-11CLI: remove --enable-cache optionAndrew Kelley
This use case is now handled instead by the --listen option. closes #15025 closes #15072
2023-04-10std.Build.RunStep: don't close stdinAndrew Kelley
Instead, ignore stdin. Otherwise this interfers with a sub-process which expects to have a stdin file descriptor open.
2023-04-10std.Build.CompileStep: remove run() and install()Andrew Kelley
These functions are problematic in light of dependencies because they run and install, respectively, for the *owner* package rather than for the *user* package. By removing these functions, the build script is forced to provide the *Build object to associate the new step with, making everything less surprising. Unfortunately, this is a widely breaking change. see #15079
2023-04-10std.Build.CompileStep: delete install_step fieldAndrew Kelley
This was used to ensure that an artifact would only be installed once, but this is not only unnecessary, but actively harmful, in the face of dependencies. see #15079
2023-04-10std.Build.CompileStep: remove redundant dest_builder fieldAndrew Kelley
The destination *Build object is already known to be step.owner, while the source object is artifact.step.owner.
2023-04-01link: handle -u flag in all linkersJakub Konka
Also clean up parsing of linker args - reuse `ArgsIterator`. In MachO, ensure we add every symbol marked with `-u` as undefined before proceeding with symbol resolution. Additionally, ensure those symbols are never garbage collected. MachO entry_in_dylib test: pass `-u _my_main` when linking executable so that it is not incorrectly garbage collected by the linker.
2023-03-25build: fixes from reviewkcbanner
2023-03-25coff: change dynamicbase to default to true (to match lld), change it to ↵kcbanner
pass the negation to lld, and add --no-dynamicbase build: expose linker_dynamicbase on CompileStep and map it to emit --no-dynamicbase
2023-03-23build: allow for deferred FileSource matching in CheckObjectStepJakub Konka
Re-enable all of functionality of MachO dylib test.
2023-03-23build: when parsing rpaths, do not expand special runtime paths on DarwinJakub Konka
Special runtime paths on Darwin are: `@executable_path` and `@loader_path`.
2023-03-20std.Build.RunStep: fix control flow with qemu+glibc logicAndrew Kelley
2023-03-19fix std.Build.OptionsStepAndrew Kelley
* use the same hash function as the rest of the steps * fix race condition due to a macOS oddity. * fix race condition due to file truncation (rename into place instead) * integrate with marking Step.result_cached. check if the file already exists with fs.access before doing anything else. * use a directory so that the file basename can be "options.zig" instead of a hash digest. * better error reporting in case of file system failures.
2023-03-18build-step: remove latest LogStep refNicolas Sterchele
LogStep was removed during the build parallel enhancement made in this commit 58edefc6d1716c0731ee2fe672ec8d073651aafb
2023-03-17main: add debug option to dump unoptimized llvm irJacob Young
2023-03-15std.Build: fix invalid assumption about fifosAndrew Kelley
Previously this code asserted that a fifo's readable length was greater than or equal to the length of its readable slice, which was an invalid assertion. This code avoids making that assumption.
2023-03-15std.Build.Cache: make unit tests not depend on cwdAndrew Kelley
This makes them more resilient to being run multiple times by multiple different processes at the same time.
2023-03-15std.Build.RunStep: fix handling spawn failureAndrew Kelley
The error was caught and created a Step failure rather than bubbling up so that the interpreter logic could handle it. Fixes hundreds of test failures on Windows.
2023-03-15std.Build.Cache: handle ENOENT on createFile raceAndrew Kelley
Companion commit to 628fec41593a2d2eca8b504e4fe90de9823aeded
2023-03-15std.Build.CompileStep: remove setNamePrefix and add setNameAndrew Kelley
2023-03-15std.Build.Cache: handle ENOENT on createFile raceAndrew Kelley
There are no dir components, so you would think that this was unreachable, however we have observed on macOS two processes racing to do openat() with O_CREAT manifest in ENOENT.
2023-03-15std.Build.CompileStep: proper step dependency on headersAndrew Kelley
Rather than calling make() from within make().
2023-03-15build runner: fix compilation errors on windowsAndrew Kelley
2023-03-15std.build.RunStep: clean up some leftover messAndrew Kelley
* Remove some functions that are no longer needed since EmulateableRunStep is gone. * Add removeEnvironmentVariable function. * Support printing environment variables in --verbose mode.
2023-03-15make the build runner and test runner talk to each otherAndrew Kelley
std.Build.addTest creates a CompileStep as before, however, this kind of step no longer actually runs the unit tests. Instead it only compiles it, and one must additionally create a RunStep from the CompileStep in order to actually run the tests. RunStep gains integration with the default test runner, which now supports the standard --listen=- argument in order to communicate over stdin and stdout. It also reports test statistics; how many passed, failed, and leaked, as well as directly associating the relevant stderr with the particular test name that failed. This separation of CompileStep and RunStep means that `CompileStep.Kind.test_exe` is no longer needed, and therefore has been removed in this commit. * build runner: show unit test statistics in build summary * added Step.writeManifest since many steps want to treat it as a warning and emit the same message if it fails. * RunStep: fixed error message that prints the failed command printing the original argv and not the adjusted argv in case an interpreter was used. * RunStep: fixed not passing the command line arguments to the interpreter. * move src/Server.zig to std.zig.Server so that the default test runner can use it. * the simpler test runner function which is used by work-in-progress backends now no longer prints to stderr, which is necessary in order for the build runner to not print the stderr as a warning message.
2023-03-15std.Build.InstallFileStep: add missing step dependenciesAndrew Kelley
in the creation function, which had to change from init() to create().
2023-03-15std.Build.WriteFileStep: add missing step dependenciesAndrew Kelley
2023-03-15zig objcopy: support the compiler protocolAndrew Kelley
This commit extracts out server code into src/Server.zig and uses it both in the main CLI as well as `zig objcopy`. std.Build.ObjCopyStep now adds `--listen=-` to the CLI for `zig objcopy` and observes the protocol for progress and other kinds of integrations. This fixes the last two test failures of this branch when I run `zig build test` locally.
2023-03-15build runner enhancements in preparation for test-casesAndrew Kelley
* std.zig.ErrorBundle: support rendering options for whether to include the reference trace, whether to include the source line, and TTY configuration. * build runner: don't print progress in dumb terminals * std.Build.CompileStep: - add a way to expect compilation errors via the new `expect_errors` field. This is an advanced setting that can change the intent of the CompileStep. If this slice has nonzero length, it means that the CompileStep exists to check for compile errors and return *success* if they match, and failure otherwise. - remove the object format parameter from `checkObject`. The object format is known based on the CompileStep's target. - Avoid passing -L and -I flags for nonexistent directories within search_prefixes. This prevents a warning, that should probably be upgraded to an error in Zig's CLI parsing code, when the linker sees an -L directory that does not exist. * std.Build.Step: - When spawning the zig compiler process, takes advantage of the new `std.Progress.Node.setName` API to avoid ticking up a meaningless number at every progress update.
2023-03-15std.Build.CheckFileStep: add a way to expect exactAndrew Kelley
This is done in a bit of a haphazard way. Eventually the API needs to break in favor of a "checks" system similar to how RunStep works.
2023-03-15std.Build.RunStep: support -fqemu solving bad dynamic linkerAndrew Kelley
2023-03-15std.Build.CompileStep: add FileSource support to some pathsAndrew Kelley
Library paths, RPaths, and framework paths now support being fulfilled by FileSource arguments.
2023-03-15std.Build.CheckObjectStep: better error messageAndrew Kelley
when reading the file fails