2020-06-17 13:00:49 +02:00
|
|
|
{
|
2023-09-19 10:33:32 +02:00
|
|
|
llvmPackages_latest
|
2023-10-31 10:36:18 +01:00
|
|
|
, lib
|
2020-11-19 18:50:30 +01:00
|
|
|
, fetchFromGitHub
|
2020-06-17 13:00:49 +02:00
|
|
|
, cmake
|
|
|
|
, bash
|
|
|
|
, python3
|
|
|
|
, perl
|
|
|
|
, which
|
2022-02-14 20:44:39 +01:00
|
|
|
, elfutils
|
2020-06-17 13:00:49 +02:00
|
|
|
, libffi
|
2023-06-28 10:45:03 +02:00
|
|
|
, zlib
|
2020-06-17 13:00:49 +02:00
|
|
|
, pkg-config
|
2023-11-21 16:58:57 +01:00
|
|
|
, gcc # needed to set the rpath of libstdc++ for clang-tblgen
|
2020-11-19 18:50:30 +01:00
|
|
|
, enableDebug ? false
|
2023-10-31 10:36:18 +01:00
|
|
|
, useGit ? false
|
|
|
|
, gitUrl ? "ssh://git@bscpm03.bsc.es/llvm-ompss/llvm-mono.git"
|
|
|
|
, gitBranch ? "master"
|
2023-11-24 15:22:50 +01:00
|
|
|
, gitCommit ? "0a6d6c64b04f9bbbe1399f18be426e191fb6b42c"
|
2020-06-17 13:00:49 +02:00
|
|
|
}:
|
|
|
|
|
2023-09-19 10:33:32 +02:00
|
|
|
let
|
|
|
|
stdenv = llvmPackages_latest.stdenv;
|
2020-11-19 18:50:30 +01:00
|
|
|
|
2023-10-31 10:36:18 +01:00
|
|
|
release = rec {
|
2023-12-05 11:58:03 +01:00
|
|
|
version = "18.0.0-ompss-2";
|
2023-10-31 10:36:18 +01:00
|
|
|
src = fetchFromGitHub {
|
|
|
|
owner = "bsc-pm";
|
|
|
|
repo = "llvm";
|
2023-12-05 11:58:03 +01:00
|
|
|
rev = "refs/tags/${version}";
|
|
|
|
hash = "sha256-Z0TVrujOQNHiAuTlyexbIBA2pOk2Tdmv7JuQn3M3foY=";
|
2023-10-31 10:36:18 +01:00
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
git = rec {
|
|
|
|
version = src.shortRev;
|
|
|
|
src = builtins.fetchGit {
|
|
|
|
url = gitUrl;
|
|
|
|
ref = gitBranch;
|
|
|
|
rev = gitCommit;
|
|
|
|
};
|
2020-11-19 18:50:30 +01:00
|
|
|
};
|
|
|
|
|
2023-10-31 10:36:18 +01:00
|
|
|
source = if (useGit) then git else release;
|
|
|
|
|
|
|
|
in stdenv.mkDerivation rec {
|
|
|
|
pname = "clang-ompss2";
|
|
|
|
inherit (source) src version;
|
|
|
|
|
2020-06-17 13:00:49 +02:00
|
|
|
enableParallelBuilding = true;
|
2020-07-21 16:31:31 +02:00
|
|
|
isClang = true;
|
2020-06-17 13:00:49 +02:00
|
|
|
|
2020-07-27 17:55:35 +02:00
|
|
|
passthru = {
|
|
|
|
CC = "clang";
|
|
|
|
CXX = "clang++";
|
|
|
|
};
|
|
|
|
|
2020-06-17 13:00:49 +02:00
|
|
|
isClangWithOmpss = true;
|
|
|
|
|
2023-06-28 10:45:03 +02:00
|
|
|
nativeBuildInputs = [ zlib ];
|
|
|
|
|
2020-06-17 13:00:49 +02:00
|
|
|
buildInputs = [
|
|
|
|
which
|
|
|
|
bash
|
|
|
|
python3
|
|
|
|
perl
|
|
|
|
cmake
|
2023-09-19 10:33:32 +02:00
|
|
|
llvmPackages_latest.lld
|
2022-02-14 20:44:39 +01:00
|
|
|
elfutils
|
2020-06-17 13:00:49 +02:00
|
|
|
libffi
|
|
|
|
pkg-config
|
2023-06-28 10:45:03 +02:00
|
|
|
zlib
|
2023-11-21 16:58:57 +01:00
|
|
|
gcc.cc.lib # Required for libstdc++.so.6
|
2020-06-17 13:00:49 +02:00
|
|
|
];
|
|
|
|
|
2020-11-19 18:50:30 +01: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'
|
2021-04-21 19:42:37 +02:00
|
|
|
# Requires disabling the "fortify" set of flags, however, for performance we
|
|
|
|
# disable all:
|
|
|
|
hardeningDisable = [ "all" ];
|
2020-07-02 21:10:44 +02:00
|
|
|
|
2020-06-17 13:00:49 +02:00
|
|
|
cmakeBuildType = if enableDebug then "Debug" else "Release";
|
|
|
|
|
2023-11-15 15:25:26 +01:00
|
|
|
dontStrip = enableDebug;
|
|
|
|
|
2020-06-17 13:00:49 +02:00
|
|
|
dontUseCmakeBuildDir = true;
|
|
|
|
|
2023-09-01 16:44:17 +02:00
|
|
|
# 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 13:00:49 +02:00
|
|
|
preConfigure = ''
|
|
|
|
mkdir -p build
|
|
|
|
cd build
|
|
|
|
cmakeDir="../llvm"
|
|
|
|
cmakeFlagsArray=(
|
2023-09-01 16:44:17 +02:00
|
|
|
"-DLLVM_HOST_TRIPLE=${stdenv.targetPlatform.config}"
|
2023-09-05 17:55:38 +02:00
|
|
|
"-DLLVM_TARGETS_TO_BUILD=host"
|
2023-09-06 14:14:40 +02:00
|
|
|
"-DLLVM_BUILD_LLVM_DYLIB=ON"
|
|
|
|
"-DLLVM_LINK_LLVM_DYLIB=ON"
|
|
|
|
# Required to run clang-ast-dump and clang-tblgen during build
|
2023-11-21 16:58:57 +01:00
|
|
|
"-DCMAKE_BUILD_RPATH=$PWD/lib:${zlib}/lib:${gcc.cc.lib}/lib"
|
2020-06-17 13:00:49 +02:00
|
|
|
"-DLLVM_ENABLE_LLD=ON"
|
|
|
|
"-DCMAKE_CXX_FLAGS_DEBUG=-g -ggnu-pubnames"
|
2023-11-14 10:45:27 +01:00
|
|
|
"-DCMAKE_EXE_LINKER_FLAGS_DEBUG=-Wl,--gdb-index"
|
2020-06-17 13:00:49 +02:00
|
|
|
"-DLLVM_LIT_ARGS=-sv --xunit-xml-output=xunit.xml"
|
2023-12-01 15:11:10 +01:00
|
|
|
"-DLLVM_ENABLE_PROJECTS=clang;compiler-rt;lld"
|
2023-11-09 15:03:08 +01:00
|
|
|
"-DLLVM_ENABLE_ASSERTIONS=ON"
|
2020-06-17 13:00:49 +02:00
|
|
|
"-DLLVM_INSTALL_TOOLCHAIN_ONLY=ON"
|
2022-02-21 15:58:16 +01:00
|
|
|
"-DCMAKE_INSTALL_BINDIR=bin"
|
2023-06-28 10:45:03 +02:00
|
|
|
"-DLLVM_ENABLE_ZLIB=FORCE_ON"
|
|
|
|
"-DLLVM_ENABLE_LIBXML2=OFF"
|
2023-06-28 11:18:35 +02:00
|
|
|
# Set the rpath to include external libraries (zlib) both on build and
|
|
|
|
# install
|
|
|
|
"-DCMAKE_INSTALL_RPATH_USE_LINK_PATH=ON"
|
2023-11-21 16:58:57 +01:00
|
|
|
"-DCMAKE_INSTALL_RPATH=${zlib}/lib:${gcc.cc.lib}/lib"
|
2020-06-17 13:00:49 +02:00
|
|
|
)
|
2023-06-28 10:45:03 +02:00
|
|
|
'';
|
|
|
|
|
2020-06-17 13:00:49 +02: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.
|
|
|
|
}
|