Working stdenv with clang+ompss2

This commit is contained in:
Rodrigo Arias 2020-06-17 13:00:49 +02:00
parent a8523c4b4e
commit 19e4e12126
7 changed files with 178 additions and 85 deletions

View File

@ -27,12 +27,12 @@ stdenv.mkDerivation rec {
# };
postConfigure = ''
env | grep NIX
env
'';
# export NANOS6_HOME="${nanos6}"
preConfigure = ''
export NANOS6_HOME="${nanos6}"
export TAMPI_HOME="${tampi}"
'';

68
bsc/llvm-ompss2/clang.nix Normal file
View File

@ -0,0 +1,68 @@
{
stdenv
, fetchgit
, cmake
, lld
, bash
, python3
, perl
, clang
, which
, libelf
, libffi
, pkg-config
, enableDebug ? true
}:
stdenv.mkDerivation rec {
version = "11.0.0";
pname = "clang-ompss2";
enableParallelBuilding = true;
#isClang = true;
#isGNU = true;
isClangWithOmpss = true;
buildInputs = [
which
clang
bash
python3
perl
cmake
lld
libelf
libffi
pkg-config
];
cmakeBuildType = if enableDebug then "Debug" else "Release";
dontUseCmakeBuildDir = true;
preConfigure = ''
mkdir -p build
cd build
cmakeDir="../llvm"
cmakeFlagsArray=(
"-DLLVM_ENABLE_LLD=ON"
"-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"
"-DLLVM_ENABLE_ASSERTIONS=ON"
"-DLLVM_INSTALL_TOOLCHAIN_ONLY=ON"
)
'';
# 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,
# and specify nanos6 at run time.
src = builtins.fetchGit {
url = "git@bscpm02.bsc.es:llvm-ompss/llvm-mono.git";
rev = "38e2e6aac04d40b6b2823751ce25f6b414f52263";
ref = "master";
};
}

View File

@ -1,63 +1,27 @@
{
stdenv
, fetchgit
, cmake
, lld
, bash
, python3
, perl
, clang
, which
, libelf
, libffi
, pkg-config
, enableDebug ? true
, gcc
, nanos6
, clang-ompss2-unwrapped
, wrapCCWith
, libstdcxxHook
}:
stdenv.mkDerivation rec {
version = "11.0.0";
pname = "clang-ompss2";
enableParallelBuilding = true;
isClang = true;
isGNU = true;
isClangWithOmpss = true;
let
targetConfig = stdenv.targetPlatform.config;
inherit gcc nanos6;
in wrapCCWith rec {
cc = clang-ompss2-unwrapped;
extraPackages = [ libstdcxxHook ];
extraBuildCommands = ''
echo "-target ${targetConfig}" >> $out/nix-support/cc-cflags
echo "-B${gcc.cc}/lib/gcc/${targetConfig}/${gcc.version}" >> $out/nix-support/cc-cflags
echo "-L${gcc.cc}/lib/gcc/${targetConfig}/${gcc.version}" >> $out/nix-support/cc-ldflags
echo "-L${gcc.cc.lib}/${targetConfig}/lib" >> $out/nix-support/cc-ldflags
echo "--gcc-toolchain=${gcc}" >> $out/nix-support/cc-cflags
buildInputs = [
which
clang
bash
python3
perl
cmake
lld
libelf
libffi
pkg-config
];
cmakeBuildType = if enableDebug then "Debug" else "Release";
dontUseCmakeBuildDir = true;
preConfigure = ''
mkdir -p build
cd build
cmakeDir="../llvm"
cmakeFlagsArray=(
"-DLLVM_ENABLE_LLD=ON"
"-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"
"-DLLVM_ENABLE_ASSERTIONS=ON"
"-DLLVM_INSTALL_TOOLCHAIN_ONLY=ON"
)
echo "# Hack to include NANOS6_HOME" >> $out/nix-support/setup-hook
echo "export NANOS6_HOME=${nanos6}" >> $out/nix-support/setup-hook
'';
src = builtins.fetchGit {
url = "git@bscpm02.bsc.es:llvm-ompss/llvm-mono.git";
rev = "38e2e6aac04d40b6b2823751ce25f6b414f52263";
ref = "master";
};
}

View File

@ -3,11 +3,8 @@
let
inherit (pkgs.lib) callPackageWith;
inherit (pkgs.lib) callPackagesWith;
inherit (pkgs) pythonPackages;
inherit (pkgs) perlPackages;
inherit (pkgs) buildPerlPackage;
#callPackage = callPackageWith (pkgs);
callPackage = callPackageWith (pkgs // self.bsc);
callPackage_i686 = callPackageWith (pkgs.pkgsi686Linux // self.bsc);
callPackages = callPackagesWith (pkgs // self.bsc);
self.bsc = rec {
@ -51,20 +48,22 @@ let
extrae = extrae;
};
clang-ompss2-unwrapped = callPackage ./bsc/llvm-ompss2/default.nix { };
#
# clang-ompss2 = import ./bsc/cc-wrapper/default.nix {
## inherit stdenv binutils coreutils ;
## stdenv = bsc.stdenv;
# coreutils = pkgs.coreutils;
# bintools = pkgs.binutils;
# gnugrep = pkgs.gnugrep;
# stdenvNoCC = pkgs.stdenvNoCC;
# libc = pkgs.glibc;
# nativeTools = false;
# nativeLibc = false;
# cc = clang-ompss2-unwrapped;
# };
clang-ompss2 = import ./bsc/cc-wrapper/default.nix {
# inherit stdenv binutils coreutils ;
# stdenv = bsc.stdenv;
coreutils = pkgs.coreutils;
bintools = pkgs.binutils;
gnugrep = pkgs.gnugrep;
stdenvNoCC = pkgs.stdenvNoCC;
libc = pkgs.glibc;
nativeTools = false;
nativeLibc = false;
cc = clang-ompss2-unwrapped;
};
# gcc = lib.makeOverridable (import ./bsc/cc-wrapper/default.nix) {
# nativeTools = false;
@ -110,22 +109,50 @@ let
# llvmPackages_latest = llvmPackages_10;
stdenv_nanos6 = pkgs.clangStdenv.override {
cc = clang-ompss2;
};
cpic = callPackage ./bsc/cpic/default.nix {
stdenv = stdenv_nanos6;
tampi = tampi;
mpi = mpi;
nanos6 = nanos6-git;
# llvm-ompss2 = llvm-ompss2;
};
#
# cpic = callPackage ./bsc/cpic/default.nix {
# stdenv = stdenv_nanos6;
# tampi = tampi;
# mpi = mpi;
# nanos6 = nanos6-git;
## llvm-ompss2 = llvm-ompss2;
# };
dummy = callPackage ./bsc/dummy/default.nix {
};
chroot = callPackage ./test/chroot.nix {};
# llvmOmpss2Packages = callPackage bsc/llvm-ompss2/11/default.nix {};
clang-ompss2-unwrapped = callPackage ./bsc/llvm-ompss2/clang.nix {
stdenv = pkgs.llvmPackages_10.stdenv;
};
clang-ompss2 = callPackage bsc/llvm-ompss2/default.nix {
nanos6 = nanos6-git;
inherit clang-ompss2-unwrapped;
};
stdenv-nanos6 = pkgs.clangStdenv.override {
cc = clang-ompss2;
};
test-clang-ompss2 = callPackage ./test/compilers/clang-ompss2.nix {
stdenv = stdenv-nanos6;
nanos6 = nanos6-git;
inherit clang-ompss2;
};
cpic = callPackage ./bsc/cpic/default.nix {
stdenv = stdenv-nanos6;
tampi = tampi;
mpi = mpi;
nanos6 = nanos6-git;
# llvm-ompss2 = llvm-ompss2;
};
};
in pkgs // self

View File

@ -0,0 +1,20 @@
{stdenv, clang-ompss2, nanos6}:
stdenv.mkDerivation rec {
version = "0.0.1";
name = "test-clang-ompss2";
src = ./.;
buildInputs = [ clang-ompss2 nanos6 ];
buildPhase = ''
export NIX_DEBUG=6
clang -fompss-2 hello.c -o hello
./hello
clang -fompss-2 hello.cc -o hello
./hello
'';
installPhase = ''
mkdir -p $out
'';
}

7
test/compilers/hello.c Normal file
View File

@ -0,0 +1,7 @@
#include <stdio.h>
int main()
{
printf("Hello world!\n");
return 0;
}

7
test/compilers/hello.cc Normal file
View File

@ -0,0 +1,7 @@
#include <stdio.h>
int main()
{
printf("Hello world!\n");
return 0;
}