33081 Commits

Author SHA1 Message Date
Michael Pfaff
0cb9ffc6d8
Fix implementation of std.os.linux.accept on x86 2025-05-10 10:27:17 +02:00
Alex Rønne Petersen
9070607c03
glibc: Fix stub libraries containing unwanted symbols.
Closes #8096.
2025-05-09 16:44:04 +02:00
mlugg
7199cfc21f
Compilation: don't warn about failure to delete missing C depfile
If clang encountered bad imports, the depfile will not be generated. It
doesn't make sense to warn the user in this case. In fact,
`FileNotFound` is never worth warning about here; it just means that
the file we were deleting to save space isn't there in the first place!
If the missing file actually affected the compilation (e.g. another
process raced to delete it for some reason) we would already error in
the normal code path which reads these files, so we can safely omit the
warning in the `FileNotFound` case always, only warning when the file
might still exist.

To see what this fixes, create the following file...

```c
#include <nonexist>
```

...and run `zig build-obj` on it. Before this commit, you will get a
redundant warning; after this commit, that warning is gone.
2025-05-09 16:43:57 +02:00
Meghan Denny
b1082a31a5
std.os: handle ENOENT for fnctl on macos 2025-05-09 16:43:50 +02:00
xdBronch
55acb29d68
translate-c: fix callconv attribute in macro 2025-05-09 16:43:35 +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
Alex Rønne Petersen
5cfd47660c
0934823815f1d4336b2160f09f65df5ba8e52a15 take 2. 2025-05-05 09:07:52 +02:00
Alex Rønne Petersen
0934823815
Unbreak the build (156ab8750056c3ff440af0937806d8cdb2623816 is not in the 0.14.x branch). 2025-05-05 08:06:09 +02:00
tjog
e739ba1bd9
disable getauxvalImpl instrumentation as libfuzzer's allocator may need to call it 2025-05-05 07:26:06 +02:00
tjog
f592674642
link+macho+fuzz: use correct input type
A debug build of the compiler detects invalid union access since `classifyInputFile`
detects `.archive` and this line constructed a `.object` input.
2025-05-05 07:25:55 +02:00
Alex Rønne Petersen
566e4ab6b1
compiler: Set libc++ ABI version to 2 for Emscripten.
It remains 1 everywhere else.

Also remove some code that allowed setting the libc++ ABI version on the
Compilation since there are no current plans to actually expose this in the CLI.
2025-05-05 07:25:25 +02:00
Xavier Bouchoux
7b45bd3c09
fix system library lookup when cross-compiling to windows-msvc 2025-05-04 02:52:33 +02:00
Matthew Lugg
e07d8fccd1
Merge pull request #23263 from mlugg/comptime-field-ptr
Sema: fix pointers to comptime fields of comptime-known aggregate pointers
2025-05-04 02:51:47 +02:00
mlugg
db936b9094
compiler: fix comptime memory store bugs
* When storing a zero-bit type, we should short-circuit almost
  immediately. Zero-bit stores do not need to do any work.
* The bit size computation for arrays is incorrect; the `abiSize` will
  already be appropriately aligned, but the logic to do so here
  incorrectly assumes that zero-bit types have an alignment of 0. They
  don't; their alignment is 1.

Resolves: #21202
Resolves: #21508
Resolves: #23307
2025-05-04 02:51:42 +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
Pavel Verigo
331bd83f11
wasm-c-abi: llvm fix struct handling + reorganize
I changed to `wasm/abi.zig`, this design is certainly better than the previous one. Still there is some conflict of interest between llvm and self-hosted backend, better design will appear when abi tests will be tested with self-hosted.

Resolves: #23304
Resolves: #23305
2025-05-02 18:30:32 +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
aea1272a3f
test: Disable vector reduce operation for sparc.
https://github.com/ziglang/zig/issues/23719
2025-05-01 21:34:57 +02:00
Alex Rønne Petersen
a09c1d91ed
test: Disable some varargs behavior tests on sparc.
https://github.com/ziglang/zig/issues/23718
2025-05-01 21:34:53 +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
Ali Cheraghi
200fb1e92e
test: skip "struct fields get automatically reordered" for spirv64 backend 2025-05-01 21:34:34 +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
mlugg
bee19572c8
Sema: fix a few indexing bugs
* Indexing zero-bit types should not produce AIR indexing instructions
* Getting a runtime-known element pointer from a many-pointer should
  check that the many-pointer is not comptime-only

Resolves: #23405
2025-04-28 20:48:24 +02:00
dweiller
b5c22777f8
sema: do checked cast when resolving aggregate size 2025-04-28 20:48:19 +02:00
xdBronch
7e68999f79
Sema: fix memcpy with C pointers 2025-04-28 12:10:04 +02:00
Alex Rønne Petersen
470dac8a77
wasi-libc: Fix paths to psignal.c and strsignal.c.
Closes #23709.
2025-04-28 01:03:15 +02:00
Alex Rønne Petersen
e6a71e9e7a
Sema: Fix some ptr alignment checks to handle a potential ISA tag bit.
Closes #23570.
2025-04-28 00:58:53 +02:00
Shun Sakai
168981c678
docs(std.ascii): Remove redundant three slashes 2025-04-28 00:58:44 +02:00
Kevin Primm
23ab05f1f5
compiler: Fix -m<os>-version-min=... ordering 2025-04-27 14:27:52 +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
Alex Rønne Petersen
a8844ab3bc
std.Target.amdgcn.cpu.gfx1153 doesn't exist in LLVM 19. 2025-04-25 20:14:44 +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
Ali Cheraghi
f38a28a626
revive nvptx linkage 2025-04-25 19:57:45 +02:00
Ali Cheraghi
af6670c403
Module: ignore xnack and sramecc features on some gpu models 2025-04-25 19:57:39 +02:00
Pavel Otchertsov
fd7aafdbd5
cmake: support static linking against libxml2 2025-04-16 23:40:28 +02:00
phatchman
4b47e978e3
Return FileNotFound when CreateProcessW is called with a missing path (#23567) 2025-04-16 04:25:02 +02:00
David Rubin
d80cfa6f41 Compilation: Use trapping UBSan if -fno-ubsan-rt is passed.
This is a mitigation of #23216 meant only for 0.14.x.
2025-04-15 21:29:10 +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
Alex Rønne Petersen
c0378e85b6
link: Improve handling of --build-id when using LLD. 2025-04-15 01:30:34 +02:00
Luis Cáceres
ebb37e719d
src/libunwind.zig: Fix symbol visibility macro define
The define was changed in commit 729899f7b6bf6aff65988d895d7a639391a67608
in upstream llvm.
2025-04-15 01:30:27 +02:00
kcbanner
527df938e1
Value: ensure that extern structs have their layout resolved in ptrField 2025-04-11 21:35:42 +02:00
Jacob Young
1d34616236
x86_64: fix error_set_has_value of inferred error sets 2025-04-11 16:59:55 +02:00
Alex Rønne Petersen
a5f4107d3e
Compilation: Pass -m<os>-version-min=... to Clang for all applicable Darwin targets. 2025-04-11 02:19:22 +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
Techatrix
83e1ce1e00
Compilation: Fix logic in addCCArgs() for various file types and flags.
Co-authored-by: Alex Rønne Petersen <alex@alexrp.com>
2025-04-09 15:04:24 +02:00
Meghan Denny
9397dc5af6
std: add nvidia as a known arm implementer 2025-04-09 15:03:45 +02:00