Commit graph

58 commits

Author SHA1 Message Date
GasInfinity
914acf13cb
chore: make std.zig.target.intByteSize return an u16 2025-10-27 11:13:25 +01:00
Alex Rønne Petersen
07cc32b004 wasi-libc: update to c89896107d7b57aef69dcadede47409ee4f702ee 2025-08-20 19:18:11 +02:00
Jacob Young
917640810e Target: pass and use locals by pointer instead of by value
This struct is larger than 256 bytes and code that copies it
consistently shows up in profiles of the compiler.
2025-06-19 11:45:06 -04:00
Alex Rønne Petersen
3b2bef8a95
Merge pull request #24025 from alexrp/glibc-deduplication
`libc`: Merge header directories for glibc and NetBSD libc where applicable
2025-06-04 05:14:21 +02:00
Alex Rønne Petersen
0cbff2ff7f mingw: Remove libscrnsav(e,w) support.
This defines a WinMain() function that can be potentially problematic when it
isn't wanted. If we add back support for this library in the future, it should
be built separately from mingw32.lib and on demand.
2025-05-30 01:03:47 +02:00
Alex Rønne Petersen
7c7627b18a
compiler: Use new merged header paths for glibc and NetBSD libc. 2025-05-30 00:15:37 +02:00
Alex Rønne Petersen
f925e1379a std.zig.target: Remove thumb-freebsd-eabihf.
Leftover from 76d525f74a.
2025-05-21 09:55:23 +02:00
Alex Rønne Petersen
a090ef007b
std.zig.target: Add NetBSD libc support. 2025-05-17 04:41:27 +02:00
Alex Rønne Petersen
35f8121194
std.zig.LibCDirs: Add NetBSD libc support. 2025-05-17 04:41:27 +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
eeaa1b17c6
std.zig.target: Add FreeBSD libc support. 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
35f30558ad
std.Build: Rename --glibc-runtimes to --libc-runtimes and enable it for musl. 2025-05-06 01:52:47 +02:00
Alex Rønne Petersen
ed9aa8f259 compiler: Move int size/alignment functions to std.Target and std.zig.target.
This allows using them in e.g. compiler-rt.
2025-04-11 05:22:00 -04:00
Alex Rønne Petersen
0a5c088ecc
compiler: Add hexagon-linux-musl support.
Closes #21588.
2025-04-11 02:28:35 +02:00
Alex Rønne Petersen
8954e9748a
std.Target: Add Abi.muslf32 and Abi.muslsf. 2025-04-04 06:08:09 +02:00
Linus Groh
f660675467 std: Add support for SerenityOS in various places
Not nearly the entire downstream patchset but these are completely
uncontroversial and known to work.
2025-03-11 14:59:42 +00:00
Alex Rønne Petersen
51b44be9cc
std.zig.target: Support new wiaguid library name for MinGW-w64. 2025-02-24 12:01:12 +01:00
Alex Rønne Petersen
e62352611f
std.Target: Move osArchName() and Cpu.Arch.archName() to std.zig.target.
These deal with how Zig stores OS headers in `lib/libc/include` and so don't
really belong in std.Target.
2025-02-17 19:17:56 +01:00
Alex Rønne Petersen
6fcf8e6809
std.zig.target: Fix glibc runtime triple for x86-linux-gnu. 2025-01-31 14:00:32 +01:00
Alex Rønne Petersen
7d699be772 std.zig.target: Remove some library names from isLibCLibName() for MinGW.
These are system DLLs, most of which MinGW provides .def files for. It just so
happens that MinGW also has some static libraries by the same name which link in
some GUID definitions.

The remaining non-MinGW library names represent libraries that are always
statically linked, so if those are requested by the user, it makes sense to
error if libc is not linked. A future enhancement could be to compile those
independent of mingw32.lib, however.

Closes #22560.
2025-01-29 21:38:34 +01:00
Alex Rønne Petersen
424f9ba532
std.zig.target: Check OS version for all targets in canBuildLibC().
The old logic only checked it for macOS, but we also need it to be checked for
Linux now.
2024-12-17 05:04:16 +01:00
Alex Rønne Petersen
df235f5163
std.zig.target: Attach a minimum Linux version to each glibc/musl libc entry.
(With the exception of x86 since that was available from the beginning.)

