Commit Graph

1264 Commits

Author SHA1 Message Date
Aaron Puchert 4491bb19df [libcxxabi] Fix forced_unwind3.pass.cpp compilation error
Under some circumstances there is no struct _Unwind_Exception, it's just
an alias to another struct. This would result in an error like this:

libcxxabi/test/forced_unwind3.pass.cpp:50:77: error: typedef '_Unwind_Exception' cannot be referenced with a struct specifier
  static _Unwind_Reason_Code stop(int, _Unwind_Action actions, type, struct _Unwind_Exception*, struct _Unwind_Context*,
                                                                            ^
<...>/lib/clang/15.0.0/include/unwind.h:68:38: note: declared here
typedef struct _Unwind_Control_Block _Unwind_Exception; /* Alias */
                                     ^

This seems to have been an issue since the test was first added in
D109856, except that it didn't surface with Clang 14 because the code
is filtered out by the preprocessor if `__clang_major__ < 15`.

Reviewed By: danielkiss, mstorsjo, #libc_abi, ldionne

Differential Revision: https://reviews.llvm.org/D132873
2022-09-11 20:44:38 +02:00
Nikolas Klauser d5e26775d0 [libc++] Granularize the rest of memory
Reviewed By: ldionne, #libc

Spies: vitalybuka, paulkirth, libcxx-commits, mgorny

Differential Revision: https://reviews.llvm.org/D132790
2022-09-05 12:36:41 +02:00
Louis Dionne 690a4692d1 [runtimes] Don't link against compiler-rt when we don't find it
Otherwise, we would end up passing `-lNOTFOUND` to the compiler, which
caused various compiler checks to fail and ended up breaking the build
in the most obscure ways. For example, checks for -faligned-allocation
would fail because the compiler would complain about an unknown library
called NOTFOUND, and we would end up not passing -faligned-allocation
anywhere in our build. This is madness.

An even better alternative would be to simply FATAL_ERROR if we don't
find the builtins library. However, it seems like our build has been
working fine without finding it for a while, so instead of making a
bunch of builds fail, we can figure out why linking against compiler-rt
doesn't actually seem to be required in a follow-up, and perhaps
relax that.
2022-08-24 10:33:10 -04:00
Louis Dionne 342e0ebd0b Revert the removal of LLVM_ENABLE_PROJECTS for libc++ and libc++abi
This commit reverts the following commits:

- 952f90b72b
- e6a0800532 (D132298)
- 176db3b3ab (D132324)

These commits caused CI instability and need to be reverted in order
to figure things out again. See the discussion in https://llvm.org/D132324
for more information.
2022-08-23 09:58:30 -04:00
John Ericson e6a0800532 [libcxxabi][cmake] Allow building without libcxx again
This allows `-DLLVM_ENABLE_RUNTIMES=libcxxabi` to work.

This functionality was removed in D125561 (among other such removals) as
dead code, because it was only available as part of the standalone build
before.

The functionality as added back as it was, except `target_include_directories` is used instead of the cruder `target_compile_options` (with an MSVC vs not MSVC conditional split). That is just wholly better.

Reviewed By: phosek, #libc_abi

Differential Revision: https://reviews.llvm.org/D132298
2022-08-21 08:22:57 -04:00
Simon Tatham a771a91dcb [libcxxabi] Fix alignment of pointers returned by fallback_malloc
This aligns the ``heap[]`` array in ``fallback_malloc.cpp`` to ensure
that it can be safely cast to ``heap_node*``, and also adjusts the
allocation algorithm to ensure that every allocated block has the
alignment requested by ``__attribute__((aligned))``, by putting the
block's ``heap_node`` header 4 bytes before an aligned address.

Patch originally by Eric Fiselier: this is an updated version of
D12669, which was never landed.

Reviewed By: ldionne, #libc_abi

Differential Revision: https://reviews.llvm.org/D129842
2022-08-19 15:07:57 +01:00
John Ericson e941b031d3 Revert "[cmake] Use `CMAKE_INSTALL_LIBDIR` too"
This reverts commit f7a33090a9.

Unfortunately this causes a number of failures that didn't show up in my
local build.
2022-08-18 22:46:32 -04:00
John Ericson f7a33090a9 [cmake] Use `CMAKE_INSTALL_LIBDIR` too
We held off on this before as `LLVM_LIBDIR_SUFFIX` conflicted with it.
Now we return this.

`LLVM_LIBDIR_SUFFIX` is kept as a deprecated way to set
`CMAKE_INSTALL_LIBDIR`. The other `*_LIBDIR_SUFFIX` are just removed
entirely.

I imagine this is too potentially-breaking to make LLVM 15. That's fine.
I have a more minimal version of this in the disto (NixOS) patches for
LLVM 15 (like previous versions). This more expansive version I will
test harder after the release is cut.

Reviewed By: sebastian-ne, ldionne, #libc, #libc_abi

Differential Revision: https://reviews.llvm.org/D130586
2022-08-18 15:33:35 -04:00
tlattner 44f81dfba4 Remove references to old mailing lists that have moved to discourse. Replace with links to discourse.
Reviewed By: #libc_abi, ldionne

Differential Revision: https://reviews.llvm.org/D129675
2022-07-22 09:59:03 -07:00
Petr Hosek 1f3f4833ea [libcxxabi][CMake] Set --unwindlib=none when using LLVM libunwind
We already link libunwind explicitly so avoid trying to link toolchain's
default libunwind which may be missing. This matches what we already do
for libcxx.

Differential Revision: https://reviews.llvm.org/D129469
2022-07-14 18:59:40 +00:00
Muiez Ahmed 85593e7bb5 [SystemZ][z/OS] Modify cxxabi to be compatible with existing z/OS runtime
This patch is to enable exception handling on the z/OS platform that is compatible with the existing z/OS runtime. No functionality of libcxxabi has been changed for other platforms. With this patch the hope is we can add z/OS as a platform to perform testing on any C++ ABI changes.

There is a primary difference for the z/OS implementation. On z/OS the thrown object is added to a linked list of caught and uncaught exceptions. The unwinder uses the top one as the current exception it is trying to find the landing pad for. We have to pop the top exception after we get it’s landing pad for our unwinder to correctly get any subsequent rethrows or nested exception calls.

Differential Revision: https://reviews.llvm.org/D99913
2022-06-28 21:01:25 +03:00
Xing Xue 8da2009608 [libc++abi][AIX] Use _LIBCXXABI_FUNC_VIS for exported routines
Summary:
This patch adds _LIBCXXABI_FUNC_VIS to the definitions of the personality and helper routines for the state table based EH, now that the support of the visibility attribute is being added to AIX Clang. Currently an export list is generated in the absence of the visibility attribute support downstream.

Reviewed by: MaskRay, daltenty

Differential Revision: https://reviews.llvm.org/D126915
2022-06-21 16:18:17 -04:00
Mark de Wever eb12ad9d7f [libc++][CI] Updates GCC to version 12.
Reviewed By: ldionne, philnik, #libc, #libc_abi

Differential Revision: https://reviews.llvm.org/D126667
2022-06-21 18:59:20 +02:00
owenca 462b49f18c [libcxx] Remove extraneous '---' lines in .clang-format files 2022-06-15 01:34:37 -07:00
Jake Egan 1cf4113952 [libcxx][AIX] Switch build compiler to clang
This patch switches the build compiler for AIX from ibm-clang to clang. ibm-clang++_r has `-pthread` by default, but clang for AIX doesn't, so `-pthread` had to be added to the test config. A bunch of tests now pass, so the `XFAIL` was removed. This patch also switch the build to use the visibility support available in clang-15 to control symbols exported by the shared library (AIX traditionally uses explicit export lists for this purpose).

Reviewed By: #libc, #libc_abi, daltenty, #libunwind, ldionne

Differential Revision: https://reviews.llvm.org/D127470
2022-06-13 21:45:18 -04:00
Louis Dionne 2ae52326da [libc++] Towards a simpler extern template story in libc++
The flexibility around extern template instantiation declarations in
libc++ result in a very complicated model, especially when support for
slightly different configurations (like the debug mode or assertions
in the dylib) are taken into account. That results in unexpected bugs
like http://llvm.org/PR50534 (and there have been multiple similar
bugs in the past, notably around the debug mode).

