This requires using -Dstatic-llvm and setting the search prefix and the
target, just like it is required for building stage2 and stage3. This
prevents Zig from trying to integrate with the system, which would
trigger an error due to the `cc` command not being installed.
closes#12144
* Use a debug build of stage3 instead of a debug build of stage2 for
our self-hosted compiler test coverage.
* Move coverage from stage1 to stage3 for:
- building self-hosted without LLVM
- building self-hosted for 32-bit arm
- test-compiler-rt
- test-behavior
- test-std
- test-compare-output
- test-asm-link
- test-fmt
* test/link: initial wasm support
This adds basic parsing and dumping of wasm section so they
can be tested using the new linker-test infrastructure.
* test/link: all wasm sections parsing and dumping
We now parse and dump all sections for the wasm binary format.
Currently, this only dumps the name of a custom section.
Later this should also dump symbol table, name, linking metadata and relocations.
All of those live within the custom sections.
* Add wasm linker test
This also fixes a parser mistake in reading the flags.
* test/link: implement linker tests wasm & fixes
Adds several test cases to test the wasm self-hosted linker.
This also introduces fixes that were caught during the implementation
of those tests.
* test-runner: obey omit_stage2 for standalone
When a standalone test requires stage2, but stage2 is omit
from the compiler, such test case will not be included as part
of the test suite that is being ran. This is to support CI's
where we omit stage2 to lower the memory usage.
Prior to this change we would assume the ABI for Apple targets to
be GNU which could result in subtle errors in LLVM emitting calls
to non-existent system libc provided functions such as `_sincosf`
which is a GNU extension and as such is not provided by macOS for example.
This would result in linker errors where the linker would not be
able to find the said symbol in `libSystem.tbd`.
With this change, we now correctly identify macOS (and other Apple
platforms) as having ABI `unknown` which translates to unspecified
in LLVM under-the-hood:
```
// main.ll
target triple = "aarch64-unknown-macos-unknown"
```
Note however that we never suffix the target OS with target version
such as `macos11` or `macos12` which means we fail to instruct LLVM
of potential optimisations provided by the OS such as the availability
of function `___sincosf_stret`. I suggest we investigate that in a
follow-up commit.
* migrate runtime safety tests to the new test harness
- this required adding compare output / execution support for stage1
to the test harness.
* rename `zig build test-stage2` to `zig build test-cases` since it now
does quite a bit of stage1 testing actually. I named it this way
since the main directory in the source tree associated with these
tests is "test/cases/".
* add some documentation for the test manifest format.
stage2: change logic for detecting whether the main package is inside
the std package. Previously it relied on realpath() which is not portable.
This uses resolve() which is how imports already work.
* stage2: fix cleanup bug when creating Module
* flatten lib/std/special/* to lib/*
- this was motivated by making main_pkg_is_inside_std false for
compiler_rt & friends.
* rename "mini libc" to "universal libc"
We can't yet run the behavior tests with stage3, but at least we can run
them with stage2, and we can use the proper test matrix.
This commit also adds use_llvm and ofmt to the zig build system.
This change adds a "--exclude" parameter to zig format, which can be
used to make sure that it does not process certain files or folders
when recursively walking a directory.
To do this, we simply piggy-back on the existing "seen" logic in zig
fmt and mark these files/folders as seen before processing begins.
using the provided -L directories before checking if we need to integrate
with system library paths. This prevents false positive of invoking
system cc to find native paths when in fact all dependencies are
satisfied by -L (or --search-prefix to zig build).
* build.zig: remove detour through zig0. I'll add it back as an option
later. This means you can build stage1 with a freshly built zig
without detouring through zig0 again.
* remove unused file windows_script.bat
* drone.yml: remove unnecessary steps
* ninja doesn't need a jobs parameter
* build the release version of zig with zig build instead of cmake.
* build stage2 with -Dstatic-llvm -Duse-zig-libcxx
* Test everything on the Linux CI even if we can't run it, because it's
our fastest machine.
* Test stage2 using a build of stage2 (instead of using `-fno-stage1`)
so that compiler-rt is also built with stage2.
* Additionally test running x86_64-macos on the macOS CI, both the LLVM
backend and x86_64 backend.
- Correctly load slice value on stack
- Implement WrapErrorUnionErr and payload
- Implement trunc, fix sliceLen and write undefined
- Implement slice as return type and argument
Note: This also fixes a memory leak for inferred error sets, and for usingnamespace
This reverts commit 725267f7c2, reversing
changes made to 2dae860de3.
This test is failing:
```zig
pub fn main() u8 {
var e = foo();
const i = e catch 69;
return i;
}
fn foo() anyerror!u8 {
return 5;
}
```
It's returning 69 instead of the expected value 5.
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.
Add additional search paths pointing at homebrew prefixes as Apple
doesn't ship a static libncurses for linking - only a stub for dynamic
linking `libncurses.tbd`.
A new zsf-hosted server is being brought online.
This should be enough for linux build, test and packaging pipeline.
Currently this pipeline does not not post artifacts.
Upstream LLVM fixes#8597, no longer need `-Dskip-debug` and others.
Additionally, due to the nature of drone.io server pool, it is
beneficial to know which aarch64 CPU brand is in use.
- drop `-Dskip-debug` and others
- invoke `lscpu` prior to build
- enable more testsuite consistent with ci azure
- remove workaround for (already closed) #6830closes#8597
tar does not properly implement the -k feature, so don't use it.
It incorrectly reports "file exists" when the expected behavior is to
leave the existing file alone.
NetBSD CI is disabled because it is not yet supported in
zig-bootstrap. Once NetBSD has proper zig-bootstrap support, it can be
re-enabled.
Windows is not solved here yet; will be pushing a separate commit for
that.
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.
Conflicts:
* cmake/Findclang.cmake
* cmake/Findlld.cmake
* cmake/Findllvm.cmake
In master branch, more search paths were added to these files with "12"
in the path. In this commit I updated them to "13".
* src/stage1/codegen.cpp
* src/zig_llvm.cpp
* src/zig_llvm.h
In master branch, ZigLLVMBuildCmpXchg is improved to add
`is_single_threaded`. However, the LLVM 13 C API has this already, and
in the llvm13 branch, ZigLLVMBuildCmpXchg is deleted in favor of the C
API. In this commit I updated stage2 to use the LLVM 13 C API rather
than depending on an improved ZigLLVMBuildCmpXchg.
Additionally, src/target.zig largestAtomicBits needed to be updated to
include the new m68k ISA.
The following is an azure failure that occured Sep 13:
del : Cannot remove item D:\a\1\s\sfx.exe: The process cannot access the file 'D:\a\1\s\sfx.exe' because it is being used by another process.
Windows will keep a hold of recently run exeutables even after their process has exited. To avoid this I've just removed the deletion of the exe file. It's about 70 MB so it's probably OK.
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`.
* remove unused download page html. It's now handled in the
www.ziglang.org website repo.
* add netbsd to the downloads index.json file that we send to
the www.ziglang.org website repo.
* shallow clone the website repo to avoid downloading old copies of
data.js unnecessarily.
This extra message was intended to help contributors by clarifying
what to do when they hit a `zig fmt` failure, but now AST errors are
also emitted here and the message may actually introduce confusion.
Remove it for now.
This breaking change disambiguates between overriding the lib dir when
performing an installation with the Zig Build System, and overriding the
lib dir that the Zig installation itself uses.
Since v0.23 release of Wasmtime, if we want to iterate a directory
Y then directory Y needed to have been granted `fd_readdir` right.
However, it is now also required for directory X to carry `fd_readdir`
right, and so on, up-chain all the way until we reach the preopen
(which possesses all rights by default).
This caused problems for us since our libstd implementation is more
fine-grained and allowed for parent dirs not to carry the right while
allow for iterating on its children. My proposal here is to always
grant `fd_readdir` right as part of
`std.fs.Dir.OpenDirOptions.access_sub_paths`. This seems to be the
approach taken by Rust also, plus we should be justified to take this
approach since WASI is experimental and snapshot1 will be discontinued
eventually and replaced with a new approach to access management
that will require a complete rewrite of our libstd anyhow.
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.
new pipeline `BuildMacOS_arm64`
- `vmImage: 'macOS-10.15' `
new `macos_arm64_script`
- switch from using `make` to `ninja`
- select xcode 12.4
- set zig-cache env variables
- build host-zig binary with xcode, link against llvm for x86_64 (target macos 10.15)
- build arm64-zig binary with xcode and host-zig, link against llvm for arm64 (target macos 11.0)
- ad-hoc codesign arm64 binary with linker
- use host-zig for docgen
- use host-zig for experimental std lib docs
- sync final `release/` hierarchy with `linux_script`
- use gnu-tar for good-practices (set owner, set sort)
enhance `CMakeLists.txt`
- do not build `zig0` when cross-compiling
- disable `BYPRODUCTS` directive `zig1.o` to avoid `ninja` error
see #8265
I got this error when re-running the cmake line setting
-DZIG_EXECUTABLE:
```
ninja: warning: multiple rules generate zig1.o. builds involving
this target will not be correct; continuing anyway
[-w dupbuild=warn]
```
But it works fine with make.
* no longer depend on apt.llvm.org, instead we rely on a zig-bootstrap
tarball with pre-built Zig, LLVM, LLD, and Clang. Similar to the
Windows Dev Kit but for Linux. This also makes the script no longer
depend on Docker, libxml2, or GCC.
* remove bash retry logic; it was only needed for flaky apt.llvm.org
and isn't needed for the other resources we download.
* build and upload the experimental std lib automatically generated
docs. langref.html is moved to docs/langref.html because the std lib
docs are in docs/std/.
* the superfluous "zig" directory in $prefix/lib/zig/std/std.zig is
removed from the tarball.
* update_download_page makes a commit in the www.ziglang.org repository
updating data/releases.json so that repository can manage deploys.
git describe is used for version string creation, but it had to be
reverted in commit 69da6ba because it was broken in CI builds.
Azure Pipelines and Drone perform shallow clones by default.
This change reconfigures them to fetch history and tags. It adds tens of
seconds, which is negligible compared to overall build and test time.
Related: #6466, #6509, #7601
The version we were using in CI is now getting quite old, and we
want to make sure that the code we produce is compatible with
current versions of Wasmtime.
Zig supports both Linux and Windows natively. Those are the main use
cases we are focusing on. Happy to accept mingw patches if they are
non-invasive, but we will not be hampering progress on the main use
cases with failing mingw CI builds.
* caching system: use 16 bytes siphash final(), there was a bug in the
std lib that wasn't catching undefined values for 18 bytes. fixed in
master branch.
* fix caching system unit test logic to not cause error.TextBusy on windows
* port the logic from stage1 for building glibc shared objects
* add is_native_os to the base cache hash
* fix incorrectly freeing crt_files key (which is always a reference to
global static constant data)
* fix 2 use-after-free in loading glibc metadata
* fix memory leak in buildCRTFile (errdefer instead of defer on arena)
We're up against the 6 hour limit so this is a time-saving workaround.
Compile error tests are generally not OS-specific so the coverage from
the other platforms should be sufficient.