24139 Commits

Author SHA1 Message Date
Luuk de Gram
f2860bb4f4
wasm: more liveness fixes 2023-05-19 20:18:59 +02:00
Luuk de Gram
67d27dbe63
wasm: fix liveness bugs
Make sure to increase the reference count for `intcast` when the
operand doesn't require any casting of the respective WebAssembly type.

Function arguments have a reserved slot, and therefore cannot be
re-used arbitrarily
2023-05-19 20:18:59 +02:00
Luuk de Gram
e20976b7f2
wasm: fix miscompilation for shifting
This fix ensures that when we are shifting left or right,
both operands have the same WebAssembly type. e.g. it's not possible
to shift a 64 bit integer and 32 bit integer together and will fail
WebAssembly's validator. By first coercing the values to the same
type, we ensure we satisfy the validator.
2023-05-19 20:18:59 +02:00
Luuk de Gram
d353d208e2
wasm: implement @mulWithOverflow for big ints
Currently we only support exact 128 bit *unsigned* integers
2023-05-19 20:18:59 +02:00
Luuk de Gram
992de8e617
wasm: implement @addWithOverflow for 64bit ints 2023-05-19 20:18:59 +02:00
Luuk de Gram
8236a26c60
wasm: implement mul, shl and xor for big ints
Uses compiler-rt for multiplication and shifting left, while lowers
it down using regular instructions for xor.
2023-05-19 20:18:59 +02:00
Luuk de Gram
eb77e3381f
wasm: implement @frameAddress 2023-05-19 20:18:58 +02:00
Andrew Kelley
447a302990 Sema: eliminate Type.Tag.var_args_param
This was a special type tag used for hacky stuff in Semantic Analysis.
Move the hacky stuff to use a dedicated `Air.Inst.Ref` instead.

This way, `var_args_param` is not involved in the type system or intern
pool.
2023-05-19 11:05:05 -07:00
Motiejus Jakštys
b61d0debd6 multi-writer: test with a non-comptime stream
Since #14819 this test failed with:

    $ ../../../build/stage3/bin/zig test multi_writer.zig
    multi_writer.zig:26:57: error: unable to evaluate comptime expression
                var batch = std.event.Batch(Error!void, self.streams.len, .auto_async).init();
                                                        ~~~~^~~~~~~~
    referenced by:
        Writer: multi_writer.zig:19:52
        writer: multi_writer.zig:21:36
        remaining reference traces hidden; use '-freference-trace' to see all reference traces

Thanks @jacobly for hints how to fix this on IRC.
2023-05-19 09:13:49 -07:00
Andrew Kelley
b873ce1e0e
Merge pull request #15727 from jacobly0/x86_64-behavior
x86_64: behavior
2023-05-19 00:56:59 -07:00
Andrew Kelley
503302ceef Sema: simplify "duplicate test name" error message
* Avoid redundant words ("found")
   - All compile errors are found by the compiler
 * Avoid unnecessary prepositions ("with")
   - There is a grammatically correct alternate word order without the
     preposition.
2023-05-18 19:17:04 -07:00
Jacob Young
47405b1a1c x86_64: fix @bitCast when the operand dies 2023-05-18 21:02:29 -04:00
Jacob Young
79bdd2bd63 x86_64: implement saturating add/sub for weird types 2023-05-18 20:42:38 -04:00
Jacob Young
60e69fdaa1 codegen: emit global vector padding 2023-05-18 20:42:38 -04:00
Jacob Young
35da95fe87 x86_64: implement integer vector @truncate 2023-05-18 20:42:38 -04:00
Jacob Young
28c445addd x86_64: fix 128-bit atomics on non-linux 2023-05-18 20:42:38 -04:00
Jacob Young
01b63cd081 x86_64: delete some incorrect code 2023-05-18 20:42:38 -04:00
Jacob Young
36ddab03fa x86_64: fix multi-limb compare 2023-05-18 20:42:38 -04:00
Jacob Young
80df8da82f x86_64: initialize array sentinels 2023-05-18 20:42:38 -04:00
Jacob Young
729daed591 x86_64: rewrite casts 2023-05-18 20:42:38 -04:00
Jacob Young
403c2d91be x86_64: fix float min/max behavior 2023-05-18 20:42:38 -04:00
David CARLIER
b9d2e0e308 std.os: add linux timer api 2023-05-19 03:41:10 +03:00
Andrew Kelley
ad391ad399 Revert "Sema: handle recursive inferred errors better in analyzeIsNonErrComptimeOnly"
This reverts commit 5aa9628de3c6637f45b9d8cf8cbd19c422a74f6f.

