17327 Commits

Author SHA1 Message Date
Andrew Kelley
88d1258e08 stage2: make -lgcc_s additionally link libunwind
Previously, Zig ignored -lgcc_s with a warning that this dependency is
redundant because it is satisfied by compiler-rt. However, sfackler
pointed out that it also provides exception handling functions. So if
Zig sees -lgcc_s on the linker line, it needs to fulfill this dependency
with libunwind.

I also made link_libc inferred to be on if libunwind is linked since
libunwind depends on libc.
2022-02-23 13:25:10 -07:00
Jakub Konka
b7760ad742 std: re-enable result printing in the test runner for macos 2022-02-23 19:39:50 +01:00
Jakub Konka
2f0299c3cf x64: account for multiple returns from functions
This is necessary to correctly adjust for spilling of the %rdi
register in the callee.
2022-02-23 19:29:47 +01:00
Jakub Konka
2ca809c32a macho: ensure we save the fully qualified name for any local symbol
Otherwise, we risk collisions in the global symbol table. This is
also an opportunity to generalise and rewrite the symbol table
abstraction.

Also, improve the logs for the symbol table.
2022-02-23 19:10:44 +01:00
Jakub Konka
897a5a4735 macho: synthesising __mh_execute_header needs to work with incremental
Prior to this change, the routine would assume it is called first,
before any symbol was created, thus precluding an option that in the
incremental setting, we might have already pulled a suitably defined
and exported symbol that could collide and/or be replaced by the
symbol synthesised by the linker.
2022-02-23 19:10:40 +01:00
Luuk de Gram
acec06cfaf wasm-linker: Implement updateDeclExports
We now correctly implement exporting decls. This means it is possible to export
a decl with a different name than the decl that is doing the export.
This also sets the symbols with the correct flags, so when we emit a relocatable
object file, a linker can correctly resolve symbols and/or export the symbol to the host environment.

This commit also includes fixes to ensure relocations have the correct offset to how other
linkers will expect the offset, rather than what we use internally.
Other linkers accept the offset, relative to the section.
Internally we use an offset relative to the atom.
2022-02-23 16:07:36 +01:00
Luuk de Gram
0a48a763fd wasm-linker: Emit relocations for object files
When generating a relocatable object file, we now emit a custom "reloc.CODE" and "reloc.DATA" section
which will contain the relocations for each section.

Using a new symbol location -> Atom mapping, we can now easily find the corresponding `Atom` from a symbol.
This can be used to construct the symbol table, as well as easier access to a target atom when performing
a relocation for a data symbol.
2022-02-23 16:07:36 +01:00
Luuk de Gram
2b0431a8d3 wasm-linker: Do not merge data segments for obj
When creating a relocatable object file, we do no longer perform the following actions:
- Merge data segments
- Calculate stack size
- Relocations

We now also make the stack pointer symbol `undefined` for this use case as well as add the symbol
as an import.
2022-02-23 16:07:36 +01:00
Luuk de Gram
daf741318e wasm-linker: Emit segment info
When creating a relocatable object file, also emit the segment information
2022-02-23 16:07:36 +01:00
Luuk de Gram
f7f3678b48 wasm-linker: Emit symbol table for object file
When creating a relocatable object file, emit the symbol table.
We do this by iterating over all atoms, and finding the corresponding
symbols of those. This provides us all the meta information such as size, and offset as well.
This data is required for defined data symbols.

