22846 Commits

Author SHA1 Message Date
Jakub Konka
292f91aef2 Handle .ah vs .spl register aliases 2023-03-11 20:05:49 +01:00
Jakub Konka
bc43cee775 Get more things passing 2023-03-11 20:05:49 +01:00
Jakub Konka
ea3b3e94ab x86_64: clean up call semantics in codegen 2023-03-11 20:05:49 +01:00
Jakub Konka
f14831ec73 x86_64: truncate immediates 2023-03-11 20:05:49 +01:00
Jakub Konka
817fb263b5 x86_64: downstream table-driven instruction encoder 2023-03-11 20:05:49 +01:00
Andrius Bentkus
4ea2f441df Module: retry ZIR cache file creation
There are no dir components, so you would think that this was
unreachable, however we have observed on macOS two processes racing to
do openat() with O_CREAT manifest in ENOENT.

closes #12138
2023-03-11 06:20:51 -05:00
Andrew Kelley
3169f0529b eliminate posix_spawn from the standard library
Today I found out that posix_spawn is trash. It's actually implemented
on top of fork/exec inside of libc (or libSystem in the case of macOS).

So, anything posix_spawn can do, we can do better. In particular, what
we can do better is handle spawning of child processes that are
potentially foreign binaries. If you try to spawn a wasm binary, for
example, posix spawn does the following:

 * Goes ahead and creates a child process.
 * The child process writes "foo.wasm: foo.wasm: cannot execute binary file"
   to stderr (yes, it prints the filename twice).
 * The child process then exits with code 126.

This behavior is indistinguishable from the binary being successfully
spawned, and then printing to stderr, and exiting with a failure -
something that is an extremely common occurrence.

Meanwhile, using the lower level fork/exec will simply return ENOEXEC
code from the execve syscall (which is mapped to zig error.InvalidExe).

