32426 Commits

Author SHA1 Message Date
Andrew Kelley
8fa47bb904
Merge pull request #22230 from alexrp/lto-stuff
Disable LTO by default + some LTO fixes
2025-01-25 13:17:25 -08:00
Alex Rønne Petersen
015a5e1982 std.Build: Make ofmt part of standardTargetOptions(). 2025-01-25 20:39:10 +01:00
Andrew Kelley
d0d5ca2b6c
Merge pull request #22581 from jacobly0/x86_64-rewrite
x86_64: rewrite `@abs` on floats
2025-01-25 07:30:45 -08:00
Alex Rønne Petersen
b60e39fe8f
Compilation: Disable LTO by default.
LLD has too many LTO bugs, and we're dropping the LLD dependency soon anyway.
2025-01-25 14:59:02 +01:00
Alex Rønne Petersen
9f116d38b8
libtsan: Build with unwind tables like upstream. 2025-01-25 14:58:55 +01:00
Alex Rønne Petersen
46a1a15861
Compilation: Remove the _tls_index hack for MinGW.
No longer needed since we disable LTO for mingw32.
2025-01-25 14:58:44 +01:00
Alex Rønne Petersen
1e8b82f6b4
compiler: Rework LTO settings for some Zig-provided libraries.
* compiler-rt and mingw32 have both run into LLD bugs, and LLVM disables LTO for
  its compiler-rt, so disable LTO for these.
* While we haven't run into any bugs in it, LLVM disables LTO for its libtsan,
  so follow suit just to be safe.
* Allow LTO for libfuzzer as LLVM does.
2025-01-25 14:57:33 +01:00
Alex Rønne Petersen
afe2fed34d
link: Set machine and float ABI when invoking ld.lld and lld-link.
If this isn't done, LTO can completely miscompile the input bitcode modules for
certain targets where we need to explicitly set these ABIs (because LLVM's
defaults are bad).
2025-01-25 14:57:33 +01:00
Alex Rønne Petersen
cd8c92fc40
compiler: Explicitly specify ABI for arm, mips, and powerpc when talking to LLVM.
See 652c5151429e279f70396ee601416c87a70c1bec. Better to avoid relying on default
LLVM behavior going forward.
2025-01-25 14:56:59 +01:00
Alex Rønne Petersen
b95081209a
compiler: Explicitly specify loongarch ABI when talking to LLVM.
Necessary because of: dc665fa5f5
2025-01-25 14:56:59 +01:00
Alex Rønne Petersen
673544b783
compiler-rt: Pass called functions into inline asm so the compiler sees the usage. 2025-01-25 14:54:02 +01:00
Alex Rønne Petersen
35da1e1e8f
compiler-rt: Don't export __a(u)ll(div,rem) if linking libc.
libc provides these when targeting MSVC.
2025-01-25 13:49:21 +01:00
Alex Rønne Petersen
05a877a9a1
compiler-rt: More accurately export Windows Arm functions. 2025-01-25 13:49:21 +01:00
Matthew Lugg
8ba3812eee
Merge pull request #22594 from mlugg/panic-stuff
compiler: yet more panic handler changes
2025-01-25 04:10:55 +00:00
Jacob Young
c7433212d1 x86_64: rewrite scalar and vector int @min and @max 2025-01-24 21:02:32 -05:00
Jacob Young
7701cfa032 x86_64: mitigate miscomp during switch dispatch 2025-01-24 20:56:11 -05:00
Jacob Young
ba82d6e83e x86_64: fix typo and lower optimized insts 2025-01-24 20:56:11 -05:00
Jacob Young
b1fa89439a x86_64: rewrite float vector @abs and equality comparisons 2025-01-24 20:56:11 -05:00
Jacob Young
ae3d95fc8d x86_64: rewrite scalar float equality comparisons 2025-01-24 20:56:11 -05:00
Andrew Kelley
921725427e
Merge pull request #22596 from ziglang/pipeline
Compilation pipeline: repeat failed prelink tasks
2025-01-24 19:52:09 -05:00
mlugg
b6726913d3
Zcu: remove null_stack_trace
The new simplifications to the panic handler have eliminated the need
for this piece of memoized state.
2025-01-24 22:33:23 +00:00
mlugg
3232e59ab9
std: remove old declarations now a zig1 update has happened 2025-01-24 22:33:23 +00:00
mlugg
38b47034f7
compiler_rt: upgrade to new panic interface 2025-01-24 22:33:23 +00:00
mlugg
5a6666db55
all: update for panic.unwrapError and panic.call signature changes 2025-01-24 22:33:23 +00:00
mlugg
dd334d5ee5
stage1: update zig1.wasm
Oh dear, not again! Sorry, I changed the panic handler...

