3 |
3 |
|
4 |
4 |
EAPI=8
|
5 |
5 |
|
6 |
|
PYTHON_COMPAT=( python3_{9..11} )
|
7 |
|
inherit cmake flag-o-matic llvm llvm.org python-any-r1 toolchain-funcs
|
|
6 |
PYTHON_COMPAT=( python3_{10..12} )
|
|
7 |
inherit cmake crossdev flag-o-matic llvm llvm.org python-any-r1 toolchain-funcs
|
8 |
8 |
|
9 |
9 |
DESCRIPTION="Compiler runtime library for clang (built-in part)"
|
10 |
10 |
HOMEPAGE="https://llvm.org/"
|
11 |
11 |
|
12 |
12 |
LICENSE="Apache-2.0-with-LLVM-exceptions || ( UoI-NCSA MIT )"
|
13 |
|
SLOT="${LLVM_VERSION}"
|
14 |
|
KEYWORDS="amd64 arm arm64 ppc64 ~riscv x86 ~amd64-linux ~ppc-macos ~x64-macos"
|
|
13 |
SLOT="${LLVM_MAJOR}"
|
|
14 |
KEYWORDS="amd64 arm arm64 ~loong ppc64 ~riscv x86 ~amd64-linux ~ppc-macos ~x64-macos"
|
15 |
15 |
IUSE="+abi_x86_32 abi_x86_64 +clang debug test"
|
16 |
16 |
RESTRICT="!test? ( test ) !clang? ( test )"
|
17 |
17 |
|
... | ... | |
31 |
31 |
"
|
32 |
32 |
|
33 |
33 |
LLVM_COMPONENTS=( compiler-rt cmake llvm/cmake )
|
34 |
|
LLVM_PATCHSET=${PV/_/-}
|
35 |
34 |
llvm.org_set_globals
|
36 |
35 |
|
37 |
36 |
python_check_deps() {
|
... | ... | |
53 |
52 |
if [[ ${CHOST} != *-darwin* ]] || has_version sys-devel/llvm; then
|
54 |
53 |
LLVM_MAX_SLOT=${LLVM_MAJOR} llvm_pkg_setup
|
55 |
54 |
fi
|
|
55 |
|
|
56 |
if target_is_not_host || tc-is-cross-compiler ; then
|
|
57 |
# strips vars like CFLAGS="-march=x86_64-v3" for non-x86 architectures
|
|
58 |
CHOST=${CTARGET} strip-unsupported-flags
|
|
59 |
# overrides host docs otherwise
|
|
60 |
DOCS=()
|
|
61 |
fi
|
56 |
62 |
python-any-r1_pkg_setup
|
57 |
63 |
}
|
58 |
64 |
|
59 |
65 |
test_compiler() {
|
|
66 |
target_is_not_host && return
|
60 |
67 |
$(tc-getCC) ${CFLAGS} ${LDFLAGS} "${@}" -o /dev/null -x c - \
|
61 |
68 |
<<<'int main() { return 0; }' &>/dev/null
|
62 |
69 |
}
|
... | ... | |
68 |
75 |
# pre-set since we need to pass it to cmake
|
69 |
76 |
BUILD_DIR=${WORKDIR}/${P}_build
|
70 |
77 |
|
71 |
|
if use clang; then
|
|
78 |
if use clang && ! is_crosspkg; then
|
72 |
79 |
# Only do this conditionally to allow overriding with
|
73 |
80 |
# e.g. CC=clang-13 in case of breakage
|
74 |
81 |
if ! tc-is-clang ; then
|
... | ... | |
79 |
86 |
strip-unsupported-flags
|
80 |
87 |
fi
|
81 |
88 |
|
82 |
|
if ! test_compiler; then
|
|
89 |
if ! is_crosspkg && ! test_compiler ; then
|
83 |
90 |
local nolib_flags=( -nodefaultlibs -lc )
|
84 |
91 |
|
85 |
92 |
if test_compiler "${nolib_flags[@]}"; then
|
... | ... | |
96 |
103 |
fi
|
97 |
104 |
|
98 |
105 |
local mycmakeargs=(
|
99 |
|
-DCOMPILER_RT_INSTALL_PATH="${EPREFIX}/usr/lib/clang/${LLVM_VERSION}"
|
|
106 |
-DCOMPILER_RT_INSTALL_PATH="${EPREFIX}/usr/lib/clang/${LLVM_MAJOR}"
|
100 |
107 |
|
101 |
108 |
-DCOMPILER_RT_INCLUDE_TESTS=$(usex test)
|
102 |
109 |
-DCOMPILER_RT_BUILD_LIBFUZZER=OFF
|
... | ... | |
109 |
116 |
-DPython3_EXECUTABLE="${PYTHON}"
|
110 |
117 |
)
|
111 |
118 |
|
112 |
|
if use amd64; then
|
|
119 |
if use amd64 && ! target_is_not_host; then
|
113 |
120 |
mycmakeargs+=(
|
114 |
121 |
-DCAN_TARGET_i386=$(usex abi_x86_32)
|
115 |
122 |
-DCAN_TARGET_x86_64=$(usex abi_x86_64)
|
116 |
123 |
)
|
117 |
124 |
fi
|
118 |
125 |
|
|
126 |
if is_crosspkg; then
|
|
127 |
# Needed to target built libc headers
|
|
128 |
export CFLAGS="${CFLAGS} -isystem /usr/${CTARGET}/usr/include"
|
|
129 |
mycmakeargs+=(
|
|
130 |
# Without this, the compiler will compile a test program
|
|
131 |
# and fail due to no builtins.
|
|
132 |
-DCMAKE_C_COMPILER_WORKS=1
|
|
133 |
-DCMAKE_CXX_COMPILER_WORKS=1
|
|
134 |
|
|
135 |
# Without this, compiler-rt install location is not unique
|
|
136 |
# to target triples, only to architecture.
|
|
137 |
# Needed if you want to target multiple libcs for one arch.
|
|
138 |
-DLLVM_ENABLE_PER_TARGET_RUNTIME_DIR=ON
|
|
139 |
|
|
140 |
-DCMAKE_ASM_COMPILER_TARGET="${CTARGET}"
|
|
141 |
-DCMAKE_C_COMPILER_TARGET="${CTARGET}"
|
|
142 |
-DCOMPILER_RT_DEFAULT_TARGET_ONLY=ON
|
|
143 |
)
|
|
144 |
fi
|
|
145 |
|
119 |
146 |
if use prefix && [[ "${CHOST}" == *-darwin* ]] ; then
|
120 |
147 |
mycmakeargs+=(
|
121 |
148 |
# setting -isysroot is disabled with compiler-rt-prefix-paths.patch
|