903 Commits

Author SHA1 Message Date
Andrew Kelley
a3efdd7279 std.Io: delete StreamSource
it shan't be missed
2025-07-22 09:41:43 -07:00
Andrew Kelley
b3ee5a6c30 update cmake file listing 2025-07-16 17:20:02 -07:00
Andrew Kelley
5360968e03 std: rename io to Io in preparation
This commit is non-breaking.

std.io is deprecated in favor of std.Io, in preparation for that
namespace becoming an interface.
2025-07-11 01:16:27 +02:00
Andrew Kelley
0e37ff0d59 std.fmt: breaking API changes
added adapter to AnyWriter and GenericWriter to help bridge the gap
between old and new API

make std.testing.expectFmt work at compile-time

std.fmt no longer has a dependency on std.unicode. Formatted printing
was never properly unicode-aware. Now it no longer pretends to be.

Breakage/deprecations:
* std.fs.File.reader -> std.fs.File.deprecatedReader
* std.fs.File.writer -> std.fs.File.deprecatedWriter
* std.io.GenericReader -> std.io.Reader
* std.io.GenericWriter -> std.io.Writer
* std.io.AnyReader -> std.io.Reader
* std.io.AnyWriter -> std.io.Writer
* std.fmt.format -> std.fmt.deprecatedFormat
* std.fmt.fmtSliceEscapeLower -> std.ascii.hexEscape
* std.fmt.fmtSliceEscapeUpper -> std.ascii.hexEscape
* std.fmt.fmtSliceHexLower -> {x}
* std.fmt.fmtSliceHexUpper -> {X}
* std.fmt.fmtIntSizeDec -> {B}
* std.fmt.fmtIntSizeBin -> {Bi}
* std.fmt.fmtDuration -> {D}
* std.fmt.fmtDurationSigned -> {D}
* {} -> {f} when there is a format method
* format method signature
  - anytype -> *std.io.Writer
  - inferred error set -> error{WriteFailed}
  - options -> (deleted)
* std.fmt.Formatted
  - now takes context type explicitly
  - no fmt string
2025-07-07 22:43:51 -07:00
Andrew Kelley
5ae2428d52 compiler: change canonical path for backend ABI source files 2025-07-02 15:01:50 -07:00
Andrew Kelley
a13f0d40eb compiler: delete arm backend
this backend was abandoned before it was completed, and it is not worth
salvaging.
2025-07-02 14:50:41 -07:00
Andrew Kelley
20a543097b compiler: delete aarch64 backend
this backend was abandoned before it was completed, and it is not worth
salvaging.
2025-07-02 14:42:20 -07:00
Andrew Kelley
80a9b8f326 compiler: delete powerpc backend stub
nobody is currently working on this
2025-07-02 14:35:13 -07:00
Jonathan Marler
f5a327cd36 windows: msvc: avoid linking to non-redistributable ucrt 2025-06-19 13:43:27 +02:00
Jonathan Marler
f3940ad858 windows: MSVC: disable extra dubious Microsoft runtime checks
Cmake by default adds the `/RTC1` compiler flag for debug builds.
However, this causes C code that conforms to the C standard and has
well-defined behavior to trap. Here I've updated CMAKE to use the more
lenient `/RTCs` by default which removes the uninitialized variable checks
but keeps the stack error checks.
2025-06-18 16:41:25 +02:00
mlugg
d24af29742
CMakeLists: update file list 2025-06-12 13:55:41 +01:00
Alex Rønne Petersen
44155eb93c
cmake: Simplify some arm/thumb checks.
I'm not convinced that some of the possibilities that these regexes allowed are real. I've literally never seen or heard of "armhfel", nor of "thumb" ever showing up in `uname -m`, etc.
2025-06-07 22:24:09 +02:00
Alex Rønne Petersen
06d50d046a
cmake: Fix arm/thumb arch checks
Closes #24114.
2025-06-07 22:12:03 +02:00
Jacob Young
0bf8617d96 x86_64: add support for pie executables 2025-06-06 23:42:14 -07:00
Alex Rønne Petersen
e3b8aece4b
Revert "Allocate enough memory when building zig2"
This reverts commit 9356cb1475606a7afd2e722af60f87ce2b39f9f8.

