Commit Graph

4736 Commits

Author SHA1 Message Date
Andrew Kelley da8403bcdd build.zig: libuserland expects to against libc 2019-04-16 19:13:46 -04:00
Andrew Kelley 89763c9a0d stage1 is now a hybrid of C++ and Zig
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
2019-04-16 19:12:20 -04:00
Andrew Kelley 4c03746926 Revert "DirectAllocator: on windows, use HeapFree instead of HeapReAlloc to free memory."
This reverts commit 71bb8cd537.

This broke the CI on Windows.
2019-04-16 19:11:37 -04:00
Andrew Kelley b29241fc08 docs: update intro text 2019-04-16 14:23:58 -04:00
Michael Dusan 611d4bc6a1 stage1: const_values_equal support tagged union 2019-04-16 13:55:23 -04:00
Andrew Kelley 52caf311bb Merge pull request #2286 from shritesh/wasm_alloc
WasmAllocator: WebAssembly Memory Allocator
2019-04-16 13:27:56 -04:00
Shritesh Bhattarai 0c28a18d96 WasmAllocator: cleanup 2019-04-16 12:23:45 -05:00
Sahnvour 71bb8cd537 DirectAllocator: on windows, use HeapFree instead of HeapReAlloc to free memory. 2019-04-16 13:18:21 -04:00
Andrew Kelley 4e2f6ebf39 freestanding target adds -ffrestanding to cc parameters
closes #2287
2019-04-16 12:06:14 -04:00
Andrew Kelley 3226b5315e translate-c: move some code to the C API
See #1964
2019-04-16 04:32:48 -04:00
Andrew Kelley f488f3fd03 remove workaround for LLD bug
Zig's embedded LLD now has a patch to resolve the deadlock race
condition, and the patch is getting upstreamed too, so this
closes #2283.
2019-04-16 03:58:15 -04:00
Andrew Kelley c8b60538ed add patch to LLD to fix deadlock race condition in wasm linker
Patch is getting upstreamed here: https://reviews.llvm.org/D60757
And so this patch can be removed with LLVM 9.0.0.
2019-04-16 03:56:46 -04:00
Shritesh Bhattarai 4235982fe6 fmt wasm_allocator 2019-04-16 01:42:11 -05:00
Shritesh Bhattarai aa3f31ac0a wasm: add WasmAllocator 2019-04-16 01:40:16 -05:00
Shritesh Bhattarai f2119f9961 wasm: WasmAllocator that uses fixed 64kb pages 2019-04-15 21:21:46 -05:00
Andrew Kelley 0a280b6062 update std.os.page_size for WebAssembly 2019-04-15 21:20:41 -04:00
Andrew Kelley 6692cbbe18 disable threads when linking WebAssembly to work around an LLD bug
See #2283
2019-04-15 20:41:50 -04:00
Andrew Kelley 579dd74114 fix Debug mode when error return tracing is off
Previously the code for generating a panic crash expected
one of the parameters to be the error return trace. Now
it does not expect that parameter when g->have_err_ret_tracing
is false.

