Commit Graph
61 Commits
Author SHA1 Message Date
Alex Rønne Petersen 964e93dc47 move wcslen from libzigc to compiler-rt
Similar to strlen, LLVM 23+ will sometimes emit libcalls to this function even
when libc isn't linked.
2026-10-07 00:30:52 +02:00
Alex Rønne Petersen 292edd2440 move std.os.linux.elf_aux_maybe to compiler_rt as __zig_elf_auxv
This gets rid of the super confusing and (as far as I can tell) incorrect
getauxval logic in std.os.linux, and clarifies exactly who owns this state.

The ABI that std now expects is:

    extern var __zig_elf_auxv: [*]std.elf.Auxv;

Users can technically override this weak symbol with a strong symbol if they
wish, although I see no particularly useful reason to do so.

It is now a compile error to use std.os.linux.getauxval if libc is linked,
whereas previously it would just give useless results in some cases. I consider
this to be strictly an improvement. Just use std.c.getauxval when linking libc,
which std already does correctly where it needs getauxval.

This code is expected to be further simplified once our baseline Linux version
allows implementing https://codeberg.org/ziglang/zig/issues/31290.

closes https://codeberg.org/ziglang/zig/issues/36203
2026-10-05 03:26:41 +02:00
Alex Rønne Petersen 5e754304de remove support for wasi-libc
closes https://github.com/ziglang/zig/issues/9342
closes https://github.com/ziglang/zig/issues/15005
closes https://github.com/ziglang/zig/issues/20747
closes https://github.com/ziglang/zig/issues/22570
closes https://codeberg.org/ziglang/zig/issues/30977
2026-10-04 18:23:18 +02:00
Alex Rønne Petersen 476efc5b70 remove internal and link_once global linkages
These have no clear use case, no coherent definition, and incomplete/broken
compiler and linker support.