This is a breaking language change and I do not agree with it. Please go
through the proposal process on this one.
2023-05-18 16:24:07 -07:00
zooster
3d64ed0353
make @trap return unreachable/noreturn (#15749)
`@trap` is a special function that we know never returns so it should
behave just like `@panic` and `@compileError` do currently and cause the
"unreachable code" + "control flow is diverted here" compile error.
Currently, `@trap(); @trap();` does not cause this error. Now it does.
2023-05-18 17:00:35 -04:00
Andrew Kelley
7cf2cbb33e std.crypto.tls.Client.readvAdvanced: fix bugs
* When there is buffered cleartext, return it without calling the
   underlying read function. This prevents buffer overflow due to space
   used up by cleartext.
 * Avoid clearing the buffer when the buffered cleartext could not be
   completely given to the result read buffer, and there is some
   buffered ciphertext left.
 * Instead of rounding up the amount of bytes to ask for to the nearest
   TLS record size, round down, with a minimum of 1. This prevents the
   code path from being taken which requires extra memory copies.
 * Avoid calling `@memcpy` with overlapping arguments.

closes #15590
2023-05-18 03:26:16 -07:00
Andrew Kelley
378264d404
Merge pull request #15750 from ziglang/zig2.c
zig2.c: omit non-essential subcommands
2023-05-17 23:28:35 -07:00
IntegratedQuantum
6e05620117 Document the sorting order in std.sort. 2023-05-17 18:26:49 -07:00
Andrew Kelley
f52189834c rename omit_pkg_fetching_code to only_core_functionality
No functional changes. This renames an internal build option to better
reflect how it is used.
2023-05-17 16:00:24 -07:00
Andrew Kelley
fea6157102 zig2.c: omit non-essential subcommands
When producing zig2.c, don't waste time emitting C code for subcommands
that won't be used, such as objcopy.

This takes zig2.c down from 111M to 109M, and sidesteps some unfortunate
warnings that are currently emitted by GCC.
2023-05-17 15:43:15 -07:00
Andrew Kelley
ad20236e97
Merge pull request #15573 from motiejus/resolv_dn
glibc hacks: also add a few dn_* functions
2023-05-17 10:42:32 -07:00
Andrew Kelley
c1add1e19e
Merge pull request #15459 from motiejus/build-id-full
stage2: implement `--build-id` styles
2023-05-17 07:19:15 -07:00
Andrew Kelley
5b06daf52b zig cc: implement -### (dry run)
closes #7170
2023-05-17 05:18:51 -07:00
Andrew Kelley
fd213accb8
Merge pull request #14462 from motiejus/infile_stdin
zig cc: support reading from stdin via "-x LANG -"
2023-05-17 02:54:51 -07:00
Andrew Kelley
728ce2d7c1 tweaks to --build-id
* build.zig: the result of b.option() can be assigned directly in many
   cases thanks to the return type being an optional
 * std.Build: make the build system aware of the
   std.Build.Step.Compile.BuildId type when used as an option.
   - remove extraneous newlines in error logs
 * simplify caching logic
 * simplify hexstring parsing tests and use a doc test
 * simplify hashing logic. don't use an optional when the `none` tag
   already provides this meaning.
 * CLI: fix incorrect linker arg parsing
2023-05-16 20:39:01 -07:00
Motiejus Jakštys
df5085bde0 stage2: implement --build-id styles 2023-05-16 20:38:39 -07:00
David CARLIER
40e8c2243c std.c: darwin's *copyfile api update. 2023-05-17 06:06:41 +03:00
Frank Denis
c6966486e3
crypto.AegisMac: fix a regression from s/mem.copy/@memcpy/ (#15733)
In an update whose size is not a multiple of the block size,
we would end up calling @memcpy() with arguments of different sizes.
2023-05-16 23:51:47 +00:00
Andrew Kelley
233a0d3991 CLI: remove cleanup logic for stdin temp file
In one of the happy paths, execve() is used to switch to clang in which
case any cleanup logic that exists for this temporary file will not run
and this temp file will be leaked. Oh well. It's a minor punishment for
using `-x c` which nobody should be doing. Therefore, we make no effort
to clean up. Using `-` for stdin as a source file always leaks a temp
file.

Note that the standard `zig build-exe` CLI does not support stdin as an
input file. This is only for `zig cc` C compiler compatibility.
2023-05-16 16:41:22 -07:00
Andrew Kelley
ae119a9a8d CLI: fix stdin dumping behavior
* no need to move `tmpFilePath` around
 * no need for calculating max length of `FileExt` tag name
 * provide a canonical file extension name for `FileExt` so that, e.g.
   the file will be named `stdin.S` instead of
   `stdin.assembly_with_cpp`.
 * move temp file cleanup to a function to reduce defer bloat in a large
   function.
 * fix bug caused by mixing relative and absolute paths in the cleanup
   logic.
 * remove commented out test and dead code
2023-05-16 16:41:22 -07:00
Motiejus Jakštys
2e692312f1 zig cc: support reading from non-files
echo 'some C program' | $CC -x c -

Is a common pattern to test for compiler or linker features. This patch
adds support for reading from non-regular files.

This will make at least one more Go test to pass.
2023-05-16 16:40:58 -07:00
Cortex
c269e16c3b
std.mem.byteSwapAllFields: add suppport for nested structs (#15696) 2023-05-16 19:10:44 -04:00
Andrew Kelley
958fba0eb7
Merge pull request #15713 from alichraghi/ali-spirv
spirv: get more behavior tests passing
2023-05-16 16:09:22 -07:00
David CARLIER
b754068fbc std.c: add ptrace for freebsd support. 2023-05-16 22:47:51 +03:00
Loris Cro
87c7ef31c5
Merge pull request #15731 from der-teufel-programming/autodoc-quickfixes
autodoc: Fix rendering of imported modules
2023-05-16 13:20:16 +02:00
Krzysztof Wolicki
3e5824d2a6 autodoc: Fix rendering of imported modules 2023-05-16 13:11:33 +02:00
Tw
e584dd8062 std.mem.zeroInit: zero hidden padding for extern struct
Signed-off-by: Tw <tw19881113@gmail.com>
2023-05-16 10:33:04 +03:00
Travis Staloch
8bbc906b59 Package: support gitlab tarball urls
Allows the package manager to download gitlab tarballs from urls such as
https://gitlab.com/<namespace>/<project>/-/archive/<sha>/<project>-<sha>.tar.gz

Such http requests have headers Content-Type=application/octet-stream
and Content-Disposition='attachment; filename="<project>-<sha>.tar.gz"'.
The package manager doesn't yet support these headers. This patch
doesn't attempt to properly parse the content-disposition header.
Instead it checks that it starts with 'attachment;' and ends with
'.tar.gz"'.
2023-05-15 22:44:32 -07:00
Andrew Kelley
4ba61a2191
Merge pull request #15704 from Vexu/fix-memcpyset
`@mem{cpy,set}` fixes
2023-05-15 22:39:45 -07:00
David CARLIER
b677b36278 std.c: add netbsd's accept_filter_data for ACCEPT_FILTER sock opt. 2023-05-16 04:31:15 +03:00
Roman Frołow
21b7c48043 Add wasi_ prefix to wasm files 2023-05-15 23:34:43 +03:00