Commit graph

33500 commits

Author SHA1 Message Date
Pat Tullmann
a55ecd7532 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-04-30 20:32:04 -07:00
Pat Tullmann
cf989374e9 linux: update sigmask in every arch ucontext_t
All the existing code that manipulates `ucontext_t` expects there to be a
glibc-compatible sigmask (1024-bit).  The `ucontext_t` struct need to be
cleaned up so the glibc-dependent format is only used when linking
glibc/musl library, but that is a more involved change.

In practice, no Zig code looks at the sigset field contents, so it just
needs to be the right size.
2025-04-30 20:32:04 -07:00
Pat Tullmann
120c4789c3 sigset_t: sigemptyset() and sigfillset() are functions that return sigset_t
By returning an initialized sigset (instead of taking the set as an output
parameter), these functions can be used to directly initialize the `mask`
parameter of a `Sigaction` instance.
2025-04-30 20:32:04 -07:00
Pat Tullmann
f0aefa625b posix: remove empty_sigset
When linking a libc, Zig should defer to the C library for sigset
operations.  The pre-filled constants signal sets (empty_sigset,
filled_sigset) are not compatible with C library initialization, so remove
them and use the runtime `sigemptyset` and `sigfillset` methods to
initialize any sigset.
2025-04-30 20:32:04 -07:00
Pat Tullmann
d16079d79a posix.zig: export sigset_t and matching operations from system
Unify the C library sigset_t and Linux native sigset_t and the accessor
operations.

Add tests that the various sigset_t operations are working.  And clean up
existing tests a bit.
2025-04-30 20:32:04 -07:00
Pat Tullmann
298b1886b2 std.os.linux: export kernel-sized sigset_t and operations
The kernel ABI sigset_t is smaller than the glibc one.  Define the
right-sized sigset_t and fixup the sigaction() wrapper to leverage it.
The Sigaction wrapper here is not an ABI, so relax it (drop the "extern"
and the "restorer" fields), the existing `k_sigaction` is the ABI
sigaction struct.

Linux defines `sigset_t` with a c_ulong, so it can be 32-bit or 64-bit,
depending on the platform.  This can make a difference on big-endian
systems.

Patch up `ucontext_t` so that this change doesn't impact its layout.
AFAICT, its currently the glibc layout.
2025-04-30 20:32:04 -07:00
Pat Tullmann
51654aea87 c.zig: glibc/musl export 1024-bit sigset_t
Export the sigset_t ops (sigaddset, etc) from the C library.  Don't rely
on the linux.zig defintions (which will be defined to use the kernel ABI).

