From: "Michał Górny" <mgorny@gentoo.org>
To: gentoo-commits@lists.gentoo.org
Subject: [gentoo-commits] repo/gentoo:master commit in: llvm-runtimes/libcxx/
Date: Mon, 17 Mar 2025 06:22:43 +0000 (UTC) [thread overview]
Message-ID: <1742192496.4b9aa358421f60057eb35ba5ab5c73945d7fca8b.mgorny@gentoo> (raw)
commit: 4b9aa358421f60057eb35ba5ab5c73945d7fca8b
Author: Michal Rostecki <vadorovsky <AT> protonmail <DOT> com>
AuthorDate: Mon Dec 2 14:04:51 2024 +0000
Commit: Michał Górny <mgorny <AT> gentoo <DOT> org>
CommitDate: Mon Mar 17 06:21:36 2025 +0000
URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=4b9aa358
sys-libs/libcxx: Support cross build
Inherit the `crossdev` eclass and use a cross sysroot when a custom
target is specified. That allows to bootstrap libcxx with crossdev.
Extend the compiler test with the case when the (cross) toolchain has
a runtime, but doesn't have stdlib yet (because it's about to be built).
In such case, a build with default arguments fails, but a build with
`-nostdlib` succeeds. libc++ doesn't need stdlib to build, so that's
fine.
Signed-off-by: Michal Rostecki <vadorovsky <AT> protonmail.com>
Signed-off-by: Michał Górny <mgorny <AT> gentoo.org>
...ibcxx-20.1.0.ebuild => libcxx-19.1.7-r1.ebuild} | 59 ++++++++++++++--------
llvm-runtimes/libcxx/libcxx-20.1.0.ebuild | 50 +++++++++++++-----
llvm-runtimes/libcxx/libcxx-21.0.0.9999.ebuild | 50 +++++++++++++-----
3 files changed, 112 insertions(+), 47 deletions(-)
diff --git a/llvm-runtimes/libcxx/libcxx-20.1.0.ebuild b/llvm-runtimes/libcxx/libcxx-19.1.7-r1.ebuild
similarity index 74%
copy from llvm-runtimes/libcxx/libcxx-20.1.0.ebuild
copy to llvm-runtimes/libcxx/libcxx-19.1.7-r1.ebuild
index 75a626f221f8..08e54cd9b566 100644
--- a/llvm-runtimes/libcxx/libcxx-20.1.0.ebuild
+++ b/llvm-runtimes/libcxx/libcxx-19.1.7-r1.ebuild
@@ -4,8 +4,8 @@
EAPI=8
PYTHON_COMPAT=( python3_{10..13} )
-inherit cmake-multilib flag-o-matic llvm.org llvm-utils python-any-r1
-inherit toolchain-funcs
+inherit cmake-multilib crossdev flag-o-matic llvm.org llvm-utils
+inherit python-any-r1 toolchain-funcs
DESCRIPTION="New implementation of the C++ standard library, targeting C++11"
HOMEPAGE="https://libcxx.llvm.org/"
@@ -40,9 +40,7 @@ BDEPEND="
)
"
-LLVM_COMPONENTS=(
- runtimes libcxx{,abi} libc llvm/{cmake,utils/llvm-lit} cmake
-)
+LLVM_COMPONENTS=( runtimes libcxx{,abi} llvm/{cmake,utils/llvm-lit} cmake )
llvm.org_set_globals
python_check_deps() {
@@ -69,12 +67,15 @@ test_compiler() {
src_configure() {
llvm_prepend_path "${LLVM_MAJOR}"
+ local install_prefix=${EPREFIX}
+ target_is_not_host && install_prefix+=/usr/${CTARGET}
+
# note: we need to do this before multilib kicks in since it will
# alter the CHOST
local cxxabi cxxabi_incs
if use libcxxabi; then
cxxabi=system-libcxxabi
- cxxabi_incs="${EPREFIX}/usr/include/c++/v1"
+ cxxabi_incs="${install_prefix}/usr/include/c++/v1"
else
local gcc_inc="${EPREFIX}/usr/lib/gcc/${CHOST}/$(gcc-fullversion)/include/g++-v$(gcc-major-version)"
cxxabi=libsupc++
@@ -86,8 +87,8 @@ src_configure() {
multilib_src_configure() {
if use clang; then
- local -x CC=${CHOST}-clang
- local -x CXX=${CHOST}-clang++
+ local -x CC=${CTARGET}-clang
+ local -x CXX=${CTARGET}-clang++
strip-unsupported-flags
fi
@@ -95,18 +96,29 @@ multilib_src_configure() {
local use_compiler_rt=OFF
[[ $(tc-get-c-rtlib) == compiler-rt ]] && use_compiler_rt=ON
- # bootstrap: cmake is unhappy if compiler can't link to stdlib
- local nolib_flags=( -nodefaultlibs -lc )
- if ! test_compiler; then
- if test_compiler "${nolib_flags[@]}"; then
- local -x LDFLAGS="${LDFLAGS} ${nolib_flags[*]}"
- ewarn "${CXX} seems to lack runtime, trying with ${nolib_flags[*]}"
+ # Scenarios to consider:
+ #
+ # 1. Compiler test works with the default flags.
+ # 2. There is a runtime library, but no stdlib. In that case, leave the
+ # LDFLAGS untouched, since there is no self-dependency in libc++.
+ # 3. There is no runtime library nor stdlib. In that case, overwrite the
+ # LDFLAGS.
+ local nostdlib_flags=( -nostdlib --rtlib=compiler-rt -lc )
+ local nort_flags=( -nodefaultlibs -lc )
+ if ! test_compiler && ! test_compiler "${nostdlib_flags[@]}"; then
+ if test_compiler "${nort_flags[@]}"; then
+ local -x LDFLAGS="${LDFLAGS} ${nort_flags[*]}"
+ ewarn "${CXX} seems to lack runtime, trying with ${nort_flags[*]}"
fi
fi
+ local install_prefix=${EPREFIX}
+ target_is_not_host && install_prefix+=/usr/${CTARGET}
+
local libdir=$(get_libdir)
local mycmakeargs=(
- -DCMAKE_CXX_COMPILER_TARGET="${CHOST}"
+ -DCMAKE_CXX_COMPILER_TARGET="${CTARGET}"
+ -DCMAKE_INSTALL_PREFIX="${install_prefix}/usr"
-DPython3_EXECUTABLE="${PYTHON}"
-DLLVM_ENABLE_RUNTIMES=libcxx
-DLLVM_INCLUDE_TESTS=OFF
@@ -126,7 +138,16 @@ multilib_src_configure() {
# this is broken with standalone builds, and also meaningless
-DLIBCXXABI_USE_LLVM_UNWINDER=OFF
)
-
+ if is_crosspkg; then
+ # Needed to target built libc headers
+ local -x CFLAGS="${CFLAGS} -isystem ${ESYSROOT}/usr/${CTARGET}/usr/include"
+ mycmakeargs+=(
+ # Without this, the compiler will compile a test program
+ # and fail due to no builtins.
+ -DCMAKE_C_COMPILER_WORKS=1
+ -DCMAKE_CXX_COMPILER_WORKS=1
+ )
+ fi
if use test; then
mycmakeargs+=(
-DLLVM_EXTERNAL_LIT="${EPREFIX}/usr/bin/lit"
@@ -147,11 +168,6 @@ multilib_src_compile() {
multilib_src_test() {
local -x LIT_PRESERVES_TMP=1
- cmake_build install-cxx-test-suite-prefix
- cp "${BUILD_DIR}"/{lib,libcxx/test-suite-install/$(get_libdir)}/libc++_shared.so || die
- if use static-libs; then
- cp "${BUILD_DIR}"/{lib,libcxx/test-suite-install/$(get_libdir)}/libc++_static.a || die
- fi
cmake_build check-cxx
}
@@ -160,6 +176,7 @@ multilib_src_install() {
# since we've replaced libc++.{a,so} with ldscripts, now we have to
# install the extra symlinks
if [[ ${CHOST} != *-darwin* ]] ; then
+ target_is_not_host && into /usr/${CTARGET}
dolib.so lib/libc++_shared.so
use static-libs && dolib.a lib/libc++_static.a
fi
diff --git a/llvm-runtimes/libcxx/libcxx-20.1.0.ebuild b/llvm-runtimes/libcxx/libcxx-20.1.0.ebuild
index 75a626f221f8..3b7c0a5e8bfb 100644
--- a/llvm-runtimes/libcxx/libcxx-20.1.0.ebuild
+++ b/llvm-runtimes/libcxx/libcxx-20.1.0.ebuild
@@ -4,8 +4,8 @@
EAPI=8
PYTHON_COMPAT=( python3_{10..13} )
-inherit cmake-multilib flag-o-matic llvm.org llvm-utils python-any-r1
-inherit toolchain-funcs
+inherit cmake-multilib crossdev flag-o-matic llvm.org llvm-utils
+inherit python-any-r1 toolchain-funcs
DESCRIPTION="New implementation of the C++ standard library, targeting C++11"
HOMEPAGE="https://libcxx.llvm.org/"
@@ -69,12 +69,15 @@ test_compiler() {
src_configure() {
llvm_prepend_path "${LLVM_MAJOR}"
+ local install_prefix=${EPREFIX}
+ target_is_not_host && install_prefix+=/usr/${CTARGET}
+
# note: we need to do this before multilib kicks in since it will
# alter the CHOST
local cxxabi cxxabi_incs
if use libcxxabi; then
cxxabi=system-libcxxabi
- cxxabi_incs="${EPREFIX}/usr/include/c++/v1"
+ cxxabi_incs="${install_prefix}/usr/include/c++/v1"
else
local gcc_inc="${EPREFIX}/usr/lib/gcc/${CHOST}/$(gcc-fullversion)/include/g++-v$(gcc-major-version)"
cxxabi=libsupc++
@@ -86,8 +89,8 @@ src_configure() {
multilib_src_configure() {
if use clang; then
- local -x CC=${CHOST}-clang
- local -x CXX=${CHOST}-clang++
+ local -x CC=${CTARGET}-clang
+ local -x CXX=${CTARGET}-clang++
strip-unsupported-flags
fi
@@ -95,18 +98,29 @@ multilib_src_configure() {
local use_compiler_rt=OFF
[[ $(tc-get-c-rtlib) == compiler-rt ]] && use_compiler_rt=ON
- # bootstrap: cmake is unhappy if compiler can't link to stdlib
- local nolib_flags=( -nodefaultlibs -lc )
- if ! test_compiler; then
- if test_compiler "${nolib_flags[@]}"; then
- local -x LDFLAGS="${LDFLAGS} ${nolib_flags[*]}"
- ewarn "${CXX} seems to lack runtime, trying with ${nolib_flags[*]}"
+ # Scenarios to consider:
+ #
+ # 1. Compiler test works with the default flags.
+ # 2. There is a runtime library, but no stdlib. In that case, leave the
+ # LDFLAGS untouched, since there is no self-dependency in libc++.
+ # 3. There is no runtime library nor stdlib. In that case, overwrite the
+ # LDFLAGS.
+ local nostdlib_flags=( -nostdlib --rtlib=compiler-rt -lc )
+ local nort_flags=( -nodefaultlibs -lc )
+ if ! test_compiler && ! test_compiler "${nostdlib_flags[@]}"; then
+ if test_compiler "${nort_flags[@]}"; then
+ local -x LDFLAGS="${LDFLAGS} ${nort_flags[*]}"
+ ewarn "${CXX} seems to lack runtime, trying with ${nort_flags[*]}"
fi
fi
+ local install_prefix=${EPREFIX}
+ target_is_not_host && install_prefix+=/usr/${CTARGET}
+
local libdir=$(get_libdir)
local mycmakeargs=(
- -DCMAKE_CXX_COMPILER_TARGET="${CHOST}"
+ -DCMAKE_CXX_COMPILER_TARGET="${CTARGET}"
+ -DCMAKE_INSTALL_PREFIX="${install_prefix}/usr"
-DPython3_EXECUTABLE="${PYTHON}"
-DLLVM_ENABLE_RUNTIMES=libcxx
-DLLVM_INCLUDE_TESTS=OFF
@@ -126,7 +140,16 @@ multilib_src_configure() {
# this is broken with standalone builds, and also meaningless
-DLIBCXXABI_USE_LLVM_UNWINDER=OFF
)
-
+ if is_crosspkg; then
+ # Needed to target built libc headers
+ local -x CFLAGS="${CFLAGS} -isystem ${ESYSROOT}/usr/${CTARGET}/usr/include"
+ mycmakeargs+=(
+ # Without this, the compiler will compile a test program
+ # and fail due to no builtins.
+ -DCMAKE_C_COMPILER_WORKS=1
+ -DCMAKE_CXX_COMPILER_WORKS=1
+ )
+ fi
if use test; then
mycmakeargs+=(
-DLLVM_EXTERNAL_LIT="${EPREFIX}/usr/bin/lit"
@@ -160,6 +183,7 @@ multilib_src_install() {
# since we've replaced libc++.{a,so} with ldscripts, now we have to
# install the extra symlinks
if [[ ${CHOST} != *-darwin* ]] ; then
+ target_is_not_host && into /usr/${CTARGET}
dolib.so lib/libc++_shared.so
use static-libs && dolib.a lib/libc++_static.a
fi
diff --git a/llvm-runtimes/libcxx/libcxx-21.0.0.9999.ebuild b/llvm-runtimes/libcxx/libcxx-21.0.0.9999.ebuild
index f6f57e2287bd..d3a183fb38cc 100644
--- a/llvm-runtimes/libcxx/libcxx-21.0.0.9999.ebuild
+++ b/llvm-runtimes/libcxx/libcxx-21.0.0.9999.ebuild
@@ -4,8 +4,8 @@
EAPI=8
PYTHON_COMPAT=( python3_{10..13} )
-inherit cmake-multilib flag-o-matic llvm.org llvm-utils python-any-r1
-inherit toolchain-funcs
+inherit cmake-multilib crossdev flag-o-matic llvm.org llvm-utils
+inherit python-any-r1 toolchain-funcs
DESCRIPTION="New implementation of the C++ standard library, targeting C++11"
HOMEPAGE="https://libcxx.llvm.org/"
@@ -68,12 +68,15 @@ test_compiler() {
src_configure() {
llvm_prepend_path "${LLVM_MAJOR}"
+ local install_prefix=${EPREFIX}
+ target_is_not_host && install_prefix+=/usr/${CTARGET}
+
# note: we need to do this before multilib kicks in since it will
# alter the CHOST
local cxxabi cxxabi_incs
if use libcxxabi; then
cxxabi=system-libcxxabi
- cxxabi_incs="${EPREFIX}/usr/include/c++/v1"
+ cxxabi_incs="${install_prefix}/usr/include/c++/v1"
else
local gcc_inc="${EPREFIX}/usr/lib/gcc/${CHOST}/$(gcc-fullversion)/include/g++-v$(gcc-major-version)"
cxxabi=libsupc++
@@ -85,8 +88,8 @@ src_configure() {
multilib_src_configure() {
if use clang; then
- local -x CC=${CHOST}-clang
- local -x CXX=${CHOST}-clang++
+ local -x CC=${CTARGET}-clang
+ local -x CXX=${CTARGET}-clang++
strip-unsupported-flags
fi
@@ -94,18 +97,29 @@ multilib_src_configure() {
local use_compiler_rt=OFF
[[ $(tc-get-c-rtlib) == compiler-rt ]] && use_compiler_rt=ON
- # bootstrap: cmake is unhappy if compiler can't link to stdlib
- local nolib_flags=( -nodefaultlibs -lc )
- if ! test_compiler; then
- if test_compiler "${nolib_flags[@]}"; then
- local -x LDFLAGS="${LDFLAGS} ${nolib_flags[*]}"
- ewarn "${CXX} seems to lack runtime, trying with ${nolib_flags[*]}"
+ # Scenarios to consider:
+ #
+ # 1. Compiler test works with the default flags.
+ # 2. There is a runtime library, but no stdlib. In that case, leave the
+ # LDFLAGS untouched, since there is no self-dependency in libc++.
+ # 3. There is no runtime library nor stdlib. In that case, overwrite the
+ # LDFLAGS.
+ local nostdlib_flags=( -nostdlib --rtlib=compiler-rt -lc )
+ local nort_flags=( -nodefaultlibs -lc )
+ if ! test_compiler && ! test_compiler "${nostdlib_flags[@]}"; then
+ if test_compiler "${nort_flags[@]}"; then
+ local -x LDFLAGS="${LDFLAGS} ${nort_flags[*]}"
+ ewarn "${CXX} seems to lack runtime, trying with ${nort_flags[*]}"
fi
fi
+ local install_prefix=${EPREFIX}
+ target_is_not_host && install_prefix+=/usr/${CTARGET}
+
local libdir=$(get_libdir)
local mycmakeargs=(
- -DCMAKE_CXX_COMPILER_TARGET="${CHOST}"
+ -DCMAKE_CXX_COMPILER_TARGET="${CTARGET}"
+ -DCMAKE_INSTALL_PREFIX="${install_prefix}/usr"
-DPython3_EXECUTABLE="${PYTHON}"
-DLLVM_ENABLE_RUNTIMES=libcxx
-DLLVM_INCLUDE_TESTS=OFF
@@ -125,7 +139,16 @@ multilib_src_configure() {
# this is broken with standalone builds, and also meaningless
-DLIBCXXABI_USE_LLVM_UNWINDER=OFF
)
-
+ if is_crosspkg; then
+ # Needed to target built libc headers
+ local -x CFLAGS="${CFLAGS} -isystem ${ESYSROOT}/usr/${CTARGET}/usr/include"
+ mycmakeargs+=(
+ # Without this, the compiler will compile a test program
+ # and fail due to no builtins.
+ -DCMAKE_C_COMPILER_WORKS=1
+ -DCMAKE_CXX_COMPILER_WORKS=1
+ )
+ fi
if use test; then
mycmakeargs+=(
-DLLVM_EXTERNAL_LIT="${EPREFIX}/usr/bin/lit"
@@ -159,6 +182,7 @@ multilib_src_install() {
# since we've replaced libc++.{a,so} with ldscripts, now we have to
# install the extra symlinks
if [[ ${CHOST} != *-darwin* ]] ; then
+ target_is_not_host && into /usr/${CTARGET}
dolib.so lib/libc++_shared.so
use static-libs && dolib.a lib/libc++_static.a
fi
next reply other threads:[~2025-03-17 6:22 UTC|newest]
Thread overview: 38+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-03-17 6:22 Michał Górny [this message]
-- strict thread matches above, loose matches on Subject: below --
2025-03-29 10:27 [gentoo-commits] repo/gentoo:master commit in: llvm-runtimes/libcxx/ Michał Górny
2025-03-23 13:46 Arthur Zamarin
2025-03-22 10:43 Michał Górny
2025-03-20 16:50 Michał Górny
2025-03-17 20:13 Michał Górny
2025-03-17 16:29 Michał Górny
2025-03-16 17:41 Michał Górny
2025-03-11 14:56 Michał Górny
2025-03-05 10:13 Michał Górny
2025-03-05 6:25 Michał Górny
2025-03-01 12:58 Michał Górny
2025-03-01 8:34 Michał Górny
2025-02-26 18:55 Michał Górny
2025-02-25 14:03 Michał Górny
2025-02-22 15:19 Michał Górny
2025-02-15 7:19 Michał Górny
2025-02-13 7:53 Michał Górny
2025-02-11 11:29 Michał Górny
2025-02-08 11:51 Michał Górny
2025-02-07 20:08 Arthur Zamarin
2025-02-07 20:08 Arthur Zamarin
2025-02-02 18:25 Michał Górny
2025-02-01 13:15 Michał Górny
2025-02-01 8:05 Michał Górny
2025-01-31 21:51 Michał Górny
2025-01-25 13:33 Michał Górny
2025-01-22 19:15 Michał Górny
2025-01-18 15:09 Michał Górny
2025-01-18 8:21 Michał Górny
2025-01-15 4:24 Michał Górny
2025-01-11 18:12 Michał Górny
2025-01-04 15:28 Michał Górny
2024-12-28 19:35 Michał Górny
2024-12-27 21:25 Michał Górny
2024-12-21 10:28 Michał Górny
2024-12-17 21:37 Michał Górny
2024-12-16 5:57 Michał Górny
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1742192496.4b9aa358421f60057eb35ba5ab5c73945d7fca8b.mgorny@gentoo \
--to=mgorny@gentoo.org \
--cc=gentoo-commits@lists.gentoo.org \
--cc=gentoo-dev@lists.gentoo.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox