Commit graph

17331 commits

Author SHA1 Message Date
Jacob Young
969f2cff82 Elf2: implement virtual allocation
This allows segments to be moved around in the output file without
needing to reapply relocations until virtual address space is exhaused.
2025-10-06 11:27:39 -07:00
Alex Rønne Petersen
ddc815e3d8 drop support for powerpc64 ELF v1
* ELF v1 on powerpc64 is only barely kept on life support in a couple of Linux
  distros. I don't anticipate that this will last much longer.
* Most of the Linux world has moved to powerpc64le which requires ELF v2.
* Some Linux distros have even started supporting powerpc64 with ELF v2.
* The BSD world has long since moved to ELF v2.
* We have no actual linking support for ELF v1.
* ELF v1 had confused DWARF register mappings which is becoming a problem in
  our DWARF code in std.debug.

It's clear that ELF v1 is on its way out, and we never fully supported it
anyway. So let's not waste any time or energy on it going forward.

closes #5927
2025-10-06 01:28:56 +02:00
Jacob Young
906ce2ad7c InternPool: use sequential string indices instead of byte offsets
This allows more bytes to be referenced by a smaller index range.

Closes #22867
Closes #25297
Closes #25339
2025-10-05 00:25:21 -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
Alex Rønne Petersen
6870144a3b
libcxx: don't impose _LIBCPP_ENABLE_CXX17_REMOVED_UNEXPECTED_FUNCTIONS on users
closes https://github.com/ziglang/zig/issues/25455
2025-10-04 00:46:04 +02:00
Alex Rønne Petersen
ef2001c7ff
libcxxabi: define _LIBCPP_BUILDING_LIBRARY in addition to _LIBCXXABI_BUILDING_LIBRARY 2025-10-04 00:46:04 +02:00
Alex Rønne Petersen
43888e6549
libcxxabi: don't build cxa_noexception.cpp if exceptions are enabled 2025-10-04 00:46:02 +02:00
Alex Rønne Petersen
920ea35714
libcxxabi: sort file list according to upstream CMakeLists.txt 2025-10-04 00:43:20 +02:00
Jacob Young
07c3f9ef8e x86_64: fix bool vector init register clobber
Closes #25439
2025-10-03 12:18:53 -04:00
Jacob Young
12ed0ff1ef
Merge pull request #25430 from jacobly0/x86_64-win
Coff2: create a new linker from scratch
2025-10-03 05:03:44 -04:00
Alex Rønne Petersen
91fa2c61aa
compiler: control the s390x backchain feature through the frame pointer option
This is a little different from how C/C++ compilers do this, but I think it's
justified because it's what users actually *mean* when the use frame pointer
options.

This is another one of those LLVM "CPU" features that have nothing to do with
CPU at all and should really be a TargetMachine option or something. One day
we'll figure out a better way of dealing with these...
2025-10-03 03:29:20 +02: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
mlugg
1914d1a6e5 Lld: fix implib emit path
Resolves: https://github.com/ziglang/zig/issues/24993
2025-10-02 02:31:44 +01:00
Timothy Bess
cbe3dd12c4 Fix zig build lazy -> eager dependency promotion
Before, this had a subtle ordering bug where duplicate
deps that are specified as both lazy and eager in different
parts of the dependency tree end up not getting fetched
depending on the ordering. I modified it to resubmit lazy
deps that were promoted to eager for fetching so that it will
be around for the builds that expect it to be eager downstream
of this.
2025-09-30 18:58:42 -07:00
mlugg
0c24b8ec66
update to new std.debug changes 2025-09-30 13:44:55 +01:00
Jacob Young
b578cca022
link.Dwarf: i just fixed error union values, s'nothin' else to it 2025-09-30 13:44:54 +01:00
mlugg
4e45362529
link.Elf: fix static PIE
We mustn't emit the DT_PLTGOT entry in `.dynamic` in a statically-linked
PIE, because there's no dl to relocate it (and `std.pie.relocate`, or
the PIE relocator in libc, won't touch it). In that case, there cannot
be any PLT entries, so there's no point emitting the `.got.plt` section
at all. If we just don't create that section, `link.Elf` already knows
not to add the DT_PLTGOT entry to `.dynamic`.

