aboutsummaryrefslogtreecommitdiff
path: root/src/target.zig
AgeCommit message (Collapse)Author
2023-09-21compiler: move struct types into InternPool properAndrew Kelley
Structs were previously using `SegmentedList` to be given indexes, but were not actually backed by the InternPool arrays. After this, the only remaining uses of `SegmentedList` in the compiler are `Module.Decl` and `Module.Namespace`. Once those last two are migrated to become backed by InternPool arrays as well, we can introduce state serialization via writing these arrays to disk all at once. Unfortunately there are a lot of source code locations that touch the struct type API, so this commit is still work-in-progress. Once I get it compiling and passing the test suite, I can provide some interesting data points such as how it affected the InternPool memory size and performance comparison against master branch. I also couldn't resist migrating over a bunch of alignment API over to use the log2 Alignment type rather than a mismash of u32 and u64 byte units with 0 meaning something implicitly different and special at every location. Turns out you can do all the math you need directly on the log2 representation of alignments.
2023-08-09change uses of std.builtin.Mode to OptimizeMode (#16745)Zachary Raineri
std.builtin.Mode is deprecated.
2023-08-03frontend: update is_libc_lib_name for mingw-w64 crt filesAndrew Kelley
2023-07-26target: emit unwind tables if the platform supports unwindingkcbanner
2023-07-20compilation: pass omit_frame_pointer through to builtin.zigkcbanner
Renamed dwarf_unwinding -> stack_iterator to better reflect that it's not just DWARF unwinding. Added a test for unwinding with a frame pointer.
2023-07-20debug: fix initialization of the optional fields on StackIteratorkcbanner
dwarf: documentation fixups target: enable unwind tables on macho
2023-06-26default to single-threaded for WebAssemblyLuuk de Gram
When targeting WebAssembly, we default to building a single-threaded build as threads are still experimental. The user however can enable a multi- threaded build by specifying '-fno-single-threaded'. It's a compile-error to enable this flag, but not also enable shared-memory.
2023-06-26Compilation: allow threads for Wasm when shared-memory is enabledLuuk de Gram
When the user enabled the linker-feature 'shared-memory' we do not force a singlethreaded build. The linker already verifies all other CPU features required for threads are enabled. This is true for both WASI and freestanding.
2023-06-17std: replace builtin.Version with SemanticVersionr00ster91
2023-06-10stage2: move function types to InternPoolAndrew Kelley
2023-06-10stage2: start the InternPool transitionAndrew Kelley
Instead of doing everything at once which is a hopelessly large task, this introduces a piecemeal transition that can be done in small increments at a time. This is a minimal changeset that keeps the compiler compiling. It only uses the InternPool for a small set of types. Behavior tests are not passing. Air.Inst.Ref and Zir.Inst.Ref are separated into different enums but compile-time verified to have the same fields in the same order. The large set of changes is mainly to deal with the fact that most Type and Value methods now require a Module to be passed in, so that the InternPool object can be accessed.
2023-04-21cbe: implement 128-bit atomics supportJacob Young
* Disable 128-bit atomics for x86_64 generic (currently also baseline) because they require heavy abi agreement to correctly lower. ** This is a breaking change ** * Enable 128-bit atomics for aarch64 in Sema since it just works.
2023-04-21Do not use -fPIC when compiling a UEFI applicationEric Rowley
2023-04-10glibc: allow linking against external libcrypt.Piotr Sikora
Support for the built-in libcrypt was removed in commit 6b7ddfba, but the -lcrypt flag remained ignored, preventing linking against external libcrypt. Fixes #5990. Signed-off-by: Piotr Sikora <piotr@aviatrix.com>
2023-04-09spirv: cannot build libcRobin Voetter
SPIR-V cannot build libc, ssp, compiler-rt, etc at the time of this commit, so prevent trying to build them.
2023-03-03Merge remote-tracking branch 'origin/master' into llvm16Andrew Kelley
2023-03-03sema: Place functions on AVR in flash addrspaceEckhart Köppen
- Use .flash as the default address space for functions on AVR - Return .flash as the address space for function pointers on AVR without explicit address space
2023-02-27Merge remote-tracking branch 'origin/master' into llvm16Andrew Kelley
2023-02-23CBE: support call attributesJacob Young
* Support always_tail and never_tail/never_inline with a comptime callee using clang * Support never_inline using gcc * Support never_inline using msvc Unfortunately, can't enable behavior tests because of the conditional support.
2023-01-26update CPU features to LLVM 16Andrew Kelley
2022-12-29powerpc does not have a red zoneAndrew Kelley
This will prevent unused argument warnings when compiling C objects targeting powerpc.
2022-12-06remove most conditional compilation based on stage1Andrew Kelley
There are still a few occurrences of "stage1" in the standard library and self-hosted compiler source, however, these instances need a bit more careful inspection to ensure no breakage.
2022-12-06Update wasi-libc to 8b7148f69ae241a2749b3defe4606da8143b72e0 (#13793)Frank Denis
2022-11-22C backend: implement vector reduce and overflow intrinsicsAndrew Kelley
2022-11-19LLVM: add valgrind integration for x86 and aarch64Andrew Kelley
This also modifies the inline assembly to be more optimizable - instead of doing explicit movs, we instead communicate to LLVM which registers we would like to, somehow, have the correct values. This is how the x86_64 code already worked and thus allows the code to be unified across the two architectures. As a bonus, I threw in x86 support.
2022-11-04all: rename i386 to x86Ali Chraghi
2022-10-26darwin: remove 10.15.7 as available libc from src/target.zigJakub Konka
2022-10-25darwin: bump max macOS version to 13.0Jakub Konka
2022-10-15addrSpaceCastIsValid nvptxGuillaume Wenzek
2022-10-15sanitize qualified name for nvptx backendGuillaume Wenzek
2022-10-15disable debug info for ptx<7.5Guillaume Wenzek
2022-10-12stage2: check address space cast validityRobin Voetter
2022-08-30Merge remote-tracking branch 'origin/master' into llvm15Andrew Kelley
2022-08-30avoid exposing supportsTailCall in the standard libraryAndrew Kelley
This is problematic because in practice it depends on whether the compiler backend supports it too, as evidenced by the TODO comment about LLVM not supporting some architectures that in fact do support tail calls. Instead this logic is organized strategically in src/target.zig, part of the internal compiler source code, and the behavior tests in question duplicate some logic for deciding whether to proceed with the test. The proper place to expose this flag is in `@import("builtin")` - the generated source file - so that third party compilers can advertise whether they support tail calls.
2022-08-29Merge remote-tracking branch 'origin/master' into llvm15Andrew Kelley
2022-08-19stage2: disable stack-protector on wasm, matching stage1Andrew Kelley
The CI gave me: unknown import: `env::__stack_chk_fail` has not been defined
2022-08-19stage2: implement stack protectorsAndrew Kelley
This is one of the final remaining TODOs for the LLVM backend.
2022-07-31update Target, CPU, OS, ABI, etc. to LLVM 15Andrew Kelley
2022-07-21Sema: improve compile error for bad function alignmentAndrew Kelley
* Integrate more declaratively with src/target.zig * Only trigger the check when a function body is found, do not trigger for function types.
2022-06-30stage2: object format affects whether LLVM can be usedAndrew Kelley
2022-06-27LLVM: fix invalid IR on `@returnAddress` of wasm/bpfAndrew Kelley
see #11946
2022-05-22Set macOS/iPhoneOS/tvOS/watchOS ABI to none (unspecified) by defaultJakub Konka
Prior to this change we would assume the ABI for Apple targets to be GNU which could result in subtle errors in LLVM emitting calls to non-existent system libc provided functions such as `_sincosf` which is a GNU extension and as such is not provided by macOS for example. This would result in linker errors where the linker would not be able to find the said symbol in `libSystem.tbd`. With this change, we now correctly identify macOS (and other Apple platforms) as having ABI `unknown` which translates to unspecified in LLVM under-the-hood: ``` // main.ll target triple = "aarch64-unknown-macos-unknown" ``` Note however that we never suffix the target OS with target version such as `macos11` or `macos12` which means we fail to instruct LLVM of potential optimisations provided by the OS such as the availability of function `___sincosf_stret`. I suggest we investigate that in a follow-up commit.
2022-05-13target: Rename sparcv9 -> sparc64Koakuma
Rename all references of sparcv9 to sparc64, to make Zig align more with other projects. Also, added new function to convert glibc arch name to Zig arch name, since it refers to the architecture as sparcv9. This is based on the suggestion by @kubkon in PR 11847. (https://github.com/ziglang/zig/pull/11487#pullrequestreview-963761757)
2022-05-04stage2: change x86_64 max int alignment from 8 to 16Andrew Kelley
For x86_64, LLVMABIAlignmentOfType(i128) reports 8. However I think 16 is a better number for two reasons: 1. Better machine code when loading into SIMD register. 2. The C ABI wants 16 for extern structs.
2022-05-04stage2: improve semantics of atomic operationsAndrew Kelley
ZIR instructions updated: atomic_load, atomic_rmw, atomic_store, cmpxchg These no longer construct a pointer type as the result location. This solves a TODO that was preventing the pointer from possibly being volatile, as well as properly handling allowzero and addrspace. It also allows the pointer to be over-aligned, which may be needed depending on the target. As a consequence, the element type needs to be communicated in the ZIR. This is done by strategically making one of the operands be ResultLoc.ty instead of ResultLoc.coerced_ty if possible, or otherwise explicitly adding elem_type into the ZIR encoding, such as in the case of atomic_load. The pointer type of atomic operations is now checked in Sema by coercing it to an expected pointer type, that maybe over-aligned according to target requirements. Together with the previous commit, Zig now has smaller alignment for large integers, depending on the target, and yet still has type safety for atomic operations that specially require higher alignment.
2022-04-18wasm: Add support for debug infoLuuk de Gram
This implements basic DWARF output when building for the wasm target. Stacktraces, however, are currently not supported.
2022-04-14stage2: Add SPARC function alignmentKoakuma
This is based on @kubkon's suggestion.
2022-03-17stage2: default to LLVM backendAndrew Kelley
on targets for which self-hosted backends are not up to par. See #89
2022-02-23stage2: make -lgcc_s additionally link libunwindAndrew Kelley
Previously, Zig ignored -lgcc_s with a warning that this dependency is redundant because it is satisfied by compiler-rt. However, sfackler pointed out that it also provides exception handling functions. So if Zig sees -lgcc_s on the linker line, it needs to fulfill this dependency with libunwind. I also made link_libc inferred to be on if libunwind is linked since libunwind depends on libc.
2022-02-09CLI: ignore -lgcc_s when it is redundant with compiler-rtAndrew Kelley
For some projects, they can't help themselves, -lgcc_s ends up on the compiler command line even though it does not belong there. In Zig we know what -lgcc_s does. It's an alternative to compiler-rt. With this commit we emit a warning telling that it is unnecessary to put such thing on the command line, and happily ignore it, since we will fulfill the dependency with compiler-rt.