Commit graph

33513 commits

Author SHA1 Message Date
Kevin Primm
19b43ee627 compiler: Fix -m<os>-version-min=... ordering 2025-04-27 19:28:48 +02:00
psbob
d92649da80
Update Windows ReadFile and WriteFile to recognise Access Denied error when a read or write is attempted on a disconnected virtual com port 2025-04-27 14:42:15 +00:00
Alex Rønne Petersen
711e055f18
test: Uncomment a bunch of targets in llvm_targets. 2025-04-27 14:09:32 +02:00
Alex Rønne Petersen
b31b309b53
test: Configure emit_asm/emit_bin correctly for some targets in llvm_targets. 2025-04-27 14:09:05 +02:00
Alex Rønne Petersen
5411358956
test: Allow cases to set emit_asm (defaults to false). 2025-04-27 14:09:05 +02:00
Alex Rønne Petersen
26bb429093
compiler: Reject using LLVM for csky and xtensa.
These backends are completely unusable at the moment; they can produce neither
assembly files nor object files. So give a nicer error when users try to use
them.
2025-04-27 14:09:05 +02:00
Alex Rønne Petersen
386b869ec4
compiler: Error if the user targets arc with -femit-bin.
LLVM can only produce assembly files for this target currently.
2025-04-27 14:09:05 +02:00
Alex Rønne Petersen
3e7708b02b
link.Elf: Skip invoking LLD for zig build-obj for unsupported targets.
LLD doesn't support these yet. Doing this hack will at least allow basic
experimentation for these targets.
2025-04-27 14:09:05 +02:00
Alex Rønne Petersen
b16c094926
Merge pull request #23691 from alexrp/llvm-targets-updates 2025-04-27 11:50:06 +02:00
Shun Sakai
5fc4448e45 chore(std.mem): Rename trimLeft and trimRight
Rename `trimLeft` to `trimStart`, and `trimRight` to `trimEnd`.
`trimLeft` and `trimRight` functions remain as deprecated aliases for
these new names.
2025-04-27 18:03:59 +09:00
mlugg
3783b1b23c std.Build.Cache: fix several bugs
Aside from adding comments to document the logic in `Cache.Manifest.hit`
better, this commit fixes two serious bugs.

The first, spotted by Andrew, is that when upgrading from a shared to an
exclusive lock on the manifest file, we do not seek it back to the
start. This is a simple fix.

The second is more subtle, and has to do with the computation of file
digests. Broadly speaking, the goal of the main loop in `hit` is to
iterate the files listed in the manifest file, and check if they've
changed, based on stat and a file hash. While doing this, the
`bin_digest` field of `std.Build.Cache.File`, which is initially
`undefined`, is populated for all files, either straight from the
manifest (if the stat matches) or recomputed from the file on-disk. This
file digest is then used to update `man.hash.hasher`, which is building
the final hash used as, for instance, the output directory name when the
compiler emits into the cache directory. When `hit` returns a cache
miss, it is expected that `man.hash.hasher` includes the digests of all
"initial files"; that is, those which have been already added with e.g.
`addFilePath`, but not those which will later be added with
`addFilePost` (even though the manifest file has told us about some such
files). Previously, `hit` was using the `unhit` function to do this in a
few cases. However, this is incorrect, because `hit` assumes that all
files already have their `bin_digest` field populated; this function is
only valid to call *after* `hit` returns. Instead, we need to actually
compute the hashes which haven't yet been populated. Even if this logic
has been working, there was still a bug here, because we called `unhit`
when upgrading from a shared to an exclusive lock, writing the
(potentially `undefined`) file digests, but the loop itself writes the
file digests *again*! All in all, the hashing logic here was actually
incredibly broken.

I've taken the opportunity to restructure this section of the code into
what I think is a more readable format. A new function,
`hitWithCurrentLock`, uses the open manifest file to try and find a
cache hit. It returns a tagged union which, in the miss case, tells the
caller (`hit`) how many files already have their hash populated. This
avoids redundant work recomputing the same hash multiple times in
situations where the lock needs upgrading. This also eliminates the
outer loop from `hit`, which was a little confusing because it iterated
no more than twice!

