Add llvm-epi clang compiler
This commit is contained in:
parent
46f699f1c2
commit
8047a6a4eb
@ -3,6 +3,10 @@ final: prev:
|
|||||||
# Changes to packages from nixpkgs
|
# Changes to packages from nixpkgs
|
||||||
|
|
||||||
{
|
{
|
||||||
|
clangEpi = final.callPackage ./pkgs/llvm-epi/default.nix { openmp = null; };
|
||||||
|
clangEpiUnwrapped = final.callPackage ./pkgs/llvm-epi/clang.nix { };
|
||||||
|
stdenvClangEpi = final.stdenv.override { cc = final.buildPackages.clangEpi; allowedRequisites = null; };
|
||||||
|
|
||||||
blis = ((prev.blis.override {
|
blis = ((prev.blis.override {
|
||||||
blas64 = true;
|
blas64 = true;
|
||||||
withArchitecture = "generic";
|
withArchitecture = "generic";
|
||||||
|
124
pkgs/llvm-epi/clang.nix
Normal file
124
pkgs/llvm-epi/clang.nix
Normal file
@ -0,0 +1,124 @@
|
|||||||
|
{
|
||||||
|
stdenv
|
||||||
|
, llvmPackages_latest
|
||||||
|
, lib
|
||||||
|
, fetchFromGitHub
|
||||||
|
, cmake
|
||||||
|
, bash
|
||||||
|
, python3
|
||||||
|
, perl
|
||||||
|
, which
|
||||||
|
, elfutils
|
||||||
|
, libffi
|
||||||
|
, zlib
|
||||||
|
, pkg-config
|
||||||
|
, enableDebug ? false
|
||||||
|
, gitUrl ? "https://repo.hca.bsc.es/gitlab/rferrer/llvm-epi.git"
|
||||||
|
, gitBranch ? "EPI-0.7"
|
||||||
|
, gitCommit ? "479518dc58dfceb23fc90667a5d6253e429f0fc2"
|
||||||
|
}:
|
||||||
|
|
||||||
|
let
|
||||||
|
llvmPackages = llvmPackages_latest;
|
||||||
|
llvmStdenv = llvmPackages.stdenv;
|
||||||
|
# needed to set the rpath of libstdc++ for clang-tblgen
|
||||||
|
gcc = stdenv.cc;
|
||||||
|
|
||||||
|
git = rec {
|
||||||
|
version = src.shortRev;
|
||||||
|
src = builtins.fetchGit {
|
||||||
|
url = gitUrl;
|
||||||
|
ref = gitBranch;
|
||||||
|
rev = gitCommit;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
source = git;
|
||||||
|
|
||||||
|
in llvmStdenv.mkDerivation rec {
|
||||||
|
pname = "clang-epi";
|
||||||
|
inherit (source) src version;
|
||||||
|
|
||||||
|
enableParallelBuilding = true;
|
||||||
|
isClang = true;
|
||||||
|
|
||||||
|
patches = if (gitBranch == "EPI-0.7") then [
|
||||||
|
./include-cstdint.patch
|
||||||
|
] else [
|
||||||
|
];
|
||||||
|
|
||||||
|
# See https://reviews.llvm.org/D135402
|
||||||
|
env.LDFLAGS = "-Wl,--undefined-version";
|
||||||
|
|
||||||
|
passthru = {
|
||||||
|
CC = "clang";
|
||||||
|
CXX = "clang++";
|
||||||
|
};
|
||||||
|
|
||||||
|
nativeBuildInputs = [
|
||||||
|
zlib
|
||||||
|
gcc.cc.lib # Required for libstdc++.so.6
|
||||||
|
];
|
||||||
|
|
||||||
|
buildInputs = [
|
||||||
|
which
|
||||||
|
bash
|
||||||
|
python3
|
||||||
|
perl
|
||||||
|
cmake
|
||||||
|
llvmPackages.lld
|
||||||
|
elfutils
|
||||||
|
libffi
|
||||||
|
pkg-config
|
||||||
|
zlib
|
||||||
|
];
|
||||||
|
|
||||||
|
# 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" ];
|
||||||
|
|
||||||
|
cmakeBuildType = if enableDebug then "Debug" else "Release";
|
||||||
|
|
||||||
|
dontStrip = enableDebug;
|
||||||
|
|
||||||
|
dontUseCmakeBuildDir = true;
|
||||||
|
|
||||||
|
# Fix shebangs, /usr/bin/env doesn't exist
|
||||||
|
prePatch = ''
|
||||||
|
patchShebangs clang/utils/EPI/generate-epi-builtins-def.py
|
||||||
|
'';
|
||||||
|
|
||||||
|
# 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
|
||||||
|
preConfigure = ''
|
||||||
|
mkdir -p build
|
||||||
|
cd build
|
||||||
|
cmakeDir="../llvm"
|
||||||
|
cmakeFlagsArray=(
|
||||||
|
"-DLLVM_HOST_TRIPLE=${llvmStdenv.targetPlatform.config}"
|
||||||
|
"-DLLVM_DEFAULT_TARGET_TRIPLE=riscv64-unknown-linux-gnu"
|
||||||
|
"-DLLVM_TARGETS_TO_BUILD=RISCV"
|
||||||
|
"-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:${gcc.cc.lib}/lib"
|
||||||
|
"-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;lld"
|
||||||
|
"-DLLVM_ENABLE_ASSERTIONS=ON"
|
||||||
|
"-DLLVM_INSTALL_TOOLCHAIN_ONLY=ON"
|
||||||
|
"-DCMAKE_INSTALL_BINDIR=bin"
|
||||||
|
"-DLLVM_ENABLE_ZLIB=FORCE_ON"
|
||||||
|
"-DLLVM_ENABLE_LIBXML2=OFF"
|
||||||
|
# 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:${gcc.cc.lib}/lib"
|
||||||
|
)
|
||||||
|
'';
|
||||||
|
}
|
46
pkgs/llvm-epi/default.nix
Normal file
46
pkgs/llvm-epi/default.nix
Normal file
@ -0,0 +1,46 @@
|
|||||||
|
{
|
||||||
|
stdenv
|
||||||
|
, lib
|
||||||
|
, gcc
|
||||||
|
, clangEpiUnwrapped
|
||||||
|
, openmp ? null
|
||||||
|
, wrapCCWith
|
||||||
|
, llvmPackages_latest
|
||||||
|
, ompss2rt ? null
|
||||||
|
}:
|
||||||
|
|
||||||
|
let
|
||||||
|
# We need to replace the lld linker from bintools with our linker just built,
|
||||||
|
# otherwise we run into incompatibility issues when mixing compiler and linker
|
||||||
|
# versions.
|
||||||
|
bintools-unwrapped = llvmPackages_latest.tools.bintools-unwrapped.override {
|
||||||
|
lld = clangEpiUnwrapped;
|
||||||
|
};
|
||||||
|
bintools = llvmPackages_latest.tools.bintools.override {
|
||||||
|
bintools = bintools-unwrapped;
|
||||||
|
};
|
||||||
|
targetConfig = stdenv.targetPlatform.config;
|
||||||
|
inherit gcc;
|
||||||
|
cc = clangEpiUnwrapped;
|
||||||
|
in wrapCCWith {
|
||||||
|
inherit cc bintools;
|
||||||
|
# extraPackages adds packages to depsTargetTargetPropagated
|
||||||
|
extraPackages = lib.optional (openmp != null) openmp;
|
||||||
|
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}/lib" >> $out/nix-support/cc-ldflags
|
||||||
|
|
||||||
|
for dir in ${gcc.cc}/include/c++/*; do
|
||||||
|
echo "-isystem $dir" >> $out/nix-support/libcxx-cxxflags
|
||||||
|
done
|
||||||
|
for dir in ${gcc.cc}/include/c++/*/${targetConfig}; do
|
||||||
|
echo "-isystem $dir" >> $out/nix-support/libcxx-cxxflags
|
||||||
|
done
|
||||||
|
|
||||||
|
echo "--gcc-toolchain=${gcc}" >> $out/nix-support/cc-cflags
|
||||||
|
|
||||||
|
wrap clang++ $wrapper $ccPath/clang++
|
||||||
|
'';
|
||||||
|
}
|
10
pkgs/llvm-epi/include-cstdint.patch
Normal file
10
pkgs/llvm-epi/include-cstdint.patch
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
--- a/llvm/include/llvm/Support/Signals.h 2024-09-25 08:34:21.257642944 +0200
|
||||||
|
+++ b/llvm/include/llvm/Support/Signals.h 2024-09-25 08:35:12.593556793 +0200
|
||||||
|
@@ -15,6 +15,7 @@
|
||||||
|
#define LLVM_SUPPORT_SIGNALS_H
|
||||||
|
|
||||||
|
#include <string>
|
||||||
|
+#include <cstdint>
|
||||||
|
|
||||||
|
namespace llvm {
|
||||||
|
class StringRef;
|
Loading…
Reference in New Issue
Block a user