18072 Commits

Author SHA1 Message Date
Jakub Konka
26153ce73a dwarf: clean up allocations in std.dwarf module
While this code probably could do with some love and a redesign,
this commit fixes the allocations by making sure we explicitly
pass an allocator where required, and we use arenas for temporary
or narrowly-scoped objects such as a `Die` (for `Die` in particular,
not every `FormValue` will be allocated - we could duplicate, or
we can use an arena which is the proposal of this commit).
2022-04-21 00:06:52 +02:00
Joachim Schmidt
1a1b5ee264
Merge pull request #11462 from joachimschmidt557/stage2-aarch64
stage2 AArch64: truncation support
2022-04-20 09:44:43 +02:00
protty
e3cbea934e
std.Thread.Futex improvements (#11464)
* atomic: cache_line

* Thread: Futex rewrite + more native platform support

* Futex: tests compile

* Futex: compiles and runs test

* Futex: broadcast test

* Futex: fix PosixImpl for tests

* Futex: fix compile errors for bsd platforms

* Futex: review changes + fix timeout=0 + more comments
2022-04-19 19:42:15 -05:00
Yusuf Bham
2fa7f6e502 std.os.uefi: Add BlockIoProtocol 2022-04-19 19:51:19 -04:00
Robin Voetter
859ae152bc array hash map: fix getOrPutAdapted on Managed array hash map 2022-04-19 19:41:12 -04:00
Andrew Kelley
0c5ad335d2 build system: add -fstage1/-fno-stage1 to zig build
So that people can start experimenting with compiling their projects
with the self-hosted compiler.

I expect this commit to be reverted after #89 is closed.
2022-04-19 14:40:27 -07:00
joachimschmidt557
fa85a739d9
stage2 AArch64: fix shl, shr, shl_exact, shr_exact
Introduces the necessary truncation after shift
2022-04-19 22:40:51 +02:00
joachimschmidt557
cbb13c023e
stage2 AArch64: change binOp lowering mechanism to use Mir tags
Mirrors e2e69803dc16efe11a6d42c6c49853e16a41fd0c for AArch64
2022-04-19 22:40:50 +02:00
joachimschmidt557
0a909a6712
stage2 AArch64: implement addwrap, subwrap, mulwrap 2022-04-19 22:40:50 +02:00
joachimschmidt557
d9d9fea6ae
stage2 AArch64: Add ldrsb, ldrsh instructions 2022-04-19 22:40:48 +02:00
joachimschmidt557
f95a8ddafa
stage2 AArch64: Implement basic truncate functionality 2022-04-19 22:39:14 +02:00
joachimschmidt557
c78daeb642
stage2 AArch64: add basic assertions to bits.zig for correct codegen
Includes many fixes of errors discovered by adding these assertions
2022-04-19 22:37:56 +02:00
Andrew Kelley
9c2cbe39c2
Merge pull request #11461 from Luukdegram/wasm-debug-info
Wasm: add support for debug information
2022-04-19 14:12:13 -04:00
Luuk de Gram
be08d2bdbd
wasm: Fix unreachable paths
When the last instruction is a debug instruction, the type of it is void.
Similarly for 'noreturn' emit an 'unreachable' instruction to tell the wasm-validator
the path cannot be reached.

Also respect the '--strip' flag in the self-hosted wasm linker and not emit a 'name' section
when the flag is set to `true`.
2022-04-19 19:58:49 +02:00
Andrew Kelley
78f26b970e
Merge pull request #11469 from topolarity/wasm-fixup
stage2: Move `selfExePathWasi` to `introspect.zig`
2022-04-19 13:30:15 -04:00
Andrew Kelley
535d5624e4 wasm: fix lowerDeclRefValue using wrong Decl 2022-04-19 13:04:59 -04:00
Andrew Kelley
f3b3d7f20a
Merge pull request #11468 from topolarity/f80-mul
compiler_rt: Implement softfloat multiply for `f80`
2022-04-19 13:04:31 -04:00
Cody Tapscott
f8dc6fc416 stage2: Only bypass flock on WASI 2022-04-18 23:08:00 -07:00
Cody Tapscott
bb9cd6db1c stage2: Move WASI/Zig-specific selfExePath to introspect.zig 2022-04-18 23:06:49 -07:00
Cody Tapscott
b2950866b1 compiler_rt: Fix rounding/NaN handling for f80 add/sub
There were a few minor bugs in the rounding behavior and Inf/NaN
handling for the f80 __addxf3 and __subtf3 functions.

This change updates the original generic implementation to correctly
handle f80 floats, including the explicit integer bit.
2022-04-18 21:45:46 -07:00
Cody Tapscott
d760cae2b1 compiler_rt: implement __mulxf3 for f80 2022-04-18 20:46:03 -07:00
Andrew Kelley
edb4a07d4d Sema: fix not reserving enough memory for comptime shl 2022-04-18 16:41:54 -07:00
Andrew Kelley
c9858f833c stage2: fix building stage3 in release mode
Previously, comptime function calls could cause a crash in the hash
function due to a lazy value depending on an unresolved type.
2022-04-18 16:41:54 -07:00
Andrew Kelley
b75d86027d stage2: avoid binary bloat from GeneralPurposeAllocator
In the case of not using it.
2022-04-18 16:41:54 -07:00
Jakub Konka
b03345f32a
Merge pull request #11024 from topolarity/wasi-stage2
stage2: Add limited WASI support for selfExePath and globalCacheDir
2022-04-18 23:53:41 +02:00
Jakub Konka
5195b87639
Merge pull request #11396 from wojtekmach/wm-zig-cc-subsystem
zig cc: support --subsystem linker flag
2022-04-18 19:20:23 +02:00
Cody Tapscott
3a63fa6b7f stage2: Add 'zig.wasm' fallback for binary name 2022-04-18 10:20:20 -07:00
Cody Tapscott
692ccd01b4 stage2: Initialize WASI preopens on startup 2022-04-18 10:20:20 -07:00
Cody Tapscott
089651716c stage2: Bypass file locks in src/Cache.zig for WASI targets 2022-04-18 10:20:15 -07:00
Cody Tapscott
922d8378e7 stage2: Add limited WASI support for selfExePath and globalCacheDir
This change adds support for locating the Zig executable and the library
and global cache directories, based on looking in the fixed "/zig" and
"/cache" directories.

Since our argv[0] on WASI is just the basename (any absolute/relative
path information is deleted by the runtime), there's very limited
introspection we can do on WASI, so we rely on these fixed directories.
These can be provided on the command-line using `--mapdir`, as follows:

```
wasmtime --mapdir=/cwd::. --mapdir=/cache::"$HOME/.cache/zig" --mapdir=/zig::./zig-out/ ./zig-out/bin/zig.wasm
```
2022-04-18 10:19:34 -07:00
Luuk de Gram
2193f7c4a2
wasm: Add support for debug info
This implements basic DWARF output when building for the wasm target.
Stacktraces, however, are currently not supported.
2022-04-18 13:11:37 +02:00
Wojtek Mach
b2344cc18e Support --subsystem=x instead of --subsystem,x 2022-04-18 11:43:17 +02:00
Ryan Liptak
f8d2b87fa1 Update doc comment of ArrayHashMap to include 4th arg in eql fns
4th argument was added in cf88cf2657d721c68055a284e8c498a18639f74c
2022-04-18 03:47:03 -04:00
Andrew Kelley
a7c05c06be stage2: expose progress bar API to linker backends
This gives us insight as to what is happening when we are waiting for
things such as LLVM emit object and LLD linking.
2022-04-17 04:09:35 -07:00
Yusuf Bham
2aeaa1cfc4
std.os.uefi: fix GUID formatting (#11452) 2022-04-17 06:15:15 -04:00
Cody Tapscott
7b090df668 stdlib std.os: Improve wasi-libc parity for WASI CWD emulation
Two major changes here:
  1. We store the CWD as a simple `[]const u8` and lookup Preopens for
     every absolute or CWD-referenced file operation, based on the
     Preopen with the longest match (i.e. most specific path)
  2. Preorders are normalized to POSIX absolute paths at init time.
     Behavior depends on the "cwd_root" parameter of `initPreopensWasi`:

	`cwd_root` is used for any Preopens that start with "."

	  For example:
            "./foo/bar" - inits to -> "{cwd_root}/foo/bar"
            "foo/bar"   - inits to -> "/foo/bar"
	    "/foo/bar"  - inits to -> "/foo/bar"

        `cwd_root` must be an absolute path.

	Using "/" as `cwd_root` gives behavior similar to wasi-libc.
2022-04-16 18:08:05 +02:00
Jakub Konka
8f75823728
Merge pull request #11446 from ziglang/aarch64-macos-llvm
stage2: fix behavior test failures on aarch64-macos (LLVM+native), and other minor fixes
2022-04-16 18:07:02 +02:00
Andrew Kelley
a315d51c0a
Merge pull request #11437 from koachan/sparc64-mutex
compiler_rt: atomics: Add TAS lock support for SPARC
2022-04-16 06:36:54 -04:00
Andrew Kelley
e428f85cfd
Merge pull request #11445 from viriuwu/f80-freebsd-tests
re-enable f80 tests on freebsd
2022-04-16 06:26:14 -04:00
Jakub Konka
897df18573 stage2: fix @mulAdd on aarch64 Darwin
According to Apple docs, the long double type is a double precision
IEEE754 binary floating-point type, which makes it identical to the
double type. This behavior contrasts to the standard specification,
in which a long double is a quad-precision, IEEE754 binary,
floating-point type.

Thus, we need to take this into account when using the compiler
intrinsics so that we select the correct function version for
FloatMulAdd.
2022-04-16 12:23:47 +02:00
Andrew Kelley
ec8a6544a3
Merge pull request #11444 from kprotty/treap
Introduce std.Treap
2022-04-16 06:23:18 -04:00
Jakub Konka
1b5a43fdf7 start.zig: make sure macos uses full startup code 2022-04-16 12:07:34 +02:00
Jakub Konka
88d87d6506 stage2,macho: swap out inodes before checking for intermediary basename
This way we avoid the infamous SIGKILL on arm64 macos.
2022-04-16 12:06:58 +02:00
Andrew Kelley
578a792b33
Merge pull request #11442 from Vexu/stage3
Make self hosted compiler capable of building itself
2022-04-16 05:42:25 -04:00
joachimschmidt557
3bfb1616db stage2 ARM: move genArgDbgInfo back to CodeGen
This removes the questionable Air -> Mir dependency that existed
before. The x86_64 backend also performed this change.
2022-04-16 09:41:27 +02:00
vi
4ad1480298
std.math.fabs: enable f80 testing 2022-04-15 16:52:02 -06:00
vi
2ef9a0d9ae
std.math: enable f80 tests on freebsd 2022-04-15 16:50:00 -06:00
kprotty
33952dad12 treap: zig fmt 2022-04-15 17:01:01 -05:00
kprotty
4d0303b992 treap: fix + determinstically randomize test cases. 2022-04-15 16:30:45 -05:00
Veikka Tuominen
101aac92c2 stage2: fix bugs preventing stage2 from building stage3 with LLVM 2022-04-15 23:32:26 +03:00