This patch gets rid of the _LIBCPP_DISABLE_EXTERN_TEMPLATE knob, which
I don't think is fundamental. Indeed, the motivation for that knob was to
avoid taking a dependency on the library, however that can be done better
by linking against the static library instead. And in fact, some parts of
the headers will always depend on things defined in the library, which
defeats the original goal of _LIBCPP_DISABLE_EXTERN_TEMPLATE.

Differential Revision: https://reviews.llvm.org/D103960
2022-06-08 22:05:07 -04:00
Martin Storsjö 4a3722a2c3 [libcxxabi] Check __SEH__, when checking if ARM EHABI is implied
ARM EHABI isn't signalled by any specific compiler builtin define,
but is implied by the lack of defines specifying any other
exception handling mechanism, `__USING_SJLJ_EXCEPTIONS__` or
`__ARM_DWARF_EH__`.

As Windows SEH also can be used for unwinding, check for the
`__SEH__` define too, in the same way.

Differential Revision: https://reviews.llvm.org/D126866
2022-06-06 23:19:22 +03:00
Xing Xue b8f5732634 [libc++abi][AIX] add personality and helper functions for the state table EH
Summary:
This patch adds the personality and helper functions for the state table based EH used by IBM legacy compilers xlC and xlclang++ on AIX.

 * A high level description of the state table based EH is provided in the code comments.

 * Function scan_state_tab() is added to scan the state table. It is invoked by the state table personality routine __xlcxx_personality_v0() and returns scan_results like scan_eh_tab() does.

 * A couple of EH helper functions used by xlC and xlclang++ generated code are also added, e.g., __xlc_catch_matchv2() which checks whether the thrown object matches the catch handler's exception type.

 * Debugging macros _LIBCXXABI_TRACE_STATETAB, _LIBCXXABI_TRACE_STATETAB0, and _LIBCXXABI_TRACING_STATETAB are added to dump state table scanning traces if environment variable LIBCXXABI_PRINT_STATTAB is set.

 * The state variable and state table data is the LSDA found from the traceback table of the function during unwinding.

