9105 Commits

Author SHA1 Message Date
mlugg
eae9aa800e
std: avoid references that trigger compile errors
Note that the `_ = Address` statements in tests previously were a nop,
and now actually check that the type is valid. However, on WASI, the
type is *not* valid.
2024-07-04 21:01:42 +01:00
Jonathan Marler
d9f1a952b8 build: fix WriteFile and addCSourceFiles not adding LazyPath deps
Adds a missing call to addLazyPathDependenciesOnly in
std.Build.Module.addCSourceFiles.  Also fixes an issue in
std.Build.Step.WriteFile where it wasn't updating all the GeneratedFile
instances for every directory.  To fix the second issue, I removed
all the GeneratedFile instances and now all files/directories reference
the steps main GeneratedFile via sub paths.
2024-07-04 13:34:17 -04:00
Andrew Kelley
768b17755e
Merge pull request #19615 from ianic/tar_diagnostic
std.tar: add strip components error to diagnostics
2024-07-03 21:29:04 -04:00
Techatrix
8f7b50e2c4 json: respect duplicate_field_behavior in std.json.Value.jsonParse 2024-07-03 15:34:59 -04:00
Igor Anić
035c1b6522 std.tar: add strip components error to diagnostics
This was the only kind of error which was raised in pipeToFileSystem and
not added to Diagnostics.
Shell tar silently ignores paths which are stripped out when used with
`--strip-components` switch. This enables that same behavior, errors
will be collected in diagnostics but caller is free to ignore that type
of diagnostics errors.
Enables use case where caller knows structure of the tar file and want
to extract only some deeply nested folders ignoring upper files/folders.

