32919 Commits

Author SHA1 Message Date
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 dea72d15da4fba909dc3ccb2e9dc5286372ac023, reversing
changes made to ab381933c87bcc744058d25a876cfdc0d23fc674.

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
Loris Cro
466fa311b1 @deprecated: optimize sema implementation
mlugg suggested a better way of implementing analysis of an istruction
that cannot be referenced by other instructions.
2025-02-26 14:41:33 -05:00
Loris Cro
c75fdd96d2 @deprecated: add tests 2025-02-26 14:41:33 -05:00
Loris Cro
06a66745a0 @deprecated: add langref entry 2025-02-26 14:41:33 -05:00
Loris Cro
ba7cd8121d @deprecated: add build system support 2025-02-26 14:41:33 -05:00
Loris Cro
fff8eff2bd initial implementation of @deprecated 2025-02-26 14:41:33 -05:00
Ali Cheraghi
8957b27074 Compilation: disable ubsan_rt for spirv target 2025-02-26 14:39:30 -05:00
Andrew Kelley
c45dcd013b
Merge pull request #22488 from Rexicon226/ubsan-rt
implement a ubsan runtime for better error messages
2025-02-26 03:08:36 -05:00
mlugg
e0a955afb3 x86_64: use ZON for encodings 2025-02-25 22:32:00 +00:00
mlugg
de8a1211c1 Zcu: correctly resolve references to test bodies
Resolves: #21569
Resolves: #22912
2025-02-25 22:29:02 +00:00
mlugg
3fcb4408a5 AstGen: improve 'file cannot be a tuple' source location
Instead of just reporting this on token 0, report it on the first
tuple-like field.
2025-02-25 22:28:47 +00:00
Alex Rønne Petersen
055969b101 std.Target: Update known max OS versions. 2025-02-25 20:30:43 +01:00
Robin Voetter
d856763aca
Merge pull request #22937 from alichraghi/ali_spv
spirv: make test suite working again
2025-02-25 20:27:37 +01:00
David Rubin
ca83f52fd9 ubsan: update wording 2025-02-25 11:22:33 -08:00
Andrew Kelley
2447b87d98 std.heap.page_size_min: relax freestanding restriction
x86_64 and aarch64 have safe values for page_size_min
2025-02-25 11:22:33 -08:00
Andrew Kelley
faf256e429 std.mem.indexOfSentinel: don't ask the OS the page size
simply use page_size_min instead.

better yet, this logic would avoid depending on page size entirely...
2025-02-25 11:22:33 -08:00
Andrew Kelley
e18c7f9cca ubsan: don't create ubsan in every static lib by default
Problem here is if zig is asked to create multiple static libraries, it
will build the runtime multiple times and then they will conflict.
Instead we want to build the runtime exactly once.
2025-02-25 11:22:33 -08:00
Andrew Kelley
d4413e3504 ubsan: avoid depending on @returnAddress combined with inline 2025-02-25 11:22:33 -08:00
David Rubin
44d3b5a6e4 build: add comments explaining why we disable ubsan 2025-02-25 11:22:33 -08:00
David Rubin
35b9db3b15 correct some bugs 2025-02-25 11:22:33 -08:00
David Rubin
931178494f Compilation: correct when to include ubsan 2025-02-25 11:22:33 -08:00
David Rubin
9432a9b6e1 build: add bundle_ubsan_rt 2025-02-25 11:22:33 -08:00
David Rubin
d669b9520b ubsan: clean-up a bit more 2025-02-25 11:22:33 -08:00