Commit Graph

9700 Commits

Author SHA1 Message Date
David Rubin
341857e5cd make addCSourceFiles assert options.files are relative 2024-03-26 14:03:39 +02:00
Prokop Randáček
055023efb4
valgrind client request wrappers take const pointers (#19237)
* valgrind client request wrappers take const pointers

* require zero terminated strings in valgrind wrappers
2024-03-26 14:00:13 +02:00
Veikka Tuominen
59203cb4f2
Merge pull request #19385 from markus-oberhumer-forks/improve-old-glibc-versions
Improve old glibc versions
2024-03-26 13:56:07 +02:00
Luis Cáceres
29e41c6850 std.Build: dupe provided paths for Step.Fmt.create() 2024-03-26 13:54:24 +02:00
Andrew Kelley
405502286d
Merge pull request #19414 from mlugg/comptime-mutable-memory-yet-again
compiler: implement analysis-local comptime-mutable memory
2024-03-25 16:32:18 -07:00
Andrew Kelley
abadad4640
Merge pull request #19402 from ianprime0509/markdown-autolinks
Autodoc: hyperlink URLs in text
2024-03-25 15:36:37 -07:00
Andrew Kelley
32b4d85605
Merge pull request #19406 from jacobly0/haiku
haiku: get a cross-compiled compiler working
2024-03-25 15:33:51 -07:00
HydroH
ef31d8f48f
autodoc: better indentation handling when rendering source code (#19422)
Closes #19293
2024-03-25 18:20:15 -04:00
mlugg
9c3670fc93
compiler: implement analysis-local comptime-mutable memory
This commit changes how we represent comptime-mutable memory
(`comptime var`) in the compiler in order to implement the intended
behavior that references to such memory can only exist at comptime.

It does *not* clean up the representation of mutable values, improve the
representation of comptime-known pointers, or fix the many bugs in the
comptime pointer access code. These will be future enhancements.

Comptime memory lives for the duration of a single Sema, and is not
permitted to escape that one analysis, either by becoming runtime-known
or by becoming comptime-known to other analyses. These restrictions mean
that we can represent comptime allocations not via Decl, but with state
local to Sema - specifically, the new `Sema.comptime_allocs` field. All
comptime-mutable allocations, as well as any comptime-known const allocs
containing references to such memory, live in here. This allows for
relatively fast checking of whether a value references any
comptime-mtuable memory, since we need only traverse values up to
pointers: pointers to Decls can never reference comptime-mutable memory,
and pointers into `Sema.comptime_allocs` always do.

This change exposed some faulty pointer access logic in `Value.zig`.
I've fixed the important cases, but there are some TODOs I've put in
which are definitely possible to hit with sufficiently esoteric code. I
plan to resolve these by auditing all direct accesses to pointers (most
of them ought to use Sema to perform the pointer access!), but for now
this is sufficient for all realistic code and to get tests passing.

This change eliminates `Zcu.tmp_hack_arena`, instead using the Sema
arena for comptime memory mutations, which is possible since comptime
memory is now local to the current Sema.

This change should allow `Decl` to store only an `InternPool.Index`
rather than a full-blown `ty: Type, val: Value`. This commit does not
perform this refactor.
2024-03-25 14:49:41 +00:00
Simon Brown
5c628312b1
std.enums: fix EnumSet.init and EnumMap.init for non-exhaustive enums 2024-03-24 22:29:27 +00:00
Jacob Young
af0668d6c2 Build.Cache: fix UAF during unhit 2024-03-24 18:28:16 +00:00
Jacob Young
879ea2710f reduce: fix compile errors
Regressed by c11b6adf13.
2024-03-24 17:29:39 +01:00
Marc Tiehuis
091aa54a3e fix comptime float formatting
Closes #19379
Closes #18046
2024-03-24 10:23:48 +02:00
Ben Sinclair
e90583f5d1 std.fmt.fmtIntSize{Bin,Dec}: Don't add .0... to bytes
These are the fundamental units so they can't have decimal places.
2024-03-24 01:15:22 +02:00
Jacob Young
2dd74cd312 haiku: debitrot 2024-03-23 18:11:32 +01:00
Jacob Young
a7282d0910 WasmAllocator: fix safety panic during OOM 2024-03-23 11:32:37 +01:00
Jacob Young
ff7ca4b70f Build.Cache: fix UAF during unhit 2024-03-23 11:32:37 +01:00
Jakub Konka
640acf8625
Merge pull request #19396 from ziglang/coff-stdlib
lib/std/coff: port more definitions
2024-03-23 11:22:49 +01:00
Ian Johnson
ad34ed5a63 Autodoc: recognize Markdown links in plain text
This extension to the typical `<>` Markdown autolink syntax allows
HTTP(S) links to be recognized in normal text without being delimited by
`<>`. This is the most natural way to write links in text, so it makes
sense to support it and allow documentation comments to be written in a
more natural way.
2024-03-22 20:53:25 -04:00
Ian Johnson
d3ca9d55d9 Autodoc: implement Markdown autolinks
Closes #19265

This commit implements support for Markdown autolinks delimited by angle
brackets. The precise syntax accepted is documented in the doc comment
of `markdown.zig`.
2024-03-22 20:03:32 -04:00
Jakub Konka
86c4c33d2c lib/std/coff: add ImportHeader, and Relocation metadata 2024-03-22 15:12:11 +01:00
Jakub Konka
2326f0e53b lib/std/coff: add undocumented machine type ARM64EC 2024-03-22 15:05:32 +01:00
Jakub Konka
541e3a03ec lib/std/coff: allow for unhandled enum values 2024-03-22 14:04:17 +01:00
regeliv
13a9d94a80 Change std.os.exit to std.process.exit 2024-03-22 15:01:02 +02:00
Andrew Kelley
d8bb139da4
Merge pull request #19390 from ziglang/valgrind
make the behavior tests run almost valgrind clean
2024-03-22 02:04:48 -07:00
Andrew Kelley
a2651cbc82
Merge pull request #19388 from ziglang/cache-dedup
cache system file deduplication
2024-03-22 01:13:43 -07:00
Andrew Kelley
950359071b std.Build.Cache: bump manifest_file_size_max to 100M
Some users are hitting this limit. I think it's primarily due to not
deduplicating (solved in the previous commit) but this seems like a
better limit regardless.
2024-03-21 19:56:47 -07:00
Andrew Kelley
2f4bbd6c63 std.Build.Cache: use an array hash map for files
Rather than an ArrayList. Provides deduplication.
2024-03-21 19:56:30 -07:00
Andrew Kelley
ebec7336e2 std.array_hash_map: remove meta context verification
The zig way is to let the compiler provide errors, rather than trying to
implement the compiler in the standard library.

I played around with this and found the compile errors to be easier to
comprehend without this logic.
2024-03-21 19:40:56 -07:00
Andrew Kelley
1e46e36eac std.array_hash_map: enhance doc comments
- more readable in markdown
- remove confusing stuff
- linkification
- rewording
- move parameter documentation to parameter documentation
2024-03-21 17:54:58 -07:00
Andrew Kelley
7bc0b74b6d move Package.Path to std.Build.Cache.Path 2024-03-21 16:16:47 -07:00
Andrew Kelley
8778dc4bb2 extract std.Build.Cache.Directory into separate file 2024-03-21 16:11:59 -07:00
Andrew Kelley
54c08579e4
Merge pull request #19348 from jedisct1/wasi-threads-compfix
Unbreak support for WASI threads
2024-03-21 15:13:15 -07:00
Sean
f32723a237
Update frexp.zig (#19370)
1. Entirely rewrote frexp with generics, reducing the implementation to a single function and enabling parameters of types f80 and f16
2. Expanded upon the tests, making them more descriptive and comprehensive, and automatically generating the test bodies for each floating point type
3. Added a doctest for frexp
2024-03-21 18:08:52 -04:00
Andrew Kelley
4dc50151c4 std.mem.indexOfSentinel: valgrind integration
this code returns false positives in Valgrind, so we fall back to the
other implementation when running in valgrind.

see #17717
2024-03-21 15:01:57 -07:00
Andrew Kelley
33428fc6aa std.mem.indexOfScalarPos: valgrind integration
this code returns false positives in Valgrind, so we fall back to the
other implementation when running in valgrind.

see #17717
2024-03-21 14:35:37 -07:00
Andrew Kelley
afa0834195 add std.debug.inValgrind
This is like `@inComptime` but for the Valgrind virtual machine.

Related #17717
2024-03-21 14:35:08 -07:00
Andrew Kelley
12191c8a22 std: promote tests to doctests
Now these show up as "example usage" in generated documentation.
2024-03-21 14:11:46 -07:00
Andrew Kelley
5ae838d105 std: remove one layer of redundant parse_float namespace
there are still more, though.

This provides a doctest for the `parseFloat` function.
2024-03-21 14:08:54 -07:00
Andrew Kelley
c5bd19e45e std.Build.addTest: add doc comments
closes #15009
2024-03-21 14:02:58 -07:00
Marc Tiehuis
31791ae15b rename ryu128 -> format_float
Symmetry with parse_float and to hide the implementation from the user.
Additionally, we expose the entire namespace and provide some aliases so
everything is available to a user.

Closes #19366
2024-03-21 17:10:41 +02:00
Michael Ortmann
afdc41cfd6 std.os.windows: add POLL.IN and POLL.OUT 2024-03-21 17:08:50 +02:00
Igor Anić
e831313b10 std.io: remove BufferedTee
Introduced in  #19032 as a fix for #18967.
Not needed any more after #19253.
2024-03-20 21:05:35 -07:00
Andrew Kelley
43edd53c33
Merge pull request #19365 from ziglang/update-mingw-w64
Update mingw-w64 and add Win32 def files
2024-03-20 17:33:56 -07:00
Andrew Kelley
4bc18c52f7 std.hash_map: fix pointer lock safety false positive
closes #19358
2024-03-20 17:14:52 -07:00
Michael Dusan
e4ed63f138 bsd: followup to std.posix extraction from std.os
netbsd fix:
- `Futex.zig:542:56: error: expected error union type, found 'c_int'`

openbsd fix:
- `emutls.zig:10:21: error: root struct of file 'os' has no member named 'abort'`
- `Thread.zig:627:22: error: expected 6 argument(s), found 5`
2024-03-20 14:06:35 -07:00
Andrew Kelley
f47e92ca0d mingw-w64: update to latest master
upstream commit 0bac2d3cdb122dadcdee90009f7e24a69d56939f
2024-03-20 11:26:09 -07:00
Andrew Kelley
25fb6de83c mingw-w64: update to reflect latest tool changes
upstream commit dddccbc3ef50ac52bf00723fd2f68d98140aab80

closes #18968
2024-03-20 11:23:51 -07:00
Andrew Kelley
cba1555104 std: don't do BYOS at the POSIX API layer
This was a mistake from day one. This is the wrong abstraction layer to
do this in.

My alternate plan for this is to make all I/O operations require an IO
interface parameter, similar to how allocations require an Allocator
interface parameter today.
2024-03-20 00:38:44 -07:00
Andrew Kelley
5d389535e8 std: fix inconsistent errno size on linux
Now it's always u16
2024-03-20 00:36:41 -07:00
Andrew Kelley
8c94950c24 fix compilation failures found by CI 2024-03-19 16:18:18 -07:00
Andrew Kelley
cd62005f19 extract std.posix from std.os
closes #5019
2024-03-19 11:45:09 -07:00
Frank Denis
9b454a8ce2 WASI-thread: panic if no allocator is given 2024-03-19 13:11:33 +01:00
Andrew Kelley
c52a2c338d std.Build.Step.Run: documentation for addFileArg and friends
Someone on IRC got these functions mixed up, and it sure would have been
helpful to have these docs in the first place, eh?
2024-03-18 23:52:52 -07:00
Frank Denis
c470016743 Unbreak support for WASI threads 2024-03-18 16:51:41 +01:00
Andrew Kelley
cbeab678a5
Merge pull request #19325 from Vexu/dynlib
std: adjust DynLib API
2024-03-17 20:19:51 -07:00
Reokodoku
1206604262
Implementing structs and better enums in build options 2024-03-18 02:46:54 +00:00
Jacob Young
c11b6adf13 Ast: fix comptime destructure
A preceding `comptime` keyword was being ignored if the first
destructure variable was an expression.
2024-03-17 15:23:16 -07:00
Veikka Tuominen
e6f74b78ef std: define error set of toPosixPath 2024-03-17 09:06:54 +02:00
Jacob Young
e646e01161 Revert "back out the build_runner.zig moving change"
This reverts commit 1a01151a4e in
preparation for a zig1.wasm update.
2024-03-17 03:06:39 +01:00
Jacob Young
d10c52c194 AstGen: disallow alignment on function types
A pointer type already has an alignment, so this information does not
need to be duplicated on the function type.  This already has precedence
with addrspace which is already disallowed on function types for this
reason.  Also fixes `@TypeOf(&func)` to have the correct addrspace and
alignment.
2024-03-17 03:06:17 +01:00
Leo Emar-Kar
f88a971e4f
std.fmt: fix incorrect rounding on 0 precision of a decimal 2024-03-16 23:38:46 +00:00
Veikka Tuominen
ec2465542c std: adjust DynLib API
The cross-platform functions now use an error set that contains all possible errors on every platform.
2024-03-17 01:20:08 +02:00
Andrew Kelley
242ab81112
std: introduce pointer stability locks to hash maps (#17719)
This adds std.debug.SafetyLock and uses it in std.HashMapUnmanaged by
adding lockPointers() and unlockPointers().

This provides a way to detect when an illegal modification has happened and
panic rather than invoke undefined behavior.
2024-03-16 18:45:10 -04:00
Jari Vetoniemi
7628785983 std: use expectError in dynamic_library tests 2024-03-16 23:27:36 +02:00
Jari Vetoniemi
59e9f529df std: do not use inferred errors in dynamic_library
The error unions for WindowsDynLib and ElfDynLib do not contain all the possible errors.
So user code that relies on DynLib.Error will fail to compile.
2024-03-16 23:27:36 +02:00
Stephen Gregoratto
67df3ded68 Windows: make FILE_INFO_BY_HANDLE_CLASS a tagged enum
Fixes a TODO referencing the ancient issue #305.
2024-03-16 23:37:50 +11:00
Stephen Gregoratto
69175ad62f Windows: Add wrappers for GetCurrent(Process|Thread) via NT_TIB
This is how they've been implemented in `kernel32` since NT 3.1.
2024-03-16 23:37:50 +11:00
Stephen Gregoratto
9532f72937 Windows: Replace CreatePipe with ntdll implementation
This implementation is now a direct replacement for the `kernel32` one.
New bitflags for named pipes and other generic ones were added based on
browsing the ReactOS sources.

`UNICODE_STRING.Buffer` has also been changed to be nullable, as
this is what makes the implementation work.
This required some changes to places accesssing the buffer after a
`SUCCESS`ful return, most notably `QueryObjectName` which even referred
to it being nullable.
2024-03-16 23:37:50 +11:00
Igor Anić
3ea1276eeb
io_uring: ring mapped buffers (#17806)
* io_uring: ring mapped buffers

Ring mapped buffers are newer implementation of ring provided buffers, supported
since kernel 5.19. Best described in Jens Axboe [post](https://github.com/axboe/liburing/wiki/io_uring-and-networking-in-2023#provided-buffers)

This commit implements low level io_uring_*_buf_ring_* functions as mostly
direct translation from liburing. It also adds BufferGroup abstraction over those
low level functions.

* io_uring: add multishot recv to BufferGroup

Once we have ring mapped provided buffers functionality it is possible to use
multishot recv operation. Multishot receive is submitted once, and completions
are posted whenever data arrives on the socket. Received data are placed in a
new buffer from buffer group.

Reference: [io_uring and networking in 2023](https://github.com/axboe/liburing/wiki/io_uring-and-networking-in-2023#multi-shot)

Getting NOENT for cancel completion result, meaning:
  -ENOENT
    The request identified by user_data could not be located.
    This could be because it completed before the cancelation
    request was issued, or if an invalid identifier is used.

https://man7.org/linux/man-pages/man3/io_uring_prep_cancel.3.html
https://github.com/ziglang/zig/actions/runs/6801394000/job/18492139893?pr=17806

Result in cancel/recv cqes are different depending on the kernel.
on older kernel (tested with v6.0.16, v6.1.57, v6.2.12, v6.4.16)
  cqe_cancel.err() == .NOENT
  cqe_crecv.err() == .NOBUFS
on kernel (tested with v6.5.0, v6.5.7)
  cqe_cancel.err() == .SUCCESS
  cqe_crecv.err() == .CANCELED
2024-03-15 22:34:31 -04:00
Andrew Kelley
ce4245f873
Merge pull request #19312 from mikdusan/bsd-debitrot
bsd: debitrot
2024-03-15 16:59:05 -07:00
Loris Cro
5cd7fef17f build runner: add --summary new
`new` only prints summary nodes that were not cached.
Useful for build.zig authors to check if rebuilds happen exactly only
when expected.
2024-03-15 09:13:01 -07:00
Nguyễn Gia Phong
f13401ac69 Fix stuttering stderr in Zig test log
Before this fix, the stderr FIFO was advanced by the length
of the trimmed message, thus the next error log contained
the tail of that message.
2024-03-15 16:45:58 +02:00
garrisonhh
1ddd0691c6 std.mem: use destructurable tuple for indexOfMinMax return type 2024-03-15 16:40:51 +02:00
expikr
67a40c679d
make math.degreesToRadians and math.radiansToDegrees infer type from argument 2024-03-15 16:31:02 +02:00
paoda
a4508ad716 fix(math): eval isPowerOfTwo at comptime in rotl/rotr 2024-03-15 16:19:48 +02:00
Michael Dusan
d7cf25f5ca
bsd: debitrot std.c
- follow-up to f4bf061d8a
- updated std.fs.Dir to use properly named symbols
2024-03-15 02:28:50 -04:00
Michael Dusan
5ce40e61c6
bsd: debitrot AtomicOrder renames
- complete std.builtin.AtomicOrder renames that were missed from 6067d39522
2024-03-15 02:28:50 -04:00
Michael Dusan
cf4a2099e1
dragonfly: debitrot std.c 2024-03-15 02:28:50 -04:00
Elaine Gibson
6b38758594 coff: only store PDB basename 2024-03-14 18:56:02 -07:00
Michael Dusan
6724a524d4 bsd: add missing os.IFNAMESIZE
- based on system API value IF_NAMESIZE
- unblocks `zig test lib/std/std.zig`
2024-03-14 18:54:25 -07:00
Matthew Lugg
39459e78ad
Merge pull request #19273 from mlugg/incremental-some-more
compiler: more progress on incremental
2024-03-14 17:45:21 +00:00
Ahmed
5c8eda36d6 chore: Fix some typos 2024-03-14 19:43:24 +02:00
Andrew Kelley
bc5b094695 remove std.io.PeekStream
See #16114. This functionality should be added to bufferedReader
instead.
2024-03-14 07:48:47 -07:00
Luuk de Gram
0103c4bf78 std: make std.dwarf.FixedBufferReader public
Also fixes a compile-error as the field `is_64` no longer exists.
2024-03-14 02:57:46 -07:00
mlugg
00969062a9
compiler: detect duplicate test names in AstGen
There is no reason to perform this detection during semantic analysis.
In fact, doing so is problematic, because we wish to utilize detection
of existing decls in a namespace in incremental compilation.
2024-03-14 07:40:05 +00:00
Andrew Kelley
778ab767b1
Merge pull request #19258 from castholm/enums-eval-branch-quota
std.enums: Increase eval branch quotas
2024-03-13 18:50:12 -07:00
Jonathan Marler
32f602ad16
std.os.windows: handle OBJECT_NAME_INVALID in OpenFile (#19288)
It's been seen on Windows 11 (22H2) Build 22621.3155 that NtCreateFile
will return the OBJECT_NAME_INVALID error code with certain path names.
The path name we saw this with started with `C:Users` (rather than
`C:\Users`) and also contained a `$` character.  This PR updates our
OpenFile wrapper to propagate this error code as `error.BadPathName`
instead of making it `unreachable`.

see https://github.com/marler8997/zigup/issues/114#issuecomment-1994420791
2024-03-13 21:39:20 -04:00
Carl Åstholm
2008b14bc7 autodoc: Use code for keyboard events 2024-03-13 18:37:00 -07:00
pancelor
7a858257f2 remove math.lerp bounds for t
I think of lerp() as a way to change coordinate systems, essentially
remapping the input numberline onto a shifted+rescaled numberline. In
my mind the full numberline is remapped, not just the 0-1 segment.

An example of how this is useful: in a game, you can write:
`myPos = lerp(pos0, pos1, easeOutBack(u))`
for some `u` that changes from 0 to 1 over time.
(see https://easings.net/#easeOutBack)
This will animate `myPos` between `pos0` and `pos1`, overshooting the
goal position `pos1` in a nicely-animated way.
`easeOutBack(float)->float` is a pure function that overshoots 1,
and by combining it with `lerp()` we can remap coordinates in other
coordinate systems, making them overshoot in the same way.

However, this overshooting is only possible because `easeOutBack(t)`
sometimes exceeds the range 0-1 (e.g. `easeOutBack(0.5)` is 1.0877),
which is not allowed by the current `math.lerp` implementation.

This commit removes the asserts that prevented this use-case. Now, any
value can be inputted for t. For example, `lerp(10,20, 2.0)` will now
return 30, instead of throwing an assert error.
2024-03-13 18:35:07 -07:00
Andrew Kelley
ea8e9e668b
Merge pull request #19289 from ianic/issue_19052
compress.xz: fix slow running read loop
2024-03-13 18:32:50 -07:00
Adrià Arrufat
17bad9f886 Fix emscripten exports 2024-03-13 21:47:31 +01:00
Igor Anić
791c4491a7 compress.xz: remove unnecessary variable
`to_read.items.len is always zero when entering readBlock.
2024-03-13 18:43:36 +01:00
Igor Anić
54f882c4aa compress.xz: make reader loop little more readable
No need to do same error check on two places. First return all
uncompressed data then on last read check error.
2024-03-13 18:41:20 +01:00
Igor Anić
a21f9b6d8b compress.xz: remove copyForwards from tight loop
In the example from the issue #19052 to_read holds 213_315_584
uncompressed bytes. Calling read with small output results in many
shifts of that big buffer.
This removes need to shift to_read after each read.
2024-03-13 18:22:08 +01:00
Michael Dusan
22fd1851bd
zig libc: allow non-native targets
On macos, allow targets supported by the SDK. This then spawns `xcrun`
and correct paths are emitted for:

- x86_64-macos
- x86_64-ios
- x86_64-tvos
- x86_64-watchos
- x86_64-ios-macbi
- aarch64-macos
- aarch64-ios
- aarch64-tvos
- aarch64-watchos
- aarch64-ios-macbi

On platforms with android NDK, allow android targets. Example usage:

```
CC=/NDK/.../bin/aarch64-linux-android34-clang zig libc -target aarch64-linux-android
```
2024-03-13 02:17:28 -04:00
Frank Denis
153ba46a5b
{aegis,aes_gcm}: fix overflow with large inputs on 32-bit systems (#19270)
These systems write the number of *bits* of their inputs as a u64.

However if `@sizeOf(usize) == 4`, an input message or associated data
whose size is > 512 MiB could overflow.

On 64-bit systems, it is safe to assume that no machine has more than
2 EiB of memory.
2024-03-12 22:56:28 +00:00
Frank Denis
b8920bceb7
ml_kem.zig: inLen -> in_len (#19269)
Don't use camelCase for variable names, especially just for that one.
2024-03-12 19:52:06 +00:00
Andrew Kelley
da5b16f9e2
Merge pull request #19238 from dweiller/ring-buffer
std.RingBuffer: minor cleanup and doc improvements
2024-03-11 18:49:16 -07:00
Andrew Kelley
cb4e087fda
Merge pull request #19239 from jedisct1/ml-kem
std.crypto: add support for ML-KEM
2024-03-11 18:48:08 -07:00