Commit Graph

3569 Commits

Author SHA1 Message Date
Andrew Kelley
84704ef43e stage1: LLVM code for @tagName not emitting null byte
Thanks LemonBoy for the patch.
2021-12-03 16:50:20 -07:00
Jonathan Marler
7659229edc std.build.InstallRawStep: allow custom dest_dir
I'm working on a build.zig file where I'm leveraging InstallRawStep but I'd like to change the install dir.  This allows the install dir to be changd and also enhances InstallRawStep to add more options in the future by putting them into a struct with default values.  This also removes the need for an extra addInstallStepWithFormat function in build.zig.
2021-12-03 12:56:49 -08:00
Andrew Kelley
b24cbecdb2 zig build: promote qemu, wine, wasmtime, darling, and rosetta
from zig-specific options to generally recognized zig build options that
any project can take advantage of. See the updated usage text for more
details.
2021-12-02 15:46:22 -07:00
Matthew Borkowski
c98b020ce2 parse.zig: make chained comparison operators a parse error 2021-12-02 11:59:29 -08:00
Andrew Kelley
42db515665 disable failing @mulAdd behavior test for aarch64-macos
See #9900
2021-12-01 17:30:41 -08:00
Jakub Konka
cf4423bb33 Remove .disable_native for x86_64-macos as it's fixed now
Add `aarch64-macos-gnu` corresponding test case.

Fix rebase gone wrong.
2021-12-02 00:32:56 +01:00
Jakub Konka
852841fd1f Make Rosetta availability declarative by the user
Like QEMU or Wine, you need to declare you want Rosetta
enabled for running tests/build artifacts via `-Denable-rosetta`
flag.
2021-12-02 00:22:09 +01:00
Lee Cannon
066eaa5e9c
allocgate: change resize to return optional instead of error 2021-11-30 23:45:01 +00:00
Lee Cannon
80bbf234e0
allocgate: fix failing tests 2021-11-30 23:32:48 +00:00
Lee Cannon
1093b09a98
allocgate: renamed getAllocator function to allocator 2021-11-30 23:32:47 +00:00
Lee Cannon
75548b50ff
allocgate: stage 1 and 2 building 2021-11-30 23:32:47 +00:00
Lee Cannon
85de022c56
allocgate: std Allocator interface refactor 2021-11-30 23:32:47 +00:00
Andrew Kelley
1e0addcf73 put the passing stage2 behavior tests back
This mostly reverts commit 692c254336.

The test "for loop over pointers to struct, getting field from struct
pointer" is still failing on the CI so that one is not moved over.
2021-11-30 16:15:42 -07:00
Andrew Kelley
692c254336 Revert "I found some more passing behavior tests"
This reverts commit 0a9b4d092f.

Hm, these are all passing for me locally. I'll have to do some
troubleshooting to figure out which one(s) are failing on the CI.
2021-11-30 00:19:37 -07:00
Andrew Kelley
902df103c6 std lib API deprecations for the upcoming 0.9.0 release
See #3811
2021-11-30 00:13:07 -07:00
Andrew Kelley
173d56213b improve behavior test coverage for overflow arithmetic 2021-11-29 23:21:07 -07:00
Andrew Kelley
0a9b4d092f I found some more passing behavior tests 2021-11-29 22:36:52 -07:00
Andrew Kelley
d3426ce634 AstGen: require binary operations to have reachable operands 2021-11-29 13:21:36 -07:00
Luuk de Gram
adf059f272
wasm: Update wasm stage2 test backend to use 'main' 2021-11-29 08:05:51 +01:00
Andrew Kelley
17f057c556 stage2: implement @typeName
* stage1: change the `@typeName` of `@TypeOf(undefined)`,
   `@TypeOf(null)`, and `@TypeOf(.foo)` to match stage2.
 * move passing behavior tests to the passing-for-stage2 section.
2021-11-27 00:27:52 -07:00
Andrew Kelley
f0deef1d79 Sema: fix analyzeBlockBody logic
Previously, when a coercion needed to be inserted into a break
instruction, the `br` AIR instruction would be rewritten so that the
block operand was a sub-block that did the coercion. The problem is that
the sub-block itself was never added to the parent block, resulting in
the `br` instruction operand being a bad reference.

Now, the `br` AIR instruction that needs to have coercion instructions
added is replaced with the sub-block itself with type `noreturn`, and
then the sub-block has the coercion instructions and a new `br`
instruction that breaks from the original block.

LLVM backend needed to be fixed to lower `noreturn` blocks without
emitting an unused LLVM basic block.
2021-11-26 23:17:01 -07:00
Andrew Kelley
67b201982b stage1: fix exporting enums
After extern enums were removed, stage1 was left in an incorrect state
of checking for `extern enum` for exported enums. This commit fixes it
to look for an explicit integer tag type instead, and adds test coverage
for the compile error case as well as the success case.

closes #9498
2021-11-25 18:20:39 -07:00
Andrew Kelley
b560f46c87 stage2: fix unwrap function call with optional pointer return value 2021-11-24 22:44:33 -07:00
Andrew Kelley
e266ede6e3 stage2: fix cleanup code for @import errors
When adding test coverage, I noticed an inconsistency in which source
location the compile error was pointing to for `@embedFile` errors vs
`@import` errors. They now both point to the same place, the string
operand.

closes #9404
closes #9939
2021-11-24 19:10:58 -07:00
Andrew Kelley
20cc7af8e6 stage2: support LLD -O flags on ELF
In 7e23b3245a I made -O flags to the
linker emit a warning that the argument does nothing. That was not
correct however; LLD does have some logic that does different things
depending on -O0, -O1, and -O2. It defaults to -O1, and it does less
optimizations with -O0 and more with -O2.

