17160 Commits

Author SHA1 Message Date
Veikka Tuominen
ee149aaa03 stage2: actually coerce in coerce_result_ptr at comptime 2022-02-26 12:51:23 -07:00
Andrew Kelley
b3aa1ab693
Merge pull request #10994 from Vexu/typeof-scope
stage2: `@TypeOf` improvements
2022-02-26 14:47:43 -05:00
Veikka Tuominen
315d4e8442 stage2: do not require function when evaluating typeOf
We only care about the instructions type; it will never actually be codegen'd.
2022-02-26 18:08:31 +02:00
Veikka Tuominen
ff72b8a819 stage2: evaluate TypeOf arguments in a separate scope 2022-02-26 18:08:11 +02:00
Al Hoang
db82c1b982 add constant for haiku
* re-enable zig build on haiku
2022-02-26 10:53:13 +02:00
Endel Dreyer
cd9a6fed4f fix typo on Thread's getHandle docs 2022-02-26 10:48:37 +02:00
Jakub Konka
0474943ddf
Merge pull request #10991 from ziglang/macho-pointer-rebase 2022-02-26 08:19:01 +01:00
Jakub Konka
e0f5627d4a x64+aarch64: check for pointer to zero-bit type when lowering decl
Unless the pointer is a pointer to a function, if the pointee type
has zero-bits, we need to return `MCValue.none` as the `Decl` has
not been lowered to memory, and therefore, any GOT reference will be
wrong.
2022-02-25 21:59:19 +01:00
Jakub Konka
4b14384989 aarch64: check if type has runtime bits before allocating mem ptr 2022-02-25 21:59:19 +01:00
Jakub Konka
1b8ed7842c macho: redo selection of segment/section for decls and consts
* fix alignment issues for consts with natural ABI alignment not
  matching that of the `ldr` instruction in `aarch64` - solved by
  preceeding the `ldr` with an additional `add` instruction to form
  the full address before dereferencing the pointer.
* redo selection of segment/section for decls and consts based on
  combined type and value
2022-02-25 21:59:19 +01:00
Veikka Tuominen
bf6540ce50 Revert "stage2: make array len field type usize to match stage1"
This reverts commit 73bf418eb16a3e385218400cdc184f5d5e5aeaad.
2022-02-25 11:33:53 +02:00
Veikka Tuominen
73bf418eb1 stage2: make array len field type usize to match stage1
match stage1 behavior to avoid issues in standard library.
2022-02-25 11:25:56 +02:00
Luuk de Gram
0147eb9b58 wasm: Fix error union's size/alignment
Previously error unions were packed in memory. Now each 'field' is correctly
aligned to the error union's alignment.
2022-02-25 09:33:15 +01:00
Luuk de Gram
f4adb53bcf wasm: Refactor lowerUnnamedConst
Rather than ping ponging between codegen and the linker to generate the symbols/atoms
for a local constant and its relocations. We now create all neccesary objects within the linker.

This simplifies the code as we can now simply call `lowerUnnamedConst` from anywhere in codegen,
allowing us to further improve lowering constants into .rodata so we do not have to sacrifice
lowering certain types such as decl_ref's where its type is a slice.
2022-02-25 09:33:15 +01:00
Andrew Kelley
27eb42c15e Sema: implement tupleFieldVal, fix comptime elem_ptr 2022-02-24 22:28:37 -07:00
Andrew Kelley
adb746a701 stage2: improved handling of store_to_block_ptr
* AstGen: remove the setBlockBodyEliding function. This is no longer
   needed after 63788b2a511eb87974065a052e2436b0c6202544.
 * Sema: store_to_block_ptr instruction is handled as
   store_to_inferred_ptr or store, as necessary.