Reviewed by: MaskRay, cebowleratibm, libc++abi

Differential Revision: https://reviews.llvm.org/D100504
2022-05-31 09:21:34 -04:00
Louis Dionne a7f9895cc1 [runtimes] Rename various libcpp-has-no-XYZ Lit features to just no-XYZ
Since those features are general properties of the environment, it makes
sense to use them from libc++abi too, and so the name libcpp-has-no-xxx
doesn't make sense.

Differential Revision: https://reviews.llvm.org/D126482
2022-05-27 15:24:45 -04:00
Louis Dionne 719bf2d9d9 [runtimes] Officially deprecate the legacy testing configuration system
Add a warning and tweak the release note to explain that the deprecation
targets libc++, libc++abi and libuwnind as well.

Also, as a fly-by, ensure that our CI runs the legacy testing configuration
for libc++, libc++abi and libunwind. This doesn't matter too much since
it's deprecated, but we might as well test it properly.

Differential Revision: https://reviews.llvm.org/D126478
2022-05-27 13:15:48 -04:00
Piggy NL 842e48bd65
[demangler][RISCV] Fix for long double
Summary:
The size of long double in RISCV (both RV32 and RV64) is 16 bytes, thus
the mangled_size shouble be 32.

This patch will fix test case
"_ZN5test01hIfEEvRAcvjplstT_Le4001a000000000000000E_c"
in test_demangle.pass.cpp, which is expected to be invalid but demangler
returned "void test0::h<float>(char (&) [(unsigned int)((sizeof (float))
+ (0x0.000000004001ap-16382L))])" in RISCV environment without this patch.

Reviewed By: urnathan

Differential Revision: https://reviews.llvm.org/D126480
2022-05-27 13:53:20 +08:00
Louis Dionne 851bfc07c8 [libc++abi] Use from-scratch testing configs for libc++abi by default
Like we have been doing for libc++ for a while now, start using
from-scratch testing configurations for libc++abi.

As a fly-by fix, remove the LIBCXXABI_NO_TIMER macro, which was defined
but never used.

