bscpkgs/pkgs/llvm-ompss2/openmp.nix
Aleix Roca Nonell c4d5135fde Split openmp versions in separate derivations
The openmp derivation provides both libomp and libompv. To avoid
accidentally linking with the wrong library and to avoid the nosv
dependency on libomp, this patch separates each version in a different
derivation.

Also, it adapts the clang wrappers and stdenvs to provide an stdenv per
openmp library where each openmp will be used by default when the
compiler flag "-fopenmp" is used. This eases linking ompv with nixpkgs
libraries, such as blis, that expect openmp to be provided with stdenv.

Reviewed-by: Rodrigo Arias Mallo <rodrigo.arias@bsc.es>
Tested-by: Rodrigo Arias Mallo <rodrigo.arias@bsc.es>
2023-12-07 18:01:20 +01:00

68 lines
1.2 KiB
Nix

{ lib
, llvmPackages_latest
, monorepoSrc
, runCommand
, cmake
, ninja
, llvm
, perl
, pkg-config
, version
, nosv
, enableNosv ? false
, enableDebug ? false
}:
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
] ++ lib.optionals enableNosv [
nosv
];
doCheck = false;
hardeningDisable = [ "all" ];
cmakeBuildType = if enableDebug then "Debug" else "Release";
dontStrip = enableDebug;
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.*
'';
passthru = {
inherit nosv;
};
}