Commit graph

33094 commits

Author SHA1 Message Date
Carl Åstholm
711b0fef58 init: Substitute invalid package names with foo
Closes #23066
2025-03-04 02:42:00 -05:00
Andrew Kelley
13757aacc7 update .mailmap
keeps our contributor count in the release notes somewhat accurate
2025-03-03 17:19:09 -08: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
mlugg
501e84a96a incremental: invalidate namespace dependencies when a name changes visibility
We could have more fine-grained dependencies here, but I think this is
fine for now.
2025-03-03 22:18:02 +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
Alex Rønne Petersen
4fad60fd3a compiler: Don't consider powerpc to have red zone support yet.
The command line flag is only supported in Clang 20: https://github.com/ziglang/zig/issues/23056

This gets rid of some warnings when using zig cc.
2025-03-03 19:36:46 +01:00
Linus Groh
6d29ef0baf
Merge pull request #23046 from linusg/uefi-time
Three time-related fixes for UEFI
2025-03-03 10:07:41 +00:00
Jacob Young
00a8742bbf
Merge pull request #22982 from mlugg/cache-mode
compiler: default to `.whole` cache mode for self-hosted backends
2025-03-02 22:15:42 -05: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
Jacob Young
d741be512b link: fixed bugs uncovered by changing the cache mode 2025-03-02 16:39:18 -05:00
mlugg
725c825829 link: make sure MachO closes the damn files
Windows is a ridiculous operating system designed by toddlers, and so
requires us to close all file handles in the `tmp/xxxxxxx` cache dir
before renaming it into `o/xxxxxxx`. We have a hack in place to handle
this for the main output file, but the MachO linker also outputs a file
with debug symbols, and we weren't closing it! This led to a fuckton of
CI failures when we enabled `.whole` cache mode by default for
self-hosted backends.

thanks jacob for figuring this out while i sat there
2025-03-02 16:39:18 -05:00
mlugg
c2983a3f88 compiler: default to .whole cache mode for self-hosted backends
This is a better default cache mode until incremental compilation is
enabled by default.
2025-03-02 16:39:18 -05: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
Jacob Young
a6525c1762
Merge pull request #22529 from xtexx/x86-64/shl-sat-int
x86_64: Implement integer saturating left shifting codegen
2025-03-02 02:51:36 -05:00
Bingwu Zhang
1da909a1e2
x86_64: add behavior tests for saturating shift left
Co-authored-by: Jacob Young <jacobly0@users.noreply.github.com>
Signed-off-by: Bingwu Zhang <xtex@aosc.io>
2025-03-02 10:30:43 +08:00
xtex
4e32193de3
x86_64: implement integer saturating left shifting codegen
Simliarly to shl_with_overflow, we first SHL/SAL the integer, then
SHR/SAR it back to compare if overflow happens.
If overflow happened, set result to the upper limit to make it saturating.

Bug: #17645
Co-authored-by: Jacob Young <jacobly0@users.noreply.github.com>
Signed-off-by: Bingwu Zhang <xtex@aosc.io>
2025-03-02 10:30:32 +08:00
Andrew Kelley
235001a646 zig init template: remove outdated comments
closes #23040
2025-03-01 16:11:59 -08:00
Jacob Young
50b40c9621 x86_64: rewrite wrapping add/sub 2025-03-01 16:29:22 -05: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
Andrew Kelley
ab381933c8 CI: bump timeout on windows to 7h 2025-02-26 22:29:41 -08: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
ea516f0e81 bump package id component to 32 bits
and to make the base64 round even, bump sha256 to 200 bits (up from 192)
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
a70307e7ff CLI: add unit test and improve sanitizeExampleName 2025-02-26 11:42:03 -08:00
Andrew Kelley
eff1716b6c Package: update unit tests to new API 2025-02-26 11:42:03 -08:00
Andrew Kelley
512bb9ad3e update zig's own manifest file to conform to new rules 2025-02-26 11:42:03 -08:00
Andrew Kelley
7cedc01b7e zig init: sanitize generated name
Adhere to the new rules: 32 byte limit + must be a valid bare zig
identifier
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
9763dd2901 Package.Manifest: enforce maximum version string length of 32 2025-02-26 11:42:03 -08:00
Andrew Kelley
76e8b297b1 Package.Manifest: enforce name limit of 32 2025-02-26 11:42:03 -08:00
Andrew Kelley
a57b0a0f2f fix generated hash of by-path dependencies
This branch regressed from master by switching to binary rather than hex
digest, allowing null bytes to end up in identifiers in the zig file.

This commit fixes it by changing the "hash" to be literally equal to the
sub_path (with a prefix '/' to indicate "global") if it can fit. If it
is too long then it is actually hashed, and that value used instead.
2025-02-26 11:42:03 -08:00
Andrew Kelley
e03bc7ac78 require package names to be valid zig identifiers 2025-02-26 11:42:03 -08:00
Andrew Kelley
12355cfb4c Package: new hash format
legacy format is also supported.

closes #20178
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
Andrew Kelley
f74a856d84 reword deprecated error slightly
"found" -> "reached" to match "reached unreachable code"
2025-02-26 14:41:33 -05:00
Andrew Kelley
c5aa680c88 don't inherit allowed deprecation from parent modules
Inheriting allow-deprecation from parent modules doesn't make too much
sense, so instead make them default to disallow unless otherwise
specified. This allows build system to avoid redundant
`-fno-allow-deprecated` args.

This makes the generated CLIs smaller, and makes zig1.wasm update not
needed.

Also represented `is_root` differently (moved to field of graph).
2025-02-26 14:41:33 -05:00
Andrew Kelley
4ddb13468b langref: update deprecated section 2025-02-26 14:41:33 -05:00
Andrew Kelley
7c2649f89d langref: fix whitespace 2025-02-26 14:41:33 -05:00
Loris Cro
25790e95f1 @deprecated: remove per-module flag in Build
This implementation looks at the builder of each
module in the build graph instead of storing a
boolean for each module.
2025-02-26 14:41:33 -05:00
Loris Cro
e3da2852f4 @deprecated: add suggested changes to langref entry 2025-02-26 14:41:33 -05:00