aboutsummaryrefslogtreecommitdiff
path: root/src/Compilation
AgeCommit message (Collapse)Author
2025-02-25Compilation: correct when to include ubsanDavid Rubin
2025-01-25Compilation: Disable LTO by default.Alex Rønne Petersen
LLD has too many LTO bugs, and we're dropping the LLD dependency soon anyway.
2025-01-23Package.Module: Make create() fall back on options.global.root_optimize_mode.Alex Rønne Petersen
As is done for root_strip and root_error_tracing.
2025-01-23compiler: Fix computation of Compilation.Config.any_unwind_tables.Alex Rønne Petersen
This moves the default value logic to Package.Module.create() instead and makes it so that Compilation.Config.any_unwind_tables is computed similarly to any_sanitize_thread, any_fuzz, etc. It turns out that for any_unwind_tables, we only actually care if unwind tables are enabled at all, not at what level.
2025-01-05Added support for thin ltoTravis Lange
2024-12-11compiler: Improve the handling of unwind table levels.Alex Rønne Petersen
The goal here is to support both levels of unwind tables (sync and async) in zig cc and zig build. Previously, the LLVM backend always used async tables while zig cc was partially influenced by whatever was Clang's default.
2024-11-19Compilation: Re-enable LTO for RISC-V.Alex Rønne Petersen
2024-11-18Compilation: Disable LTO for all ILP32-on-LP64 ABIs.Alex Rønne Petersen
Extension of 3a6a8b8aa540413d099a6f41a0d8f882f22acb45 to all similar ABIs. The LLD issue affects them all.
2024-11-17Compilation: Disable LTO for mips n32.Alex Rønne Petersen
See: https://github.com/llvm/llvm-project/pull/116537
2024-11-16Use options debug format if it is provided (#21995)Benjamin
Co-authored-by: Alex Rønne Petersen <alex@alexrp.com>
2024-09-23std.Target: Remove Cpu.Arch.dxil and ObjectFormat.dxcontainer.Alex Rønne Petersen
See: https://devblogs.microsoft.com/directx/directx-adopting-spir-v Since we never hooked up the (experimental) DirectX LLVM backend, we've never actually supported targeting DXIL in Zig. With Microsoft moving away from DXIL, that seems very unlikely to change.
2024-08-11std.Target: Add goff and xcoff to ObjectFormat.Alex Rønne Petersen
Also improve the docs a bit, and handle driverkit and dxil in default().
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-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-08Compilation: put supported codegen backends on a separate threadJacob Young
(There are no supported backends.)
2024-06-19add error message for `-fno-llvm` `-flld`David Rubin
We plan to remove all dependency on LLD either way, so this will not be a supported usecase.
2024-03-11std.builtin: make link mode fields lowercaseTristan Ross
2024-02-01remove std.io.ModeVeikka Tuominen
2024-01-01compiler: Compilation.Config: trivial refactorAndrew Kelley
2024-01-01frontend: make dll_export_fns=false on non-windowsAndrew Kelley
Fixes a regression introduced in this branch.
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: avoid spurious error when no zcuAndrew Kelley
use_llvm=false does not always mean there needs to be a zig compiler backend available. In particular, when there is no zig compilation unit, use_llvm=false and yet no zig backend will be used to produce code.
2024-01-01frontend: fix "any" default resolution ambiguityAndrew Kelley
In Compilation.create, update the resolved config to account for the default resolution of the root module. This makes it so that, for example, reading comp.config.any_non_single_threaded is valid in order to determine whether any module has single_threaded=false.
2024-01-01fix MachO linkingAndrew Kelley
* fix relationship between createEmpty/open (similar logic as 607111aa758002bc51914b7dc800b23927c931b8) * still resolve the start symbol when linking libc because when zig is the linker it still needs to know the entry symbol. * make use_llvm=false when there is no zig compilation unit.
2024-01-01fix logic for default entry pointAndrew Kelley
when linking libc, the entry point is within libc. when producing C code, the entry point is decided when compiling the C code and does not need to be known up front. fixes a false positive "error: unknown target entry point" when using -ofmt=c.
2024-01-01Compilation.Config.resolve: explicit error setAndrew Kelley
Some logic has comptime-known conditions, causing the inferred error set to be different on different compiler build configurations.
2024-01-01resolve error tracing logic at module creation timeAndrew Kelley
rather than checking multiple conditions in Sema
2024-01-01move dll_export_fns and rdynamic to Compilation.ConfigAndrew Kelley
2024-01-01libcxx: update to new Compilation APIAndrew Kelley
2024-01-01update bin_file.options references in SemaAndrew Kelley
mainly pertaining to error return tracing
2024-01-01compiler: miscellaneous branch progressAndrew Kelley
implement builtin.zig file population for all modules rather than assuming there is only one global builtin.zig module. move some fields from link.File to Compilation move some fields from Module to Compilation compute debug_format in global Compilation config resolution wire up C compilation to the concept of owner modules make whole cache mode call link.File.createEmpty() instead of link.File.open()
2024-01-01linkers: update references to "options" fieldAndrew Kelley
2024-01-01compiler: update references to single_threadedAndrew Kelley
2024-01-01frontend: fix stack protector option logicAndrew Kelley
Commit 97e23896a9168132b6d36ca22ae1af10dd53d80d regressed this behavior because it made target_util.supportsStackProtector *correctly* notice which zig backend is being used to generate code, while the logic calling that function *incorrectly assumed* that .zig code is being compiled, when in reality it might be only C code being compiled. This commit adjusts the option resolution logic for stack protector so that it takes into account the zig backend only if there is a zig compilation unit. A separate piece of logic checks whether clang supports stack protector for a given target. closes #18009 closes #18114 closes #18254
2024-01-01move a large chunk of linker logic away from "options"Andrew Kelley
These options are only supposed to be provided to the initialization functions, resolved, and then computed values stored in the appropriate place (base struct or the object-format-specific structs). Many more to go...
2024-01-01WIP: move many global settings to become per-ModuleAndrew Kelley
Much of the logic from Compilation.create() is extracted into Compilation.Config.resolve() which accepts many optional settings and produces concrete settings. This separate step is needed by API users of Compilation so that they can pass the resolved global settings to the Module creation function, which itself needs to resolve per-Module settings. Since the target and other things are no longer global settings, I did not want them stored in link.File (in the `options` field). That options field was already a kludge; those options should be resolved into concrete settings. This commit also starts to work on that, deleting link.Options, moving the fields into Compilation and ObjectFormat-specific structs instead. Some fields were ephemeral and should not have been stored at all, such as symbol_size_hint. The link.File object of Compilation is now a `?*link.File` and `null` when -fno-emit-bin is passed. It is now arena-allocated along with Compilation itself, avoiding some messy cleanup code that was there before. On the command line, it is now possible to configure the standard library itself by using `--mod std` just like any other module. This meant that the CLI needed to create the standard library module rather than having Compilation create it. There are a lot of changes in this commit and it's still not done. I didn't realize how quickly this changeset was going to balloon out of control, and there are still many lines that need to be changed before it even compiles successfully. * introduce std.Build.Cache.HashHelper.oneShot * add error_tracing to std.Build.Module * extract build.zig file generation into src/Builtin.zig * each CSourceFile and RcSourceFile now has a Module owner, which determines some of the C compiler flags.