aboutsummaryrefslogtreecommitdiff
path: root/src/Compilation.zig
AgeCommit message (Collapse)Author
2024-07-29compiler: Enable -Werror=date-time for C/C++ code in release builds.Alex Rønne Petersen
We advertise reproducible builds for release modes, so let's help users achieve that in C/C++ code. Users can still override this manually if they really want.
2024-07-28link: Accept `-Brepro` linker option and pass it to LLD.Alex Rønne Petersen
Enable it by default when building Zig code in release modes. Contributes to #9432.
2024-07-28Merge pull request #20807 from Rexicon226/riscvJakub Konka
riscv: more backend progress
2024-07-26comp: enable compilation of zig_libcDavid Rubin
2024-07-26frontend: add missed cache hash on --debug-rtAndrew Kelley
Makes adding --debug-rt correctly invalidate the cache for compiler_rt and libfuzzer.
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-24add sub-compilation cache inputs to parents in whole modeAndrew Kelley
closes #20782
2024-07-24Compilation: build compiler_rt and fuzzer in parallelAndrew Kelley
With the rest of the pipeline. Tracked by #9188
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-23LLVM: more fine-grained sancov emit optionsAndrew Kelley
Exposes sanitizer coverage flags to the target machine emit function. Makes it easier to change sancov options without rebuilding the C++ files. This also enables PCTable = true for sancov which is needed by AFL, and adds the corresponding Clang flag.
2024-07-23Merge pull request #20725 from ziglang/fuzzAndrew Kelley
initial support for integrated fuzzing
2024-07-22Compilation: fix regression in addCCArgsAndrew Kelley
`-fno-sanitize=function` must come after `-fsanitize=undefined` or it has no effect.
2024-07-22initial support for integrated fuzzingAndrew Kelley
* Add the `-ffuzz` and `-fno-fuzz` CLI arguments. * Detect fuzz testing flags from zig cc. * Set the correct clang flags when fuzz testing is requested. It can be combined with TSAN and UBSAN. * Compilation: build fuzzer library when needed which is currently an empty zig file. * Add optforfuzzing to every function in the llvm backend for modules that have requested fuzzing. * In ZigLLVMTargetMachineEmitToFile, add the optimization passes for sanitizer coverage. * std.mem.eql uses a naive implementation optimized for fuzzing when builtin.fuzz is true. Tracked by #20702
2024-07-22macho: redo input file parsing in prep for multithreadingJakub Konka
2024-07-20Merge pull request #20688 from ziglang/incr-testAndrew Kelley
introduce a new tool for testing incremental compilation
2024-07-20dev: fix llvm backend checksJacob Young
2024-07-20add std.fmt.hexAndrew Kelley
converts an unsigned integer into an array
2024-07-19dev: introduce dev environments that enable compiler feature setsJacob Young
2024-07-15update some Module references to Zcu insteadAndrew Kelley
I ended up reverting my real change, so here's a consolation prize instead.
2024-07-15frontend: move updateZirRefs to be single-threadedAndrew Kelley
for simplicity's sake. This makes it O(M) instead of O(N*M) where N is tracked insts and M is number of changed source files.
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-14Merge pull request #20593 from jacobly0/more-racesAndrew Kelley
InternPool: fix more races
2024-07-13frontend: report correct paths for C objectsAndrew Kelley
oops, the src_path field of CObject is not relative to the module owner's root directory.
2024-07-13Compilation: restore `saveState`Jacob Young
2024-07-13Compilation: introduce work stages for better work distributionJacob Young
2024-07-13InternPool: add and use a mutate mutex for each listJacob Young
This allows the mutate mutex to only be locked during actual grows, which are rare. For the lists that didn't previously have a mutex, this change has little effect since grows are rare and there is zero contention on a mutex that is only ever locked by one thread. This change allows `extra` to be mutated without racing with a grow.
2024-07-12Compilation: fix rebase conflictAndrew Kelley
2024-07-12frontend: add file system inputs for incremental cache modeAndrew Kelley
These are also used for whole cache mode in the case that any compile errors are emitted.
2024-07-12integrate Compile steps with file watchingAndrew Kelley
Updates the build runner to unconditionally require a zig lib directory parameter. This parameter is needed in order to correctly understand file system inputs from zig compiler subprocesses, since they will refer to "the zig lib directory", and the build runner needs to place file system watches on directories in there. The build runner's fanotify file watching implementation now accounts for when two or more Cache.Path instances compare unequal but ultimately refer to the same directory in the file system. Breaking change: std.Build no longer has a zig_lib_dir field. Instead, there is the Graph zig_lib_directory field, and individual Compile steps can still have their zig lib directories overridden. I think this is unlikely to break anyone's build in practice. The compiler now sends a "file_system_inputs" message to the build runner which shares the full set of files that were added to the cache system with the build system, so that the build runner can watch properly and redo the Compile step. This is implemented for whole cache mode but not yet for incremental cache mode.
2024-07-10Compilation: fix leakJacob Young
2024-07-10InternPool: make `global_error_set` thread-safeJacob Young
2024-07-10InternPool: make `tracked_insts` thread-safeJacob Young
2024-07-10InternPool: make `files` more thread-safeJacob Young
2024-07-10InternPool: add `FileIndex` to `*File` mappingJacob Young
2024-07-08Compilation: put supported codegen backends on a separate threadJacob Young
(There are no supported backends.)
2024-07-07InternPool: implement and use thread-safe list for extra and limbsJacob Young
2024-07-07InternPool: implement and use thread-safe list for itemsJacob Young
2024-07-07InternPool: implement and use thread-safe list for stringsJacob Young
2024-07-07InternPool: implement thread-safe hash mapJacob Young
2024-07-07Zcu: pass `PerThread` to intern pool string functionsJacob Young
2024-07-07Zcu: introduce `PerThread` and pass to all the functionsJacob Young
2024-07-04frontend: TrackedInst stores FileIndex instead of path digestAndrew Kelley
The purpose of using path digest was to reference a file in a serializable manner. Now that there is a stable index associated with files, it is a superior way to accomplish that goal, since removes one layer of indirection, and makes TrackedInst 8 bytes instead of 20. The saved Zig Compiler State file for "hello world" goes from 1.3M to 1.2M with this change.
2024-07-04Zcu: extract permanent state from FileAndrew Kelley
Primarily, this commit removes 2 fields from File, relying on the data being stored in the `files` field, with the key as the path digest, and the value as the struct decl corresponding to the File. This table is serialized into the compiler state that survives between incremental updates. Meanwhile, the File struct remains ephemeral data that can be reconstructed the first time it is needed by the compiler process, as well as operated on by independent worker threads. A key outcome of this commit is that there is now a stable index that can be used to refer to a File. This will be needed when serializing error messages to survive incremental compilation updates.
2024-07-04Compilation: don't give len=0 bufs to pwritevAndrew Kelley
The OS returns EFAULT for undefined pointers, even when len=0.
2024-07-04Merge pull request #20494 from mlugg/the-great-decl-splitAndrew Kelley
refactors ad infinitum
2024-07-04Compilation: rename tsan_static_lib to tsan_libJakub Konka
2024-07-04cbe: fix for export changesJacob Young
2024-07-04compiler: rework type resolution, fully resolve all typesmlugg
I'm so sorry. This commit was just meant to be making all types fully resolve by queueing resolution at the moment of their creation. Unfortunately, a lot of dominoes ended up falling. Here's what happened: * I added a work queue job to fully resolve a type. * I realised that from here we could eliminate `Sema.types_to_resolve` if we made function codegen a separate job. This is desirable for simplicity of both spec and implementation. * This led to a new AIR traversal to detect whether any required type is unresolved. If a type in the AIR failed to resolve, then we can't run codegen. * Because full type resolution now occurs by the work queue job, a bug was exposed whereby error messages for type resolution were associated with the wrong `Decl`, resulting in duplicate error messages when the type was also resolved "by" its owner `Decl` (which really *all* resolution should be done on). * A correct fix for this requires using a different `Sema` when performing type resolution: we need a `Sema` owned by the type. Also note that this fix is necessary for incremental compilation. * This means a whole bunch of functions no longer need to take `Sema`s. * First-order effects: `resolveTypeFields`, `resolveTypeLayout`, etc * Second-order effects: `Type.abiAlignmentAdvanced`, `Value.orderAgainstZeroAdvanced`, etc The end result of this is, in short, a more correct compiler and a simpler language specification. This regressed a few error notes in the test cases, but nothing that seems worth blocking this change. Oh, also, I ripped out the old code in `test/src/Cases.zig` which introduced a dependency on `Compilation`. This dependency was problematic at best, and this code has been unused for a while. When we re-enable incremental test cases, we must rewrite their executor to use the compiler server protocol.
2024-07-04compiler: type.zig -> Type.zigmlugg