aboutsummaryrefslogtreecommitdiff
path: root/lib/std/Build/Step/Compile.zig
AgeCommit message (Collapse)Author
2024-09-12Replace deprecated default initializations with decl literalsLinus Groh
2024-08-28LLVM: disable inline 8-bit counters when using trace pc guardAndrew Kelley
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-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-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-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-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-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-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-01Extract getZigArgs function in std.Build.Step.CompileSashko
2024-06-02pass `-fno-builtin` when testing `lib/c.zig`, `lib/compiler_rt.zig`Veikka Tuominen
2024-05-28std.Build.step.Compile: Fix lib{c,cpp} mixup in dependsOnSystemLibrary()Linus Groh
2024-05-27update the codebase for the new std.Progress APIAndrew Kelley
2024-05-05Run: add output directory argumentsJacob Young
This allows running commands that take an output directory argument. The main thing that was needed for this feature was generated file subpaths, to allow access to the files in a generated directory. Additionally, a minor change was required to so that the correct directory is created for output directory args.
2024-05-05Build: cleanupJacob Young
* `doc/langref` formatting * upgrade `.{ .path = "..." }` to `b.path("...")` * avoid using arguments named `self` * make `Build.Step.Id` usage more consistent * add `Build.pathResolve` * use `pathJoin` and `pathResolve` everywhere * make sure `Build.LazyPath.getPath2` returns an absolute path
2024-05-03Rename Dir.writeFile2 -> Dir.writeFile and update all callsitesRyan Liptak
writeFile was deprecated in favor of writeFile2 in f645022d16361865e24582d28f1e62312fbc73bb. This commit renames writeFile2 to writeFile and makes writeFile2 a compile error.
2024-05-03Delete compile errors for deprecated declsRyan Liptak
2024-05-02Build system: Allow specifying Win32 resource include paths using LazyPathRyan Liptak
Adds an `include_paths` field to RcSourceFile that takes a slice of LazyPaths. The paths are resolved and subsequently appended to the -rcflags as `/I <resolved path>`. This fixes an accidental regression from https://github.com/ziglang/zig/pull/19174. Before that PR, all Win32 resource compilation would inherit the CC flags (via `addCCArgs`), which included things like include directories. After that PR, though, that is no longer the case. However, this commit intentionally does not restore the previous behavior (inheriting the C include paths). Instead, each .rc file will need to have its include paths specified directly and the include paths only apply to one particular resource script. This allows more fine-grained control and has less potentially surprising behavior (at the cost of some convenience). Closes #19605
2024-04-22std.Build: Install Windows DLLs to `<prefix>/bin/` by defaultCarl Åstholm
Windows does not support RPATH and only searches for DLLs in a small number of predetermined paths by default, with one of them being the directory from which the application loaded. Installing both executables and DLLs to `bin/` by default helps ensure that the executable can find any DLL artifacts it has linked to. DLL import libraries are still installed to `lib/`. These defaults match CMake's behavior.
2024-04-18std.Build: revert --host-target, --host-cpu, --host-dynamic-linkerAndrew Kelley
This is a partial revert of 105db13536b4dc2affe130cb8d2eee6c97c89bcd. As we learned from Void Linux packaging, these options are not actually helpful since the distribution package manager may very well want to cross-compile the packages that it is building. So, let's not overcomplicate things. There are already the standard options: -Dtarget, -Dcpu, and -Ddynamic-linker. These options are generally provided when the project generates machine code artifacts, however, there may be a project that does no such thing, in which case it makes sense for these options to be missing. The Zig Build System is a general-purpose build system, after all.
2024-04-11remove deprecated LazyPath.path union tagAndrew Kelley
2024-04-10introduce std.Build.path; deprecate LazyPath.relativeAndrew Kelley
This adds the *std.Build owner to LazyPath so that lazy paths returned from a dependency can be used in the application without friction or footguns. closes #19313
2024-04-07Account for dependency boundaries when duping headersCarl Åstholm
This is a temporary workaround that can be revered if/when 'path' lazy paths are updated to encode which build root they are relative to.
2024-04-07Document added/updated functionsCarl Åstholm
Also renames `addHeaders` to `addHeadersDirectory` for clarity.
2024-04-07Oops, forgot to dupe installations in `installLibraryHeaders`Carl Åstholm
Added test coverage for `installLibraryHeaders`
2024-04-07Implement `WriteFile.addCopyDirectory`Carl Åstholm
2024-04-07Create an include tree of installed headers for dependent modulesCarl Åstholm
2024-04-07std.Build: correct behavior of `Step.Compile.installHeader`Carl Åstholm
Previously, `Step.Compile.installHeader` and friends would incorrectly modify the default `install` top-level step, when the intent was for headers to get bundled with and installed alongside an artifact. This change set implements the intended behavior. This carries with it some breaking changes; `installHeader` and `installConfigHeader` both have new signatures, and `installHeadersDirectory` and `installHeadersDirectoryOptions` have been merged into `installHeaders`.
2024-03-30Update uses of `@fieldParentPtr` to use RLSJacob Young
2024-03-30Update uses of `@fieldParentPtr` to pass a pointer typeJacob Young
2024-03-27Build.Step.Compile: Add `mingw_unicode_entry_point` fieldRyan Liptak
Corresponds to the `-municode` CLI flag
2024-03-11std.builtin: make link mode fields lowercaseTristan Ross
2024-03-06feat: add support for --enable-new-dtags and --disable-new-dtagsDillen Meijboom
2024-02-25test: rework how filtering worksJacob Young
* make test names contain the fully qualified name * make test filters match the fully qualified name * allow multiple test filters, where a test is skipped if it does not match any of the specified filters
2024-02-24change `addCSourceFiles` to use `LazyPath` instead `Dependency` (#19017)David Rubin
Co-authored-by: Jacob Young <jacobly0@users.noreply.github.com>
2024-02-09Merge pull request #18712 from Vexu/std.optionsAndrew Kelley
std: make options a struct instance instead of a namespace
2024-02-02std.Build: implement --host-target, --host-cpu, --host-dynamic-linkerAndrew Kelley
This also makes a long-overdue change of extracting common state from Build into a shared Graph object. Getting the semantics right for these flags turned out to be quite tricky. In the end it works like this: * The override only happens when the target is fully native, with no additional query parameters, such as versions or CPU features added. * The override affects the resolved Target but leaves the original Query unmodified. * The "is native?" detection logic operates on the original, unmodified query. This makes it possible to provide invalid host target information, causing confusing errors to occur. Don't do that. There are some minor breaking changes to std.Build API such as the fact that `b.zig_exe` is now moved to `b.graph.zig_exe`, as well as a handful of other similar flags.
2024-02-02cli+build: handle -ObjC flag and route it to MachO linkerJakub Konka
2024-02-01remove std.io.ModeVeikka Tuominen
2024-01-29Apply cflags from pkg-config to all dependent modulesIan Johnson
Closes #18628 This commit splits the arguments obtained from pkg-config into two groups, cflags and libs, and consistently applies the cflags to each individual module linking the library while applying the libs only once for each compilation.
2024-01-19std.Build.Compile: handle modules sans root source filesAndrew Kelley
Uses the new `-M[name][=src]` CLI syntax to omit the source when the module does not have a zig root source file. Only some kinds of link objects imply that this should happen.
2024-01-14std/Build/Step/Compile: do not propagate deps of complex addObject stepJakub Konka
2024-01-13Expose `-f(no-)formatted-panics` to the build system (again)Carl Åstholm
2024-01-09Add support for `--(no-)undefined-version`dhash
Co-authored-by: Motiejus Jakštys <motiejus@jakstys.lt> Co-authored-by: Jakub Konka <kubkon@jakubkonka.com> Co-authored-by: Samuel Cantero <scanterog@gmail.com> Co-authored-by: Giorgos Georgiou <giorgos.georgiou@datadoghq.com> Co-authored-by: Carl Åstholm <carl@astholm.se>
2024-01-09Merge pull request #18491 from ziglang/fix-mod-link-obj-pathAndrew Kelley
std.Build.Step.Compile: fix link object paths
2024-01-08std.Build.Step.Compile: fix link object pathsAndrew Kelley
They were being resolved relative to the wrong owner. closes #18460
2024-01-09Build: Use `LazyPath` for version scriptsCarl Åstholm
2024-01-02std.Build.Step.Compile: fix passing wrong Builder to getPathAndrew Kelley
This resulted in an error building a transitive module dependency.