16860 Commits

Author SHA1 Message Date
Andrew Kelley
f409457925 compiler: fix a bunch of format strings 2025-07-07 22:43:52 -07:00
Andrew Kelley
494819be91 cbe: reapply writer changes 2025-07-07 22:43:52 -07:00
Andrew Kelley
6963a1c7b9 C backend: prepare for merge 2025-07-07 22:43:52 -07:00
Andrew Kelley
6314e6f238 compiler: fix a bunch of format strings 2025-07-07 22:43:52 -07:00
Andrew Kelley
d5c97fded5 compiler: fix a bunch of format strings 2025-07-07 22:43:52 -07:00
Andrew Kelley
3afc6fbac6 std.zig.llvm.Builder: update format API 2025-07-07 22:43:52 -07:00
Andrew Kelley
ec3b5f0c74 compiler: upgrade various std.io API usage 2025-07-07 22:43:52 -07:00
Andrew Kelley
756a2dbf1a compiler: upgrade various std.io API usage 2025-07-07 22:43:52 -07:00
Andrew Kelley
941bc37193 compiler: update all instances of std.fmt.Formatter 2025-07-07 22:43:52 -07:00
Andrew Kelley
49be02e6d7 MachO: revert unfinished changes 2025-07-07 22:43:52 -07:00
Andrew Kelley
c8fcd2ff2c MachO: update to new std.io APIs 2025-07-07 22:43:52 -07:00
Andrew Kelley
f71d97e4cb update compiler source to new APIs 2025-07-07 22:43:52 -07:00
Andrew Kelley
fac5fe57be std.io.Writer.Allocating: rename interface to writer 2025-07-07 22:43:52 -07: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
0b3f0124dc std.io: move getStdIn, getStdOut, getStdErr functions to fs.File
preparing to rearrange std.io namespace into an interface

how to upgrade:

std.io.getStdIn() -> std.fs.File.stdin()
std.io.getStdOut() -> std.fs.File.stdout()
std.io.getStdErr() -> std.fs.File.stderr()
2025-07-07 22:43:51 -07:00
Andrew Kelley
9f27d770a1 std.io: deprecated Reader/Writer; introduce new API 2025-07-07 22:43:51 -07:00
Andrew Kelley
fc2c1883b3
Merge pull request #24362 (remove async, await, usingnamespace)
remove `async` and `await` keywords; remove `usingnamespace`
2025-07-08 07:41:39 +02:00
Alex Rønne Petersen
9e49652757 llvm: Revert #17963 (workaround for #16392) 2025-07-08 02:50:15 +02:00
Andrew Kelley
34f64432b0 remove usingnamespace from the language
closes #20663
2025-07-07 13:39:48 -07:00
Andrew Kelley
aa52bb8327 zig fmt 2025-07-07 13:39:16 -07:00
Andrew Kelley
40d11cc25a remove async and await keywords
Also remove `@frameSize`, closing #3654.

While the other machinery might remain depending on #23446, it is
settled that there will not be `async`/ `await` keywords in the
language.
2025-07-07 13:39:16 -07:00
Alex Rønne Petersen
b5cc658ab4 llvm: Use emulated TLS when appropriate for the target
Closes #24236.
2025-07-07 07:23:24 +02:00
Alex Rønne Petersen
c96c913bab
Merge pull request #24352 from alexrp/wasi-emulated-libs
`wasi`: Build emulated libraries into `libc.a`
2025-07-07 03:42:51 +02:00
Alex Rønne Petersen
2bf9ff1b42
wasi: Fix libwasi-emulated-process-clocks build
Might have been broken in 05d8b565ad1a1d6c0c1e93dc47f1d828043fcafc.
2025-07-06 20:49:19 +02:00
Alex Rønne Petersen
1f1082e36d
wasi: Build emulated libraries into libc.a
This matches what we do for small helper libraries like this in MinGW-w64. It
simplifies the compiler a bit, and also means the build system doesn't have to
treat these library names specially.

Closes #24325.
2025-07-06 20:05:18 +02:00
Alex Rønne Petersen
97ecb6c551 compiler: Disable self-hosted x86_64 backend on NetBSD
https://github.com/ziglang/zig/issues/24341
2025-07-06 19:50:29 +02:00
Alex Rønne Petersen
b461d07a54 Sema: Stop adding Windows implib link inputs for extern "..." syntax.
Closes #23971.
2025-07-06 01:00:18 +02:00
Alex Rønne Petersen
fc993945a9
Merge pull request #24335 from kada49/common-impl-libc-floor 2025-07-05 03:18:31 +02:00
Silver
be20f97eb9 Update TracyAllocator to new allocator API 2025-07-05 00:24:40 +02:00
David Senoner
b78751051f
delete superfluous assembly libc floor implementations 2025-07-04 20:05:18 +02:00
David Senoner
3124f700c7
delete superfluous libc floor implementations 2025-07-04 12:54:31 +02:00
Andrew Kelley
e126e5592d compiler: delete dead x86 bits file 2025-07-02 15:03:26 -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
Alex Rønne Petersen
edf785db0f
Merge pull request #24302 from alexrp/riscv
Native RISC-V bootstrap and test fixes
2025-07-02 04:15:10 +02:00
Ivan Stepanov
ee6d19480d spirv: fix signed overflow detection for safe subtraction
The overflow check for safe signed subtraction was using the formula (rhs < 0) == (lhs > result). This logic is flawed and incorrectly reports an overflow when the right-hand side is zero.
For the expression 42 - 0, this check evaluated to (0 < 0) == (42 > 42), which is false == false, resulting in true. This caused the generated SPIR-V to incorrectly branch to an OpUnreachable instruction, preventing the result from being stored.

