Skip to content

[pull] master from ziglang:master #3

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 4,784 commits into
base: master
Choose a base branch
from
Open

Conversation

pull[bot]
Copy link

@pull pull bot commented Jul 16, 2024

See Commits and Changes for more details.


Created by pull[bot] (v2.0.0-alpha.3)

Can you help keep this open source service alive? 💖 Please sponsor : )

@pull pull bot added ⤵️ pull merge-conflict Resolve conflicts manually labels Jul 16, 2024
mlugg and others added 28 commits June 20, 2025 00:24
Fixes an additional bug reported in the closed #24216.
x86_64: increase passing test coverage on windows
Linux futex (v1 and v2) API fixes, tests and Ziggification
`std.Build`: more miscellaneous bits
On powerpc64le Linux, the registers used for passing syscall parameters
(r4-r8, as well as r0 for the syscall number) are volatile, or
caller-saved. However, Zig's syscall wrappers for this architecture do
not include all such registers in the list of clobbers, leading the
compiler to assume these registers will maintain their values after the
syscall completes.

In practice, this resulted in a segfault when allocating memory with
`std.heap.SmpAllocator`, which calls `std.os.linux.sched_getaffinity`.
The third parameter to `sched_getaffinity` is a pointer to a `cpu_set_t`
and is stored in register r5. After the syscall, the code attempts to
access data in the `cpu_set_t`, but because the compiler doesn't realize
the value of r5 may have changed, it uses r5 as the memory address, which
in practice resulted in a memory access at address 0x8.

This commit adds all volatile registers to the list of clobbers.
musl and glibc both specify r0 as an output register because its value
may be overwritten by system calls. As with the updates for 64-bit
PowerPC in the previous commit, this commit brings Zig's syscall
functions for 32-bit PowerPC in line with musl and glibc by adding r0 to
the list of clobbers. (Listing r0 as both an input and a clobber is as
close as we can get to musl, which declares it as a "+r" read-write
output, since Zig doesn't support multiple outputs or the "+"
specifier.)
Since marks are limited to a single filesystem.
Context: #20670
Original pull request: #20672

Co-authored-by: Maciej 'vesim' Kuliński <[email protected]>
Btrfs at least supports 16 EiB files (limited in practice to 8EiB by the
Linux VFS code which uses signed 64-bit offsets).  So fix the fs.zig test
case to expect either a FileTooBig or success from truncating a file to
8EiB.  And test that beyond that size the offset is interpreted as a
negative number.

Fixes #24242
* c.darwin: define MSG for macos

* darwin: add series os name

* Update lib/std/c.zig

Co-authored-by: Alex Rønne Petersen <[email protected]>

---------

Co-authored-by: Alex Rønne Petersen <[email protected]>
* getrandom was added in glibc 2.25
https://sourceware.org/bugzilla/show_bug.cgi?id=17252

* copy_file_range was added in glibc 2.27
https://sourceware.org/git/?p=glibc.git;a=commit;h=bad7a0c81f501fbbcc79af9eaa4b8254441c4a1f

* threads.h should not exist for glibc < 2.28

* single_threaded.h should not exist for glibc < 2.35

* Apply suggestions from code review

Co-authored-by: Alex Rønne Petersen <[email protected]>

* 2.35 instead of 35

* before 2.35 instead of 2.34 and before

---------

Co-authored-by: Alex Rønne Petersen <[email protected]>
* Fix warning WasmMut_toC not all control paths return a value

This is a follow up to #24206 where
I had previously submitted different mechanisms to fix this warning.
This PR is a suggestion by Alex to return NULL instead and Andrew
confirmed this is his preference.
…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`.
#24180)

* compiler: test runner: fix tests never fails on crippled architectures

* riscv64: skip failing tests

* riscv64: enable test summary printing
This new error mirrors the error returned from the Elf struct (error.UnsupportedElfArchitecture):

https://github.com/ziglang/zig/blob/0adcfd60f4fcfd01c74a6477cbcef187ce06f533/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
…tain 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`.
prevents crashes in backends; improves codegen; provides more
comptime-ness.
andrewrk and others added 30 commits July 15, 2025 11:32
these are taking too long. let's use a different workflow for now until
these runs are not holding up the pipeline, then they can be
reintroduced on master branch
These regressed with 1a99888

I'm not ready to tackle std.posix quite yet
std.Io fixes, docs, and tests
Soft float is a very rare use case for riscv*-linux. No point wasting CI
resources on these targets, especially since our arm and mips soft float
coverage is already likely to catch most soft float bugs.
until now these were stringly typed.

it's kinda obvious when you think about it.
needed due to syntax update
LLVM always assumes these are on. Zig backends do not observe them.

If Zig backends want to start using them, they can be introduced, one
arch at a time, with proper documentation.
"that's really easy to handle correctly" he said
wtf are these dollar signs?
inline assembly: use types for clobbers
prevents e.g. lld-link: warning: undefined symbol: SystemFunction036
from being only a warning
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
⤵️ pull merge-conflict Resolve conflicts manually
Projects
None yet
Development

Successfully merging this pull request may close these issues.