*/*: Clean PYTHON_COMPAT of obsolete impls
[gentoo.git] / sys-libs / libomp / libomp-9.0.0.ebuild
1 # Copyright 1999-2020 Gentoo Authors
2 # Distributed under the terms of the GNU General Public License v2
3
4 EAPI=7
5
6 PYTHON_COMPAT=( python{2_7,3_{6,7}} )
7 inherit cmake-multilib linux-info llvm.org multiprocessing python-any-r1
8
9 DESCRIPTION="OpenMP runtime library for LLVM/clang compiler"
10 HOMEPAGE="https://openmp.llvm.org"
11 LLVM_COMPONENTS=( openmp )
12 llvm.org_set_globals
13
14 LICENSE="Apache-2.0-with-LLVM-exceptions || ( UoI-NCSA MIT )"
15 SLOT="0"
16 KEYWORDS="~amd64 ~arm ~arm64 ~ppc64 ~x86 ~amd64-linux ~x64-macos"
17 IUSE="cuda hwloc kernel_linux offload ompt test"
18 # CUDA works only with the x86_64 ABI
19 REQUIRED_USE="offload? ( cuda? ( abi_x86_64 ) )"
20 RESTRICT="!test? ( test )"
21
22 RDEPEND="
23         hwloc? ( sys-apps/hwloc:0=[${MULTILIB_USEDEP}] )
24         offload? (
25                 virtual/libelf:=[${MULTILIB_USEDEP}]
26                 virtual/libffi:=[${MULTILIB_USEDEP}]
27                 cuda? ( dev-util/nvidia-cuda-toolkit:= )
28         )"
29 # tests:
30 # - dev-python/lit provides the test runner
31 # - sys-devel/llvm provide test utils (e.g. FileCheck)
32 # - sys-devel/clang provides the compiler to run tests
33 DEPEND="${RDEPEND}"
34 BDEPEND="dev-lang/perl
35         offload? ( virtual/pkgconfig[${MULTILIB_USEDEP}] )
36         test? (
37                 $(python_gen_any_dep 'dev-python/lit[${PYTHON_USEDEP}]')
38                 >=sys-devel/clang-6
39         )"
40
41 # least intrusive of all
42 CMAKE_BUILD_TYPE=RelWithDebInfo
43
44 python_check_deps() {
45         has_version "dev-python/lit[${PYTHON_USEDEP}]"
46 }
47
48 kernel_pds_check() {
49         if use kernel_linux && kernel_is -lt 4 15 && kernel_is -ge 4 13; then
50                 local CONFIG_CHECK="~!SCHED_PDS"
51                 local ERROR_SCHED_PDS="\
52 PDS scheduler versions >= 0.98c < 0.98i (e.g. used in kernels >= 4.13-pf11
53 < 4.14-pf9) do not implement sched_yield() call which may result in horrible
54 performance problems with libomp. If you are using one of the specified
55 kernel versions, you may want to disable the PDS scheduler."
56
57                 check_extra_config
58         fi
59 }
60
61 pkg_pretend() {
62         kernel_pds_check
63 }
64
65 pkg_setup() {
66         use test && python-any-r1_pkg_setup
67 }
68
69 multilib_src_configure() {
70         local libdir="$(get_libdir)"
71         local mycmakeargs=(
72                 -DOPENMP_LIBDIR_SUFFIX="${libdir#lib}"
73
74                 -DLIBOMP_USE_HWLOC=$(usex hwloc)
75                 -DLIBOMP_OMPT_SUPPORT=$(usex ompt)
76
77                 -DOPENMP_ENABLE_LIBOMPTARGET=$(usex offload)
78
79                 # do not install libgomp.so & libiomp5.so aliases
80                 -DLIBOMP_INSTALL_ALIASES=OFF
81                 # disable unnecessary hack copying stuff back to srcdir
82                 -DLIBOMP_COPY_EXPORTS=OFF
83         )
84         use offload && mycmakeargs+=(
85                 # this is non-fatal and libomp checks for CUDA conditionally
86                 # to ABI, so we can just ignore passing the wrong value
87                 # on non-amd64 ABIs
88                 -DCMAKE_DISABLE_FIND_PACKAGE_CUDA=$(usex !cuda)
89         )
90         use test && mycmakeargs+=(
91                 # this project does not use standard LLVM cmake macros
92                 -DOPENMP_LLVM_LIT_EXECUTABLE="${EPREFIX}/usr/bin/lit"
93                 -DOPENMP_LIT_ARGS="-vv;-j;${LIT_JOBS:-$(makeopts_jobs "${MAKEOPTS}" "$(get_nproc)")}"
94
95                 -DOPENMP_TEST_C_COMPILER="$(type -P "${CHOST}-clang")"
96                 -DOPENMP_TEST_CXX_COMPILER="$(type -P "${CHOST}-clang++")"
97         )
98         cmake-utils_src_configure
99 }
100
101 multilib_src_test() {
102         # respect TMPDIR!
103         local -x LIT_PRESERVES_TMP=1
104
105         cmake-utils_src_make check-libomp
106 }