Commit Graph

8419 Commits

Author SHA1 Message Date
Krzysztof Wolicki
80c1d48ccb
autodoc: Implement a[b], a.?, and a.* (#16863)
* autodoc: Implement elem_val_node and basic optional_payload_*

* autodoc: Add `.*` loads
2023-09-03 17:18:16 +02:00
Loris Cro
0516a4d629 autodoc: fix typo 2023-09-03 17:15:15 +02:00
Loris Cro
c0da41582b autodoc: better light mode colors
fix #15799
2023-09-03 17:12:52 +02:00
James Chen-Smith
c3a8f1fe92
autodoc: Extract decl ref style and fix light mode color (#15990)
Co-authored-by: James Chen-Smith <james@chen-smith.net>
Co-authored-by: Loris Cro <kappaloris@gmail.com>
2023-09-03 16:51:07 +02:00
Ambareesh "Amby" Balaji
62f727eedb std.fs: Fix typo in accessAbsoluteW 2023-09-03 12:03:14 +02:00
Jan Philipp Hafer
1816bb4ab0 std.os+windows: isAtLeast(.win10_rs5) in renameatW(), DeleteFile() for posix semantics
Usage of FILE_RENAME_IGNORE_READONLY_ATTRIBUTE or
FILE_DISPOSITION_IGNORE_READONLY_ATTRIBUTE for posix semantics require
win10_rs5 instead of win10_rs1 necessary for posix semantics. Keep it as simple
as possible, since it is reasonable to expect users being able to update
win10_rs5 or use non-posix semantics instead.

Closes #17049.
2023-09-03 08:35:26 +02:00
Josh Wolfe
8b74eae9c6
std.ArrayHashMap.reIndex also recomputes hashes (#17054) 2023-09-02 17:00:20 -04:00
Michal Ziulek
bb2eb44430 std.coff: Fixed compile error. 2023-09-02 00:18:53 +02:00
Ryan Liptak
01f9cdd21a Temporarily disable Dir.statFile test when linking glibc
See https://github.com/ziglang/zig/issues/17034
2023-08-31 18:01:15 -07:00
Ryan Liptak
f46008c1d8 Fix Dir.statFile for WASI when linking libc
`statFile` now only uses `os.fstatatWasi` when not linking libc, matching the pattern used throughout other `Dir` functions. This fixes the compilation error: `error: struct 'c.wasi.Stat' has no member named 'fromFilestat'` (which the added test would have failed with)
2023-08-31 14:07:15 -07:00
Igor Sadikov
4635179857 Optimize std.base64.standard.Encoder.encode 2023-08-29 16:00:31 -04:00
Jakub Konka
3b2b9fcbc5 darwin: move inference of SDK version into the linker
`std.zig.system.darwin.getSdk` now pulls only the SDK path
so we execute a child process only once and not twice as it was
until now since we parse the SDK version directly from the pulled path.
This is actually how `ld64` does it too.
2023-08-29 06:43:41 +02:00
Jay Petacat
26b03ca823 std: Move TailQueue alias to correct namespace
This fixes a mistake in PR #16996.
2023-08-28 17:41:37 -07:00
Jay Petacat
ff61c42879 std: Rename TailQueue to DoublyLinkedList
`TailQueue` was implemented as a doubly-linked list, but named after an
abstract data type. This was inconsistent with `SinglyLinkedList`, which
can be used to implement an abstract data type, but is still named after
the implementation. Renaming `TailQueue` to `DoublyLinkedList` improves
consistency between the two type names, and should help discoverability.

`TailQueue` is now a deprecated alias of `DoublyLinkedList`.

Related to issues #1629 and #8233.
2023-08-27 20:57:46 -07:00
Jacob Young
750998eef6 Build: fail tests that log errors, like zig test does 2023-08-25 15:36:25 -07:00
xdBronch
4403008cab
fix compile errors introduced by #16953 (#16955) 2023-08-25 21:07:24 +00:00
Andrew Kelley
a31748b29e std.os.uefi: reorganize namespaces
This is a breaking change.

This commit applies the following rules to std.os.uefi:
* avoid redundant names in the namespace such as "protocol.FooProtocol"
* don't initialize struct field to undefined. do that at the
  initialization site if you want that, or create a named constant that
  sets all the fields to undefined.
* avoid the word "data", "info", "context", "state", "details", or
  "config" in the type name, especially if a word from that category is
  already in the type name.
* embrace tree structure

After following these rules, `usingnamespace` disappeared naturally.
This commit eliminates 26/53 (49%) instances of `usingnamespace` in the
standard library. All these uses were due to not understanding how
to properly use namespaces.

I did not test this commit. The standard library UEFI code is
experimental and pull requests have been accepted with minimal vetting.
Users of std.os.uefi will need to submit follow-up pull requests to fix
up whatever regressions this commit introduces, this time without
abusing namespaces (pun intended).
2023-08-24 22:38:47 -07:00
matu3ba
7a834e2581
std.windows: use atomic rename, if possible (#16717)
Mitigates #14978.

Uses the same strategy as in #16499 suggested by @squeek502
2023-08-23 20:11:01 -04:00
Andrew Kelley
ada0010471 compiler: move unions into InternPool
There are a couple concepts here worth understanding:

Key.UnionType - This type is available *before* resolving the union's
fields. The enum tag type, number of fields, and field names, field
types, and field alignments are not available with this.

InternPool.UnionType - This one can be obtained from the above type with
`InternPool.loadUnionType` which asserts that the union's enum tag type
has been resolved. This one has all the information available.

Additionally:

* ZIR: Turn an unused bit into `any_aligned_fields` flag to help
  semantic analysis know whether a union has explicit alignment on any
  fields (usually not).
* Sema: delete `resolveTypeRequiresComptime` which had the same type
  signature and near-duplicate logic to `typeRequiresComptime`.
  - Make opaque types not report comptime-only (this was inconsistent
    between the two implementations of this function).
* Implement accepted proposal #12556 which is a breaking change.
2023-08-22 13:54:14 -07:00
Carl Åstholm
60fc18bd1c compiler_rt: fix f80 comparisons
This corrects comparisons between negative numbers.
2023-08-21 11:26:25 -07:00
Gregory Mullen
f74e10cd47 Update default stack frames for general_purpose_allocator.zig
Created from a conversation with  @andrewrk on irc: Memory leaks when using ArrayList can be inconvenient to debug when the stack frame size is 4 because the entirety of the printed frame is within zig stdlib, and not in the users calling stack. Increasing this to 6 for Debug builds, gives 2 frames of user code. I increased the frame size for tests as well by the equivalent factor, but I'm unconvinced that's actually desirable.
2023-08-21 11:22:22 -07:00
mlugg
283afb50b5 AstGen: disallow '-0' integer literal
The intent here is ambiguous: this resolves to the comptime_int '0', but
it's likely the user meant to use a floating-point literal.

Resolves: #16890
2023-08-21 11:47:31 +03:00
mlugg
321961d860 AstGen: add result location analysis pass
The main motivation for this change is eliminating the `block_ptr`
result location and corresponding `store_to_block_ptr` ZIR instruction.
This is achieved through a simple pass over the AST before AstGen which
determines, for AST nodes which have a choice on whether to provide a
result location, which choice to make, based on whether the result
pointer is consumed non-trivially.

This eliminates so much logic from AstGen that we almost break even on
line count! AstGen no longer has to worry about instruction rewriting
based on whether or not a result location was consumed: it always knows
what to do ahead of time, which simplifies a *lot* of logic. This also
incidentally fixes a few random AstGen bugs related to result location
handling, leading to the changes in `test/` and `lib/std/`.

This opens the door to future RLS improvements by making them much
easier to implement correctly, and fixes many bugs. Most ZIR is made
more compact after this commit, mainly due to not having redundant
`store_to_block_ptr` instructions lying around, but also due to a few
bugs in the old system which are implicitly fixed here.
2023-08-20 11:58:14 -07:00
Ryan Liptak
020105d0dd Cache: Fix findPrefix when paths are slightly out of the ordinary
This makes Cache.findPrefix/findPrefixResolved use `std.fs.path.relative` instead of `std.mem.startsWith` when checking if a file is within a prefix. This fixes multiple edge cases around prefix detection:

- If a prefix path ended with a path separator, then the first character of the 'sub_path' would get cut off because the previous implementation assumed it was a path separator. Example: prefix: `/foo/`, file_path: `/foo/abc.txt` would see that they both start with `/foo/` and then slice starting from one byte past the common prefix, ending up with `bc.txt` instead of the expected `abc.txt`
- If a prefix contained double path separators after any component, then the `startsWith` check would erroneously fail. Example: prefix: `/foo//bar`, file_path: `/foo/bar/abc.txt` would not see that abc.txt is a sub path of the prefix `/foo//bar`
- On Windows, case insensitivity was not respected at all, instead the UTF-8 bytes were compared directly

This fixes all of the things in the above list (and possibly more).
2023-08-19 22:32:24 -07:00
Ryan Liptak
a11cdb6a34 os.realpathW: Reduce the number of OpenFile calls for directories
Same as a190582b26 but for os.realpathW instead of fs.Dir.realpathW
2023-08-19 22:29:46 -07:00
Andrew Kelley
4c97919e8e
Merge pull request #16885 from squeek502/windows-selfExePath-symlink
`fs.selfExePath`: Make the Windows implementation follow symlinks
2023-08-19 21:24:36 -07:00
Ryan Liptak
2c2ecd624a fs.selfExePath: Make the Windows implementation follow symlinks
Before, selfExePath would be the path of the symlink on Windows instead of the path of what the symlink points to.

This deprecates fs.selfExePathW since it does not provide a separate use-case over selfExePath (before, the W version could return [:0]u16 directly)

Fixes #16670
2023-08-19 17:48:18 -07:00
Jakub Konka
ddf5859c22 macos: add <paths.h> header to Zig shipped libc 2023-08-19 14:23:00 +02:00
Ryan Liptak
e078324dbe Add NetworkNotFound to ReadLinkError
This matches how other filesystem functions were made to handle BAD_NETWORK_PATH/BAD_NETWORK_NAME in https://github.com/ziglang/zig/pull/16568. ReadLink was the odd one out, but that is no longer the case.
2023-08-18 18:07:16 -07:00
Andrew Kelley
84b4b6bffa
Merge pull request #16818 from ziglang/damn-sysroot
build: do not emit `-iwithsysroot`/`-iframeworkwithsysroot` implicitly
2023-08-18 18:06:20 -07:00
Ryan Liptak
3dd439030c fs tests: Use 127.0.0.1 instead of localhost as the server in UNC transformation
In theory, localhost could be mapped to a different address via the LMHOSTS file, so using 127.0.0.1 should remove that potential wrinkle and allow the drive-absolute -> UNC transformation to work on any(?) setup.

Also print the error name to ensure it gets printed in CI (aarch64-windows ReleaseSmall seemed not to print the error in the last intermittent UNC failure)
2023-08-18 12:21:54 -07:00
Jakub Konka
1e899b8769 check-object: dump contents of LC_BUILD_VERSION and LC_VERSION_MIN_* cmds 2023-08-18 11:56:14 +02:00
Jakub Konka
274400c57d macho: add helper for accessing tools array in LC_BUILD_VERSION cmd 2023-08-18 11:55:29 +02:00
Jakub Konka
71cc2e6759 build: merge FrameworkDir into IncludeDir 2023-08-18 08:08:24 +02:00
Lewis Gaul
387b0ac4f1
Make NaNs quiet by default and other NaN tidy-up (#16826)
* Generalise NaN handling and make std.math.nan() give quiet NaNs

* Address uses of std.math.qnan_* and std.math.nan_* consts

* Comment out failing test due to issues with signalling NaN

* Fix issue in c_builtins.zig where we need qnan_u32
2023-08-18 02:07:49 -04:00
Jakub Konka
23b4a2b8e1 build: disambiguate system framework path (-iframework) from framework path (-F) 2023-08-18 08:00:40 +02:00
Jakub Konka
6a4b29a58f build: remove spurious -iframework flag; use getPath2 for framework path resolution 2023-08-18 08:00:40 +02:00
Jakub Konka
5e945f813c build: do not emit -iwithsysroot/-iframeworkwithsysroot implicitly
Prior to this change, we would unconditionally emit any system include path/framework
path as `-iwithsysroot`/`-iframeworkwithsysroot` if the sysroot was
set which can lead to unexpected build failures. Now, calls to
`b.addSystemIncludePath` and `b.addFrameworkPath` will always emit
search paths as `-isystem`/`-iframework`. As a result, it is now up to
the user to correctly concat the search paths with the sysroot when
and where desired.

If there is a need for emitting `-iwithsysroot`/`-iframeworkwithsysroot`
I would advise adding explicit hooks such as `addSystemIncludePathWithSysroot`
and `addFrameworkPathWithSysroot`.
2023-08-18 08:00:40 +02:00
Andrew Kelley
8c1329b222
Merge pull request #16847 from squeek502/fs-fixes
`std.fs`: Improve tests and fix some bugs that were uncovered
2023-08-17 12:15:51 -07:00
Andrew Kelley
5ae5dc507b
Merge pull request #16824 from mikdusan/bsd
de-bitrot the BSDs
2023-08-17 12:14:30 -07:00
Michael Dusan
e288c54699
std.debug: openbsd does not have getcontext 2023-08-17 10:55:39 -04:00
Ian Johnson
f3f554b9b8
std.json: avoid stale pointers when parsing Value (#16864)
Closes #16861

Using `alloc_if_needed` when parsing a `Value` allows receiving a token
which points to the buffer of the underlying `Reader`. This token will
no longer be valid after the `Reader`'s buffer is refilled, which will
happen with large values. Using `alloc_always` avoids this issue by
ensuring the returned tokens always own their data independently of the
underlying buffer.
2023-08-17 07:52:46 -04:00
Ryan Liptak
2b44961a20 Fix ntToWin32Namespace and friends on big endian architectures 2023-08-17 00:59:19 -07:00
Ryan Liptak
8c8f3cbd43 fs tests: Update some testing.expect calls to use the more specific expect functions 2023-08-17 00:59:19 -07:00
Ryan Liptak
8f5f1ff25a fs tests: Test multiple different path types in most tests
(which path types will depend on which the target supports)
2023-08-17 00:59:19 -07:00
mlugg
000aa30086 std.Build: check for native CPU when serializing CrossTarget
When using `std.Build.dependency` with target options, dependencies
would sometimes get targets which are equivalent but have distinct
names, e.g. `native` vs `native-native`. This is a somewhat broad issue,
and it's unclear how to fix it more generally - perhaps we should
special-case CrossTarget in options passing, or maybe targets should
have a canonical name which we guarantee to use everywhere aside from
raw user input.

However, this commit fixes the most egregious issue, which was an active
blocker to using the package manager for some users. This was caused by
the CPU changing from `native` to a specific descriptor (e.g.
`skylake+sgx`), which then changed the behavior of `zigTriple`.

Resolves: #16856
2023-08-16 18:05:18 -07:00
Jakub Konka
3e228bdf45
Merge pull request #16832 from kcbanner/coff_dwarf_and_pdb
Windows: Support loading debug symbols from both the PDB file and embedded DWARF information
2023-08-16 12:31:22 +02:00
Ryan Liptak
3819e69376 windows.GetFinalPathNameByHandle: Support UNC paths 2023-08-15 15:52:34 -07:00
Ryan Liptak
19b219bc8a Fix windows.CreateSymbolicLink/ReadLink for non-relative paths
This fixes a few things:
- Previously, CreateSymbolicLink would always create a relative link if a `dir` was provided, but the relative-ness of a link should be determined by the target path, not the null-ness of the `dir`.
- Special handling is now done to symlink to 'rooted' paths correctly (they are treated as a relative link, which is different than how the xToPrefixedFileW functions treat them)
- ReadLink now correctly supports UNC paths via a new `ntToWin32Namespace` function which intends to be an analog of `RtlNtPathNameToDosPathName` (RtlNtPathNameToDosPathName is not used because it seems to heap allocate as it takes an RTL_UNICODE_STRING_BUFFER)
2023-08-15 15:52:33 -07:00
Michael Dusan
c685b675e5
std.debug: avoid os.getFdPath
Commit ea9917d9bd introduced usage
of fs.Dir.realpath which eventually calls os.getFdpath which is
forbidden to be used by the compiler. It causes building zig to fail on
OpenBsd, NetBSD and older versions of FreeBSD and DragonFly.

This patch substitutes with os.realpath on libc targets and eventually
calls c.realpath and allows zig to build. Any use of realpath is not
desired but this is the lesser evil.
2023-08-15 17:29:35 -04:00