4296 Commits

Author SHA1 Message Date
Felix (xq) Queißner
dce74c31cc Depending on system libs only enforces libraries to require dynamic linking, but neither static libs nor object files. 2020-10-05 00:27:42 -04:00
Andrew Kelley
1d777e9958 add --image-base support
Based on #6121 by Jay Petacat.
2020-10-04 17:59:44 -07:00
Andrew Kelley
da596b7e4f
Merge pull request #6255 from joachimschmidt557/stage2-arm
stage2 ARM: more instructions, return values, parameters
2020-10-04 19:49:18 -04:00
Andrew Kelley
6aa668e020
Merge pull request #6476 from kubkon/macho-exe
Link basic MachO executables with stage2
2020-10-04 19:05:45 -04:00
Andrew Kelley
302a69f127
Merge pull request #6295 from Vexu/stage2
Stage2: basic imports
2020-10-04 18:00:21 -04:00
Jakub Konka
c4054f8e0a Refactor flushing of MachO exe
This commit refactors free space analysis (and VM analysis) somewhat.
This is still far from perfect, but at least it's not using any
hardcoded values.

This commit also reorganizes different flushing bits here and there,
so that bit common to Exe and Obj are put in the common path, while
Exe-specific are behind an appropriate switch/if statement.
2020-10-04 15:31:47 +02:00
Jakub Konka
737a8bf204 Redo local symbols and offsets tracking to match Elf's approach 2020-10-04 15:31:47 +02:00
Jakub Konka
2ba23abd9d Add missing ensureCapacity call in codegen 2020-10-04 15:31:47 +02:00
Jakub Konka
f8dd48bcd2 Fix after rebase and enable stage2 tests for macOS
Also, rewrites codegen section to store symbol address in a register
to then later invoke `callq` on the register.
2020-10-04 15:31:47 +02:00
Jakub Konka
5a7105401c First hacked together, working MachO exe! 2020-10-04 15:31:47 +02:00
Jakub Konka
635984abc7 Move writing symbol table and export trie into functions 2020-10-04 15:31:47 +02:00
Jakub Konka
ccf9bba61f Write out LC_DYSYMTAB together with dyld_stub_binder undef symbol 2020-10-04 15:31:47 +02:00
Jakub Konka
a927f24201 Generate more MachO exe boilerplate
* Convert draft to generate all relevant segments and sections in right places
* Do not prealloc space in text blocks until we can NOP
* Write out LC_LOAD_DYLINKER command
* Add LC_LOAD_DYLIB command in order to specify to load libSystem
* Redo update decl exports (similar to Elf globals, globals need to be contiguous in
  memory)
2020-10-04 15:31:47 +02:00
Jakub Konka
57a81bb559 Re-draft required elements for minimal MachO binary 2020-10-04 15:31:47 +02:00
Andrew Kelley
2de53592a1 stage1: better value for builtin.link_mode
Now it is Dynamic unless -DZIG_STATIC=on is passed to cmake.

This partially addresses #6469.
2020-10-03 23:15:45 -07:00
Alexandros Naskos
52ba2c3a43 Reintroduce progress bar when compiling C files 2020-10-03 22:11:29 -04:00
Tadeo Kondrak
9917b0576a stage0: check for some more required parameters 2020-10-03 21:32:32 -04:00
Tadeo Kondrak
cbdd825056 stage1: delete unused os code 2020-10-03 21:31:08 -04:00
Tadeo Kondrak
26546af1b8 Revert "Include dbg.h to third-party libs"
This reverts commit c8b4cc2ff9cf15a42f95b2302e02431a0004f5c8.

This includes many C++ standard library headers:

  #include <algorithm>
  #include <chrono>
  #include <ctime>
  #include <iomanip>
  #include <ios>
  #include <iostream>
  #include <memory>
  #include <sstream>
  #include <string>
  #include <tuple>
  #include <type_traits>
  #include <vector>

which adds more than a second of compile time for each file that
includes the header:

  ir.cpp before: 8.041s
  ir.cpp after: 6.847s
