2302 Commits

Author SHA1 Message Date
Bingwu Zhang
a8fea09cd5 cbe: fix more MIPS register names in inline assembly 2025-11-01 15:11:35 +01:00
Jacob Young
5b060ef9d4
Merge pull request #25558 from jacobly0/elfv2-load-obj
Elf2: start implementing input object loading
2025-10-30 12:09:13 -04:00
Jacob Young
32779a7c73
aarch64: fix macho external references 2025-10-30 09:31:30 +00:00
Jacob Young
402c14f86a
aarch64: implement optional comparisons 2025-10-30 09:31:30 +00:00
Matthew Lugg
74931fe25c
std.debug.lockStderrWriter: also return ttyconf
`std.Io.tty.Config.detect` may be an expensive check (e.g. involving
syscalls), and doing it every time we need to print isn't really
necessary; under normal usage, we can compute the value once and cache
it for the whole program's execution. Since anyone outputting to stderr
may reasonably want this information (in fact they are very likely to),
it makes sense to cache it and return it from `lockStderrWriter`. Call
sites who do not need it will experience no significant overhead, and
can just ignore the TTY config with a `const w, _` destructure.
2025-10-30 09:31:28 +00:00
Jacob Young
09aa4add2a x86_64: add lret encoding
Closes #25608
2025-10-29 19:31:44 -04:00
Jacob Young
52a029e503 x86_64: continue hacking around unimplemented linker logic
Closes #25666
2025-10-29 19:31:44 -04:00
Jacob Young
ada9035af5 x86_64: fix encoding for out with an immediate port
Closes #25547
2025-10-29 18:41:31 -04:00
Jacob Young
0834e696f7 Elf2: start implementing dynamic linking 2025-10-29 18:15:09 -04:00
Jacob Young
7542c3260f Elf2: load relocations from input objects 2025-10-29 18:06:17 -04:00
Andrew Kelley
a072d821be
Merge pull request #25592 from ziglang/init-std.Io
std: Introduce `Io` Interface
2025-10-29 13:51:37 -07:00
Alex Rønne Petersen
a7119d4269 remove all IBM AIX and z/OS support
As with Solaris (dba1bf935390ddb0184a4dc72245454de6c06fd2), we have no way to
actually audit contributions for these OSs. IBM also makes it even harder than
Oracle to actually obtain these OSs.

closes #23695
closes #23694
closes #3655
closes #23693
2025-10-29 14:25:51 +01:00
Andrew Kelley
02119362d7 wasm linking: handle unreachable call_indirect
The compiler crashed when we tried to call a function pointer for which
the type signature does not match any function body or function import
in the entire wasm executable, because there is no way to create a
reference to a function without it being in the function table or import
table. Solution is to make this instruction lower to unreachable.
2025-10-29 06:20:51 -07:00
Andrew Kelley
2bcdde2985 compiler: update for introduction of std.Io
only thing remaining is using libc dns resolution when linking libc
2025-10-29 06:20:49 -07:00
Cooksey99
2cbd0d3f08 spirv: fix airWorkGroupSize to use workgroup_size builtin 2025-10-28 10:23:32 +01:00
Alex Rønne Petersen
06d9e3bc06
Merge pull request #25691 from GasInfinity-Forks/x86_16-gcc
feat: init x86_16 arch via CBE
2025-10-28 10:19:21 +01:00
Alex Rønne Petersen
dba1bf9353 remove all Oracle Solaris support
There is no straightforward way for the Zig team to access the Solaris system
headers; to do this, one has to create an Oracle account, accept their EULA to
download the installer ISO, and finally install it on a machine or VM. We do not
have to jump through hoops like this for any other OS that we support, and no
one on the team has expressed willingness to do it.

As a result, we cannot audit any Solaris contributions to std.c or other
similarly sensitive parts of the standard library. The best we would be able to
do is assume that Solaris and illumos are 100% compatible with no way to verify
that assumption. But at that point, the solaris and illumos OS tags would be
functionally identical anyway.

For Solaris especially, any contributions that involve APIs introduced after the
OS was made closed-source would also be inherently more risky than equivalent
contributions for other proprietary OSs due to the case of Google LLC v. Oracle
America, Inc., wherein Oracle clearly demonstrated its willingness to pursue
legal action against entities that merely copy API declarations.

Finally, Oracle laid off most of the Solaris team in 2017; the OS has been in
maintenance mode since, presumably to be retired completely sometime in the 2030s.

For these reasons, this commit removes all Oracle Solaris support.

Anyone who still wishes to use Zig on Solaris can try their luck by simply using
illumos instead of solaris in target triples - chances are it'll work. But there
will be no effort from the Zig team to support this use case; we recommend that
people move to illumos instead.
2025-10-27 07:35:38 -07:00
GasInfinity
104c272ae5
feat: init x86_16 arch via CBE 2025-10-27 11:19:51 +01:00
Alex Rønne Petersen
bebfdc3661 llvm: remove some workarounds in loadTruncate()
No longer needed with LLVM 21.
2025-10-25 04:52:46 +02:00
Alex Rønne Petersen
af1d777b27
std.builtin: add CallingConvention.sh_interrupt
Only supported in CBE.
2025-10-23 09:27:17 +02:00
Alex Rønne Petersen
4fa453ce20
std.builtin: add CallingConvention.microblaze_interrupt
Only supported in CBE.
2025-10-23 09:27:17 +02:00
Alex Rønne Petersen
abf40caeb7
std.builtin: add CallingConvention.msp430_interrupt
Supported by LLVM and CBE.
2025-10-23 09:27:17 +02:00
Alex Rønne Petersen
beb507a1ed
std.builtin: add CallingConvention.x86_64_x32
This was forgotten during the refactoring of std.builtin.CallingConvention. It
mirrors mips64_n32 for MIPS.
2025-10-23 09:27:17 +02:00
Alex Rønne Petersen
ee72f06f47
std.Target: add tags and info for alpha, hppa, microblaze, sh 2025-10-23 09:27:17 +02:00
Alex Rønne Petersen
3e2daa509a
std.Target: add arceb and xtensaeb Cpu.Arch tags 2025-10-23 09:27:17 +02:00
Alex Rønne Petersen
dbf9c7b548 compiler: add support for arc_interrupt calling convention
Only for use with the C backend at the moment.
2025-10-19 22:27:19 +02:00
Bingwu Zhang
6de339d5d3 cbe: fix MIPS register names in inline assembly
Zig uses "rN" for MIPS register clobbers which are more
ergonomic and easier to write (.rN vs. .@"$N").
However, GCC and Clang uses "$N".

