Commit Graph

16851 Commits

Author SHA1 Message Date
Jakub Konka
beb275b371 Revert "CI: upgrade both host and target tarballs to llvm 13.0.1 x86_64-macos"
This reverts commit 1072d8a065.
2022-02-12 11:17:41 +01:00
Jakub Konka
1072d8a065 CI: upgrade both host and target tarballs to llvm 13.0.1 x86_64-macos 2022-02-12 11:01:10 +01:00
Andrew Kelley
3fdbc3bba8 CI: upgrade x86_64-macos tarball to llvm 13.0.1 2022-02-12 01:09:13 -07:00
joachimschmidt557
2262640e8b stage2 ARM: lower const slices
Follow-up to e1a535360f for ARM

This also fixes some stack offset calculation bugs
2022-02-12 00:01:05 +01:00
Andrew Kelley
a5a7f0ff00 CI: upgrade x86_64-macos tarball to llvm 13.0.1 2022-02-11 15:57:44 -07:00
Jakub Konka
e1a535360f
Merge pull request #10862 from ziglang/elf-lower-slices
stage2: native backends: lower const slices
2022-02-11 15:02:17 +01:00
Jakub Konka
cad3e3e63a x64: enable more behavior tests 2022-02-11 12:49:06 +01:00
Jakub Konka
066758b1a2 macho: correctly lower slices incl reloc and rebase tracking
Match changes required to `Elf` linker, which enable lowering
of const slices on `MachO` targets.

Expand `Mir` instructions requiring the knowledge of the containing
atom - pass the symbol index into the linker's table from codegen
via mir to emitter, to then utilise it in the linker.
2022-02-11 12:16:32 +01:00
Jakub Konka
b9b1ab0240 elf: store pointer relocations indexed by containing atom
In `getDeclVAddr`, it may happen that the target `Decl` has not
been allocated space in virtual memory. In this case, we store a
relocation in the linker-global table which we will iterate over
when flushing the module, and fill in any missing address in the
final binary. Note that for optimisation, if the address was resolved
at the time of a call to `getDeclVAddr`, we skip relocating this
atom.

This commit also adds the glue code for lowering const slices in
the ARM backend.
2022-02-11 10:52:13 +01:00
Jakub Konka
08e2f5d083 codegen: handle lowering of const slice pointers 2022-02-11 10:52:13 +01:00
Andrew Kelley
f0400ad93e
Merge pull request #10857 from Luukdegram/wasm-tests
stage2: Wasm - implement field_ptr
2022-02-10 19:22:23 -05:00
Luuk de Gram
9c6d416bec
Activate passing behavior tests
This moves the single bugs behavior tests to the outer branch and disables the test cases
for all non-passing backends.
For the larger files, we move it up a single branch and disable it for the c backend.
All test cases that do pass for the c backend however, are enabled.
2022-02-10 21:40:06 +01:00
Luuk de Gram
0e2fcab334
wasm: Implement 'field_ptr' constants
This implements the `field_ptr` value for pointers. As the value only provides us with the index,
we must calculate the offset from the container type using said index. (i.e. the offset from a struct field at index 2).

Besides this, small miscellaneous fixes/updates were done to get remaining behavior tests passing:
 - We start the function table index at 1, so unresolved function pointers don't can be null-checked properly.
 - Implement genTypedValue for floats up to f64.
 - Fix zero-sized arguments by only creating `args` for non-zero-sized types.
 - lowerConstant now works for all decl_ref's.
 - lowerConstant properly lowers optional pointers, so `null` pointers are lowered to `0`.
2022-02-10 21:40:06 +01:00
Jakub Konka
e139c41fd8 stage2: handle truncate to signed non-pow-two integers 2022-02-10 15:05:12 +01:00
Andrew Kelley
c10fdde5a6 stage2: LLVM backend: make unnamed struct globals
LLVM union globals have to be lowered as unnamed structs if the
non-most-aligned field is the active tag. In this case it bubbles up so
that structs containing unions have the same restriction.

This fix needs to be applied to optionals and other callsites of
createNamedStruct.

