Commit graph

33483 commits

Author SHA1 Message Date
Alex Rønne Petersen
44bf64a709
llvm: Fix a bunch of volatile semantics violations.
Also fix some cases where we were being overzealous in applying volatile.
2025-05-12 17:07:50 +02:00
Alex Rønne Petersen
427810f3ed
llvm: Don't set nonnull attribute on pointers in non-generic address spaces.
LLVM considers null pointers to be valid for such address spaces.
2025-05-12 17:07:50 +02:00
Alex Rønne Petersen
e9ae9a5fc4
llvm: Don't set nonnull attribute on allowzero slices. 2025-05-12 17:07:49 +02:00
Alex Rønne Petersen
e95e7651ec
llvm: Set null_pointer_is_valid attribute when accessing allowzero pointers.
This informs optimization passes that they shouldn't assume that a load from a
null pointer invokes undefined behavior.

Closes #15816.
2025-05-12 17:07:49 +02:00
Alex Rønne Petersen
5c2e300f42
Air: Fix mustLower() to consider volatile for a handful of instructions.
These can all potentially operate on volatile pointers.
2025-05-12 17:07:49 +02:00
Alex Rønne Petersen
47aaaec6ea
Air: Always return true for inline assembly in mustLower().
AstGen requires inline assembly to either have outputs or be marked volatile, so
there doesn't appear to be any point in doing these checks.
2025-05-12 17:07:49 +02:00
Alex Rønne Petersen
4c36a403a8
Air: Fix mustLower() for atomic_load with inter-thread ordering. 2025-05-12 17:07:49 +02:00
Alex Rønne Petersen
d4ca9804f8
riscv64: Handle writes to the zero register sensibly in result bookkeeping. 2025-05-12 17:07:49 +02:00
Alex Rønne Petersen
61ae9a2f45
riscv64: Add missing fence for seq_cst atomic_store. 2025-05-12 17:07:49 +02:00
Alex Rønne Petersen
e40de86082
riscv64: Get rid of some trailing whitespace. 2025-05-12 17:07:49 +02:00
Alex Rønne Petersen
8285de62d5
Merge pull request #23745 from alexrp/target-os-versions
`std.Target`: Update supported OS version ranges
2025-05-12 16:59:46 +02:00
Linus Groh
abbead1fb8 libc: update macOS headers to SDK 15.2 2025-05-12 16:50:17 +02:00
Alex Rønne Petersen
833d4c9ce4
Merge pull request #23835 from alexrp/freebsd-libc
Support dynamically-linked FreeBSD libc when cross-compiling
2025-05-12 01:19:23 +02:00
Alex Rønne Petersen
c3906718b3
Merge pull request #23810 from alexrp/more-test-targets 2025-05-11 20:52:47 +02:00
Alex Rønne Petersen
f3e851dbd0
compiler: Link libc by default when targeting FreeBSD.
We don't yet have a direct syscall layer in std.os.freebsd.
2025-05-11 11:15:23 +02:00
Alex Rønne Petersen
4c2f1e01a7
freebsd: Create strong references to __progname and environ in stub libc.so.
These symbols are defined in the statically-linked startup code. The real
libc.so.7 contains strong references to them, so they need to be put into the
dynamic symbol table.
2025-05-11 11:15:23 +02:00
Alex Rønne Petersen
6282129218
test: Add {powerpc64,riscv32}-netbsd-none to llvm_targets. 2025-05-11 11:15:23 +02:00
Alex Rønne Petersen
e8992af7f0
Compilation.Config: Default to dynamic linking with FreeBSD libc. 2025-05-11 11:15:09 +02:00
Alex Rønne Petersen
2116f2e3b2
Compilation: Don't pass -mabi to Clang on powerpc64(le)-freebsd.
The driver doesn't support it, and FreeBSD 13+ on PPC64 uses ELFv2 anyway.
2025-05-10 20:58:28 +02:00
Alex Rønne Petersen
d3a6236eef
compiler: Support building FreeBSD crt1.o/Scrt1.o and stub shared libraries.
Only works for FreeBSD 14+. Note that we still default to targeting FreeBSD 13.

Contributes to #2876.
2025-05-10 20:58:15 +02:00
Alex Rønne Petersen
837e0f9c37 std.Target: Remove ObjectFormat.nvptx (and associated linker code).
Textual PTX is just assembly language like any other. And if we do ever add
support for emitting PTX object files after reverse engineering the bytecode
format, we'd be emitting ELF files like the CUDA toolchain. So there's really no
need for a special ObjectFormat tag here, nor linker code that treats it as a
distinct format.
2025-05-10 12:21:57 +02:00
Alex Rønne Petersen
0e3609b8e0
std.Target: Factor arch/ABI into FreeBSD minimum OS version selection.
Based on data in std.zig.target.
2025-05-10 12:19:26 +02:00
Alex Rønne Petersen
eeaa1b17c6
std.zig.target: Add FreeBSD libc support. 2025-05-10 12:19:26 +02:00
Alex Rønne Petersen
9e23e1d16c
compiler: Define __FreeBSD_version when targeting FreeBSD libc. 2025-05-10 12:19:26 +02:00
Alex Rønne Petersen
be566a4c11
libc: Add FreeBSD libc abilists file.
Currently covers version 1.7 (FreeBSD 14.0.0).
2025-05-10 12:19:26 +02:00
Alex Rønne Petersen
68cd00497f
update_freebsd_libc: Add tool for updating FreeBSD libc startup code. 2025-05-10 12:19:26 +02:00
Alex Rønne Petersen
a36dcef7dc
libc: Add FreeBSD libc startup code from 14.2.0.
* NT_FREEBSD_ABI_TAG was manually adjusted from using a hardcoded value to using
  __FreeBSD_version which will be defined by the compiler.
