Commit graph

11820 commits

Author SHA1 Message Date
mlugg
7218218040
build runner: don't incorrectly omit reference traces
It's incorrect to ever set `include_reference_trace` here, because the
compiler has already given or not given reference traces depending on
the `-freference-trace` option propagated to the compiler process by
`std.Build.Step.Compile`.

Perhaps in future we could make the compiler always return the reference
trace when communicating over the compiler protocol; that'd be more
versatile than the current behavior, because the build runner could, for
instance, show a reference trace on-demand without having to even invoke
the compiler. That seems really useful, since the reference trace is
*often* unnecessary noise, but *sometimes* essential. However, we don't
live in that world right now, so passing the option here doesn't make
sense.

Resolves: #23415
2025-05-17 00:36:54 +02:00
Marc Tiehuis
455ea58872
std.hash.Wyhash: fix dangling stack pointer
Closes #23895.
2025-05-16 17:03:39 +02:00
Cezary Kupaj
c4237e8909
Fix SIGSEGV handler for AArch64 Darwin targets
* ucontext_t ptr is 8-byte aligned instead of 16-byte aligned which @alignCast() expects
* Retrieve pc address from ucontext_t since unwind_state is null
* Work around __mcontext_data being written incorrectly by the kernel
2025-05-14 05:39:01 +02:00
Michael Pfaff
0cb9ffc6d8
Fix implementation of std.os.linux.accept on x86 2025-05-10 10:27:17 +02:00
Meghan Denny
b1082a31a5
std.os: handle ENOENT for fnctl on macos 2025-05-09 16:43:50 +02:00
HydroH
b21fa8e2cd
std: fix compile errors in std.crypto.ecc (#23797)
Implemented `neg()` method for `AffineCoordinates` struct of p256,
p384 and secp256k1 curves.

Resolves: #20505 (partially)
2025-05-06 18:03:03 +02:00
tjog
e739ba1bd9
disable getauxvalImpl instrumentation as libfuzzer's allocator may need to call it 2025-05-05 07:26:06 +02:00
mlugg
87983e800a
std.Progress: fix many bugs
There were several bugs with the synchronization here; most notably an
ABA problem which was causing #21663. I fixed that and some other
issues, and took the opportunity to get rid of the `.seq_cst` orderings
from this file. I'm at least relatively sure my new orderings are correct.

Co-authored-by: achan1989 <achan1989@gmail.com>
Resolves: #21663
2025-05-04 02:51:07 +02:00
Pat Tullmann
142a890c37
std.os.linux: Fix MIPS signal numbers
Dunno why the MIPS signal numbers are different, or why Zig had them
already special cased, but wrong.

We have the technology to test these constants.  We should use it.
2025-05-02 18:30:50 +02:00
Alex Rønne Petersen
0209c68fcc
compiler-rt: Add missing _Qp_sqrt export for sparc64.
https://github.com/ziglang/zig/issues/23716
2025-05-01 21:36:19 +02:00
Alex Rønne Petersen
47e46b58d2
std.os.linux: Add missing time_t definition for sparc64. 2025-05-01 21:34:49 +02:00
psbob
8717453208
Fix Unexpected error for 1453 on Windows (#23729) 2025-05-01 21:31:58 +02:00
Dongjia Zhang
8a5f834240
use correcct symbol for the end of pcguard section 2025-04-28 20:48:30 +02:00
Shun Sakai
168981c678
docs(std.ascii): Remove redundant three slashes 2025-04-28 00:58:44 +02:00
mlugg
160f2dabed
std.Build.Cache: fix several bugs
Aside from adding comments to document the logic in `Cache.Manifest.hit`
better, this commit fixes two serious bugs.

The first, spotted by Andrew, is that when upgrading from a shared to an
exclusive lock on the manifest file, we do not seek it back to the
start. This is a simple fix.

The second is more subtle, and has to do with the computation of file
digests. Broadly speaking, the goal of the main loop in `hit` is to
iterate the files listed in the manifest file, and check if they've
changed, based on stat and a file hash. While doing this, the
`bin_digest` field of `std.Build.Cache.File`, which is initially
`undefined`, is populated for all files, either straight from the
manifest (if the stat matches) or recomputed from the file on-disk. This
file digest is then used to update `man.hash.hasher`, which is building
the final hash used as, for instance, the output directory name when the
compiler emits into the cache directory. When `hit` returns a cache
miss, it is expected that `man.hash.hasher` includes the digests of all
"initial files"; that is, those which have been already added with e.g.
`addFilePath`, but not those which will later be added with
`addFilePost` (even though the manifest file has told us about some such
files). Previously, `hit` was using the `unhit` function to do this in a
few cases. However, this is incorrect, because `hit` assumes that all
files already have their `bin_digest` field populated; this function is
only valid to call *after* `hit` returns. Instead, we need to actually
compute the hashes which haven't yet been populated. Even if this logic
has been working, there was still a bug here, because we called `unhit`
when upgrading from a shared to an exclusive lock, writing the
(potentially `undefined`) file digests, but the loop itself writes the
file digests *again*! All in all, the hashing logic here was actually
incredibly broken.

I've taken the opportunity to restructure this section of the code into
what I think is a more readable format. A new function,
`hitWithCurrentLock`, uses the open manifest file to try and find a
cache hit. It returns a tagged union which, in the miss case, tells the
caller (`hit`) how many files already have their hash populated. This
avoids redundant work recomputing the same hash multiple times in
situations where the lock needs upgrading. This also eliminates the
outer loop from `hit`, which was a little confusing because it iterated
no more than twice!

The bugs fixed here could manifest in several different ways depending
on how contended file locks were satisfied. Most notably, on a cache
miss, the Zig compiler might have written the compilation output to the
incorrect directory (because it incorrectly constructed a hash using
`undefined` or repeated file digests), resulting in all future hits on
this manifest causing `error.FileNotFound`. This is #23110. I have been
able to reproduce #23110 on `master`, and have not been able to after
this commit, so I am relatively sure this commit resolves that issue.

Resolves: #23110
2025-04-27 14:08:21 +02:00
Michael Pfaff
53f298cffa
Calculate WTF-8 length before converting instead of converting into an intermediate buffer on the stack 2025-04-26 15:07:26 +02:00
tjog
3ca0f18bfe
fuzz: fix expected section start/end symbol name on MacOS when linking libfuzzer
Not only is the section name when adding the sancov variables different.

The linker symbol ending up in the binary is also different.

Reference: 60105ac6ba/llvm/lib/Transforms/Instrumentation/SanitizerCoverage.cpp (L1076-L1104)
2025-04-26 15:07:21 +02:00
Ryan Liptak
aa013b7643
FailingAllocator: remove outdated doc comments, move doc comment example to decltest
Note: The decltests for files-as-a-struct don't show up in autodoc currently
2025-04-25 19:58:11 +02:00
phatchman
4b47e978e3
Return FileNotFound when CreateProcessW is called with a missing path (#23567) 2025-04-16 04:25:02 +02:00
Alex Rønne Petersen
379f1c9fa0
std.Build.Step: Don't capture a stack trace if !std.debug.sys_can_stack_trace. 2025-04-15 01:30:52 +02:00
Pat Tullmann
2a7683933a
linux.zig: epoll_wait: pass kernel sigset size
Linux kernel syscalls expect to be given the number of bits of sigset that
they're built for, not the full 1024-bit sigsets that glibc supports.

I audited the other syscalls in here that use `sigset_t` and they're all
using `NSIG / 8`.

Fixes #12715
2025-04-10 10:49:04 +02:00
Meghan Denny
9397dc5af6
std: add nvidia as a known arm implementer 2025-04-09 15:03:45 +02:00
Stefan Weigl-Bosker
8bb7c85bd4
start: fix pc register syntax for m68k 2025-04-08 12:10:22 +02:00
Alex Rønne Petersen
79e3c4a9a8
start: Align the stack on m68k. 2025-04-08 12:10:16 +02:00
Alex Rønne Petersen
b2feb0d575
glibc: Add missing stubs-lp64s.h for loongarch64-linux-gnusf.
https://sourceware.org/bugzilla/show_bug.cgi?id=32776
2025-04-06 17:23:19 +02:00
Zenomat
a2ea4b02bc
std.net: Implement if_nametoindex for windows (#22555) 2025-04-05 20:41:50 +02:00
Alex Rønne Petersen
1bada4b275
Merge pull request #23447 from alexrp/cpuid-updates 2025-04-03 19:32:59 +02:00
Alex Rønne Petersen
f5de2770e5
Merge pull request #23445 from alexrp/external-executor-fixes 2025-04-03 19:32:54 +02:00
Misaki Kasumi
d128f5c0bb
std.os.linux: block all signals in raise 2025-04-02 23:57:32 +02:00
Parker Liu
06fc600aec
translate-c: fix function prototype decalared inside a function
* If a function prototype is declarated inside a function, do not
  translate it to a top-level extern function declaration. Similar to
  extern local variable, just wrapped it into a block-local struct.

* Add a new extern_local_fn tag of aro_translate_c node for present
  extern local function declaration.

* When a function body has a C function prototype declaration, it adds
  an extern local function declaration. Subsequent function references
  will look for this function declaration.
2025-04-02 23:56:07 +02:00
Auguste Rame
0b4176891c
DebugAllocator: Fix bucket removal logic causing segfault/leak (#23390)
Make buckets doubly linked
2025-04-02 14:22:15 +02:00
Ali Cheraghi
edaa9584cc
zon: normalize negative zeroes 2025-04-02 08:43:21 +02:00
Parker Liu
6ecd143212
translate-c: fix referencing extern locals from nested blocks 2025-04-02 08:43:13 +02:00
Alex Rønne Petersen
4c0913ff7c
Merge pull request #23417 from dweiller/zstd-fixes
Zstd fixes
2025-03-31 17:52:23 +02:00
Simon Brown
e5ea175ffb
Add quota for comptime sort, add test 2025-03-31 17:52:16 +02:00
Sean Stasiak
9025f73733
check result of mmap() call to handle a large base_addr value correctly 2025-03-27 21:08:23 +01:00
Alex Rønne Petersen
ed6418544c
Merge pull request #23373 from alexrp/get-base-address
`std.process`: Some minor fixes for `getBaseAddress()`
2025-03-27 21:08:04 +01:00
Андрей Краевский
8088105b05
std.meta.FieldType -> @FieldType 2025-03-27 12:19:07 +01:00
孙冰
38a8fd5d85
std.posix: update LFS64 interfaces for android bionic C 2025-03-26 23:52:16 +01:00
Felix "xq" Queißner
3592868435
Enables parsing for '-Wl,-rpath,' in pkg-config output, allows better support for NixOS linking. 2025-03-26 23:51:58 +01:00
wooster0
27ae10afe0
linux: don't export getauxval when not required 2025-03-26 21:52:44 +01:00
Kendall Condon
f391a2cd20
Allocator.create: properly handle alignment for zero-sized types (#21864) 2025-03-26 21:52:12 +01:00
dweiller
172dc6c314
zig build: add env_map entries to hash for Step.Run
This change fixes false-positive cache hits for run steps that get run
with different sets of environment variables due the the environment map
being excluded from the cache hash.
2025-03-26 15:41:17 +01:00
Arnau Camprubí
9c857bb32d
Fix std.debug.dumpHex address offsets 2025-03-26 15:40:56 +01:00
Alex Rønne Petersen
38ececf0a7
Merge pull request #23310 from Rexicon226/fix-23309
big.int: return normalized results from `{add,sub}Carry`
2025-03-25 18:44:58 +01:00
Chris Clark
cb3eec285f
std.zig.Ast: Fix error case memory leak in parse() 2025-03-25 15:40:55 +01:00
godalming123
0367d46d3c
Update the documentation comment in arena_allocator.zig to be more accurate
Update the documentation comment in arena_allocator.zig to specify that free() is a no-op unless the item is the most recent allocation.
2025-03-25 15:24:20 +01:00
孙冰
d67bf8bde3
std.c: android bionic C supports arc4random_buf and getentropy
1. https://android.googlesource.com/platform/bionic/+/refs/heads/main/libc/include/bits/getentropy.h
2. https://android.googlesource.com/platform/bionic/+/refs/heads/main/libc/include/stdlib.h
2025-03-25 15:24:07 +01:00
Alex Rønne Petersen
7d8a556ba9
Merge pull request #23220 from samy-00007/bytesAsSlice-fix
Minor fix for `Allocator.remap` and `mem.bytesAsSlice` for zero-sized types
2025-03-25 15:23:08 +01:00
rpkak
1aca3dd6e0
DepTokenizer: allow space between target and colon 2025-03-24 15:31:59 +01:00