22796 Commits

Author SHA1 Message Date
Andrew Kelley
2641feb9b9
Merge pull request #14789 from jacobly0/ditype
llvm: fix use after free with pointers to optional slices
2023-03-05 16:32:51 -05:00
r00ster91
f1ae688d37 AstGen: ensure certain builtin functions return void
Fixes #14779

Co-authored-by: Veikka Tuominen <git@vexu.eu>
2023-03-05 23:01:17 +02:00
jiacai2050
29c56a8aa7 fix package redeclaration when cache is not found 2023-03-05 14:59:34 -05:00
Andrew Kelley
7b01af2bfd
Merge pull request #14745 from jacobly0/bigint
CBE: add support for integers larger than 128 bits (and apparently vectors too)
2023-03-05 14:48:06 -05:00
jim price
a63134a4a5 std.os: Add DeviceBusy as a possible write error
In Linux when writing to various files in the virtual file system,
for example /sys/fs/cgroup, if you write an invalid value to a file
you'll get errno 16.

This change allows for these specific cases to be caught instead of
being lumped together in UnexpectedError.
2023-03-05 17:56:44 +02:00
Jacob Young
1efd36cd5c CBE: fix reduce of emulated integers 2023-03-05 06:32:55 -05:00
Jacob Young
8ea1c1932e behavior: disable failing tests 2023-03-05 04:25:04 -05:00
Jacob Young
7352d461cf behavior: fix comptime issue and disable failing test 2023-03-05 03:34:57 -05:00
Jacob Young
33fa25ba44 CBE: ensure uniqueness of more internal identifiers 2023-03-05 02:59:02 -05:00
Jacob Young
0b0298aff2 CBE: implement select and shuffle 2023-03-05 02:59:02 -05:00
Jacob Young
aac4707902 CBE: implement splat 2023-03-05 02:59:02 -05:00
Jacob Young
ba69ee488b CBE: implement vector truncate 2023-03-05 02:59:02 -05:00
Jacob Young
8f6da78fb1 CBE: implement vector element pointers 2023-03-05 02:59:02 -05:00
Jacob Young
c478c7609e CBE: implement vector operations
Also, bigint add and sub which is all I was actually trying to do.
2023-03-05 02:59:02 -05:00
Jacob Young
b2e9c0d0ff Sema: fix cmp_vector type 2023-03-05 02:59:02 -05:00
Jacob Young
9e3a5ecd39 CBE: fix behavior test failures on msvc 2023-03-05 02:59:02 -05:00
Jacob Young
e96a0fd0a1 CBE: "compute" max int alignment the lazy way 2023-03-05 02:59:01 -05:00
Jacob Young
93d696e84e CBE: implement some big integer and vector unary operations 2023-03-05 02:59:01 -05:00
Jacob Young
a8f4ac2b94 CBE: implement big integer and vector comparisons 2023-03-05 02:59:01 -05:00
Jacob Young
874ae81f1b CBE: implement big integer literals 2023-03-05 02:59:01 -05:00
Andrew Kelley
e7f128c205
Merge pull request #14782 from r00ster91/trap
add `@trap` builtin
2023-03-04 16:20:31 -05:00
tranquillity-codes
c9d990d790 fix doc Build Mode 2023-03-04 23:13:15 +02:00
Andrew Kelley
16302578d5 add behavior test case for previous commit 2023-03-04 14:04:58 -07:00
r00ster91
010596c930 AstGen: compile-error on primitive value export
Fixes #14778

Co-authored-by: Veikka Tuominen <git@vexu.eu>
2023-03-04 22:52:57 +02:00
Jacob Young
2cf27c5718 llvm: fix incorrectly annotated DIType
Closes #14715
Closes #14783
2023-03-04 13:52:47 -07:00
r00ster91
4eb3f50fcf Wasm @breakpoint: emit unreachable
This should improve the developer debugging experience.
2023-03-04 12:08:23 +01:00
r00ster91
65368683ad add @trap builtin
This introduces a new builtin function that compiles down to something that results in an illegal instruction exception/interrupt.
It can be used to exit a program abnormally.

This implements the builtin for all backends.
2023-03-04 12:08:19 +01:00
Andrew Kelley
653814f76b std.Build.addModule: return the created module 2023-03-04 05:39:14 -05:00
Jakub Konka
18e6d1e819
Merge pull request #14781 from ziglang/codegen-cleanup
codegen: move common logic for generating typed values from each native backend into codegen.zig
2023-03-04 03:38:12 +01:00
r00ster91
e0d3904638 Ast: properly handle sentinel-terminated slices in tuple
Co-authored-by: Veikka Tuominen <git@vexu.eu>
2023-03-04 01:08:03 +02:00
r00ster91
d6bd00e855 Zir: move set_cold from Inst.Tag to Inst.Extended
If I could mark a builtin function as cold, I would mark @setCold as cold.
We have run out of `Zir.Inst.Tag`s so I had to move a tag from Zir.Inst.Tag to
Zir.Inst.Extended. This is because a new noreturn builtin will be added and
noreturn builtins cannot be part of Inst.Tag:
```
/// `noreturn` instructions may not go here; they must be part of the main `Tag` enum.
pub const Extended = enum(u16) {
```

