aboutsummaryrefslogtreecommitdiff
path: root/src
AgeCommit message (Collapse)Author
2025-04-28spirv: allow `offset_and_cast` for vectors when possibleAli Cheraghi
2025-04-27C backend: less branchingAndrew Kelley
2025-04-27make `@memcpy` and `@memmove` share panic handlersAndrew Kelley
2025-04-28Merge pull request #23698 from alexrp/goff-xcoff-stubsAlex Rønne Petersen
`link`: Stub out GOFF/XCOFF linker code based on LLVM
2025-04-28Sema: fix memcpy with C pointersxdBronch
2025-04-28cbe: aggregate assignment does not need a second castmlugg
`writeCValue` already emits a cast; including another here is, in fact, invalid, and emits errors under MSVC. Probably this code was originally added to work around the incorrect `.Initializer` location which was fixed in the previous commit.
2025-04-28Merge pull request #23663 from alexrp/emit-asm-onlyAlex Rønne Petersen
2025-04-28cbe: assignment is not initializationJacob Young
Turns out the backend currently never emits a non-static initializer, but the handling is kept in case it is needed again in the future.
2025-04-28Sema: fix alignment of runtime field pointer of underaligned tuplemlugg
2025-04-28Sema: fix pointers to comptime fields of comptime-known aggregate pointersmlugg
Resolves: #23190
2025-04-27Sema: Fix some ptr alignment checks to handle a potential ISA tag bit.Alex Rønne Petersen
Closes #23570.
2025-04-28std.Target: Remove Os.Tag.elfiamcu.Alex Rønne Petersen
The last Intel Quark MCU was released in 2015. Quark was announced to be EOL in 2019, and stopped shipping entirely in 2022. The OS tag was only meaningful for Intel's weird fork of Linux 3.8.7 with a special ABI that differs from the regular i386 System V ABI; beyond that, the CPU itself is just a plain old P54C (i586). We of course keep support for the CPU itself, just not Intel's Linux fork.
2025-04-27Merge pull request #22605 from dweiller/memmoveAndrew Kelley
add `@memmove` builtin
2025-04-27compiler: Fix `-m<os>-version-min=...` orderingKevin Primm
2025-04-27compiler: Reject using LLVM for csky and xtensa.Alex Rønne Petersen
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-27compiler: Error if the user targets arc with -femit-bin.Alex Rønne Petersen
LLVM can only produce assembly files for this target currently.
2025-04-27link.Elf: Skip invoking LLD for `zig build-obj` for unsupported targets.Alex Rønne Petersen
LLD doesn't support these yet. Doing this hack will at least allow basic experimentation for these targets.
2025-04-27chore(std.mem): Rename `trimLeft` and `trimRight`Shun Sakai
Rename `trimLeft` to `trimStart`, and `trimRight` to `trimEnd`. `trimLeft` and `trimRight` functions remain as deprecated aliases for these new names.
2025-04-27std.Build.Cache: fix several bugsmlugg
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-27llvm: Fix data layout string for s390x-zos.Alex Rønne Petersen
2025-04-27link: Stub out GOFF/XCOFF linker code based on LLVM.Alex Rønne Petersen
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-26compiler: Allow configuring UBSan mode at the module level.Alex Rønne Petersen
* 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-26std.Target: Remove Abi.gnuilp32.Alex Rønne Petersen
* 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-26Merge pull request #23572 from alexrp/zig-cc-static-dynamicAlex Rønne Petersen
2025-04-26compiler: add @memmove builtindweiller
2025-04-22compiler: allow emitting tests to an object filemlugg
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-22Merge pull request #23617 from mlugg/incr-fixesMatthew Lugg
incremental: fixes
2025-04-21revive nvptx linkageAli Cheraghi
2025-04-21Module: ignore `xnack` and `sramecc` features on some gpu modelsAli Cheraghi
2025-04-20compiler: integrate `@compileLog` with incremental compilationmlugg
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-20incremental: correctly handle dead exportersmlugg
Resolves: #23604
2025-04-14zig cc: Respect Clang's -static and -dynamic flags.Alex Rønne Petersen
Before: ❯ zig cc main.c -target x86_64-linux-musl && musl-ldd ./a.out musl-ldd: ./a.out: Not a valid dynamic program ❯ zig cc main.c -target x86_64-linux-musl -static && musl-ldd ./a.out musl-ldd: ./a.out: Not a valid dynamic program ❯ zig cc main.c -target x86_64-linux-musl -dynamic && musl-ldd ./a.out musl-ldd: ./a.out: Not a valid dynamic program After: ❯ zig cc main.c -target x86_64-linux-musl && musl-ldd ./a.out musl-ldd: ./a.out: Not a valid dynamic program ❯ zig cc main.c -target x86_64-linux-musl -static && musl-ldd ./a.out musl-ldd: ./a.out: Not a valid dynamic program ❯ zig cc main.c -target x86_64-linux-musl -dynamic && musl-ldd ./a.out /lib/ld-musl-x86_64.so.1 (0x72c10019e000) libc.so => /lib/ld-musl-x86_64.so.1 (0x72c10019e000) Closes #11909.
2025-04-14compiler: MinGW-w64 import libs should not count towards any_dyn_libs.Alex Rønne Petersen
They are, themselves, static libraries even if the resulting artifact strictly speaking requires dynamic linking to the corresponding system DLLs to run. Note, though, that there's no libc-provided dynamic linker on Windows like on POSIX, so this isn't particularly problematic. This matches x86_64-w64-mingw32-gcc behavior.
2025-04-13std: eradicate u29 and embrace std.mem.AlignmentAndrew Kelley
2025-04-13link: Improve handling of --build-id when using LLD.Alex Rønne Petersen
2025-04-12src/libunwind.zig: Fix symbol visibility macro defineLuis Cáceres
The define was changed in commit 729899f7b6bf6aff65988d895d7a639391a67608 in upstream llvm.
2025-04-12Merge pull request #23529 from alexrp/2879-groundworkAlex Rønne Petersen
Introduce libzigc for libc function implementations in Zig
2025-04-11Merge pull request #22516 from Jan200101/PR/build_id_optionAndrew Kelley
std.Build: add build-id option
2025-04-11Merge pull request #23061 from pavelverigo/stage2-wasm-miscAndrew Kelley
stage2-wasm: multiple fixes
2025-04-11Value: ensure that extern structs have their layout resolved in ptrFieldkcbanner
2025-04-11Introduce libzigc for libc function implementations in Zig.Alex Rønne Petersen
This lays the groundwork for #2879. This library will be built and linked when a static libc is going to be linked into the compilation. Currently, that means musl, wasi-libc, and MinGW-w64. As a demonstration, this commit removes the musl C code for a few string functions and implements them in libzigc. This means that those libzigc functions are now load-bearing for musl and wasi-libc. Note that if a function has an implementation in compiler-rt already, libzigc should not implement it. Instead, as we recently did for memcpy/memmove, we should delete the libc copy and rely on the compiler-rt implementation. I repurposed the existing "universal libc" code to do this. That code hadn't seen development beyond basic string functions in years, and was only usable-ish on freestanding. I think that if we want to seriously pursue the idea of Zig providing a freestanding libc, we should do so only after defining clear goals (and non-goals) for it. See also #22240 for a similar case.
2025-04-11x86_64: pass exact integer bit sizes to compiler-rt routinesJacob Young
This was a hack around compiler-rt not computing the correct size.
2025-04-11compiler: Move int size/alignment functions to std.Target and std.zig.target.Alex Rønne Petersen
This allows using them in e.g. compiler-rt.
2025-04-11std.Target: Rename charSignedness() to cCharSignedness().Alex Rønne Petersen
To be consistent with the other functions that answer C ABI questions.
2025-04-11Merge pull request #23355 from jacobly0/x86_64-rewriteJacob Young
x86_64: start rewriting overflow operations
2025-04-11compiler: Add hexagon-linux-musl support.Alex Rønne Petersen
Closes #21588.
2025-04-11tsan: Rename lib/tsan to lib/libtsan.Alex Rønne Petersen
For consistency with other vendored C/C++ libraries.
2025-04-10Compilation: Pass `-m<os>-version-min=...` to Clang for all applicable ↵Alex Rønne Petersen
Darwin targets.
2025-04-10x86_64: fix `error_set_has_value` of inferred error setsJacob Young
2025-04-10AstGen: redistribute inline asm limitsJacob Young