zig/test
Andrew Kelley 8ce880ca75 avoid calling into stage1 backend when AstGen fails
The motivation for this commit is that there exists source files which
produce ast-check errors, but crash stage1 or otherwise trigger stage1
bugs. Previously to this commit, Zig would run AstGen, collect the
compile errors, run stage1, report stage1 compile errors and exit if
any, and then report AstGen compile errors.

The main change in this commit is to report AstGen errors prior to
invoking stage1, and in fact if any AstGen errors occur, do not invoke
stage1 at all.

This caused most of the compile error tests to fail due to things such
as unused local variables and mismatched stage1/stage2 error messages.
It was taking a long time to update the test cases one-by-one, so I
took this opportunity to unify the stage1 and stage2 testing harness,
specifically with regards to compile errors. In this way we can start
keeping track of which tests pass for 1, 2, or both.
`zig build test-compile-errors` no longer works; it is now integrated
into `zig build test-stage2`.

This is one step closer to executing compile error tests in parallel; in
fact the ThreadPool object is already in scope.

There are some cases where the stage1 compile errors were actually
better; those are left failing in this commit, to be addressed in a
follow-up commit.

Other changes in this commit:

 * build.zig: improve support for -Dstage1 used with the test step.
 * AstGen: minor cosmetic changes to error messages.
 * stage2: add -fstage1 and -fno-stage1 flags. This now allows one to
   download a binary of the zig compiler and use the llvm backend of
   self-hosted. This was also needed for hooking up the test harness.
   However, I realized that stage1 calls exit() and also has memory
   leaks, so had to complicate the test harness by not using this flag
   after all and instead invoking as a child process.
   - These CLI flags will disappear once we start shipping the
     self-hosted compiler as the main compiler. Until then, they can be
     used to try out the work-in-progress stage2.
 * stage2: select the LLVM backend by default for release modes, as long
   as the target architecture is supported by LLVM.
 * test harness: support setting the optimize mode
2021-07-02 13:27:28 -07:00
..
behavior stage2: fix unreachable in union(enum) with anytype payload 2021-06-27 12:26:29 +03:00
src std.build: don't default to static linkage 2021-06-12 14:23:07 +03:00
stage1/c_abi stage1: Fix handling of C ABI parameters split in multiple regs 2021-06-10 12:50:25 -04:00
stage2 avoid calling into stage1 backend when AstGen fails 2021-07-02 13:27:28 -07:00
standalone cleanups related to unused params 2021-06-21 17:03:04 -07:00
assemble_and_link.zig update std lib to new Target API 2020-02-28 14:51:54 -05:00
behavior.zig tagName: return a null-terminated slice 2021-06-16 22:02:42 +01:00
cases.zig avoid calling into stage1 backend when AstGen fails 2021-07-02 13:27:28 -07:00
cli.zig update godbolt test case for unused parameter 2021-06-23 10:44:46 -07:00
compare_output.zig fix unused parameters in compare_output test cases 2021-06-23 10:44:46 -07:00
compile_errors.zig avoid calling into stage1 backend when AstGen fails 2021-07-02 13:27:28 -07:00
gen_h.zig run zig fmt on src/ and test/ 2020-10-31 12:21:49 +02:00
run_translated_c.zig translate-c: Remove usage of extern enum 2021-06-23 08:44:25 +03:00
runtime_safety.zig fix unused variable errors in runtime safety test cases 2021-06-23 10:44:46 -07:00
stack_traces.zig overhaul elf csu (c-runtime startup) logic 2021-05-23 15:38:57 -04:00
standalone.zig std: Fix PIE startup sequence 2021-06-19 18:02:51 +02:00
tests.zig avoid calling into stage1 backend when AstGen fails 2021-07-02 13:27:28 -07:00
translate_c.zig translate-c: Ensure all local variables and function params are used 2021-06-23 10:47:47 -07:00