The posix_spawn behavior means the zig build runner can't tell the
difference between a failure to run a foreign binary, and a binary that
did run, but failed in some other fashion. This is unacceptable, because
attempting to excecve is the proper way to support things like Rosetta.
2023-03-10 15:41:07 -05:00
Luuk de Gram
904f414e7e
Merge pull request #14869 from Luukdegram/wasm-linker
wasm-linker: refactor virtual addresses
2023-03-10 16:48:30 +01:00
Lavt Niveau
5a26d1b426
Include signal.h to define SIGTRAP in Stage 1 compiler (#14867)
copy lib/zig.h to stage1/zig.h

In this case, it looks safe to backport over with no changes.

Co-authored-by: Andrew Kelley <andrew@ziglang.org>
2023-03-10 13:36:43 +00:00
mlugg
023753b469 Sema: correctly detect use of undefined within slices in @Type
Resolves: #14712
2023-03-10 12:18:06 +02:00
Luuk de Gram
0ee9a52507
wasm-linker: remove synthetic segments & atoms 2023-03-10 06:20:10 +01:00
antlilja
b445bbfea2 Add ability to import dependencies from build.zig 2023-03-09 22:38:14 -05:00
Andrew Kelley
7c9ed45ac2
Merge pull request #14762 from truemedian/http-keepalive
std.http: add connection pooling, handle keep-alive and compressed content
2023-03-09 22:02:01 -05:00
mlugg
14590e956e Fix test case added in 6d7fb8f 2023-03-09 23:25:38 +02:00
Nameless
524e0cd987
std.http: rework connection pool into its own type 2023-03-09 14:55:31 -06:00
Nameless
634e715504
std.http: split Client's parts into their own files 2023-03-09 14:55:20 -06:00
Nameless
0a4130f364
std.http: handle relative redirects 2023-03-09 14:55:13 -06:00
Nameless
fd2f906d1e
std.http: handle compressed payloads 2023-03-09 14:54:26 -06:00
Nameless
8d86194b6e
add error sets to tcpConnect* and tls.Client.init 2023-03-09 14:54:26 -06:00
Nameless
afb26f4e6b
std.http: add connection pooling and make keep-alive requests by default 2023-03-09 14:54:23 -06:00
Frank Denis
95f6a5935a
TurboSHAKE: change default delimiter to 0x1F (#14857)
The TurboSHAKE paper just got published:
https://eprint.iacr.org/2023/342.pdf

and unlike the previous K12 paper, suggests 0x1F instead of 0x01
as the default value for "D".
2023-03-09 19:20:57 +00:00
Luuk de Gram
87738cad86
wasm-linker: store symbol's virtual address
For data symbols we will now store its virtual address. This means
we do no longer have to calculate it each time a relocation asks
for the address. This is now done for all data symbols only once
rather than every single relocation for that symbol.

This now also allows us directly store the virtual address of synthetic
symbols without having to create an atom for them. This means we also
don't need to have a "synthetic" segment any longer and do not emit
the synthetic symbols such as __heap_end and __heap_base into the final
binary.
2023-03-09 19:14:17 +01:00
Andrew Kelley
12b74b2c05 CI: more aggressively check zig1 bootstrapping
This would have caught the problem we are seeing in #14799.
2023-03-09 01:26:21 -05:00
Frank Denis
134e5748e0
Fix incorrect SHA-3 computation with the streaming API (#14852)
* Fix SHA3 with streaming

Leftover bytes should be added to the buffer, not to the state.

(or, always to the state; we can and probably should eventually get
rid of the buffer)

Fixes #14851

* Add a test for SHA-3 with streaming
2023-03-09 05:18:15 +00:00
mlugg
6d7fb8f19c Sema: check type of comptime try operand
Resolves: #14693
2023-03-09 02:02:19 +02:00
Isaac Freund
3e99afdbfe build: add -Dpie option
It is becoming increasingly common for distributions to want to enable
PIE for all binaries and zig currently does not provide any way to do
so aside from patching the build.zig.
2023-03-08 17:47:36 -05:00
Jan Philipp Hafer
06b263825a std.os: add missing mmap errors
Man page for posix lists EMFILE, man page for linux ENFILE.
Also posix says "The mmap() function adds an extra reference to the file
associated with the file descriptor fildes which is not removed by a
subsequent close() on that file descriptor. This reference is removed
when there are no more mappings to the file."

It sounds counter-intuitive, that a process limit but no system limit can
be exceeeded.

As far as I understand, fildes is only used for file descriptor backed mmaps.
2023-03-08 13:00:06 -05:00
John Schmidt
ecc0108cea astgen: fill result location with void value if no other value
With this change, `break` and `break :blk` will fill the result location
with `.void_value`, ensuring that the value will be type checked.
The same will happen for a for loop that contains no `break`s in it's body.

Closes https://github.com/ziglang/zig/issues/14686.
2023-03-08 16:35:53 +02:00
Frank Denis
fea14c78d1
wasm-linker: emit build_id section (#14820)
The Build ID is a value that uniquely identifies a build.

It is intended to capture the "meaning" or inputs of the build,
and is usually associated with debug info.

Reference: https://github.com/WebAssembly/tool-conventions/blob/main/BuildId.md
2023-03-08 13:50:06 +00:00
Jacob Young
e3cf9d1650 Module: rewrite zir caching logic
Multiple processes can sit waiting for the exclusive lock at the same
time, so we want to recheck whether it needs to be updated whenever
we get an exclusive lock.

This also fixes a race condition between one process truncating the
cache file and another process reading it without atomic locking.
2023-03-08 00:00:52 -05:00
Andrew Kelley
6fc1621cbd
Merge pull request #14828 from jacobly0/fix-big-div
compiler_rt: fix rare case in udivei4
2023-03-07 19:32:32 -05:00
Gaëtan
bbba701a41 std.os.windows.advapi32: Add RegCloseKey 2023-03-07 18:14:37 -05:00
Frank Denis
8da6b393fb std.fmt: add bytesToHex() to encode bytes as hex digits
We already had `hexToBytes()`, but not the reverse operation
(at least not without using formatters).
2023-03-07 17:45:31 -05:00
Jacob Young
e33dfc300e zig.h: implement zig_breakpoint and zig_trap for more targets 2023-03-07 12:46:35 -05:00
Frank Denis
36d47dd199
std.crypto.hash.sha3: add TurboSHAKE (#14824) 2023-03-07 10:04:45 +01:00
Jacob Young
77d06012c2 CBE: implement unsigned big int div and mod 2023-03-07 03:03:35 -05:00
Jacob Young
c1d16a2b80 compiler_rt: fix rare case in udivei4
Unsigned integers are never less than zero, and so zig
helpfully deleted the entire case. :D

Closes #14816
2023-03-07 03:00:08 -05:00
r00ster91
6218e40046 Zir: fix outdated comment 2023-03-06 18:18:52 -05:00
r00ster91
70cbe5ac7c AstGen: remove unnecessary pubs
I think it helps when you know that something is entirely
self-contained, which AstGen is. The only function public is `generate`.
2023-03-06 18:18:52 -05:00
Eric Milliken
ccf00ccdf7
crypto.25519.field: de-inline mul for small builds (#14775) 2023-03-06 17:28:11 -05:00
jim price
6ab04b5941 std.os: Allow write functions to return INVAL errors
In Linux when interacting with the virtual file system when writing
in invalid value to a file the OS will return errno 22 (INVAL).

Instead of triggering an unreachable, this change now returns a
newly introduced error.InvalidArgument.
2023-03-06 15:59:18 -05:00
Jacob Young
2770159606 std: reenable vectorized code with the C backend 2023-03-06 08:09:32 -05:00
Jacob Young
c29c4c6f70 tools: add lldb pretty printer for std.MultiArrayList.Slice 2023-03-06 05:58:46 -05:00
Andrew Kelley
ac1b0e832b
Merge pull request #14799 from ziglang/update-zig1
`@trap` fixups
2023-03-06 01:29:56 -05:00
Andrew Kelley
8558983c86 std.os.abort: take advantage of @trap 2023-03-05 17:29:28 -07:00
Andrew Kelley
cdb9cc8f6b update zig1.wasm 2023-03-05 17:29:28 -07:00
Andrew Kelley
c839c180ef stage2: add zig_backend to ZIR cache namespace 2023-03-05 17:23:09 -07:00
Andrew Kelley
48e72960a4 llvm: fix lowering of @trap
It needed an unreachable instruction after it.
2023-03-05 17:23:09 -07:00
Andrew Kelley
fb04ff45cd langref: small clarification to @trap 2023-03-05 17:11:46 -07:00
Andrew Kelley
34a23db664 zig.h: lower trap to SIGTRAP instead of SIGILL 2023-03-05 17:11:46 -07:00