Split OpenMP from Clang in LLVM

As the OpenMP-V implementation requires to be built with nOS-V, we can
split the OpenMP package in a different derivation to prevent rebuilds
of clang. Additionally, as OpenMP-V now can be build alongside the
vanilla OpenMP runtime, we simply build a single openmp derivation with
both runtimes. Only a single build of the clang compiler is now
required.

Reviewed-by: Aleix Roca Nonell <aleix.rocanonell@bsc.es>
Reviewed-by: Rodrigo Arias Mallo <rodrigo.arias@bsc.es>
This commit is contained in:
Raúl Peñacoba 2023-12-01 15:11:10 +01:00 committed by Rodrigo Arias Mallo
parent 2a953d811c
commit 8ceaddfea7
5 changed files with 66 additions and 20 deletions

View File

@ -12,11 +12,10 @@ let
bscPkgs = {
bench6 = callPackage ./pkgs/bench6/default.nix { };
clangOmpss2 = callPackage ./pkgs/llvm-ompss2/default.nix { };
openmp = callPackage ./pkgs/llvm-ompss2/openmp.nix { monorepoSrc = final.clangOmpss2Unwrapped.src; version = final.clangOmpss2Unwrapped.version; };
clangOmpss2Nanos6 = callPackage ./pkgs/llvm-ompss2/default.nix { ompss2rt = final.nanos6; };
clangOmpss2Nodes = callPackage ./pkgs/llvm-ompss2/default.nix { ompss2rt = final.nodes; };
clangOmpss2OpenmpNodes = callPackage ./pkgs/llvm-ompss2/default.nix { ompss2rt = final.nodes; clangOmpss2Unwrapped = final.clangOmpss2OpenmpUnwrapped; };
clangOmpss2Unwrapped = callPackage ./pkgs/llvm-ompss2/clang.nix { };
clangOmpss2OpenmpUnwrapped = final.clangOmpss2Unwrapped.override { enableNosv = true; };
#extrae = callPackage ./pkgs/extrae/default.nix { }; # Broken and outdated
gpi-2 = callPackage ./pkgs/gpi-2/default.nix { };
intelPackages_2023 = callPackage ./pkgs/intel-oneapi/2023.nix { };
@ -41,7 +40,6 @@ let
stdenvClangOmpss2 = final.stdenv.override { cc = final.clangOmpss2; allowedRequisites = null; };
stdenvClangOmpss2Nanos6 = final.stdenv.override { cc = final.clangOmpss2Nanos6; allowedRequisites = null; };
stdenvClangOmpss2Nodes = final.stdenv.override { cc = final.clangOmpss2Nodes; allowedRequisites = null; };
stdenvClangOmpss2OpenmpNodes = final.stdenv.override { cc = final.clangOmpss2OpenmpNodes; allowedRequisites = null; };
tagaspi = callPackage ./pkgs/tagaspi/default.nix { };
tampi = callPackage ./pkgs/tampi/default.nix { };
wxparaver = callPackage ./pkgs/paraver/default.nix { };
@ -76,10 +74,10 @@ in bscPkgs // {
stdenv = final.stdenvClangOmpss2Nodes;
};
clangNosvOpenmp-task = callPackage ./test/compilers/clang-openmp.nix {
stdenv = final.stdenvClangOmpss2OpenmpNodes;
stdenv = final.stdenvClangOmpss2Nodes;
};
clangNosvOpenmp-nosv = callPackage ./test/compilers/clang-openmp-nosv.nix {
stdenv = final.stdenvClangOmpss2OpenmpNodes;
stdenv = final.stdenvClangOmpss2Nodes;
};
};

View File

@ -10,11 +10,9 @@
, elfutils
, libffi
, zlib
, nosv
, pkg-config
, gcc # needed to set the rpath of libstdc++ for clang-tblgen
, enableDebug ? false
, enableNosv ? false
, useGit ? false
, gitUrl ? "ssh://git@bscpm03.bsc.es/llvm-ompss/llvm-mono.git"
, gitBranch ? "master"
@ -73,8 +71,6 @@ in stdenv.mkDerivation rec {
pkg-config
zlib
gcc.cc.lib # Required for libstdc++.so.6
] ++ lib.optionals enableNosv [
nosv
];
# Error with -D_FORTIFY_SOURCE=2, see https://bugs.gentoo.org/636604:
@ -107,15 +103,12 @@ in stdenv.mkDerivation rec {
"-DCMAKE_CXX_FLAGS_DEBUG=-g -ggnu-pubnames"
"-DCMAKE_EXE_LINKER_FLAGS_DEBUG=-Wl,--gdb-index"
"-DLLVM_LIT_ARGS=-sv --xunit-xml-output=xunit.xml"
"-DLLVM_ENABLE_PROJECTS=clang;openmp;compiler-rt;lld"
"-DLLVM_ENABLE_PROJECTS=clang;compiler-rt;lld"
"-DLLVM_ENABLE_ASSERTIONS=ON"
"-DLLVM_INSTALL_TOOLCHAIN_ONLY=ON"
"-DCMAKE_INSTALL_BINDIR=bin"
"-DLLVM_ENABLE_ZLIB=FORCE_ON"
"-DLLVM_ENABLE_LIBXML2=OFF"
'' + (lib.optionalString enableNosv ''
"-DCLANG_DEFAULT_NOSV_HOME=${nosv}"
'') + ''
# Set the rpath to include external libraries (zlib) both on build and
# install
"-DCMAKE_INSTALL_RPATH_USE_LINK_PATH=ON"
@ -124,12 +117,6 @@ in stdenv.mkDerivation rec {
'';
# Remove support for GNU and Intel Openmp
postInstall = ''
rm -f $out/lib/libgomp*
rm -f $out/lib/libiomp*
'';
# About "-DCLANG_DEFAULT_NANOS6_HOME=${nanos6}", we could specify a default
# nanos6 installation, but this is would require a recompilation of clang each
# time nanos6 is changed. Better to use the environment variable NANOS6_HOME,

View File

@ -0,0 +1,57 @@
{ lib
, llvmPackages_latest
, monorepoSrc
, runCommand
, cmake
, ninja
, llvm
, perl
, pkg-config
, version
, nosv
, enableDebug ? false
}:
let
stdenv = llvmPackages_latest.stdenv;
in
stdenv.mkDerivation rec {
pname = "openmp";
inherit version;
src = runCommand "${pname}-src" {} ''
mkdir -p "$out"
cp -r ${monorepoSrc}/cmake "$out"
cp -r ${monorepoSrc}/${pname} "$out"
'';
sourceRoot = "${src.name}/${pname}";
nativeBuildInputs = [
cmake
ninja
perl
pkg-config
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
postInstall = ''
rm -f $out/lib/libgomp*
rm -f $out/lib/libiomp*
'';
}

View File

@ -2,6 +2,7 @@
stdenv
, nosv
, writeText
, openmp
}:
let
@ -40,7 +41,7 @@ in stdenv.mkDerivation {
# fail to run otherwise, so we disable the sandbox for this test.
__noChroot = true;
buildInputs = [ nosv ];
buildInputs = [ nosv openmp ];
buildPhase = ''
set -x

View File

@ -1,6 +1,7 @@
{
stdenv
, writeText
, openmp
}:
let
@ -28,6 +29,8 @@ in stdenv.mkDerivation {
# fail to run otherwise, so we disable the sandbox for this test.
__noChroot = true;
buildInputs = [ openmp ];
buildPhase = ''
set -x