aboutsummaryrefslogtreecommitdiff
path: root/src
AgeCommit message (Collapse)Author
2025-01-15wasm linker: support export section as implicit symbolsAndrew Kelley
2025-01-15wasm: fix many compilation errorsAndrew Kelley
Still, the branch is not yet passing semantic analysis.
2025-01-15switch to ArrayListUnmanaged for machine codeAndrew Kelley
2025-01-15wasm: use call_intrinsic MIR instructionAndrew Kelley
2025-01-15wasm: move error_name lowering to Emit phaseAndrew Kelley
2025-01-15wasm codegen: rename func: CodeGen to cg: CodeGenAndrew Kelley
2025-01-15wasm codegen: switch on bool instead of intAndrew Kelley
2025-01-15wasm: implement errors_len as a MIR opcode with no linker involvementAndrew Kelley
2025-01-15wasm codegen: fix some compilation errorsAndrew Kelley
2025-01-15rewrite wasm/Emit.zigAndrew Kelley
mainly, rework how relocations works. This is the point at which symbol indexes are known - not before. And don't emit unnecessary relocations! They're only needed when emitting an object file. Changes wasm linker to keep MIR around long-lived so that fixups can be reapplied after linker garbage collection. use labeled switch while we're at it
2025-01-15compiler: add type safety for export indicesAndrew Kelley
2025-01-15rework error handling in the backendsAndrew Kelley
2025-01-15elf linker: conform to explicit error setsAndrew Kelley
2025-01-15macho linker conforms to explicit error sets, againAndrew Kelley
2025-01-15remove "FIXME" from codebaseAndrew Kelley
See #363. Please file issues rather than making TODO comments.
2025-01-15macho linker: conform to explicit error setsAndrew Kelley
Makes linker functions have small error sets, required to report diagnostics properly rather than having a massive error set that has a lot of codes. Other linker implementations are not ported yet. Also the branch is not passing semantic analysis yet.
2025-01-15wasm linker: aggressive DODificationAndrew Kelley
The goals of this branch are to: * compile faster when using the wasm linker and backend * enable saving compiler state by directly copying in-memory linker state to disk. * more efficient compiler memory utilization * introduce integer type safety to wasm linker code * generate better WebAssembly code * fully participate in incremental compilation * do as much work as possible outside of flush(), while continuing to do linker garbage collection. * avoid unnecessary heap allocations * avoid unnecessary indirect function calls In order to accomplish this goals, this removes the ZigObject abstraction, as well as Symbol and Atom. These abstractions resulted in overly generic code, doing unnecessary work, and needless complications that simply go away by creating a better in-memory data model and emitting more things lazily. For example, this makes wasm codegen emit MIR which is then lowered to wasm code during linking, with optimal function indexes etc, or relocations are emitted if outputting an object. Previously, this would always emit relocations, which are fully unnecessary when emitting an executable, and required all function calls to use the maximum size LEB encoding. This branch introduces the concept of the "prelink" phase which occurs after all object files have been parsed, but before any Zcu updates are sent to the linker. This allows the linker to fully parse all objects into a compact memory model, which is guaranteed to be complete when Zcu code is generated. This commit is not a complete implementation of all these goals; it is not even passing semantic analysis.
2025-01-15print_value: fix crash on undefined slice ptrmlugg
Resolves: #22418
2025-01-14Sema: more validation for builtin decl typesmlugg
Also improve the source locations when this validation fails. Resolves: #22465
2025-01-14Sema: fix UB in error reportingmlugg
And add test coverage for the compile error in question.
2025-01-14Type: `struct {}` does not have a well-defined layoutmlugg
`Type.hasWellDefinedLayout` was in disagreement with pointer loading logic about auto-layout structs with zero fields, `struct {}`. For consistency, these types should not have a well-defined layout. This is technically a breaking change.
2025-01-14Coff msdos-stub: replace with documented byte arraywooster0
This replaces the msdos-stub binary with a fully documented byte array with inline comments to make it easy to understand what every byte actually means.
2025-01-14mingw: Add upstream RtlSecureZeroMemory implementation.Alex Rønne Petersen
Closes #22475.
2025-01-13Sema: disallow non scalar sentinels in array types and reified types (#22473)xdBronch
2025-01-12Dwarf: emit debug info for extern globalsJacob Young
2025-01-13Sema: allow tail calls of function pointersmlugg
Resolves: #22474
2025-01-11compiler: improve "... contains reference to comptime var" errorsmlugg
`Sema.explainWhyValueContainsReferenceToComptimeVar` (concise name!) adds notes to an error explaining how to get from a given `Value` to a pointer to some `comptime var` (or a comptime field). Previously, this error could be very opaque in any case where it wasn't obvious where the comptime var pointer came from; particularly for type captures. Now, the error notes explain this to the user.
2025-01-10cbe: fix miscomps of the compilerJacob Young
2025-01-10x86_64: fix miscomp where in use register is marked as freeJacob Young
2025-01-10Merge pull request #22414 from mlugg/better-analyze-callMatthew Lugg
Sema: rewrite semantic analysis of function calls
2025-01-10bsd: fix stage3 linking on freebsd and dragonflyMichael Dusan
2025-01-09Sema: rewrite semantic analysis of function callsmlugg
This rewrite improves some error messages, hugely simplifies the logic, and fixes several bugs. One of these bugs is technically a new rule which Andrew and I agreed on: if a parameter has a comptime-only type but is not declared `comptime`, then the corresponding call argument should not be *evaluated* at comptime; only resolved. Implementing this required changing how function types work a little, which in turn required allowing a new kind of function coercion for some generic use cases: function coercions are now allowed to implicitly *remove* `comptime` annotations from parameters with comptime-only types. This is okay because removing the annotation affects only the call site. Resolves: #22262
2025-01-08cbe: fix miscomps of x86_64 backendJacob Young
2025-01-08Dwarf: fix assertion failureJacob Young
I'm not entirely sure how this happens.
2025-01-07Sema: fix invalid AIR from array concatDavid Rubin
2025-01-06Dwarf: fix abbrev code being overwritten with the wrong empty variantJacob Young
2025-01-06remove wasm from redzone targets listReuben Dunnington
2025-01-06fix win32 manifest ID for DLLsReuben Dunnington
* MSDN documentation page covering what resource IDs manifests should have: https://learn.microsoft.com/en-us/windows/win32/sbscs/using-side-by-side-assemblies-as-a-resource * This change ensures shared libraries that embed win32 manifests use the proper ID of 2 instead of 1, which is only allowed for .exes. If the manifest uses the wrong ID, it will not be found and is essentially ignored.
2025-01-05x86_64: fix `@errorName` dataJacob Young
The final offset was clobbering the first error name, which is revealed by an out of bounds when the global error set is empty. Closes #22362
2025-01-05Sema: fix incorrect type in `optional_payload` instructionmlugg
Resolves: #22417
2025-01-05Added support for thin ltoTravis Lange
2025-01-05Merge pull request #22412 from mlugg/line-number-incrementalMatthew Lugg
incremental: debug line number updates
2025-01-05compiler: slightly simplify builtin decl memoizationmlugg
Rather than `Zcu.BuiltinDecl.Memoized` being a struct with fields, it can instead just be an array, indexed by the enum. This allows runtime indexing, avoiding a few now-unnecessary `inline` switch cases.
2025-01-05Dwarf: implement new incremental line number update APIJacob Young
2025-01-05link: new incremental line number update APImlugg
2025-01-04incremental: new `AnalUnit` to group dependencies on `std.builtin` declsmlugg
This commit reworks how values like the panic handler function are memoized during a compiler invocation. Previously, the value was resolved by whichever analysis requested it first, and cached on `Zcu`. This is problematic for incremental compilation, as after the initial resolution, no dependencies are marked by users of this memoized state. This is arguably acceptable for `std.builtin`, but it's definitely not acceptable for the panic handler/messages, because those can be set by the user (`std.builtin.Panic` checks `@import("root").Panic`). So, here we introduce a new kind of `AnalUnit`, called `memoized_state`. There are 3 such units: * `.{ .memoized_state = .va_list }` resolves the type `std.builtin.VaList` * `.{ .memoized_state = .panic }` resolves `std.Panic` * `.{ .memoized_state = .main }` resolves everything else we want These units essentially "bundle" the resolution of their corresponding declarations, storing the results into fields on `Zcu`. This way, when, for instance, a function wants to call the panic handler, it simply runs `ensureMemoizedStateResolved`, registering one dependency, and pulls the values from the `Zcu`. This "bundling" minimizes dependency edges. The 3 units are separated to allow them to act independently: for instance, the panic handler can use `std.builtin.Type` without triggering a dependency loop.
2025-01-04incremental: correctly handle losing file root `struct_decl` instmlugg
2025-01-04incremental: correctly return `error.AnalysisFail` when type structure changesmlugg
`Zcu.PerThead.ensureTypeUpToDate` is set up in such a way that it only returns the updated type the first time it is called. In general, that's okay; however, the exception is that we want the function to continue returning `error.AnalysisFail` when the type has been lost, or its number of captures changed. Therefore, the check for this case now happens before the up-to-date success return. For simplicity, the number of captures is now handled by intentionally losing the instruction in `Zcu.mapOldZirToNew`, since there is nothing to gain from tracking a type when old instances of it can never be reused.
2025-01-04Zcu: fix crash when incremental re-analysis of type annotation yields same ↵mlugg
result
2025-01-03Zir: split up start and end of range in `for_len`mlugg
The old lowering was kind of neat, but it unintentionally allowed the syntax `for (123) |_| { ... }`, and there wasn't really a way to fix that. So, instead, we include both the start and the end of the range in the `for_len` instruction (each operand to `for` now has *two* entries in this multi-op instruction). This slightly increases the size of ZIR for loops of predominantly indexables, but the difference is small enough that it's not worth complicating ZIR to try and fix it.