we don't really have a way to determine whether the stage1
zig compiler requires PIC so to be safe we always enable it
when building libuserland.
fixes build on some configurations of alpine linux.
* add zig build option `-Dskip-libc` to skip tests that build libc
(e.g. if you don't want to wait for musl to build)
* add `-Denable-wine` option which uses wine to run cross compiled
windows tests on non-windows hosts
* add `-Denable-qemu` option which uses qemu to run cross compiled
foreign architecture tests
* add `-Denable-foreign-glibc=path` option which combined with
`-Denable-qemu` enables running cross compiled tests that link
against glibc. See
https://github.com/ziglang/zig/wiki/Updating-libc#glibc for how to
produce this directory.
* the test matrix is done manually. release test builds are only
enabled by default for the native target. this should save us some CI
time, while still providing decent coverage of release builds.
- add test coverage for `x86_64-linux-musl -lc` (building musl libc)
- add test coverage for `x86_64-linux-gnu -lc` (building glibc)
- add test coverage for `aarch64v8_5a-linux-none`
- add test coverage for `aarch64v8_5a-linux-musl -lc` (building musl libc)
- add test coverage for `aarch64v8_5a-linux-gnu -lc` (building glibc)
- add test coverage for `arm-linux-none`
- test coverage for `arm-linux-musleabihf -lc` (building musl libc) is
disabled due to #3286
- test coverage for `arm-linux-gnueabihf -lc` (building glibc) is disabled
due to #3287
- test coverage for `x86_64-windows-gnu -lc` (building mingw-w64) is
disabled due to #3285
* enable qemu testing on the Linux CI job. There's not really a good
reason to enable wine, since we have a Windows CI job as well.
* remove the no longer needed `--build-file ../build.zig` from CI
scripts
* fix bug in glibc compilation where it wasn't properly reading the abi
list txt files, resulting in "key not found" error.
* std.build.Target gains:
- isNetBSD
- isLinux
- osRequiresLibC
- getArchPtrBitWidth
- getExternalExecutor
* zig build system gains support for enabling wine and enabling qemu.
`artifact.enable_wine = true;`, `artifact.enable_qemu = true;`. This
communicates that the system has these tools installed and the build
system will use them to run tests.
* zig build system gains support for overriding the dynamic linker of
an executable artifact.
* fix std.c.lseek prototype. makes behavior tests for
arm-linux-musleabihf pass.
* disable std lib tests that are failing on ARM. See #3288, #3289
* provide `std.os.off_t`.
* disable some of the compiler_rt symbols for arm 32 bit. Fixes
compiler_rt tests for arm 32 bit
* add __stack_chk_guard when linking against glibc. Fixes std lib tests
for aarch64-linux-gnu
* workaround for "unable to inline function" using `@inlineCall`. Fixes
compiler_rt tests for arm 32 bit.
`zig build test-compare-panic`
Create basic tests to compare panic output. The address field
is replaced by a symbolic constant and each expected output is
specific to os. Tests will only run for explicitly defined
platforms.
see also #2485
also start prefering NtDll API. so far:
* NtQueryInformationFile
* NtClose
adds a performance workaround for windows unicode conversion. but that
should probably be removed before merging
This moves the installation of shipped source files from large
CMakeLists.txt lists to zig build recursive directory installation.
On my computer a cmake `make install` takes 2.4 seconds even when it has
to do nothing, and prints a lot of unnecessary lines to stdout that say
"up-to-date: [some file it is installing]".
After this commit, the default output of `make` is down to 1
second, and it does not print any junk to stdout. Further, a `make
install` is no longer required and `make` is sufficient.
This closes#2874.
It also closes#2585. `make` now always invokes `zig build` for
installing files and libuserland.a, and zig's own caching system makes
that go fast.
* fix crash when doing field access of slice types. closes#2486
* remove the deprecated Child property from slice types
* add -Dskip-non-native build option to build script
Sadly due to a workaround for LLD linker limitations on macOS
we cannot put libuserland into an .a file; instead we have to use object
files. Again due to linker limitations, bundling compiler_rt.o into
another relocatable object also doesn't work. So we're left with
disabling stack probing on macOS for the stage1 self-hosted code.
These workarounds could all be removed if the macos support in the LLD
linker improved, or if Zig project had its own linker that did not have
these issues.
and use it when building libuserland.a
The self-hosted part of stage1 relies on zig's compiler-rt, and so we
include it in libuserland.a.
This should potentially be the default, but for now it's behind a linker
option.
self-hosted translate-c: small progress on translating functions.
Previously libuserland was being built for the native target,
which could depend on native CPU features such as AVX. The
CI infrastructure is intending to create binaries that are
widely compatible and do not make use of specific CPU features.
There could be something to gain from enabling native CPU features
sometimes, by introducing a new cmake configuration option, but
since it's planned to eventually ship self-hosted rather than stage1,
I don't think it really matters.
closes#2348
This modifies the build process of Zig to put all of the source files
into libcompiler.a, except main.cpp and userland.cpp.
Next, the build process links main.cpp, userland.cpp, and libcompiler.a
into zig1. userland.cpp is a shim for functions that will later be
replaced with self-hosted implementations.
Next, the build process uses zig1 to build src-self-hosted/stage1.zig
into libuserland.a, which does not depend on any of the things that
are shimmed in userland.cpp, such as translate-c.
Finally, the build process re-links main.cpp and libcompiler.a, except
with libuserland.a instead of userland.cpp. Now the shims are replaced
with .zig code. This provides all of the Zig standard library to the
stage1 C++ compiler, and enables us to move certain things to userland,
such as translate-c.
As a proof of concept I have made the `zig zen` command use text defined
in userland. I added `zig translate-c-2` which is a work-in-progress
reimplementation of translate-c in userland, which currently calls
`std.debug.panic("unimplemented")` and you can see the stack trace makes
it all the way back into the C++ main() function (Thanks LemonBoy for
improving that!).
This could potentially let us move other things into userland, such as
hashing algorithms, the entire cache system, .d file parsing, pretty
much anything that libuserland.a itself doesn't need to depend on.
This can also let us have `zig fmt` in stage1 without the overhead
of child process execution, and without the initial compilation delay
before it gets cached.
See #1964
* in Zig build scripts, getOutputPath() is no longer a valid function
to call, unless setOutputDir() was used, or within a custom make()
function. Instead there is more convenient API to use which takes
advantage of the caching system. Search this commit diff for
`exe.run()` for an example.
* Zig build by default enables caching. All build artifacts will go
into zig-cache. If you want to access build artifacts in a convenient
location, it is recommended to add an `install` step. Otherwise
you can use the `run()` API mentioned above to execute programs
directly from their location in the cache. Closes#330.
`addSystemCommand` is available for programs not built with Zig
build.
* Please note that Zig does no cache evicting yet. You may have to
manually delete zig-cache directories periodically to keep disk
usage down. It's planned for this to be a simple Least Recently
Used eviction system eventually.
* `--output`, `--output-lib`, and `--output-h` are removed. Instead,
use `--output-dir` which defaults to the current working directory.
Or take advantage of `--cache on`, which will print the main output
path to stdout, and the other artifacts will be in the same directory
with predictable file names. `--disable-gen-h` is available when
one wants to prevent .h file generation.
* `@cImport` is always independently cached now. Closes#2015.
It always writes the generated Zig code to disk which makes debug
info and compile errors better. No more "TODO: remember C source
location to display here"
* Fix .d file parsing. (Fixes the MacOS CI failure)
* Zig no longer creates "temporary files" other than inside a
zig-cache directory.
This breaks the CLI API that Godbolt uses. The suggested new invocation
can be found in this commit diff, in the changes to `test/cli.zig`.
* zig fmt
* std.mem.join takes a slice of slices instead of var args
* std.mem.join takes a separator slice rather than byte,
and always inserts it. Previously it would not insert the separator
if there already was one, violating the documented behavior.
* std.mem.join calculates exactly the correct amount to allocate
and has no call to allocator.shrink()
* bring back joinWindows and joinPosix and the corresponding tests.
it is intended to be able to call these functions from any OS.
* rename std.os.path.resolveSlice to resolve (now resolve takes
a slice of slices instead of var args)
* rename std.mem.split to std.mem.tokenize
* add future deprecation notice to docs
* (unrelated) add note to std.os.path.resolve docs
* std.mem.separate - assert delimiter.len not zero
* fix implementation of std.mem.separate to respect the delimiter
* separate the two iterators to different structs
This commit contains everything from the copy-elision-2
branch that does not have to do with copy elision directly,
but is generally useful for master branch.
* All const values know their parents, when applicable, not
just structs and unions.
* Null pointers in const values are represented explicitly,
rather than as a HardCodedAddr value of 0.
* Rename "maybe" to "optional" in various code locations.
* Separate DeclVarSrc and DeclVarGen
* Separate PtrCastSrc and PtrCastGen
* Separate CmpxchgSrc and CmpxchgGen
* Represent optional error set as an integer, using the 0 value.
In a const value, it uses nullptr.
* Introduce type_has_one_possible_value and use it where applicable.
* Fix debug builds not setting memory to 0xaa when storing
undefined.
* Separate the type of a variable from the const value of a variable.
* Use copy_const_val where appropriate.
* Rearrange structs to pack data more efficiently.
* Move test/cases/* to test/behavior/*
* Use `std.debug.assertOrPanic` in behavior tests instead of
`std.debug.assert`.
* Fix outdated slice syntax in docs.
* add a --system-linker-hack command line parameter to work around
poor LLD macho code. See #1535
* build.zig correctly handles static as well as dynamic dependencies
when building the self hosted compiler.
- no more unnecessary libxml2 dependency
- a static build on macos produces a completely static self-hosted
compiler for macos (except for libSystem as intended).
init-lib creates a working static library with tests, and
init-exe creates a working hello world with a `run` target.
both now have test coverage with the new "cli tests" file.
closes#1035