This supports the case when it is known that LLVM, Clang, LLD were built
with Clang (or `zig c++`). This commit updates the Linux CI script to
pass this since we build using a zig tarball.
* rework `build_options` to integrate with the FileSource abstraction
* support mapping as an arbitrarily named package
* support mapping to multiple different artifacts
* use hash of contents for options filename
This way, we can explicitly signal if a test requires the presence
of macOS SDK to build. For instance, when testing our in-house
MachO linker for correctly linking Objective-C, we require the
presence of the SDK on the host system, and we can enforce this
with `-Denable-macos-sdk` flag to `zig build test-standalone`.
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
Before this change, when one or more of name or value are not known at
comptime, build.zig files must allocate and do the concatanation, which can be
cumbersome, and also adds a redundant allocation when name and value are
slices. The new version only does a single allocation directly in the builder's
allocator to concatonate name and value.
The origional behavior is available in defineCMacroRaw, for use in situations
such as parseing c compiler arguments.
Additionally, several places have been updated to use the new funtions.
Now that `@import` of a non-existent file name is a compile error, the
Zig installation needs to include files that end with test.zig. However
we still want to avoid bloat in the installation size, so we blank them
out instead of omitting them entirely.
Now AstGen of the full standard library can complete successfully on a
Zig installation rather than erroring out with file not found.
Conflicts:
* build.zig
* src/Compilation.zig
* src/codegen/spirv/spec.zig
* src/link/SpirV.zig
* test/stage2/darwin.zig
- this one might be problematic; start.zig looks for `main` in the
root source file, not `_main`. Not sure why there is an underscore
there in master branch.
* `-lc++` now implies `-lc`.
* `-lunwind` is now pulled out into a separate `link_libunwind` flag in
the frontend driver code. This allows a project to request zig to
provide libunwind even if the default situation that causes it to be
implicitly added, is not active.
* build.zig: ask for -lunwind when building the self-hosted compiler on
Linux. Otherwise we get linker errors with unresolved symbols to
libunwind.
* for cross testing stage2 tests, we use `darling shell` command
since the path to the tested binary is relative to cwd
* for the `zig test` command, we simply use `darling` since the
path to the binary is absolute
With this change, it is now possible to use zig-bootstrap as the
initial C/C++ compiler, and then build stage2 with the resultant
stage1 without the need to link any system libs!
On CI, we have been running into OOM issues when running the test
suite on Windows for quite some time.
Unfortunately, we are very close to having the same issues on Linux
as well. Some additional comptime work immediately makes these builds
fail as well.
Add a new `test-toolchain` step, that tests everything except `std.*`
and documentation.
On CI, call `test-toolchain`, `test-std` and `docs` separately
instead of the `test` big hammer that emcompasses all of them.
Change the special case we made for Windows to the same code as other
platforms.
This is a stopgap measure that stage2 will eventually make useless.
Until then, it gives us some headroom.
Change `linux_script` by the way to only output the log of failing
steps. This shrinks the Linux CI log from a bazilion lines down to
something more humanely manageable.
* AstGen: emit decl lookup ZIR instructions rather than directly
looking up decls in AstGen. This is necessary because we want to
reuse the same immutable ZIR code for multiple generic instantiations
(and comptime function calls).
* AstGen: fix using members_len instead of fields_len for struct decls.
* structs: the struct_decl ZIR instruction is now also a block. This is
so that the type expressions, default field value expressions, and
alignment expressions can be evaluated in a scope that contains the
decls from the struct namespace itself.
* Add "std" and "builtin" packages to the builtin package.
* Don't try to build glibc, musl, or mingw-w64 when using `-ofmt=c`.
* builtin.zig is generated without `usingnamespace`.
* builtin.zig takes advantage of `std.zig.fmtId` for CPU features.
* A first pass at implementing `usingnamespace`. It's problematic and
should either be deleted, or polished, before merging this branch.
* Sema: allow explicitly specifying the namespace in which to look up
Decls. This is used by `struct_decl` in order to put the decls from
the struct namespace itself in scope when evaluating the type
expressions, default value expressions, and alignment expressions.
* Module: fix `analyzeNamespace` assuming that it is the top-level root
declaration node.
* Sema: implement comptime and runtime cmp operator.
* Sema: implement peer type resolution for enums and enum literals.
* Pull in the changes from master branch:
262e09c482.
* ZIR: complete out simple_ptr_type debug printing
* Add some more tests for the sqrt/sqrtf implementations.
The idea is to cross-check the software impl with the HW one whenever
possible.
* Fix a broken test, oops.
Previously you had to recompile if you wanted to change the log scopes
that get printed. Now, log scopes can be set at runtime, and -Dlog
controls whether all logging is available at runtime.
Purpose here is a nicer development experience. Most likely stage2
developers will always want -Dlog enabled and then pass --debug-log
scopes when debugging particular issues.
* remove the -Ddump-zir thing. that's handled through --verbose-ir
* rework Fn to have an is_inline flag without requiring any more memory
on the heap per function.
* implement a rough first version of dumping typed zir (tzir) which is
a lot more helpful for debugging than what we had before. We don't
have a way to parse it though.
* keep track of whether the inline-ness of a function changes because
if it does we have to go update callsites.
* add compile error for inline and export used together.
inline function calls and comptime function calls are implemented the
same way. A block instruction is set up to capture the result, and then
a scope is set up that has a flag for is_comptime and some state if the
scope is being inlined.
when analyzing `ret` instructions, zig looks for inlining state in the
scope, and if found, treats `ret` as a `break` instruction instead, with
the target block being the one set up at the inline callsite.
Follow-up items:
* Complete out the debug TZIR dumping code.
* Don't redundantly generate ZIR for each inline/comptime function
call. Instead we should add a new state enum tag to Fn.
* comptime and inlining branch quotas.
* Add more test cases.
restore "Comply with semantic versioning pre-release format"
restore "stage2: SemVer compliance for development builds"
restore "Remove 'g' prefix from commit hash in Zig semver"
This reverts commit d96d8639e5.
This reverts commit e8810f5794.
This reverts commit 9afe5859a3.
This broke compiling with -Dstage1 on Windows, because it added the
cpp_source_files to the compilation multiple times.
This reverts commit c81ae52ee0.