2022-02-24 22:28:37 -07:00
protty
5d30e8016d
time: introduce Instant (#10972) 2022-02-24 18:51:44 -05:00
Veikka Tuominen
63788b2a51 stage2: change how stale store_to_block_ptrs are detected
Instead of explicitly setting lhs to .none,
check if the lhs instruction was analyzed.
This simpler approach also handles stores from nested blocks correctly.
2022-02-24 18:32:08 -05:00
Isaac Freund
52a2aa11e2 std: work around current packed struct situation
As of 6249a24, align() is not allowed on packed struct fields
and as such the align(4) was removed from the first field of
EdidOverrideProtocolAttributes. The endgame here is packed struct
backed by explicit integers, in this case a u32, but until that
is implemented put the align(4) on the pointer to avoid breaking
someone's UEFI code in a hard to debug way.
2022-02-24 16:08:37 -05:00
Andrew Kelley
e06cb31659
Merge pull request #10982 from Vexu/stage2
stage2: implement fieldParentPtr
2022-02-24 15:52:56 -05:00
Andrew Kelley
5ab5e2e673 Revert "Merge pull request #10950 from hexops/sg/responsefiles"
This reverts commit 136a43934bc08dc3aee85f1182904b97456601d3, reversing
changes made to 9dd839b7ed15d1191f3303d069cffe0473e03e83.

This broke the behavior of `zig run`.
2022-02-24 12:11:11 -07:00
Veikka Tuominen
cbd5d6c704 spirv spec: do not align packed struct fields 2022-02-24 19:48:34 +02:00
Veikka Tuominen
b034c45b2b stage2: implement fieldParentPtr 2022-02-24 19:48:34 +02:00
Andrew Kelley
6249a24e81 stage2: integer-backed packed structs
This implements #10113 for the self-hosted compiler only. It removes the
ability to override alignment of packed struct fields, and removes the
ability to put pointers and arrays inside packed structs.

After this commit, nearly all the behavior tests pass for the stage2 llvm
backend that involve packed structs.

I didn't implement the compile errors or compile error tests yet. I'm
waiting until we have stage2 building itself and then I want to rework
the compile error test harness with inspiration from Vexu's arocc test
harness. At that point it should be a much nicer dev experience to work
on compile errors.
2022-02-23 23:59:25 -07:00
Mitchell Hashimoto
65c0475970 stage2: peer type resolution *[N]T and *[M]T to []const T 2022-02-24 08:50:26 +02:00
Jakub Konka
ffb7ac6755 elf: use fully qualified decl names in the linker 2022-02-24 00:01:11 +01:00
Jakub Konka
9d098318e2
Merge pull request #10977 from joachimschmidt557/stage2-aarch64
stage2 AArch64: more support for PIE targets (Mach-O)
2022-02-24 00:00:15 +01:00
Jakub Konka
136a43934b
Merge pull request #10950 from hexops/sg/responsefiles
Do not fail to build if 'zig build-lib' etc. arguments exceed OS limits
2022-02-23 22:54:25 +01:00
Jakub Konka
9dd839b7ed
Merge pull request #10976 from ziglang/x64-macos-fixes
x64: print test runner results on macos
2022-02-23 22:40:06 +01:00
Jan Philipp Hafer
5d89955543 compiler_rt: specify goals, organize README and compiler_rt.zig
* goals
  - zig as linker for object files generated by other compilers
  - zig-specific runtime features for eventual standardisation

* changes
  - missing routines are marked with `missing`
  - structure inspired by libgcc docs, but improved order and wording
  - rename misspelled functions
  - reorder and rephrase compiler_rt.zig to reflect documentation
  - potential decimal float or fixed-point arithmetic support:
    * 'Decimal float library routines' ca. 120 functions
    * 'Fixed-point fractional library routines' ca. 300 functions

thanks to @Vexu for multiple reviews and @scheibo for review
2022-02-23 16:38:51 -05:00
Andrew Kelley
ecf56d85ef
Merge pull request #10969 from Vexu/stage2
stage2: fn typeinfo params
2022-02-23 16:10:17 -05:00
joachimschmidt557
f91fe9afb9
stage2 AArch64: more support for MCValue.got_load and direct_load 2022-02-23 21:58:13 +01:00
joachimschmidt557
4683f94463
stage2 AArch64: remove MIR load_memory instruction
This instruction now just represents loading from a hard-coded adrress
after extracting the other use cases for load_memory into load_got and
load_direct.
2022-02-23 21:57:59 +01:00
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