These were determined by analyzing the full, reconstructed Git history of the
Linux kernel here: https://landley.net/kdocs/fullhist
2024-12-17 05:04:14 +01:00
Alex Rønne Petersen
6066e7bfd1
std.zig.target: Remove wasm32-freestanding-musl.
This is, at least today, a very broken target: It doesn't actually build either
musl or wasi-libc even if you use -lc. It does give you musl headers, but that's
it. Those headers are not terribly useful, however, without any implementation
code. You can sort of call some math functions because they just so happen to
have implementations in compiler-rt. But that's only true for a small subset,
and I don't think users should be relying on the ABI surface of a library that
is an implementation detail of the compiler.

Clearly, a freestanding-capable libc of sorts is a useful thing as evidenced by
newlib, picolibc, etc existing. However, calling it "musl" is misleading when it
isn't actually musl-compatible, nor can it ever be because the musl API surface
is inextricably tied to the Linux kernel. In the discussion on #20690, there was
agreement that once we split up the API and ABI components in the target string,
the API component should be about compatibility, not whether you literally get a
particular implementation of it. Also, we decided that Linux musl and wasi-libc
musl shouldn't use the same API tag precisely because they're not actually
compatible.

(And besides, how would any syscall even be implemented in freestanding? Who or
what would we be calling?)

So I think we should remove this triple for now. If we decide to reintroduce
something like this, especially once #2879 gets going, we should come up with a
bespoke name for it rather than using "musl".
2024-12-15 12:25:12 +01:00
Alex Rønne Petersen
13a9bf8629
std.zig.target: Update isLibCLibName() for MinGW dcd7fefc703fb4b12187235386900d34cc13fdc5. 2024-12-14 07:02:14 +01:00
Alex Rønne Petersen
d48611ba67
Merge pull request #22090 from alexrp/glibc-runtime-triples
Add `std.zig.target.glibcRuntimeTriple()` and use it in `std.Build.Step.Run` and `process_headers.zig`
2024-12-12 18:55:15 +01:00
Alex Rønne Petersen
c9e74bb9aa
std.zig.target: Teach isLibCLibName() about emulated wasi-libc libraries. 2024-12-08 20:23:58 +01:00
Alex Rønne Petersen
92117d9bef
std.zig.target: Remove duplicate libc check for macOS in isLibCLibName(). 2024-12-08 20:18:01 +01:00
Alex Rønne Petersen
65cfc91836
std.zig.target: Consider libsupc++ to be a libc++ library name.
This is, roughly, GCC's equivalent of libc++abi.
2024-12-06 15:08:43 +01:00
Alex Rønne Petersen
80ac91172f
std.zig.target: Add glibcRuntimeTriple() function.
This lets us centralize the logic for constructing a target triple that matches
the format used by glibc's build-many-glibcs.py script.
2024-11-28 17:18:00 +01:00
Alex Rønne Petersen
24ecf45569
std.Target: Add Os.HurdVersionRange for Os.Tag.hurd.
This is necessary since isGnuLibC() is true for hurd, so we need to be able to
represent a glibc version for it.