Here's another reason I went for @setCold:
```
$ git grep setRuntimeSafety | wc -l
322
$ git grep setCold | wc -l
79
$ git grep setEvalBranchQuota | wc -l
82
```

This also simply removes @setCold from Autodoc and the docs frontend because
as far as I could understand it, builtins represented using Zir extended
instructions are not yet supported because I couldn't find
@setStackAlign or @setFloatMode there, either.
2023-03-03 21:16:21 +01:00
Ali Chraghi
75ff34db9e std.Build.Cache: remove 'test-filetimestamp.tmp' once timestamp returned 2023-03-03 13:50:44 -05:00
Jakub Konka
dc709fbf48 codegen: rename GenerateSymbolError to CodeGenError 2023-03-03 18:56:57 +01:00
Jakub Konka
d23472747e elf: fully zero out symbol when appending to freelist 2023-03-03 18:53:47 +01:00
Jakub Konka
f6eeb6c8ce sparc64: use common implementation of genTypedValue 2023-03-03 18:53:30 +01:00
Jakub Konka
5b3ea49806 riscv64: use common implementation of genTypedValue 2023-03-03 18:53:13 +01:00
Jakub Konka
0d2c25ca9d aarch64: use common implementation of genTypedValue 2023-03-03 18:46:08 +01:00
Andrew Kelley
2834b937f1 link: give executable bit to wasm executables sometimes
Give +x to the .wasm file if it is an executable and the OS is WASI.
Some systems may be configured to execute such binaries directly. Even
if that is not the case, it means we will get "exec format error" when
trying to run it rather than "access denied", and then can react to that
in the same way as trying to run an ELF file from a foreign CPU
architecture.

This is part of the strategy to unify RunStep and EmulatableRunStep.
2023-03-03 12:43:12 -05:00
Jakub Konka
d8d8842190 arm: skip unimplemented behavior test for @fieldParentPtr 2023-03-03 18:42:29 +01:00
Jakub Konka
c413ac100f codegen: refactor generating Int as immediate where appropriate 2023-03-03 18:40:16 +01:00
Jakub Konka
1024332adc arm: use common implementation of genTypedValue helper 2023-03-03 18:24:58 +01:00
Jakub Konka
c746cbc686 codegen: move gen logic for typed values, consts and decl ref to common codegen 2023-03-03 18:06:25 +01:00
Eckhart Köppen
6be5946ed8 sema: Place functions on AVR in flash addrspace
- Use .flash as the default address space for functions on AVR
- Return .flash as the address space for function pointers on AVR
  without explicit address space
2023-03-03 15:20:31 +02:00
Frank Denis
fdee558e45 crypto.25519.field: de-inline _sq()
May fix #14764
2023-03-03 07:51:23 -05:00
Andrew Kelley
aaaaab9ec2 std.process.Child: remove pid and handle, add id
Previously, this API had pid, to be used on POSIX systems, and handle,
to be used on Windows.

This commit unifies the API, defining an Id type that is either the pid
or the HANDLE depending on the target OS.

This commit also prepares for the future by allowing one to import via
`std.process.Child` which is the fully qualified namespace that I intend
to migrate to in the future.
2023-03-03 07:49:05 -05:00
Andrew Kelley
bb5006d728 std: add fchmodat
Also add `std.fs.has_executable_bit` for doing conditional compilation.

This adds the linux syscalls for chmod and fchmodat, as well as the
extern libc function declarations.

Only `fchmodat` is added to `std.os`, and it is not yet added to std.fs.
2023-03-03 02:37:45 -05:00
Andrew Kelley
426c13dddf add doc comments to std.fs.File.default_mode 2023-03-03 01:00:44 -05:00
Frank Denis
4789cc0249
crypto.KeccakF: compute rotations at comptime, add a test with f=800 (#14760) 2023-03-02 19:14:41 +00:00
Frank Denis
28364166e8
crypto.hash.sha3: make permutation generic and public, add SHAKE (#14756)
Make the Keccak permutation public, as it's useful for more than
SHA-3 (kMAC, SHAKE, TurboSHAKE, TupleHash, etc).

Our Keccak implementation was accepting f as a comptime parameter,
but always used 64-bit words and 200 byte states, so it actually
didn't work with anything besides f=1600.

That has been fixed. The ability to use reduced-round versions
was also added in order to support M14 and K12.

The state was constantly converted back and forth between bytes
and words, even though only a part of the state is actually used
for absorbing and squeezing bytes. It was changed to something
similar to the other permutations we have, so we can avoid extra
copies, and eventually add vectorized implementations.

In addition, the SHAKE extendable output function (XOF) was
added (SHAKE128, SHAKE256). It is required by newer schemes,
such as the Kyber post-quantum key exchange mechanism, whose
implementation is currently blocked by SHAKE missing from our
standard library.

Breaking change: `Keccak_256` and `Keccak_512` were renamed to
`Keccak256` and `Keccak512` for consistency with all other
hash functions.
2023-03-02 06:13:40 +00:00
Andrew Kelley
db8217f9a0 packages: avoid creating multiple modules with same build.zig
When there is a diamond dependency, reuse a *Module instead of creating
a redundant one using the same build.zig file. Otherwise, the compile
error "file exists in multiple modules" would occur.
2023-03-01 20:01:23 -05:00