Commit Graph

8382 Commits

Author SHA1 Message Date
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
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
Michael Dusan
3eedaab731
bsd: std.c.fs: skip test w/ getFdPath in calltree 2023-08-15 17:29:35 -04:00
Michael Dusan
e1216686f3
dragonfly: std.c: more decls
- add ucontext_t, mcontext_t
- add pthread_rwlock_t
2023-08-15 17:29:35 -04:00
Michael Dusan
4532ff2780
netbsd: std.c: fix pthread_rwlock_t
- make .owner field optional
2023-08-15 17:29:35 -04:00
Michael Dusan
bac3c2748f
netbsd: std.dwarf.abi: disable x86_64 regBytes()
We do not yet have correct implementation to access xmm registers from
the world of ucontext/mcontext.

Unimplement .netbsd to allow building zig compiler.
2023-08-15 17:26:39 -04:00
Michael Dusan
25542c3443
netbsd: std.c.REG: populate indexes for x86_64 2023-08-15 17:20:04 -04:00
Ryan Liptak
3e69115784 Do not skip fs.Dir.access test on WASI 2023-08-15 14:00:35 -07:00
Jakub Konka
fdce18cd30 std: fix compilation errors in dwarf/abi.zig when targeting iOS 2023-08-15 22:09:51 +02:00
kcbanner
8a5f331ec8 coff: handle the case of there being no PDB path 2023-08-15 10:20:11 -04:00
kcbanner
5b86180ae3 debug: support looking up debug symbols in both PDB and DWARF debug info, instead of only using DWARF if .debug_info is present
coff: support reading from memory loaded by the loader, or a mapped file
2023-08-15 10:20:11 -04:00
Ryan Liptak
a155e35850
std.json: Fix decoding of UTF-16 surrogate pairs (#16830)
* std.unicode: Add more UTF-16 decoding functions

This mostly makes parts of Utf16LeIterator reusable

* std.json: Fix decoding of UTF-16 surrogate pairs

Before this commit, there were 524,288 codepoints that would get decoded improperly. After this commit, there are 0.

Fixes #16828
2023-08-15 09:11:59 -04:00
e4m2
9135115573
std.crypto.aead: Consistent decryption tail and doc fixes (#16781)
* Consistent decryption tail for all AEADs

* Remove outdated note

This was previously copied here from another function. There used
to be another comment on the tag verification linking to issue #1776,
but that one was not copied over. As it stands, this note seems fairly
misleading/irrelevant.

* Prettier docs

* Add note about plaintext contents to docs

* Capitalization

* Fixup missing XChaChaPoly docs
2023-08-14 21:39:51 +02:00
kcbanner
1054e67f01 dwarf: add missing length check in rowColumns 2023-08-14 11:18:04 -07:00
Andrew Kelley
a1049d4561
Merge pull request #16773 from Sahnvour/build-stack-frames
std.Build: make number of collected stack frames configurable
2023-08-13 13:54:51 -07:00
Sahnvour
2ceeade99a std.Build: add support for deps .d file in Step.Run 2023-08-13 12:15:47 -07:00
Sahnvour
f43402f883 std.Build: factorize Step stack trace dumping code 2023-08-13 11:25:48 +02:00
Sahnvour
078e330555 std.Build: make number of collected stack frames configurable 2023-08-13 10:56:28 +02:00
Andrew Kelley
35b85d3ba5
Merge pull request #16783 from squeek502/fs-too-many-parent-dirs
Windows: Fix `TooManyParentDirs` handling for paths that shouldn't be cwd-relative
2023-08-12 10:38:31 -07:00
Xavier Bouchoux
2da28d93de build/ObjCopy: strip debug info to a separate elf file.
example usage:
    if (!strip) {
        b.installArtifact(exe);
    } else {
        const stripped_exe = b.addObjCopy(exe.getEmittedBin(), .{
            .basename = exe.out_filename, // set the name for the debuglink
            .compress_debug = true,
            .strip = .debug_and_symbols,
            .extract_to_separate_file = true,
        });
        b.getInstallStep().dependOn(&b.addInstallBinFile(stripped_exe.getOutput(), exe.out_filename).step);
        b.getInstallStep().dependOn(&b.addInstallBinFile(stripped_exe.getOutputSeparatedDebug().?, b.fmt("{s}.debug", .{exe.out_filename})).step);
    }
2023-08-12 09:54:35 +02:00
Ryan Liptak
7e542e788c fs tests: Add a 'non-cwd .. parent' test 2023-08-11 18:58:40 -07:00
Ryan Liptak
3f9294c735 Windows: Fix TooManyParentDirs handling for paths that shouldn't be cwd-relative
Previously, a relative path like `..` would:
- Attempt to be normalized (i.e. remove . and .. without any path resolution), but would error with TooManyParentDirs
- This would make wToPrefixedFileW run it through `RtlGetFullPathName_U` to do the necessary path resolution, but `RtlGetFullPathName_U` always resolves relative paths relative to the CWD

Instead, when TooManyParentDirs occurs, we now look up the path of the passed in `dir` (if it's non-null) and append the relative path to it before giving it to `RtlGetFullPathName_U`. If `dir` is null, then we just give it RtlGetFullPathName_U directly and let it resolve it relative to the CWD.

Closes #16779
2023-08-11 18:58:40 -07:00
jaina heartles
b835fd90ce std.http.Server: use correct header for Transfer-Encoding 2023-08-10 17:45:37 -07:00
Ali Chraghi
7ab306d1f7 Build.ConfigHeader: render identifiers 2023-08-10 16:17:32 -07:00
Matt Knight
9959319d53
Compare user input for multiple dependency build variants (#16600) 2023-08-10 18:32:55 -04:00
Ryan Liptak
a190582b26 fs.Dir.realpathW: Reduce the number of OpenFile calls for directories
`.filter = .any` can be used here to remove an unnecessary extra OpenFile call when getting the path of a directory
2023-08-10 13:25:14 -07:00
Andrew Kelley
b820d5df79
Merge pull request #16747 from jacobly0/llvm-wo-libllvm
llvm: enable the backend even when not linked to llvm
2023-08-10 12:02:57 -07:00
Zachary Raineri
0461a64a93
change uses of std.builtin.Mode to OptimizeMode (#16745)
std.builtin.Mode is deprecated.
2023-08-09 14:39:34 -04:00
mllken
9676a43a5d linux: add setsid 2023-08-09 11:33:06 -07:00
Jacob Young
151c06cce4 std.mem.sliceAsBytes: support arrays of zero-bit types
This makes `std.ArrayListUnmanaged(void)` usable.
2023-08-09 05:47:13 -04:00
Philipp Lühmann
d34201c849
std.json: stringify enum literals (#16742) 2023-08-08 23:26:46 +00:00
Andrew Kelley
36c57c3ba1
Merge pull request #16707 from marler8997/jsonStringifyBigNumbers
std.json: fix roundtrip stringify for large integers
2023-08-08 12:08:21 -07:00
Zachary Raineri
49244dc0ca
std: remove some unused imports (#16710) 2023-08-06 15:18:50 -04:00
Loris Cro
373e48c983
autodoc: new layout (#16715)
* autodoc: init guide TOC work

* autodoc: working guides toc navigation

* autodoc: more improvements

* autodoc: ui refinements

* autodoc: new layout and init descriptions for namespaces in std.zig
2023-08-06 18:12:05 +02:00
Jonathan Marler
2046880de8 std.json: josh review fixes
* renamed enum_big_numbers_quoted option to enum_nonportable_numbers_as_strings
* updated stringify doc to mention the option

I also reversed the logic to determine whether an integer is nonportable,
it seemed easier to reason about.

I also took a stab at applying the new option to floats, but, I got stuck
at trying to print large floats, not sure if Zig supports that yet.
2023-08-06 09:25:21 -06:00
Jacob Young
1cce539ddc json.stringify: properly implement RFC8259 recommendation
The previous magic numbers used `1 << 52`, which did not account for the
implicit leading one in the floating point format.  The RFC is correct
when it uses an exponent of 53.  Technically these exclusive endpoints
are also representable, but everyone including the RFC seems to use them
exclusively.

Also, delete special case optimizations related to the type which have
already been implemented in the zig compiler to produce comptime values
for tautological runtime comparisons.
2023-08-06 00:35:10 -04:00
Jonathan Marler
7dacf77745 std.json: fix roundtrip stringify for large integers
std.json follows interoperability recommendations from RFC8259 to limit
JSON number values to those that fit inside an f64.  However, since Zig
supports arbitrarily large JSON numbers, this breaks roundtrip data
congruence.

To appease both use cases, I've added an option `emit_big_numbers_quoted`
to StringifyOptions.  It's disabled by default which preserves roundtrip
but can be enabled to favor interoperability.
2023-08-05 21:56:00 -06:00
none
f3fbdf2b44 wyhash: keep tail bytes on iterative update
Update calls with input longer then one block must ensure that
last sixteen bytes are available when final is called.

Fixes #16695
2023-08-05 15:30:50 -07:00
Ryan Liptak
90fde14c5f std.testing.expectEqualSlices: On failure, print address for pointer types
When comparing slice elements, `std.meta.eql` is used which only compares pointer address and length to determine equality for pointer types. This previously led to confusing results where `expectEqualSlices` would appear to fail on seemingly equal slices (judging by the output of `expectEqualSlices`. For example:

try testing.expectEqualSlices(
    []const i64,
    &[_][]const i64{ &[_]i64{ 1, 2, 3 }, &[_]i64{ 5, 5, 5 } },
    &[_][]const i64{ &[_]i64{ 1, 2, 3 }, &[_]i64{ 5, 5, 5 } },
);

Previously, this would result in:

============ expected this output: =============  len: 2 (0x2)

[0]: { 1, 2, 3 }
[1]: { 5, 5, 5 }

============= instead found this: ==============  len: 2 (0x2)

[0]: { 1, 2, 3 }
[1]: { 5, 5, 5 }

================================================

After this commit, it will result in:

============ expected this output: =============  len: 2 (0x2)

[0]i64@7ff7e2773758: { 1, 2, 3 }
[1]i64@7ff7e2773770: { 5, 5, 5 }

============= instead found this: ==============  len: 2 (0x2)

[0]i64@7ff7e2773788: { 1, 2, 3 }
[1]i64@7ff7e27737a0: { 5, 5, 5 }

================================================
2023-08-05 11:54:26 -07:00