diff options
author | 2025-08-04 13:54:57 +0200 | |
---|---|---|
committer | 2025-08-06 14:29:19 +0200 | |
commit | e6d53eab57db5cacde6735750ebd51ef0b6fbf0b (patch) | |
tree | 893c82a7939cfaab7280db647609ccb0c1451bc6 | |
parent | llvm-runtimes/libcxxabi: Support build with cross emerge wrapper (diff) | |
download | gentoo-e6d53eab57db5cacde6735750ebd51ef0b6fbf0b.tar.gz gentoo-e6d53eab57db5cacde6735750ebd51ef0b6fbf0b.tar.bz2 gentoo-e6d53eab57db5cacde6735750ebd51ef0b6fbf0b.zip |
llvm-runtimes/libcxx: 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 <[email protected]>
Part-of: https://github.com/gentoo/gentoo/pull/39280
Signed-off-by: Michał Górny <[email protected]>
Part-of: https://github.com/gentoo/gentoo/pull/39280
Signed-off-by: Michał Górny <[email protected]>
-rw-r--r-- | llvm-runtimes/libcxx/libcxx-19.1.7.ebuild | 5 | ||||
-rw-r--r-- | llvm-runtimes/libcxx/libcxx-20.1.8.ebuild | 5 | ||||
-rw-r--r-- | llvm-runtimes/libcxx/libcxx-21.1.0.9999.ebuild | 5 | ||||
-rw-r--r-- | llvm-runtimes/libcxx/libcxx-22.0.0.9999.ebuild | 5 |
4 files changed, 12 insertions, 8 deletions
diff --git a/llvm-runtimes/libcxx/libcxx-19.1.7.ebuild b/llvm-runtimes/libcxx/libcxx-19.1.7.ebuild index 00dd72b37153..c5649f641a28 100644 --- a/llvm-runtimes/libcxx/libcxx-19.1.7.ebuild +++ b/llvm-runtimes/libcxx/libcxx-19.1.7.ebuild @@ -65,8 +65,6 @@ test_compiler() { } src_configure() { - llvm_prepend_path "${LLVM_MAJOR}" - local install_prefix=${EPREFIX} is_crosspkg && install_prefix+=/usr/${CTARGET} @@ -87,6 +85,7 @@ src_configure() { multilib_src_configure() { if use clang; then + llvm_prepend_path -b "${LLVM_MAJOR}" local -x CC=${CTARGET}-clang local -x CXX=${CTARGET}-clang++ strip-unsupported-flags @@ -114,6 +113,8 @@ multilib_src_configure() { local libdir=$(get_libdir) local mycmakeargs=( + -DLLVM_ROOT="${ESYSROOT}/usr/lib/llvm/${LLVM_MAJOR}" + -DCMAKE_CXX_COMPILER_TARGET="${CTARGET}" -DPython3_EXECUTABLE="${PYTHON}" -DLLVM_ENABLE_RUNTIMES=libcxx diff --git a/llvm-runtimes/libcxx/libcxx-20.1.8.ebuild b/llvm-runtimes/libcxx/libcxx-20.1.8.ebuild index 3b1f3f487fa0..ac2a1dba2e07 100644 --- a/llvm-runtimes/libcxx/libcxx-20.1.8.ebuild +++ b/llvm-runtimes/libcxx/libcxx-20.1.8.ebuild @@ -67,8 +67,6 @@ test_compiler() { } src_configure() { - llvm_prepend_path "${LLVM_MAJOR}" - local install_prefix=${EPREFIX} is_crosspkg && install_prefix+=/usr/${CTARGET} @@ -89,6 +87,7 @@ src_configure() { multilib_src_configure() { if use clang; then + llvm_prepend_path -b "${LLVM_MAJOR}" local -x CC=${CTARGET}-clang local -x CXX=${CTARGET}-clang++ strip-unsupported-flags @@ -116,6 +115,8 @@ multilib_src_configure() { local libdir=$(get_libdir) local mycmakeargs=( + -DLLVM_ROOT="${ESYSROOT}/usr/lib/llvm/${LLVM_MAJOR}" + -DCMAKE_CXX_COMPILER_TARGET="${CTARGET}" -DPython3_EXECUTABLE="${PYTHON}" -DLLVM_ENABLE_RUNTIMES=libcxx diff --git a/llvm-runtimes/libcxx/libcxx-21.1.0.9999.ebuild b/llvm-runtimes/libcxx/libcxx-21.1.0.9999.ebuild index 940a5893f521..935dea8bfb0f 100644 --- a/llvm-runtimes/libcxx/libcxx-21.1.0.9999.ebuild +++ b/llvm-runtimes/libcxx/libcxx-21.1.0.9999.ebuild @@ -66,8 +66,6 @@ test_compiler() { } src_configure() { - llvm_prepend_path "${LLVM_MAJOR}" - local install_prefix=${EPREFIX} is_crosspkg && install_prefix+=/usr/${CTARGET} @@ -88,6 +86,7 @@ src_configure() { multilib_src_configure() { if use clang; then + llvm_prepend_path -b "${LLVM_MAJOR}" local -x CC=${CTARGET}-clang local -x CXX=${CTARGET}-clang++ strip-unsupported-flags @@ -115,6 +114,8 @@ multilib_src_configure() { local libdir=$(get_libdir) local mycmakeargs=( + -DLLVM_ROOT="${ESYSROOT}/usr/lib/llvm/${LLVM_MAJOR}" + -DCMAKE_CXX_COMPILER_TARGET="${CTARGET}" -DPython3_EXECUTABLE="${PYTHON}" -DLLVM_ENABLE_RUNTIMES=libcxx diff --git a/llvm-runtimes/libcxx/libcxx-22.0.0.9999.ebuild b/llvm-runtimes/libcxx/libcxx-22.0.0.9999.ebuild index 940a5893f521..935dea8bfb0f 100644 --- a/llvm-runtimes/libcxx/libcxx-22.0.0.9999.ebuild +++ b/llvm-runtimes/libcxx/libcxx-22.0.0.9999.ebuild @@ -66,8 +66,6 @@ test_compiler() { } src_configure() { - llvm_prepend_path "${LLVM_MAJOR}" - local install_prefix=${EPREFIX} is_crosspkg && install_prefix+=/usr/${CTARGET} @@ -88,6 +86,7 @@ src_configure() { multilib_src_configure() { if use clang; then + llvm_prepend_path -b "${LLVM_MAJOR}" local -x CC=${CTARGET}-clang local -x CXX=${CTARGET}-clang++ strip-unsupported-flags @@ -115,6 +114,8 @@ multilib_src_configure() { local libdir=$(get_libdir) local mycmakeargs=( + -DLLVM_ROOT="${ESYSROOT}/usr/lib/llvm/${LLVM_MAJOR}" + -DCMAKE_CXX_COMPILER_TARGET="${CTARGET}" -DPython3_EXECUTABLE="${PYTHON}" -DLLVM_ENABLE_RUNTIMES=libcxx |