Also add an Os.TaggedVersionRange.gnuLibCVersion() convenience function.
2024-11-24 22:11:16 +01:00
Alex Rønne Petersen
11915ae48e
std.zig.target: Change mips64(el)-linux-musl triples to -muslabi64.
With this, MIPS triples for musl are in line with glibc triples.
2024-11-02 10:42:53 +01:00
Alex Rønne Petersen
8baf887f4e
std.zig.target: Add mips64(el)-linux-muslabin32 and x86_64-linux-muslx32. 2024-11-02 10:42:53 +01:00
Alex Rønne Petersen
94cf5b26f4
process_headers: Add muslabin32 and muslx32 support. 2024-11-02 10:42:53 +01:00
Alex Rønne Petersen
270fbbcd86
std.Target: Add muslabin32 and muslabi64 tags to Abi.
Once we upgrade to LLVM 20, these should be lowered verbatim rather than to
simply musl. Similarly, the special case in llvmMachineAbi() should go away.
2024-11-02 10:42:53 +01:00
Alex Rønne Petersen
8045268698
std.zig.target: Update musl path helpers to support alternative ABIs.
This is needed for muslx32 and muslabin32 support.
2024-11-02 10:38:06 +01:00
Alex Rønne Petersen
140fb615a6
std.Target: Move isLib{C,Cxx}LibName() to std.zig.target.
These are really answering questions about the Zig compiler's capacity to
provide a libc/libc++ implementation. As such, std.zig.target seems like a more
fitting place for these.
2024-10-16 22:25:13 +02:00
Alex Rønne Petersen
1efc9c149c std.zig.target: Sort the target triple list in a more user-friendly way.
This order should be a bit closer to what a user would expect when running
`zig targets | jq -r .libc[]` or similar.
2024-10-16 00:33:23 +02:00
Alex Rønne Petersen
c38dd72ca7
std.zig.target: Add loongarch64-linux-gnusf. 2024-10-03 04:39:39 +02:00
Alex Rønne Petersen
17f54e8274
std.zig.target: Split powerpc-linux-musl triple into powerpc-linux-musleabi(hf). 2024-09-06 20:11:47 +02:00
Alex Rønne Petersen
c1a70acc91
std.zig.target: Split mips(el)-linux-musl triples into mips(el)-linux-musleabi(hf).
Closes #21184.
2024-09-06 20:11:47 +02:00
Andrew Kelley
5d08b7f054
Merge pull request #21178 from alexrp/glibc-thumb
`std.zig.target`: Remove `thumb*-linux-gnueabi*` target triples.
2024-08-30 14:35:30 -07:00
Alex Rønne Petersen
1c6642552e
std.zig.target: Change arm-windows-gnu triple to thumb-linux-gnu.
Windows on 32-bit Arm only operates in Thumb-2 mode: https://devblogs.microsoft.com/oldnewthing/20210601-00/?p=105267

Trying to compile for arm-windows-gnu fails in all sorts of ways as neither
LLVM nor MinGW-w64 expect it.
2024-08-28 03:08:10 +02:00
Alex Rønne Petersen
281707acf3 std.zig.target: Remove thumb*-linux-gnueabi* target triples.
Grepping for `NO_THUMB` in glibc suggests that glibc does not actually support
pure Thumb-2 mode. This is the mode that is implied by these target triples;
mixed Arm/Thumb mode should just use the regular `arm*-linux-gnueabi*` triples.
2024-08-28 02:57:31 +02:00
Alex Rønne Petersen
7a41e2f40b std.zig.target: Add missing thumbeb triples. 2024-08-12 00:44:56 -07:00
Andrew Kelley
cd5f673cae
Merge pull request #20909 from alexrp/glibc-riscv
Support building glibc for riscv32/riscv64
2024-08-07 01:14:54 -07:00
Alex Rønne Petersen
ebd0c6ffd0 std.zig.target: Add arc-linux-gnu.
https://lists.gnu.org/archive/html/info-gnu/2020-08/msg00002.html
2024-08-07 01:03:22 -07:00
Alex Rønne Petersen
388248ad33 std.zig.target: Set minimum glibc version for csky to 2.29.
https://lists.gnu.org/archive/html/info-gnu/2019-01/msg00018.html
2024-08-05 09:49:47 -07:00
Alex Rønne Petersen
635a3d87de
glibc: Change riscv32-linux-gnuilp32 target triple to riscv32-linux-gnu.
This target triple was weird on multiple levels:

* The `ilp32` ABI is the soft float ABI. This is not the main ABI we want to
  support on RISC-V; rather, we want `ilp32d`.
* `gnuilp32` is a bespoke tag that was introduced in Zig. The rest of the world
  just uses `gnu` for RISC-V target triples.
* `gnu_ilp32` is already the name of an ILP32 ABI used on AArch64. `gnuilp32` is
  too easy to confuse with this.
* We don't use this convention for `riscv64-linux-gnu`.
* Supporting all RISC-V ABIs with this convention will result in combinatorial
  explosion; see #20690.
2024-08-02 09:54:08 +02:00
Alex Rønne Petersen
e74c368962
std.zig.target: Set the minimum glibc for riscv32 to 2.33.
Relevant release notes:

* https://sourceware.org/legacy-ml/libc-announce/2018/msg00000.html
* https://sourceware.org/pipermail/libc-announce/2021/000030.html

Note that the supported ISAs/ABIs are explicitly listed in each, and only 2.33
actually supports the 32-bit ones.
2024-07-29 09:50:09 +02:00