With this commit, e.g. `-Wl,-O1` is supported by the `zig cc` frontend,
and by default we pass `-O0` to LLD in debug mode, and `-O3` in release
modes.

I also fixed a bug in the LLD ELF linker line which was incorrectly
passing `-O` flags instead of `--lto-O` flags for LTO.
2021-11-24 18:46:32 -07:00
Andrew Kelley
02b8d88153 stage2: add test coverage for @embedFile outside package path
closes #6662
2021-11-24 14:57:13 -07:00
Andrew Kelley
c42763f8cc AstGen: use reachableExpr for return operand
Related: #9630
2021-11-24 14:47:33 -07:00
Scibuild
2e15a404e2 C backend: errors and optionals
* bitcast treats all pointers as pointers
 * correctly unwrapping error unions with pointers
 * equality operators for primitive optional types
2021-11-23 13:46:56 -07:00
Andrew Kelley
e08b6149ab Sema: fix alignment of type-inferred locals 2021-11-22 20:30:20 -07:00
Andrew Kelley
e8b9942873 add more alignment behavior test coverage 2021-11-22 20:12:19 -07:00
Andrew Kelley
af1a5751d9
Merge pull request #10165 from jmc-88/cbe
CBE: add .optional_single_mut_pointer and .optional_single_const_pointer to Type.childType
2021-11-22 21:36:24 -05:00
Kirk Scheibelhut
065f40a3c5 stage1: improve packed struct array padding error message 2021-11-22 21:33:08 -05:00
Andrew Kelley
11330cbcc5
Merge pull request #10201 from Snektron/stage2-more-coercion
stage2: more in-memory coercion
2021-11-22 19:00:30 -05:00
Stephen Gutekanst
9836f1b2f9
add support for compiling Objective-C++ code (#10096)
* add support for compiling Objective-C++ code

Prior to this change, calling `step.addCSourceFiles` with Obj-C++ file extensions
(`.mm`) would result in an error due to Zig not being aware of that extension.
Clang supports an `-ObjC++` compilation mode flag, but it was only possible to use
if you violated standards and renamed your `.mm` Obj-C++ files to `.m` (Obj-C) to
workaround Zig being unaware of the extension.

This change makes Zig aware of `.mm` files so they can be compiled, enabling compilation
of projects such as [Google's Dawn WebGPU](https://dawn.googlesource.com/dawn/) using
a `build.zig` file only.

Helps hexops/mach#21

Signed-off-by: Stephen Gutekanst <stephen@hexops.com>

* test/standalone: add ObjC++ compilation/linking test

Based on the existing objc example, just tweaked for ObjC++.

Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
2021-11-22 08:44:49 +01:00
Robin Voetter
2b589d71fb stage2: move some tests which are now passing 2021-11-22 04:36:57 +01:00
Robin Voetter
cb248898ab sema: error union in-memory coercion 2021-11-22 03:21:31 +01:00
Luuk de Gram
deb8d0765b
wasm: Fix text cases and add pointer test cases
Ensure all previous test cases are still passing, as well as add some basic tests for now
for testing pointers to the stack.

This means we can start implementing wasm's C ABI found at: https://github.com/WebAssembly/tool-conventions/blob/main/BasicCABI.md

We also simplified the block logic by always using 'void' block types and instead writing the value to a local,
which can then be referenced by continues instructions, as done currently by AIR.
Besides this, we also no longer need to insert blocks at an offset, as we simply write the saved temporary
after we create the block.
2021-11-21 21:07:55 +01:00
Evan Haas
c6b4fe0066 translate-c: coerce boolean results to c_int when negated
Fixes #10175
2021-11-20 19:52:06 -05:00
Evan Haas
3fefdc1a0b translate-c: Allow negative denominator in remainder (%) operator
Fixes #10176
2021-11-20 13:52:07 -05:00
joachimschmidt557
e8112f7744 stage2 RISCV64: implement basic function prologue and epilogue 2021-11-20 19:25:59 +01:00
Jakub Konka
696e51be49 stage2: re-enable all tests
I've committed what I didn't want to by mistake...
2021-11-19 22:41:10 +01:00
Jakub Konka
ad5533fdfb stage2,x86_64: revert fixing callee preserved regs
This will require further rework in the codegen so reverting for now.
2021-11-19 22:18:56 +01:00
Jacob G-W
149bc79486 add tests for previous commit 2021-11-19 09:38:36 +01:00
Daniele Cocca
b3f4abbc5a CBE: mark align.zig and error.zig as passing
Newly passing as of 3794a32d89.
2021-11-17 23:43:19 +00:00
Andrew Kelley
09588c795c stage2: LLVM backend: memset to 0xaa for undefined stores
Also support `one` and `int_big_positive` tags for const pointers.
2021-11-16 17:46:39 -07:00
Drew P
68fe391de0 typo 2021-11-16 16:51:31 -07:00
Drew P
30ed91b7b9 fix tests failing on stage2 release modes due to setRuntimeSafety not being recognized 2021-11-16 16:51:31 -07:00
drew
0249344a47 cast -> cast_llvm, cast_c -> cast (doesn't work on LLVM backend) 2021-11-16 16:51:31 -07:00
drew
f33af8f071 fix array airStoreUndefined for arrays 2021-11-16 16:51:31 -07:00
drew
cf99afc525 add generics behavior test
-airLoad and airStore now properly report an error if they are used with an array, instead of having the C compiler emit a vague error
-airStoreUndefined now works with array types
-structFieldPtr now works with array types, allowing generics' tests to pass
2021-11-16 16:51:31 -07:00