jungle/pkgs/llvm-ompss2/openmp.nix

112 lines
2.4 KiB
Nix

{ lib
, llvmPackages_latest
, monorepoSrc
, runCommand
, cmake
, ninja
, llvm
, perl
, pkg-config
, version
, nosv
, ovni
, python3
, enableNosv ? false
, enableDebug ? false
, enableOvni ? false
}:
assert enableOvni -> enableNosv;
let
stdenv = llvmPackages_latest.stdenv;
in
stdenv.mkDerivation rec {
pname = "openmp" + (lib.optionalString enableNosv "-v");
inherit version;
src = runCommand "${pname}-src" {} ''
mkdir -p "$out"
cp -r ${monorepoSrc}/cmake "$out"
cp -r ${monorepoSrc}/openmp "$out"
'';
sourceRoot = "${src.name}/openmp";
nativeBuildInputs = [
cmake
ninja
perl
pkg-config
python3
];
buildInputs = lib.optionals enableNosv [
nosv
] ++ lib.optionals enableOvni [
ovni
];
doCheck = false;
hardeningDisable = [ "all" ];
cmakeBuildType = if enableDebug then "Debug" else "Release";
dontStrip = enableDebug;
separateDebugInfo = true;
strictDeps = true;
cmakeFlags = [
"-DLIBOMP_OMPD_SUPPORT=OFF"
"-DOPENMP_ENABLE_LIBOMPTARGET=OFF"
];
# Remove support for GNU and Intel Openmp.
# Also, remove libomp if building with nosv, as there is no support to build
# only one runtime at a time.
postInstall = ''
rm -f $out/lib/libgomp*
rm -f $out/lib/libiomp*
'' + lib.optionalString enableNosv ''
rm -f $out/lib/libomp.*
rm -f $out/libllvmrt/libomp.*
'';
doInstallCheck = true;
# There are not cmake flags to force nOS-V, it enables it when found through
# pkg-config. If enableNosv is set, but we fail to find it at build time,
# the build will succeed but won't use nOS-V (libompv won't be created).
# This is a sanity check to ensure that after install we have the proper
# files.
installCheckPhase =
if enableNosv then
''
test -f $out/lib/libompv.so
test -f $out/libllvmrt/libompv.so
test ! -f $out/lib/libomp.so
test ! -f $out/libllvmrt/libomp.so
''
else
''
test -f $out/lib/libomp.so
test -f $out/libllvmrt/libomp.so
test ! -f $out/lib/libompv.so
test ! -f $out/libllvmrt/libompv.so
'';
passthru = {
inherit nosv;
};
meta = {
homepage = "https://gitlab.pm.bsc.es/llvm-ompss/llvm-mono";
description = "Support for the OpenMP language (with nOS-V)";
maintainers = with lib.maintainers.bsc; [ rpenacob ];
platforms = lib.platforms.linux;
license = [ lib.licenses.asl20 lib.licenses.llvm-exception ];
};
}