1 # Copyright 1999-2020 Gentoo Authors
2 # Distributed under the terms of the GNU General Public License v2
6 PYTHON_COMPAT=( python{2_7,3_{6,7}} )
7 inherit cmake-multilib linux-info llvm.org multiprocessing python-any-r1
9 DESCRIPTION="OpenMP runtime library for LLVM/clang compiler"
10 HOMEPAGE="https://openmp.llvm.org"
11 LLVM_COMPONENTS=( openmp )
14 LICENSE="Apache-2.0-with-LLVM-exceptions || ( UoI-NCSA MIT )"
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 )"
23 hwloc? ( sys-apps/hwloc:0=[${MULTILIB_USEDEP}] )
25 virtual/libelf:=[${MULTILIB_USEDEP}]
26 virtual/libffi:=[${MULTILIB_USEDEP}]
27 cuda? ( dev-util/nvidia-cuda-toolkit:= )
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
34 BDEPEND="dev-lang/perl
35 offload? ( virtual/pkgconfig[${MULTILIB_USEDEP}] )
37 $(python_gen_any_dep 'dev-python/lit[${PYTHON_USEDEP}]')
41 # least intrusive of all
42 CMAKE_BUILD_TYPE=RelWithDebInfo
45 has_version "dev-python/lit[${PYTHON_USEDEP}]"
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."
66 use test && python-any-r1_pkg_setup
69 multilib_src_configure() {
70 local libdir="$(get_libdir)"
72 -DOPENMP_LIBDIR_SUFFIX="${libdir#lib}"
74 -DLIBOMP_USE_HWLOC=$(usex hwloc)
75 -DLIBOMP_OMPT_SUPPORT=$(usex ompt)
77 -DOPENMP_ENABLE_LIBOMPTARGET=$(usex offload)
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
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
88 -DCMAKE_DISABLE_FIND_PACKAGE_CUDA=$(usex !cuda)
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)")}"
95 -DOPENMP_TEST_C_COMPILER="$(type -P "${CHOST}-clang")"
96 -DOPENMP_TEST_CXX_COMPILER="$(type -P "${CHOST}-clang++")"
98 cmake-utils_src_configure
101 multilib_src_test() {
103 local -x LIT_PRESERVES_TMP=1
105 cmake-utils_src_make check-libomp