aboutsummaryrefslogtreecommitdiff
path: root/src/Compilation
AgeCommit message (Collapse)Author
2025-06-19Target: pass and use locals by pointer instead of by valueJacob Young
This struct is larger than 256 bytes and code that copies it consistently shows up in profiles of the compiler.
2025-06-06x86_64: add support for pie executablesJacob Young
2025-06-06Compilation.Config: prefer_llvm depends on pieAndrew Kelley
2025-06-06Compilation.Config: eliminate the only variable from this functionAndrew Kelley
2025-06-06Compilation.Config: "can_use_llvm" -> "prefer_llvm"Andrew Kelley
2025-06-06Compilation: enable the x86_64 backend by default for debug buildsJacob Young
Closes #22257
2025-06-05std.Target: Introduce Cpu convenience functions for feature tests.Alex Rønne Petersen
Before: * std.Target.arm.featureSetHas(target.cpu.features, .has_v7) * std.Target.x86.featureSetHasAny(target.cpu.features, .{ .sse, .avx, .cmov }) * std.Target.wasm.featureSetHasAll(target.cpu.features, .{ .atomics, .bulk_memory }) After: * target.cpu.has(.arm, .has_v7) * target.cpu.hasAny(.x86, &.{ .sse, .avx, .cmov }) * target.cpu.hasAll(.wasm, &.{ .atomics, .bulk_memory })
2025-06-04compiler: Always dynamically link executables for Fuchsia.Alex Rønne Petersen
Fuchsia only supports PIE executables, specifically ET_DYN. https://fuchsia.dev/fuchsia-src/concepts/process/program_loading
2025-06-04compiler: Rework PIE option logic.Alex Rønne Petersen
To my knowledge, the only platforms that actually *require* PIE are Fuchsia and Android, and the latter *only* when building a dynamically-linked executable. OpenBSD and macOS both strongly encourage using PIE by default, but it isn't technically required. So for the latter platforms, we enable it by default but don't enforce it. Also, importantly, if we're building an object file or a static library, and the user hasn't explicitly told us whether to build PIE or non-PIE code (and the target doesn't require PIE), we should *not* default to PIE. Doing so produces code that cannot be linked into non-PIE output. In other words, building an object file or a static library as PIE is an optimization only to be done when the user knows that it'll end up in a PIE executable in the end. Closes #21837.
2025-05-17compiler: Link libc by default when targeting NetBSD.Alex Rønne Petersen
We don't yet have a direct syscall layer in std.os.netbsd.
2025-05-17Compilation.Config: Default to dynamic linking with NetBSD libc.Alex Rønne Petersen
2025-05-12Merge pull request #23835 from alexrp/freebsd-libcAlex Rønne Petersen
Support dynamically-linked FreeBSD libc when cross-compiling
2025-05-11compiler: Link libc by default when targeting FreeBSD.Alex Rønne Petersen
We don't yet have a direct syscall layer in std.os.freebsd.
2025-05-11Compilation.Config: Default to dynamic linking with FreeBSD libc.Alex Rønne Petersen
2025-05-10std.Target: Remove ObjectFormat.nvptx (and associated linker code).Alex Rønne Petersen
Textual PTX is just assembly language like any other. And if we do ever add support for emitting PTX object files after reverse engineering the bytecode format, we'd be emitting ELF files like the CUDA toolchain. So there's really no need for a special ObjectFormat tag here, nor linker code that treats it as a distinct format.
2025-05-03compiler: Link libunwind when linking glibc statically.Alex Rønne Petersen
glibc's libc.a depends on the functions provided by libunwind.
2025-05-03compiler: Allow linking native glibc statically.Alex Rønne Petersen
This is generally ill-advised, but can be useful in some niche situations where the caveats don't apply. It might also be useful when providing a libc.txt that points to Eyra.
2025-05-03compiler: Rename misleading libcNeedsLibUnwind() function.Alex Rønne Petersen
It's about libc++, not libc.
2025-04-26compiler: Allow configuring UBSan mode at the module level.Alex Rønne Petersen
* Accept -fsanitize-c=trap|full in addition to the existing form. * Accept -f(no-)sanitize-trap=undefined in zig cc. * Change type of std.Build.Module.sanitize_c to std.zig.SanitizeC. * Add some missing Compilation.Config fields to the cache. Closes #23216.
2025-04-09Merge pull request #23501 from imreallybadatnames/masterimreallybadatnames™️
Step.Compile: use LtoMode enum for lto option
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