Commit Graph

36606 Commits

Author SHA1 Message Date
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 3aaf394249 test: remove dependencies on legacy coercion 2025-02-26 00:17:09 +00:00
mlugg 8e074f1549 std: remove dependencies on legacy coercion 2025-02-26 00:17:09 +00:00
mlugg 84da520c44 Sema: remove legacy coercion
This was meant to be removed in #21817, but was somehow missed.
2025-02-26 00:17:09 +00: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
David Rubin 14178475e3 main: add -f{no-}ubsan-rt to the usage text 2025-02-25 11:22:33 -08:00
David Rubin 2d4574aafb Compilation: always import ubsan if a ZCU exists
Unlike `compiler-rt`, `ubsan` uses the standard library quite a lot.
Using a similar approach to how `compiler-rt` is handled today, where it's
compiled into its own object and then linked would be sub-optimal as we'd
be introducing a lot of code bloat.

This approach always "imports" `ubsan` if the ZCU, if it exists. If it doesn't
such as the case where we're compiling only C code, then we have no choice other
than to compile it down to an object and link. There's still a tiny optimization
we can do in that case, which is when compiling to a static library, there's no
need to construct an archive with a single object. We'd only go back and parse out
ubsan from the archive later in the pipeline. So we compile it to an object instead
and link that to the static library.

TLDR;
- `zig build-exe foo.c` -> build `libubsan.a` and links
- `zig build-obj foo.c` -> doesn't build anything, just emits references to ubsan runtime
- `zig build-lib foo.c -static` -> build `ubsan.o` and link it
- `zig build-exe foo.zig bar.c` -> import `ubsan-rt` into the ZCU
- `zig build-obj foo.zig bar.c` -> import `ubsan-rt` into the ZCU
- `zig build-lib foo.zig bar.c` -> import `ubsan-rt` into the ZCU
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
Andrew Kelley e902c231c8 Merge pull request #23011 from alexrp/macho-cu-intcast
`link.MachO.UnwindInfo`: Handle `u24` overflow for CU records pointing to DWARF.
2025-02-25 14:19:36 -05:00
Andrew Kelley 466ce48e4c link.MachO.UnwindInfo: reproduce lld's comment
it explains why zero is used instead of saturation
2025-02-25 11:18:42 -08:00