Co-authored-by: Jacob Young <jacobly0@users.noreply.github.com>
2025-09-30 13:44:53 +01:00
mlugg
bfbbda7751
compiler: fix new panic handler in release builds 2025-09-30 13:44:52 +01:00
mlugg
f40fbdb3b3
link.Elf: restore eh_frame_hdr search table building
At least, when there's not a ZigObject. The old behavior was incorrect
in the presence of a ZigObject, and this doesn't really mix nicely with
incremental compilation anyway; but when the objects are all external,
we may as well build the search table.
2025-09-30 13:44:52 +01:00
mlugg
d9661e9e05
compiler: better crash handler
Far simpler, because everything which `crash_report.zig` did is now
handled pretty well by `std.debug` anyway. All we want is to print some
context around panics and segfaults. Using the new ability to override
the default segfault handler while still having std handle the
target-specific bits for us, that's really simple.
2025-09-30 13:44:52 +01:00
mlugg
0c7b2a7bd5
fix compiler ftbfs from std.macho and std.dwarf changes 2025-09-30 13:44:51 +01:00
mlugg
c2ada49354
replace usages of old std.debug APIs
src/crash_handler.zig is still TODO though, i am planning bigger changes there
2025-09-30 13:44:51 +01:00
mlugg
89d862180f
yet more 2025-09-30 13:44:49 +01:00
mlugg
b750e7cf9e
change one million things 2025-09-30 13:44:49 +01:00
Matthew Lugg
7adb15892e
Merge pull request #25353 from mlugg/x86_64-faster
x86_64: generate better constant memcpy code
2025-09-30 13:28:37 +01:00
Alex Rønne Petersen
ba19c1104b
musl: delete dead __restore and __restore_rt functions for hexagon, loongarch64, riscv32, riscv64
https://www.openwall.com/lists/musl/2025/09/28/2
2025-09-28 17:04:56 +02:00
Alex Rønne Petersen
f90510b081 libcxx: respond to some feature macro changes in LLVM 20
ba87515fea

closes #25376
2025-09-28 14:45:31 +02: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
d79b3cc134 target: x86_64 backend can build compiler rt with coff
Without allowing this, the references to `compiler_rt.dll` emitted by
the coff linker will prevent the executable from running.
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
1f7ee99b35 musl: add missing fenv C dummy functions for loongarch64-linux-muslsf
https://www.openwall.com/lists/musl/2025/09/27/1

closes #25367
2025-09-27 17:13:29 +02:00
Ryan Liptak
b1a0a4e03b Update descriptions of -f[no-]error-tracing to match the actual behavior
Before https://github.com/ziglang/zig/pull/18160, error tracing defaulted to true in ReleaseSafe, but that is no longer the case. These option descriptions were never updating accordingly.
2025-09-26 14:01:17 -07:00
Andrew Kelley
e0dc2e4e3f
Merge pull request #25342 from ziglang/fuzz-limit
fuzzing: implement limited fuzzing
2025-09-26 05:28:46 -07:00
Andrew Kelley
3b365a1f9b
Merge pull request #25351 from ziglang/chomp
std.mem: introduce cut functions; rename "index of" to "find"
2025-09-26 01:45:07 -07:00
Andrew Kelley
98253bc0ee Compilation: --debug-rt always Debug
--debug-rt previously would make rt libs match the root module. Now they
are always debug when --debug-rt is passed. This includes compiler-rt,
fuzzer lib, and others.
2025-09-25 17:15:47 -07: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
Andrew Kelley
2a88a6a456
Merge pull request #24497 from ziglang/aro-translate-c
compiler: update aro and translate-c to latest; delete clang translate-c
2025-09-25 14:18:49 -07:00
Andrew Kelley
14e227d8a6 std.mem: add cutLast and cutScalarLast 2025-09-25 11:38:38 -07:00
Andrew Kelley
3411b5e499 std.mem: add cut and cutScalar and example usage 2025-09-25 11:11:46 -07:00
Andrew Kelley
dd2f1cbebf std.mem: rename chomp to cut 2025-09-25 10:54:28 -07:00
Andrew Kelley
ccaf82d243 CLI: simpler semantics for prefixed integer args 2025-09-25 10:50:41 -07:00
Andrew Kelley
513389bc5b CLI: exploit std.mem.chompPrefix
fixes a bug in how -fstructured-cfg and -fno-structured-cfg are handled.
2025-09-25 10:50:41 -07:00
Jacob Young
6257f4abb7 x86_64: improve support for large enums
Closes #25247
2025-09-24 21:20:27 -07:00
Andrew Kelley
e05073b9e4 aro does not have -mmacos version flags or -Wno-overriding-option 2025-09-24 20:01:19 -07:00