Skip to content

Add compiler-rt build for LLVM 15#1

Merged
sklam merged 3 commits intosklam:enh/llvm15_conda_buildscriptfrom
gmarkall:llvmdev-15-compiler-rt
Apr 15, 2024
Merged

Add compiler-rt build for LLVM 15#1
sklam merged 3 commits intosklam:enh/llvm15_conda_buildscriptfrom
gmarkall:llvmdev-15-compiler-rt

Conversation

@gmarkall
Copy link

@gmarkall gmarkall commented Apr 15, 2024

This is based on numba#979.

Notes:

  • It is a little simpler than that PR because there are fewer issues to deal with when building within the llvm-project tree.
  • A couple of patches are required - one from Update llvmdev to build compiler-rt numba/llvmlite#979, and one to fix the compiler-rt build with clang 18 on MacOS (backporting an actual fix)
  • I have tested the builds locally on all supported platforms (Linux-64, Linux-aarch64, Linux-ppcle64, osx-64, osx-aarch64, Windows-64) and manually verified symbol visibility and inspected the disassembly to ensure that the compiler-rt builtins libraries are present and available for linking as expected.
  • I uploaded packages I built to my conda channel: https://anaconda.org/gmarkall/llvmdev/files - note that because I built them on my Linux system, there seems to be some conda weirdness with a __unix0 metapackage (or something similar) which means they won't install on some systems, but I don't expect this to be an issue with a buildfarm build.

A lot of the work here is done by @oliverhu - I have re-packaged it here for the LLVM 15 conda recipe PR.

gmarkall and others added 3 commits April 15, 2024 14:16
This is a backport of:

```
commit 7939ce39dac0078fef7183d6198598b99c652c88
Author: Jon Roelofs <jonathan_roelofs@apple.com>
Date:   Fri Nov 17 14:21:57 2023 -0800

    [builtins] Move cfi start's after the symbol name [NFC]

    ... in preparation for diagnosing improperly nested .cfi regions.

    See https://reviews.llvm.org/D155245
```

The ordering of `.cfi_startproc` and the function name in compiler-rt's
`assembly.h` triggers a new diagnostic about improperly nested `.cfi`
regions in Clang 18 onwards. This is fixed in compiler-rt upstream, but
needs to be applied to compiler-rt from LLVM 15 because we're building
it with Clang 18 in some cases.

References to discussions of the issue:

- rust-lang/llvm-project@8238831
- https://issues.chromium.org/issues/40945072
The symbols in the compiler-rt builtins library are private external by
default on MacOS. We need them to be visible so we can link against them
(e.g. when building libllvmlite.so). This patch makes the symbols
visible when the CMake option `COMPILER_RT_BUILTINS_HIDE_SYMBOLS` is
off. Note that this is an existing option for the compiler-rt build, and
the flags requiring modification in this patch appear to be an
oversight.

References:

- https://discourse.llvm.org/t/lld-automatically-hide-symbols-with-prefix/73192
- numba#986 (comment)
This enables the build of compiler-rt builtins with the following
changes:

- Add `compiler-rt` to the list of LLVM projects to build
- Disable the build of all `compiler-rt` components except for the
  builtins. Whilst it would be interesting to add these, they seem to
  require clang to be built at the same time.
- Setting the `COMPILER_RT_BUILTINS_HIDE_SYMBOLS` CMake option to `OFF`,
  to ensure that we can link against those symbols in the general case.

Note that these changes are simpler than previous efforts towards
enabling `compiler-rt` builtins (e.g. numba#979) - this is because we now
build as part of the whole `llvm-project` tree, which simplifies things
and removes issues that had to be worked around when building it
separately.
@gmarkall
Copy link
Author

Quick update - the linux-ppcle64 build also completed successfully, so as far as I can ascertain, all is well here.

@sklam sklam merged commit cba5fc8 into sklam:enh/llvm15_conda_buildscript Apr 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants