3 |
3 |
|
4 |
4 |
EAPI=8
|
5 |
5 |
|
6 |
|
PYTHON_COMPAT=( python3_{9..10} )
|
|
6 |
PYTHON_COMPAT=( python3_{9..11} )
|
7 |
7 |
inherit check-reqs cmake flag-o-matic llvm llvm.org python-any-r1
|
8 |
8 |
|
9 |
9 |
DESCRIPTION="Compiler runtime libraries for clang (sanitizers & xray)"
|
10 |
10 |
HOMEPAGE="https://llvm.org/"
|
11 |
11 |
|
12 |
12 |
LICENSE="Apache-2.0-with-LLVM-exceptions || ( UoI-NCSA MIT )"
|
13 |
|
SLOT="$(ver_cut 1-3)"
|
|
13 |
SLOT="${LLVM_VERSION}"
|
14 |
14 |
KEYWORDS="amd64 arm arm64 ppc64 ~riscv x86 ~amd64-linux ~ppc-macos ~x64-macos"
|
15 |
15 |
IUSE="+abi_x86_32 abi_x86_64 +clang debug test"
|
16 |
16 |
# base targets
|
... | ... | |
34 |
34 |
!test? ( test )
|
35 |
35 |
"
|
36 |
36 |
|
37 |
|
LLVM_MAX_SLOT=${SLOT%%.*}
|
38 |
37 |
DEPEND="
|
39 |
|
sys-devel/llvm:${LLVM_MAX_SLOT}
|
|
38 |
sys-devel/llvm:${LLVM_MAJOR}
|
40 |
39 |
virtual/libcrypt[abi_x86_32(-)?,abi_x86_64(-)?]
|
41 |
40 |
"
|
42 |
41 |
BDEPEND="
|
... | ... | |
45 |
44 |
elibc_glibc? ( net-libs/libtirpc )
|
46 |
45 |
test? (
|
47 |
46 |
!!<sys-apps/sandbox-2.13
|
48 |
|
$(python_gen_any_dep ">=dev-python/lit-5[\${PYTHON_USEDEP}]")
|
49 |
|
=sys-devel/clang-${PV%_*}*:${LLVM_MAX_SLOT}
|
50 |
|
sys-libs/compiler-rt:${SLOT}
|
|
47 |
$(python_gen_any_dep ">=dev-python/lit-15[\${PYTHON_USEDEP}]")
|
|
48 |
=sys-devel/clang-${LLVM_VERSION}*:${LLVM_MAJOR}
|
|
49 |
sys-libs/compiler-rt:${LLVM_VERSION}
|
51 |
50 |
)
|
52 |
51 |
!test? (
|
53 |
52 |
${PYTHON_DEPS}
|
54 |
53 |
)
|
55 |
54 |
"
|
56 |
55 |
|
57 |
|
LLVM_COMPONENTS=( compiler-rt cmake )
|
|
56 |
LLVM_COMPONENTS=( compiler-rt cmake llvm/cmake )
|
58 |
57 |
LLVM_TEST_COMPONENTS=( llvm/lib/Testing/Support llvm/utils/unittest )
|
59 |
|
LLVM_PATCHSET=${PV}-r3
|
|
58 |
LLVM_PATCHSET=${PV/_/-}
|
60 |
59 |
llvm.org_set_globals
|
61 |
60 |
|
62 |
61 |
python_check_deps() {
|
63 |
62 |
use test || return 0
|
64 |
|
python_has_version ">=dev-python/lit-5[${PYTHON_USEDEP}]"
|
|
63 |
python_has_version ">=dev-python/lit-15[${PYTHON_USEDEP}]"
|
65 |
64 |
}
|
66 |
65 |
|
67 |
66 |
check_space() {
|
... | ... | |
77 |
76 |
|
78 |
77 |
pkg_setup() {
|
79 |
78 |
check_space
|
80 |
|
llvm_pkg_setup
|
|
79 |
LLVM_MAX_SLOT=${LLVM_MAJOR} llvm_pkg_setup
|
81 |
80 |
python-any-r1_pkg_setup
|
82 |
81 |
}
|
83 |
82 |
|
... | ... | |
126 |
125 |
done
|
127 |
126 |
|
128 |
127 |
local mycmakeargs=(
|
129 |
|
-DCOMPILER_RT_INSTALL_PATH="${EPREFIX}/usr/lib/clang/${SLOT}"
|
|
128 |
-DCOMPILER_RT_INSTALL_PATH="${EPREFIX}/usr/lib/clang/${LLVM_VERSION}"
|
130 |
129 |
# use a build dir structure consistent with install
|
131 |
130 |
# this makes it possible to easily deploy test-friendly clang
|
132 |
|
-DCOMPILER_RT_OUTPUT_DIR="${BUILD_DIR}/lib/clang/${SLOT}"
|
|
131 |
-DCOMPILER_RT_OUTPUT_DIR="${BUILD_DIR}/lib/clang/${LLVM_VERSION}"
|
133 |
132 |
|
134 |
133 |
-DCOMPILER_RT_INCLUDE_TESTS=$(usex test)
|
135 |
134 |
# builtins & crt installed by sys-libs/compiler-rt
|
... | ... | |
159 |
158 |
-DLLVM_LIT_ARGS="$(get_lit_flags)"
|
160 |
159 |
|
161 |
160 |
# they are created during src_test()
|
162 |
|
-DCOMPILER_RT_TEST_COMPILER="${BUILD_DIR}/lib/llvm/${LLVM_MAX_SLOT}/bin/clang"
|
163 |
|
-DCOMPILER_RT_TEST_CXX_COMPILER="${BUILD_DIR}/lib/llvm/${LLVM_MAX_SLOT}/bin/clang++"
|
|
161 |
-DCOMPILER_RT_TEST_COMPILER="${BUILD_DIR}/lib/llvm/${LLVM_MAJOR}/bin/clang"
|
|
162 |
-DCOMPILER_RT_TEST_CXX_COMPILER="${BUILD_DIR}/lib/llvm/${LLVM_MAJOR}/bin/clang++"
|
164 |
163 |
)
|
165 |
164 |
|
166 |
165 |
# same flags are passed for build & tests, so we need to strip
|
167 |
166 |
# them down to a subset supported by clang
|
168 |
|
CC=${EPREFIX}/usr/lib/llvm/${LLVM_MAX_SLOT}/bin/clang \
|
169 |
|
CXX=${EPREFIX}/usr/lib/llvm/${LLVM_MAX_SLOT}/bin/clang++ \
|
|
167 |
CC=${EPREFIX}/usr/lib/llvm/${LLVM_MAJOR}/bin/clang \
|
|
168 |
CXX=${EPREFIX}/usr/lib/llvm/${LLVM_MAJOR}/bin/clang++ \
|
170 |
169 |
strip-unsupported-flags
|
171 |
170 |
fi
|
172 |
171 |
|
... | ... | |
187 |
186 |
cmake_src_configure
|
188 |
187 |
|
189 |
188 |
if use test; then
|
190 |
|
local sys_dir=( "${EPREFIX}"/usr/lib/clang/${SLOT}/lib/* )
|
|
189 |
local sys_dir=( "${EPREFIX}"/usr/lib/clang/${LLVM_VERSION}/lib/* )
|
191 |
190 |
[[ -e ${sys_dir} ]] || die "Unable to find ${sys_dir}"
|
192 |
191 |
[[ ${#sys_dir[@]} -eq 1 ]] || die "Non-deterministic compiler-rt install: ${sys_dir[*]}"
|
193 |
192 |
|
194 |
193 |
# copy clang over since resource_dir is located relatively to binary
|
195 |
194 |
# therefore, we can put our new libraries in it
|
196 |
|
mkdir -p "${BUILD_DIR}"/lib/{llvm/${LLVM_MAX_SLOT}/{bin,$(get_libdir)},clang/${SLOT}/include} || die
|
197 |
|
cp "${EPREFIX}"/usr/lib/llvm/${LLVM_MAX_SLOT}/bin/clang{,++} \
|
198 |
|
"${BUILD_DIR}"/lib/llvm/${LLVM_MAX_SLOT}/bin/ || die
|
199 |
|
cp "${EPREFIX}"/usr/lib/clang/${SLOT}/include/*.h \
|
200 |
|
"${BUILD_DIR}"/lib/clang/${SLOT}/include/ || die
|
|
195 |
mkdir -p "${BUILD_DIR}"/lib/{llvm/${LLVM_MAJOR}/{bin,$(get_libdir)},clang/${LLVM_VERSION}/include} || die
|
|
196 |
cp "${EPREFIX}"/usr/lib/llvm/${LLVM_MAJOR}/bin/clang{,++} \
|
|
197 |
"${BUILD_DIR}"/lib/llvm/${LLVM_MAJOR}/bin/ || die
|
|
198 |
cp "${EPREFIX}"/usr/lib/clang/${LLVM_VERSION}/include/*.h \
|
|
199 |
"${BUILD_DIR}"/lib/clang/${LLVM_VERSION}/include/ || die
|
201 |
200 |
cp "${sys_dir}"/*builtins*.a \
|
202 |
|
"${BUILD_DIR}/lib/clang/${SLOT}/lib/${sys_dir##*/}/" || die
|
|
201 |
"${BUILD_DIR}/lib/clang/${LLVM_VERSION}/lib/${sys_dir##*/}/" || die
|
203 |
202 |
# we also need LLVMgold.so for gold-based tests
|
204 |
|
if [[ -f ${EPREFIX}/usr/lib/llvm/${LLVM_MAX_SLOT}/$(get_libdir)/LLVMgold.so ]]; then
|
205 |
|
ln -s "${EPREFIX}"/usr/lib/llvm/${LLVM_MAX_SLOT}/$(get_libdir)/LLVMgold.so \
|
206 |
|
"${BUILD_DIR}"/lib/llvm/${LLVM_MAX_SLOT}/$(get_libdir)/ || die
|
|
203 |
if [[ -f ${EPREFIX}/usr/lib/llvm/${LLVM_MAJOR}/$(get_libdir)/LLVMgold.so ]]; then
|
|
204 |
ln -s "${EPREFIX}"/usr/lib/llvm/${LLVM_MAJOR}/$(get_libdir)/LLVMgold.so \
|
|
205 |
"${BUILD_DIR}"/lib/llvm/${LLVM_MAJOR}/$(get_libdir)/ || die
|
207 |
206 |
fi
|
208 |
207 |
fi
|
209 |
208 |
}
|