commit: 2fd5c49ba14561033c5891d3acc9690e2991c053
Author: Michal Rostecki <vadorovsky <AT> protonmail <DOT> com>
AuthorDate: Mon Aug 4 11:53:09 2025 +0000
Commit: Michał Górny <mgorny <AT> gentoo <DOT> org>
CommitDate: Wed Aug 6 12:29:17 2025 +0000
URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=2fd5c49b
llvm-runtimes/compiler-rt: Support build with cross emerge wrapper
When cross emerge wrapper is used, using `llvm_prepend_path` without
any options, results in prepending the following path:
```
${ESYSROOT}/usr/lib/llvm/${slot}/bin
```
For example:
```
/usr/aarch64-unknown-linux-musl/usr/lib/llvm/19/bin
```
The problem is that cross emerge wrapper uses a cross clang wrapper as
a compiler, e.g. `aarch64-unknown-linux-musl-clang`. However, the file
with such name can be usually found in two places:
* `/usr/lib/llvm/19/bin/aarch64-unknown-linux-musl-clang`, which is
a clang wrapper that calls the host clang with appropriate
configuration. We want to call that file.
*
`/usr/aarch64-unknown-linux-musl/usr/lib/llvm/19/bin/aarch64-unknown-linux-musl-clang`,
which is an actual aarch64 compiler binary. We cannot execute it on
x86_64, or other incompatible host.
However, the path added by `llvm_prepend_path` causes resolution of
`aarch64-unknown-linux-musl-clang` to the second path, therefore causing
errors like:
```
/usr/aarch64-unknown-linux-musl/usr/lib/llvm/19/bin/clang: cannot execute
binary file: Exec format error
```
Solve that by:
* Using `LLVM_ROOT` CMake parameter to point the build to LLVM library
artifacts.
* Using `llvm_prepend_path` with `-b` argument if we need clang, which
is the case when either `clang` or `test` USE flags are enabled.
Signed-off-by: Michal Rostecki <vadorovsky <AT> protonmail.com>
Part-of: https://github.com/gentoo/gentoo/pull/39280
Signed-off-by: Michał Górny <mgorny <AT> gentoo.org>
Part-of: https://github.com/gentoo/gentoo/pull/39280
Signed-off-by: Michał Górny <mgorny <AT> gentoo.org>
llvm-runtimes/compiler-rt/compiler-rt-19.1.7.ebuild | 7 +++++--
llvm-runtimes/compiler-rt/compiler-rt-20.1.8.ebuild | 5 ++++-
llvm-runtimes/compiler-rt/compiler-rt-21.1.0.9999.ebuild | 5 ++++-
llvm-runtimes/compiler-rt/compiler-rt-22.0.0.9999.ebuild | 5 ++++-
4 files changed, 17 insertions(+), 5 deletions(-)
diff --git a/llvm-runtimes/compiler-rt/compiler-rt-19.1.7.ebuild
b/llvm-runtimes/compiler-rt/compiler-rt-19.1.7.ebuild
index cbefa7c69ba6..f69ea53263c0 100644
--- a/llvm-runtimes/compiler-rt/compiler-rt-19.1.7.ebuild
+++ b/llvm-runtimes/compiler-rt/compiler-rt-19.1.7.ebuild
@@ -3,7 +3,7 @@
EAPI=8
-PYTHON_COMPAT=( python3_{10..13} )
+PYTHON_COMPAT=( python3_{11..13} )
inherit cmake crossdev flag-o-matic llvm.org llvm-utils python-any-r1
inherit toolchain-funcs
@@ -64,7 +64,9 @@ test_compiler() {
}
src_configure() {
- llvm_prepend_path "${LLVM_MAJOR}"
+ if use clang || use test; then
+ llvm_prepend_path -b "${LLVM_MAJOR}"
+ fi
# LLVM_ENABLE_ASSERTIONS=NO does not guarantee this for us, #614844
use debug || local -x CPPFLAGS="${CPPFLAGS} -DNDEBUG"
@@ -101,6 +103,7 @@ src_configure() {
local mycmakeargs=(
-DCOMPILER_RT_INSTALL_PATH="${EPREFIX}/usr/lib/clang/${LLVM_MAJOR}"
+ -DLLVM_ROOT="${ESYSROOT}/usr/lib/llvm/${LLVM_MAJOR}"
-DCOMPILER_RT_EXCLUDE_ATOMIC_BUILTIN=$(usex !atomic-builtins)
-DCOMPILER_RT_INCLUDE_TESTS=$(usex test)
diff --git a/llvm-runtimes/compiler-rt/compiler-rt-20.1.8.ebuild
b/llvm-runtimes/compiler-rt/compiler-rt-20.1.8.ebuild
index 06f23e36b4ad..b69c52abd821 100644
--- a/llvm-runtimes/compiler-rt/compiler-rt-20.1.8.ebuild
+++ b/llvm-runtimes/compiler-rt/compiler-rt-20.1.8.ebuild
@@ -64,7 +64,9 @@ test_compiler() {
}
src_configure() {
- llvm_prepend_path "${LLVM_MAJOR}"
+ if use clang || use test; then
+ llvm_prepend_path -b "${LLVM_MAJOR}"
+ fi
# LLVM_ENABLE_ASSERTIONS=NO does not guarantee this for us, #614844
use debug || local -x CPPFLAGS="${CPPFLAGS} -DNDEBUG"
@@ -101,6 +103,7 @@ src_configure() {
local mycmakeargs=(
-DCOMPILER_RT_INSTALL_PATH="${EPREFIX}/usr/lib/clang/${LLVM_MAJOR}"
+ -DLLVM_ROOT="${ESYSROOT}/usr/lib/llvm/${LLVM_MAJOR}"
-DCOMPILER_RT_EXCLUDE_ATOMIC_BUILTIN=$(usex !atomic-builtins)
-DCOMPILER_RT_INCLUDE_TESTS=$(usex test)
diff --git a/llvm-runtimes/compiler-rt/compiler-rt-21.1.0.9999.ebuild
b/llvm-runtimes/compiler-rt/compiler-rt-21.1.0.9999.ebuild
index 18238ea1344c..2a785527c374 100644
--- a/llvm-runtimes/compiler-rt/compiler-rt-21.1.0.9999.ebuild
+++ b/llvm-runtimes/compiler-rt/compiler-rt-21.1.0.9999.ebuild
@@ -63,7 +63,9 @@ test_compiler() {
}
src_configure() {
- llvm_prepend_path "${LLVM_MAJOR}"
+ if use clang || use test; then
+ llvm_prepend_path -b "${LLVM_MAJOR}"
+ fi
# LLVM_ENABLE_ASSERTIONS=NO does not guarantee this for us, #614844
use debug || local -x CPPFLAGS="${CPPFLAGS} -DNDEBUG"
@@ -100,6 +102,7 @@ src_configure() {
local mycmakeargs=(
-DCOMPILER_RT_INSTALL_PATH="${EPREFIX}/usr/lib/clang/${LLVM_MAJOR}"
+ -DLLVM_ROOT="${ESYSROOT}/usr/lib/llvm/${LLVM_MAJOR}"
-DCOMPILER_RT_EXCLUDE_ATOMIC_BUILTIN=$(usex !atomic-builtins)
-DCOMPILER_RT_INCLUDE_TESTS=$(usex test)
diff --git a/llvm-runtimes/compiler-rt/compiler-rt-22.0.0.9999.ebuild
b/llvm-runtimes/compiler-rt/compiler-rt-22.0.0.9999.ebuild
index 18238ea1344c..2a785527c374 100644
--- a/llvm-runtimes/compiler-rt/compiler-rt-22.0.0.9999.ebuild
+++ b/llvm-runtimes/compiler-rt/compiler-rt-22.0.0.9999.ebuild
@@ -63,7 +63,9 @@ test_compiler() {
}
src_configure() {
- llvm_prepend_path "${LLVM_MAJOR}"
+ if use clang || use test; then
+ llvm_prepend_path -b "${LLVM_MAJOR}"
+ fi
# LLVM_ENABLE_ASSERTIONS=NO does not guarantee this for us, #614844
use debug || local -x CPPFLAGS="${CPPFLAGS} -DNDEBUG"
@@ -100,6 +102,7 @@ src_configure() {
local mycmakeargs=(
-DCOMPILER_RT_INSTALL_PATH="${EPREFIX}/usr/lib/clang/${LLVM_MAJOR}"
+ -DLLVM_ROOT="${ESYSROOT}/usr/lib/llvm/${LLVM_MAJOR}"
-DCOMPILER_RT_EXCLUDE_ATOMIC_BUILTIN=$(usex !atomic-builtins)
-DCOMPILER_RT_INCLUDE_TESTS=$(usex test)