aboutsummaryrefslogtreecommitdiff
path: root/lib/std/build.zig
AgeCommit message (Collapse)Author
2022-09-08std.zig.system.NativeTargetInfo: detection ignores self exeAndrew Kelley
Before, native glibc and dynamic linker detection attempted to use the executable's own binary if it was dynamically linked to answer both the C ABI question and the dynamic linker question. However, this could be problematic on a system that uses a RUNPATH for the compiler binary, locking it to an older glibc version, while system binaries such as /usr/bin/env use a newer glibc version. The problem is that libc.so.6 glibc version will match that of the system while the dynamic linker will match that of the compiler binary. Executables with these versions mismatching will fail to run. Therefore, this commit changes the logic to be the same regardless of whether the compiler binary is dynamically or statically linked. It inspects `/usr/bin/env` as an ELF file to find the answer to these questions, or if there is a shebang line, then it chases the referenced file recursively. If that does not provide the answer, then the function falls back to defaults. This commit also solves a TODO to remove an Allocator parameter to the detect() function.
2022-08-22build system: add flag for -fstack-protectorAndrew Kelley
2022-08-21std: fix EmulatableRunStepLuuk de Gram
Fixes a compilation error when using the `EmulatableRunStep` that is being generated from a step directly using `runEmulatable`.
2022-08-20test/link: add wasm linker-test for archivesLuuk de Gram
Adds a test case that will pull-in compiler-rt symbols, and therefore link with the compiler-rt archive file.
2022-08-18std.build: Fix typo in `LibExeObjStep.runEmulatable`'s assertionSage Hane
2022-07-26std.fmt: require specifier for unwrapping ?T and E!TInKryption
2022-07-23Share logic between EmulatableRunStep & RunStepLuuk de Gram
2022-07-23rename:RunCompareStep -> EmulatableRunStepLuuk de Gram
Renamed to better convery the intention of the step
2022-07-23RunCompareStep: implement new stepLuuk de Gram
This creates a new step that can run foreign binaries when emulation is enabled using options such as `enable_qemu`. When an incompatible binary is found, the binary will not be executed. This differs from `RunStep` which will always execute a binary, regardless of the compatibility. This is useful for usecases where the user wishes to allow for running the binary on any supported platform either natively or through emulation, but not generate an error when met with an incompatibility. The above is useful when creating test cases that rely on running the binary and optionally verifying its output. The addition of this Step was generated by the need for our linker tests. For that reason, a handy function was created on `CheckObjectStep` to ease the setup for that.
2022-07-22cli: support --gc-sections and --no-gc-sections for Zig sourcesJakub Konka
2022-07-20build.zig: teach `--compress-debug-sections`Motiejus Jakštys
Now that #11863 is landed, let's expose it to the zig programs that build stuff via `build.zig`. "Benchmarks" with [turbonss](https://git.sr.ht/~motiejus/turbonss): Built with: $ zig build -Dtarget=x86_64-linux-gnu.2.19 -Dcpu=x86_64_v3 -Drelease-small=true *Debug, uncompressed* 174K turbonss-analyze 161K turbonss-getent 1.2M turbonss-unix2db 448K libnss_turbo.so.2.0.0 *Debug, compressed* 78K turbonss-analyze 86K turbonss-getent 572K turbonss-unix2db 190K libnss_turbo.so.2.0.0 *Stripped, for completeness* 17K turbonss-analyze 20K turbonss-getent 197K turbonss-unix2db 26K libnss_turbo.so.2.0.0
2022-07-15std.fs: split `Dir` into `IterableDir`Veikka Tuominen
Also adds safety check for attempting to iterate directory not opened with `iterate = true`.
2022-07-12wasm-linker: Implement linker tests (#12006)Luuk de Gram
* test/link: initial wasm support This adds basic parsing and dumping of wasm section so they can be tested using the new linker-test infrastructure. * test/link: all wasm sections parsing and dumping We now parse and dump all sections for the wasm binary format. Currently, this only dumps the name of a custom section. Later this should also dump symbol table, name, linking metadata and relocations. All of those live within the custom sections. * Add wasm linker test This also fixes a parser mistake in reading the flags. * test/link: implement linker tests wasm & fixes Adds several test cases to test the wasm self-hosted linker. This also introduces fixes that were caught during the implementation of those tests. * test-runner: obey omit_stage2 for standalone When a standalone test requires stage2, but stage2 is omit from the compiler, such test case will not be included as part of the test suite that is being ran. This is to support CI's where we omit stage2 to lower the memory usage.
2022-07-11use std.log for loggingMikko Kaihlavirta
2022-06-28build: handle weakly imported libs and frameworksJakub Konka
2022-06-27macho: implement and handle `-needed-*` and `-needed_*` family of flagsJakub Konka
MachO linker now handles `-needed-l<name>`, `-needed_library=<name>` and `-needed_framework=<name>`. While on macOS `-l` is equivalent to `-needed-l`, and `-framework` to `-needed_framework`, it can be used to the same effect as on Linux if combined with `-dead_strip_dylibs`. This commit also adds handling for `-needed_library` which is macOS specific flag only (in addition to `-needed-l`). Finally, in order to leverage new linker testing harness, this commit added ability to specify lowering to those flags via `build.zig`: `linkSystemLibraryNeeded` (and related), and `linkFrameworkNeeded`.
2022-06-27macho: implement -dead_strip_dylibs linker flagJakub Konka
2022-06-25macho: implement -headerpad_max_install_namesJakub Konka
2022-06-25macho: implement -headerpad_size optionJakub Konka
Includes both traditiona and incremental codepaths with one caveat that in incremental case, the requested size cannot be smaller than the default padding size due to prealloc required due to incremental nature of linking. Also parse `-headerpad_max_install_names`, however, not actionable just yet - missing implementation.
2022-06-24macho: implement -search_dylibs_first linker optionJakub Konka
2022-06-22link-tests: rename CheckMachOStep to CheckObjectStep and accept obj formatJakub Konka
2022-06-21link-tests: add CheckMachOStepJakub Konka
CheckMachOStep specialises CheckFileStep into directed (surgical) MachO file fuzzy searches. This will be the building block for comprehensive MachO linker tests.
2022-06-20link-tests: test pagezero_size option for machoJakub Konka
2022-06-08std.build: Expose `-z norelro` and `-z lazy`Isaac Freund
2022-05-31stage2: add support for -fbuild-id,-fno-build-idAndrew Kelley
closes #3047
2022-05-26Rename `std.build.Pkg.path` to `std.build.Pkg.source` (#11557)Hanna
2022-05-11Update usages of `process.getEnvMap` and change BufMap -> EnvMap where ↵Jonathan Marler
applicable # Conflicts: # lib/std/build/RunStep.zig
2022-05-09stdlib: escape backslashes and double quotes in Builder response fileEvan Haas
Fixes #11595
2022-05-07Merge pull request #11592 from ziglang/stage3-macos-linkerAndrew Kelley
Sema: solve a false positive "depends on itself"
2022-05-06flatten lib/std/special and improve "pkg inside another" logicAndrew Kelley
stage2: change logic for detecting whether the main package is inside the std package. Previously it relied on realpath() which is not portable. This uses resolve() which is how imports already work. * stage2: fix cleanup bug when creating Module * flatten lib/std/special/* to lib/* - this was motivated by making main_pkg_is_inside_std false for compiler_rt & friends. * rename "mini libc" to "universal libc"
2022-05-05CI: add non-LLVM backends to the test matrixAndrew Kelley
We can't yet run the behavior tests with stage3, but at least we can run them with stage2, and we can use the proper test matrix. This commit also adds use_llvm and ofmt to the zig build system.
2022-04-29std: Do not allocate the result for ChildProcess.initJimmi Holst Christensen
Instead, just return ChildProcess directly. This structure does not require a stable address, so we can put it on the stack just fine. If someone wants it on the heap they should do. const proc = try allocator.create(ChildProcess); proc.* = ChildProcess.init(args, allocator);
2022-04-28Revert "Merge pull request #11214 from iddev5/ay-build-runner"Andrew Kelley
This reverts commit 75c9936737a6ba991d4ef187ddc9d51bc0ad0998, reversing changes made to 7f13f5cd5f5a518638b15d7225eae2d88ec1efb5. I don't think `runZigBuild` belongs in std.testing. We already have `test/standalone/*` for this. Additionally test names should explain what they are testing rather than referencing GitHub issue numbers.
2022-04-28std.build: fix dll-export-fns APIAndrew Kelley
We have a pattern using `?bool` for the -f/-fno- style flags. Fixup for 8e3add8736be683b450c2754bedb064811baed0e.
2022-04-28Merge pull request #11214 from iddev5/ay-build-runnerVeikka Tuominen
std: explicitly handle error.UnexpectedExitCode in build_runner
2022-04-28std.build: make no_dll_export_fns accessible in build stepErik Hugne
2022-04-19build system: add -fstage1/-fno-stage1 to `zig build`Andrew Kelley
So that people can start experimenting with compiling their projects with the self-hosted compiler. I expect this commit to be reverted after #89 is closed.
2022-04-15std.build: add test for issue 10381iddev5
2022-04-12std.build: Fix transitive linkSystemLibraryName() dependenciesIsaac Freund
Currently transitive system library dependencies are always linked using linkSystemLibrary() and therefore pkg-config even if they were originally specified with linkSystemLibraryName() instead. This causes problems in practice for projects needing total control over exactly what library is linked, such as the mach game engine. This is fixed by keeping track of whether libraries are to be linked with pkg-config or not and holding off on actually running pkg-config until after transitive dependency resolution in LibExeObjStep.make(). This also fixes a separate issue with the pkg-config handling that could cause partial application of pkg-config flags if the first part of the pkg-config output parses correctly but there is an error later on. This error isn't always fatal as we fall back to a plain -lfoo in the case of linkSystemLibrary().
2022-03-22macho: extend CodeSignature to accept entitlementsJakub Konka
With this change, we can now bake in entitlements into the binary. Additionally, I see this as the first step towards full code signature support which includes baking in Apple issued certificates for redistribution, etc.
2022-03-21Sema: dummy implementation of `@errorReturnTrace`Andrew Kelley
Also update std/build.zig to use stage2 function pointer semantics. This gets us a little bit closer to `zig build` working, although it is now hitting a new crash in the compiler.
2022-03-16std: introduce posix_spawn as an alt to fork-execJakub Konka
Currently, the new API will only be available on macOS with the intention of adding more POSIX systems to it incrementally (such as Linux, etc.). Changes: * add `posix_spawn` wrappers in a separate container in `os/posix_spawn.zig` * rewrite `ChildProcess.spawnPosix` using `posix_spawn` targeting macOS as `ChildProcess.spawnMacos` * introduce a `posix_spawn` specific `std.c.waitpid` wrapper which does return an error in case the child process failed to exec - this is required for any process that was spawned using `posix_spawn` mechanism as, by definition, the errors returned by `posix_spawn` routine cover only the `fork`-equivalent; `pre-exec()` and `exec()` steps are covered by a catch-all error `ECHILD` returned by `waitpid` on unsuccessful execution, e.g., no such file error, etc.
2022-03-05Revert "Revert "Merge pull request #10950 from hexops/sg/responsefiles""Stephen Gutekanst
This reverts commit 5ab5e2e6731a9f1198df6c53134545ccc6a6bbd3.
2022-02-24Revert "Merge pull request #10950 from hexops/sg/responsefiles"Andrew Kelley
This reverts commit 136a43934bc08dc3aee85f1182904b97456601d3, reversing changes made to 9dd839b7ed15d1191f3303d069cffe0473e03e83. This broke the behavior of `zig run`.
2022-02-23Merge pull request #10950 from hexops/sg/responsefilesJakub Konka
Do not fail to build if 'zig build-lib' etc. arguments exceed OS limits
2022-02-23stage1-wasm: implement shared memoryxReveres
2022-02-21std: Builder: use response files for zig test invocations tooStephen Gutekanst
Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
2022-02-21std: Builder: account for null term considering response filesStephen Gutekanst
Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
2022-02-20std: have Builder use response files if zig build args exceed OS limitsStephen Gutekanst
In Mach engine we're seeing command line arguments to `zig build-lib` exceed the 32 KiB limit that Windows imposes, due to the number of sources and compiler flags we must pass in order to build gpu-dawn. This change fixes the issue by having `Builder` check if the arguments to a `zig build-*` command are >30 KiB and, if so, writes the arguments to a file `zig-cache/args/<SHA2 of args>`. Then the command invocation merely becomes `zig build-lib @<that file>`. Fixes #10693 Fixes hexops/mach#167 Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
2022-02-17Revert "reduce build error noise"Andrew Kelley
This reverts commit baead472d7641bdd96130354bafadc1fb1ed223b. Let's go through the proposal process on this one. I want to push back on this. My position is that, at the very least, a full trace of command lines of sub-processes should be printed on failure, with the exception of opt-in flags such as `--prominent-compile-errors`.