16860 Commits

Author SHA1 Message Date
Andrew Kelley
4e700fdf8e
Merge pull request #22516 from Jan200101/PR/build_id_option
std.Build: add build-id option
2025-04-11 16:37:46 -04:00
Andrew Kelley
65bd8d52c8
Merge pull request #23061 from pavelverigo/stage2-wasm-misc
stage2-wasm: multiple fixes
2025-04-11 15:56:35 -04:00
kcbanner
fa59153896 Value: ensure that extern structs have their layout resolved in ptrField 2025-04-11 15:30:20 -04:00
Alex Rønne Petersen
1f896c1bf8
Introduce libzigc for libc function implementations in Zig.
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-11 17:12:31 +02:00
Jacob Young
27cfff8f44 x86_64: pass exact integer bit sizes to compiler-rt routines
This was a hack around compiler-rt not computing the correct size.
2025-04-11 07:06:01 -04:00
Alex Rønne Petersen
ed9aa8f259 compiler: Move int size/alignment functions to std.Target and std.zig.target.
This allows using them in e.g. compiler-rt.
2025-04-11 05:22:00 -04:00
Alex Rønne Petersen
0132be7bf3 std.Target: Rename charSignedness() to cCharSignedness().
To be consistent with the other functions that answer C ABI questions.
2025-04-11 05:22:00 -04:00
Jacob Young
c82e1fe880
Merge pull request #23355 from jacobly0/x86_64-rewrite
x86_64: start rewriting overflow operations
2025-04-11 05:21:44 -04:00
Alex Rønne Petersen
0a5c088ecc
compiler: Add hexagon-linux-musl support.
Closes #21588.
2025-04-11 02:28:35 +02:00
Alex Rønne Petersen
ee0ff134e9
tsan: Rename lib/tsan to lib/libtsan.
For consistency with other vendored C/C++ libraries.
2025-04-11 02:08:18 +02:00
Alex Rønne Petersen
a9ff2d56ce Compilation: Pass -m<os>-version-min=... to Clang for all applicable Darwin targets. 2025-04-10 22:11:13 +02:00
Jacob Young
73498737a2 x86_64: fix error_set_has_value of inferred error sets 2025-04-10 06:04:09 -04:00
Jacob Young
06eebafadd AstGen: redistribute inline asm limits 2025-04-10 06:04:09 -04:00
Jacob Young
7a2963efab x86_64: add avx512 registers 2025-04-10 02:04:52 -04:00
Jacob Young
bbf8abf5d3 x86_64: support rip-relative addressing to labels in inline asm 2025-04-10 02:04:52 -04:00
Jacob Young
f4a31bed98 x86_64: remove broken const value tracking 2025-04-10 02:04:52 -04:00
Jacob Young
1eb5d70d12 x86_64: fix switch on big ints 2025-04-09 20:14:12 -04:00
Jacob Young
bc10131db1 x86_64: rewrite scalar @mulWithOverflow
Closes #19607
2025-04-09 20:14:12 -04:00
Jacob Young
55ce756868 x86_64: rewrite scalar @subWithOverflow 2025-04-09 20:14:12 -04:00
Jacob Young
80068b6e59 x86_64: rewrite scalar @addWithOverflow 2025-04-09 20:14:12 -04:00
Alex Rønne Petersen
ddcf6fcdf3 compiler: Allow using LLVM's SPIR-V backend. 2025-04-09 19:32:57 +02:00
Mun Maks
4fc783670a Sema/arith.zig: Fixing more typos from #23177.
This is a complementary PR to #23487 (I had only found one typo before).

Now I've looked at the whole `arith.zig` file, trying to find other potential problems.

Discussion about these changes:
https://github.com/ziglang/zig/pull/23177#discussion_r1997957095
2025-04-09 12:53:11 +01:00
Alex Rønne Petersen
79a620d617 zig_clang: Fix ZigClangAPValue being underaligned vs clang::APValue.
Also add a static_assert to catch future alignment mismatches on this type, and
reflect recent layout changes in the Zig bindings.
2025-04-09 11:53:24 +02:00
Techatrix
3830fc041b Compilation: Fix logic in addCCArgs() for various file types and flags.
Co-authored-by: Alex Rønne Petersen <alex@alexrp.com>
2025-04-09 10:12:42 +02:00
imreallybadatnames™️
7733b5dbe6
Merge pull request #23501 from imreallybadatnames/master
Step.Compile: use LtoMode enum for lto option
2025-04-09 05:16:36 +00:00
SuperAuguste
227788e6d5 Fix mach-o naming for sancov sections 2025-04-09 04:48:39 +02:00
Matthew Roush
fb1d4990cb
Make translate-c more robust in handling macro functions.
Translate-c didn't properly account for C macro functions having parameter names that are C keywords. So something like `#define FOO(float) ((float) + 10)` would've been interpreted as casting `+10` to a `float` type, instead of adding `10` to the parameter `float`.

An example of a real-world macro function like this is SDL3's `SDL_DEFINE_AUDIO_FORMAT` from `SDL_audio.h`, which uses `signed` as a parameter.
2025-04-07 20:53:38 +00:00
Alex Rønne Petersen
f2f36c49c8 compiler: Switch default code model for loongarch64 to medium.
LLVM 21 will change the default, but we're making the change now to make
building Zig for loongarch64 less painful.

