aboutsummaryrefslogtreecommitdiff
path: root/src
AgeCommit message (Collapse)Author
2024-10-31link.File.Wasm: unify the string tablesAndrew Kelley
Before, the wasm struct had a string table, the ZigObject had a string table, and each Object had a string table. Now there is just the one. This makes for more efficient use of memory and simplifies logic, particularly with regards to linker state serialization. This commit additionally adds significantly more integer type safety.
2024-10-31link.File.Wasm: conform to naming conventionsAndrew Kelley
2024-10-31link.File.Wasm.Archive: remove header fieldAndrew Kelley
it's not needed
2024-11-01Merge pull request #21861 from alichraghi/masterRobin Voetter
spirv: push constants and small fixes
2024-11-01spirv: decorate arrays strideAli Cheraghi
2024-11-01spirv: Uniform/PushConstant variablesAli Cheraghi
- Rename GPU address spaces to match with SPIR-V spec. - Emit `Block` Decoration for Uniform/PushConstant variables. - Don't emit `OpTypeForwardPointer` for non-opencl targets. (there's still a false-positive about recursive structs) Signed-off-by: Ali Cheraghi <alichraghi@proton.me>
2024-10-31compiler: remove anonymous struct types, unify all tuplesmlugg
This commit reworks how anonymous struct literals and tuples work. Previously, an untyped anonymous struct literal (e.g. `const x = .{ .a = 123 }`) was given an "anonymous struct type", which is a special kind of struct which coerces using structural equivalence. This mechanism was a holdover from before we used RLS / result types as the primary mechanism of type inference. This commit changes the language so that the type assigned here is a "normal" struct type. It uses a form of equivalence based on the AST node and the type's structure, much like a reified (`@Type`) type. Additionally, tuples have been simplified. The distinction between "simple" and "complex" tuple types is eliminated. All tuples, even those explicitly declared using `struct { ... }` syntax, use structural equivalence, and do not undergo staged type resolution. Tuples are very restricted: they cannot have non-`auto` layouts, cannot have aligned fields, and cannot have default values with the exception of `comptime` fields. Tuples currently do not have optimized layout, but this can be changed in the future. This change simplifies the language, and fixes some problematic coercions through pointers which led to unintuitive behavior. Resolves: #16865
2024-10-30link.File.Wasm: parse inputs in compilation pipelineAndrew Kelley
Primarily, this moves linker input parsing from flush() into the linker task queue, which is executed simultaneously with the frontend. I also made it avoid redundantly opening the same archive file N times for each object file inside. Furthermore, hard code fixed buffer stream rather than using a generic stream type. Finally, I fixed the error handling of the Wasm.Archive.parse function. Please pay attention to this pattern of returning a struct rather than accepting a mutable struct as an argument. This ensures function-level atomicity and makes resource management straightforward. Deletes the file and path fields from Archive and Object. Removed a well-meaning but ultimately misguided suggestion about how to think about ZigObject since thinking about it that way has led to problematic anti-DOD patterns.
2024-10-30Merge pull request #21862 from alexrp/llvm-19-api-breakAndrew Kelley
Reduce our exposure to LLVM API breakage
2024-10-30link.File.Wasm: remove the "files" abstractionAndrew Kelley
Removes the `files` field from the Wasm linker, storing the ZigObject as its own field instead using a tagged union. This removes a layer of indirection when accessing the ZigObject, and untangles logic so that we can introduce a "pre-link" phase that prepares the linker state to handle only incremental updates to the ZigObject and then minimize logic inside flush(). Furthermore, don't make array elements store their own indexes, that's always a waste. Flattens some of the file system hierarchy and unifies variable names for easier refactoring. Introduces type safety for optional object indexes.
2024-10-31link: Fix archive format selection for some OSs.Alex Rønne Petersen
* AIX has its own bespoke format. * Handle all Apple platforms. * FreeBSD and OpenBSD both use the GNU format in LLVM. * Windows has since been switched to the COFF format by default in LLVM.
2024-10-31mingw: Fix COFF machine type selection for thumb-windows-gnu import libraries.Alex Rønne Petersen
2024-10-31zig_llvm: Reduce our exposure to LLVM API breakage.Alex Rønne Petersen
LLVM recently introduced new Triple::ArchType members in 19.1.3 which broke our static assertions in zig_llvm.cpp. When implementing a fix for that, I realized that we don't even need a lot of the stuff we have in zig_llvm.(cpp,h) anymore. This commit trims the interface down considerably.
2024-10-29link/Elf: ensure we always sort all relocations by r_offset in -r modeJakub Konka
According to a comment in mold, this is the expected (and desired) condition by the linkers, except for some architectures (RISCV and Loongarch) where this condition does not have to upheld. If you follow the changes in this patch and in particular doc comments I have linked the comment/code in mold that explains and implements this. I have also modified `testEhFrameRelocatable` test to now test both cases such that `zig ld -r a.o b.o -o c.o` and `zig ld -r b.o a.o -o d.o`. In both cases, `c.o` and `d.o` should produce valid object files which was not the case before this patch.
2024-10-29Merge pull request #21826 from Snektron/spirv-vulkanRobin Voetter
spirv: vulkan setup
2024-10-29CLI: don't warn on missing host-detected directoriesAndrew Kelley
2024-10-28dwarf: flush wip_nav after emitting anyerror type infoRobin Voetter
This caused a missing reference for u16 to not be emitted. Triggered after removing something from start.zig which transitively added u16 to the module.
2024-10-28Merge pull request #21807 from Rexicon226/riscv-interuptAlex Rønne Petersen
implement new interrupt calling conventions in the llvm backend
2024-10-28Sema: add missing coercion to bool for condbr_inlinemlugg
Also, start using labeled switch statements when dispatching maybe-runtime instructions like condbr to comptime-only variants like condbr_inline. This can't be merged until we get a zig1.wasm update due to #21385. Resolves: #21405
2024-10-27implement new interrupts in the llvm backendDavid Rubin
2024-10-27spirv: forbid merging logical pointersRobin Voetter
Under some architecture/operating system combinations it is forbidden to return a pointer from a merge, as these pointers must point to a location at compile time. This adds a check for those cases when returning a pointer from a block merge.
2024-10-27spirv: generate test entry points for vulkanRobin Voetter
2024-10-27spirv: use PhysicalStorageBuffer64 for global pointers under vkRobin Voetter
We can use real pointers with this storage class!!
2024-10-27spirv: fix up calling conventions for vulkanRobin Voetter
* Fragment and Vertex CCs are only valid for SPIR-V when running under Vulkan. * Emit GLCompute instead of Kernel for SPIR-V kernels.
2024-10-26Compilation: Omit Clang CPU model flags for some targets.Alex Rønne Petersen
2024-10-26link/Elf.zig: ensure capacity before appending linker args.Xavier Bouchoux
fixes e567abb339e1edaf5a3c86fe632522a3b8005275 "rework linker inputs" closes https://github.com/ziglang/zig/issues/21801
2024-10-25Merge pull request #21796 from Rexicon226/var-argsMatthew Lugg
fix callconv resolution for varargs
2024-10-25Merge pull request #21710 from alexrp/function-alignmentAlex Rønne Petersen
Some improvements to the compiler's handling of function alignment
2024-10-25use `cCallingConvention` instead of `.C` in SemaDavid Rubin
using `.C` in Sema is incorrect since it will be resolved under the target that Zig was compiled with, not the target build configuration. This is easily solved by just calling `cCallingConvention` on the target to resolve it.
2024-10-24remove leak from linkerDavid Rubin
2024-10-24link/Coff: simplify file structure by collapsing all files into Coff.zig ↵Jakub Konka
(#21761) * coff: collapse Coff/lld.zig logic into Coff.zig * coff: rename std.coff uses to coff_util * coff: rename self to coff for *Coff references * coff: collapse Coff/Atom.zig logic into Coff.zig * coff: collapse Coff/Relocation.zig logic into Coff.zig * coff: collapse Coff/ImportTable.zig logic into Coff.zig * coff: remove unused Coff/Object.zig * link/Coff: fix rebase gone wrong
2024-10-24Sema: fix check for whether current AnalUnit is a test functionVeikka Tuominen
Closes #21159
2024-10-23avoid unnecessarily building Scrt1.o when cross-compiling glibcAndrew Kelley
which, in this branch causes a miscompilation because it would get sent to the linker.
2024-10-23mutex protect comp.arena in --verbose-linkAndrew Kelley
2024-10-23link.flushTaskQueue: move safety lockAndrew Kelley
The safety lock needs to happen after check()
2024-10-23combine codegen work queue and linker task queueAndrew Kelley
these tasks have some shared data dependencies so they cannot be done simultaneously. Future work should untangle these data dependencies so that more can be done in parallel. for now this commit ensures correctness by making linker input parsing and codegen tasks part of the same queue.
2024-10-23work on compiler_rt and fuzzer libs earlier in the pipelineAndrew Kelley
don't wait for AstGen and C source files to complete before starting to build compiler_rt and libfuzzer
2024-10-23link.Elf.ZigObject.updateFunc: reduce data dependenciesAndrew Kelley
Unfortunately it's not a complete solution, so a follow-up commit will need to do something more drastic like not do the linker task queue at the same time as codegen task queue. From that point, it is possible to do more work at the same time but that should be a separate branch. This one has gotten big enough.
2024-10-23Compilation.create: skip libc_installation on darwinAndrew Kelley
If the "is darwin" check is moved below the libc_installation check below, error.LibCInstallationMissingCrtDir is returned from lci.resolveCrtPaths(). This should be revisited because it makes sense to check libc_installation first even on darwin. Anyway for now this more closely matches logic from master branch.
2024-10-23use deterministic order in relocatable-eh-frame testsAndrew Kelley
This test does not pass in master branch either if you flip the object order around.
2024-10-23use unstable sort in relocatable writeSyntheticSectionsAndrew Kelley
unstable sort is always better if you have no ties
2024-10-23glibc sometimes makes archives be ld scriptsAndrew Kelley
it is incredible how many bad ideas glibc is bundled into one project.
2024-10-23link.Elf: unstable sort for section headersAndrew Kelley
using name as tie-breaker.
2024-10-23also find static libc files on the hostAndrew Kelley
and don't look for glibc files on windows
2024-10-23link.Elf: remove ZigObject from filesAndrew Kelley
By making it a field of link.Elf, it is now accessible without a data dependency on `files`, fixing a race condition with the codegen thread and linker thread.
2024-10-23add missing check for output mode in tsan logicAndrew Kelley
2024-10-23better error messagesAndrew Kelley
2024-10-23don't create unused musl crt objectsAndrew Kelley
2024-10-23unify parsing codepaths between relocatable and nonAndrew Kelley
2024-10-23fix wasm crt logicAndrew Kelley