aboutsummaryrefslogtreecommitdiff
path: root/src/Compilation.zig
AgeCommit message (Collapse)Author
2023-10-02Merge pull request #17221 from Vexu/aro-translate-cVeikka Tuominen
Aro translate-c
2023-10-01aro-translate-c: translate enumsVeikka Tuominen
2023-10-01add compiler flag for selecting C frontendVeikka Tuominen
2023-10-01x86_64: implement and test unary float builtinsJacob Young
2023-09-29C backend: remove ?*Decl from DeclGenAndrew Kelley
Another simplification. DeclGen already has `decl_index` which can be used to retrieve the `*Decl` if needed.
2023-09-28Compilation: introduce saveState()Andrew Kelley
This commit introduces `--debug-incremental` so that we can start playing around with incremental compilation while it is still being developed, and before it is enabled by default. Currently it saves InternPool data, and has TODO comments for the remaining things. Deserialization is not implemented yet, which will require some post-processing such as to build a string map out of null-terminated string table bytes. The saved compiler state is stored in a file called <root-name>.zcs alongside <root-name>.o, <root-name>.pdb, <root-name>.exe, etc. In case of using the zig build system, these files are all in a zig-cache directory. For the self-hosted compiler, here is one data point on the performance penalty of saving this data: ``` Benchmark 1 (3 runs): zig build-exe ... measurement mean ± σ min … max outliers delta wall_time 51.1s ± 354ms 50.7s … 51.4s 0 ( 0%) 0% peak_rss 3.91GB ± 354KB 3.91GB … 3.91GB 0 ( 0%) 0% cpu_cycles 212G ± 3.17G 210G … 216G 0 ( 0%) 0% instructions 274G ± 57.5M 274G … 275G 0 ( 0%) 0% cache_references 13.1G ± 97.6M 13.0G … 13.2G 0 ( 0%) 0% cache_misses 1.12G ± 24.6M 1.10G … 1.15G 0 ( 0%) 0% branch_misses 1.53G ± 1.46M 1.53G … 1.53G 0 ( 0%) 0% Benchmark 2 (3 runs): zig build-exe ... --debug-incremental measurement mean ± σ min … max outliers delta wall_time 51.8s ± 271ms 51.5s … 52.1s 0 ( 0%) + 1.3% ± 1.4% peak_rss 3.91GB ± 317KB 3.91GB … 3.91GB 0 ( 0%) - 0.0% ± 0.0% cpu_cycles 213G ± 398M 212G … 213G 0 ( 0%) + 0.3% ± 2.4% instructions 275G ± 79.1M 275G … 275G 0 ( 0%) + 0.1% ± 0.1% cache_references 13.1G ± 26.9M 13.0G … 13.1G 0 ( 0%) - 0.1% ± 1.2% cache_misses 1.12G ± 5.66M 1.11G … 1.12G 0 ( 0%) - 0.6% ± 3.6% branch_misses 1.53G ± 1.75M 1.53G … 1.54G 0 ( 0%) + 0.2% ± 0.2% ``` At the end of each compilation with `--debug-incremental`, we end up with a 43 MiB `zig.zcs` file that contains all of the InternPool data serialized. Of course, it will necessarily be more expensive to save the state than to not save the state. However, this data point shows just how cheap the save state operation is, with all of the groundwork laid for using a serialization-friendly in-memory data layout.
2023-09-26Merge pull request #17152 from mikdusan/macos-sdkAndrew Kelley
macos SDK updates and enhancements
2023-09-26define `_WIN32_WINNT` for windows compilations based on target minver (#17224)Phil Richards
2023-09-25kubkon review changes: 3Michael Dusan
- make vendored settings failure unreachable - rename field `darwinSdkLayout` → `darwin_sdk_layout` - make `darwin_sdk_layout` optional
2023-09-25kubkon review changes: 1Michael Dusan
general: - rename `DarwinSdkLayout` → `DarwinSdkLayout` - drop `DarwinSdkLayout.installation` (not needed for darwin) - document struct inferSdkVersion: - use explicit allocator - avoid trying to infer SDK ver from vendored path
2023-09-25macos: better SDK version detectionMichael Dusan
SDK version detection: - read SDKSettings.json before inferral from SDK path - vendored libc: add SDKSettings.json for SDK version info resolveLibSystem: - adjust search order to { search_dirs, { sysroot or vendored }} - previous search order was { sysroot, search_dirs, vendored }
2023-09-25macos: vendored libc: combine headers: part 2Michael Dusan
- update include dirs to use combined dir - use one libSystem.tbd (drop use of libSystem.VERSION.tbd) - update canBuildLibC to check for minimum os version only
2023-09-25translate-c: convert clang errors messages into `std.zig.ErrorBundle`Techatrix
2023-09-24resinator: do not include in only_core_functionality buildsmlugg
This prevents resinator from being included in zig1 and zig2.
2023-09-23Fix reportRetryableWin32ResourceErrorRyan Liptak
Follow up to https://github.com/ziglang/zig/pull/17069. This TODO being left in was a complete oversight. Before, any 'retryable' error would hit: error: thread 2920 panic: access of union field 'success' while field 'failure_retryable' is active Now, it will be reported/handled properly: C:\Users\Ryan\Programming\Zig\zig\test\standalone\windows_resources\res\zig.rc:1:1: error: FileNotFound
2023-09-22Merge pull request #17069 from squeek502/resinatorAndrew Kelley
Add a `.rc` -> `.res` compiler to the Zig compiler
2023-09-21classifyFileExt: Use case-insensitive matching for .rc and .resRyan Liptak
2023-09-19clang: -fno-sanitize=function workaroundAndrew Kelley
It is very common, and well-defined, for a pointer on one side of a C ABI to have a different but compatible element type. Examples include: - `char*` vs `uint8_t*` on a system with 8-bit bytes - `const char*` vs `char*` - `char*` vs `unsigned char*` Without this flag, Clang would invoke UBSAN when such an extern function was called. Might be nice to file an upstream issue and find out if there is a more precise way to disable the problematic check. `-fsanitize-cfi-icall-generalize-pointers` looks promising according to the documentation, but empirically it does not work.
2023-09-19libcxx: update to LLVM 17Andrew Kelley
release/17.x branch, commit 8f4dd44097c9ae25dd203d5ac87f3b48f854bba8 This adds the flag `-D_LIBCPP_PSTL_CPU_BACKEND_SERIAL`. A future enhancement could possibly pass something different if there is a compelling parallel implementation. That libdispatch one might be worth looking into.
2023-09-17Fix rc preprocessing when using the MinGW includes and targeting the GNU abiRyan Liptak
Also update the standalone test so that this failure would have been detected on any host system.
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-17Only populate rc_include_dirs if there are .rc files in the compilationRyan Liptak
2023-09-17Add the ATLMFC include directory to the libc include dir listRyan Liptak
https://learn.microsoft.com/en-us/cpp/mfc/mfc-and-atl Note that this include directory gets added to %INCLUDE% by vcvarsall.bat, and is especially crucial when working with resource files (many .rc files within the https://github.com/microsoft/Windows-classic-samples/ set reference files from the ATLMFC include directory).
2023-09-17Add a .rc -> .res compiler to the Zig compilerRyan Liptak
2023-09-15ErrorBundle: rename addBundle to addBundleAsNotes, add addBundleAsRootsRyan Liptak
2023-09-14Add -includes option to zig libcRyan Liptak
Prints the detected libc include paths for the target and exits
2023-09-04Compilation: support --verbose_llvm_cpu_featuresMichael Dusan
2023-08-31Merge pull request #17020 from ziglang/macho-versionsJakub Konka
macho: big-ish refactor and report errors to the user using Zig's API
2023-08-29macho: add simple error reporting for misc errorsJakub Konka
2023-08-28Sema: revert reference trace changes that are no longer neededJacob Young
2023-08-21frontend: directly pass resolved frameworks container to the linkerJakub Konka
We can infer the framework name from the included resolved framework path. Fix hash implementation, and bump linker hash value from 9 to 10.
2023-08-20frontend: move framework path resolution from the linker to frontendJakub Konka
2023-08-16comp: make --verbose-cc actually thread-safeJakub Konka
2023-08-10Merge pull request #16747 from jacobly0/llvm-wo-libllvmAndrew Kelley
llvm: enable the backend even when not linked to llvm
2023-08-09change uses of std.builtin.Mode to OptimizeMode (#16745)Zachary Raineri
std.builtin.Mode is deprecated.
2023-08-09llvm: enable even without libllvm linkedJacob Young
2023-08-03Compilation: detect sysroot from libc installationAndrew Kelley
2023-08-03darwin: pass -iframework to clang for system frameworksAndrew Kelley
2023-08-03Compilation: fix incorrect non-optional assumptionAndrew Kelley
2023-08-03zig libc: restore functionality on macOSAndrew Kelley
Regressed in 2006add8496c47804ee3b6c562f420871cb4ea0a. References to native_darwin_sdk are no longer kept in the frontend. Instead the darwin SDK is detected as part of NativePaths and as part of LibCInstallation.
2023-08-03std.zig.system.NativePaths: simplify and integrate with Darwin SDKAndrew Kelley
2023-08-03frontend: make SystemLib.path optionalAndrew Kelley
This can be null in two cases right now: 1. Windows DLLs that zig ships such as advapi32. 2. extern "foo" fn declarations where we find out about libraries too late TODO: make this non-optional and resolve those two cases somehow.
2023-08-03frontend: fix linking to Windows DLLs as system libsAndrew Kelley
2023-08-03compiler: resolve library paths in the frontendAndrew Kelley
search_strategy is no longer passed to Compilation at all; instead it is used in the CLI code only. When using Zig CLI mode, `-l` no longer has the ability to link statically; use positional arguments for this. The CLI has a small abstraction around library resolution handling which is used to remove some code duplication regarding static libraries, as well as handle the difference between zig cc CLI mode and zig CLI mode. Thanks to this, system libraries are now included in the cache hash, and thus changes to them will correctly cause cache misses. In the future, lib_dirs should no longer be passed to Compilation at all, because it is a frontend-only concept. Previously, -search_paths_first and -search_dylibs_first were Darwin-only arguments; they now work the same for all targets. Same thing with --sysroot. Improved the error reporting for failure to find a system library. An example error now looks like this: ``` $ zig build-exe test.zig -lfoo -L. -L/a -target x86_64-macos --sysroot /home/andy/local error: unable to find Dynamic system library 'foo' using strategy 'no_fallback'. search paths: ./libfoo.tbd ./libfoo.dylib ./libfoo.so /home/andy/local/a/libfoo.tbd /home/andy/local/a/libfoo.dylib /home/andy/local/a/libfoo.so /a/libfoo.tbd /a/libfoo.dylib /a/libfoo.so ``` closes #14963
2023-07-26compilation: change compiler_rt to inherit `strip` and `want_unwind_tables` ↵kcbanner
from the parent compilation
2023-07-26Add --verbose-generic-instances to provide visibility on the number of ↵kcbanner
generic function instantiations
2023-07-24CLI: delete dead option -femit-analysisAndrew Kelley
This used to do something with the old autodocs system. Now it does nothing.
2023-07-23test: test for issues starting codegen on many targetsJacob Young
Specifically this is to make sure llvm data layout generation doesn't regress. The no emit bin is to allow testing targets that can't currently be linked. The commented out targets are ones that fail in the linker anyway when no emit bin is passed.
2023-07-23Compilation: fix autodocs CLIAndrew Kelley
6e4fff6ba62ae3e61a948c98fa8fea7e35732cc0 regressed the direct CLI interface of -femit-docs. This commit fixes it and also hooks up to the progress bar.
2023-07-22move installation logic to the build script where it belongsAndrew Kelley
* build.zig: introduce `-Dflat` option which makes the installation match what we want to ship for our download tarballs. This allows deleting a bunch of shell script logic from the CI. - for example it puts the executable directly in prefix/zig rather than prefix/bin/zig and it additionally includes prefix/LICENSE. * build.zig: by default also install std lib documentation to doc/std/ - this can be disabled by `-Dno-autodocs` similar to how there is already `-Dno-langref`. * build.zig: add `std-docs` and `langref` steps which build and install the std lib autodocs and langref to prefix/doc/std and prefix/doc/langref.html, respectively. * std.Build: implement proper handling of `-femit-docs` using the LazyPath system. This is a breaking change. - this is a partial implementation of #16351 * frontend: fixed the handling of Autodocs with regards to caching and putting the artifacts in the proper location to integrate with the build system. - closes #15864 * CI: delete the logic for autodocs since it is now handled by build.zig and is enabled by default. - in the future we should strive to have nearly all the CI shell script logic deleted in favor of `zig build` commands. * CI: pass `-DZIG_NO_LIB=ON`/`-Dno-lib` except for the one command where we want to actually generate the langref and autodocs. Generating the langref takes 14 minutes right now (why?!) so we don't want to do that more times than necessary. * Autodoc: fixed use of a global variable. It works fine as a local variable instead. - note that in the future we will want to make Autodoc run simultaneously using the job system, but for now the principle of YAGNI dictates that we don't have an init()/deinit() API and instead simply call the function that does the things. * Autodoc: only do it when there are no compile errors