Differential Revision: https://reviews.llvm.org/D125242
2022-05-26 09:08:31 -04:00
Louis Dionne e3f990b4e9 [libc++abi] Add missing XFAIL on test 2022-05-20 09:35:44 -04:00
Louis Dionne fa7ce8e685 [runtimes] Fix the build of merged ABI/unwinder libraries
Also, add a CI job that tests this configuration. The exact configuration
is that we build a shared libc++ and merge objects for the ABI library
and the unwinder library into it.

Differential Revision: https://reviews.llvm.org/D125903
2022-05-19 10:49:36 -04:00
Martin Storsjö bedf657d0f [runtimes] Default LIB*_HERMETIC_STATIC_LIBRARY to ON on Windows
(In the case of libunwind, the cmake option is called
LIBUNWIND_HIDE_SYMBOLS, but it has the same effect as
LIBCXX_HERMETIC_STATIC_LIBRARY and
LIBCXXABI_HERMETIC_STATIC_LIBRARY.)

Previously, the same issue was dealt with by setting a project wide
define (_LIBUNWIND_HIDE_SYMBOLS,
_LIBCXXABI_DISABLE_VISIBILITY_ANNOTATIONS and
_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS) if only building a static
library.  If building both static and shared at the same time, this
wasn't set, and the static library would contain dllexport directives.

The LIB*_HERMETIC_STATIC_LIBRARY and LIBUNWIND_HIDE_SYMBOLS cmake
options only apply the defines to the static library in the build,
even if building both static and shared at the same time.

(This could only be done use after the object libraries were
enabled, as a shared libcxx needs libcxxabi object files built
with dllexports included.)

This allows removing inelegant code for deciding how to build the
libcxxabi static library and a TODO comment that suggested that
users should need to start setting an option, which they shouldn't
need to. Finally, this gets rid of two XFAILs in tests.

Differential Revision: https://reviews.llvm.org/D125715
2022-05-18 20:31:51 +03:00
Daniel Kiss c218fd3d7d [libunwind][AArch64] Add support for DWARF expression for RA_SIGN_STATE.
Program may set the RA_SIGN_STATE pseudo register by expressions.
Libunwind expected only the DW_CFA_AARCH64_negate_ra_state could change the value
of the register which leads to runtime errors on PAC enabled systems.
In the recent version of the aadwarf64[1] a limitation is added[2] to forbid the mixing the
DW_CFA_AARCH64_negate_ra_state with other DWARF Register Rule Instructions.

[1] https://github.com/ARM-software/abi-aa/releases/tag/2022Q1
[2] https://github.com/ARM-software/abi-aa/pull/129

Reviewed By: #libunwind, MaskRay

Differential Revision: https://reviews.llvm.org/D123692
Reland: test moved because it depends on exceptions.
2022-05-18 17:56:16 +02:00
Louis Dionne aa656f6c2d [runtimes] Introduce object libraries
This is a variant of D116689 rebased on top of the new (proposed) ABI
refactoring in D120727. It should conserve the basic properties of the
original patch by @phosek, except it also allows cleaning up the merging
of libc++abi into libc++ from the libc++ side.

Differential Revision: https://reviews.llvm.org/D125393
2022-05-16 08:41:16 -04:00
Petr Hosek 6f5f847a36 [libcxxabi] Copy headers into build location
Prior to D120727, the libcxx build was responsible for copying libcxxabi
headers into the right location, both in the build and install trees,
but now it's the responsibility of the libcxxabi build. While the build
already did the right thing for the install tree, it wouldn't copy
headers into the build tree, resulting in errors when trying to use the
just built toolchain as is the case in the runtimes build when building
compiler-rt runtimes.

Differential Revision: https://reviews.llvm.org/D125597
2022-05-14 03:49:09 +00:00
Louis Dionne 0a22dfcb11 [runtimes][NFC] Remove dead code for Standalone builds
Standalone builds have been deprecated and then removed for a while now.
Trying to use standalone builds leads to a fatal CMake error, so this
code is all dead. Remove it to clean things up.

Differential Revision: https://reviews.llvm.org/D125561
2022-05-13 14:37:24 -04:00
Louis Dionne f21cf11a4c [libc++abi][NFCI] Refactor demangling_terminate_handler to reduce nesting
This keeps the same logic, but uses early return to avoid multiple layers
of nested ifs and make the code simpler to follow.

