Commit Graph

10643 Commits

Author SHA1 Message Date
Veikka Tuominen dff32a2cd7 Sema: resolve lazy values in analyzeMinMax
Closes #13797
2022-12-07 14:48:24 +02:00
Veikka Tuominen ddce76059b Sema: add error for @tagName on empty enum 2022-12-07 14:48:24 +02:00
Veikka Tuominen d078d08e4f Sema: export function instead of the constant referencing it
Closes #13706
2022-12-07 14:48:24 +02:00
Veikka Tuominen 92f1a29c40 AstGen: make @compileError operand implicitly comptime
This matches the language reference.
2022-12-07 14:48:24 +02:00
Andrew Kelley 53a9ee699a Merge pull request #13799 from ziglang/close-stage1-issues
close stage1 issues
2022-12-07 03:06:10 -05:00
Casey Banner 8ccb9a6ad3 cache: Fix LockViolation during C compilation paths (#13591)
- C compilation flows didn't hold an exclusive lock on the cache manifest file when writing to it in all cases
- On windows, explicitly unlock the file lock before closing it
2022-12-06 23:15:54 -05:00
Andrew Kelley 50eb7983cd remove most conditional compilation based on stage1
There are still a few occurrences of "stage1" in the standard library
and self-hosted compiler source, however, these instances need a bit
more careful inspection to ensure no breakage.
2022-12-06 20:38:54 -07:00
Andrew Kelley b7b905d227 add behavior test for while(true) not needing else unreachable
closes #707
2022-12-06 17:57:27 -07:00
Andrew Kelley e7d28344fa Merge pull request #13560 from ziglang/wasi-bootstrap
Nuke the C++ implementation of Zig from orbit using WASI
2022-12-06 18:52:39 -05:00
Frank Denis 817cf6a82e Update wasi-libc to 8b7148f69ae241a2749b3defe4606da8143b72e0 (#13793) 2022-12-06 22:48:35 +00:00
Andrew Kelley 3f693cf5d5 CLI: quality of life enhancement for windows CBE behavior tests
When testing with

```
stage4/bin/zig test ../test/behavior.zig -I../test -ofmt=c -target x86_64-windows
```

previously, one would see this message:

```
error: lld-link: subsystem must be defined
```

Now, `--subsystem console` as well as `-lntdll -lkernel32` are on the
`zig run` line, producing a binary.
2022-12-06 12:46:59 -07:00
Jacob Young 91e489174b CBE: avoid trailing space 2022-12-06 12:27:28 -07:00
Jacob Young 3686787f67 CBE: add windows-specific reserved identifiers 2022-12-06 12:27:28 -07:00
Andrew Kelley 823d1e7087 add std.heap.wasm_allocator 2022-12-06 12:27:28 -07:00
Andrew Kelley a3fadd2813 stage2: revert change to handling of --color on
This change has been extracted to #13786 and can be solved separately
than this branch.
2022-12-06 12:15:05 -07:00
Andrew Kelley cb012490ee translate-c: fix wrong logic adjustment
In ea9ad1e85dd5e2ba18e7d55f7a7f9694282159f1, I incorrectly applied
boolean logic to one of the pieces of logic, resulting in a regression
in translate-c.
2022-12-06 12:15:05 -07:00
Jacob Young c8541f0a12 cc: remove argument parsing from only-c builds 2022-12-06 12:15:04 -07:00
Jacob Young 47a2a526e2 test: remove reference to stage1 2022-12-06 12:15:04 -07:00
Jacob Young f421efbcc1 CBE: fix bad local reuse for volatile memset 2022-12-06 12:15:04 -07:00
Andrew Kelley 7ef745db59 Sema: queue type resolution for result of @fieldParentPtr 2022-12-06 12:15:04 -07:00
Andrew Kelley 9cb06f3b8b fix merge conflicts from master branch 2022-12-06 12:15:04 -07:00
Andrew Kelley ef447c3eca redo CMakeLists.txt to use WASI interpreter
current status is that it hits error: OutOfMemory for unknown reasons,
probably due to bugs in the C WASI interpreter port.
2022-12-06 12:15:04 -07:00
Andrew Kelley 8c1c67bdd0 stage2: take advantage of the new WasmAllocator 2022-12-06 12:15:04 -07:00
Andrew Kelley 3dcdd5544f stage2: make --color override apply to std.Progress 2022-12-06 12:15:04 -07:00
Andrew Kelley 3a8117439d allow build-obj and build-exe in -Donly-c builds 2022-12-06 12:15:04 -07:00
Andrew Kelley d5312d53a0 WASI: remove absolute path emulation from std lib
Instead of checking for absolute paths and current working directories
in various file system operations, there is one simple solution: allow
overriding `std.fs.cwd` on WASI.

os.realpath is back to causing a compile error when used on WASI. This
caused a compile error in the Sema handling of `@src()`. The compiler
should never call realpath, so the commit that made this change is
reverted (95ab942184). If this breaks
debug info, a different strategy is needed to solve it other than using
realpath.

I also removed the preopens code and replaced it with something much
simpler. There is no longer any global state in the standard library.

Additionally-
 * os.openat no longer does an unnecessary fstat on WASI when O.WRONLY
   is not provided.
 * os.chdir is back to causing a compile error on WASI.
2022-12-06 12:15:04 -07:00
Andrew Kelley 3ba916584d actually remove stage1 2022-12-06 12:15:04 -07:00
Andrew Kelley db023b98a4 build: introduce -Dwasi-bootstrap option
Also, make -Donly-c prevent Autodoc from being included in the binary.

This produces a 2.6 MiB zig.wasm file. 781 KB if piped through zstd.
2022-12-06 12:15:04 -07:00
Andrew Kelley 28514476ef remove -fstage1 option
After this commit, the self-hosted compiler does not offer the option to
use stage1 as a backend anymore.
2022-12-06 12:15:04 -07:00
Andrew Kelley 36da3000c0 Sema: resolve elem type for non-default aligned ptrs
Before this commit, I observe a crash from this abiSize call because the
element type is a struct that is not yet resolved. This is triggered by
running the behavior tests with -ofmt=c -target x86_64-windows.
2022-12-06 02:54:58 -05:00
Andrew Kelley 80be5e4832 zig cc: fix wrong flag name from earlier commit
In dfe9420244, I made a typo. This commit
corrects it. I tested this commit via a patch to zig-bootstrap.
2022-12-06 00:09:17 -07:00
Frank Denis 861aa98ac2 wasi-libc: define BULK_MEMORY_THRESHOLD for the bulk_memory feature (#13787)
When the bulk_memory feature is enabled, wasi-libc will only use
it if the number of bytes is >= BULK_MEMORY_THRESHOLD

Set it to 32 as in the original wasi-libc Makefile.
2022-12-06 04:05:00 +00:00
Andrew Kelley dfe9420244 zig cc: support -stack in addition to --stack for linker arg 2022-12-05 18:08:31 -07:00
Jakub Konka 12e34e7037 dwarf: pull out debug line program internals into DeclState helpers 2022-12-05 22:35:07 +01:00
Jakub Konka 8796da0283 dwarf: reuse getDbgInfoAtom helper in all of Dwarf.zig
We need to access it outside of `DeclState` too so why not reuse
the helper anyway.
2022-12-05 14:19:22 +01:00
Jakub Konka 3575048c0a Merge pull request #13763 from ziglang/macho-dsym-incr
macho+dsym: refactor and reorganize file layout to support incremental DWARF updates
2022-12-05 13:48:12 +01:00
Jacob Young 4ee79aa33c CBE: revert broken change that got missed 2022-12-04 22:37:48 -05:00
Jacob Young 7d3cc3bc8d CBE: defer invariant local reuse in loops
When a local defined outside a loop dies inside the loop, it can still
be needed on subsequent loop iterations, so reuse of the local must be
deferred until after the loop ends. This causes behavior tests to pass.
2022-12-04 15:57:40 -07:00
Andrew Kelley cc8bcae8c0 CBE: fix liveness issue with wrapping optionals 2022-12-04 15:57:40 -07:00
Andrew Kelley 4a6deaff5f CBE: remove stray comment 2022-12-04 15:57:40 -07:00
Andrew Kelley 701cebeb30 CBE: fix union init wrong field name 2022-12-04 15:57:40 -07:00
Andrew Kelley aa98517b3e CBE: aggregate_init: resolve all operands before processing Liveness 2022-12-04 15:57:40 -07:00
Andrew Kelley 4aae0b09cf CBE and LLVM: handle unused try instructions
In both backends they did not observe the Liveness information for try
instructions. Now they do. For the C backend this is necessary for
correctness; for the LLVM backend, it improves code generation.
2022-12-04 15:57:40 -07:00
Andrew Kelley f2e59e41c1 CBE: fix various regressions caught by behavior tests 2022-12-04 15:57:40 -07:00
Andrew Kelley 6c0a1417c6 CBE: fix static allocs being double allocated 2022-12-04 15:57:40 -07:00
Andrew Kelley da73410e7f CBE: avoid curly inits because they don't work in assignments 2022-12-04 15:57:40 -07:00
Andrew Kelley db1819e8ed CBE: fix use-after-free of Type keys in free_locals map 2022-12-04 15:57:40 -07:00
Andrew Kelley 7bd63a602a CBE: fix assignment expr and switch free tracking 2022-12-04 15:57:40 -07:00
Andrew Kelley 8bfbfa589c CBE: fix clone of freed locals not being deep clone 2022-12-04 15:57:40 -07:00
Andrew Kelley 73a76b45c5 CBE: take advantage of switch_br and cond_br liveness 2022-12-04 15:57:40 -07:00