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