Fixes: #17620 by giving caller options:
- not provide diagnostic and get errors
- provide diagnostics and analyze errors
- provide diagnostics and ignore errors
2024-07-03 12:12:50 -07:00
Michael Bradshaw
fe66a12a23 Rename nonSIMDCall* to nonSimdCall* 2024-07-03 19:00:17 +01:00
Michael Bradshaw
21cad3e09f Rename MAX_NAME_BYTES to max_name_bytes 2024-07-03 17:42:09 +01:00
Nikita
e1d4cf67ca Add two new io_uring flags to linux.zig 2024-07-03 05:28:55 -04:00
cryptocode
cb182432b0 [std.c] Add eventfd and dup3 functions to FreeBSD
The eventfd system call and dup3 library call have been available
since FreeBSD 13 and 10 respectively, and are thus available in
all [FreeBSD releases not deemed EOL](<https://endoflife.date/freebsd>)

The lack of these were discovered when porting a terminal emulator
to FreeBSD. It would be nice to have them included in Zig's stdlib.
2024-07-03 05:27:21 -04:00
wooster0
5e3bad3556 Make 0e.0 and 0xp0 not crash
This fixes those sequences of characters crashing.
2024-07-03 02:53:37 -04:00
Michael Bradshaw
02b3d5b58a Rename isASCII to isAscii 2024-07-02 16:31:15 +02:00
David Rubin
e4447c54ea add ppc64 reloc definitions 2024-07-02 08:59:10 +02:00
Andrew Kelley
fed8d9054c
Merge pull request #19267 from PanSashko/compile-dup-mod
Fix adding module arguments for Step.Compile
2024-07-02 01:10:34 -04:00
Sashko
8ef24461a0 DynLib: fix a typo in DynLib.openZ 2024-07-01 19:44:20 -04:00
Sashko
604a332e21 Extract getZigArgs function in std.Build.Step.Compile 2024-07-01 16:36:13 -07:00
mlugg
5b523d0469
Zir: make src_line absolute for declaration instructions
We need special logic for updating line numbers anyway, so it's fine to
just use absolute numbers here. This eliminates a field from `Decl`.
2024-06-26 05:28:03 +01:00
Bogdan Romanyuk
ab4c461b76
std.mem.zeroes: explicit compile error for @Type(.EnumLiteral) 2024-06-24 00:43:09 +00:00
Alex Rønne Petersen
1ede3af9f6 std.zig.target: Remove armeb-windows-gnu and aarch64_be-windows-gnu.
This doesn't actually exist; Windows on Arm only runs on little endian. MinGW
also doesn't work for these targets at all.
2024-06-23 19:53:52 -04:00
Frank Denis
f3655fd07d
std.crypto.chacha: fix typo in XChaChaIETF.stream() (#20399)
Thanks to @r4gus for reporting this.

Fixes #20398
2024-06-23 13:20:18 +00:00
Bram
5f58956264 std: Extended type checks for Thread startFn return type 2024-06-23 04:35:00 +01:00
Sean
f1b6f1aeb3
std.meta.hasUniqueRepresentation: Handle optional pointers correctly (#20366)
std.meta.hasUniqueRepresentation should now return true for non-slice optional pointers. Additional checks were added to the test to reflect this.
2024-06-23 03:33:45 +00:00
Michael Bradshaw
642093e04b Rename *[UI]LEB128 functions to *[UI]leb128 2024-06-23 04:30:12 +01:00
Alex Rønne Petersen
9be9b8ca90 std.Build.findProgram(): Try with and without the Windows executable extensions.
I renamed std.process.Child.CreateProcessSupportedExtension to WindowsExtension
and made it public to avoid duplicating the list of extensions.

While here, I also improved it to not misreport OOM from std.fs.realpathAlloc()
as a generic failure to find the program, but instead panic like the rest of the
build system does for OOM.

Closes #20314.
2024-06-21 15:41:03 -04:00
Ryan G
b6fd34aa46
std.static_string_map: Cast length of input for runtime initialization 2024-06-20 23:22:39 +00:00
Igor Anić
b8890f8ee1 io_uring: don't assume completions order (2)
In my first [try](https://github.com/ziglang/zig/pull/20224) to fix
20212 I didn't reproduce bug on required kernel (6.9.2) and wrongly
concluded that first two completions have different order on newer
kernel.
On my current kernel (6.5.0) order of completions is: send1, recv,
send2. On 6.9.2 order is send1, send2, recv. This fix allows second two
completions to arrive in any order.
Tested on both kernels.

Fixes: #20212
2024-06-20 18:03:28 -04:00
Alex Kladov
e03026507f
std: fuzz test sort stability (#20284)
Stability of std sort was undertested before this change. Add a fuzz
test for more confidence.

Specifically, we used to have a single example test that used an array
of eight elements. That ends up exercising only a tiny fraction of
sorting logic, as it hits a hard-coded sorting network due to small
size.
2024-06-20 12:38:54 -07:00
Alex Kladov
5afd774db3 std: mark Build.args as const
I don't think these are intended to be mutated!
2024-06-20 15:17:31 -04:00
Matthew Lugg
f73be120f4
Merge pull request #20299 from mlugg/the-great-decl-split
The Great Decl Split (preliminary work): refactor source locations and eliminate `Sema.Block.src_decl`.
2024-06-20 11:07:17 +01:00
mlugg
1fdf13a148 AstGen: error for redundant @inComptime() 2024-06-19 03:43:13 +01:00
Isaac Freund
5f2bdafa39 std.posix: remove unchecked std.os.linux usage
Using std.os.linux directly in e.g. std.posix.timerfd_create() causes
the function to compile but silently fail at runtime when targeting any
OS other than Linux.

To catch errors like this at compile time, std.os.linux must only be
directly accessed within std.posix where there has been a comptime check
that the target os is in fact Linux.
2024-06-18 22:35:28 +02:00
rohlem
0ffeec4b4d fix std.meta.eql for comptime-only union
switch from `inline for` with `std.mem.eql`
to `inline else` and tag comparison.

add previously-failing test code.
2024-06-18 19:04:16 +02:00
rohlem
17ce3e5a17 fix std.testing.expectEqual for comptime-only union
switch from `inline for` with `std.mem.eql`
to `inline else` and tag comparison;
expectEqualDeep(Inner) was already doing this.

add a previously-failing test case.
2024-06-18 19:01:05 +02:00
mlugg
75395c99c5
Zir: track reifications across updates
This was always necessary, it was just missing logic. It is necessary
due to type equivalence rules.
2024-06-18 04:48:24 +01:00
mlugg
0486aa5081
Zir: provide absolute node for reify
Since we track `reify` instructions across incremental updates, it is
acceptable to treat it as the baseline for a relative source location.
This turns out to be a good idea, since it makes it easy to define the
source location for a reified type.
2024-06-18 04:48:24 +01:00
Isaac Freund
a1777cb5cb
std: fix pthread_{get,set}name_np return type ABI
I believe this was accidentally broken when the E enum for errno values
was introduces. These functions are quite the special case in that they
return the error value directly rather than returning -1 and passing the
error value through the errno variable.

In any case, using a u16 as the return type at the ABI boundary where a
c_int is expected is asking for trouble.
2024-06-17 23:26:53 +02:00
Isaac Freund
687a756bf9
std: make all dirent structs extern
Using structs with unspecified layout on the ABI boundry can't end well.
2024-06-17 23:26:53 +02:00
Jay Petacat
254a3ba9d9 std.zip: Fix typo in doc comments 2024-06-17 16:12:19 -04:00
Andrew Kelley
fda2458f6a
Merge pull request #20321 from ziglang/build-system-fmt
enhance `std.Build.Step.Fmt` and use it more
2024-06-17 01:04:57 -04:00
Alex Rønne Petersen
2c373b0fb6 std.Target: Update known Windows 10/11 versions and build numbers. 2024-06-16 23:37:38 -04:00
Alex Rønne Petersen
6220c754cf std.Build: Add Step.Fail and addFail() function.
Closes #15373.
2024-06-16 23:13:12 -04:00
Alex Rønne Petersen
c533233f42 Revert "start: workaround for LLVM 17 regression"
This reverts commit d7daf7c203f583ed440efc68df6ee690ee8f8f32.

This is no longer needed with the LLVM 18 upgrade, and it was breaking PIE.

Closes #20306.
2024-06-16 23:11:08 -04:00
Andrew Kelley
eb8201afde std.Build.Step.Fmt: display non-conforming files
When in --check mode, and files are found to not conform, emit them
explicitly as step errors. Previously this stdout data was being
ignored.
2024-06-16 19:30:14 -07:00
Andrew Kelley
af7afbd08b std.Build.Step: split evalChildProcess into two functions
Now there is `captureChildProcess` which gives access to the
`std.process.Child.RunResult`, which is useful for accessing the stdout.

It also accepts and passes an optional `std.Progress.Node` to the child.
2024-06-16 19:29:05 -07:00
Andrew Kelley
42658de762 std.process.Child: run fn accepts std.Progress.Node
There was not a way to pass a progress node to this function until now.
2024-06-16 19:28:13 -07:00
Andrew Kelley
20e20f9238 std.Progress.Node: add none init value 2024-06-16 19:27:49 -07:00
Marc Tiehuis
1b728e1834 std.float.parseFloat: fix large hex-float parsing
There were two primary issues at play here:
 1. The hex float prefix was not handled correctly when the stream was
    reset for the fallback parsing path, which occured when the mantissa was
    longer max mantissa digits.
 2. The implied exponent was not adjusted for hex-floats in this branch.

Additionally, some of the float parsing routines have been condensed, making
use of comptime.

closes #20275
2024-06-15 18:23:06 +02:00
mlugg
b8d2323b88
Sema: eliminate Block.src_decl
🦀 src_decl is gone 🦀

This commit eliminates the `src_decl` field from `Sema.Block`. This
change goes further to eliminating unnecessary responsibilities of
`Decl` in preparation for its major upcoming refactor.

The two main remaining reponsibilities had to do with namespace types:
`src_decl` was used to determine their line number and their name. The
former use case is solved by storing the line number alongside type
declarations (and reifications) in ZIR; this is actually more correct,
since previously the line number assigned to the type was really the
line number of the source declaration it was syntactically contained
within, which does not necessarily line up. Consequently, this change
makes debug info for namespace types more correct, although I am not
sure how debuggers actually utilize this line number, if at all. Naming
types was solved by a new field on `Block`, called `type_name_ctx`. In a
sense, it represents the "namespace" we are currently within, including
comptime function calls etc. We might want to revisit this in future,
since the type naming rules seem to be a bit hand-wavey right now.

As far as I can tell, there isn't any more preliminary work needed for
me to start work on the behemoth task of splitting `Zcu.Decl` into the
new `Nav` (Named Addressable Value) and `Cau` (Comptime Analysis Unit)
types. This will be a sweeping change, impacting essentially every part
of the pipeline after `AstGen`.
2024-06-15 00:58:35 +01:00
mlugg
07a24bec9a
compiler: move LazySrcLoc out of std
This is in preparation for some upcoming changes to how we represent
source locations in the compiler. The bulk of the change here is dealing
with the removal of `src()` methods from `Zir` types.
2024-06-15 00:57:52 +01:00
mlugg
e39cc0dff7
Zir: use absolute nodes for declarations and type declarations
The justification for using relative source nodes in ZIR is that it
allows source locations -- which may be serialized across incremental
updates -- to be relative to the source location of their containing
declaration. However, having those "baseline" instructions themselves be
relative to their own parent is counterproductive, since the source
location updating problem is only being moved to `Decl`. Storing the
absolute node here instead makes more sense, since it allows for this
source location update logic to be elided entirely in the future by
storing a `TrackedInst.Index` to resolve a source location relative to
rather than a `Decl.Index`.
2024-06-15 00:57:52 +01:00
Peng Guanwen
82a934bb91 Fix futex2_waitv syscall
The syscall gives immediate compile error in zig 0.12. This fix that.
2024-06-13 16:51:13 -04:00