27667 Commits

Author SHA1 Message Date
Andrew Kelley
29cce62a25 CLI: introduce -M; deprecate --mod
I changed my mind on how the CLI for Zig modules should work. I don't
like that `--mod` takes 2 parameters. Instead let's swing all the way in
the other direction: `-M[name][=src]`

This is shorter (Zig CLI invocations are long enough already), avoids
the double parameter edge case, and supports the concept of omitting the
source file part of the argument, which was already wanted for `-Mstd`.
The legacy way to encode that was `--mod std ''` - awkward!

Undocumented support for `--mod` remains so that this branch does not
need a zig1.wasm update. The next time that file is updated, support for
`--mod` can be dropped.

Importantly, this commit also adds support for modules that do not have
a root zig source file. In such case, it sets root to cwd and
root_src_path to empty string, and only sets have_zcu to true if a
module is provided with a root zig source file.
2024-01-19 22:26:13 -07:00
Andrew Kelley
41eff5723d Compilation: avoid caching root source file twice
The deleted lines here are redundant because they happen first thing
inside the function call below.

Additionally, skip hashing the root source file if it is an empty
string. I explored making this field along with `root` optional but
found this to be less messy actually.
2024-01-19 22:18:04 -07:00
Meghan Denny
46d592e485 do not enforce function parameters to be marked comptime if only called at comptime 2024-01-19 15:31:18 -08:00
Andrew Kelley
d7b6d637df
Merge pull request #18615 from ziglang/langref
miscellaneous documentation changes
2024-01-19 12:14:30 -08:00
Andrew Kelley
3c16e80372
Merge pull request #18611 from erikarvstedt/array-list-overflow
ArrayList: remove unneeded overflow checks
2024-01-19 12:10:00 -08:00
David Rubin
100efcf8d3
return optional state to zirPtrCastNoDest 2024-01-19 21:25:05 +02:00
Emil Tywoniak
b80cad2484 libcxx: fix C++ builds with glibc <2.16 without aligned_alloc 2024-01-18 21:37:41 -08:00
Andrew Kelley
96e54e7017 langref: extract code comments into paragraphs
Related #18496
2024-01-18 22:01:09 -07:00
Andrew Kelley
ab82132749 zig build: add doc comments for functions related to options
closes #18204
2024-01-18 22:01:09 -07:00
Andrew Kelley
56db624643 langref: update Zig Build System section
It's hosted externally for now.

closes #18103
2024-01-18 22:01:09 -07:00
Andrew Kelley
8662c0ff43 langref: avoid the ambiguous word "safe"
See #2402
2024-01-18 22:01:09 -07:00
Andrew Kelley
9e6ff71330 langref: delete Nested Container Tests section
This section documented how a buggy feature worked at one point in time
but it's not a description of what is supposed to happen. What is
supposed to happen is simple enough to not warrant any documentation
about it. When a file is imported, all the test decls are supposed to be
queued for analysis.

Also, refAllDecls() is a hack which should not be celebrated or even
mentioned in the language reference.

closes #18042
2024-01-18 22:01:09 -07:00
Andrew Kelley
9b714e019c
Merge pull request #18219 from g-cassie/optional-documentation-tweaks
Minor improvements to the Optionals documentation
2024-01-18 20:34:00 -08:00
Andrew Kelley
6ecf3b1ef3
Merge pull request #18599 from dweiller/err-union-switch-err-trace
astgen: fix error return trace on error union switch
2024-01-18 18:32:52 -08:00
Erik Arvstedt
c50ba2d101 std.ArrayList.replaceRange: remove unneded overflow checks
The code asserted that the range to be replaced is within bounds of
`self.items`.
This is now reflected in the doc comment.
The old, wrong doc comment was copied from the `insert*` fns.

