aboutsummaryrefslogtreecommitdiff
path: root/lib/std/Build/Step/Compile.zig
AgeCommit message (Collapse)Author
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.
2024-01-01CLI: introduce global -I args for C include pathsAndrew Kelley
This isn't technically needed since per-module -I args can suffice, but this can produce very long CLI invocations when several --mod args are combined with --search-prefix args since the -I args have to be repeated for each module. This is a partial revert of ecbe8bbf2df2ed4d473efbc32e0b6d7091fba76f.
2024-01-01std.Build.Step.Compile: fix search prefix loweringAndrew Kelley
Instead of adding -I and -L flags at the end of the CLI, they need to be added for every module, after the module-specific flags.
2024-01-01std.Build.Step.Compile: support modules with different argsAndrew Kelley
Now that the CLI supports per-module settings, the build system takes advantage of this when lowering a compilation to the command line.
2024-01-01std.Build.Step.Compile: restore previous step nameAndrew Kelley
Print using the target query rather than the resolved target. This makes it print "native" when compiling for the native target.
2024-01-01std.Build.ResolvedTarget: rename target field to resultAndrew Kelley
This change is seemingly insignificant but I actually agonized over this for three days. Some other things I considered: * (status quo in master branch) make Compile step creation functions accept a Target.Query and delete the ResolvedTarget struct. - downside: redundantly resolve target queries many times * same as before but additionally add a hash map to cache target query resolutions. - downside: now there is a hash map that doesn't actually need to exist, just to make the API more ergonomic. * add is_native_os and is_native_abi fields to std.Target and use it directly as the result of resolving a target query. - downside: they really don't belong there. They would be available as comptime booleans via `@import("builtin")` but they should not be exposed that way. With this change the downsides are: * the option name of addExecutable and friends is `target` instead of `resolved_target` matching the type name. - upside: this does not break compatibility with existing build scripts * you likely end up seeing `target.result.cpu.arch` rather than `target.cpu.arch`. - upside: this is an improvement over `target.target.cpu.arch` which it was before this commit. - downside: `b.host.target` is now `b.host.result`.
2024-01-01std.Target: add DynamicLinkerAndrew Kelley
2024-01-01rename std.zig.CrossTarget to std.Target.QueryAndrew Kelley
2024-01-01fix linker test regressionsAndrew Kelley
Caused by problems with transitive dependencies
2024-01-01zig build system: change target, compilation, and module APIsAndrew Kelley
Introduce the concept of "target query" and "resolved target". A target query is what the user specifies, with some things left to default. A resolved target has the default things discovered and populated. In the future, std.zig.CrossTarget will be rename to std.Target.Query. Introduces `std.Build.resolveTargetQuery` to get from one to the other. The concept of `main_mod_path` is gone, no longer supported. You have to put the root source file at the module root now. * remove deprecated API * update build.zig for the breaking API changes in this branch * move std.Build.Step.Compile.BuildId to std.zig.BuildId * add more options to std.Build.ExecutableOptions, std.Build.ObjectOptions, std.Build.SharedLibraryOptions, std.Build.StaticLibraryOptions, and std.Build.TestOptions. * remove `std.Build.constructCMacro`. There is no use for this API. * deprecate `std.Build.Step.Compile.defineCMacro`. Instead, `std.Build.Module.addCMacro` is provided. - remove `std.Build.Step.Compile.defineCMacroRaw`. * deprecate `std.Build.Step.Compile.linkFrameworkNeeded` - use `std.Build.Module.linkFramework` * deprecate `std.Build.Step.Compile.linkFrameworkWeak` - use `std.Build.Module.linkFramework` * move more logic into `std.Build.Module` * allow `target` and `optimize` to be `null` when creating a Module. Along with other fields, those unspecified options will be inherited from parent `Module` when inserted into an import table. * the `target` field of `addExecutable` is now required. pass `b.host` to get the host target.
2024-01-01zig build system: remove vcpkg integrationAndrew Kelley
Instead of vcpkg, users are encouraged to use the Zig package manager to fulfill dependencies on Windows.
2024-01-01introduce std.Build.Module and extract some logic into itAndrew Kelley
This moves many settings from `std.Build.Step.Compile` and into `std.Build.Module`, and then makes them transitive. In other words, it adds support for exposing Zig modules in packages, which are configured in various ways, such as depending on other link objects, include paths, or even a different optimization mode. Now, transitive dependencies will be included in the compilation, so you can, for example, make a Zig module depend on some C source code, and expose that Zig module in a package. Currently, the compiler frontend autogenerates only one `@import("builtin")` module for the entire compilation, however, a future enhancement will be to make it honor the differences in modules, so that modules can be compiled with different optimization modes, code model, valgrind integration, or even target CPU feature set. closes #14719
2023-12-16Expose `-f(no-)formatted-panics` to the build systemCarl Åstholm
2023-11-13expose to build systemxdBronch
2023-11-03cli: consolidate entry point flagsLuuk de Gram
2023-11-03update linker testsLuuk de Gram
This updates all linker tests to include `no_entry` as well as changes all tests to executable so they do not need to be updated later when the in-house WebAssembly linker supports dynamic libraries.
2023-11-03wasm-linker: implement `-fno-entry` flagLuuk de Gram
This adds support for the `-fno-entry` and `-fentry` flags respectively, for zig build-{exe/lib} and the build system. For `zig cc` we use the `--no-entry` flag to be compatible with clang and existing tooling. In `start.zig` we now make the main function optional when the target is WebAssembly, as to allow for the build-exe command in combination with `-fno-entry`. When the execution model is set, and is set to 'reactor', we now verify when an entry name is given it matches what is expected. When no entry point is given, we set it to `_initialize` by default. This means the user will also be met with an error when they use the reactor model, but did not provide the correct function.
2023-10-25Step.Compile: differentiate between fuzzy and exact matches for compile errorsJakub Konka
2023-10-24build: match and ignore /?/ in expected compile errorsJakub Konka
2023-10-22child_process + Build: rename exec to run + all related codeJan Philipp Hafer
Justification: exec, execv etc are unix concepts and portable version should be called differently. Do no touch non-Zig code. Adjust error names as well, if associated. Closes #5853.
2023-10-20Merge pull request #17608 from squeek502/resinator-fixesAndrew Kelley
resinator: Fix `INCLUDE` var handling and sync with upstream
2023-10-20std.Build: do not assume custom test runners support client-server modedweiller
2023-10-18Error if an .rc file uses the 'preprocess only' or 'no preprocess' flagsRyan Liptak
2023-10-15Add preliminary support for Windows .manifest filesRyan Liptak
An embedded manifest file is really just XML data embedded as a RT_MANIFEST resource (ID = 24). Typically, the Windows-only 'Manifest Tool' (`mt.exe`) is used to embed manifest files, and `mt.exe` also seems to perform some transformation of the manifest data before embedding, but in testing it doesn't seem like the transformations are necessary to get the intended result. So, to handle embedding manifest files, Zig now takes the following approach: - Generate a .rc file with the contents `1 24 "path-to-manifest.manifest"` - Compile that generated .rc file into a .res file - Link the .res file into the final binary This effectively achieves the same thing as `mt.exe` minus the validation/transformations of the XML data that it performs. How this is used: On the command line: ``` zig build-exe main.zig main.manifest ``` (on the command line, specifying a .manifest file when the target object format is not COFF is an error) or in build.zig: ``` const exe = b.addExecutable(.{ .name = "manifest-test", .root_source_file = .{ .path = "main.zig" }, .target = target, .optimize = optimize, .win32_manifest = .{ .path = "main.manifest" }, }); ``` (in build.zig, the manifest file is ignored if the target object format is not COFF) Note: Currently, only one manifest file can be specified per compilation. This is because the ID of the manifest resource is currently always 1. Specifying multiple manifests could be supported if a way for the user to specify an ID for each manifest is added (manifest IDs must be a u16). Closes #17406 options
2023-10-13remove redundant use of pathFromRootradar roark
2023-10-10Step.Compile: add options struct for `addCSourceFiles` (#17420)Krzysztof Wolicki
Closes #17410
2023-10-08get `zig fetch` working with the new systemAndrew Kelley
* start renaming "package" to "module" (see #14307) - build system gains `main_mod_path` and `main_pkg_path` is still there but it is deprecated. * eliminate the object-oriented memory management style of what was previously `*Package`. Now it is `*Package.Module` and all pointers point to externally managed memory. * fixes to get the new Fetch.zig code working. The previous commit was work-in-progress. There are still two commented out code paths, the one that leads to `Compilation.create` and the one for `zig build` that fetches the entire dependency tree and creates the required modules for the build runner.
2023-10-04comp: add support for -fdata-sectionsJakub Konka
2023-10-02std.Build: expose `-idirafter` to the build systemCarl Åstholm
2023-09-26Add '--compress-debug-sections=zstd'LinuxUserGD
2023-09-24Support non zig dependenciesantlilja
Dependencies no longer require a build.zig file. Adds path function to Dependency struct which returns a LazyPath into a dependency.
2023-09-17rc compilation: Use MSVC includes if present, fallback to mingwRyan Liptak
The include directories used when preprocessing .rc files are now separate from the target, and by default will use the system MSVC include paths if the MSVC + Windows SDK are present, otherwise it will fall back to the MinGW includes distributed with Zig. This default behavior can be overridden by the `-rcincludes` option (possible values: any (the default), msvc, gnu, or none). This behavior is useful because Windows resource files may `#include` files that only exist with in the MSVC include dirs (e.g. in `<MSVC install directory>/atlmfc/include` which can contain other .rc files, images, icons, cursors, etc). So, by defaulting to the `any` behavior (MSVC if present, MinGW fallback), users will by default get behavior that is most-likely-to-work. It also should be okay that the include directories used when compiling .rc files differ from the include directories used when compiling the main binary, since the .res format is not dependent on anything ABI-related. The only relevant differences would be things like `#define` constants being different values in the MinGW headers vs the MSVC headers, but any such differences would likely be a MinGW bug.
2023-09-17addWin32ResourceFile: Ignore the resource file if the target object format ↵Ryan Liptak
is not coff
2023-09-17Add a .rc -> .res compiler to the Zig compilerRyan Liptak
2023-08-18build: merge FrameworkDir into IncludeDirJakub Konka
2023-08-18build: disambiguate system framework path (-iframework) from framework path (-F)Jakub Konka
2023-08-18build: remove spurious -iframework flag; use getPath2 for framework path ↵Jakub Konka
resolution
2023-08-18build: do not emit -iwithsysroot/-iframeworkwithsysroot implicitlyJakub Konka
Prior to this change, we would unconditionally emit any system include path/framework path as `-iwithsysroot`/`-iframeworkwithsysroot` if the sysroot was set which can lead to unexpected build failures. Now, calls to `b.addSystemIncludePath` and `b.addFrameworkPath` will always emit search paths as `-isystem`/`-iframework`. As a result, it is now up to the user to correctly concat the search paths with the sysroot when and where desired. If there is a need for emitting `-iwithsysroot`/`-iframeworkwithsysroot` I would advise adding explicit hooks such as `addSystemIncludePathWithSysroot` and `addFrameworkPathWithSysroot`.
2023-08-09change uses of std.builtin.Mode to OptimizeMode (#16745)Zachary Raineri
std.builtin.Mode is deprecated.
2023-08-03std.Build.Step.Compile: fine-grained system lib search controlAndrew Kelley
For each library you can specify the preferred mode and search strategy. The old way of setting global state is eliminated.
2023-08-03Fix compile error in `addVcpkgPaths`Fabio Arnold
2023-08-02build: dupe library, rpath, and framework LazyPathsMitchell Hashimoto
Without duping, users could get some unexpected behavior if they used a string with a lifetime that didn't persist throughout the full build, i.e. if it wasn't heap allocated, or if it was explicitly freed.