aboutsummaryrefslogtreecommitdiff
path: root/src/Compilation.zig
AgeCommit message (Collapse)Author
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-09Merge pull request #18875 from ziglang/macho-zo-dwarfJakub Konka
macho: emit DWARF for ZigObject relocatable
2024-02-09Merge pull request #18712 from Vexu/std.optionsAndrew Kelley
std: make options a struct instance instead of a namespace
2024-02-08builtin: enable panic handler on self-hosted machoJakub Konka
comp: toggle compiler-rt and zig-libc caps for macho
2024-02-06Merge pull request #18814 from mlugg/incremental-dependenciesMatthew Lugg
Begin re-implementing incremental compilation
2024-02-05compiler: rename value.zig to Value.zigAndrew Kelley
This commit only does the file rename to be friendlier to version control conflicts.
2024-02-04compiler: lock incremental dependency tracking behind --debug-incrementalmlugg
This logic (currently) has a non-trivial cost (particularly in terms of peak RSS) for tracking dependencies. Until incremental compilation is in use in the wild, it doesn't make sense for users to pay that cost.
2024-02-04Zcu: refactor Decl.analysis fieldmlugg
* Functions failing codegen now set this failure on the function analysis state. Decl analysis `codegen_failure` is reserved for failures generating constant values. * `liveness_failure` is consolidated into `codegen_failure`, as we do not need to distinguish these, and Liveness.Verify is just a debugging feature anyway. * `sema_failure_retryable` and `codegen_failure_retryable` are removed. Instead, retryable failures are recorded in the new `Zcu.retryable_failures` list. On an incremental update, this list is flushed, and all elements are marked as outdated so that we re-attempt analysis and code generation. Also remove the `generation` fields from `Zcu` and `Decl` as these are not needed by our new strategy for incremental updates.
2024-02-04Zcu: incremental compilation improvementsmlugg
* Mark root Decls for re-analysis separately * Check for re-analysis of root Decls * Remove `outdated` entry when analyzing fn body * Remove legacy `outdated` field from Decl analysis state
2024-02-04Zcu: more dependency tracking logicmlugg
* Invalidate `decl_val` dependencies * Recursively mark and un-mark all dependencies correctly * Queue analysis of outdated dependers in `Compilation.performAllTheWork` Introduces logic to invalidate `decl_val` dependencies after `Zcu.semaDecl` completes. Also, recursively un-mark dependencies as PO where needed. With this, all dependency invalidation logic is in place. The next step is analyzing outdated dependencies and triggering appropriate re-analysis.
2024-02-04compiler: re-introduce dependencies for incremental compilationmlugg
Sema now tracks dependencies appropriately. Early logic in Zcu for resolving outdated decls/functions is in place. The setup used does not support `usingnamespace`; compilations using this construct are not yet supported by this incremental compilation model.
2024-02-02Compilation: delete clang diag files afterwardsAndrew Kelley
After parsing diagnostics files from clang we don't have any more use for those tmp files. Delete them to reduce clutter and disk usage.
2024-02-02cli+build: handle -ObjC flag and route it to MachO linkerJakub Konka
2024-02-01remove std.io.ModeVeikka Tuominen
2024-01-26Merge pull request #18654 from mlugg/incremental-the-secondAndrew Kelley
InternPool: introduce TrackedInst to prepare for incremental compilation
2024-01-25Compilation: preserve "builtin" as the first dependencyJacob Young
Previously, sorting dependencies would reorder the builtin dependency and cause `Package.Module.getBuiltinDependency` to stop working.
2024-01-24macho: parse dependent dylibsJakub Konka
2024-01-23InternPool: introduce TrackedInstmlugg
It is problematic for the cached `InternPool` state to directly reference ZIR instruction indices, as these are not stable across incremental updates. The existing ZIR mapping logic attempts to handle this by iterating the existing Decl graph for a file after `AstGen` and update ZIR indices on `Decl`s, struct types, etc. However, this is unreliable due to generic instantiations, and relies on specialized logic for everything which may refer to a ZIR instruction (e.g. a struct's owner decl). I therefore determined that a prerequisite change for incremental compilation would be to rework how we store these indices. This commit introduces a `TrackedInst` type which provides a stable index (`TrackedInst.Index`) for a single ZIR instruction in the compilation. The `InternPool` now stores these values in place of ZIR instruction indices. This makes the ZIR mapping logic relatively trivial: after `AstGen` completes, we simply iterate all `TrackedInst` values and update those indices which have changed. In future, if the corresponding ZIR instruction has been removed, we must also invalidate any dependencies on this instruction to trigger any required re-analysis, however the dependency system does not yet exist.
2024-01-22Fix wrong if condition for windows (#18637)ndbn
Fixes #18594
2024-01-20Merge pull request #18596 from ypsvlq/mingwAndrew Kelley
mingw-w64: add missing CRT sources
2024-01-20Merge pull request #18622 from ziglang/zig-mod-edge-caseAndrew Kelley
build system: better handle modules that do not have a zig root source file
2024-01-19zig cc: expose clang precompiled C header supportXavier Bouchoux
see https://releases.llvm.org/17.0.1/tools/clang/docs/UsersManual.html#generating-a-pch-file syntax examples: `zig cc -x c-header test.h -o test.pch` `zig cc -include-pch test.pch main.c` `zig c++ -x c++-header test.h -o test.pch` `zig c++ -include-pch test.pch main.cpp`
2024-01-19Compilation: avoid caching root source file twiceAndrew Kelley
The deleted lines here are redundant because they happen first thing inside the function call below. Additionally, skip hashing the root source file if it is an empty string. I explored making this field along with `root` optional but found this to be less messy actually.
2024-01-20mingw: update build logicElaine Gibson
2024-01-14compiler: move each_lib_rpath to frontendJan200101
Co-authored-by: Andrew Kelley <andrew@ziglang.org>
2024-01-10Compilation: fix tsan error reportingAndrew Kelley
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-08compilation: fix bad path in error messageAndrew Kelley
2024-01-08Compilation: only add __MSVCRT_VERSION__ for -lcAndrew Kelley
prevents it from being defined twice when building mingw-w64 libs.
2024-01-08Compilation: add definition to prefer ucrt for windows C/C++ filesAndrew Kelley
This makes C/C++ files when targeting mingw-w64 choose to depend on ucrt for stdio.
2024-01-08mingw: update from msvcrt to ucrtAndrew Kelley
2024-01-06Compilation: pass code model in buildOutputFromZigTristan Ross
2024-01-03compiler: fix build runner not added to cache hashAndrew Kelley
Closes #18438
2024-01-01link: accept the update arena in flushAndrew Kelley
This branch introduced an arena allocator for temporary allocations in Compilation.update. Almost every implementation of flush() inside the linker code was already creating a local arena that had the lifetime of the function call. This commit passes the update arena so that all those local ones can be deleted, resulting in slightly more efficient memory usage with every compilation update. While at it, this commit also removes the Compilation parameter from the linker flush function API since a reference to the Compilation is now already stored in `link.File`.
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-01Compilation: rename before flush during whole cache modeAndrew Kelley
The linker needs to know the file system path of output in the flush function because file paths inside the build artifacts reference each other. Fixes a regression introduced in this branch.
2024-01-01Compilation: fix cache hash of incremental buildsAndrew Kelley
Without this commit, unrelated test builds using incremental cache mode (self-hosted, no lld) would end up using the same cache namespace, which is undesireable since concurrent builds will clobber each other's work. This happened because of passing the root module to addModuleToCacheHash. In the case of a test build, the root module actually does not connect to the rest of the import table. Instead, the main module needs to be passed, which has "root" in its import table. The other call to addModuleTableToCacheHash which is in addNonIncrementalStuffToCacheManifest already correctly passes the main module. In the future, I think this problem can be fully addressed by obtaining an advisory lock on the output binary file. However, even in that case, it is still valuable to make different compilations use different cache namespaces lest unrelated compilations suffer from pointless thrashing rather than being independently edited.
2024-01-01Compilation: make create() take an arena allocatorAndrew Kelley
Instead of making its own inside create. 10 out of 10 calls to create() had already an arena in scope, so this commit means that 10 instances of Compilation now reuse an existing arena with the same lifetime rather than creating a redundant one. In other words, this very slightly optimizes initialization of the frontend in terms of memory allocation.
2024-01-01restore -fno-emit-bin -femit-llvm-ir functionalityAndrew Kelley
Now, link.File will always be null when -fno-emit-bin is specified, and in the case that LLVM artifacts are still required, the Zcu instance has an LlvmObject.
2024-01-01Compilation: don't add importlib jobs when outputting C codeAndrew Kelley
Fixes "building import libs not included in core functionality" when bootstrapping on Windows.
2024-01-01move misc_errors from linker to CompilationAndrew Kelley
So that they can be referenced by getAllErrorsAlloc(). Fixes missing compile errors.
2024-01-01Compilation: inline the flush functionAndrew Kelley
There is only one call to this function and this made it easier to troubleshoot the logic.
2024-01-01Compilation: fix whole mode cache hashAndrew Kelley
before this commit it was trying to hash based on resolved bin_file settings, but bin_file was always null since cache mode is always whole when this function is called! hash based on the lf_open_opts instead.
2024-01-01Compilation: consolidate module hashing codeAndrew Kelley
2024-01-01move eh_frame_hdr from link.File to CompilationAndrew Kelley
since it's accessed by Compilation. fixes an invalid check of bin_file==null
2024-01-01move force_undefined_symbols into CompilationAndrew Kelley
This field is needed by Compilation regardless of whether a link file is instantiated. Fixes an invalid check for bin_file=null.
2024-01-01Compilation: several branch regression fixesAndrew Kelley
* move wasi_emulated_libs into Compilation - It needs to be accessed from Compilation, which needs to potentially build those artifacts. * Compilation: improve error reporting for two cases - the setMiscFailure mechanism is handy - let's use it! * fix one instance of incorrectly checking for emit_bin via `comp.bin_file != null`. There are more instances of this that need to be fixed in a future commit. * fix renameTmpIntoCache not handling the case where it needs to make the "o" directory in the zig-cache directory. - while I'm at it, simplify the logic for handling the fact that Windows returns error.AccessDenied rather than error.PathAlreadyExists for failure to rename a directory over another one. * fix missing cache hash additions - there are still more to add in a future commit - addNonIncrementalStuffToCacheManifest is called when bin_file is always null, and then it incorrectly checks if bin_file is non-null and only then adds a bunch of stuff to the cache hash. It needs to instead add to the cache hash based on lf_open_opts.
2024-01-01compiler: push entry symbol name resolution into the linkerAndrew Kelley
This is necessary because on COFF, the entry symbol name is not known until the linker has looked at the set of global symbol names to determine which of the four possible main entry points is present.
2024-01-01frontend: remove deprecated field from CompilationAndrew Kelley