If actually needed, they can be reintroduced if someone can present a reasonable
use case along with a plan for how they should be implemented consistently in
all backends and linkers.
2026-09-26 19:12:48 +02:00
Pavel Verigo 7def86c2f2 compiler-rt: add @disableIntrinsics to memset 2026-08-23 03:57:05 +02:00
Jacob Young a242b0be88 compiler_rt: change float abi so it can become compatible with cbe 2026-07-27 14:35:12 -04:00
rpkak 2c894ce206 compiler_rt: optimize memset 2026-07-21 09:38:18 +02:00
rpkak 0e61c9aba3 compiler_rt: fix arg type of memset and __memset_chk 2026-07-21 09:06:26 +02:00
rpkak 5eb216744a compiler_rt: remove __memset 2026-07-21 09:06:26 +02:00
ndjenksandndjenks 160e1b229b add the missing compiler_rt routines for sparc32 (#35835)
Fixes #31067

Co-authored-by: ndjenks <ndjenkoua@gmail.com>
Reviewed-on: https://codeberg.org/ziglang/zig/pulls/35835
Reviewed-by: Alex Rønne Petersen <alex@alexrp.com>
2026-07-07 00:34:25 +02:00
Alex Rønne Petersen 3d604248e6 compiler-rt: delete workarounds for __int128 ABI on x86_64-windows
LLVM requires frontends to lower i128 to <2 x i64> in IR to get the correct
__int128 ABI on x86_64-windows; this is what Clang does. I'm guessing our LLVM
backend didn't do this in the past, which made these hacks necessary. But it
does do so now, so just get rid of this stuff.
2026-06-19 04:25:42 +02:00
Linus Groh 991f56fd6b std.meta: Remove Int in favor of @Int 2026-05-03 21:42:06 +01:00
Alex Rønne Petersen 593f45ee02 llvm: switch most targets to using half and fp128 IR types
As of LLVM 22, most backends can (finally) handle legalization of these types as
necessary, so we don't need to do it ourselves anymore.

closes https://github.com/ziglang/zig/issues/23674
2026-04-25 21:54:47 +02:00
Pavel Verigo 557caecaaa stage2-wasm: start big int support 2026-04-02 15:48:43 +02:00
Andrew Kelley 80625990d5 std: different mechanism for disabling network dependency
On Windows, it is sometimes problematic to depend on ws2_32.dll. Before,
users of std.Io.Threaded would have to call ioBasic() rather than io()
in order to avoid unnecessary dependencies on ws2_32.dll. Now, the
application can disable networking with std.Options.

This change is necessary due to moving networking functionality to
be based on Io.Operation, which is a tagged union.
2026-03-08 19:20:34 -07:00
Andrew Kelley 74608293af compiler_rt: common -> compiler_rt
use the "symbol" helper function in all exports

move all declarations from common.zig to compiler_rt.zig

flatten the tree structure somewhat (move contents of tiny files into
parent files)

No functional changes.
2026-02-09 20:03:15 -08:00
Andrew Kelley 04c180c8e5 compiler_rt: partial cleanup
introduce `symbol` helper function and partially migrate to using it
2026-02-09 20:04:17 +01:00
David Rubin 938efe4aab compiler-rt: fix f80 ceil/floor optimization
Our implementation did the classic add-sub rounding trick `(y = x +/- C =+ C - x)`
with `C = 1 / eps(T) = 2^(mantissa - 1)`. This approach only works for values whose
magnitude is below the rounding capacity of the constant. For a 64-bit mantissa
(like f80 has), `C = 2^63` only rounds for `|x| < 2^63`. Before we allowed this to
be ran on `e < bias + 64` aka `|x| < 2^64`. And because it isn't large enough,
we lose a bit to rounding.

For reference, the musl implementation does the same thing, using `mantissa - 1`:
https://git.musl-libc.org/cgit/musl/tree/src/math/ceill.c#n18
where `LDBL_MANT_DIG` is 64 for `long double` on x86.

This commit also combines the floor and ceil implementations into one generic one.
2026-01-08 00:45:52 +01:00
Andrew Kelley b64491f2d6 compiler_rt: ensure no std.Io used when not testing 2026-01-04 00:27:08 -08:00
Matthew Lugg 20bd5e8018 compiler-rt: remove dead code
`__addosi4`, `__addodi4`, `__addoti4`, `__subosi4`, `__subodi4`, and
`__suboti4` were all functions which we invented for no apparent reason.
Neither LLVM, nor GCC, nor the Zig compiler use these functions. It
appears the functions were created in a kind of misunderstanding of an
old language proposal; see https://github.com/ziglang/zig/pull/10824.

There is no benefit to these functions existing; if a Zig compiler
backend needs this operation, it is trivial to implement, and *far*
simpler than calling a compiler-rt routine. Therefore, this commit
deletes them. A small amount of that code was used by other parts of
compiler-rt; the logic is trivial so has just been inlined where needed.
I also chose to quickly implement `__addvdi3` (a standard function)
because it is trivial and we already implement the `sub` parallel.
2025-11-12 16:00:16 +00:00
Alex Rønne Petersen e9ac2ce116 compiler-rt: move strlen from libzigc to here
LLVM 21 has started recognizing strlen-like idioms and optimizing them to strlen
calls, so we need this function provided in compiler-rt for libc-less
compilations.
2025-08-30 06:36:41 +02:00
Jacob Young 7894703ee7 aarch64: implement more optional/error union/union support 2025-07-26 21:39:50 -04:00
Jacob Young 5060ab99c9 aarch64: add new from scratch self-hosted backend 2025-07-22 19:43:47 -07:00
Alex Rønne Petersen 5f7780c533 compiler-rt: Export _fltused for UEFI.
Closes #24148.
2025-06-16 13:46:23 +02:00
Andrew Kelley 826e1c30ba Merge pull request #24013 from alexrp/test-matrix
More target coverage in the module test matrix
2025-06-03 17:05:15 -04:00
Hilger Baumstark 0386730777 compiler-rt: add __addvsi3, __subvsi3, __mulvsi3, and __subvdi3 2025-06-01 20:17:25 +02:00
Alex Rønne Petersen 358ee859ba compiler-rt: Fix some exports for *-windows-none. 2025-05-29 15:35:35 +02:00
Jacob Young 8c48376d64 x86_64: rewrite scalar and vector int @divTrunc 2025-02-15 03:45:21 -05:00
Jacob Young 4e4775d6bd x86_64: implement conversions between scalar floats and ints
Closes #22797
2025-02-09 00:42:55 -08:00
dweiller bf89482f23 compiler-rt: move memmove back to memmove.zig 2025-01-20 17:16:24 +11:00
David Rubin f278038923 replace compiler_rt memcpy with a better version 2025-01-17 12:34:15 -08:00
Brian CainandAlex Rønne Petersen 4aa6246345 compiler_rt: Add hexagon builtins (#22029)
Signed-off-by: Brian Cain <bcain@quicinc.com>
Signed-off-by: Brian Cain <brian.cain@oss.qualcomm.com>
Co-authored-by: Alex Rønne Petersen <alex@alexrp.com>
2024-11-24 01:17:21 +00:00
Andrew Kelley 1c45903274 handle _fltused in compiler_rt
so we don't have to do an entire compilation unit for just this silly
symbol
2024-10-23 16:27:39 -07:00
Pavel Verigo 17f14e1d65 stage2-wasm: bit_reverse 2024-06-16 11:53:33 +02:00
Andrew Kelley 53f74d6a04 move libssp into libcompiler_rt
closes #7265
2023-11-10 13:12:10 -07:00
Eric Joldasov 50339f595a all: zig fmt and rename "@XToY" to "@YFromX"
Signed-off-by: Eric Joldasov <bratishkaerik@getgoogleoff.me>
2023-06-19 12:34:42 -07:00
matu3ba 97b9facb98 compiler_rt: declutter int.zig, add mulXi3 tests (#14623)
- Combine mulXi3 routines for follow-up cleanup.
- DRY up Dwords and Twords
- rename both to HalveInt and use instance
  * Justification: Not all processors have word size 32 bit.
* remove test file from CMakeLists
* DRY things.
2023-02-24 13:27:02 -05:00
Jan Philipp Hafer 476bdc8b0b compiler_rt: restructure compiler_rt.zig according to README.md
Justifications
- compiler_rt base routines are almost finished, so make 1:1
mapping of code and documentation.
- Make adjustments to code + documentation simpler to prevent technical or
  documentation debt.
2023-02-19 14:00:55 -05:00
Jan Philipp Hafer e10c0eefde compiler_rt: add __powihf2, __powisf2, __powidf2, __powitf2, __powixf2
Implementation and tests ported from LLVM release 80.
Tests of __powihf2 created from __powisf2 tests with minor adjustments.
2023-02-12 00:10:27 +02:00
Frank Denis 8d66aacb64 compiler-rt: implement __udivei4 and __umodei4 (#14023)
Allows dividing and formatting arbitrary-large unsigned integers.
2022-12-22 16:29:19 -05:00
Jacob Young 2a3d9c321e compiler_rt: remove stack probe functions from c builds 2022-12-06 12:27:28 -07:00
Andrew Kelley 39fd77bc16 interpret the WASI blob to produce zig2.c and compiler_rt.c
* synchronize zig1.c from zig-wasi external project
 * change the way argv works to avoid absolute paths
 * autodetect isatty
 * compiler_rt: disable some functions when object format is C
 * add missing flag from config.zig.in

The next problem is that compiling compiler_rt.c with gcc gives
"conflicting types" errors for `__eqhf2` and friends.
2022-12-06 12:15:04 -07:00
Andrew Kelley 545c3117ff rename lse_atomics.zig to aarch64_outline_atomics.zig 2022-11-21 17:17:02 -07:00
Andrew Kelley 95ee8ab77d simplify outline atomics
* Rely on libSystem when targeting macOS.
 * Make tools/gen_outline_atomics.zig more idiomatic.
 * Remove the CPU detection / auxval checking from compiler_rt. This
   functionality belongs in a different component. Zig's compiler_rt
   must not rely on constructors. Instead it will export a symbol for
   setting the value, and start code can detect and activate it.
 * Remove the separate logic for inline assembly when the target does or
   does not have lse support. `.inst` works in both cases.
2022-11-21 17:17:02 -07:00
Devin Singh a8f2d00ec4 compiler_rt: add outlined lse atomics for aarch64 2022-11-21 17:17:02 -07:00
Luuk de Gram cdf7e7dba9 fix: correctly import memcmp.zig in compiler-rt
cmp.zig was accidently being referenced twice, rather than importing
memcmp.zig. This means that its symbols were also not included in
the generated compiler-rt output.
2022-10-22 16:56:33 +02:00
Andrew Kelley ce3ffa5e1b Merge pull request #11747 from Luukdegram/compiler-rt
compiler_rt: Move mem implementations from c.zig
2022-10-17 18:12:22 -04:00
Luuk de Gram f5edaa96dd compiler_rt: Move mem implementations from c.zig
This moves functions that LLVM generates calls to,
to the compiler_rt implementation itself, rather than c.zig.
This is a prerequisite for native backends to link with compiler-rt.
This also allows native backends to generate calls to `memcpy` and the like.
2022-10-15 07:02:38 -07:00
Cody Tapscott 0d533433e2 compiler_rt: Add missing f16 functions
This change also exposes some of the existing functions under both the
PPC-style names symbols and the compiler-rt-style names, since Zig
currently lowers softfloat calls to the latter.
2022-10-13 12:53:20 -07:00
Cody Tapscott 05915b85dd compiler-rt: Implement mulXc3 and divXc3 functions
These are the standard complex multiplication/division functions
required by the C standard (Annex G).

Don't get me started on the standard's handling of complex-infinity...
2022-10-09 11:09:41 -07:00