The bugs fixed here could manifest in several different ways depending
on how contended file locks were satisfied. Most notably, on a cache
miss, the Zig compiler might have written the compilation output to the
incorrect directory (because it incorrectly constructed a hash using
`undefined` or repeated file digests), resulting in all future hits on
this manifest causing `error.FileNotFound`. This is #23110. I have been
able to reproduce #23110 on `master`, and have not been able to after
this commit, so I am relatively sure this commit resolves that issue.

Resolves: #23110
2025-04-27 05:42:18 +01:00
Alex Rønne Petersen
2d44bc5d2b
test: Add powerpc(64)-aix to llvm_targets. 2025-04-27 03:54:32 +02:00
Alex Rønne Petersen
5502a820e8
llvm: Fix data layout string for s390x-zos. 2025-04-27 03:54:32 +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
b59f7f0726
test: Remove sparc(64)-illumos from llvm_targets.
Illumos dropped support for SPARC many years ago.
2025-04-27 02:53:46 +02:00
Alex Rønne Petersen
962b491745
test: Remove sparc-solaris and x86-solaris from llvm_targets.
These are no longer supported.
2025-04-27 02:53:45 +02:00
Alex Rønne Petersen
d9122e9f15
test: Remove some thumb(eb)-*-* targets from llvm_targets.
There is no evidence that these operating systems support pure Thumb, not even
just in userland.
2025-04-27 02:53:33 +02:00
Alex Rønne Petersen
c974590525
test: Remove mips(64)(el)-freebsd targets from llvm_targets.
These were dropped in FreeBSD 14 and we're not going to add e.g. libc support
for them anyway, so they're effectively dead to us.
2025-04-27 01:13:50 +02:00
Alex Rønne Petersen
5668c8b7ba std.Target: Bump minimum glibc to 2.34 for arches migrating to 64-bit time.
https://github.com/ziglang/zig/issues/21738#issuecomment-2822411842
2025-04-27 00:24:55 +02:00
Alex Rønne Petersen
b3537d0f4a compiler: Allow configuring UBSan mode at the module level.
* Accept -fsanitize-c=trap|full in addition to the existing form.
* Accept -f(no-)sanitize-trap=undefined in zig cc.
* Change type of std.Build.Module.sanitize_c to std.zig.SanitizeC.
* Add some missing Compilation.Config fields to the cache.

Closes #23216.
2025-04-26 22:54:34 +02:00
Alex Rønne Petersen
23440fbb99 std.Target: Remove Abi.gnuilp32.
* This has not seen meaningful development for about a decade.
* The Linux kernel port was never upstreamed.
* The glibc port was never upstreamed.
* GCC 15.1 recently deprecated support it.

It may still make sense to support an ILP32 ABI on AArch64 more broadly (which
we already have the Abi.ilp32 tag for), but, to the extent that it even existed
in any "official" sense, the *GNU* ILP32 ABI is certainly dead.
2025-04-26 22:12:31 +02:00
Alex Rønne Petersen
99a79f98ec
Merge pull request #23572 from alexrp/zig-cc-static-dynamic 2025-04-26 15:05:18 +02:00
Carter Snook
573d9aab5e std.c: use arch's ino_t and off_t for dirent
Fixes #23622. The integer types used for these fields before would not
work on some platforms.
2025-04-26 14:55:59 +02:00
tjog
2e35fdd032 fuzz: fix expected section start/end symbol name on MacOS when linking libfuzzer
Not only is the section name when adding the sancov variables different.

The linker symbol ending up in the binary is also different.

Reference: 60105ac6ba/llvm/lib/Transforms/Instrumentation/SanitizerCoverage.cpp (L1076-L1104)
2025-04-26 14:35:03 +02:00
Michael Pfaff
69007f0961 Calculate WTF-8 length before converting instead of converting into an intermediate buffer on the stack 2025-04-26 14:31:28 +02:00
dweiller
2e9c1553ef std: deprecate std.mem.copy{Forwards,Backwards} 2025-04-26 13:34:17 +10:00
dweiller
5cba7c8562 langref: document @memmove 2025-04-26 13:34:17 +10:00
dweiller
4e78836d29 test: add tests for @memmove 2025-04-26 13:34:17 +10:00
dweiller
898ca82458 compiler: add @memmove builtin 2025-04-26 13:34:16 +10:00
dweiller
b9f440620d test: add error return to memcpy_len_mismatch and memcpy_alias 2025-04-26 13:34:16 +10:00
Ryan Liptak
c06fecd466 FailingAllocator: remove outdated doc comments, move doc comment example to decltest
Note: The decltests for files-as-a-struct don't show up in autodoc currently
2025-04-23 19:28:28 -04:00
mlugg
927f233ff8 compiler: allow emitting tests to an object file
This is fairly straightforward; the actual compiler changes are limited
to the CLI, since `Compilation` already supports this combination.