With this assertion holding true, `start + len` is always within the
address space and `start + new_items.len` is, at this point, always
strictly within bounds of `self.items`.
2024-01-19 00:55:17 +01:00
Erik Arvstedt
0bb6967d14 std.ArrayList: remove + 1 overflow checks 2024-01-19 00:55:17 +01:00
Sebastien Marie
7d81c952d5 openbsd: add proper support for aarch64
define openbsd specific elements in std/dwarf/abi.zig regBytes()

work from Jasper Lievisse Adriaanse, with register values from sys/signal.h
and https://github.com/ARM-software/abi-aa/blob/main/aadwarf64/aadwarf64.rst#dwarf-register-names
2024-01-18 15:45:42 -08:00
Nameless
a7dbc57a35 std.http.Client: read response messages with no length until eof 2024-01-18 15:43:58 -08:00
Andrew Kelley
22b9d8987d
Merge pull request #17499 from rootbeer/makepath-dangling-symlink
std.fs: tests for makePath and symlinks
2024-01-18 15:37:16 -08:00
Krzysztof Wolicki
14efbbfd89
std.Uri: change specifier for printing with scheme to semicolon ;
Fetch: print scheme when suggesting adding a ref to git URIs
2024-01-18 09:13:04 +02:00
dweiller
c4cff443b8 test/stack_traces.zig: add err union switch case 2024-01-18 15:10:32 +11:00
David Rubin
6e5bdb5397
add type check to zirSwitchBlockErrUnion 2024-01-18 00:46:00 +00:00
dweiller
7ef3d3876a astgen: fix error return trace on error union switch 2024-01-18 04:47:31 +11:00
Techatrix
ec358d6db5 sema: fix safe integer arithmetic operations on undefined values
Previously `@as(i64, undefined) +% 1` would produce `@as(@TypeOf(undefined), undefined)` which now gives `@as(i64, undefined)`.
Previously `@as(i64, undefined) +| 1` would hit an assertion which now gives `@as(i64, undefined)`.
2024-01-16 16:27:31 -08:00
Loris Cro
4ace1f5a7f Build: add namedWriteFiles to Build 2024-01-16 16:09:58 -08:00
Jay Petacat
fd43baa9ad byos: Ease GeneralPurposeAllocator integration
These changes enable me to use `GeneralPurposeAllocator` with my "Bring
Your Own OS" package. The previous checks for a freestanding target have
been expanded to `@hasDecl` checks.

