26827 Commits

Author SHA1 Message Date
Jakub Konka
8142925c7e elf: hook up saving object files in an archive 2023-11-05 13:37:13 +01:00
Jakub Konka
55fa8a04f1 elf: add hooks for archiving Objects 2023-11-05 12:56:17 +01:00
Jakub Konka
5c48236103 elf: init objects after parsing them 2023-11-05 12:37:15 +01:00
Jakub Konka
8d7ec05070 elf: actually save correct object names in the archive 2023-11-05 12:08:15 +01:00
Jakub Konka
f24ceec35a
Merge pull request #17844 from ziglang/elf-object
elf: handle emitting relocatables and static libraries - humble beginnings
2023-11-04 20:58:15 +01:00
Andrew Kelley
98dc28bbe2
Merge pull request #17852 from ziglang/zig-reduce
introduce `zig reduce` subcommand
2023-11-04 14:25:50 -04:00
Andrew Kelley
a7d8cd591c
Merge pull request #17788 from jacobly0/x86_64
x86_64: pass more tests
2023-11-04 14:24:59 -04:00
Jakub Konka
7a186d9eb6 Compilation: take into account if LLVM is available in lib-building logic 2023-11-04 16:09:52 +01:00
Jacob Young
095c4294aa x86_64: fix miscompilations
Closes #17618
2023-11-04 09:15:05 -04:00
Jacob Young
6553359f39 x86_64: fix ub that the llvm backend was hiding 2023-11-04 08:13:13 -04:00
Jakub Konka
533c88158e elf: actually capture positionals when linking static library 2023-11-04 09:14:15 +01:00
Jakub Konka
bd0416aeb6 elf: flag errors on hitting unimplemented codepaths 2023-11-04 09:14:05 +01:00
Jakub Konka
9cf3ebe524 elf: fix more int resolution issues 2023-11-04 09:13:50 +01:00
Jakub Konka
56296694d9 elf: fix 32bit build 2023-11-04 09:13:43 +01:00
Jakub Konka
ee66137269 elf: add link smoke tests covering emitting obj and static lib 2023-11-04 09:13:34 +01:00
Jakub Konka
e3b82eaa66 elf: do not store filename in strtab unless longer than 15 chars 2023-11-04 09:13:26 +01:00
Jakub Konka
acd700ac6b elf: store ar state per input object file 2023-11-04 09:13:18 +01:00
Jakub Konka
ed2984f335 elf: do not align end of archive to 2bytes; fix archive parser 2023-11-04 09:13:07 +01:00
Andrew Kelley
a333ac846d Compilation: refactor logic for library-building capabilities
And mark the stage2_x86_64 backend as being capable of building
compiler-rt and zig libc.
2023-11-04 09:12:54 +01:00
Jakub Konka
65adbec918 link: commit missing source StringTable.zig 2023-11-04 09:12:46 +01:00
Jakub Konka
912a774a15 x86_64: rewrite call r/m64 to call rel32 for .got.zig refs when object 2023-11-04 09:12:35 +01:00
Jakub Konka
33a0a72e87 elf: align ar_hdr to at least 2 bytes 2023-11-04 09:12:26 +01:00
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
Jacob Young
7b1a644d6e print_zir: fix more crashes during printing 2023-11-04 01:54:12 -04:00
Andrew Kelley
31529f912b zig reduce: add transformation of replacing var init with undefined 2023-11-03 22:08:01 -07:00
Andrew Kelley
a2f4adbd19 zig reduce: add "delete unused globals" transform
While walking the AST looking for reductions, notice if any globals are
unreferenced, and if they are, add a transformation for removing the
global.
2023-11-03 21:31:32 -07:00
Andrew Kelley
6aedddf900 fix bootstrap 2023-11-03 20:53:38 -07:00
Jacob Young
46d3e5bb04 x86_64: reduce RegisterManager performance regression
This reduces the regression from 0.11.0 by 95%.

Closes #17678
2023-11-03 23:18:23 -04:00