Differential Revision: https://reviews.llvm.org/D125476
2022-05-13 12:22:40 -04:00
Louis Dionne a80e65e00a [libc++] Overhaul how we select the ABI library
This patch overhauls how we pick up the ABI library. Instead of setting
ad-hoc flags, it creates interface targets that can be linked against by
the rest of the build, which is easier to follow and extend to support
new ABI libraries.

This is intended to be a NFC change, however there are some additional
simplifications and improvements we can make in the future that would
require a slight behavior change.

Differential Revision: https://reviews.llvm.org/D120727
2022-05-13 08:32:09 -04:00
Nathan Sidwell 562ce15924 [demangler] Avoid special-subst code duplication
We need to expand special substitutions in four different ways.  This
refactors to only have one conversion from enum to string, and derive
the other 3 needs off that.

The SpecialSubstitution node is derived from the
ExpandedSpecialSubstitution.  While this may seem unintuitive, it
works out quite well, as SpecialSubstitution can then use the former's
getBaseName and remove an unneeded 'basic_' prefix, for those
substitutions that are instantiations (to known typedef).  Similarly
all those instantiations use the same set of template arguments (with
'basic_string', getting an additional 'allocator' arg).

Expansion tests were added in D123134, and remain unchanged.

Reviewed By: MaskRay, dblaikie

Differential Revision: https://reviews.llvm.org/D125257
2022-05-13 04:35:29 -07:00
Louis Dionne 2f21f5b06a [libc++abi][NFC] Add comment on long reaching #if 2022-05-12 13:26:55 -04:00
Louis Dionne 6089fd6c0b [libc++abi] Refactor exception type demangling into a separate function
As a fly-by fix, also let `__cxa_demangle` allocate its buffer alone,
since we are not allowed to pass a non-malloc'd buffer to it.

Differential Revision: https://reviews.llvm.org/D125268
2022-05-12 13:17:15 -04:00
Louis Dionne c631e33f31 [runtimes] Print the testing configuration in use in libunwind and libc++abi
We do it for libc++, and it's rather useful for debugging e.g. CI.
2022-05-11 10:18:09 -04:00
Louis Dionne 671afac89d [libc++abi][NFC] Fix typo in comment 2022-05-10 11:15:16 -04:00
Louis Dionne ead7a5fc04 [libc++abi] Reword uncaught exception termination message
When we terminate due to an exception being uncaught, libc++abi prints
a message saying "terminating with uncaught exception [...]". This patch
changes that to say "terminating due to uncaught exception [...]" instead,
which is a bit clearer. Indeed, I've seen some people being confused and
thinking that libc++abi was the component throwing the exception.

Differential Revision: https://reviews.llvm.org/D125245
2022-05-10 09:58:40 -04:00
Martin Storsjö bf1b81d076 [libcxxabi] [cmake] Fix a mismatched variable name
The variable name checked didn't match the one set on the line above.

This error was introduced in b3df14b6c9.
2022-05-10 10:25:43 +03:00
Nathan Sidwell bc150a07f1 [demangler] No need to space adjacent template closings
With the demangler parenthesizing 'a >> b' inside template parameters,
because C++11 parsing of >> there, we don't really need to add spaces
between adjacent template arg closing '>' chars.  In 2022, that just
looks odd.

Reviewed By: MaskRay

Differential Revision: https://reviews.llvm.org/D123134
2022-05-09 06:14:44 -07:00
Nathan Sidwell e48cd7088b [demangler] Buffer peeking needs buffer
The output buffer has a 'back' member, which returns NUL when you try
it with an empty buffer.  But there are no use cases that need that
additional functionality.  This makes the 'back' member behave more
like STL containers' back members.  (It still returns a value, not a
reference.)

Reviewed By: dblaikie

Differential Revision: https://reviews.llvm.org/D123201
2022-05-09 04:17:22 -07:00
Martin Storsjö aeb4907ed6 [libcxxabi] Use the right calling convention for exception destructors on i386 Windows
On Windows on i386, C++ member functions use a different calling
convention (`__thiscall`) than the default one for regular functions
(`__cdecl`). (On Windows on architectures other than i386, both calling
convention attributes are no-ops.)