- `root.os.heap.page_allocator` is used if it exists.
- `debug.isValidMemory` only calls `os.msync` if it's supported.
2024-01-16 15:05:38 -08:00
Andrew Kelley
a338c279f8
Merge pull request #15565 from xEgoist/spawnWindows
child_process: Add write and inheritable access to the null handle
2024-01-16 15:03:25 -08:00
ocrap7
1ce12db5c8 Skip all dbg instructions 2024-01-16 15:01:42 -08:00
melonedo
9b0da5ccef Fix TLS record overflow by limiting inner record length to 2^14
Per last paragraph of RFC 8446, Section 5.2, the length of the inner content of an encrypted record must not exceed 2^14 + 1, while that of the whole encrypted record must not exceed 2^14 + 256.
2024-01-16 14:58:56 -08:00
Pat Tullmann
ff5613873f std/fs/test.zig: Add statFile() tests of dangling symlink
Create a dangling symlink and check that statFile works with it.
2024-01-16 14:19:48 -08:00
Pat Tullmann
d35bdc8ee7 std/fs/test.zig: Try harder to clean up locking files 2024-01-16 14:19:48 -08:00
Pat Tullmann
c36962bb19 std/fs/test.zig: Factor out the symlink-creation wrappers
Because creation of a symlink can fail on Windows with an Access Denied
error (https://learn.microsoft.com/en-us/windows/security/threat-protection/security-policy-settings/create-symbolic-links)
any tests that need a symbolic link "skip" if they run into this problem.

This change factors out a "setupSymbolicLink()" routine to make this
clearer, a bit tighter, and easier to use in future tests.

I also collapsed the "symlink in parent directory" test into the existing
"Dir.readlink" test, because the latter uses the more comprehensive
testWithAllSupportedPathTypes wrapper.
2024-01-16 14:19:48 -08:00
Pat Tullmann
95a0e127b3 std/fs/test.zig: quote . and .. in test names
The test runner uses "." in its output between the test module and the
test name, so quote the leading '.' in these test names to make them
easier to read.
2024-01-16 13:49:00 -08:00
Purrie
c4a1b54ebe tls client interface consistency fix
Client for tls was using a function that wasn't declared on the
interface for it. The issue wasn't apparent because net stream
implemented that function.

I changed it to keep the interface promise of what's required to be
compatible with the tls client functionality.
2024-01-16 13:02:00 -08:00
Piotr Szlachciak
c724cc6487 Move the paragraph to under variables 2024-01-16 20:18:45 +02:00
Piotr Szlachciak
2d4ebcffbf Move the extern paragraph to a more logical place 2024-01-16 20:18:45 +02:00
Piotr Szlachciak
6a3f9a0b50 Add missing != null operator 2024-01-16 20:17:29 +02:00
travisstaloch
f3353708d8
AstGen: use correct token_src for switch, if and while exprs
fixes #18579
2024-01-16 18:22:44 +02:00
february cozzocrea
da506aaf6e
translate-c: Explicit cast bool from float fix 2024-01-16 18:12:05 +02:00
february cozzocrea
50457482b1
translate-c: Fix for compound assign implicit cast error 2024-01-16 17:57:31 +02:00
Andrew Kelley
195eeed2d8 std: remove deprecated API 2024-01-16 04:20:05 -08:00
Andrew Kelley
fe870418b1
Merge pull request #18584 from Techatrix/fix-switch-on-err
fix ast gen failure to catch incorrect by ref error captures
2024-01-16 02:42:06 -08:00
xEgoist
194ed30825 child_process: Use security attributes while creating handle.
As suggested by @matu3ba, it can be better to use Security Attributes
directly while creating the handle instead of creating the handle then
setting the handle to inherit. Doing so can prevent potentially leaking
to other parallel spawned processes which would inherit the opened `\Device\Null`
handle.

This change also allows windows.OpenFile to handle when bInheritHandle
is set.

Note that we are using the same `saAttr`, but since it's taken as a
pointer to a const in all calls, it's never mutated, and OpenFile never alters it.

This also saves 1 kernel call for setting the handle to inherit.
2024-01-16 01:25:14 -08:00
xEgoist
41bf816fa6 child_process: Add write access to the null handle
This commit allows write access to the `\\Device\\Null` Handle.
Without a write access, it's not possible for the child process to write
SdOut to Null. As a requirement `SetHandleInformation` was also changed
to mark the handle as iheritable (by adding it to Flags) by the spawned process.
This allows the child to access the NUL device that was opened.

This also makes the Windows part to behave similarly to `spawnPosix`.
2024-01-16 01:25:14 -08:00
Krzysztof Wolicki
7116b02210 Allow multiple options using the same enum type 2024-01-15 23:08:11 -08:00
Andrew Kelley
88ee323cd7
Merge pull request #18570 from gh-fork-dump/linux-6.7
Linux: Update syscall bits for 6.7
2024-01-15 23:04:02 -08:00
Andrew Kelley
d1ce8b8837
Merge pull request #18168 from cipharius/feature/zig-build-fossil-support
Adds support for Fossil SCM source tree archives as zig build dependencies
2024-01-15 23:02:50 -08:00
Andrew Kelley
ca8c6dd4d6
Merge pull request #18569 from dweiller/17944-followup
17944 followup
2024-01-15 22:59:33 -08:00
Andrew Kelley
fcc94f5431
Merge pull request #18468 from notcancername/legalize-arraylist
std.array_list: Document and reduce illegal behavior in ArrayLists
2024-01-15 22:46:27 -08:00
Andrew Kelley
f2721a4cbc std.ArrayList: pedantic rewordings of documentation and unit tests 2024-01-15 23:44:36 -07:00