https://github.com/ziglang/zig/pull/20514#issuecomment-2774509823
2025-06-02 20:33:36 +02:00
Hilger Baumstark
0386730777
compiler-rt: add __addvsi3, __subvsi3, __mulvsi3, and __subvdi3 2025-06-01 20:17:25 +02:00
Jacob Young
c04be630d9 Legalize: introduce a new pass before liveness
Each target can opt into different sets of legalize features.
By performing these transformations before liveness, instructions
that become unreferenced will have up-to-date liveness information.
2025-05-29 03:57:48 -04:00
Alex Rønne Petersen
999777e73a compiler: Scaffold stage2_powerpc backend.
Nothing interesting here; literally just the bare minimum so I can work on this
on and off in a branch without worrying about merge conflicts in the non-backend
code.
2025-05-20 10:23:16 +02:00
Alex Rønne Petersen
a97e417ab1
compiler: Support building NetBSD crt1.o/Scrt1.o and stub shared libraries.
Only works for NetBSD 10.1+. Note that we still default to targeting NetBSD 9.

Contributes to #2877.
2025-05-17 20:12:56 +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
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
610d3cf9de
compiler: Move vendored library support to libs subdirectory. 2025-05-10 12:19:26 +02:00
Alex Rønne Petersen
30e254fc31
link: Stub out GOFF/XCOFF linker code based on LLVM.
This allows emitting object files for s390x-zos (GOFF) and powerpc(64)-aix
(XCOFF).

Note that GOFF emission in LLVM is still being worked on upstream for LLVM 21;
the resulting object files are useless right now. Also, -fstrip is required, or
LLVM will SIGSEGV during DWARF emission.
2025-04-27 03:52:52 +02:00
Alex Rønne Petersen
3be6809e27
Merge pull request #23217 from selfisekai/cmake-release-safe
* cmake: Add ZIG_RELEASE_SAFE option to build as ReleaseSafe
* cmake: Map MinSizeRel to ReleaseSmall.
2025-04-17 04:18:23 +02:00
Pavel Otchertsov
dc090e99cf cmake: support static linking against libxml2 2025-04-16 22:56:27 +02:00
Alex Rønne Petersen
f2363623e1
cmake: Map MinSizeRel to ReleaseSmall. 2025-04-16 20:46:41 +02:00
Alex Rønne Petersen
1bfc71d4da build: Set LLVM_BUILD_STATIC/CLANG_BUILD_STATIC when linking statically.
This is needed since LLVM 20, particularly for Windows.
2025-04-09 10:11:52 +02:00
Andrew Kelley
0cd31fc7ff
Merge pull request #22780 from ziglang/llvm20
LLVM 20
2025-04-05 01:46:13 -04:00
Alex Rønne Petersen
957a5ae560
cmake: Pass -fno-sanitize=undefined when building zig2.
We build zig2.c and compiler_rt.c with -O0 but then proceed to link with -O3.
So zig2.o and compiler_rt.o will have references to ubsan-rt symbols, but the
-O3 causes the compiler to not link ubsan-rt. We don't actually need the safety
here, so just explicitly disable ubsan.
2025-04-04 06:08:10 +02:00
Alex Rønne Petersen
c712f18d74
build: Update to LLVM/Clang 20. 2025-04-04 06:08:08 +02:00
Andrew Kelley
1639fcea43 de-genericify SinglyLinkedList
by making it always intrusive, we make it a more broadly useful API, and
avoid binary bloat.
2025-04-03 14:55:04 -07:00
LN Liberda
19888f759f cmake: Add ZIG_RELEASE_SAFE option to build as ReleaseSafe 2025-03-12 18:15:42 +01:00
Andrew Kelley
05937b362a start the 0.15.0 release cycle 2025-03-04 14:31:32 -08:00
Alex Rønne Petersen
5c44934e20 Move the compiler's LLVM bitcode builder to std.zig.llvm. 2025-02-27 01:32:49 -05:00
mlugg
e0a955afb3 x86_64: use ZON for encodings 2025-02-25 22:32:00 +00:00
Jan200101
bf6ee7cb34 cmake: use cache entry for extra build args to get the type correct 2025-01-28 14:23:42 +01:00
melonedo
658a4a527c Fix incompatibility with multi-config cmake generator
Avoid hard coding the path of zig2 relative to PROJECT_BINARY_DIR
2025-01-26 21:06:09 +01:00
Andrew Kelley
7879d2cf41 cmake: remove deleted file 2025-01-15 15:11:35 -08:00
Andrew Kelley
795e7c64d5 wasm linker: aggressive DODification
The goals of this branch are to:
* compile faster when using the wasm linker and backend
* enable saving compiler state by directly copying in-memory linker
  state to disk.
* more efficient compiler memory utilization
* introduce integer type safety to wasm linker code
* generate better WebAssembly code
* fully participate in incremental compilation
* do as much work as possible outside of flush(), while continuing to do
  linker garbage collection.
* avoid unnecessary heap allocations
* avoid unnecessary indirect function calls

In order to accomplish this goals, this removes the ZigObject
abstraction, as well as Symbol and Atom. These abstractions resulted
in overly generic code, doing unnecessary work, and needless
complications that simply go away by creating a better in-memory data
model and emitting more things lazily.

For example, this makes wasm codegen emit MIR which is then lowered to
wasm code during linking, with optimal function indexes etc, or
relocations are emitted if outputting an object. Previously, this would
always emit relocations, which are fully unnecessary when emitting an
executable, and required all function calls to use the maximum size LEB
encoding.

This branch introduces the concept of the "prelink" phase which occurs
after all object files have been parsed, but before any Zcu updates are
sent to the linker. This allows the linker to fully parse all objects
into a compact memory model, which is guaranteed to be complete when Zcu
code is generated.

This commit is not a complete implementation of all these goals; it is
not even passing semantic analysis.
2025-01-15 15:11:35 -08:00
Jacob Young
5837147461 cmake: fix warnings 2024-12-23 14:40:28 -05:00
Jakub Konka
f78006c1bf CMakeLists: add MachO/Dwarf.zig and remove MachO/dwarf.zig 2024-12-02 22:05:21 -05:00
Andrew Kelley
f6392b9526 cmake: don't add an unnecessary curses static lib dependency 2024-11-25 15:05:42 -08:00
Alex Rønne Petersen
baf60426d4
std.Target: Rename amdgpu module to amdgcn.
This was an inconsistency left over from c825b567b26c475e058e074e5d22af006854fab6.
2024-11-02 10:44:14 +01:00
Andrew Kelley
ba2d006634 link.File.Wasm: remove the "files" abstraction
Removes the `files` field from the Wasm linker, storing the ZigObject
as its own field instead using a tagged union.

This removes a layer of indirection when accessing the ZigObject, and
untangles logic so that we can introduce a "pre-link" phase that
prepares the linker state to handle only incremental updates to the
ZigObject and then minimize logic inside flush().

Furthermore, don't make array elements store their own indexes, that's
always a waste.

Flattens some of the file system hierarchy and unifies variable names
for easier refactoring.

Introduces type safety for optional object indexes.
2024-10-30 19:34:58 -07:00
Alex Rønne Petersen
b5cafe223a Revert "cmake: Add a ZIG2_NO_RTLIB option for building zig2 without compiler-rt."
This reverts commit 3dd6456c0f8d50801d366062bcf5894bb5d9e7ac.

We didn't end up using this after all.
2024-10-29 06:48:47 +01:00
Jakub Konka
56996a2809
link/Coff: simplify file structure by collapsing all files into Coff.zig (#21761)
* coff: collapse Coff/lld.zig logic into Coff.zig

* coff: rename std.coff uses to coff_util

* coff: rename self to coff for *Coff references

* coff: collapse Coff/Atom.zig logic into Coff.zig

* coff: collapse Coff/Relocation.zig logic into Coff.zig

* coff: collapse Coff/ImportTable.zig logic into Coff.zig

* coff: remove unused Coff/Object.zig

* link/Coff: fix rebase gone wrong
2024-10-24 13:50:02 +00:00
Andrew Kelley
5ca54036ca move linker input file parsing to the compilation pipeline 2024-10-23 16:27:38 -07:00
Andrew Kelley
1e785409bb move link.Elf.LdScript to link.LdScript 2024-10-23 16:27:38 -07:00
Andrew Kelley
7b69738a06 link.Elf: fix merge sections namespacing
`link.Elf.merge_section.MergeSection` -> `link.Elf.Merge.Section`
2024-10-11 10:33:54 -07:00