31821 Commits

Author SHA1 Message Date
Alex Rønne Petersen
78b8ce5095
test: Change llvm_targets to actually emit an object for each target.
Without doing this, we don't actually test whether the data layout string we
generate matches LLVM's.

A number of targets had to be commented out due to this change:

* Some are using a non-working experimental LLVM backend (arc, csky, ...).
* Some don't have working LLD support (lanai, sparc, ...).
* Some don't have working self-hosted linker support (nvptx).
* Some are using ABIs that haven't been standardized (loongarch32).

Finally, all non-x86 uefi targets are hopelessly broken and can't really be
fixed until we change our emit logic to lower *-uefi-* verbatim rather than to
*-windows-*. See: https://github.com/ziglang/zig/issues/21630
2024-11-28 22:04:00 +01:00
Alex Rønne Petersen
0bf054f4c5
test: Remove aarch64(_be)-linux-gnuilp32 from llvm_targets.
LLVM doesn't handle this target correctly (pointer size, etc).
2024-11-28 22:04:00 +01:00
Alex Rønne Petersen
abf3032ff1
test: Add m68k-linux-musl to llvm_targets. 2024-11-28 22:04:00 +01:00
Alex Rønne Petersen
322013c648
test: Add aarch64(_be)-linux-musl to llvm_targets. 2024-11-28 22:04:00 +01:00
Alex Rønne Petersen
11d51ea5a2
test: Remove aarch64-rtems-ilp32 from llvm_targets.
LLVM can't represent this target at the moment.
2024-11-28 22:04:00 +01:00
Alex Rønne Petersen
4369d3b93d
test: Add *-windows-cygnus triples to llvm_targets. 2024-11-28 22:04:00 +01:00
Alex Rønne Petersen
7361f0bafa
link.MachO: Don't try to get a semver value for bridgeos. 2024-11-28 22:04:00 +01:00
Alex Rønne Petersen
f0f2dc52cc
llvm: Lower ohoseabi to ohos instead of verbatim.
LLVM doesn't recognize ohoseabi.
2024-11-28 22:04:00 +01:00
Alex Rønne Petersen
7fe219998f
std.Target: Fix long double alignment for wasm(32,64)-emscripten-*. 2024-11-28 21:31:28 +01:00
Alex Rønne Petersen
6cd67cec67
std.Target: Fix long double size for aarch64-bridgeos-*. 2024-11-28 21:31:28 +01:00
Alex Rønne Petersen
310d1c1ff4
std.Target: Fix long/unsigned long size for aarch64-watchos-ilp32. 2024-11-28 21:31:28 +01:00
Alex Rønne Petersen
aea4f705dc
std.Target: Add missing C type info for aix, elfiamcu, hermit, hurd, rtems, and zos. 2024-11-28 21:31:28 +01:00
Alex Rønne Petersen
8594f179f9
Merge pull request #22067 from alexrp/pie-tests
Add PIC/PIE tests and fix some bugs + some improvements to the test harness
2024-11-28 14:07:28 +01:00
Alex Rønne Petersen
6cf01a679f std.Thread.Futex: Mark inline asm volatile in WasmImpl.
Closes #22082.
2024-11-27 23:24:37 +01:00
Justin Braben
d16a9b0acb
std.os.windows: Map PIPE_NOT_AVAILABLE from OpenFile() to error.NoDevice (#21938) 2024-11-27 22:33:29 +01:00
mlugg
1a99c99ee9 std.Build: gracefully handle child stdin closing when running tests
We have deduced that it seems the sporadic BrokenPipe failures happening
on the CI runners (e.g.
https://github.com/ziglang/zig/actions/runs/12035916948/job/33555963190)
are likely caused by the test runner's stdin pipe abnormally closing,
likely due to the process crashing. Here, we introduce error handling
for this case, so that if these writes fail, the step is marked as
failed correctly, and we still collect the child's stderr to report.
This won't fix the CI issues, but it should promote them to proper error
messages including child stderr, which -- at least in theory -- should
allow us to ultimately track down where the errors come from.

Note that this change is desirable regardless of bugs in the test runner
or similar, since the child process could terminate abnormally for any
number of reasons (e.g. a crashing test), and such cases should be
correctly reported by the build runner.
2024-11-27 19:35:31 +00:00
Andrew Kelley
3ce6de8765 revert langref section "common errdefer slip ups"
This does not belong in the language reference.

reverts 91a88a789ffa80ebb57c77ae0fe37594276e3707
2024-11-26 15:03:24 -08:00
Andrew Kelley
11bf2d92de diversify "unable to spawn" failure messages
to help understand where a spurious failure is occurring
2024-11-26 13:56:40 -08:00
Andrew Kelley
68b3f50866
Merge pull request #22070 from Rexicon226/fix-crc32
add `crc32` as a feature dep of `sse4.2` and refactor `update_cpu_feature.zig`
2024-11-26 16:29:51 -05:00
Alex Rønne Petersen
047311a76a std.math: Disable isSignalNan test on mips32.
https://github.com/ziglang/zig/issues/14366
2024-11-26 18:29:13 +01:00
Chris Boesch
87863a834b
std.math.complex: Add squared magnitude function (#21998) 2024-11-26 13:03:48 +00:00
Andrew Kelley
b0dcce93f7
Merge pull request #22075 from ziglang/fix-broken-pipe
std.io.Poller: handle EPIPE as EOF
2024-11-26 00:36:33 -05:00
David Rubin
a6af55cc6e ip: cleanup @constCast usages 2024-11-25 18:41:36 -05:00
Andrew Kelley
f6392b9526 cmake: don't add an unnecessary curses static lib dependency 2024-11-25 15:05:42 -08:00
Andrew Kelley
21f0fce28b CI: update macOS runner to 13
Apple has already dropped support for macOS 12.
GitHub Actions is dropping macOS 12 support now.
The Zig project is also dropping macOS 12 support now.

This commit also bumps default minimum macos version to 13.
2024-11-25 15:00:10 -08:00
Andrew Kelley
775b48dd10 std.io.Poller: handle EPIPE as EOF
closes #17483
2024-11-25 14:18:55 -08:00
Andrew Kelley
aa5341bf85 std.process.Child: explicit error set for wait 2024-11-25 14:18:55 -08:00
Andrew Kelley
f4e042a4c3
Merge pull request #21858 from francescoalemanno/patch-1
add improved std.hash.int - deprecate std.hash.uint32
2024-11-25 17:00:17 -05:00
David Rubin
f36f7d54a7
refactor update_cpu_features.zig
Most of this commit is whitespace changes, moving to use RLS
for assigning the `CpuModel`
2024-11-25 01:11:15 -08:00
David Rubin
9e17e097e5
make crc32 a featdep of sse4.2
To my knowledge there isn't an implementation of `sse4.2` that doesn't have `crc32`.
The Clang driver also sets `crc32` to be implicitly enabled when an explicit `-crc32`
wasn't provided. This matches that behaviour.

We need this behaviour to compile libraries like `rocksdb` which currently guard against
`crc32` intrinsics by checking for `sse4.2`.
2024-11-25 01:11:15 -08:00
David Rubin
bc3ed51b7f
cleanup update_cpu_feature.zig
* Cleanup the argument handling logic to allow for optional arguments.
* Add a filter for which `llvm_target` to process.
* Switch to using a threadpool, needed for skipping llvm targets cleanly
  and better distributes the work.
* Remove a seemingly useless piece of logic. I re-ran the script and it gave identical outputs.
2024-11-25 01:11:06 -08:00
Andrew Kelley
ca67f80b6e std.hash.int: avoid words like "easy" and "fast" in doc comments 2024-11-24 15:30:52 -08:00
Francesco Alemanno
ae6c24b490 std.hash.int: better handle odd bit sizes
Uses the non rational solution of a quadratic, I made it work up to 256
bits, added Mathematica code in case anyone wants to verify the magic
constant.

integers between sizes 3...15 were affected by fatal bias, it is best to
make them pass through the generic solution.

Thanks to RetroDev256 & Andrew feedback.
2024-11-24 15:29:20 -08:00
Andrew Kelley
d09fd249c0 std.hash.int: restore previous behavior
In the parent commit, I handled odd bit sizes by upcasting and
truncating. However it seems the else branch is intended to handle
those cases instead, so this commit reverts that behavior.
2024-11-24 15:27:03 -08:00
Andrew Kelley
5ad44c14b0 std.hash.int: use anytype instead of explicit type parameter
also
* allow signed ints, simply bitcast them to unsigned
* handle odd bit sizes by upcasting and then truncating
* naming conventions
* remove redundant code
* better use of testing API
2024-11-24 15:27:03 -08:00
Francesco Alemanno
aee6f7d7ee std.hash: improve simple hashing of unsigned integers
Before, the default bit mixer was very biased, and after a
lot of searching it turns out that selecting a better solution is hard.

I wrote a custom statistical analysis taylored for bit mixers in order
to select the best one at each size (u64/u32/u16), compared a lot of
mixers, and packaged the best ones in this commit.
2024-11-24 15:27:03 -08:00
Ilia Choly
e2f24a2d70 Allocator.free: document zero-length behavior
It wasn't immediately clear from the implementation whether passing
zero-length memory to free() was undefined behavior or intentionally
supported. Since ArrayList and other core data structures rely on
this behavior working correctly, this should be explicitly documented
as part of the public API contract.
2024-11-24 18:19:11 -05:00
Bruno Reis
c2db5d9cd1 treat errno(6) (NXIO) as expected error in openatZ 2024-11-24 18:17:56 -05:00
Andrew Barchuk
1f37b70344
Remove unused buf field from std.fmt.Parser (#21994)
And make the initialization less error prone by removing a default for
iter, which is required for a functional parser

std: Add a brief doc comment for `std.fmt.Parser`
2024-11-24 15:09:36 -08:00
Fri3dNstuff
b2030cb9ab
std.meta.eql: use == directly when comparing packed structs (#21982) 2024-11-24 14:29:44 -08:00
Jacob Young
c894ac09a3 dwarf: fix stepping through an inline loop containing one statement
Previously, stepping from the single statement within the loop would
always exit the loop because all of the code unrolled from the loop is
associated with the same line and treated by the debugger as one line.
2024-11-24 17:28:12 -05:00
Alex Rønne Petersen
5beb5f20d2
test: Set emit_bin=false for some safety tests.
This should hopefully be reverted soon with Andrew's work on the self-hosted
wasm linker.

error: thread 171731 panic: integer overflow
/home/alexrp/Source/ziglang/zig/src/link/Wasm.zig:2392:32: 0x22b709e in setupMemory (zig)
        break :index sym.index - wasm.imported_globals_count;
                               ^
/home/alexrp/Source/ziglang/zig/src/link/Wasm.zig:2678:25: 0x1ed1be6 in flushModule (zig)
    try wasm.setupMemory();
                        ^
/home/alexrp/Source/ziglang/zig/src/link/Wasm.zig:2619:28: 0x1c2e4d4 in flush (zig)
    return wasm.flushModule(arena, tid, prog_node);
                           ^
/home/alexrp/Source/ziglang/zig/src/link.zig:874:77: 0x1a55ad7 in flush (zig)
                return @as(*tag.Type(), @fieldParentPtr("base", base)).flush(arena, tid, prog_node);
                                                                            ^
/home/alexrp/Source/ziglang/zig/src/Compilation.zig:2411:17: 0x1a553f9 in flush (zig)
        lf.flush(arena, tid, prog_node) catch |err| switch (err) {
                ^
/home/alexrp/Source/ziglang/zig/src/Compilation.zig:2371:22: 0x1a58d60 in update (zig)
            try flush(comp, arena, .{
                     ^
/home/alexrp/Source/ziglang/zig/src/main.zig:4114:32: 0x1ae392b in serve (zig)
                try comp.update(main_progress_node);
                               ^
/home/alexrp/Source/ziglang/zig/src/main.zig:3555:22: 0x1b05322 in buildOutputType (zig)
            try serve(
                     ^
/home/alexrp/Source/ziglang/zig/src/main.zig:265:31: 0x195faca in mainArgs (zig)
        return buildOutputType(gpa, arena, args, .{ .build = .Obj });
                              ^
/home/alexrp/Source/ziglang/zig/src/main.zig:200:20: 0x195c995 in main (zig)
    return mainArgs(gpa, arena, args);
                   ^
/home/alexrp/Source/ziglang/zig/lib/std/start.zig:617:37: 0x195c49e in main (zig)
            const result = root.main() catch |err| {
                                    ^
2024-11-24 22:11:17 +01:00
Alex Rønne Petersen
1d1ca84854
test: Set emit_bin=false for spirv_mergable_pointers.zig.
/home/alexrp/.cache/zig/b/18236e302af25e3fb99bc6a232ddc447/builtin.zig:6:5: error: TODO (SPIR-V): Implement unsigned composite int type of 64 bits
pub const zig_backend = std.builtin.CompilerBackend.stage2_spirv64;
~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2024-11-24 22:11:17 +01:00
Alex Rønne Petersen
4b16d81318
test: Set emit_bin=false for all nvptx tests.
error: thread 165232 panic: TODO: rewrite the NvPtx.flushModule function
/home/alexrp/Source/ziglang/zig/src/link/NvPtx.zig:123:5: 0x1ed99ce in flushModule (zig)
    @panic("TODO: rewrite the NvPtx.flushModule function");
    ^
/home/alexrp/Source/ziglang/zig/src/link/NvPtx.zig:110:28: 0x1c2e7e6 in flush (zig)
    return self.flushModule(arena, tid, prog_node);
                           ^
/home/alexrp/Source/ziglang/zig/src/link.zig:874:77: 0x1a55bd3 in flush (zig)
                return @as(*tag.Type(), @fieldParentPtr("base", base)).flush(arena, tid, prog_node);
                                                                            ^
/home/alexrp/Source/ziglang/zig/src/Compilation.zig:2411:17: 0x1a553f9 in flush (zig)
        lf.flush(arena, tid, prog_node) catch |err| switch (err) {
                ^
/home/alexrp/Source/ziglang/zig/src/Compilation.zig:2348:22: 0x1a595ba in update (zig)
            try flush(comp, arena, .{
                     ^
/home/alexrp/Source/ziglang/zig/src/main.zig:4114:32: 0x1ae392b in serve (zig)
                try comp.update(main_progress_node);
                               ^
/home/alexrp/Source/ziglang/zig/src/main.zig:3555:22: 0x1b05322 in buildOutputType (zig)
            try serve(
                     ^
/home/alexrp/Source/ziglang/zig/src/main.zig:265:31: 0x195faca in mainArgs (zig)
        return buildOutputType(gpa, arena, args, .{ .build = .Obj });
                              ^
/home/alexrp/Source/ziglang/zig/src/main.zig:200:20: 0x195c995 in main (zig)
    return mainArgs(gpa, arena, args);
                   ^
/home/alexrp/Source/ziglang/zig/lib/std/start.zig:617:37: 0x195c49e in main (zig)
            const result = root.main() catch |err| {
                                    ^
2024-11-24 22:11:17 +01:00
Alex Rønne Petersen
2298108daf
test: Allow tests to set emit_bin=false. 2024-11-24 22:11:17 +01:00
Alex Rønne Petersen
c4cd3c0541
test: Force compile test cases to be codegen'd if requested. 2024-11-24 22:11:17 +01:00
Alex Rønne Petersen
ad2be71514
test: Add test cases for PIC/PIE on various supported platforms.
Closes #22052.
2024-11-24 22:11:17 +01:00
Alex Rønne Petersen
fefcdc5673
test: Allow setting PIC/PIE in test cases. 2024-11-24 22:11:17 +01:00
Alex Rønne Petersen
9d10246a80
test: Enable -Dtest-target-filter=... to work for test-debugger. 2024-11-24 22:11:17 +01:00
Alex Rønne Petersen
2a29381117
test: Enable -Dtest-target-filter=... to work for test-cases and test-translate-c. 2024-11-24 22:11:17 +01:00