Commit graph

11782 commits

Author SHA1 Message Date
Andrew Kelley
b31c32879d WIP 2025-03-27 17:21:16 -07:00
Matthew Lugg
d0911786c9
Merge pull request #22397 from Techatrix/type-safe-ast
improve type safety of std.zig.Ast
2025-03-12 02:22:41 +00:00
mlugg
24db007cde std.mem.Allocator.remap: fix incorrect doc comment (part 2) 2025-03-11 22:15:43 +00:00
孙冰
77395457fe std.c: fix sysconf names (std.c._SC) for android api
c.f. https://android.googlesource.com/platform/bionic/+/refs/heads/main/libc/include/bits/sysconf.h
2025-03-11 21:41:58 +01:00
Linus Groh
f660675467 std: Add support for SerenityOS in various places
Not nearly the entire downstream patchset but these are completely
uncontroversial and known to work.
2025-03-11 14:59:42 +00:00
Linus Groh
79a0de2a2f std.c: Add definitions for SerenityOS 2025-03-11 14:59:29 +00:00
mlugg
5ffd8bf5f6 std.mem.Allocator.remap: fix incorrect doc comment
Resolves: #23194
2025-03-11 04:15:38 +00:00
Alex Rønne Petersen
9840157c18 std.Target.Query: Don't append glibc version in zigTriple() if ABI isn't GNU. 2025-03-09 19:50:13 +01:00
Carmen
17b40b1d68 lib/std/os/uefi/status.zig: add error to enum conversion fn 2025-03-09 10:54:21 +00:00
Meghan Denny
0f6056903b std: Abi.default: only require an os tag 2025-03-09 09:44:11 +01:00
Pat Tullmann
eace31c6b3 std/lib: {fs,io,posix} test clean up
* use `tmp.dir.realpathAlloc()` to get full path into tmpDir instances
* use `testing.allocator` where that simplifies things (vs. manual ArenaAllocator for 1 or 2 allocs)
* Trust `TmpDir.cleanup()` to clean up contained files and sub-trees
* Remove some unnecessary absolute paths (enabling WASI to run the tests)
* Drop some no-longer necessary `[_][]const u8` casts
* Add scopes to reduce `var` usage in favor of `const`
2025-03-09 07:41:06 +01:00
remeh
02f63fdee9 std/containers: improve consistency using gpa parameter name for allocator. 2025-03-09 07:39:20 +01:00
Jeremy Hertel
801a95035c std.time.epoch: change getDaysInMonth to accept the year as an argument 2025-03-08 14:25:28 -05:00
Jacob Young
a5900e310e compiler-rt: fix signed min int from float 2025-03-08 14:21:22 -05:00
Pat Tullmann
214750fcfe lib/std/Build/Cache.zig: remove .wasi SkipZigTest checks
The build Cache test pass on Wasi now.

Fixes #5437
2025-03-08 04:38:29 +01:00
Techatrix
4129f7ff5a
std.zig.Ast: store lbrace and rbrace token in data of .error_set_decl
This makes the `.data` field the better choice over the `.main_token` for this tag.
2025-03-07 22:22:01 +01:00
Techatrix
d84055f9c6
std.zig.Ast: don't set the data field on .error_value and .enum_literal
The main_token already has the necessary information.
2025-03-07 22:22:01 +01:00
Techatrix
ba74af2ae8
std.zig.Ast: update doc comments of Node.Tag
The existing comment are incomplete, outdated and sometimes incorrect.
2025-03-07 22:22:01 +01:00
Techatrix
ca6fb30e99
std.zig.Ast: improve type safety
This commits adds the following distinct integer types to std.zig.Ast:
- OptionalTokenIndex
- TokenOffset
- OptionalTokenOffset
- Node.OptionalIndex
- Node.Offset
- Node.OptionalOffset

The `Node.Index` type has also been converted to a distinct type while
`TokenIndex` remains unchanged.

