Commit graph

838 commits

Author SHA1 Message Date
Demetrius Kanios
1d4e04f7a7
[WebAssembly] Call EH personality function instead of Unwind_CallPersonality (#209282)
On Wasm, it's not currently possibly to change which `personality` is
attached to a given IR function. This is primarily because no matter
what `personality` is attached, codegen creates a call to a
`Unwind_CallPersonality` wrapper hard-coded to call c++abi's
personality.

In order to allow alternative personalities without introducing bloat at
each personality call site, this PR adjusts the ABI of the personality
on Wasm. `Unwind_CallPersonality` is moved to `libcxxabi` under the name
`__gxx_wasm_personality_v0`, with the "real" personality code renamed
`__gxx_personality_imp` and called by `__gxx_wasm_personality_v0` (after
resetting the landing pad context).

The signature of EH personalities on Wasm is now `int personality(void*
exception_object)` (where the int return is `_Unwind_Reason_Code` and
the `void*` is `_Unwind_Exception*`), and personalities are expected to
`__wasm_lpad_context.selector = 0;`.

Based on #175202
2026-07-28 20:05:45 -07:00
Piotr Kubaj
6b0a46958c
[libunwind][PPC64] Fix unw_getcontext corrupting callee-saved VSX registers on LE (#198371)
This is the first of two independent fixes for libunwind on ppc64le
(ELFv2 ABI, little-endian), where two separate bugs together cause
SIGSEGV during backtracing. This commit addresses the VSX register
corruption; the TOC-restore fault is handled in a follow-up. Both
were discovered while debugging lang/rust build failures with
RUST_BACKTRACE=1 on FreeBSD/powerpc64le (IBM POWER9).

On ppc64le, `unw_getcontext` saves each VS register with an in-place
`xxswapd n, n` followed by `stxvd2x`. The swap is needed because
`stxvd2x` stores doublewords in the wrong order on LE. However, the
macro never applies a second `xxswapd` to restore the register after
the store, so all 64 VS registers are permanently corrupted on return
from `unw_getcontext`.

This affects every callee-saved VSX register: f14-f31 (VSR14-VSR31)
and VR20-VR31 (VSR52-VSR63). After `_Unwind_Backtrace` returns, any
code that uses these registers sees wrong values. In practice this
manifests as SIGSEGV inside hashbrown's `reserve_rehash`: VR20-VR31
are corrupted before a SIMD comparison loop runs, producing an
out-of-bounds access.

Fix: add a second `xxswapd n, n` after the `stxvd2x` store. Since
`xxswapd` is its own inverse, the pair is a no-op on the architectural
register while still writing the correctly byte-swapped value to memory.
2026-07-25 12:11:31 -07:00
Jon Roelofs
8e34b2cbb0
[libunwind][arm64e] Mach-O Support unwinding PAuth_LR frames (#202772)
Under PAuth_LR, compact unwind entries marked UNWIND_ARM64_MODE_FRAME_PAUTH_LR are signed with the PC of the pacibsppc at the start of the range. The compiler may emit those entries with UNWIND_IS_NOT_FUNCTION_START when the pacibsppc is not the first instruction in the function; the unwinder must scan backwards past such entries to find the actual function start (and its LSDA pointer).

When unwinding a PAuth_LR frame, authenticate and re-sign using setIPPAuthLR(), which calls __builtin_ptrauth_auth_with_pc_and_resign when available, falling back to inline asm (autib171615 + pacib) for compilers that lack the builtin.

To reduce the size of Compact Unwind entries for shrinkwrapped frames, new offset bits encode the distance in multiples of 4 bytes from the range start to the pacibsppc. The compiler emits paired FRAMELESS/FRAMELESS+PAUTH_LR entries that the linker merges into a single FRAME_PAUTH_LR | (offset/4) << 12 encoding.

rdar://161907302&169746432&171118419
2026-07-24 14:17:11 -07:00
Jon Roelofs
77e879f967
[libunwind][AArch64] Support .cfi_set_ra_state (#209950)
This new CFI directive directly assigns an RA signing state to the RA_SIGN_STATE DWARF pseudo-register for use when unwinding, to indicate whether the value of PC has been used as a diversifier for return address signing. The new directive subsumes and replaces .cfi_negate_ra_state_with_pc, which was found to be unsuitable for descibing some block layouts [1], particularly in hot-cold-split functions.

1: https://github.com/ARM-software/abi-aa/pull/346
2026-07-23 11:46:36 -07:00
Jon Roelofs
d1d3891077
[libunwind] XFAIL the za unwind test on Apple targets older than OS 27.0 (#211379)
When linking against the system unwinder on macOS < 27, the test
fails on platforms that support SME.
2026-07-23 09:27:55 -04:00
Hubert Tong
dbaabbc920
[libunwind][test][AIX] Add C API test for unwinding from AIX VAPI (as signal handler) (#209662)
Further to https://github.com/llvm/llvm-project/pull/209306, test a case
where a signal handler is a Virtual API function triggered synchronously
while the VAPI is not active. Resuming an ancestor context of the signal
frame should call the VAPI return glue.

---------

Assisted-by: IBM Bob
2026-07-22 13:17:47 -04:00
Hubert Tong
861efe03d9
[libunwind][test][AIX] Add C API test for unwinding from AIX VAPI (non-signal-handler case) (#209306)
Test detection, during stepping, of the backchain mutation introduced by
a VAPI call (see https://github.com/llvm/llvm-project/pull/209280).
Further, test resumption of contexts using cursors obtained while a VAPI
is active on the thread.

Testing is done via FileCheck inspection of trace output enabled by
`LIBUNWIND_PRINT_UNWINDING=1`. When Live Library Update is not enabled,
synthetic trace output is generated by the test program itself.

---------

Assisted-by: IBM Bob
2026-07-22 13:08:16 -04:00
Louis Dionne
743f03189f
[runtimes] LLVM 24 version bumps (#211262)
This patch bumps the version of libc++abi and libunwind, and libc++ in
the documentation.
2026-07-22 12:38:40 -04:00
Xing Xue
8aa808457c
[libunwind][AIX] Handle VAPI-based return addresses in stack unwinding for LLU (#209280)
In AIX's implementation of LLU (Live Library Update), the caller of a
Virtual API (VAPI) interface instead calls VAPI glue and the
implementation for a VAPI function is entered from the VAPI glue. If a
VAPI is not already active on the thread, the VAPI calls the
implementation of the VAPI function with the link register (LR) value
set to a return address in the VAPI glue. In this case, the LR (return
address) value on entry to the VAPI glue is saved in the VAPI control
block. This PR checks whether the return address in a stack frame falls
within the VAPI address range. If it does, the unwinder retrieves the LR
value from the VAPI control block and uses it as the return address
during stack unwinding. In addition, before transferring control to a
landing pad, this PR executes the VAPI return glue to clear the VAPI
control block if the VAPI glue was used.

---------

Co-authored-by: Hubert Tong <hubert.reinterpretcast@gmail.com>
2026-07-22 11:34:21 -04:00
Jon Roelofs
a01ff35d03
[libunwind] Fix exposure of UNW_AARCH64_RA_SIGN_STATE through _Unwind_GetGR (#209947)
The pseudo register was previously hacked in under kRegisterIsUndefined, leaving it in a state that was only accessible from within the unwinder itself.
To fix this, allowing external access to the state (and therefore tests!), we invent a new register location kRegisterIsPseudo to record the additional state that the register has been defined by a .cfi_negate_ra_state opcode having been executed.
2026-07-20 11:17:14 -07:00
Zachary Yedidia
c4026e4350
[LFI][libunwind] Omit unsuppported stg/za instructions for LFI target (#209392)
Under the LFI target the SVE `za` are not currently supported, and
neither is the `stg` instruction. When included in an LFI program they
cause verification failures due to being unsupported instructions. This
patch omits them from compilation when targeting LFI.
2026-07-20 10:40:40 -07:00
Reid Kleckner
93b1240309
[docs] Finish misc MyST migration (#210209)
Tracking issue: #201242
See the [migration guide] for more information.

[migration guide]:
https://llvm.org/docs/SphinxQuickstartTemplate.html#markdown-migration-guidelines

This is a stacked PR based on #210208, which is the standalone rename
commit for this miscellaneous Markdown migration batch.

This was prepared with rst2myst plus LLM-assisted cleanup. LLDB man
pages are intentionally left as reStructuredText because LLDB man-page
building should not take on Markdown parser dependencies.

Unfortunately, many of these miscellaneous docs do not have working
standalone doc build targets, so I was not able to render HTML for all
of them. I think the scope is small enough that this is reviewable by
hand.
2026-07-17 11:56:59 -07:00
Reid Kleckner
c42ce32264
[docs] Rename misc rst docs to md (#210208)
Tracking issue: #201242
See the [migration guide] for more information. 

[migration guide]:
https://llvm.org/docs/SphinxQuickstartTemplate.html#markdown-migration-guidelines

This is the initial straight rename commit.

Many of these miscellaneous .rst files are not actually part of a real
docs build, since docs/conf.py does not exist for many of them.
2026-07-17 10:48:13 -07:00
Hubert Tong
84199dde71
[libunwind][test] Add .clang-format (#209364)
Borrow from `libcxx/test/.clang-format` to avoid `clang-format`
suggestions that are incompatible with `FileCheck`.
2026-07-14 13:29:57 -04:00
quic-k
7a8b26271b
[libunwind][Hexagon] Save/restore full r0-r7 in getcontext/jumpto (#208753)
The Hexagon save and restore routines dropped GPRs, producing an
incomplete context.

UnwindRegistersSave.S (__unw_getcontext): save r0-r7 (stores began at
__r[8]), drop a dead "r1 = memw(r30)" before the PC store, and return
UNW_ESUCCESS instead of a stale non-zero value.

UnwindRegistersRestore.S (jumpto): restore the missing r2-r7 (r0/r1 and
r8-r31 were already handled), and fix the stale "pointer is in r2"
comment (it is r0).

Signed-off-by: Kushal Pal <kushpal@qti.qualcomm.com>
2026-07-13 08:18:51 -05:00
Shreeyash Pandey
6eb3532614
[libunwind] include alloca.h in test/aarch64_za_unwind.pass.cpp (#207376)
Glibc provides the alloca function as a part of stdlib.h when
_GNU_SOURCE is declared (which is the case with standard linux builds).
[1]

On non-glibc systems, this may not be the case (for example, picolibc).
These libraries may not implicitly include alloca.h as a part of the
standard lib.

[1]
04e750e75b/stdlib/stdlib.h (L728)

Signed-off-by: Shreeyash Pandey <shrpand@qti.qualcomm.com>
2026-07-08 12:33:55 +05:30
Jon Roelofs
4d87e55d8a
[libunwind][aarch64] Fix auth on PAuth_LR'd frames (#206814)
The RA_SIGN_STATE pseudo register is a three-state enum, so it should be
encoded as one in the unwinder's representation. This fixes a bug on the
authentication path, which assumed "is signed with PC" was a subset of
"is signed".
2026-07-01 09:11:31 -07:00
Matt Arsenault
6a909d6862
[runtimes][NFC] Re-indent shared library blocks (#205523)
Re-indent the shared library target blocks that were wrapped in
if(<runtime>_SUPPORTS_SHARED_LIBRARY) in the previous commit. This is a
whitespace-only change split out from the functional change to keep that
diff minimal and reviewable.

Co-authored-by: Claude (Opus 4.8) <noreply@anthropic.com>
2026-07-01 12:50:29 +02:00
Heejin Ahn
443d933cef
[libunwind] Fix comment about phase (NFC) (#206660)
We switched to use `_UA_SEARCH_PHASE` in
https://github.com/emscripten-core/emscripten/pull/17991, but the
comment above was not fixed, and it was upstreamed that way later.
2026-06-30 16:55:55 -07:00
Petr Hosek
e192ec42b4
[CMake] Warn when the version of CMake is older than 3.31.0 (#204203)
This is a preparation to raise the minimum required CMake version to
3.31.0 in LLVM 24.

See
https://discourse.llvm.org/t/rfc-raising-minimum-required-cmake-version-to-3-31/91086.
2026-06-29 11:16:27 -07:00
Matt Arsenault
885ef9daac
[runtimes] Don't create shared library targets when unsupported (#205517)
On platforms that don't support shared libraries (e.g. CMAKE_SYSTEM_NAME
of "Generic", used for GPU and other baremetal targets), CMake's
Platform/Generic.cmake sets the global TARGET_SUPPORTS_SHARED_LIBS
property to FALSE. Under CMP0164's OLD behavior (the default, since the runtimes 
set cmake_minimum_required(3.20)), CMake silently demotes SHARED library
targets to STATIC archives. libcxx, libcxxabi and libunwind always create their
shared target, so after demotion both the shared and static targets emit e.g.
"libc++abi.a" and Ninja fails with "multiple rules generate ...".

Rather than papering over the collision with a distinct output name,
skip creating the shared library targets entirely when the platform does not
support them, gating on the TARGET_SUPPORTS_SHARED_LIBS property (left 
undefined on platforms that do support shared libraries). The few consumers of 
the shared targets are guarded with TARGET checks so they fall back to the static
library or are skipped.

Also set policy CMP0164 to NEW so that any future unguarded
add_library(... SHARED ...) on an unsupported platform fails at
configure time instead of silently producing a colliding static archive.

See https://gitlab.kitware.com/cmake/cmake/-/issues/25759.

The bodies of the newly-conditional blocks are left at their original
indentation to keep this diff minimal. A follow-up commit will fix the
indentation. This was mostly AI generated with some comment fixups.

Co-authored-by: Claude (Opus 4.8) <noreply@anthropic.com>
2026-06-29 17:53:09 +02:00
Scott Linder
42ff45b865
[docs] Create utils/docs (#203962)
llvm-project is home to many sphinx documentation sites, each with
configuration quirks and bespoke extensions.

The sphinx config model makes sharing code somewhat difficult. There
are options like sphinx-multiproject, but some of our docs builds are
out of the source tree while some are done out of the binary tree, so
the multiproject configuration itself would need to be generated. It
also would impose more uniformity around extensions than required.

This change instead creates a python package at utils/docs/llvm_sphinx
and makes it available to all sphinx-build processes via PYTHONPATH.
Each conf.py does not modify its own sys.path because not all builds are
out of the source tree, so there isn't a stable relative path to use to
refer to the utils/docs/ directory.

Type checking via pyright in new package is pinned to being python 3.8
compatible.

The myst slug script from llvm/docs is promoted to be the default,
with a slight edit to targets needed in FlangDriver.md to adapt to the
change.

The ghlinks extension from clang gets lifted to be the first generic
extension, although it is still only used in clang currently. I used it
as an example of a general extension that might be useful for other
projects, but I also intend to add a new generic extension in a future
patch.

As part of the move ghlinks is refactored a bit:

* Rather than have a main function directly to run its tests, those
  tests are now run via the command-line entrypoint to the new package,
  e.g. `python utils/docs --test` will now replace
  `python clang/docs/ghlinks.py --test`. This makes the command-line
  more pithy (`python utils/docs/llvm_sphinx/ext/ghlinks --test` is a
  bit long), and makes the default behavior when running be to
  include utils/docs in the sys.path, so imports can be absolute and
  the behavior is as close to the CMake targets as possible.
* The static files that were previously written to a tempdir during
  testing are just committed directly in git. The assumption here is
  that the original version was taking pains to avoid polluting the
  clang/docs directory with test files that would confuse sphinx-build,
  and without that limitation the workaround can be removed.
* Some typing-related changes to make it strictly python 3.8 compatible.

Change-Id: Ie16de273f74973f163dbf7fe9d22d80a466d051f
2026-06-24 15:12:48 -04:00
Jon Roelofs
e67b31a00e
[libunwind] Fix an uninitialized read of __ra_sign_state (#205152)
The Arm DWARF spec defines UNW_AARCH64_RA_SIGN_STATE as being zeroed
until the first .cfi_negate_ra_state / .cfi_set_ra_state [1]. The GPRs
struct containing __ra_sign_state is memcpy'd directly from the
unw_context_t, which in turn is initialized by __unw_getcontext. Since
it is a pseudo register, there is no corresponding state to restore in
__unw_resume.


https://github.com/ARM-software/abi-aa/blob/main/aadwarf64/aadwarf64.rst#44call-frame-instructions
2026-06-22 13:41:46 -07:00
Brad Smith
94b475dae6
[libunwind] Add SME detection for Apple platforms (#193630)
Copy SME detection sysctl code from ZA test. Also fix a
logic issue in the original code while being reviewed.
2026-05-05 02:25:33 +00:00
Nikolas Klauser
6810a69ab8
[libc++] Update macOS and AppleClang (#193711)
The new AppleClang is only available on macOS 26, so we need to update
both.
2026-04-30 19:57:23 +02:00
Alex Rønne Petersen
06ddfcf0ca
[libunwind] fix build errors on x32 and mips n32 (#194310) 2026-04-27 15:32:47 +02:00
Alexander Kornienko
1f332ae4f1
Fix -Wformat diagnostic after #190965 (#193704)
Fixes libunwind compiler diagnostic when building with clang after
034d4dcad6:
```
In file included from libunwind/src/libunwind.cpp:31:
In file included from libunwind/src/UnwindCursor.hpp:52:
libunwind/src/CompactUnwinder.hpp:339:46: error: format specifies type 'unsigned long long' but the argument has type 'uint64_t' (aka 'unsigned long') [-Werror,-Wformat]
  338 |                            "function starting at 0x%llX",
      |                                                    ~~~~
      |                                                    %lX
  339 |                             compactEncoding, functionStart);
      |                                              ^~~~~~~~~~~~~
libunwind/src/config.h:215:63: note: expanded from macro '_LIBUNWIND_DEBUG_LOG'
  215 |   #define _LIBUNWIND_DEBUG_LOG(msg, ...)  _LIBUNWIND_LOG(msg, __VA_ARGS__)
      |                                                          ~~~  ^~~~~~~~~~~
libunwind/src/config.h:181:45: note: expanded from macro '_LIBUNWIND_LOG'
  181 |     fprintf(stderr, "libunwind: " msg "\n", __VA_ARGS__);                      \
      |                                   ~~~       ^~~~~~~~~~~
In file included from libunwind/src/libunwind.cpp:31:
In file included from libunwind/src/UnwindCursor.hpp:52:
libunwind/src/CompactUnwinder.hpp:458:39: error: format specifies type 'unsigned long long' but the argument has type 'uint64_t' (aka 'unsigned long') [-Werror,-Wformat]
  457 |                            "function starting at 0x%llX",
      |                                                    ~~~~
      |                                                    %lX
  458 |                             encoding, functionStart);
      |                                       ^~~~~~~~~~~~~
libunwind/src/config.h:215:63: note: expanded from macro '_LIBUNWIND_DEBUG_LOG'
  215 |   #define _LIBUNWIND_DEBUG_LOG(msg, ...)  _LIBUNWIND_LOG(msg, __VA_ARGS__)
      |                                                          ~~~  ^~~~~~~~~~~
libunwind/src/config.h:181:45: note: expanded from macro '_LIBUNWIND_LOG'
  181 |     fprintf(stderr, "libunwind: " msg "\n", __VA_ARGS__);                      \
      |                                   ~~~       ^~~~~~~~~~~
```
2026-04-23 10:33:03 +00:00
Zachary Yedidia
2b63e5e75d
[LFI][libunwind] Avoid writing to reserved registers on the aarch64_lfi target (#192739)
The registers `x25`, `x26`, `x27`, and `x28` are reserved for the
`aarch64_lfi` target and should not be written/used. See
`llvm/docs/LFI.rst` for more details. They contain fixed constants or
temporaries used as part of assembly-level rewrites of load/store
instructions. The rewriter will reject programs that attempt to write to
these registers. It is technically OK to save/read them (in
`UnwindRegistersSave.S`), but there is no point since there is no need
to restore them (and to maintain LFI's security invariant, they in fact
cannot be written).
2026-04-21 15:42:31 -07:00
Brad Smith
bffb208404
[libunwind] Add SME detection for ZA test on OpenBSD / FreeBSD (#193148)
Follow up to 588451c160 to
add SME detection on OpenBSD and FreeBSD.
2026-04-21 17:28:16 -04:00
Michael Kruse
afb80bddf1
[Runtimes] Introduce variables containing resource dir paths (#177953)
Introduce common infrastructure for runtimes that determines compiler
resource path locations. These variables introduced are:

 * RUNTIMES_OUTPUT_RESOURCE_DIR
 * RUNTIMES_INSTALL_RESOURCE_PATH
 
That contain the location for the compiler resource path (typically
`lib/clang/<version>`) in the build tree and the install tree (the
latter relative to CMAKE_INSTALL_PREFIX).

Additionally, define

 * RUNTIMES_OUTPUT_RESOURCE_LIB_DIR
 * RUNTIMES_INSTALL_RESOURCE_LIB_PATH

as for the location of clang/flang version-locked libraries (typically
`lib${LLVM_LIBDIR_SUFFIX}/<targer-triple>`, but also depends on `APPLE`
and `LLVM_ENABLE_PER_TARGET_RUNTIME_DIR`). This code is moved from
flang-rt and initially becomes its only user.

Refactored out of #171610 as requested
[here](https://github.com/llvm/llvm-project/pull/171610#discussion_r2687382481).

Extracted `get_runtimes_target_libdir_common` from compiler-rt as
requested
[here](https://github.com/llvm/llvm-project/pull/171610#discussion_r2689565634).
 
Added TODO comments to all runtimes as requested
[here](https://github.com/llvm/llvm-project/pull/171610#issuecomment-3789598635).
2026-04-02 10:32:14 +00:00
Oliver Hunt
1aba434dab
[libunwind][PAC] Defang ptrauth's PC in valid CFI range abort (#184041)
It turns out making the CFI check a release mode abort causes many, if
not the majority, of JITs to fail during unwinding as they do not set up
CFI sections for their generated code. As a result any JITs that do
nominally support unwinding (and catching) through their JIT or assembly
frames trip this abort.

rdar://170862047
2026-03-27 14:33:08 +00:00
Jon Roelofs
47e4282c19
[libunwind][Apple] Improve test coverage on Apple platforms (#186423)
Introduces a macro abstraction around capturing the bounds of a
function, which many platforms handle subtly differently (Mach-O, and
ELF, for example).

Also introduce an arm64[^-]* -> aarch64 available feature, to enable
more tests that would otherwise be excluded on Apple platforms, whose
target triples tend to take the form e.g. 'arm64-apple-macosx', rather
than 'aarch64-apple-macosx'.

Third, we implement the has-sme check using the appropriate sysctl, as
getauxval is not available on Darwin platforms.
2026-03-25 18:16:19 -07:00
Jon Roelofs
0129ecf022
[llvm][CompactUnwind] Compact Unwind does not support .cfi_signal_frame (#186458)
Fixes libunwind's signal_frame.pass.cpp test on Mach-O platforms.
2026-03-25 13:58:19 -07:00
Brad Smith
588451c160
[libunwind] Fix building on OpenBSD / FreeBSD aarch64 (#188397)
Just checking for the header presence of sys/auxv.h breaks the
build on OpenBSD / FreeBSD. Make use of elf_aux_info().
2026-03-25 15:39:08 -04:00
Alex Crichton
a3f28233fc
[WebAssembly] Move __cpp_exception to libunwind (#185770)
The `__cpp_exception` symbol is now defined in libunwind instead of
compiler-rt. This is moved for a few reasons, but the primary reason is
that compiler-rt is linked duplicate-ly into all shared objects meaning
that it's not suitable for define-once symbols such as
`__cpp_exception`. By moving the definition to the user of the symbol,
libunwind itself, that guarantees that the symbol should be defined
exactly once and only when appropriate. A secondary reason for this
movement is that it avoids the need to compile compiler-rt twice: once
with exception and once without, and instead the same build can be used
for both exceptions-and-not.
2026-03-11 00:43:11 +00:00
Sam Clegg
0baf5a0496
Revert "Silence -Wunused-parameter warnings in Unwind-wasm.c" (#175776)
Reverts llvm/llvm-project#125412

See the discussion in #125412 for why this is necessary. The summary is
that:

- Eliding arguments is the C23 extension, but libunwind builds its C
files with `-std=c99`, so this change broke the build.
- `-Wno-unused-parameter` is part of the build for libunwind, so the
codebase does allow them.
2026-03-04 09:59:28 -08:00
Martin Storsjö
0991d7b8fd
[libunwind] Fix building with EXCEPTION_DISPOSITION as enum (#180513)
On Windows, libunwind is normally only built in mingw mode; it's not
relevant for MSVC targets. (Attempting to build it is entirely blocked
in CMake, see [1]).

In mingw headers, the type EXCEPTION_DISPOSITION is defined as an int
while it is an enum in the MSVC vcruntime headers.

However, in addition to the canonical enum members, we also use a value
which has no assigned enum member. In older mingw-w64 headers, there was
a define for this value, 4, with the name ExceptionExecuteHandler, but
that was removed in [2]. The libunwind code reference this value just by
the literal value 4, with a comment referencing it as
ExceptionExecuteHandler.

This extra enum value isn't passed to the outside Microsoft runtime, but
is only used to pass values from one part of libunwind to another; this
handling is necessary for the forced_unwind{1-3}.pass.cpp tests to
succeed.

If the mingw-w64 headers would define EXCEPTION_DISPOSITION as an enum,
just like the MSVC vcruntime headers, then we'd run into build errors
and warnings like this:

    llvm-project/libunwind/src/Unwind-seh.cpp:166:14: error: cannot initialize return object of type 'EXCEPTION_DISPOSITION' (aka 'enum _EXCEPTION_DISPOSITION') with an rvalue of type 'int'
          166 |       return 4 /* ExceptionExecuteHandler in mingw */;
              |              ^
    llvm-project/libunwind/src/Unwind-seh.cpp:185:14: error: cannot initialize return object of type 'EXCEPTION_DISPOSITION' (aka 'enum _EXCEPTION_DISPOSITION') with an rvalue of type 'int'
          185 |       return 4 /* ExceptionExecuteHandler in mingw */;
              |              ^
    llvm-project/libunwind/src/Unwind-seh.cpp:272:8: warning: case value not in enumerated type 'EXCEPTION_DISPOSITION' (aka 'enum _EXCEPTION_DISPOSITION') [-Wswitch]
          272 |   case 4 /*ExceptionExecuteHandler*/:
              |        ^

Fix these cases by adding explicit casts between EXCEPTION_DISPOSITION
and int.

A (partial) similar change was proposed in [3], but the author never
followed up on the discussion, and the PR was later closed.

[1] b0b546d447
[2] 2de6703961
[3] https://github.com/llvm/llvm-project/pull/159293
2026-02-12 00:31:09 +02:00
willmafh
0653e079c2
[libunwind][NFC] Typo fixes & comments corrections & code style changes. (#174565) 2026-01-24 13:45:50 +00:00
Louis Dionne
ec983ad611
[runtimes] Post-branch tasks for the LLVM 23 release (#176007)
This performs most of the post-branch tasks to start working on the LLVM
23 release. Things that are left to do:
- Update the unicode version
- Update CI versions and supported compiler versions
2026-01-14 18:39:02 +00:00
Heejin Ahn
44d4a64a8b
[libunwind][WebAssembly] Fix typos (NFC) (#173745) 2026-01-05 13:54:53 -08:00
Daniil Kovalev
2b25e92948
[PAC][libunwind] Pass ptrauth-qualified values as const references (#173765)
For Apple's arm64e or Linux's pauthtest, `Registers_arm64::link_reg_t`
type is `__ptrauth`-qualified. When passing a value of such a type to a
function accepting non-`__ptrauth`-qualified parameter with `pint_t`
type, an authentication is performed. So, the corresponding callee
argument does not contain an embedded signature, making it prone to
substitution if spilled to the stack.

This patch prevents early authentication of signed values of
`link_reg_t` type by passing them as const l-value references instead of
passing by value with type `pint_t`. This way, the callee would operate
with a `__ptrauth`-qualified value containing a signature, allowing to
detect a substitution if the value is spilled to the stack.

Note that this approach was introduced previously in #143230 for some
other functions. In this patch, we apply the approach to the functions
which were not considered previously.
2026-01-02 12:28:30 +00:00
Daniil Kovalev
367e3889fa
[PAC][libunwind] Enhance PAuth-related comments in __unw_set_reg (#173769)
The PAuth-related checks performed for arm64e are also performed for
other PAuth-enabled ABIs such as Linux's pauthtest. This patch
introduces use of 'PAuth-enabled ABI' phrase instead of 'arm64e' term
for non-arm64e specific things. Also, on non-arm64e we cannot assume
that we have FPAC, so an additional explanation regarding resign
function guarantees is provided.

Note that other comments mentioning arm64e while not being
arm64e-specific are fixed as part of #171717.

Fixes #160117
2025-12-29 06:56:52 +00:00
Nikolas Klauser
3c100d5d54
[libc++] Enable -Wmissing-prototypes (#116261) 2025-12-16 11:25:07 +01:00
Louis Dionne
4ffd373e38
[runtimes] Remove dependencies on cxx_experimental for test-suite installs (#171678)
This patch removes explicit dependencies on cxx_experimental for
installations that are local to the test suite. Such dependencies
are not required anymore from the test-suite installation targets
since the proper dependency is now encoded between cxx and
cxx_experimental.
2025-12-12 12:09:11 -05:00
Louis Dionne
a9fadb3ed4
[runtimes] Modernize installation targets (#171677)
This patch moves away from using cmake_install scripts to install the
various targets when building runtimes, since those have been deprecated
by CMake. Instead, we use `cmake --install` which is the prefered
method.

This patch also localizes how we set dependencies on the various
installation targets, allowing the removal of a few global variables
that were used as lists.

Finally, it makes the way we set up installation targets for libc++,
libc++abi and libunwind consistent again.
2025-12-11 09:09:37 -05:00
Brad Smith
3fdce799cc
[libunwind] fix building on Haiku i386 (#171586)
Co-authored-by: Jérôme Duval <jerome.duval@gmail.com>
2025-12-10 21:27:21 -05:00
Louis Dionne
fb8a7c774d
[libunwind] Make sure libunwind test dependencies are installed before running tests (#171474)
This patch adds an installation step where we install libc++ in a fake
installation tree before testing libunwind. This is necessary because
some configurations (in particular "generic-merged") require libc++ to
be installed, since the libunwind tests are actually linking libc++.so
in which libc++abi.a and libunwind.a have been merged.

Without this, we were actually failing to find `libc++.so` to link
against and then linking against whatever system library we'd find in
the provided search directories. While this happens to work in the
current CI configuration, this breaks down when updating to newer build
tools.
2025-12-10 07:59:17 -05:00
Nathan Corbyn
63ea3537d5
[libunwind](TestOnly) Mark failing tests as unsupported on Apple targets (#170488)
#167642 introduced a number of test failures on one of our stage 2
builds:
https://ci.swift.org/job/llvm.org/job/clang-stage2-Rthinlto/1403/. This
PR marks these tests as unsupported on `.*-apple.*` targets.
2025-12-03 18:17:54 +00:00
Gleb Popov
33bcde0678
libunwind: Remove OS requirements from tests to make them run on more OSes (#167642)
There might be a cleaner way to enable these tests running on FreeBSD,
I'm open to suggestions.

Co-authored-by: Alexander Richardson <mail@alexrichardson.me>
2025-12-01 12:05:37 -08:00
hstk30-hw
6214dccbc9
[Unwind][AArch64] Match sigreturn instructions in big endian (#167139)
Since insns are always stored LE, on a BE system the opcodes will be
loaded byte-reversed. Therefore, define two sets of opcodes, one for LE
and one for BE.
2025-11-15 09:37:15 +08:00