Commit Graph

780 Commits

Author SHA1 Message Date
Brad Smith
f03ccef45f [compiler-rt][libunwind] Allow for CET on OpenBSD (#164341) 2025-10-25 17:11:47 -04:00
Oliver Hunt
c1678e52f9 [PAC][libunwind] Fix gcc build of libunwind and compiler-rt (#164535)
This adds guards on the ptrauth feature checks so that they are only
performed if __has_feature is actually available.
2025-10-22 13:41:50 -07:00
Raul Tambre
c208a23643 [NFCI][asm][i386/x86-64] Enable AT&T syntax explicitly (#164453)
Implementation files using the Intel syntax explicitly specify it.
Do the same for the few files using AT&T syntax.

This also enables building LLVM with `-mllvm -x86-asm-syntax=intel` in one's Clang config files
(i.e. a global preference for Intel syntax).

No functional change intended.
2025-10-21 21:28:41 +03: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
Martin Storsjö
a17afee7ec [libunwind] Fix aarch64 SEH unwinding with a debugger attached (#162867)
See https://github.com/LuaJIT/LuaJIT/issues/593#issuecomment-1717728494
for the original explanation of the problem.

In short; when a debugger is attached, there's a
function KiUserExceptionDispatcher in the stack that is being unwound.
The function KiUserExceptionDispatcher contains a CONTEXT, with a copy
of the context from where the exception was raised. When unwinding
through this function, this whole CONTEXT gets restored.

This CONTEXT is what we receive a pointer to in the callbacks, as the
ms_ctx pointer.

When we unwind manually using RtlUnwindEx, the unwinding overwrites the
CONTEXT that is passed to it. Thus, to avoid clobbering the CONTEXT that
needs to be restored by KiUserExceptionDispatcher, we could either
declare a new temporary CONTEXT on the stack before calling RtlUnwindEx,
or just use disp->ContextRecord as we already have available.

Fixes: https://github.com/llvm/llvm-project/issues/161851

Co-authored-by: Peter Cawley <corsix@corsix.org>
Co-authored-by: Hannes Domani <ssbssa@yahoo.de>
2025-10-16 22:47:08 +03:00
小钟
e6358ab75c Fix typo: IsGlobaLinkage -> IsGlobalLinkage in XCOFF (#161960)
Corrects the spelling of 'IsGlobaLinkage' to 'IsGlobalLinkage' in
XCOFF-related code, comments, and tests across the codebase.
2025-10-12 12:03:40 -07:00
Arjun Ramesh
7e7c923b58 [WebAssembly] Support for new target wasm32-linux-muslwali (#162581)
Add toolchain support for the
[WALI](https://doc.rust-lang.org/rustc/platform-support/wasm32-wali-linux.html)
target as per its corresponding
[RFC](https://discourse.llvm.org/t/rfc-new-wasm-linux-target-support/88203)
2025-10-10 14:54:25 -07:00
Aiden Grossman
0c2913afc8 [libcxx] Use %{temp} instead of %T (#162323)
Based on review feedback in #160026.

This makes the substitution a lot more clear now that there is no
documentation around %T.

---------

Co-authored-by: Louis Dionne <ldionne.2@gmail.com>
2025-10-09 16:52:42 -07:00
Louis Dionne
4f80c064eb [runtimes][NFC] Consistently declare main() functions in tests (#162548)
In the libc++ test suite, we consistently declare main() functions with
full parameters and explicitly return from the function. This helps code
that compiles the tests with -ffreestanding, where main() is not a
special function (with an implicit return and special mangling).

This patch fixes a few stray declarations, including in libunwind and
libc++abi.
2025-10-09 09:00:20 -04:00
Wu Yingcong
4aaf6d1b8c [libunwind][test] Add check for objcopy to improve test compatibility (#161112)
Previously, we only used `objcopy`, which is not available for some
build configurations. With this patch, we not only try to use `objcopy`,
but also try to use `llvm-objcopy` if available.

This is a follow-up of https://github.com/llvm/llvm-project/pull/156383.
2025-10-02 07:42:43 +08:00
Jade Marker
a3d7c468bd [Mips] Fixed libunwind::Registers_mips_o32::jumpto to allow for load delay (#152942)
Fix #152922

MIPS III also has load delay, so 
libunwind::Registers_mips_newabi::jumpto() is also fixed.
2025-09-25 09:20:25 +08:00
David Spickett
e85926545e [libcxx][CI] Use lld for everything in the ARM picolib builds (#158320)
Our host compiler is a clang install that will default to ld if not told
otherwise.

We were telling meson to use lld, but the way that we did it was
outdated, which lead to picolib producing a linker script that lld could
not use. The tests were in fact linking with ld instead.

Using the `c_ld` setting fixes this problem. See:
https://mesonbuild.com/Machine-files.html#binaries

Then to use lld in tests we need `-fuse-ld=lld` in the config files.

Some of these options were not needed for clang 19.1.7, but were for
clang 21.1.1. We will soon update to 21.1.1 so I have included all of
the required options in this PR.
2025-09-15 09:20:58 +01:00
Wu Yingcong
1af19772e6 [libunwind][test] set fed test to require x86 as others arch may have cross toolchain build (#156383)
In https://github.com/llvm/llvm-project/pull/154902, the test failed
with llvm-clang-win-x-aarch64(it is a cross-build, which builds on
Windows and run on Linux, "Win to Aarch64 Linux Ubuntu Cross
Toolchain"), and objdump is not available on Windows(the build env).
Set to require x86 Linux instead.
2025-09-02 19:30:44 +08:00
Wu Yingcong
e57f0e928d [libunwind] fix pc range condition check bug (#154902)
There is an off-by-one error with current condition check for PC fallen
into the range or not. There is another check within libunwind that use
the correct checks in
5050da7ba1/libunwind/src/UnwindCursor.hpp (L2757)
```
      if ((fdeInfo.pcStart <= pc) && (pc < fdeInfo.pcEnd))
```
2025-09-01 09:15:52 +08:00
Benjamin Maxwell
bfab8085af [libunwind] Add support for the AArch64 "Vector Granule" (VG) register (#153565)
The vector granule (AArch64 DWARF register 46) is a pseudo-register that
contains the available size in bits of SVE vector registers in the
current call frame, divided by 64. The vector granule can be used in
DWARF expressions to describe SVE/SME stack frame layouts (e.g., the
location of SVE callee-saves).

The first time VG is evaluated (if not already set), it is initialized
to the result of evaluating a "CNTD" instruction (this assumes SVE is
available).

To support SME, the value of VG can change per call frame; this is
currently handled like any other callee-save and is intended to support
the unwind information implemented in #152283. This limits how VG is
used in the CFI information of functions with "streaming-mode changes"
(mode changes that change the SVE vector length), to make the unwinder's
job easier.
2025-08-21 10:01:40 +01:00
David Tenty
63195d3d7a [NFC][CMake] quote ${CMAKE_SYSTEM_NAME} consistently (#154537)
A CMake change included in CMake 4.0 makes `AIX` into a variable
(similar to `APPLE`, etc.)
ff03db6657

However, `${CMAKE_SYSTEM_NAME}` unfortunately also expands exactly to
`AIX` and `if` auto-expands variable names in CMake. That means you get
a double expansion if you write:

`if (${CMAKE_SYSTEM_NAME}  MATCHES "AIX")`
which becomes:
`if (AIX  MATCHES "AIX")`
which is as if you wrote:
`if (ON MATCHES "AIX")`

You can prevent this by quoting the expansion of "${CMAKE_SYSTEM_NAME}",
due to policy
[CMP0054](https://cmake.org/cmake/help/latest/policy/CMP0054.html#policy:CMP0054)
which is on by default in 4.0+. Most of the LLVM CMake already does
this, but this PR fixes the remaining cases where we do not.
2025-08-20 12:45:41 -04:00
Alex Rønne Petersen
eb0d8f9272 [libunwind] Fix return type of DwarfFDECache::findFDE() in definition (#146308)
Needed to resolve this compilation error on some systems:

lib/libunwind/src/UnwindCursor.hpp:153:38: error: return type of
out-of-line definition of 'libunwind::DwarfFDECache::findFDE' differs
from that in the declaration
    typename A::pint_t DwarfFDECache<A>::findFDE(pint_t mh, pint_t pc) {
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
lib/libunwind/src/libunwind.cpp:31:10: note: in file included from
lib/libunwind/src/libunwind.cpp:31:
    #include "UnwindCursor.hpp"
             ^
lib/libunwind/src/UnwindCursor.hpp:100:17: note: previous declaration is
here
      static pint_t findFDE(pint_t mh, pint_t pc);
             ~~~~~~~^
2025-07-23 00:03:19 +02:00
Petr Hosek
9d3b60dea7 [libcxxabi][libunwind] Support for using LLVM libc (#134893)
This generalizes the support added in #99287 renaming the option to
RUNTIMES_USE_LIBC and integrating the module into libc++abi and
libunwind as well.
2025-07-09 00:48:50 -07:00
Khem Raj
b46f34452e libunwind: Do not use __attribute__((target("gcs"))) with non-clang compilers (#138077)
This attribute is unsupported in GCC, so far it worked because before
GCC15 did not define this macros in _CHKFEAT_GCS in arm_acle.h [1]

With gcc15 compiler libunwind's check for this macros is succeeding and
it ends up enabling 'gcs' by using function attribute, this works with
clang but not with gcc.

We can see this in rust compiler bootstrap for aarch64/musl when system
uses gcc15, it ends up with these errors

Building libunwind.a for aarch64-poky-linux-musl
```
cargo:warning=/mnt/b/yoe/master/sources/poky/build/tmp/work/cortexa57-poky-linux-musl/rust/1.85.1/rustc-1.85.1-src/src/llvm-project/libunwind/src/UnwindLevel1.c:191:1: error: arch extension 'gcs' should be prefixed by '+' cargo:warning=  191 | unwind_phase2(unw_context_t *uc, unw_cursor_t *cursor, _Unwind_Exception *exception_object) {
cargo:warning=      | ^~~~~~~~~~~~~
cargo:warning=/mnt/b/yoe/master/sources/poky/build/tmp/work/cortexa57-poky-linux-musl/rust/1.85.1/rustc-1.85.1-src/src/llvm-project/libunwind/src/UnwindLevel1.c:337:22: error: arch extension 'gcs' should be prefixed by '+'
cargo:warning=  337 |                      _Unwind_Stop_Fn stop, void *stop_parameter) {
cargo:warning=      |                      ^~~~~~~~~~~~~~~
```

[1] https://gcc.gnu.org/git/?p=gcc.git;a=commit;h=5a6af707f0af

Signed-off-by: Khem Raj <raj.khem@gmail.com>
2025-06-11 20:22:08 -07:00
Nikolas Klauser
c59cc2b690 [libunwind] Remove checks for -nostdlib++ (#143162)
libunwind uses a C linker, so it's never even trying to link against any
C++ libraries. This removes the code which tries to drop C++ libraries,
which makes the CMake configuration simpler and allows for upgrading
GCC.
2025-06-11 11:43:34 +02:00
Trung Nguyen
1d9ef8211f [libunwind][Haiku] Fix signal frame unwinding (#135367)
The current unwinding implementation on Haiku is messy and broken.
1. It searches weird paths for private headers, which is breaking builds
in consuming projects, such as dotnet/runtime.
2. It does not even work, due to relying on incorrect private offsets.

This commit strips all references to private headers and ports a working
signal frame implementation. It has been tested against
`tests/signal_unwind.pass.cpp` and can go pass the signal frame.
2025-05-28 22:18:55 -04:00
Jacek Caban
84c1564d18 [libunwind] Add initial ARM64EC support (#138583)
ARM64EC defines `__x86_64__`, which is sufficient to make most C/C++
code behave correctly. To preserve an external ABI compatible with
x86_64, this patch uses the x86_64 context layout and implements
`unw_getcontext` by storing the appropriate aarch64 registers according
to the mapping defined by the ARM64EC ABI.
2025-05-13 15:12:16 +02:00
Raul Tambre
fc3b67aee8 [cmake] Normalize TARGET_SUBDIR paths (#138524)
Some code paths normalize ".." and thus don't create the directory. But some execute in a
shell thus requiring the directory to exist to be able to take the parent directory.

This patch normalizes all the `TARGET_SUBDIR` variables to avoid this issue.
2025-05-12 15:59:39 -04:00
Martin Storsjö
9c67ae861c [libunwind] [SEH] Set NonVolatileRegisters before calling a personality function (#137951)
The CRT __C_specific_handler function uses this for restoring registers
before calling the filter function.

This fixes the libunwind/libcxxabi forced unwind testcases on ARM and
AArch64.
2025-05-09 16:04:57 +03:00
Martin Storsjö
fc83aaea06 [libunwind] [SEH] Implement parsing of ARM pdata/xdata (#137950)
This is generally very similar to the aarch64 case.

Contrary to aarch64, the public headers don't contain any definition of
a struct for interpreting this data, so we provide our own.
2025-05-09 16:04:14 +03:00
Martin Storsjö
2e436b15d3 [libunwind] [SEH] Implement parsing of aarch64 pdata/xdata (#137949)
This is needed for forced unwind, for some testcases in
libunwind/libcxxabi.

This adds an aarch64 case for extracting the LanguageHandler and
HandlerData fields from unwind info, in UnwindCursor::getInfoFromSEH,
corresponding to the existing case for x86_64.

This uses the struct IMAGE_ARM64_RUNTIME_FUNCTION_ENTRY_XDATA; this only
became available in WinSDK 10.0.19041.0 and mingw-w64 v11.0 (or a
mingw-w64 git snapshot after April 2023).

(This is only a build-time requirement though; the format for the unwind
data has been fixed since the start of Windows 10 on ARM64, so this
doesn't impose any runtime requirement.)
2025-05-09 11:08:38 +03:00
Firas Khalil Khana
dd107b20da Update LIBUNWIND_ENABLE_WERROR default value in BuildingLibunwind.rst (#135546)
`LIBUNWIND_ENABLE_WERROR` defaults to `OFF` according to
[CMakeLists.txt](https://github.com/llvm/llvm-project/blob/main/libunwind/CMakeLists.txt#L43).
2025-04-13 09:41:30 -07:00
Gergely Futo
3acfef56b1 [libunwind][RISCV] Make asm statement volatile (#130286)
Compiling with `O3`, the `early-machinelicm` pass hoisted the asm
statement to a path that has been executed unconditionally during stack
unwinding. On hardware without vector extension support, this resulted
in reading a nonexistent register.
2025-03-10 10:13:33 +01:00
Ming-Yi Lai
507e413a2d [libunwind][NFC] Remove the CET keyword in shadow stack-related stuffs (#126663)
libunwind currently supports shadow stack based on the Intel CET and
AArch64 GCS technology, but throughout related codes, the Intel-specific
keyword, "CET", is used to refer to the generic concept of control-flow
integrity/shadow stack. This patch replaces such wordings with
architecture-neutral term "shadow stack" (abbr. "shstk") to allow future
implementation to avoid using the Intel-specific "CET" term.
2025-02-20 16:12:16 +08:00
Yuriy Chernyshov
f4206f92c5 [libunwind] Silence -Wunused-parameter warnings in Unwind-wasm.c (#125412) 2025-02-17 08:39:18 -05:00
Ami-zhang
12a154a94a [libunwind] Unwind through loongarch64/Linux sigreturn frame (#123682)
Similar to D90898 (Linux AArch64), D124765 (SystemZ), and D148499
(RISCV).

In this commit, I enabled two test cases, while zhuqizheng supported
with the source code development.

Co-Authored-By: zhuqizheng <zhuqizheng@loongson.cn>

Co-authored-by: zhuqizheng <zhuqizheng@loongson.cn>
2025-02-08 09:48:41 +08:00
Paul Kirth
92f1f99d2e [libunwind][cmake] Compile _Unwind* routines with -fexceptions (#121819)
When building libunwind with LTO, we found that routines, like
_Unwind_RaiseException were marked `nounwind`. This causes problems when
libunwind is then used with exception throwing code, since many of the
routines are marked `nounwind` and the compiler infers that something
like a try/catch block cannot throw resulting in a miscompile
(see #120657). Similarly, in #56825, it was pointed out that marking
_Unwind_Resume as `nounwind` causes bad exception table generation.

This patch adds the `-fexceptions` flag to the build of the C files that
define these routines, as proposed in #56825.

Fixes #56825 #120657

---------

Co-authored-by: Petr Hosek <phosek@google.com>
2025-01-16 13:44:55 -08:00
Alex Rønne Petersen
eb1f9cced9 [libunwind] Fix compilation for the x32 ABI. (#116608)
This would previously fail the static assertions in `UnwindCursor.hpp`
due to `UnwindCursor`'s size not matching `unw_cursor_t`'s size. As is
done for MIPS N32, this just declares the appropriate size in
`__libunwind_config.h`.
2024-12-15 05:57:51 -05:00
Louis Dionne
b0b546d447 [libc++abi] Provide an explicit error when trying to build for MSVC (#119370)
Fixes #119322
2024-12-11 12:49:06 -05:00
Sergei Barannikov
426aecb7e9 [libunwind] Fix a typo in debug print (#118856) 2024-12-06 01:22:14 +03:00
Jérôme Duval
3b904ae5ac [libunwind][Haiku] Improve support (#115462)
* Signal frame unwinding on x86_64 from X512
* Header search for commpage_defs.h on non-standard paths

Unwind supported tests pass on Haiku x86_64

---------

Co-authored-by: Trung Nguyen <trungnt282910@gmail.com>
2024-12-04 10:40:28 -05:00
Keith Packard
5a8956ea8b [compiler-rt][libunwind] Support aarch64 without FPU (#111235)
These two libraries don't build for `-march=armv8-a+nofp
-mabi=aapcs-soft` as a couple of uses of floating point instructions and
registers have crept in.

In libunwind, skip save/restore of FPU registers on targets without them.
In compiler-rt, fall back to the old C implementation of __arm_sc_memset when
the target doesn't have an FPU.

---------

Signed-off-by: Keith Packard <keithp@keithp.com>
2024-11-07 08:32:45 -08:00
Louis Dionne
e236a52a88 [libc++] Unify the benchmarks with the test suite (#101399)
Instead of building the benchmarks separately via CMake and running them
separately from the test suite, this patch merges the benchmarks into
the test suite and handles both uniformly.

As a result:
- It is now possible to run individual benchmarks like we run tests
  (e.g. using libcxx-lit), which is a huge quality-of-life improvement.

- The benchmarks will be run under exactly the same configuration as
  the rest of the tests, which is a nice simplification. This does
  mean that one has to be careful to enable the desired optimization
  flags when running benchmarks, but that is easy with e.g.
  `libcxx-lit <...> --param optimization=speed`.

- Benchmarks can use the same annotations as the rest of the test
  suite, such as `// UNSUPPORTED` & friends.

When running the tests via `check-cxx`, we only compile the benchmarks
because running them would be too time consuming. This introduces a bit
of complexity in the testing setup, and instead it would be better to
allow passing a --dry-run flag to GoogleBenchmark executables, which is
the topic of https://github.com/google/benchmark/issues/1827.

I am not really satisfied with the layering violation of adding the
%{benchmark_flags} substitution to cmake-bridge, however I believe
this can be improved in the future.
2024-11-07 09:07:50 -05:00
Louis Dionne
6127724786 [cmake] Remove obsolete files, docs and CMake variables related to the standalone build (#112741)
The runtimes used to support a build mode called the "Standalone build",
which isn't supported anymore (and hasn't been for a few years).
However, various places in the code still contained stuff whose only
purpose was to support that build mode, and some outdated documentation.
This patch cleans that up (although I probably missed some).

- Remove HandleOutOfTreeLLVM.cmake which isn't referenced anymore
- Remove the LLVM_PATH CMake variable which isn't used anymore
- Update some outdated documentation referencing standalone builds
2024-11-04 17:53:38 -05:00
Aaron Ballman
0ab44fd246 Replace documentation mentions of IRC with Discord (#114276)
This does not touch code owners or credits files that list IRC handles,
that can be done separately if we want to make that change.

See
https://discourse.llvm.org/t/rfc-remove-irc-as-a-recommended-communication-channel/82808/3
for the RFC.
2024-10-31 09:22:46 -04:00
Jack Styles
86f76c3b17 [AArch64][Libunwind] Add Support for FEAT_PAuthLR DWARF Instruction (#112171)
As part of FEAT_PAuthLR, a new DWARF Frame Instruction was introduced,
`DW_CFA_AARCH64_negate_ra_state_with_pc`. This instructs Libunwind that
the PC has been used with the signing instruction. This change includes
three commits
- Libunwind support for the newly introduced DWARF Instruction
- CodeGen Support for the DWARF Instructions
- Reversing the changes made in #96377. Due to
`DW_CFA_AARCH64_negate_ra_state_with_pc`'s requirements to be placed
immediately after the signing instruction, this would mean the CFI
Instruction location was not consistent with the generated location when
not using FEAT_PAuthLR. The commit reverses the changes and makes the
location consistent across the different branch protection options.
While this does have a code size effect, this is a negligible one.

For the ABI information, see here:
853286c7ab/aadwarf64/aadwarf64.rst (id23)
2024-10-28 08:22:38 +00:00
Vitaly Buka
240e478068 Revert "[runtimes] Probe for -nostdlib++ and -nostdinc++ with the C compiler" (#113653)
Reverts llvm/llvm-project#108357

Breaks https://lab.llvm.org/buildbot/#/builders/164/builds/3908 and
similar bots
2024-10-25 09:12:32 +03:00
Martin Storsjö
75d0281bc8 [runtimes] Probe for -nostdlib++ and -nostdinc++ with the C compiler (#108357)
While these flags semantically are relevant only for C++, we do add them
to CMAKE_REQUIRED_FLAGS if they are detected. All flags in that variable
are used both when testing compilation of C and C++ (and for detecting
libraries, which uses the C compiler driver).

Therefore, to be sure we safely can add the flags to
CMAKE_REQUIRED_FLAGS, test for the option with the C language.

This should fix compilation with GCC; newer versions of GCC do support
the -nostdlib++ option, but it's only supported by the C++ compiler
driver, not the C driver. (However, many builds of GCC also do accept
the option with the C driver, if GCC was compiled with Ada support
enabled, see [1]. That's why this issue isn't noticed in all
configurations with GCC.)

Clang does support these options in both C and C++ driver modes.

This should fix #90332.

[1]
https://github.com/llvm/llvm-project/issues/90332#issuecomment-2325099254
2024-10-24 23:46:04 +03:00
Xing Xue
dde26e361f [libunwind][AIX] Call dlclose only when dlsym() fails (#112768)
The personality routine `__xlcxx_personality_v0` in `libc++abi` is
hard-coded in the unwinder as the handler for EH in applications
generated by the legacy IBM C++ compiler. The symbol is resolved
dynamically using `dlopen` to avoid a hard dependency of `libunwind` on
`libc++abi` for cases such as non-C++ applications. However, `dlclose`
was incorrectly called after `dlsym` succeeded, potentially invalidating
the function pointer obtained from `dlsym` when the memory allocated for
the `dlopen` is reclaimed. This PR changes to call `dlclose` only when
`dlsym` fails.
2024-10-19 18:41:06 -04:00
Louis Dionne
e67442486d [runtimes] Improve the documentation for LIBCXX_ADDITIONAL_COMPILE_FLAGS (#112733)
This clarifies how that option is meant to be used to avoid confusion.
As a drive-by, also fix an incorrect usage in the recently-added GPU
caches.
2024-10-17 16:17:40 -04:00
Louis Dionne
8c77f4c508 [runtimes] Avoid cluttering the top-level build directory with test artifacts (#112717)
Instead of placing artifacts for testing the runtimes at <build>/test,
place those artifacts at <build>/<project>/test. This prevents
cluttering the build directory with the runtimes' test artifacts for
everyone else.

As a drive-by, remove LIBCXX_BINARY_INCLUDE_DIR which wasn't used
anymore.
2024-10-17 16:15:33 -04:00
Xing Xue
2ef24e05de [libunwind][AIX] Remove weak declaration "__xlcxx_personality_v0" (#112436)
`__xlcxx_personality_v0` is the personality routine in `libc++abi` for
the EH of applications generated by the legacy IBM C++ compiler. Since
the EH info generated by the legacy compiler does not provide the
location of the personality routine, this routine is hard-coded as the
handler for legacy EH in the unwinder. The symbol is resolved
dynamically using `dlopen()` to avoid a hard dependency of `libunwind`
on `libc++abi` for cases such as non-C++ applications. The weak
declaration of `__xlcxx_personality_v0` was originally intended to
bypass `dlopen()` if the C++ application generated by the legacy
compiler is statically linked with the new LLVM C++ compiler.
Unfortunately, this causes problems with runtime linking for
Clang-compiled code using the unwinder that does not link with
`libc++abi`.

On the other hand, the C++ runtime libraries shipped for AIX are
actually stripped and statically linking is not supported. So, we can
fix the problem by removing the `__xlcxx_personality_v0` weak
declaration. Besides, `dlopen()` would work as long as the libc++abi
shared library is available.
2024-10-17 13:07:18 -04:00
Louis Dionne
43ba97e707 [runtimes][NFC] Reindent CMake files (#111821)
This is a purely mechanical commit for fixing the indentation of the
runtimes' CMakeLists files after #80007. That PR didn't update the
indentation in order to make the diff easier to review and for merge
conflicts to be easier to resolve (for downstream changes).

This doesn't change any code, it only reindents it.
2024-10-10 13:13:17 -04:00
Louis Dionne
917ada35cd [runtimes] Always define cxx_shared, cxx_static & other targets (#80007)
This patch always defines the cxx_shared, cxx_static & other top-level
targets. However, they are marked as EXCLUDE_FROM_ALL when we don't want
to build them. Simply declaring the targets should be of no harm, and it
allows other projects to mention these targets regardless of whether
they end up being built or not.

This patch basically moves the definition of e.g. cxx_shared out of the
`if (LIBCXX_ENABLE_SHARED)` and instead marks it as EXCLUDE_FROM_ALL
conditionally on whether LIBCXX_ENABLE_SHARED is passed. It then does
the same for libunwind and libc++abi targets. I purposefully avoided to
reformat the files (which now has inconsistent indentation) because I
wanted to keep the diff minimal, and I know this is an area of the code
where folks may have downstream diffs. I will re-indent the code
separately once this patch lands.

This is a reapplication of 79ee0342db, which was reverted in
a353909088 because it broke the TSAN and the Fuchsia builds.

Resolves #77654

Differential Revision: https://reviews.llvm.org/D134221
2024-10-10 08:00:01 -04:00
Haowei
3a6b89540e [libunwind] Fix libunwind library path for runtime test (#110777)
This patch fixes an issue when test runner cannot find libwind library
when LLVM_ENABLE_PER_TARGET_RUNTIME_DIR is used.
2024-10-02 14:52:58 -04:00