`Ast.Node.Data` has also been changed to a (untagged) union to provide
safety checks.
2025-03-07 22:22:01 +01:00
Techatrix
6dcd8f4f75
std.zig.Ast: add blockStatements and builtinCallParams 2025-03-07 22:20:35 +01:00
Techatrix
de9c889a0e
aro_translate_c: fix ast lowering of continue node
fixes #22601
2025-03-07 22:20:35 +01:00
Techatrix
c19f4c4402
fix ZonGen error message when encountering an array access 2025-03-07 22:20:35 +01:00
Techatrix
ad38af77fa
remove unreachable code paths from std.zig.Ast.lastToken
This function checks for various possibilities that are never produced
by the parser.
Given that lastToken is unsafe to call on an Ast with errors, I also
removed code paths that would be reachable on an Ast with errors.
2025-03-07 22:20:34 +01:00
Andrew Kelley
5765736867 fix InstallArtifact opening empty string
this appears to have been a problem since 43f73af359
2025-03-07 15:21:40 -05:00
Andrew Kelley
4cefd1bd1b
Merge pull request #23097 from ziggoon/master
std.heap.PageAllocator updates to fix race condition and utilize NtAllocateVirtualMemory / NtFreeVirtualMemory instead of VirtualAlloc / VirtualFree
2025-03-06 14:39:09 -05:00
190n
1e0739f0c6 std.enums.tagName: preserve sentinel in return value 2025-03-06 08:41:51 +01:00
ziggoon
5b03e248b7 add FFI & wrappers for NtAllocateVirtualMemory & NtFreeVirtualMemory + add missing alloction constants MEM_RESERVE_PLACEHOLDER / MEM_PRESERVE_PLACEHOLDER 2025-03-04 22:10:49 -06:00
ziggoon
16875b3598 update std.heap.PageAllocator Windows implementation to remove race condition and utilize NtAllocateVirtualMemory / NtFreeVirtualMemory instead of VirtualAlloc and VirtualFree 2025-03-04 22:01:08 -06:00
Linus Groh
79460d4a3e Remove uses of deprecated callconv aliases 2025-03-05 03:01:43 +00:00
Alex Rønne Petersen
3c924abb69 std.zig.llvm.bitcode_writer: Fix word byte order on big endian systems.
The bitcode format always uses little endian words. Prior to this commit, a
bitcode file produced on e.g. aarch64_be or s390x would fail to be loaded by
LLVM.
2025-03-04 17:28:03 -05:00
Andrew Kelley
1e2b3b1df9 std.Build.Step: fix missing path sep in error message
I have a more robust solution to this coming up in the writer interface
branch.
2025-03-03 17:18:18 -08:00
Matthew Lugg
c76f451abc
Merge pull request #22979 from mlugg/remove-legacy-coercions
Sema: remove legacy coercion
2025-03-03 22:18:28 +00:00
Fausto Ribeiro
edabcf6192 std.DynLib: fix proper type of chain_ptr on GnuHashSection32
Type is correct on GnuHashSection64 but not on 32 bit version. Change it so
use of DynLib on 32-bit archs compiles.
2025-03-03 20:01:05 +01:00
Linus Groh
3bea47883a std.time: Make Instant.since() work on UEFI 2025-03-02 23:16:34 +00:00
Linus Groh
1a03b8c899 std.os.uefi: Fix two padding mistakes in the Time struct
```c
//************************************************
//EFI_TIME
//************************************************
// This represents the current time information
typedef struct {
   UINT16    Year;              // 1900 - 9999
   UINT8     Month;             // 1 - 12
   UINT8     Day;               // 1 - 31
   UINT8     Hour;              // 0 - 23
   UINT8     Minute;            // 0 - 59
   UINT8     Second;            // 0 - 59
   UINT8     Pad1;
   UINT32    Nanosecond;        // 0 - 999,999,999
   INT16     TimeZone;          // —1440 to 1440 or 2047
   UINT8     Daylight;
   UINT8     Pad2;
 }   EFI_TIME;
```
2025-03-02 23:16:34 +00:00
Linus Groh
6378295b77 std.os.uefi: Fix integer overflow in Time.toEpoch()
Instead of thinking hard about what the actual supported maximum value
for each sub-calculation is we can simply use an u64 from hours onwards.
2025-03-02 22:58:45 +00:00
rpkak
0367d684fc add parentheses in std.heap.page_size_min 2025-03-02 22:27:57 +01:00
Frank Denis
d8d2aa9af4
crypto.pcurves.common: generalize invert() (#23039)
The Bernstein-Yang inversion code was meant to be used only with the
fields we currently use for the NIST curves.

But people copied that code and were confused that it didn't work as
expected with other field sizes.

It doesn't cost anything to make it work with other field sizes,
that may support in the future. So let's do it.
This also reduces the diff with the example zig code in fiat crypto.

Suggested by @Rexicon226 -- Thank you!
2025-03-02 11:27:04 +01:00
Andrew Kelley
235001a646 zig init template: remove outdated comments
closes #23040
2025-03-01 16:11:59 -08:00
Andrew Kelley
6c3cbb0c87
Merge pull request #22994 from ziglang/newhash
implement new package hash format: `$name-$semver-$hash`
2025-02-28 04:40:05 -05:00
Andrew Kelley
6b6c1b1b0e Revert "Merge pull request #22898 from kristoff-it/deprecated-proposal"
This reverts commit dea72d15da, reversing
changes made to ab381933c8.

The changeset does not work as advertised and does not have sufficient
test coverage.

Reopens #22822
2025-02-28 01:37:10 -08:00
Alex Rønne Petersen
5c44934e20 Move the compiler's LLVM bitcode builder to std.zig.llvm. 2025-02-27 01:32:49 -05:00
Andrew Kelley
dea72d15da
Merge pull request #22898 from kristoff-it/deprecated-proposal
Implement `@deprecated`
2025-02-27 01:31:09 -05:00
Brad Olson
c031b62b83 compiler.build_runner: only build Fuzz on 64-bit platforms 2025-02-26 19:16:05 -05:00
Andrew Kelley
de43f5eb6a rename "nonce" to "fingerprint" 2025-02-26 11:42:04 -08:00
Andrew Kelley
67904e925d zig init: adjust template lang to allow zig fmt passthrough 2025-02-26 11:42:04 -08:00
Andrew Kelley
0fc7c9f57c switch from "id" to "nonce"
mainly this addresses the following use case:

1. Someone creates a template with build.zig.zon, id field included
   (note that zig init does not create this problem since it generates
   fresh id every time it runs).
2. User A uses the template, changing package name to "example" but not
   id field.
3. User B uses the same template, changing package name also to
   "example", also not changing the id field.

Here, both packages have unintentional conflicting logical ids.

By making the field a combination of name checksum + random id, this
accident is avoided. "nonce" is an OK name for this.

Also relaxes errors on remote packages when using `zig fetch`.
2025-02-26 11:42:03 -08:00
Andrew Kelley
d6a88ed74d introduce package id and redo hash format again
Introduces the `id` field to `build.zig.zon`.

Together with name, this represents a globally unique package
identifier. This field should be initialized with a 16-bit random number
when the package is first created, and then *never change*. This allows
Zig to unambiguously detect when one package is an updated version of
another.

When forking a Zig project, this id should be regenerated with a new
random number if the upstream project is still maintained. Otherwise,
the fork is *hostile*, attempting to take control over the original
project's identity.

`0x0000` is invalid because it obviously means a random number wasn't
used.

`0xffff` is reserved to represent "naked" packages.

Tracking issue #14288

Additionally:

* Fix bad path in error messages regarding build.zig.zon file.
* Manifest validates that `name` and `version` field of build.zig.zon
  are maximum 32 bytes.
* Introduce error for root package to not switch to enum literal for
  name.
* Introduce error for root package to omit `id`.
* Update init template to generate `id`
* Update init template to populate `minimum_zig_version`.
* New package hash format changes:
  - name and version limited to 32 bytes via error rather than truncation
  - truncate sha256 to 192 bits rather than 40 bits
  - include the package id

This means that, given only the package hashes for a complete dependency
tree, it is possible to perform version selection and know the final
size on disk, without doing any fetching whatsoever. This prevents
wasted bandwidth since package versions not selected do not need to be
fetched.
2025-02-26 11:42:03 -08:00
Andrew Kelley
e0129b387f std.ArrayList: delete unit test
tests should use the API, not only verify compilation succeeds.
2025-02-26 11:42:03 -08:00
Loris Cro
43a949ee95 fix regressed build system unit test 2025-02-26 14:41:33 -05:00