bscpkgs/pkgs/llvm-ompss2/clang.nix

136 lines
3.3 KiB
Nix
Raw Normal View History

2020-06-17 19:00:49 +08:00
{
llvmPackages_latest
, lib
2020-11-20 01:50:30 +08:00
, fetchFromGitHub
2020-06-17 19:00:49 +08:00
, cmake
, bash
, python3
, perl
, which
, elfutils
2020-06-17 19:00:49 +08:00
, libffi
, zlib
, nosv
2020-06-17 19:00:49 +08:00
, pkg-config
2020-11-20 01:50:30 +08:00
, enableDebug ? false
, enableNosv ? false
, useGit ? false
, gitUrl ? "ssh://git@bscpm03.bsc.es/llvm-ompss/llvm-mono.git"
, gitBranch ? "master"
, gitCommit ? "8d106db69c02fb6ec10baedc47b76f068b419d4a"
2020-06-17 19:00:49 +08:00
}:
let
stdenv = llvmPackages_latest.stdenv;
2020-11-20 01:50:30 +08:00
release = rec {
version = "2023.05.1";
src = fetchFromGitHub {
owner = "bsc-pm";
repo = "llvm";
rev = "refs/tags/github-release-${version}";
sha256 = "sha256-NB/27F1ZRJf6MXFQjinT2gCsoPbEZYlBMhd3uKcK2GM=";
};
};
git = rec {
version = src.shortRev;
src = builtins.fetchGit {
url = gitUrl;
ref = gitBranch;
rev = gitCommit;
};
2020-11-20 01:50:30 +08:00
};
source = if (useGit) then git else release;
in stdenv.mkDerivation rec {
pname = "clang-ompss2";
inherit (source) src version;
2020-06-17 19:00:49 +08:00
enableParallelBuilding = true;
2020-07-21 22:31:31 +08:00
isClang = true;
2020-06-17 19:00:49 +08:00
passthru = {
CC = "clang";
CXX = "clang++";
};
2020-06-17 19:00:49 +08:00
isClangWithOmpss = true;
nativeBuildInputs = [ zlib ];
2020-06-17 19:00:49 +08:00
buildInputs = [
which
bash
python3
perl
cmake
llvmPackages_latest.lld
elfutils
2020-06-17 19:00:49 +08:00
libffi
pkg-config
zlib
] ++ lib.optionals enableNosv [
nosv
2020-06-17 19:00:49 +08:00
];
2020-11-20 01:50:30 +08:00
# Error with -D_FORTIFY_SOURCE=2, see https://bugs.gentoo.org/636604:
# /build/source/compiler-rt/lib/tsan/dd/dd_interceptors.cpp:225:20:
# error: redefinition of 'realpath'
# Requires disabling the "fortify" set of flags, however, for performance we
# disable all:
hardeningDisable = [ "all" ];
2020-06-17 19:00:49 +08:00
cmakeBuildType = if enableDebug then "Debug" else "Release";
dontStrip = enableDebug;
2020-06-17 19:00:49 +08:00
dontUseCmakeBuildDir = true;
# Fix the host triple, as it has changed in a newer config.guess:
# https://git.savannah.gnu.org/gitweb/?p=config.git;a=commitdiff;h=ca9bfb8cc75a2be1819d89c664a867785c96c9ba
2020-06-17 19:00:49 +08:00
preConfigure = ''
mkdir -p build
cd build
cmakeDir="../llvm"
cmakeFlagsArray=(
"-DLLVM_HOST_TRIPLE=${stdenv.targetPlatform.config}"
"-DLLVM_TARGETS_TO_BUILD=host"
"-DLLVM_BUILD_LLVM_DYLIB=ON"
"-DLLVM_LINK_LLVM_DYLIB=ON"
# Required to run clang-ast-dump and clang-tblgen during build
"-DCMAKE_BUILD_RPATH=$PWD/lib:${zlib}/lib"
2020-06-17 19:00:49 +08:00
"-DLLVM_ENABLE_LLD=ON"
"-DCMAKE_CXX_FLAGS_DEBUG=-g -ggnu-pubnames"
"-DCMAKE_EXE_LINKER_FLAGS_DEBUG=-Wl,--gdb-index"
2020-06-17 19:00:49 +08:00
"-DLLVM_LIT_ARGS=-sv --xunit-xml-output=xunit.xml"
2023-05-30 20:52:42 +08:00
"-DLLVM_ENABLE_PROJECTS=clang;openmp;compiler-rt;lld"
"-DLLVM_ENABLE_ASSERTIONS=ON"
2020-06-17 19:00:49 +08:00
"-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"
"-DCMAKE_INSTALL_RPATH=${zlib}/lib"
2020-06-17 19:00:49 +08:00
)
'';
2020-07-06 21:58:09 +08:00
# Remove support for GNU and Intel Openmp
postInstall = ''
rm -f $out/lib/libgomp*
rm -f $out/lib/libiomp*
2020-07-06 21:58:09 +08:00
'';
2020-06-17 19:00:49 +08:00
# 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.
}