| 3 |
3 |
|
| 4 |
4 |
EAPI=8
|
| 5 |
5 |
|
| 6 |
|
PYTHON_COMPAT=( python3_11 )
|
| 7 |
|
inherit cmake-multilib flag-o-matic llvm llvm.org python-any-r1 \
|
| 8 |
|
toolchain-funcs
|
|
6 |
PYTHON_COMPAT=( python3_{11..13} )
|
|
7 |
inherit cmake-multilib crossdev flag-o-matic llvm.org llvm-utils
|
|
8 |
inherit python-any-r1 toolchain-funcs
|
| 9 |
9 |
|
| 10 |
10 |
DESCRIPTION="New implementation of the C++ standard library, targeting C++11"
|
| 11 |
11 |
HOMEPAGE="https://libcxx.llvm.org/"
|
| 12 |
12 |
|
| 13 |
13 |
LICENSE="Apache-2.0-with-LLVM-exceptions || ( UoI-NCSA MIT )"
|
| 14 |
14 |
SLOT="0"
|
| 15 |
|
KEYWORDS="amd64 arm arm64 ~riscv ~sparc x86 ~x64-macos"
|
|
15 |
KEYWORDS="amd64 arm arm64 ~loong ~riscv ~sparc x86 ~arm64-macos ~x64-macos"
|
| 16 |
16 |
IUSE="+clang +libcxxabi +static-libs test"
|
| 17 |
17 |
REQUIRED_USE="test? ( clang )"
|
| 18 |
18 |
RESTRICT="!test? ( test )"
|
| ... | ... | |
| 41 |
41 |
"
|
| 42 |
42 |
|
| 43 |
43 |
LLVM_COMPONENTS=( runtimes libcxx{,abi} llvm/{cmake,utils/llvm-lit} cmake )
|
| 44 |
|
LLVM_PATCHSET=${PV}-r8
|
| 45 |
44 |
llvm.org_set_globals
|
| 46 |
45 |
|
| 47 |
46 |
python_check_deps() {
|
| ... | ... | |
| 50 |
49 |
}
|
| 51 |
50 |
|
| 52 |
51 |
pkg_setup() {
|
| 53 |
|
# Darwin Prefix builds do not have llvm installed yet, so rely on
|
| 54 |
|
# bootstrap-prefix to set the appropriate path vars to LLVM instead
|
| 55 |
|
# of using llvm_pkg_setup.
|
| 56 |
|
if [[ ${CHOST} != *-darwin* ]] || has_version llvm-core/llvm; then
|
| 57 |
|
LLVM_MAX_SLOT=${LLVM_MAJOR} llvm_pkg_setup
|
| 58 |
|
fi
|
| 59 |
52 |
python-any-r1_pkg_setup
|
| 60 |
53 |
|
| 61 |
54 |
if ! use libcxxabi && ! tc-is-gcc ; then
|
| ... | ... | |
| 72 |
65 |
}
|
| 73 |
66 |
|
| 74 |
67 |
src_configure() {
|
|
68 |
local install_prefix=${EPREFIX}
|
|
69 |
is_crosspkg && install_prefix+=/usr/${CTARGET}
|
|
70 |
|
| 75 |
71 |
# note: we need to do this before multilib kicks in since it will
|
| 76 |
72 |
# alter the CHOST
|
| 77 |
73 |
local cxxabi cxxabi_incs
|
| 78 |
74 |
if use libcxxabi; then
|
| 79 |
75 |
cxxabi=system-libcxxabi
|
| 80 |
|
cxxabi_incs="${EPREFIX}/usr/include/c++/v1"
|
|
76 |
cxxabi_incs="${install_prefix}/usr/include/c++/v1"
|
| 81 |
77 |
else
|
| 82 |
78 |
local gcc_inc="${EPREFIX}/usr/lib/gcc/${CHOST}/$(gcc-fullversion)/include/g++-v$(gcc-major-version)"
|
| 83 |
79 |
cxxabi=libsupc++
|
| ... | ... | |
| 88 |
84 |
}
|
| 89 |
85 |
|
| 90 |
86 |
multilib_src_configure() {
|
|
87 |
# Workaround for bgo #961153.
|
|
88 |
# TODO: Fix the multilib.eclass, so it sets CTARGET properly.
|
|
89 |
if ! is_crosspkg; then
|
|
90 |
export CTARGET=${CHOST}
|
|
91 |
fi
|
|
92 |
|
| 91 |
93 |
if use clang; then
|
| 92 |
|
local -x CC=${CHOST}-clang
|
| 93 |
|
local -x CXX=${CHOST}-clang++
|
|
94 |
llvm_prepend_path -b "${LLVM_MAJOR}"
|
|
95 |
local -x CC=${CTARGET}-clang
|
|
96 |
local -x CXX=${CTARGET}-clang++
|
| 94 |
97 |
strip-unsupported-flags
|
| 95 |
98 |
fi
|
| 96 |
99 |
|
| ... | ... | |
| 98 |
101 |
local use_compiler_rt=OFF
|
| 99 |
102 |
[[ $(tc-get-c-rtlib) == compiler-rt ]] && use_compiler_rt=ON
|
| 100 |
103 |
|
| 101 |
|
# bootstrap: cmake is unhappy if compiler can't link to stdlib
|
| 102 |
|
local nolib_flags=( -nodefaultlibs -lc )
|
| 103 |
|
if ! test_compiler; then
|
| 104 |
|
if test_compiler "${nolib_flags[@]}"; then
|
| 105 |
|
local -x LDFLAGS="${LDFLAGS} ${nolib_flags[*]}"
|
| 106 |
|
ewarn "${CXX} seems to lack runtime, trying with ${nolib_flags[*]}"
|
|
104 |
# Scenarios to consider:
|
|
105 |
#
|
|
106 |
# 1. Compiler test works with the default flags.
|
|
107 |
# 2. There is a runtime library, but no stdlib. In that case, leave the
|
|
108 |
# LDFLAGS untouched, since there is no self-dependency in libc++.
|
|
109 |
# 3. There is no runtime library nor stdlib. In that case, overwrite the
|
|
110 |
# LDFLAGS.
|
|
111 |
local nostdlib_flags=( -nostdlib --rtlib=compiler-rt -lc )
|
|
112 |
local nort_flags=( -nodefaultlibs -lc )
|
|
113 |
if ! test_compiler && ! test_compiler "${nostdlib_flags[@]}"; then
|
|
114 |
if test_compiler "${nort_flags[@]}"; then
|
|
115 |
local -x LDFLAGS="${LDFLAGS} ${nort_flags[*]}"
|
|
116 |
ewarn "${CXX} seems to lack runtime, trying with ${nort_flags[*]}"
|
| 107 |
117 |
fi
|
| 108 |
118 |
fi
|
| 109 |
119 |
|
| 110 |
120 |
local libdir=$(get_libdir)
|
| 111 |
121 |
local mycmakeargs=(
|
| 112 |
|
-DCMAKE_CXX_COMPILER_TARGET="${CHOST}"
|
|
122 |
-DLLVM_ROOT="${ESYSROOT}/usr/lib/llvm/${LLVM_MAJOR}"
|
|
123 |
|
|
124 |
-DCMAKE_CXX_COMPILER_TARGET="${CTARGET}"
|
| 113 |
125 |
-DPython3_EXECUTABLE="${PYTHON}"
|
| 114 |
126 |
-DLLVM_ENABLE_RUNTIMES=libcxx
|
| 115 |
127 |
-DLLVM_INCLUDE_TESTS=OFF
|
| ... | ... | |
| 121 |
133 |
-DLIBCXX_CXX_ABI_INCLUDE_PATHS=${cxxabi_incs}
|
| 122 |
134 |
# we're using our own mechanism for generating linker scripts
|
| 123 |
135 |
-DLIBCXX_ENABLE_ABI_LINKER_SCRIPT=OFF
|
| 124 |
|
-DLIBCXX_HAS_MUSL_LIBC=$(usex elibc_musl)
|
|
136 |
-DLIBCXX_HAS_MUSL_LIBC=$(llvm_cmake_use_musl)
|
| 125 |
137 |
-DLIBCXX_INCLUDE_BENCHMARKS=OFF
|
| 126 |
138 |
-DLIBCXX_INCLUDE_TESTS=$(usex test)
|
|
139 |
-DLIBCXX_INSTALL_MODULES=ON
|
| 127 |
140 |
-DLIBCXX_USE_COMPILER_RT=${use_compiler_rt}
|
|
141 |
# this is broken with standalone builds, and also meaningless
|
|
142 |
-DLIBCXXABI_USE_LLVM_UNWINDER=OFF
|
| 128 |
143 |
)
|
| 129 |
|
|
|
144 |
if is_crosspkg; then
|
|
145 |
# Needed to target built libc headers
|
|
146 |
local -x CFLAGS="${CFLAGS} -isystem ${ESYSROOT}/usr/${CTARGET}/usr/include"
|
|
147 |
mycmakeargs+=(
|
|
148 |
# Without this, the compiler will compile a test program
|
|
149 |
# and fail due to no builtins.
|
|
150 |
-DCMAKE_C_COMPILER_WORKS=1
|
|
151 |
-DCMAKE_CXX_COMPILER_WORKS=1
|
|
152 |
# Install inside the cross sysroot.
|
|
153 |
-DCMAKE_INSTALL_PREFIX="${EPREFIX}/usr/${CTARGET}/usr"
|
|
154 |
)
|
|
155 |
fi
|
| 130 |
156 |
if use test; then
|
| 131 |
157 |
mycmakeargs+=(
|
| 132 |
158 |
-DLLVM_EXTERNAL_LIT="${EPREFIX}/usr/bin/lit"
|
| ... | ... | |
| 155 |
181 |
# since we've replaced libc++.{a,so} with ldscripts, now we have to
|
| 156 |
182 |
# install the extra symlinks
|
| 157 |
183 |
if [[ ${CHOST} != *-darwin* ]] ; then
|
|
184 |
is_crosspkg && into /usr/${CTARGET}
|
| 158 |
185 |
dolib.so lib/libc++_shared.so
|
| 159 |
186 |
use static-libs && dolib.a lib/libc++_static.a
|
| 160 |
187 |
fi
|