Fixes #24281.
2025-07-01 19:26:21 +02:00
Alex Rønne Petersen
07114e6bc6
llvm: Disable the machine outliner pass on RISC-V 2025-07-01 18:16:40 +02:00
Alex Rønne Petersen
aa7b32d781
llvm: Fix alignment of by-ref ptr_elem_val and slice_elem_val 2025-07-01 18:16:36 +02:00
Andrew Kelley
d9742acc23 Sema: detect one-possible-value types after function calls
produces better Air for backends
2025-06-29 17:53:52 -07:00
Andrew Kelley
7999374b21 Sema: correct OPV for optional empty error set
prevents crashes in backends; improves codegen; provides more
comptime-ness.
2025-06-29 17:20:23 -07:00
Alex Rønne Petersen
e837765956
zig rc: Fix include directory detection when cross-compiling from certain host archs (#24288)
* resinator: Only preprocess when the input is an .rc file

* resinator: Fix include directory detection when cross-compiling from certain host archs

Previously, resinator would use the host arch as the target arch when looking for windows-gnu include directories. However, Zig only thinks it can provide a libc for targets specified in the `std.zig.target.available_libcs` array, which only includes a few for windows-gnu. Therefore, when cross-compiling from a host architecture that doesn't have a windows-gnu target in the available_libcs list, resinator would fail to detect the MinGW include directories.

Now, the custom option `/:target` is passed to `zig rc` which is intended for the COFF object file target, but can be re-used for the include directory target as well. For the include directory target, resinator will convert the MachineType to the relevant arch, or fail if there is no  equivalent arch/no support for detecting the includes for the MachineType (currently 64-bit Itanium and EBC).

Fixes the `windows_resources` standalone test failing when the host is, for example, `riscv64-linux`.
2025-06-29 09:59:38 +02:00
Ryan Liptak
d3363b7a61 Replace unreachable with error return for non-standard Windows targets
This new error mirrors the error returned from the Elf struct (error.UnsupportedElfArchitecture):

0adcfd60f4/src/link/Lld.zig (L112)

Before:

```
$ zig build-exe -target riscv64-windows-gnu main.zig
thread 543087 panic: reached unreachable code
```

After:

```
$ zig build-exe -target riscv64-windows-gnu main.zig
error: unable to create compilation: UnsupportedCoffArchitecture
```

Closes #24287
2025-06-29 08:32:19 +02:00
Ryan Liptak
09f4e2d9d1 resinator: Fix include directory detection when cross-compiling from certain host archs
Previously, resinator would use the host arch as the target arch when looking for windows-gnu include directories. However, Zig only thinks it can provide a libc for targets specified in the `std.zig.target.available_libcs` array, which only includes a few for windows-gnu. Therefore, when cross-compiling from a host architecture that doesn't have a windows-gnu target in the available_libcs list, resinator would fail to detect the MinGW include directories.

Now, the custom option `/:target` is passed to `zig rc` which is intended for the COFF object file target, but can be re-used for the include directory target as well. For the include directory target, resinator will convert the MachineType to the relevant arch, or fail if there is no  equivalent arch/no support for detecting the includes for the MachineType (currently 64-bit Itanium and EBC).

Fixes the `windows_resources` standalone test failing when the host is, for example, `riscv64-linux`.
2025-06-28 19:52:18 -07:00
Ali Cheraghi
1df79ab895 remove spirv cpu arch 2025-06-23 06:03:03 +02:00
Jacob Young
c71bb0f2b6 x86_64: fix pair live-out tracking
Closes #24226
2025-06-23 05:58:14 +02:00
David Rubin
3034d1e377 minor grammatical mistake 2025-06-22 20:00:17 +02:00
Jacob Young
1f98c98fff x86_64: increase passing test coverage on windows
Now that codegen has no references to linker state this is much easier.

Closes #24153
2025-06-19 18:41:12 -04:00
Jacob Young
ed37a1a33c coff: add hack to build a compiler-rt dynamic library
This is not meant to be a long-term solution, but it's the easiest thing
to get working quickly at the moment. The main intention of this hack is
to allow more tests to be enabled. By the time the coff linker is far
enough along to be enabled by default, this will no longer be required.
2025-06-19 18:41:12 -04:00