https://github.com/llvm/llvm-project/pull/132173
2025-04-07 21:36:56 +02:00
Maksat
4995509028 #23177, maintainter 'mlugg' wanted to fix that typo, 4 weeks without changes, might be forgotten 2025-04-07 16:50:28 +01:00
Alex Rønne Petersen
f13292abbc zig_clang: Fix size of ZigClangAPValue for Clang 20.
Fixes failing tarball builds for x86-linux and x86-windows.

The MSVC special case here is very sus, but that's a problem for another day.
2025-04-07 17:41:06 +02:00
SuperAuguste
36b9e56753 Remove overzealous LLVM anti-instrumentation attributes 2025-04-07 07:53:42 +02:00
Jacob Young
470e2b63d9 Dwarf: handle undefined type values
Closes #23461
2025-04-05 21:42:33 -04:00
Jacob Young
9827ffe1de x86_64: fix incorrect handling of unreusable operands
Closes #23448
2025-04-05 20:49:56 -04:00
Jan200101
1a5dcff8e4
std.Build: update build-id flag description
it now denotes:
- all supported styles
- what a given style outputs
- what formats a given style supports
2025-04-05 22:11:07 +02:00
Andrew Kelley
0cd31fc7ff
Merge pull request #22780 from ziglang/llvm20
LLVM 20
2025-04-05 01:46:13 -04:00
Andrew Kelley
810f70ef42 update compiler usage of DoublyLinkedList API 2025-04-03 22:58:52 -07:00
Alex Rønne Petersen
c3e88a21fb
compiler: Recognize -fno-sanitize=<...> in addition to -fsanitize=<...>. 2025-04-04 06:08:10 +02:00
Alex Rønne Petersen
15a05fc324
Revert "compiler: Don't consider powerpc to have red zone support yet."
This reverts commit 4fad60fd3a70d0b059ce92ce825faabc1d2ac2e8.

Closes #23056.
2025-04-04 06:08:10 +02:00
Alex Rønne Petersen
9e4199d629
Compilation: Remove the PowerPC soft float preprocessor workaround.
Closes #21411.
2025-04-04 06:08:10 +02:00
Alex Rønne Petersen
28469636ba
zig cc: Avoid passing any "CPU" features related to float ABI to Clang. 2025-04-04 06:08:10 +02:00
Alex Rønne Petersen
0d6f3aa6c1
llvm: Remove workaround for zero-length memset/memcpy on wasm.
Closes #16360.
2025-04-04 06:08:10 +02:00
Alex Rønne Petersen
7109e462b7
llvm: Use muslabin32/muslabi64 environments in the target triple.
Closes #2909.
2025-04-04 06:08:10 +02:00
Alex Rønne Petersen
9a59cff27f
llvm: Allow FastISel on mips again.
Closes #21215.
2025-04-04 06:08:10 +02:00
Alex Rønne Petersen
166766d63d
llvm: never_tail implies never_inline, so set noinline in this case too. 2025-04-04 06:08:10 +02:00
Alex Rønne Petersen
7415739e36
Sema: Prevent tail calls of std.builtin.returnError().
LLVM 20 started tail-calling it in some of our test cases, resulting in:

    error: AndMyCarIsOutOfGas
    /home/alexrp/Source/ziglang/zig-llvm20/repro.zig:2:5: 0x103ef9d in main (repro)
        return error.TheSkyIsFalling;
        ^
    /home/alexrp/Source/ziglang/zig-llvm20/repro.zig:6:5: 0x103efa5 in main (repro)
        return error.AndMyCarIsOutOfGas;
        ^
    /home/alexrp/Source/ziglang/zig-llvm20/lib/std/start.zig:656:37: 0x103ee83 in posixCallMainAndExit (repro)
                const result = root.main() catch |err| {
                                        ^

instead of the expected:

    error: AndMyCarIsOutOfGas
    /home/alexrp/Source/ziglang/zig-llvm20/repro.zig:2:5: 0x103f00d in main (repro)
        return error.TheSkyIsFalling;
        ^
    /home/alexrp/Source/ziglang/zig-llvm20/repro.zig:6:5: 0x103f015 in main (repro)
        return error.AndMyCarIsOutOfGas;
        ^
    /home/alexrp/Source/ziglang/zig-llvm20/repro.zig:11:9: 0x103f01d in main (repro)
            try bar();
            ^
2025-04-04 06:08:10 +02:00
Alex Rønne Petersen
858305385d
llvm: Update the list of targets that use native f16/f128.
Closes #22003.
Closes #22013.
2025-04-04 06:08:10 +02:00
Alex Rønne Petersen
cf9c6f5298
compiler: Update max int alignments for some targets. 2025-04-04 06:08:10 +02:00
Alex Rønne Petersen
4c5c5bcd91
llvm: Fix i128 alignment for various targets.
This ABI bug was fixed in LLVM 20.
2025-04-04 06:08:10 +02:00
Alex Rønne Petersen
3d1cfdb365
llvm: Set target-abi module flag.
LLVM is increasingly making use of this module flag when present.
2025-04-04 06:08:09 +02:00
Alex Rønne Petersen
e99c11856d
libtsan: Update to LLVM 20. 2025-04-04 06:08:09 +02:00