Closes #2276
2019-04-15 20:17:06 -04:00
Shritesh Bhattarai f5d84250a3 wasi: switch to "standard" wasi_unstable module fn 2019-04-15 18:44:33 -04:00
Andrew Kelley 3b8a85c941 Merge pull request #2281 from shritesh/wasm_module
Support wasm module imports
2019-04-15 18:05:46 -04:00
Shritesh Bhattarai a0d2185199 wasm: add wasm-import-module attr to extern 2019-04-15 17:00:04 -05:00
Shritesh Bhattarai 9465c6d538 link: exemption for wasm instead of wasi 2019-04-15 16:59:34 -05:00
Andrew Kelley 5cb18e9c6f translate-c: move some code to the C API
See #1964
2019-04-15 00:32:27 -04:00
Shritesh Bhattarai cc8cf94cb2 Update wasm tiers (#2272)
* tier update: wasm32=2, wasm64=4
2019-04-14 11:29:22 -04:00
Andrew Kelley 27253f09b6 organize how the single threaded option is passed around 2019-04-14 11:01:01 -04:00
Andrew Kelley 63a970a548 Merge pull request #2268 from shritesh/wasi
wasm: preliminary WASI OS support
2019-04-14 10:45:30 -04:00
Shritesh Bhattarai 0f1d92e2cf wasm: force single threaded 2019-04-14 10:21:48 -04:00
Shritesh Bhattarai 94e0871603 wasi: don't pass --no-entry to linker 2019-04-14 00:03:32 -05:00
Shritesh Bhattarai ecd0f89254 wasi: better extern wasi logic 2019-04-13 23:49:02 -05:00
Shritesh Bhattarai 93d43d4529 wasi: add std/os/wasi{,/core}.zig to CMakeLists.txt 2019-04-13 22:51:18 -05:00
Shritesh Bhattarai 22960a5fdf wasi: better comments 2019-04-13 22:45:31 -05:00
Shritesh Bhattarai a2d8f03092 support extern "wasi" functions 2019-04-13 22:28:58 -05:00
Shritesh Bhattarai 93528be6b1 wasi: sigabrt at panic 2019-04-13 21:54:50 -05:00
Shritesh Bhattarai fe9cd0b4bc wasi: use __wasi_proc_exit instead of posix.exit 2019-04-13 21:36:53 -05:00
Andrew Kelley 68d7e4a1b6 better handle quota of setEvalBranchQuota
Now that c58b802034 has removed
the "top of the comptime stack" requirement, the branch quota
can be modified somewhere other than the top of the comptime stack.

This means that the quota of a parent IrExecutable has to be
modifiable by an instruction in the child.

Closes #2261
2019-04-13 16:55:59 -04:00
Duncan a43fd7a550 Add favicon to langref.html 2019-04-13 16:20:33 -04:00
Andrew Kelley 4a2ccd6fb8 Merge pull request #2266 from bnoordhuis/fix-cache-lseek-ebadf
don't close cache manifest file prematurely
2019-04-13 16:17:12 -04:00
Shritesh Bhattarai 72bcd5a4a5 WIP: hello world 2019-04-13 15:15:39 -05:00
Ben Noordhuis 93e89b3b7e don't close cache manifest file prematurely
ErrorInvalidFormat is not a fatal error so don't close the cache
manifest file right away but instead let cache_final() handle it.

Fixes the following (very common) warning when running the test suite:

    Warning: Unable to write cache file [..]: unexpected seek failure

The seek failure is an lseek() system call that failed with EBADF
because the file descriptor had already been closed.
2019-04-13 12:33:29 +02:00
Ben Noordhuis ea5518f69e make os_file_close poison file handle after close
This helps track down use-after-close bugs.
2019-04-13 12:31:49 +02:00
Andrew Kelley 9d229791c6 translate-c: move some code to the C API
See #1964
2019-04-12 14:39:12 -04:00
Shritesh Bhattarai 63f2e96eea wasm: use .wasm ext for exe 2019-04-12 13:17:59 -04:00
Andrew Kelley 6284a4c534 translate-c: move some code to the C API
See #1964
2019-04-12 03:56:38 -04:00
Andrew Kelley f860493f23 translate-c: move some code to the C API
See #1964
2019-04-12 03:12:22 -04:00
Andrew Kelley 6f34d08aed translate-c: move some code to the C API
See #1964
2019-04-11 23:38:41 -04:00
Shritesh Bhattarai 5f8dbcac06 wasm: disable error ret tracing 2019-04-11 16:37:40 -04:00
Andrew Kelley b960f1d922 translate-c: move some code to the C API
See #1964
2019-04-11 15:33:26 -04:00
Andrew Kelley 4172fe986e readme: separate powerpc 32 and 64 bit in the support table 2019-04-11 15:22:15 -04:00
Andrew Kelley 3ce024dd85 A bunch of fixes for the DWARF parser (#2254)
* Correct parsing of DWARF line_info section

* Fix reading of udata/sdata encoded attributes

* Add definition for DW_AT_alignment

Even though it's been standardized in DWARF5 some compilers produce it
anyway for DWARF4 infos too.

* Fix reading of reference attributes

* Distinguish between absolute/relative addresses
2019-04-11 14:34:13 -04:00
Andrew Kelley a895c59971 delete unused function
missed by 27cd830ec8
2019-04-11 14:33:43 -04:00