Commit graph

32887 commits

Author SHA1 Message Date
Loris Cro
7a50e76eb1 wip
this is a bad commit that contains work in progress
changes to make fuzzing on macos work.

more specifically it contains macho-specific code
for loading debug information in the webserver.

it's messy because I'm still trying to understand
how this stuff works. with these changes the web
server loads but the wasm code panics.

it's unclear if the wasm panic is due to my dwarf
loading code being wrong or if we're encountering
some other latent issue.
2025-02-28 10:34:06 +01:00
Loris Cro
f8fe503146 fuzz testing: implement initial macos support
This commit implements the linker-related code
required to have the `zig init` canyoufindme test
succeed on macos.

It fixes usage of the linker in order to account
for macos specific symbol mangling and introduces
some checks in the fuzzer code to prevent crashes
in case that instrumented code is invoked before
`fuzz_init` runs.

`@disableInstrumentation` has been added to the
start code to help reduce the amount of (needlessly)
instrumented code that runs, but the builtin is
active only in the scope where it's used, meaning
that any non-inlined function call that happens in
that same scope will still have instrumentation
enabled unless it too gets its own
`@disableInstrumentation` call.

Removing temporarily the code that bails out from
instrumentation callbacks when the fuzzer has not
been inited can be used to turn early (and wasteful)
execution of instrumented code into a crash, helping
finding places where to put more calls to
`@disableInstrumentation`.
2025-02-27 16:32:35 +01: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
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
Alex Rønne Petersen
743623bc54 link.MachO.UnwindInfo: Handle u24 overflow for CU records pointing to DWARF.
Closes #23010.
2025-02-25 11:13:00 -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
Robin Voetter
fe5a78691f
spirv: get rid of function_types cache
This deep hash map doesn't work
2025-02-24 20:58:13 +01:00
Ali Cheraghi
aec0f9b3e7
test: skip failing tests with spirv-vulkan 2025-02-24 19:39:42 +01:00
Ali Cheraghi
94af47d28c
spirv: do not generate unnecessary forward pointer
Co-authored-by: Robin Voetter <robin@voetter.nl>
2025-02-24 19:12:38 +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
Alex Rønne Petersen
2404e7f5d6
update_mingw: Add update logic for winpthreads files.
Also rename a few constants for clarity.
2025-02-24 11:58:18 +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
Alex Rønne Petersen
76558f8c6b llvm: Fix C ABI integer promotion for loongarch64.
It appears to just be a 1:1 copy of riscv64, including the super weird sign
extension quirk for u32.

Contributes to #21671.
2025-02-24 06:07:05 +01:00
Linus Groh
68bd82d0cc std.posix: Handle USER_MAPPED_FILE in windows ftruncate() impl 2025-02-23 16:58:26 -05:00