* GCJ stuff was removed.
* HAVE_CTORS definitions were removed.
2025-05-10 12:19:26 +02:00
Alex Rønne Petersen
01390cc533
std.zig.LibCDirs: Add FreeBSD libc support. 2025-05-10 12:19:26 +02:00
Alex Rønne Petersen
6e64bc845f
libc: Add FreeBSD system and libc headers from 14.2.0.
osreldate.h and sys/param.h were manually adjusted to not __FreeBSD_version
since it will be defined by the compiler.
2025-05-10 12:19:26 +02:00
Alex Rønne Petersen
df719f249d
process_headers: Add FreeBSD libc support. 2025-05-10 12:19:26 +02:00
Alex Rønne Petersen
162b11b250
libcxxabi: Pass -fPIC via module options instead of CFLAGS. 2025-05-10 12:19:26 +02:00
Alex Rønne Petersen
610d3cf9de
compiler: Move vendored library support to libs subdirectory. 2025-05-10 12:19:26 +02:00
Alex Rønne Petersen
309ff9c34e
std.Target: Add isFreeBSDLibC() function. 2025-05-10 12:19:26 +02:00
Alex Rønne Petersen
46042170cb
std.Target: Fix requiresLibC() for FreeBSD. 2025-05-10 12:19:26 +02:00
Alex Rønne Petersen
ba9f2571b7
test: Remove some nonsensical FreeBSD targets from llvm_targets. 2025-05-10 12:19:26 +02:00
David
2c241b263c
Introduce common bzero libc implementation. (#23812)
* Introduce common `bzero` libc implementation.

* Update test name according to review

Co-authored-by: Linus Groh <mail@linusgroh.de>

* address code review

- import common implementation when musl or wasi is included
- don't use `c_builtins`, use `@memset`

* bzero calling conv to .c

* Apply review

Co-authored-by: Veikka Tuominen <git@vexu.eu>

---------

Co-authored-by: Linus Groh <mail@linusgroh.de>
Co-authored-by: Veikka Tuominen <git@vexu.eu>
2025-05-10 10:37:21 +02:00
Alex Rønne Petersen
85431e745c libcxx: Backport llvm/llvm-project#137594. 2025-05-10 09:10:27 +02:00
Michael Pfaff
49c7318056 Fix implementation of std.os.linux.accept on x86 2025-05-10 02:24:33 +02:00
Pat Tullmann
6eb5e56306 std.posix: Add sigrtmin() and sigrtmax()
For C code the macros SIGRTMIN and SIGRTMAX provide these values.  In
practice what looks like a constant is actually provided by a libc call.
So the Zig implementations are explicitly function calls.

glibc (and Musl) export a run-time minimum "real-time" signal number,
based on how many signals are reserved for internal implementation details
(generally threading).  In practice, on Linux, sigrtmin() is 35 on glibc
with the older LinuxThread and 34 with the newer NPTL-based
implementation.  Musl always returns 35.  The maximum "real-time" signal
number is NSIG - 1 (64 on most Linux kernels, but 128 on MIPS).

When not linking a C Library, Zig can report the full range of "rt"
signals (none are reserved by Zig).

Fixes #21189
2025-05-09 15:10:25 +02:00
Alex Rønne Petersen
23cb2b2662
std.Target: Handle {powerpc64,riscv32}-netbsd in DynamicLinker.standard(). 2025-05-09 14:07:40 +02:00
Alex Rønne Petersen
85a6b75e18 glibc: Fix stub libraries containing unwanted symbols.
Closes #8096.
2025-05-09 13:16:35 +02:00
mlugg
787020b30b 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 11:52:26 +01:00
Meghan Denny
a5cfa3db3a std.os: handle ENOENT for fnctl on macos 2025-05-09 11:20:42 +02:00
HydroH
32bf1fbf46 std: fix error.Unexpected on certain Windows file operations
Closes #23690.
2025-05-09 08:57:00 +02:00
Alex Rønne Petersen
c3734450bc
test: Add MIPS N32 targets to the module test matrix. 2025-05-08 21:32:22 +02:00
Alex Rønne Petersen
473f36d70f
test: Add dynamic musl targets to the module test matrix.
Most of these are gated by -Dtest-extra-targets because:

* We don't really have CI resources to spare at the moment.
* They're relatively niche if you're not on a musl distro.
    * And the few musl distros that exist don't support all these targets.
* Quite a few of them are broken and need investigating.

x86_64-linux-musl and aarch64-linux-musl are not gated as they're the most
common targets that people will be running dynamic musl on, so we'll want to
have some bare minimum coverage of those.
2025-05-08 21:32:22 +02:00
Alex Rønne Petersen
c272ddc070
std: Disable os.linux.test.test.fallocate on MIPS N32.
https://github.com/ziglang/zig/issues/23809
2025-05-08 21:32:22 +02:00
Alex Rønne Petersen
2261d13759
std: Disable posix.test.test.fchmodat smoke test on MIPS N32.
https://github.com/ziglang/zig/issues/23808
2025-05-08 21:32:22 +02:00
Alex Rønne Petersen
dd1de18f96
std: Disable hash.xxhash.test.xxhash3 on MIPS N32.
https://github.com/ziglang/zig/issues/23807
2025-05-08 21:32:22 +02:00
Alex Rønne Petersen
d381645c73
std: Disable fs.test.test.setEndPos on MIPS N32.
https://github.com/ziglang/zig/issues/23806
2025-05-08 21:32:22 +02:00