13404 Commits

Author SHA1 Message Date
Jakub Konka
875beb25b5 elf: fix writing symtab to an archive 2023-11-04 09:12:18 +01:00
Jakub Konka
3b9455f005 elf: generate pretty rudimentary archive 2023-11-04 09:12:07 +01:00
Jakub Konka
eddf9cc65b elf: collect exports from ZigObject into AR symtab 2023-11-04 09:11:58 +01:00
Jakub Konka
481ee1b598 elf: enable static-lib flush path 2023-11-04 09:11:47 +01:00
Jakub Konka
d2c4597eb5 x86_64: rewrite .got.zig movs to standard loads when emitting objects 2023-11-04 09:11:37 +01:00
Jakub Konka
ccb2afacc0 elf: postpone creation of .got.zig entry until code emit 2023-11-04 09:11:29 +01:00
Jakub Konka
5affd29b47 elf: use StringTable for strtab management in ZigObject 2023-11-04 09:11:22 +01:00
Jakub Konka
96f221236d elf: fix r_offset when emitting relocs for the linker 2023-11-04 09:11:14 +01:00
Jakub Konka
7c5c59191e elf: claim unresolved dangling symbols as undef externs when emitting object 2023-11-04 09:10:43 +01:00
Jakub Konka
dbe13200f1 elf: emit STT_SECTION symbols 2023-11-04 09:10:30 +01:00
Jakub Konka
8055f68765 elf: make sure we never emit .got.zig relocs when linking object files 2023-11-04 09:10:23 +01:00
Jakub Konka
e8f522122a elf: fix properly updating .got.zig section 2023-11-04 09:10:14 +01:00
Jakub Konka
5698be3ef0 elf: write out contents of .rela sections 2023-11-04 09:10:06 +01:00
Jakub Konka
3606b5df3f elf: improve Symbol to handle emitting relocatable object files 2023-11-04 09:09:57 +01:00
Jakub Konka
ec2671d16b elf: update .rela section sizes; skip .got.zig when emitting object 2023-11-04 09:09:46 +01:00
Jakub Konka
21853bc310 elf: emit .rela shdrs for output sections 2023-11-04 09:09:35 +01:00
Jakub Konka
0ee2ab413f elf: emit valid section headers table when building an object file 2023-11-04 09:09:26 +01:00
Jakub Konka
74f12d0691 elf: remove now obsolete allocateNonAllocSection helper 2023-11-04 09:09:14 +01:00
Jakub Konka
abf6c20cb9 elf: rename .rodata to .data.rel.ro and remove allocateAllocSection helper 2023-11-04 09:09:01 +01:00
Jakub Konka
b1136a695f elf: remove now obsolete allocateSegment helper 2023-11-04 09:08:50 +01:00
Jakub Konka
1be94878e3 elf: generate invalid object file but with almost correct header 2023-11-04 09:08:38 +01:00
Jakub Konka
b8c8565e93 elf: implement --gc-sections for non-LLVM Zig source 2023-11-04 09:08:27 +01:00
Jakub Konka
25c53f08a6 elf: redo strings management in the linker
* atom names - are stored locally and pulled from defining object's
  strtab
* local symbols - same
* global symbols - in principle, we could store them locally, but
  for better debugging experience - when things go wrong - we
  store the offsets in a global strtab used by the symbol resolver
2023-11-04 09:08:16 +01:00
Andrew Kelley
1ccc68f307 frontend: rip out Decl dependencies
This incremental compilation logic will need to be reworked so that it
does not depend on buried pointers - that is, long-lived pointers that
are owned by non-top-level objects such as Decl.