A new `std.Build` API is introduced to allow representing this. By
passing the `emit_object` option to `std.Build.addTest`, you get a
`Step.Compile` which emits an object file; you can then use that as you
would any other object, such as either installing it for external use,
or linking it into another step.

A standalone test is added to cover the build system API. It builds a
test into an object, and links it into a final executable, which it then
runs.

Using this build system mechanism prevents the build system from
noticing that you're running a `zig test`, so the build runner and test
runner do not communicate over stdio. However, that's okay, because the
real-world use cases for this feature don't want to do that anyway!

Resolves: #23374
2025-04-22 22:50:36 +01:00
Matthew Lugg
6a7ca4b8b0
Merge pull request #23617 from mlugg/incr-fixes
incremental: fixes
2025-04-22 18:04:52 +01:00
Ali Cheraghi
ffd85ffcda revive nvptx linkage 2025-04-21 10:45:05 +02:00
Ali Cheraghi
13541bc1c0 Module: ignore xnack and sramecc features on some gpu models 2025-04-21 09:49:19 +02:00
mlugg
8c9c24e09b
compiler: integrate @compileLog with incremental compilation
Compile log output is now separated based on the `AnalUnit` which
perfomred the `@compileLog` call, so that we can omit the output for
unreferenced ("dead") units. The units are also sorted when collecting
the `ErrorBundle`, so that compile logs are always printed in a
consistent order, like compile errors are. This is important not only
for incremental compilation, but also for parallel analysis.

Resolves: #23609
2025-04-20 18:11:53 +01:00
mlugg
6561a98a61
incremental: correctly handle dead exporters
Resolves: #23604
2025-04-20 18:11:53 +01:00
Frank Denis
f01833e03e
crypto.ecdsa: add the ability to sign/verify prehashed messages (#23607) 2025-04-20 04:27:10 +02:00
Vadzim Dambrouski
86d3546184
Fix compile error in Fuzzer web-ui (#23605)
* Fix compile error in Fuzzer web-ui

The error was:
```
error: expected type '?mem.Alignment', found 'comptime_int'
```

* Apply suggestions from code review

`.of` call is shorter and clearer

Co-authored-by: Alex Rønne Petersen <alex@alexrp.com>

---------

Co-authored-by: Alex Rønne Petersen <alex@alexrp.com>
2025-04-19 23:10:51 +02:00
Alex Rønne Petersen
8f8f37fb0f test: Add powerpc-linux-gnueabi(hf) to the module test matrix.
Skips std tests for now: https://github.com/ziglang/zig/issues/2256
2025-04-17 17:32:33 +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
Tobias Simetsreiter
5be3c7874c
std.tar: pass entry kind to rootDir to avoid setting root_dir to file (#23456) 2025-04-16 19:17:25 +00:00
Alex Rønne Petersen
f2363623e1
cmake: Map MinSizeRel to ReleaseSmall. 2025-04-16 20:46:41 +02:00
Alex Rønne Petersen
1a2ceb36c8
Merge pull request #23573 from samy-00007/bigint-shift-fix
std.math.big.int: fix a bug in `llshl` and update test syntax
2025-04-16 18:28:25 +02:00
samy007
8ae9ac6df4 improve test syntax for better stack trace in case of failure 2025-04-16 11:10:22 +02:00
Andrew Kelley
3746b3d93c
Merge pull request #21741 from kj4tmp/langref-packed-structs
langref: improve packed struct memory layout description
2025-04-16 04:56:22 -04:00
Andrew Kelley
bd38c417fc langref: reword some packed struct text and example 2025-04-15 19:19:23 -07:00
kj4tmp@gmail.com
a8621731ec langref: packed struct documentation 2025-04-15 19:17:07 -07:00
phatchman
ae38fc6a50
Return FileNotFound when CreateProcessW is called with a missing path (#23567) 2025-04-15 21:39:44 +00:00