Signed-off-by: mlugg <mlugg@mlugg.co.uk>
2025-01-24 21:07:14 +00:00
mlugg
b0a8931690
Sema: prepare to remove ?*StackTrace argument from unwrapError and call
Now that we propagate the error return trace to all `callconv(.auto)`
functions, passing it explicitly to panic handlers is redundant.
2025-01-24 20:50:20 +00:00
Andrew Kelley
3e174ee1ac frontend: fix data race with mingw crt files 2025-01-24 12:22:00 -08:00
Andrew Kelley
d3f4e9d4ac Compilation pipeline: repeat failed prelink tasks
and remove faulty assertion. When a prelink task fails, the
completed_prelink_tasks counter will not decrement.

A future improvement will be needed to make the pipeline fully robust
and handle failed prelink tasks, followed by updates in which those
tasks succeed, and compilation proceeds like normal.

Currently if a prelink task fails, the Compilation will be left in a
state unrecoverable by an incremental update.
2025-01-24 12:22:00 -08:00
mlugg
83991efe10
compiler: yet more panic handler changes
* `std.builtin.Panic` -> `std.builtin.panic`, because it is a namespace.
* `root.Panic` -> `root.panic` for the same reason. There are type
  checks so that we still allow the legacy `pub fn panic` strategy in
  the 0.14.0 release.
* `std.debug.SimplePanic` -> `std.debug.simple_panic`, same reason.
* `std.debug.NoPanic` -> `std.debug.no_panic`, same reason.
* `std.debug.FormattedPanic` is now a function `std.debug.FullPanic`
  which takes as input a `panicFn` and returns a namespace with all the
  panic functions. This handles the incredibly common case of just
  wanting to override how the message is printed, whilst keeping nice
  formatted panics.
* Remove `std.builtin.panic.messages`; now, every safety panic has its
  own function. This reduces binary bloat, as calls to these functions
  no longer need to prepare any arguments (aside from the error return
  trace).
* Remove some legacy declarations, since a zig1.wasm update has
  happened. Most of these were related to the panic handler, but a quick
  grep for "zig1" brought up a couple more results too.

Also, add some missing type checks to Sema.

Resolves: #22584

formatted -> full
2025-01-24 19:29:51 +00:00
Alex Rønne Petersen
b3d9b0e3f6 musl: Manually inline __tls_get_addr into s390x __tls_get_offset.
See these mailing list threads:

* https://www.openwall.com/lists/musl/2024/11/23/3
* https://www.openwall.com/lists/musl/2025/01/24/1

This supplants cc73d7ad749df8d53da442faa2e7af5d69357b33.
2025-01-24 20:02:30 +01:00
Matthew Lugg
f77e1b8622
Merge pull request #22578 from mlugg/stack-trace-tests-x86_64
tests: enable stack trace tests for x86_64-selfhosted
2025-01-24 05:11:26 +00:00
Alex Rønne Petersen
180db2bf23
std.debug: Fall back to .eh_frame/.debug_frame if .eh_frame_hdr is incomplete.
When using the self-hosted backends, especially in incremental mode, the
.eh_frame_hdr section may be incomplete, so we can't treat it as authoritative.

