Commit graph

1576 commits

Author SHA1 Message Date
Nikolas Klauser
3a809f644c
[libc++abi] Add a clang-tidy config and test (#207324)
This essentially copies the `.clang-tidy` file from libc++ into
libc++abi, except that the naming conventions are updated to not add
underscores and some checks are disabled that don't pass currently. They
will be fixed in follow-ups.
2026-07-31 13:26:27 +02:00
Nikolas Klauser
e7b04d7b58
[libc++abi] Use the same .clang-format as libc++ (#208661)
libc++abi is very close to libc++, and even shares some amount of code.
We should keep the formatting style the same between the two libraries.
2026-07-30 14:10:29 +02:00
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
Nikolas Klauser
9d601915fb
[libc++abi][NFC] Remove some XFAILs which never trigger (#211241)
The oldest library we support is from LLVM 12, so we can remove any
XFAILs for libraries built before that.
2026-07-26 16:19:32 +02: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
Petr Hosek
db7356dde8
[libc++] Partially revert #208330 (#209928)
We found out that the new mechanism for detecting overriden functions
does not support Arm Pointer Authentication (PAuth). Addressing this
limitation is going to require changes to Clang. In the meantime, we
switched back to the old mechanism when PAuth is enabled.
2026-07-16 08:15:30 -04:00
Michael Jones
0cf914adef
[libcxx][libc] update LLVM-libc test status (#201236)
This update removes some unnecessary carveouts, marks some newly
XFAILing tests, and unmarks some now passing tests.

With this change the status of tests is:
Total Discovered Tests: 11471
  Unsupported      : 2098 (18.29%)
  Passed           : 9260 (80.73%)
  Expectedly Failed:  113 (0.99%)

Assisted-by: Automated tooling, human reviewed.
2026-07-15 09:58:49 -07:00
Petr Hosek
6c6ecb376a
[libcxx][libcxxabi] Remove OVERRIDABLE_FUNCTION macro (#209323)
This is no longer needed, we can just use [[gnu::weak]] attribute.
2026-07-14 00:15:30 -07:00
Nikolas Klauser
d6ef81ce4e
[libc++abi][NFC] Use C++11 spelling of [[noreturn]] (#207344)
We already use the C++11 spelling for libc++, and there isn't much of a
reason not to use it. Except for the changes in `cxxabi.h` this is even
fully standard code.
2026-07-10 15:47:09 +02:00
Martin Storsjö
5343b20425
[libcxxabi] Don't enable -fvisibility=hidden on Windows (#207943)
This option is supported (and hence gets added by the
target_add_compile_flags_if_supported function) on Windows, but if using
dllexport, there's no point in using hidden visibility. (However if
building both static and shared libraries at the same time, it could be
beneficial to have hidden visibilty in the static libraries.)

In asserts enabled builds of Clang, building with -fvisibility=hidden
caused errors like this:

    dllexport GlobalValue must have default or protected visibility
    ptr @_ZTIv
    [...]
    fatal error: error in backend: Broken module found, compilation aborted!

Normally, combining -fvisibility=hidden with dllexport is not a problem,
but specifically for `__cxxabiv1:: __fundamental_type_info` it does make
Clang trigger an inconsistency, visible in asserts enabled builds of
Clang - see https://github.com/llvm/llvm-project/issues/207963.

This fixes Windows builds with Clang with asserts enabled, after
cb942d009a.
2026-07-07 16:16:36 +03:00
Nikolas Klauser
cb942d009a
[libc++abi] Always enable -fvisibility=hidden (#207333)
Building with `-fvisibility=hidden` is generally a good idea, since it
avoids unnecessary relocations when loading a dylib. For libc++abi this
should be a no-op, since most things are annotated explicitly. By
enabling `-fvisibility=hidden` we can remove these explicit annotations
however.
2026-07-06 09:35:11 +02:00
aokblast
4a02e116e5
[libcxxabi] Re-enable thread_local_destruction_order.pass.cpp‎ on FreeBSD (#186129)
The underlying bug has been fixed in https://reviews.freebsd.org/D55826.
2026-07-05 19:35:18 +02:00
Nikolas Klauser
cbb277a718
[libc++abi][NFC] Avoid out parameter in dyn_cast_get_derived_info (#207326)
Returning the object is much more idiomatic than having an out
parameter.
2026-07-03 20:41:30 +02: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
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
Daniel Rank
7b8b8ff3ff
[libc++abi] Fix alternate deletions in exhaustion tests (#193130)
Fixes #192773
2026-06-26 16:53:45 -04:00
Nikolas Klauser
44546e0e32
[libc++] Enable clang-tidy in the CI again (#195047)
clang-tidy currently doesn't run in the CI because CMake doesn't find
the appropriate `ClangConfig.cmake` anymore. This adds the path so
clang-tidy is built again and fixes most issues. Some things are
disabled for now to get most checks back. They will be re-enabled later.
2026-06-25 09:11:33 +02:00
Fabrice de Gans
8210a58044
[Demangle] Guard DEMANGLE_ABI and add missing annotation (#202920)
This updates the DEMANGLE_ABI annotation to only be defined if it is not
already defined. This is required to parse the Demangle headers with the
ids-check script.
In addition, this adds one missing DEMANGLE_ABI annotation.

This effort is tracked in #109483.
2026-06-11 02:48:04 -07:00
Louis Dionne
d602a9343a
[libc++] Fill in Apple availability for LLVM 21 (#202347)
macOS 26.4 and aligned platforms have been released and they are roughly
synchronized to libc++ 21. As a drive-by, also add missing versions for
previous releases.

This also allows reverting #199682 which moved an XFAIL to UNSUPPORTED
to silence CI failures temporarily.
2026-06-10 10:37:56 +02:00
Corentin Jabot
68e8dd698d
[Clang] Mangling of pack indexing type and expression for itanium (#123513)
See  https://github.com/itanium-cxx-abi/cxx-abi/pull/198
and #112003
2026-05-15 16:50:30 +02:00
Jackson Stogel
f78419c36b
[libc++abi][libc][test] Use LLVM-libc headers in LLVM-libc config (#194665) 2026-04-29 08:28:57 -07:00
Khem Raj
8119f18549
libcxxabi: declare __gnu_unwind_frame in cxa_personality (#189787)
ARM EHABI builds of libcxxabi fail with clang-22+ because
cxa_personality.cpp calls __gnu_unwind_frame without a visible
declaration, triggering:

  error: use of undeclared identifier '__gnu_unwind_frame'

Add an extern "C" forward declaration before the EHABI unwind helper so
the source compiles correctly.

Signed-off-by: Khem Raj <khem.raj@oss.qualcomm.com>
2026-04-27 09:35:24 +02:00
Aiden Grossman
f650fba569
[libcxx] Add Testing Configuration for LLVM libc
This patch adds a CMake cache, and the testing configs to build libc++
and run the tests against LLVM libc.

Reviewers: ldionne, philnik777, jtstogel

Pull Request: https://github.com/llvm/llvm-project/pull/165120
2026-04-23 10:15:04 -07:00
Marco Elver
fb6f1bde00
[ItaniumDemangle] Strip __alloc_token_ to transparently demangle allocation functions (#191048)
Update the Itanium demangler to recognize and strip `__alloc_token_`
prefixes introduced by AllocToken instrumentation [1]. This ensures that
instrumented allocation functions (e.g., `__alloc_token__Znwm`) demangle
back to their original source-level names (e.g., `operator new(unsigned
long)`) with a suffix `(.alloc_token)` indicating their non-standard
origin.

Since AllocToken is intended to be transparent to users who continue to
use `operator new` as before, the demangled name should reflect this
reality instead of confusing users with internal instrumentation names
in stack traces or symbolization output.

Synchronize changes across llvm and libcxxabi copies.

[1] https://clang.llvm.org/docs/AllocToken.html

Original RFC: https://discourse.llvm.org/t/rfc-a-framework-for-allocator-partitioning-hints/87434
2026-04-22 17:57:30 +02:00
Nikolas Klauser
5d98f79f52
[libc++] Update to Clang 21 as the oldest supported version (#186062) 2026-04-20 16:08:36 +02: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
Peter Collingbourne
f3274a496c
Prepare libcxx and libcxxabi for pointer field protection.
Pointer field protection has the following characteristics:

- Pointer fields in RTTI types are unsigned. Signing these fields
  is unnecessary because PFP is a mechanism for protecting the heap,
  and the RTTI objects typically live in global variables. Therefore,
  mark the fields with the no_field_protection to inhibit PFP for these
  fields.

- libcxx's interim trivial relocatability implementation, which memcpy's
  some non-trivially-copyable objects according to the value of a trait,
  conflicts with PFP in tagged mode (in which the address of the pointer
  is used as part of the pointer encoding) by causing such copies to
  result in a crash in some cases where the object being copied includes
  a pointer field. These copies are undefined behavior. Therefore, make
  libcxx's trivially relocatable predicate simply return the value of
  the trivially copyable trait when PFP in tagged mode is enabled, which
  results in standards compliant behavior that is accommodated by PFP.

Reviewers: philnik777, fmayer, ldionne

Pull Request: https://github.com/llvm/llvm-project/pull/151651
2026-03-25 15:51:35 -07:00
Nikolas Klauser
67cf9b8f82
[libc++] Remove _LIBCPP_CONSTINIT (#171802)
`_LIBCPP_CONSTINIT` is only ever used inside `src/`, so we can just
replace it with `constinit` instead.
2026-01-20 12:51:43 +01:00
Louis Dionne
e02c79a85a
[libc++abi] Remove old workaround for detecting libunwind (#176009)
This workaround should no longer be relevant since we don't support
building against libunwind headers from LLVM 14.
2026-01-19 16:46:13 -05: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
willmafh
c705003e8c
[NFC] Exactly one kind typo fixes, change defintions to definitions. (#174333) 2026-01-14 08:12:26 +00:00
Nikolas Klauser
f0054a4896
[libc++] Replace uses of _LIBCPP_WEAK with [[gnu::weak]] (#171798)
Using `_LIBCPP_WEAK` doesn't give us anything that using `[[gnu::weak]]`
directly couldn't, so we can just expand the macro.
As a drive-by this also refactors `_LIBCPP_OVERRIDABLE_FUNCTION`.
2026-01-13 11:21:52 +01:00
Nikolas Klauser
a5cab90071
[libc++][NFC] Refactor _LIBCPP_OVERRIDABLE_FUNCTION to be a normal attribute macro (#174964)
Currently `_LIBCPP_OVERRIDABLE_FUNCTION` takes the return type, function
name and argument list, but simply constructs the function and adds
attributes without modifying the signature in any way. We can replace
this with a normal attribute macro, making the signature easier to read
and simpler to understand what's actually going on. Since it's an
internal macro we can also drop the `_LIBCPP_` prefix.
2026-01-09 12:07:42 +01:00
Nikolas Klauser
484ee42096
[libc++] Introduce the notion of a minimum header version (#166074)
Introducing the notion of a minimum header version has multiple
benefits. It allows us to merge a bunch of ABI macros into a single one.
This makes configuring the library significantly easier, since, for a
stable ABI, you only need to know which version you started distributing
the library with, instead of checking which ABI flags have been
introduced at what point. For platforms which have a moving window of
the minimum version a program has been compiled against, this also makes
it simple to remove symbols from the dylib when they can't be used by
any program anymore.
2026-01-09 11:58:29 +01:00
willmafh
2eb8ee137f
[NFC] Delete unnecessary apostrophe at the end of its (#173974) 2026-01-04 20:02:40 +08: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
f582fc6491
[libc++] Simplify how we install test-suite dependencies (#171504)
Based on comments in #171474, it was brought to my attention that we can
modernize and simplify how we perform the test suite installation in
libc++ and libc++abi.
2025-12-11 09:10:54 -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
Nikolas Klauser
3dcdb4c765
[libc++][NFC] Move __memory/aligned_alloc.h into src/ (#166172)
This header is only ever used inside `src/`, so we might as well move it
there. As a drive-by this also removes some dead code.
2025-11-24 22:36:13 +01:00
Nikolas Klauser
a8e058a590
[libc++abi] Add a test to ensure the abi namespace alias is declared correctly (#167485) 2025-11-12 10:12:13 +01:00
Nikolas Klauser
46a8ddbd14
[libc++abi][NFC] Remove some cruft from <__cxxabi_config.h> (#164578)
In `<__cxxabi_config.h>` there were a few things still around which
aren't ever actually used. This removes some of that cruft.
2025-11-10 20:04:26 +01:00
Raul Tambre
afc83688cf
[libc++abi][libunwind] Enable AT&T syntax explicitly (#166818)
Implementation files using the Intel syntax typically explicitly specify
it. Do the same for the few files where applicable for AT&T.

This enables building LLVM with `-mllvm -x86-asm-syntax=intel` in one's
Clang config files (i.e. a global preference for Intel syntax).
2025-11-08 10:20:13 -10:00
Michael Buch
54c9ddddd1
[libcxxabi][ItaniumDemangle] Separate GtIsGt counter into more states (#166578)
Currently `OutputBuffer::GtIsGt` is used to tell us if we're inside
template arguments and have printed a '(' without a closing ')'. If so,
we don't need to quote '<' when printing it as part of a binary
expression inside a template argument. Otherwise we need to. E.g.,
```
foo<a<(b < c)>> // Quotes around binary expression needed.
```

LLDB's `TrackingOutputBuffer` has heuristics that rely on checking
whether we are inside template arguments, regardless of the current
parentheses depth. We've been using `isGtInsideTemplateArgs` for this,
but that isn't correct. Resulting in us incorrectly tracking the
basename of function like:
```
void func<(foo::Enum)1>()
```
Here `GtIsGt > 0` despite us being inside template arguments (because we
incremented it when seeing '(').

This patch adds a `isInsideTemplateArgs` API which LLDB will use to more
accurately track parts of the demangled name.

To make sure this API doesn't go untested in the actual libcxxabi
test-suite, I changed the existing `GtIsGt` logic to use it. Also
renamed the various variables/APIs involved to make it (in my opinion)
more straightforward to understand what's going on. But happy to rename
it back if people disagree.

Also adjusted LLDB to use the newly introduced API (and added a
unit-test that would previously fail).
2025-11-07 07:52:03 +00:00
Michael Buch
d49c6707d0
[libcxxabi][demangle] Fix the cp-to-llvm.sh sync script to copy all headers (#166572)
In https://github.com/llvm/llvm-project/pull/137947 I refactored the
script and added a `copy_files` function, which takes the header files
to copy as an argument.

But because the list of headers is a space separated string, we need to
quote the string. Otherwise we would just copy the first header in the
list.

This patch also adds an `echo` statement in the `copy_files` loop to
print the source/destination. Confirming that the files are copied as
expected.
```
$ libcxxabi/src/demangle/cp-to-llvm.sh
This will overwrite the copies of ItaniumDemangle.h ItaniumNodes.def StringViewExtras.h Utility.h in ../../../llvm/include/llvm/Demangle and DemangleTestCases.inc in ../../../llvm/include/llvm/Demangle/../Testing/Demangle; are you sure? [y/N]y
Copying ./ItaniumDemangle.h to ../../../llvm/include/llvm/Demangle/ItaniumDemangle.h
Copying ./ItaniumNodes.def to ../../../llvm/include/llvm/Demangle/ItaniumNodes.def
Copying ./StringViewExtras.h to ../../../llvm/include/llvm/Demangle/StringViewExtras.h
Copying ./Utility.h to ../../../llvm/include/llvm/Demangle/Utility.h
Copying ../../test/DemangleTestCases.inc to ../../../llvm/include/llvm/Demangle/../Testing/Demangle/DemangleTestCases.inc
```

Luckily there weren't any out-of-sync changes introduced in the
meantime.
2025-11-05 17:48:47 +00:00
Aiden Grossman
c946b96d9b [libcxxabi] Update demangle/Utility.h
4eed68357e updated the LLVM side but did
not bump the libc++abi version. Bump the libc++abi version to fix the
test failure caused by the versions differing.
2025-11-03 04:41:26 +00:00
Louis Dionne
3252e11da3
[libc++] Add availability markup for LLVM 19 and LLVM 20 (#140072)
An LLVM 19-aligned libc++ was released with macOS 15.4 (and corresponding OSes),
and LLVM-20 aligned with macOS 26.0. This patch adds availability markup to
reflect that.
2025-11-02 15:24:30 -10:00
Louis Dionne
a98295dbcf
[libc++] Fix localization failures on macOS 15.4 (#138744)
This patch reverts e15025dd and 88e15b781 which were temporary measures
until we had figured out the underlying issues. It turns out that recent
OSes updated localization data, removing the need for several Apple-specific
workarounds in the tests.

Fixes #135385
2025-10-30 08:50:33 -07:00
Oliver Hunt
e6a1aff591
[runtimes][PAC] Harden unwinding when possible (#143230)
This hardens the unwinding logic and datastructures on systems
that support pointer authentication.

The approach taken to hardening is to harden the schemas of as many
high value fields in the myriad structs as possible, and then also
explicitly qualify local variables referencing privileged or security
critical values.

This does introduce ABI linkage between libcxx, libcxxabi, and
libunwind but those are in principle separate from the OS itself
so we've kept the schema definitions in the library specific headers
rather than ptrauth.h
2025-10-20 09:57:45 -07:00