Commit graph

11732 commits

Author SHA1 Message Date
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
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
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
d4413e3504 ubsan: avoid depending on @returnAddress combined with inline 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
David Rubin
a468929519 ubsan: resolve the last of the TODOs 2025-02-25 11:22:33 -08:00
David Rubin
50b95562fd ubsan: clean-up and remove the unused handlers 2025-02-25 11:22:33 -08:00
David Rubin
658fba982c ubsan: extend ptr before adding to avoid overflow 2025-02-25 11:22:33 -08:00
David Rubin
590c613182 ubsan: implement more checks 2025-02-25 11:22:33 -08:00
David Rubin
fc77678339 mem: add @branchHint to indexOfSentinel
also seems to work around aarch64 LLVM miscompilation 🤔
2025-02-25 11:22:33 -08:00
David Rubin
95720f007b move libubsan to lib/ and integrate it into -fubsan-rt 2025-02-25 11:22:33 -08:00
David Rubin
babee5f73c ubsan: implement some more checks 2025-02-25 11:22:33 -08:00
David Rubin
c27b7973c9 Compilation: use the minimal runtime in ReleaseSafe 2025-02-25 11:22:33 -08:00
David Rubin
eef8d4ff4f ubsan: switch to using std.builtin.panicExtra to log errors 2025-02-25 11:22:33 -08:00
David Rubin
5e0073c898 ubsan: add a basic runtime 2025-02-25 11:22:33 -08:00
Alex Rønne Petersen
ad5515bed8 compiler-rt: Add tests from llvm/llvm-project#119449. 2025-02-25 19:31:00 +01:00
Alex Rønne Petersen
c7e99b93a4 Revert "skip regressed LLVM 17 std lib test on powerpc"
This reverts commit 5b8af7a2a9.

Closes #16951.
2025-02-25 18:28:34 +01:00
Alex Rønne Petersen
bedf806672
Merge pull request #22999 from alexrp/mingw-update 2025-02-25 12:54:55 +01:00
Alex Rønne Petersen
37706cc1d9 libc: Update Linux headers to 6.13.4. 2025-02-25 11:24:18 +01:00
Ali Cheraghi
181a89e728
build: add spirv to test matrix
Signed-off-by: Ali Cheraghi <alichraghi@proton.me>
2025-02-24 19:12:38 +01:00
Ali Cheraghi
a0eec9ce9e
spirv: replace some unreachables with compile errors 2025-02-24 19:12:33 +01:00
Alex Rønne Petersen
51b44be9cc
std.zig.target: Support new wiaguid library name for MinGW-w64. 2025-02-24 12:01:12 +01:00
Alex Rønne Petersen
8afe928b6e
mingw: Update MinGW-w64 sources to 3839e21b08807479a31d5a9764666f82ae2f0356. 2025-02-24 12:01:07 +01:00
Alex Rønne Petersen
ed10a5db58
mingw: Update MinGW-w64 headers to 3839e21b08807479a31d5a9764666f82ae2f0356. 2025-02-24 11:59:10 +01:00
Alec Fessler
1cc388d526 stdlib: handle EEXIST in mmap with FIXED_NOREPLACE. Fixes #21475 2025-02-24 04:36:14 -05:00
Alex Rønne Petersen
ecc76348e6
Merge pull request #22154 from alexrp/disable-intrinsics
compiler: Implement `@disableIntrinsics()` builtin function.
2025-02-24 08:25:23 +01:00
Linus Groh
68bd82d0cc std.posix: Handle USER_MAPPED_FILE in windows ftruncate() impl 2025-02-23 16:58:26 -05:00
Andrew Kelley
e47f340e23 std.Build.Step.ConfigHeader: follow deprecation policy 2025-02-23 12:45:35 -08:00
Andrew Kelley
86f35479d9
Merge pull request #22794 from cbilz/autoconf_at
std.Build.Step.ConfigHeader: Add support for Autoconf-style `@FOO@` variables
2025-02-23 15:36:49 -05:00
Linus Groh
c44f4501e7 std.math.big.int: Support strings up to base 36
Co-Authored-By: samy007 <samy2014@free.fr>
2025-02-23 11:25:35 +00:00
mlugg
5e20e9b449 Sema: allow @ptrCast of slices changing the length
Also, refactor `Sema.ptrCastFull` to not be a horrifying hellscape.
2025-02-23 08:28:58 +00:00
Andrew Kelley
d6f8200294 zig fmt 2025-02-22 22:21:24 -08:00
Constantin Bilz
75b0538688 std.Build: Allow ConfigHeader values to be added at build.zig runtime 2025-02-22 23:31:17 -05:00
Anders Bondehagen
77007445bf
std.net: Fix IPv6 address format compression for long zero runs (#22441) 2025-02-22 19:52:47 -08:00
Linus Groh
4b0f77cc1f std.crypto.tlcsprng: Fix hardcoded use of defaultRandomSeed()
Instead of hardcoding a call to defaultRandomSeed() use the customizable
std.options.cryptoRandomSeed() like in the rest of the function.

Closes #19943.
2025-02-22 22:39:40 -05:00
Alex Rønne Petersen
e11ac02662
cbe: Implement support for -fno-builtin and @disableIntrinsics(). 2025-02-23 04:08:58 +01:00
Alex Rønne Petersen
6ba785584a
compiler: Implement @disableIntrinsics() builtin function.
Closes #21833.
Closes #22110.
2025-02-23 04:08:56 +01:00
Ryan Liptak
a502301b5e zig rc: Add COFF object file creation for CMake cross-compilation use case
In #22522 I said:

> RC="zig rc" will now work in combination with zig cc and CMake. Here's an example of cross-compiling a simple Windows GUI CMake project
>
>    $ RC="zig rc" CC="zig cc --target=x86_64-windows-gnu" cmake .. -DCMAKE_SYSTEM_NAME=Windows -G Ninja

However, I didn't realize that the time that this only works because of the `-G Ninja` part. When not using Ninja as the build tool, CMake adds a workaround for 'very long lists of object files' where it takes all object files and runs them through `ar` to combine them into one archive:

4a11fd8dde/Modules/Platform/Windows-GNU.cmake (L141-L158)

This is a problem for the Windows resource use-case, because `ar` doesn't know how to deal with `.res` files and so this object combining step fails with:

    unknown file type: foo.rc.res

Only the linker knows what to do with .res files (since it has its own `.res` -> `.obj` ('cvtres') conversion mechanism). So, when using Ninja, this object file combining step is skipped and the .res file gets passed to the linker and everyone is happy.

Note: When CMake thinks that its using `windres` as the Windows resource compiler, it will pass `-O coff` to windres which causes it to output a COFF object file instead of a `.res` file, which means that the `ar` step can succeed because it's only working on actual object files.

---

This commit gives `zig rc` the ability to output COFF object files directly when `/:output-format coff` is provided as an argument. This effectively matches what happens when CMake uses `windres` for resource compilation, but requires the argument to be provided explicitly.

So, after this change, the following CMake cross-compilation use case will work, even when not using Ninja as the generator:

    RC="zig rc /:output-format coff" CC="zig cc --target=x86_64-windows-gnu" cmake .. -DCMAKE_SYSTEM_NAME=Windows
2025-02-22 21:21:30 -05:00