The bug fixed in this commit was revealed in searching for
the cause of #10837.
2022-02-10 00:27:02 -07:00
Jakub Konka
57357c43e3 elf: pad out file to the required size when init data
We need to pad out the file to the required maximum size equal the
final section's offset plus the section's size. We only need to
this when populating initial metadata and only when section header
was updated.
2022-02-10 08:12:02 +01:00
Andrew Kelley
65c812842d freestanding libc: fix missing functions
In the previous commit I got mixed up and cut-pasted instead of
copy-pasting. In this commit I made c_stage1.zig additionally included
for stage1 and everything else included for both. So moving forward we
move stuff over from c_stage1.zig to c.zig instead of copying.
2022-02-09 19:13:53 -07:00
Andrew Kelley
f2f1c63daf stage2: add log and logf to freestanding libc 2022-02-09 18:52:32 -07:00
Sebsatian Keller
f5471299d8
stage 1: improve error message if error union is cast to payload (#10770)
Also: Added special error message for for `?T` to `T` casting
2022-02-09 20:35:53 -05:00
Andrew Kelley
1e5a494603 Sema: implement comptime ptr store to optional payload
and error union payload
2022-02-09 18:29:51 -07:00
John Schmidt
7f0cf395aa stage2: implement all builtin floatops for f{16,32,64}
- Merge `floatop.zig` and `floatop_stage1.zig` since most tests now pass
  on stage2.
- Add more behavior tests for a bunch of functions.
2022-02-09 20:29:41 -05:00
Andrew Kelley
44b5fdf326 Revert "ci: azure: split build-and-test step"
This reverts commit 846eb70182.

This did not properly translate the upload portion of the CI script to
powershell which broke our CI pipeline.
2022-02-09 18:26:56 -07:00
Andrew Kelley
274b9d5c1d ci: work around azure networking issue 2022-02-09 16:42:15 -07:00
Andrew Kelley
2836cd5fbd CLI: ignore -lgcc_s when it is redundant with compiler-rt
For some projects, they can't help themselves, -lgcc_s ends up on the
compiler command line even though it does not belong there. In Zig we
know what -lgcc_s does. It's an alternative to compiler-rt. With this
commit we emit a warning telling that it is unnecessary to put such
thing on the command line, and happily ignore it, since we will fulfill
the dependency with compiler-rt.
2022-02-09 11:38:33 -07:00
Andrew Kelley
db56d74a3b
Merge pull request #10834 from ziglang/fix-x86-i128-c-abi
stage1: fix x86 i128 C ABI for extern structs
2022-02-09 13:23:20 -05:00
Andrew Kelley
92cb17a331 CI: windows: update env var names 2022-02-09 10:41:12 -07:00
Jakub Konka
2d39142133
Merge pull request #10843 from ziglang/fix-1914
stage2: handle decl ref to void types
2022-02-09 18:12:37 +01:00
Jakub Konka
ec3e638b97 elf: fix unaligned file offset of moved phdr containing GOT section 2022-02-09 13:22:50 +01:00
Jakub Konka
e588e3873c stage2: export trunc, truncf and truncl 2022-02-09 10:28:48 +01:00
Jakub Konka
b28e9e42e0 stage2: resolve struct type when lowering struct_field_* 2022-02-09 10:28:48 +01:00
Jakub Konka
e5ce87f1b1 stage2: handle decl ref to void types
Fixes behavior test 1914
2022-02-09 10:28:48 +01:00
Jakub Konka
4d1e5ef730
Merge pull request #10846 from ziglang/x64-macho-bringup
stage2: handle direct and got load for stack args on x86_64-macos
2022-02-09 08:17:29 +01:00
Andrew Kelley
97019bc56d Sema: handle inferred error set tail call
When Sema sees a store_node instruction, it now checks for
the possibility of this pattern:
  %a = ret_ptr
  %b = store(%a, %c)
Where %c is an error union. In such case we need to add to the
current function's inferred error set, if any.

Coercion from error union to error union will be handled ideally if the
operand is comptime known. In such case it does the appropriate
unwrapping, then wraps again.

In the future, coercion from error union to error union should do the
same thing for a runtime value; emitting a runtime branch to check if
the value is an error or not.

`Value.arrayLen` for structs returns the number of fields. This is so
that Liveness can use it for the `vector_init` instruction (soon to be
renamed to `aggregate_init`).
2022-02-09 00:10:53 -07:00
Andrew Kelley
f4fa32a632 Sema: fix @typeInfo for pointers returning 0 alignment 2022-02-08 23:02:13 -07:00
Andrew Kelley
1678825c14 Sema: fix @ptrCast from slices
Also, fix allocations in comptime contexts with alignments.
2022-02-08 22:51:46 -07:00
Andrew Kelley
59418d1bf6 Sema: fix Value.intFitsInType for comptime int 2022-02-08 22:09:41 -07:00
billzez
470c8ca48c
update RwLock to use static initialization (#10838) 2022-02-08 23:35:48 -05:00
Andrew Kelley
77a6031edb C ABI: these tests are not passing yet on Windows
I was too greedy
2022-02-08 21:15:00 -07:00
Andrew Kelley
08808701d2 C ABI tests: give a clue in addition to "test failure" 2022-02-08 21:12:50 -07:00
Andrew Kelley
a35eb9fe8a c_abi tests: allow passing standard target options 2022-02-08 21:12:32 -07:00
Andrew Kelley
a67893b0e1 stage1: fix x86_64-windows C ABI classification logic
16 bytes vectors are special cased because compiler-rt currently relies
on this.
2022-02-08 21:11:53 -07:00
Andrew Kelley
e06ac9537e stage2: fix x86_64-windows C ABI
It didn't return integer status for pointers and also it incorrectly
returned memory for optionals sometimes.
2022-02-08 21:10:29 -07:00
Andrew Kelley
61ed4fe07a stage1: fix x86 i128 C ABI for extern structs
closes #10445
2022-02-08 20:10:55 -07:00
Andrew Kelley
7c1061784b stage2: fix inferred comptime constant locals
`const` declarations inside comptime blocks were not getting properly
evaluated at compile-time. To accomplish this there is a new ZIR
instruction, `alloc_inferred_comptime`. Actually we already had one
named that, but it got renamed to `alloc_inferred_comptime_mut` to match
the naming convention with the other similar instructions.
2022-02-08 20:03:17 -07:00
Andrew Kelley
210ee1067b update more API usage of std.Progress
fixes regression introduced in 5a00e24963
2022-02-08 17:49:40 -07:00
Hadrien Dorio
846eb70182 ci: azure: split build-and-test step
replace the .bat script by a pwsh script
2022-02-08 19:47:46 -05:00
Andrew Kelley
5a00e24963 std.Progress: make the API infallible
by handling `error.TimerUnsupported`. In this case, only explicit calls
to refresh() will cause the progress line to be printed.
2022-02-08 17:26:55 -07:00
Andrew Kelley
fd6c351263 cmake: fix -DZIG_SINGLE_THREADED option
It was still passing --single-threaded instead of -fsingle-threaded.
2022-02-08 17:22:11 -07:00
Jakub Konka
c689df1215 stage2: disable some tests on x86_64-macos 2022-02-08 23:59:10 +01:00
Jakub Konka
f1d2141849 stage2: handle direct and got load for stack args 2022-02-08 23:48:42 +01:00