2020-10-03 21:29:29 -04:00
Andrew Kelley
b306149b22 zig run foo.c is perfectly valid 2020-10-03 17:27:09 -07:00
Andrew Kelley
a2b86777b5 fix alignment in CLI usage text 2020-10-03 17:21:45 -07:00
Andrew Kelley
0e7523c7d7 stage1 main(): catch unreachable in debug builds for easier troubleshooting
Fixup to 2a3393eff853fe0a1dee766c859a345186e91fa3
2020-10-03 17:16:19 -07:00
LemonBoy
3b40b68210 stage2: Build libunwind for non-msvc Windows targets
Closes #6497
2020-10-03 20:47:06 +02:00
joachimschmidt557
fb58fb2d8d stage2 ARM: add testcases for non-leaf fns, parameters, return values 2020-10-03 12:52:04 +02:00
Alexandros Naskos
e31cc80130
Merge pull request #6427 from tadeokondrak/enums-explicit-tag-type-extern-allowed
Allow enums with explicit extern-allowed tag types in extern types
2020-10-03 12:51:39 +03:00
Timon Kruiper
539e90e26d Print error when running zig test/run without a source file
Closes #6498
2020-10-02 19:59:00 +02:00
joachimschmidt557
cfe486e388 stage2 ARM: Add push, pop alias instructions; non-leaf functions
Non-leaf functions now work. Combined with simple parameters and return
types, this allows more complicated programs than Hello World to be
correctly compiled.
2020-10-02 19:39:17 +02:00
joachimschmidt557
35b228630c stage2 ARM: Add stm, ldm variants and misc. additions 2020-10-02 19:39:17 +02:00
joachimschmidt557
0a54f04dbc stage2 ARM: start adding more instructions, return values, parameters 2020-10-02 19:39:17 +02:00
Alexandros Naskos
55eb7c16c0
Merge pull request #6494 from IridescentRose/emit-reloc-patch
Emit reloc patch
2020-10-02 17:00:47 +03:00
Alexandros Naskos
006b780d44
Merge pull request #6484 from LemonBoy/winshit
Some windows fixes
2020-10-02 15:05:44 +03:00
Tadeo Kondrak
61ce72a38c
Allow enums with explicit extern-allowed tag types in extern types
Closes https://github.com/ziglang/zig/issues/1467
2020-10-01 18:09:15 -06:00
Tadeo Kondrak
183d1d4ba1
Switch TypeInfo.Fn.alignment to comptime_int from u29
All integers in TypeInfo are intentionally comptime_int:
https://github.com/ziglang/zig/issues/1683
2020-10-01 18:01:41 -06:00
Tadeo Kondrak
e18fdc12b0
stage1: Implement @Type for Fn and BoundFn 2020-10-01 18:01:38 -06:00
Tadeo Kondrak
97ab720d84
stage1: Add alignment to TypeInfo.Fn 2020-10-01 17:59:42 -06:00
Alexandros Naskos
0228887b94
Merge pull request #6428 from tadeokondrak/alignment-typeinfo-struct-union
Add alignment field to TypeInfo.UnionField and TypeInfo.StructField
2020-10-02 02:56:18 +03:00
Nathan
84b6d2a80a Resolved additional formatting issues. 2020-10-01 18:03:34 -04:00
Nathan
5e3ce11b18 Resolve name and format issues. 2020-10-01 17:47:32 -04:00
Alexandros Naskos
49c0cd6e8e
Merge pull request #6481 from MasterQ32/stage1_error_return_trace
Adds error return trace printing to stage1
2020-10-02 00:22:24 +03:00
Nathan Bourgeois
4566b27373 Patch in emit relocs support 2020-10-01 17:04:04 -04:00
Tadeo Kondrak
a12203d2be
Switch TypeInfo alignment fields from u29 to comptime_int 2020-10-01 15:01:28 -06:00
Tadeo Kondrak
d81648ce8c
Add alignment field to TypeInfo.UnionField and TypeInfo.StructField
Closes https://github.com/ziglang/zig/issues/6122
2020-10-01 15:01:25 -06:00
Tadeo Kondrak
77df5dae7f
Make builtin.TypeInfo.Pointer.alignment u29 instead of comptime_int 2020-10-01 15:01:24 -06:00
LemonBoy
212171643c stage2: Add missing defines for building dllcrt2.o
Closes #6482
2020-10-01 11:39:22 +02:00
Felix (xq) Queißner
2a3393eff8 Adds error return trace printing to stage1. 2020-10-01 09:40:03 +02:00
Vexu
6d3858dc8a
stage2: use directory handles for imports 2020-09-30 18:03:10 +03:00
Vexu
d819da4350
stage2: support multiple files in tests 2020-09-30 17:00:57 +03:00
Vexu
e246fe0f5b
stage2: detect changes in imported files 2020-09-30 17:00:55 +03:00
Vexu
e2cf2e015b
stage2: struct type field access 2020-09-30 16:59:09 +03:00
Vexu
7d910b024b
stage2: very basic imports 2020-09-30 16:59:08 +03:00