This matches how libstdc++ declares these types.

This fixes the std/thread/futures/futures.{shared,unique}_future/dtor.pass.cpp
tests on i386 mingw.

Differential Revision: https://reviews.llvm.org/D124990
2022-05-05 23:21:18 +03:00
Nathan Sidwell ed2d4da732 [demangler] Fold expressions of .* and ->*
(Exitingly) a fold expression's operators include .* and ->*, but we
failed to demangle them as we categorize those as MemberExprs, not
BinaryExprs.

Reviewed By: dblaikie

Differential Revision: https://reviews.llvm.org/D123305
2022-05-03 06:45:25 -07:00
Daniel Kiss 6830ebb07e Disable test for Android/Bionic.
Test depends on pthread_cancel which is not supported on Android.
2022-04-29 09:46:43 +02:00
Daniel Kiss f326df34bc [libunwind][AArch64] Fix _Unwind_ForcedUnwind via sigreturn.
When the sigreturn trampoline is found the unw_proc_info_t.end_ip need to be set to
indicate a stack frame is found.

Reviewed By: cjdb, #libunwind, MaskRay

Differential Revision: https://reviews.llvm.org/D124522
2022-04-28 18:41:38 +02:00
gbreynoo 5420834aad [demangler] Fix demangling a template argument which happens to be a null pointer
As seen in https://github.com/llvm/llvm-project/issues/51854
llvm-cxxfilt was having trouble demangling the case "_Z1fIDnLDn0EEvv".
We handled the "LDNE" case and "LPi0E" but not "LDn0E". This change adds
that handling.

Differential Revision: https://reviews.llvm.org/D124010
2022-04-28 15:55:26 +01:00
Kirill Stoimenov aabeb5eb7f Revert "[demangler] Simplify OutputBuffer initialization"
Reverting due to a bot failure:
https://lab.llvm.org/buildbot/#/builders/5/builds/22738

This reverts commit 5b3ca24a35.
2022-04-26 20:24:06 +00:00
Nathan Sidwell 5b3ca24a35 [demangler] Simplify OutputBuffer initialization
Every non-testcase use of OutputBuffer contains code to allocate an
initial buffer (using either 128 or 1024 as initial guesses). There's
now no need to do that, given recent changes to the buffer extension
heuristics -- it allocates a 1k(ish) buffer on first need.

Just pass in a buffer (if any) to the constructor.  Thus the
OutputBuffer's ownership of the buffer starts at its own lifetime
start. We can reduce the lifetime of this object in several cases.

That new constructor takes a 'size_t *' for the size argument, as all
uses with a non-null buffer are passing through a malloc'd buffer from
their own caller in this manner.

The buffer reset member function is never used, and is deleted.

The original buffer initialization code would return a failure code if
that first malloc failed.  Existing code either ignored that, called
std::terminate with a FIXME, or returned an error code.

But that's not foolproof anyway, as a subsequent buffer extension
failure ends up calling std::terminate. I am working on addressing
that unfortunate failure mode in a manner more consistent with the C++
ABI design.

Reviewed By: dblaikie

Differential Revision: https://reviews.llvm.org/D122604
2022-04-26 04:23:12 -07:00
Nathan Sidwell c47bcf9af6 [demangler][NFC] OperatorInfo table unit test
Placing a run-once test inside the operator lookup function caused
problems with the thread sanitizer. See D122975.

Break out the operator table into a member variable, and move the test
to the unit test machinery.

Reviewed By: dblaikie

Differential Revision: https://reviews.llvm.org/D123390
2022-04-25 10:02:08 -07:00
Petr Hosek b3df14b6c9 [runtimes] [CMake] Unify variable names
Avoid repeating CMake checks across runtimes by unifying names of
variables used for results to leverage CMake caching.

Differential Revision: https://reviews.llvm.org/D110005
2022-04-24 13:06:36 +03:00
Senran Zhang a23652f6f9 [demangler] Support C23 _BitInt type
Reviewed By: #libc_abi, aaron.ballman, urnathan

Differential Revision: https://reviews.llvm.org/D122530
2022-04-08 12:20:45 +08:00