Bug: #25613
Signed-off-by: Bingwu Zhang <xtex@xtexx.eu.org>
2025-10-19 01:07:51 +02:00
bnuuydev
173f497e29 llvm-backend: fix uefi data layout
the old logic caused the uefi case to fall through which caused an
assertion assertion in llvm to fail, as the data layout was wrong.
2025-10-16 13:59:02 +02:00
Jacob Young
2e31077fe0 Coff: implement threadlocal variables 2025-10-10 22:47:47 -07:00
Jacob Young
d28006153e llvm.Builder: allow Metadata to reference metadata strings
Closes #25486
2025-10-07 07:49:54 -04:00
Ryan Liptak
e393543e63 Support generating import libraries from mingw .def files without LLVM
For the supported COFF machine types of X64 (x86_64), I386 (x86), ARMNT (thumb), and ARM64 (aarch64), this new Zig implementation results in byte-for-byte identical .lib files when compared to the previous LLVM-backed implementation.
2025-10-03 18:26:05 -07:00
Jacob Young
07c3f9ef8e x86_64: fix bool vector init register clobber
Closes #25439
2025-10-03 12:18:53 -04:00
Jacob Young
1fa11e0954 Coff: delete 2025-10-02 17:44:52 -04:00
Jacob Young
e1f3fc6ce2 Coff2: create a new linker from scratch 2025-10-02 17:44:52 -04:00
Jacob Young
d5f09f56e0 x86_64: fix windows calling convention abi 2025-10-02 15:59:51 -04:00
Jacob Young
a896a22932 x86_64: fix @mulAdd miscomp 2025-09-27 20:10:32 -04:00
Jacob Young
a744fbd22f x86_64: fix ~/! miscomps 2025-09-27 18:30:52 -04:00
Jacob Young
b206b0626a x86_64: fix @floatFromInt miscomps 2025-09-27 18:30:52 -04:00
mlugg
611c38e6da x86_64: fix unencodable rem lowerings
The memory operand might use one of the extended GPRs R8 through R15 and
hence require a REX prefix, but having a REX prefix makes the high-byte
register AH unencodeable as the src operand. This latent bug was exposed
by this branch, presumably because `select` now happens to be putting
something in an extended GPR instead of a legacy GPR.

In theory this could be fixed with minimal cost by introducing a way to
communicate to `select` that neither the destination memory nor the
other temporary can be in an extended GPR. However, I just went for the
simple solution which comes at a cost of one trivial instruction: copy
the remainder from AH to AL, and *then* copy AL to the destination.
2025-09-27 18:30:52 -04:00
mlugg
77fca1652f x86_64: fix miscompilation of mul on vectors of large ints 2025-09-27 18:30:52 -04:00
mlugg
0c476191a4 x86_64: generate better constant memcpy code
`rep movsb` isn't usually a great idea here. This commit makes the logic
which tentatively existed in `genInlineMemcpy` apply in more cases, and
in particular applies it to the "new" backend logic. Put simply, all
copies of 128 bytes or fewer will now attempt this path first,
where---provided there is an SSE register and/or a general-purpose
register available---we will lower the operation using a sequence of 32,
16, 8, 4, 2, and 1 byte copy operations.

The feedback I got on this diff was "Push it to master and if it
miscomps I'll revert it" so don't blame me when it explodes
2025-09-27 18:30:52 -04:00
Alex Rønne Petersen
86077fe6bd compiler: move self-hosted backends from src/arch to src/codegen 2025-09-26 02:02:07 +02:00
Jacob Young
f58200e3f2 Elf2: create a new linker from scratch
This iteration already has significantly better incremental support.

Closes #24110
2025-09-21 14:09:14 -07:00
Frank Denis
bdc31c9561 aarch64/zonCast: don't return a pointer to a stack element
Elements are computed at comptime, so don't declare them as "var".
2025-09-21 05:01:41 -07:00
Jacob Young
5144f10ec9 aarch64: fix behavior failures 2025-09-20 18:33:01 -07:00
Jacob Young
f12c4f86fc aarch64: implement ptr_slice_*_ptr 2025-09-20 18:33:00 -07:00
Andrew Kelley
14bda4130a llvm backend: remove canElideLoad mechanism 2025-09-20 18:33:00 -07:00
mlugg
580b6d1fad llvm: fix tagged union payload size in debug info
Resolves: #24415
2025-09-16 18:55:19 +01:00
Andrew Kelley
150169f1e0 std.fmt: delete deprecated APIs
std.fmt.Formatter -> std.fmt.Alt
std.fmt.format -> std.Io.Writer.print
2025-08-31 12:49:18 -07:00
Andrew Kelley
b7104231af
Merge pull request #25077 from ziglang/GenericReader
std.Io: delete GenericReader, AnyReader, FixedBufferStream; and related API breakage
2025-08-30 12:43:52 -07:00