In the meantime, this fixes memory leaks since the memory management of
these dependencies has bitrotted.
2023-11-03 21:24:13 -04:00
mlugg
a95be8f0e0 Sema: use correct error bit length when emitting error_set_has_value safety checks
Resolves: #17843
2023-11-03 22:39:13 +00:00
Andrew Kelley
d892665694
Merge pull request #17819 from Luukdegram/wasm-bitcast-fix
wasm - fix bitcasting between arrays and scalar types
2023-11-01 20:20:11 -04:00
Ali Chraghi
3ead829de1 print_zir: fix crash in writeRestoreErrRetIndex 2023-11-01 19:04:21 -04:00
Luuk de Gram
2c2bc9c8df
wasm: fix bitcasting to -and from arrays
Arrays are currently always passed by reference, this means that we
always keep the value in linear memory and never load it to Wasm's
stack. Scalar values however do get lowered to Wasm's stack.
This means when bitcasting from an array to a scalar value, we must
load the memory of the array as such scalar type. To bitcast
a scalar type to an array, we allocate a new temporary in the
linear data segment, and then store the scalar value there.
2023-11-01 19:47:15 +01:00
Jacob Young
13b1e10b8f cbe: fix @bitCast warnings 2023-10-31 21:37:40 -04:00
Andrew Kelley
3fc6fc6812 std.builtin.Endian: make the tags lower case
Let's take this breaking change opportunity to fix the style of this
enum.
2023-10-31 21:37:35 -04:00
Jacob Young
d890e81761 mem: fix ub in writeInt
Use inline to vastly simplify the exposed API.  This allows a
comptime-known endian parameter to be propogated, making extra functions
for a specific endianness completely unnecessary.
2023-10-31 21:37:35 -04:00
Jacob Young
50cdb65784 Sema: fix incorrect error comptime-mutating empty array 2023-10-31 21:37:35 -04:00
Jakub Konka
a09ba455c2
Merge pull request #17791 from ziglang/elf-object
elf: rename ZigModule to ZigObject and move all codegen hooks into it
2023-10-31 07:51:26 +01:00
kcbanner
fb523c6283 sema: when guessing union alignment, save the result and check if the guess was correct 2023-10-31 01:35:58 +00:00
kcbanner
4d044ee7e0 sema: Add union alignment resolution
- Add resolveUnionAlignment, to resolve a union's alignment only, without triggering layout resolution.
- Update resolveUnionLayout to cache size, alignment, and padding. abiSizeAdvanced and abiAlignmentAdvanced
  now use this information instead of computing it each time.
2023-10-31 01:35:58 +00:00
Krzysztof Wolicki
1880c799ae
autodoc: Some support for field_call (#16853)
* autodoc: Some support for field_call

* autodoc: Change handling of field_call to respect tryResolveRefPath, add fieldVal to Expr

* autodoc: Fixed errors

* autodoc: sync with latest master changes

---------

Co-authored-by: Loris Cro <kappaloris@gmail.com>
2023-10-30 21:04:49 +00:00
Jakub Konka
ea95c74948 elf: encapsulate ZigObject-specific logic in flushModule hook 2023-10-30 20:36:34 +01:00
Jakub Konka
b1a735ac65 elf: put init logic of ZigObject in init function 2023-10-30 19:44:27 +01:00
Jakub Konka
9bdbb6312f elf: move incremental codegen bits into ZigObject.zig 2023-10-30 19:09:13 +01:00
Jakub Konka
b2e847a41a elf: rename ZigModule to ZigObject 2023-10-30 19:09:13 +01:00
Jakub Konka
10d03acdb5
Merge pull request #17773 from ziglang/elf-exports
link: implement exporting anon decls
2023-10-30 17:29:05 +01:00
Jakub Konka
324a93e673 coff: implement enough of extern handling to pass comptime export tests 2023-10-30 12:44:50 +01:00
Jakub Konka
2e690f5c74 macho: implement enough of extern handling to pass comptime export tests 2023-10-30 00:09:32 +01:00
DilithiumNitrate
91e117697a
Fix hasRuntimeBitsAdvanced lazy case for pointers and optionals
As suggested by mlugg, always returns `error.NeedLazy`. If this has a
performance impact, it could be replaced by adding lazy handling to
`comptimeOnlyAdvanced`.
2023-10-29 21:12:43 +00:00
Jakub Konka
71dfea1f17 coff: implement exporting anon decls 2023-10-29 18:55:58 +01:00
Jakub Konka
a7a95ce9c4 macho: implement exporting anon decls 2023-10-29 18:55:58 +01:00
Jakub Konka
eaca72534c elf: implement exporting anon decls 2023-10-29 18:55:58 +01:00
Jakub Konka
209fd8cb93 elf: add partial implementation of exporting anon decls 2023-10-29 18:55:58 +01:00
Jacob Young
f6f2708d82 x86_64: fix compiler rt test failures 2023-10-29 07:20:36 -04:00
Jacob Young
1fecf86ebf x86_64: refactor codegen memory repr
Also refactor linker reloc lowering.
2023-10-29 05:17:43 -04:00