blob: 045fc8c8556bab0bd47b577613a729f5d20d03e3 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
|
# Copyright 1999-2025 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2
EAPI=8
PYTHON_COMPAT=( python3_{11..14} )
inherit cmake flag-o-matic llvm.org python-any-r1 toolchain-funcs
DESCRIPTION="LLVM's Fortran frontend"
HOMEPAGE="https://flang.llvm.org/"
LICENSE="Apache-2.0-with-LLVM-exceptions"
SLOT="${LLVM_MAJOR}/${LLVM_SOABI}"
KEYWORDS="~amd64 ~arm64"
IUSE="+clang debug test"
RESTRICT="!test? ( test )"
DEPEND="
~llvm-core/clang-${PV}[debug=]
~llvm-core/llvm-${PV}[debug=]
~llvm-core/mlir-${PV}[debug=]
"
RDEPEND="
${DEPEND}
"
PDEPEND="
>=llvm-runtimes/flang-rt-${PV}:${LLVM_MAJOR}
"
BDEPEND="
clang? ( llvm-core/clang )
test? (
$(python_gen_any_dep 'dev-python/lit[${PYTHON_USEDEP}]')
)
"
LLVM_COMPONENTS=( flang cmake )
LLVM_TEST_COMPONENTS=( clang/test/Driver mlir/test/lib )
LLVM_USE_TARGETS=llvm+eq
llvm.org_set_globals
python_check_deps() {
python_has_version "dev-python/lit[${PYTHON_USEDEP}]"
}
pkg_pretend() {
if ! use clang && tc-is-gcc; then
ewarn "Building using GCC requires lots of memory (up to 10 GiB per process)."
ewarn "Consider enabling USE=clang."
ewarn "See https://gcc.gnu.org/PR119705"
fi
}
pkg_setup() {
use test && python-any-r1_pkg_setup
}
src_configure() {
if use clang; then
# Only do this conditionally to allow overriding with
# e.g. CC=clang-13 in case of breakage
if ! tc-is-clang ; then
local -x CC=${CHOST}-clang
local -x CXX=${CHOST}-clang++
fi
strip-unsupported-flags
fi
local mycmakeargs=(
-DCMAKE_INSTALL_PREFIX="${EPREFIX}/usr/lib/llvm/${LLVM_MAJOR}"
-DLLVM_ROOT="${ESYSROOT}/usr/lib/llvm/${LLVM_MAJOR}"
-DCLANG_RESOURCE_DIR="../../../clang/${LLVM_MAJOR}"
-DBUILD_SHARED_LIBS=OFF
-DMLIR_LINK_MLIR_DYLIB=ON
# flang does not feature a dylib, so do not install libraries
# or headers
-DLLVM_INSTALL_TOOLCHAIN_ONLY=ON
# installed by llvm-runtimes/flang-rt
-DFLANG_INCLUDE_RUNTIME=OFF
# TODO: always enable to obtain reproducible tools
-DFLANG_INCLUDE_TESTS=$(usex test)
-DLLVM_TARGETS_TO_BUILD="${LLVM_TARGETS// /;}"
)
use test && mycmakeargs+=(
-DLLVM_EXTERNAL_LIT="${EPREFIX}/usr/bin/lit"
-DLLVM_LIT_ARGS="$(get_lit_flags)"
)
# LLVM_ENABLE_ASSERTIONS=NO does not guarantee this for us, #614844
use debug || local -x CPPFLAGS="${CPPFLAGS} -DNDEBUG"
cmake_src_configure
}
src_test() {
# respect TMPDIR!
local -x LIT_PRESERVES_TMP=1
cmake_build check-flang
}
|