From ec4e0f71bc9a31613234efe5ea5685c46feaa2b2 Mon Sep 17 00:00:00 2001 From: Michal Rostecki Date: Mon, 4 Aug 2025 13:54:44 +0200 Subject: [PATCH] llvm-runtimes/libcxxabi: Support build with cross emerge wrapper MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 Part-of: https://github.com/gentoo/gentoo/pull/39280 Signed-off-by: Michał Górny Part-of: https://github.com/gentoo/gentoo/pull/39280 Signed-off-by: Michał Górny --- llvm-runtimes/libcxxabi/libcxxabi-19.1.7.ebuild | 5 +++-- llvm-runtimes/libcxxabi/libcxxabi-20.1.8.ebuild | 5 +++-- llvm-runtimes/libcxxabi/libcxxabi-21.1.0.9999.ebuild | 5 +++-- llvm-runtimes/libcxxabi/libcxxabi-22.0.0.9999.ebuild | 5 +++-- 4 files changed, 12 insertions(+), 8 deletions(-) diff --git a/llvm-runtimes/libcxxabi/libcxxabi-19.1.7.ebuild b/llvm-runtimes/libcxxabi/libcxxabi-19.1.7.ebuild index a91a67d493023..6c3f4635d98db 100644 --- a/llvm-runtimes/libcxxabi/libcxxabi-19.1.7.ebuild +++ b/llvm-runtimes/libcxxabi/libcxxabi-19.1.7.ebuild @@ -47,9 +47,8 @@ python_check_deps() { } multilib_src_configure() { - llvm_prepend_path "${LLVM_MAJOR}" - if use clang; then + llvm_prepend_path -b "${LLVM_MAJOR}" local -x CC=${CTARGET}-clang local -x CXX=${CTARGET}-clang++ strip-unsupported-flags @@ -61,6 +60,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="libcxxabi;libcxx" diff --git a/llvm-runtimes/libcxxabi/libcxxabi-20.1.8.ebuild b/llvm-runtimes/libcxxabi/libcxxabi-20.1.8.ebuild index 1568639429649..5668a32deb268 100644 --- a/llvm-runtimes/libcxxabi/libcxxabi-20.1.8.ebuild +++ b/llvm-runtimes/libcxxabi/libcxxabi-20.1.8.ebuild @@ -47,9 +47,8 @@ python_check_deps() { } multilib_src_configure() { - llvm_prepend_path "${LLVM_MAJOR}" - if use clang; then + llvm_prepend_path -b "${LLVM_MAJOR}" local -x CC=${CTARGET}-clang local -x CXX=${CTARGET}-clang++ strip-unsupported-flags @@ -61,6 +60,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="libcxxabi;libcxx" diff --git a/llvm-runtimes/libcxxabi/libcxxabi-21.1.0.9999.ebuild b/llvm-runtimes/libcxxabi/libcxxabi-21.1.0.9999.ebuild index 366ac2ab422eb..f929e4caf008f 100644 --- a/llvm-runtimes/libcxxabi/libcxxabi-21.1.0.9999.ebuild +++ b/llvm-runtimes/libcxxabi/libcxxabi-21.1.0.9999.ebuild @@ -48,9 +48,8 @@ python_check_deps() { } multilib_src_configure() { - llvm_prepend_path "${LLVM_MAJOR}" - if use clang; then + llvm_prepend_path -b "${LLVM_MAJOR}" local -x CC=${CTARGET}-clang local -x CXX=${CTARGET}-clang++ strip-unsupported-flags @@ -62,6 +61,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="libcxxabi;libcxx" diff --git a/llvm-runtimes/libcxxabi/libcxxabi-22.0.0.9999.ebuild b/llvm-runtimes/libcxxabi/libcxxabi-22.0.0.9999.ebuild index 366ac2ab422eb..f929e4caf008f 100644 --- a/llvm-runtimes/libcxxabi/libcxxabi-22.0.0.9999.ebuild +++ b/llvm-runtimes/libcxxabi/libcxxabi-22.0.0.9999.ebuild @@ -48,9 +48,8 @@ python_check_deps() { } multilib_src_configure() { - llvm_prepend_path "${LLVM_MAJOR}" - if use clang; then + llvm_prepend_path -b "${LLVM_MAJOR}" local -x CC=${CTARGET}-clang local -x CXX=${CTARGET}-clang++ strip-unsupported-flags @@ -62,6 +61,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="libcxxabi;libcxx"