Move Darwin sigset and NSIG declarations into darwin.zig.  Remove
extraneous (?) sigaddset.  The C library sigaddset can reject some signals
being added, so need to defer to it.
2025-04-30 20:32:04 -07:00
psbob
9f7c8b8b1b
Fix Unexpected error for 1453 on Windows (#23729) 2025-04-30 22:48:16 +00:00
Robin Voetter
cc381d56a6
Merge pull request #23654 from alichraghi/continue
Compilation: don't build compiler_rt or ubsan_rt for amdgcn and ptx
2025-04-30 20:46:12 +02:00
Shun Sakai
195471a98d
test(std.mem): Remove trimStart and trimEnd from test trim 2025-04-30 19:59:59 +09:00
Deatil
8e79fc64cd
fixed codecs.zig (#23706) 2025-04-29 22:07:30 +00:00
Dongjia Zhang
535a0c4270 use correcct symbol for the end of pcguard section 2025-04-30 00:04:22 +02:00
Alex Rønne Petersen
399da543e5
Merge pull request #23720 from alexrp/sparc-stuff 2025-04-29 00:34:01 +02:00
Andrew Kelley
8facd99d41
Merge pull request #23708 from ziglang/memmove-followups
`@memmove` followups
2025-04-28 15:06:18 -04:00
mlugg
d038676a1f 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 19:43:58 +01:00
dweiller
365ed0ed68 sema: do checked cast when resolving aggregate size 2025-04-28 16:48:45 +01:00
Alex Rønne Petersen
1f6336794b wasi-libc: Fix paths to psignal.c and strsignal.c.
Closes #23709.
2025-04-28 13:36:11 +02:00
Alex Rønne Petersen
12f56b8740
test: Disable vector reduce operation for sparc.
https://github.com/ziglang/zig/issues/23719
2025-04-28 12:05:19 +02:00
Alex Rønne Petersen
fd4fcefe8a
test: Disable some varargs behavior tests on sparc.
https://github.com/ziglang/zig/issues/23718
2025-04-28 12:05:19 +02:00
Alex Rønne Petersen
d7e8337909
std.os.linux: Add missing time_t definition for sparc64. 2025-04-28 12:05:19 +02:00
Alex Rønne Petersen
2c5f54c898
compiler-rt: Add missing _Qp_sqrt export for sparc64.
https://github.com/ziglang/zig/issues/23716
2025-04-28 12:05:19 +02:00
Ali Cheraghi
9bd8f8ed56 test: skip "struct fields get automatically reordered" for spirv64 backend 2025-04-28 10:49:19 +03:30
Ali Cheraghi
710f9325ff Compilation: don't build compiler_rt for amdgcn and ubsan_rt for ptx 2025-04-28 10:49:17 +03:30
Ali Cheraghi
296b17f37b spirv: allow offset_and_cast for vectors when possible 2025-04-28 10:42:33 +03:30
Andrew Kelley
8be4511061 C backend: less branching 2025-04-27 23:30:00 -07:00
Andrew Kelley
7bd3207921 make @memcpy and @memmove share panic handlers 2025-04-27 23:30:00 -07:00
Alex Rønne Petersen
fc55c1b7a1
Merge pull request #23698 from alexrp/goff-xcoff-stubs
`link`: Stub out GOFF/XCOFF linker code based on LLVM
2025-04-28 07:50:37 +02:00
xdBronch
410298271e Sema: fix memcpy with C pointers 2025-04-28 05:09:12 +01:00
mlugg
81277b5487
cbe: aggregate assignment does not need a second cast
`writeCValue` already emits a cast; including another here is, in fact,
invalid, and emits errors under MSVC. Probably this code was originally
added to work around the incorrect `.Initializer` location which was
fixed in the previous commit.
2025-04-28 02:38:07 +01:00
Alex Rønne Petersen
78df3c9301
Merge pull request #23663 from alexrp/emit-asm-only 2025-04-28 02:18:45 +02:00
Jacob Young
029cc0640f
cbe: assignment is not initialization
Turns out the backend currently never emits a non-static initializer,
but the handling is kept in case it is needed again in the future.
2025-04-28 01:14:24 +01:00
mlugg
95932e98e5
Sema: fix alignment of runtime field pointer of underaligned tuple 2025-04-28 01:14:24 +01:00
mlugg
d4c5396646
Sema: fix pointers to comptime fields of comptime-known aggregate pointers
Resolves: #23190
2025-04-28 01:14:22 +01:00
Alex Rønne Petersen
5ed8bd5c85 Sema: Fix some ptr alignment checks to handle a potential ISA tag bit.
Closes #23570.
2025-04-27 23:54:54 +01:00
Alex Rønne Petersen
e7b46363ae std.Target: Remove Os.Tag.elfiamcu.
The last Intel Quark MCU was released in 2015. Quark was announced to be EOL in
2019, and stopped shipping entirely in 2022.

The OS tag was only meaningful for Intel's weird fork of Linux 3.8.7 with a
special ABI that differs from the regular i386 System V ABI; beyond that, the
CPU itself is just a plain old P54C (i586). We of course keep support for the
CPU itself, just not Intel's Linux fork.
2025-04-28 00:24:09 +02:00
Andrew Kelley
1b76d4c53a
Merge pull request #22605 from dweiller/memmove
add `@memmove` builtin
2025-04-27 14:39:21 -04:00
Shun Sakai
227d2b15e4 docs(std.ascii): Remove redundant three slashes 2025-04-27 19:37:43 +02:00
Kevin Primm
19b43ee627 compiler: Fix -m<os>-version-min=... ordering 2025-04-27 19:28:48 +02:00
psbob
d92649da80
Update Windows ReadFile and WriteFile to recognise Access Denied error when a read or write is attempted on a disconnected virtual com port 2025-04-27 14:42:15 +00:00
Alex Rønne Petersen
711e055f18
test: Uncomment a bunch of targets in llvm_targets. 2025-04-27 14:09:32 +02:00
Alex Rønne Petersen
b31b309b53
test: Configure emit_asm/emit_bin correctly for some targets in llvm_targets. 2025-04-27 14:09:05 +02:00
Alex Rønne Petersen
5411358956
test: Allow cases to set emit_asm (defaults to false). 2025-04-27 14:09:05 +02:00
Alex Rønne Petersen
26bb429093
compiler: Reject using LLVM for csky and xtensa.
These backends are completely unusable at the moment; they can produce neither
assembly files nor object files. So give a nicer error when users try to use
them.
2025-04-27 14:09:05 +02:00
Alex Rønne Petersen
386b869ec4
compiler: Error if the user targets arc with -femit-bin.
LLVM can only produce assembly files for this target currently.
2025-04-27 14:09:05 +02:00
Alex Rønne Petersen
3e7708b02b
link.Elf: Skip invoking LLD for zig build-obj for unsupported targets.
LLD doesn't support these yet. Doing this hack will at least allow basic
experimentation for these targets.
2025-04-27 14:09:05 +02:00
Alex Rønne Petersen
b16c094926
Merge pull request #23691 from alexrp/llvm-targets-updates 2025-04-27 11:50:06 +02:00
Shun Sakai
5fc4448e45 chore(std.mem): Rename trimLeft and trimRight
Rename `trimLeft` to `trimStart`, and `trimRight` to `trimEnd`.
`trimLeft` and `trimRight` functions remain as deprecated aliases for
these new names.
2025-04-27 18:03:59 +09:00
mlugg
3783b1b23c 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 05:42:18 +01:00
Alex Rønne Petersen
2d44bc5d2b
test: Add powerpc(64)-aix to llvm_targets. 2025-04-27 03:54:32 +02:00
Alex Rønne Petersen
5502a820e8
llvm: Fix data layout string for s390x-zos. 2025-04-27 03:54:32 +02:00