aboutsummaryrefslogtreecommitdiff
path: root/src/link
AgeCommit message (Collapse)Author
2021-01-19SPIR-V: Make emitting binary more efficientRobin Voetter
2021-01-19SPIR-V: Add glsl450 and vulkan spir-v operating system definitionsRobin Voetter
2021-01-19SPIR-V: Linking and codegen setupRobin Voetter
2021-01-18stage2 macho: cleanup indirect symbol table writesJakub Konka
Also, force rewriting of code signature padding at every update so that we take into account possible section relocs and expansion of the last preceeding section, e.g., the string table. This commit also tweak the logic responsible for managing debug lines in `DebugSymbols`. In particular, in case we update the same function, we'd previously incorrectly create a cycle adding pointer to the same `SrcFn` to itself.
2021-01-18Merge pull request #7797 from Luukdegram/wasm-refactorAndrew Kelley
stage2: wasm - Refactor codegen for wasm similar to other backends
2021-01-17macho: refactor undef symbol handlingJakub Konka
Now, we don't erroneously write to the string table on every write of global and undef symbols.
2021-01-17macho: improve x86_64 tests; clean fixups on errorJakub Konka
When codegen ends in failure, we need to manually clean up any fixups that may have been gathered during that `codegen.generateSymbol` call. Otherwise, we will end trapping.
2021-01-16stage2: implement error notes and regress -femit-zirAndrew Kelley
* Implement error notes - note: other symbol exported here - note: previous else prong is here - note: previous '_' prong is here * Add Compilation.CObject.ErrorMsg. This object properly converts to AllErrors.Message when the time comes. * Add Compilation.CObject.failure_retryable. Properly handles out-of-memory and other transient failures. * Introduce Module.SrcLoc which has not only a byte offset but also references the file which the byte offset applies to. * Scope.Block now contains both a pointer to the "owner" Decl and the "source" Decl. As an example, during inline function call, the "owner" will be the Decl of the caller and the "source" will be the Decl of the callee. * Module.ErrorMsg now sports a `file_scope` field so that notes can refer to source locations in a file other than the parent error message. * Some instances where a `*Scope` was stored, now store a `*Scope.Container`. * Some methods in the `Scope` namespace were moved to the more specific type, since there was only an implementation for one particular tag. - `removeDecl` moved to `Scope.Container` - `destroy` moved to `Scope.File` * Two kinds of Scope deleted: - zir_module - decl * astgen: properly use DeclVal / DeclRef. DeclVal was incorrectly changed to be a reference; this commit fixes it. Fewer ZIR instructions processed as a result. - declval_in_module is renamed to declval - previous declval ZIR instruction is deleted; it was only for .zir files. * Test harness: friendlier diagnostics when an unexpected set of errors is encountered. * zir_sema: fix analyzeInstBlockFlat by properly calling resolvingInst on the last zir instruction in the block. Compile log implementation: * Write to a buffer rather than directly to stderr. * Only keep track of 1 callsite per Decl. * No longer mutate the ZIR Inst struct data. * "Compile log statement found" errors are only emitted when there are no other compile errors. -femit-zir and support for .zir source files is regressed. If we wanted to support this again, outputting .zir would need to be done as yet another backend rather than in the haphazard way it was previously implemented. For parsing .zir, it was implemented previously in a way that was not helpful for debugging. We need tighter integration with the test harness for it to be useful; so clearly a rewrite is needed. Given that a rewrite is needed, and it was getting in the way of progress and organization of the rest of stage2, I regressed the feature.
2021-01-16Add tests and move tests to wasm's own fileLuuk de Gram
2021-01-15Cleanup and 'add' instruction for bigger test areaLuuk de Gram
2021-01-15stage2: refactor wasm backend - similar to the other backendsLuuk de Gram
2021-01-15macho: ensure that strtab always follows symtabJakub Konka
In rare occassions, it may happen that string table is allocated free space preceeding symbol table. This is an error in the eyes of the `dyld` dynamic loader and thus has to forbidden by the linker.
2021-01-15macho: use target arch page_size for codesigJakub Konka
It turns out I was wrong and we can set the page size to the actual page size used by the target architecture when dividing the binary into chunks and calculating a hash of each chunk for embedding within the adhoc code signature. This shaves of a considerable amount of bytes since we divide the code signature section by at least 2x. I've also unified the `write` interface of `CodeSignature` struct to follow that used in every other bit of `MachO`; namely, the functions now accept a writer instead of a buffer, therefore, there is no need to manually track where to write each struct field anymore.
2021-01-13macho: update DebugSymbols to include DATA_CONST segJakub Konka
2021-01-13macho: properly populate offset into lazy bind infoJakub Konka
2021-01-13macho: add x86_64 supportJakub Konka
2021-01-13macho: bring back lld cc hot-fixJakub Konka
2021-01-13macho: document more code + add test caseJakub Konka
2021-01-13macho: refactor writing and managing externsJakub Konka
2021-01-13macho: memorize start of stubs in helperJakub Konka
2021-01-13macho: write out stubs for new externs onlyJakub Konka
2021-01-13macho: fully working PoC with main and exitJakub Konka
2021-01-13macho: first working draft of externs on macOSJakub Konka
2021-01-13macho: write out binding infoJakub Konka
2021-01-13macho: write out rebase infoJakub Konka
2021-01-13macho: populate stubs and stub_helperJakub Konka
2021-01-13macho: add missing data sectionsJakub Konka
2021-01-13macho: prealloc DATA_CONST and DATA segmentsJakub Konka
2021-01-13stage2: lay the groundwork in prep for extern fnJakub Konka
This commit lays the groundwork in preparation for implementing handling of extern functions in various backends.
2021-01-06stage2: update to new ArrayListHashMap APIAndrew Kelley
2021-01-06Merge pull request #7700 from FireFox317/more-stage2-stuff-llvmAndrew Kelley
stage2: improvements to LLVM backend
2021-01-06stage2: C backend: support unused DeclsAndrew Kelley
2021-01-06stage2: rename and move files related to LLVM backendTimon Kruiper
2021-01-05stage2: C backend: re-implement emit-hAndrew Kelley
and also mark functions as `extern "C"` as appropriate to support c++ compilers.
2021-01-05stage2: C backend: remove format() hackeryAndrew Kelley
All C backend tests passing now, except for emit-h tests. Next task in the branch is to restore emit-h.
2021-01-05stage2: link.C: use pwritevAndrew Kelley
2021-01-05stage2: rework the C backendAndrew Kelley
* std.ArrayList gains `moveToUnmanaged` and dead code `ArrayListUnmanaged.appendWrite` is deleted. * emit_h state is attached to Module rather than Compilation. * remove the implementation of emit-h because it did not properly integrate with incremental compilation. I will re-implement it in a follow-up commit. * Compilation: use the .codegen_failure tag rather than .dependency_failure tag for when `bin_file.updateDecl` fails. C backend: * Use a CValue tagged union instead of strings for C values. * Cleanly separate state into Object and DeclGen: - Object is present only when generating a .c file - DeclGen is present for both generating a .c and .h * Move some functions into their respective Object/DeclGen namespace. * Forward decls are managed by the incremental compilation frontend; C backend no longer renders function signatures based on callsites. For simplicity, all functions always get forward decls. * Constants are managed by the incremental compilation frontend. C backend no longer has a "constants" section. * Participate in incremental compilation. Each Decl gets an ArrayList for its generated C code and it is updated when the Decl is updated. During flush(), all these are joined together in the output file. * The new CValue tagged union is used to clean up using of assigning to locals without an additional pointer local. * Fix bug with bitcast of non-pointers making the memcpy destination immutable.
2021-01-05integrate CBE with Compilation.update pipeline (closes #7589)Noam Preil
* CBE buffers are only valid during a flush() * the file is reopened and truncated during each flush() * CBE now explicitly ignores updateDecl and deleteDecl * CBE updateDecl is gone * test case is enabled
2021-01-03Merge pull request #7681 from kubkon/stage2-aarch64-fn-argsAndrew Kelley
stage2: basic fn args for aarch64
2021-01-03stage2: add aarch64 stage2 testsJakub Konka
Fix missing string format specifier in Mach-O used to generate path to debug symbols bundle.
2021-01-03stage2: Output the LLVM object files in the cache directoryTimon Kruiper
Also make sure to properly free everything.
2021-01-02stage2: implement function call inlining in the frontendAndrew Kelley
* remove the -Ddump-zir thing. that's handled through --verbose-ir * rework Fn to have an is_inline flag without requiring any more memory on the heap per function. * implement a rough first version of dumping typed zir (tzir) which is a lot more helpful for debugging than what we had before. We don't have a way to parse it though. * keep track of whether the inline-ness of a function changes because if it does we have to go update callsites. * add compile error for inline and export used together. inline function calls and comptime function calls are implemented the same way. A block instruction is set up to capture the result, and then a scope is set up that has a flag for is_comptime and some state if the scope is being inlined. when analyzing `ret` instructions, zig looks for inlining state in the scope, and if found, treats `ret` as a `break` instruction instead, with the target block being the one set up at the inline callsite. Follow-up items: * Complete out the debug TZIR dumping code. * Don't redundantly generate ZIR for each inline/comptime function call. Instead we should add a new state enum tag to Fn. * comptime and inlining branch quotas. * Add more test cases.
2021-01-02convert more {} to {d} and {s}Andrew Kelley
2021-01-02Remove some unwanted changesLemonBoy
Leftovers after a long rebase.
2021-01-02langref: Update langref to use {s}LemonBoy
2021-01-02Fix more stray uses of {} for formatting stringsLemonBoy
2021-01-02stage2: Use {s} instead of {} when formatting stringsLemonBoy
2021-01-01macho: unblock stage2 on 32bit platforms (#7632)Jakub Konka
* macho: unblock stage2 on 32bit platforms Unblocks compilation of stage2 on 32bit platforms, and fixes #7630. * Use libstd convention: reads - usize, writes - u64
2020-12-31Merge pull request #7616 from ziglang/stage2-inferred-varsAndrew Kelley
stage2: inferred local variables
2020-12-31More MachO.zig fixes ensuring 32bit compatJakub Konka
Partial resolution to #7614.