When we emit an object file, the "Names" section does not have to be emitted, as all symbol names
are already in the symbol table, so the names section is redundant.
2022-02-23 16:07:36 +01:00
Exonorid
91a88a789f
Add documentation for common mistakes in errdefer scoping 2022-02-23 14:33:51 +02:00
Evan Haas
9716a1c3ab translate-c: Add support for cast-to-union
Fixes #10955
2022-02-23 14:11:46 +02:00
Veikka Tuominen
ab4d693cfc re-enable @src behavior test 2022-02-23 10:40:46 +02:00
Veikka Tuominen
92beb2b490 stage2: misc fixes in Sema 2022-02-23 10:40:40 +02:00
xReveres
4a0b037464 wasm: correct shared memory error text 2022-02-23 08:57:20 +01:00
xReveres
fb7cde3071 wasm: shared memory checks 2022-02-23 08:57:20 +01:00
xReveres
b2805666a7 stage1-wasm: implement shared memory 2022-02-23 08:57:20 +01:00
Veikka Tuominen
923b07bac7 stage2: add parameters to fn typeInfo 2022-02-23 09:44:36 +02:00
Veikka Tuominen
f8154905e7 stage1: rename TypeInfo.FnArg to Fn.Param 2022-02-23 09:44:36 +02:00
Felix Queißner
6fdcf1ad2d
std.os.linux.socketpair: fd is an out parameter 2022-02-23 09:32:54 +02:00
Stephen Gutekanst
c577926a7d zig build: style: remove unnecessary constant bindings
Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
2022-02-22 15:49:03 -07:00
Jakub Konka
e5c30eef1f
Merge pull request #10949 from ziglang/x64-print-results
stage2,x64: print test_runner results
2022-02-22 23:06:07 +01:00
Jakub Konka
c64d3b0a96 Skip @src for stage1 too 2022-02-22 22:33:57 +01:00
Jakub Konka
160f657156 Skip unsupported while behavior tests 2022-02-22 22:14:49 +01:00
Jakub Konka
8e4a8771f5 Skip unsupported enum behavior tests 2022-02-22 22:04:32 +01:00
Jakub Konka
8abd30019c x64: completely ignore printing tests on macos until I fix the linker 2022-02-22 21:57:44 +01:00
Jakub Konka
d657ede324 x64: disable printing results on macos until I fix the linker
Hopefully, this will make the CI green, and in the meantime I can
fix the bugs in the MachO linker.
2022-02-22 21:57:44 +01:00
Jakub Konka
25e4b16e25 Port more behavior tests 2022-02-22 21:57:42 +01:00
Jakub Konka
a94267b290 std: export ceil builtins in stage2 2022-02-22 21:56:34 +01:00
Jakub Konka
1bbb886694 Port bitcast.zig tests 2022-02-22 21:56:34 +01:00
Jakub Konka
150006d216 std: enable print results in test_runner for stage2_x86_64 2022-02-22 21:56:34 +01:00
Jakub Konka
3be6c79ca2 x64: spill compare flags between blocks, extern calls, and cmp insts
This is just the first step towards the final solution as to get
here I had omit a safety assert check in `getResolvedInst` helper.
2022-02-22 21:56:34 +01:00
Jakub Konka
b9b4e4671f x64: add naive impl of else in switch 2022-02-22 21:56:34 +01:00
Jakub Konka
2617117221 x64: fix lowering of error unions (we didn't pad to alignment)
* fix returning large values on stack from procedure calls - we
  need to explicitly specify source and dest base registers for
  `genSetStack` as well
2022-02-22 21:56:34 +01:00
Jakub Konka
87a0d754be x64: add basic, naive impl of switch 2022-02-22 21:56:34 +01:00
Jakub Konka
2d3462c79a liveness: add helper for extracting liveness of switch branch 2022-02-22 21:56:34 +01:00
Jakub Konka
5ba66911fa x64: add basic impl of shl for integers 2022-02-22 21:56:34 +01:00
Jakub Konka
71dda25f14 x64: add basic impl of minimum builtin for ints 2022-02-22 21:56:34 +01:00
Jakub Konka
25d313f911 codegen: lower repeated and empty_with_sentinel array type 2022-02-22 21:56:34 +01:00
Jakub Konka
57c9eec232 x64: implement unwrap_err_payload and unwrap_err_err for stack offset 2022-02-22 21:56:34 +01:00
Jakub Konka
f4f23e307c codegen: lower error_set and error_union 2022-02-22 21:56:34 +01:00
Jakub Konka
358b544157 x64: recover address in rdi if was spilled 2022-02-22 21:56:34 +01:00
Jakub Konka
630da643c6 x64: pass pointer to stack for return value in .rdi register 2022-02-22 21:56:34 +01:00
Jakub Konka
478f770053 x64: first, really horrible attempt at returning values on stack 2022-02-22 21:56:34 +01:00
Jakub Konka
e582c0a043 x64: reorder resolving call params: return values first, then params 2022-02-22 21:56:34 +01:00
Jakub Konka
8bc95b22dc x64: sub is non-commutative 2022-02-22 21:56:34 +01:00
Andrew Kelley
b23f10b424 Sema: fix comptime coercion of payload to error union 2022-02-22 13:53:10 -07:00
Andrew Kelley
0d422ce342 Sema: auto-numbered enums increment from last tag value
This matches stage1 and the existing behavior tests.
2022-02-22 12:44:35 -07:00
Motiejus Jakštys
e620b692c6 [std.ArrayList] return explicit errors
All errors from std.ArrayList are allocation errors. Mark them as such.
This is helpful when one wants to obtain a function pointer.
2022-02-22 13:57:51 -05:00
Veikka Tuominen
df38c46bee
Merge pull request #10929 from davidmrt98/cbe
stage2: C backend: fix codegen for field_ptr/elem_ptr values
2022-02-22 15:25:50 +02:00