Commit graph

33513 commits

Author SHA1 Message Date
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
Alex Rønne Petersen
b3f52ae339
test: Disable arrays and vectors with big integers on MIPS N32.
https://github.com/ziglang/zig/issues/23805
2025-05-08 21:32:22 +02:00
Alex Rønne Petersen
d3e8541268
std.Target: Prune dead targets in Abi.default() and DynamicLinker.standard(). 2025-05-08 21:32:20 +02:00
xdBronch
10bf6964ed translate-c: fix callconv attribute in macro 2025-05-07 16:15:51 +03:00
Seiichi Uchida
bbc21393b4 Add register_file_alloc_range 2025-05-06 18:01:07 +02:00
Alex Rønne Petersen
35f30558ad
std.Build: Rename --glibc-runtimes to --libc-runtimes and enable it for musl. 2025-05-06 01:52:47 +02:00
HydroH
a14352b0b2
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-05 18:50:25 +00:00
David Rubin
369177f0ba
crypto: add sub function to Ristretto255 (#23724) 2025-05-05 15:30:59 +02:00
Alex Rønne Petersen
7401f06f99 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 14:34:05 +02:00
Alex Rønne Petersen
f0feda820e
Merge pull request #23727 from tjog/add-libfuzz-standalone-test
add standalone test for libfuzzer initialization
2025-05-05 07:23:18 +02:00
Xavier Bouchoux
bb79c85cb7 fix system library lookup when cross-compiling to windows-msvc 2025-05-04 10:57:04 +02:00
Alex Rønne Petersen
dffd18f133
Merge pull request #23752 from alexrp/static-native-glibc
compiler: Allow linking native glibc statically
2025-05-04 01:53:51 +02:00
tjog
0ba77eca74
disable getauxvalImpl instrumentation as libfuzzer's allocator may need to call it 2025-05-03 23:33:26 +02:00
Matthew Lugg
f4e9846bca
Merge pull request #23263 from mlugg/comptime-field-ptr
Sema: fix pointers to comptime fields of comptime-known aggregate pointers
2025-05-03 20:10:42 +01:00
mlugg
f83fe2714b 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-03 20:10:26 +01:00
mlugg
ae1b444d6a 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-03 20:09:51 +01:00
tjog
68700e5de1
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-03 17:23:32 +02:00
tjog
3ed159964a
libfuzzer: add standalone test for libfuzzer initialization 2025-05-03 17:15:59 +02:00
Alex Rønne Petersen
bf9b15ee67 std.Target: Add Cpu.Arch.or1k and basic target info. 2025-05-03 11:22:27 +02:00
Alex Rønne Petersen
d2f92e1797
compiler: Link libunwind when linking glibc statically.
glibc's libc.a depends on the functions provided by libunwind.
2025-05-03 10:54:36 +02:00
Alex Rønne Petersen
f6476e9cae
compiler: Allow linking native glibc statically.
This is generally ill-advised, but can be useful in some niche situations where
the caveats don't apply. It might also be useful when providing a libc.txt that
points to Eyra.
2025-05-03 10:54:33 +02:00
Alex Rønne Petersen
ae38575b42
compiler: Rename misleading libcNeedsLibUnwind() function.
It's about libc++, not libc.
2025-05-03 10:31:31 +02:00
samy007
c0ec264f75 inline assembly: implement gcc's "%=" syntax 2025-05-02 23:09:39 +02:00