Instead, if we started out intending to use .eh_frame_hdr but find that it's
incomplete, load .eh_frame/.debug_frame on demand and use that info going
forward.
2025-01-23 23:22:38 +00:00
Alex Rønne Petersen
41185d297f
Package.Module: Make create() fall back on options.global.root_optimize_mode.
As is done for root_strip and root_error_tracing.
2025-01-23 23:22:38 +00:00
Alex Rønne Petersen
ef4d7f01a5
compiler: Fix computation of Compilation.Config.any_unwind_tables.
This moves the default value logic to Package.Module.create() instead and makes
it so that Compilation.Config.any_unwind_tables is computed similarly to
any_sanitize_thread, any_fuzz, etc. It turns out that for any_unwind_tables, we
only actually care if unwind tables are enabled at all, not at what level.
2025-01-23 23:22:38 +00:00
Alex Rønne Petersen
b46a40ff1d
compiler: Handle --no-eh-frame-hdr as a regular zig build-* flag too.
For some reason we accepted --eh-frame-hdr, but not --no-eh-frame-hdr, despite
accepting the latter as a -Wl linker flag.
2025-01-23 23:22:38 +00:00
mlugg
7774287fdc
tests: enable stack trace tests for x86_64-selfhosted
Allows the stack trace tests to be additionally compiled and run with
`.use_llvm = false, .use_lld = false` depending on the host target. This
is currently enabled for x86_64 targets emitting ELF.

Self-hosted backends emit slightly different DWARF info to the LLVM
backend, so the checking logic (and the tests themselves) had to be
tweaked slightly to support both backends at once.
2025-01-23 23:22:13 +00:00
Alex Rønne Petersen
d916954bee
Merge pull request #22098 from alexrp/wasm-generic-baseline
`std.Target`: Use `lime1` as wasm baseline model and `mvp` as generic model
2025-01-23 18:41:11 +01:00
Pierre Tachoire
f3c29dcb24 std.posix.setsockopt: EOPNOTSUPP can be returned
On Linux, set REUSEPORT option on an unix socket returns a EOPNOTSUPP
error.
See 5b0af621c3
2025-01-23 14:35:57 +01:00
John Benediktsson
530335b572
adding std.c.TCP.NODELAY for macos (#22404)
closes #17260
2025-01-23 04:01:05 +00:00
Alex Rønne Petersen
68c6a88770
link.Wasm.Feature: Make fromCpuFeature() and toCpuFeature() less cute.
This is more verbose, but at least we now get a compile error instead of UB when
a new feature is added to std.Target.wasm.Feature but not to link.Wasm.Feature.
2025-01-22 21:18:15 +01:00
Alex Rønne Petersen
35e804bfb8
wasm2c: Implement nontrapping_fptoint support. 2025-01-22 20:56:30 +01:00
Alex Rønne Petersen
ea1502974d
wasm: Add a nontrapping_bulk_memory_len0 feature.
This will mainly be used when targeting our wasm2c implementation which has no
problem with zero-length bulk memory operations, as a non-standard extension.
2025-01-22 20:56:28 +01:00
Matthew Lugg
0e815c652d
Merge pull request #22572 from jacobly0/new-error-trace
compiler: include error trace in all functions, implement for x86_64 backend
2025-01-22 16:48:27 +00:00
Matthew Lugg
61fe307d0f
Merge pull request #22571 from mlugg/various-fixes-again
compiler: a few fixes
2025-01-22 16:47:45 +00:00
Jacob Young
d4b6a53327 x86_64: implement error return traces 2025-01-22 03:44:13 -05:00
mlugg
9b7b240c8e std.builtin: make returnError not take the error trace
It's now unnecessary to explicitly pass this, because it receives an
implicit error trace parameter anyway, so can just use
`@errorReturnTrace()`. The previous commit updated Sema to expect this
new interface. This saves an AIR instruction at all `returnError` call
sites.
2025-01-22 02:22:56 -05:00
mlugg
8b5c4baed8 stage1: update zig1.wasm
Necessary because the API of `std.builtin.returnError` changed.

Signed-off-by: mlugg <mlugg@mlugg.co.uk>
2025-01-22 02:22:56 -05:00
mlugg
1bce01de97 compiler: pass error return traces everywhere 2025-01-22 02:22:56 -05:00
mlugg
e864c38cc3
Sema: fix crash when inline loop condition is not comptime-known 2025-01-22 04:18:43 +00:00
mlugg
8470b6ea37
Zcu: fix switch prong source location resolution
Resolves: #22343
2025-01-22 04:11:02 +00:00