2021-02-05 17:12:51 +00:00
|
|
|
{ lowPrio, newScope, pkgs, lib, stdenv, cmake, gccForLibs
|
2020-04-24 23:36:52 +00:00
|
|
|
, libxml2, python3, isl, fetchurl, overrideCC, wrapCCWith
|
|
|
|
, buildLlvmTools # tools, but from the previous stage, for cross
|
|
|
|
, targetLlvmLibraries # libraries, but from the next stage, for cross
|
|
|
|
}:
|
|
|
|
|
|
|
|
let
|
|
|
|
release_version = "5.0.2";
|
|
|
|
version = release_version; # differentiating these is important for rc's
|
|
|
|
targetConfig = stdenv.targetPlatform.config;
|
|
|
|
|
|
|
|
fetch = name: sha256: fetchurl {
|
|
|
|
url = "https://releases.llvm.org/${release_version}/${name}-${version}.src.tar.xz";
|
|
|
|
inherit sha256;
|
|
|
|
};
|
|
|
|
|
|
|
|
clang-tools-extra_src = fetch "clang-tools-extra" "018b3fiwah8f8br5i26qmzh6sjvzchpn358sn8v079m49f2jldm3";
|
|
|
|
|
2021-05-28 09:39:13 +00:00
|
|
|
llvm_meta = {
|
|
|
|
license = lib.licenses.ncsa;
|
|
|
|
maintainers = with lib.maintainers; [ lovek323 raskin dtzWill primeos ];
|
|
|
|
platforms = lib.platforms.all;
|
|
|
|
};
|
|
|
|
|
2021-02-05 17:12:51 +00:00
|
|
|
tools = lib.makeExtensible (tools: let
|
2021-05-20 23:08:51 +00:00
|
|
|
callPackage = newScope (tools // { inherit stdenv cmake libxml2 python3 isl release_version version fetch buildLlvmTools; });
|
2020-04-24 23:36:52 +00:00
|
|
|
mkExtraBuildCommands = cc: ''
|
|
|
|
rsrc="$out/resource-root"
|
|
|
|
mkdir "$rsrc"
|
2021-05-20 23:08:51 +00:00
|
|
|
ln -s "${cc.lib}/lib/clang/${release_version}/include" "$rsrc"
|
2020-04-24 23:36:52 +00:00
|
|
|
echo "-resource-dir=$rsrc" >> $out/nix-support/cc-cflags
|
2021-05-28 09:39:13 +00:00
|
|
|
ln -s "${targetLlvmLibraries.compiler-rt.out}/lib" "$rsrc/lib"
|
2020-04-24 23:36:52 +00:00
|
|
|
'';
|
2021-05-20 23:08:51 +00:00
|
|
|
|
2020-04-24 23:36:52 +00:00
|
|
|
in {
|
|
|
|
|
2021-05-28 09:39:13 +00:00
|
|
|
libllvm = callPackage ./llvm {
|
|
|
|
inherit llvm_meta;
|
|
|
|
};
|
2021-05-20 23:08:51 +00:00
|
|
|
|
|
|
|
# `llvm` historically had the binaries. When choosing an output explicitly,
|
|
|
|
# we need to reintroduce `outputUnspecified` to get the expected behavior e.g. of lib.get*
|
|
|
|
llvm = tools.libllvm.out // { outputUnspecified = true; };
|
|
|
|
|
2021-05-28 09:39:13 +00:00
|
|
|
libllvm-polly = callPackage ./llvm {
|
|
|
|
inherit llvm_meta;
|
|
|
|
enablePolly = true;
|
|
|
|
};
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2021-05-20 23:08:51 +00:00
|
|
|
llvm-polly = tools.libllvm-polly.lib // { outputUnspecified = true; };
|
|
|
|
|
|
|
|
libclang = callPackage ./clang {
|
2021-05-28 09:39:13 +00:00
|
|
|
inherit clang-tools-extra_src llvm_meta;
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
|
2021-05-20 23:08:51 +00:00
|
|
|
clang-unwrapped = tools.libclang.out // { outputUnspecified = true; };
|
|
|
|
|
|
|
|
llvm-manpages = lowPrio (tools.libllvm.override {
|
2020-04-24 23:36:52 +00:00
|
|
|
enableManpages = true;
|
|
|
|
python3 = pkgs.python3; # don't use python-boot
|
|
|
|
});
|
|
|
|
|
2021-05-20 23:08:51 +00:00
|
|
|
clang-manpages = lowPrio (tools.libclang.override {
|
2020-04-24 23:36:52 +00:00
|
|
|
enableManpages = true;
|
|
|
|
python3 = pkgs.python3; # don't use python-boot
|
|
|
|
});
|
|
|
|
|
|
|
|
clang = if stdenv.cc.isGNU then tools.libstdcxxClang else tools.libcxxClang;
|
|
|
|
|
|
|
|
libstdcxxClang = wrapCCWith rec {
|
|
|
|
cc = tools.clang-unwrapped;
|
2020-08-20 17:08:02 +00:00
|
|
|
# libstdcxx is taken from gcc in an ad-hoc way in cc-wrapper.
|
|
|
|
libcxx = null;
|
2020-04-24 23:36:52 +00:00
|
|
|
extraPackages = [
|
|
|
|
targetLlvmLibraries.compiler-rt
|
|
|
|
];
|
2020-07-18 16:06:22 +00:00
|
|
|
extraBuildCommands = mkExtraBuildCommands cc;
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
libcxxClang = wrapCCWith rec {
|
|
|
|
cc = tools.clang-unwrapped;
|
|
|
|
libcxx = targetLlvmLibraries.libcxx;
|
|
|
|
extraPackages = [
|
|
|
|
targetLlvmLibraries.libcxxabi
|
|
|
|
targetLlvmLibraries.compiler-rt
|
|
|
|
];
|
|
|
|
extraBuildCommands = mkExtraBuildCommands cc;
|
|
|
|
};
|
|
|
|
|
2021-05-28 09:39:13 +00:00
|
|
|
lld = callPackage ./lld {
|
|
|
|
inherit llvm_meta;
|
|
|
|
};
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2021-05-28 09:39:13 +00:00
|
|
|
lldb = callPackage ./lldb {
|
|
|
|
inherit llvm_meta;
|
|
|
|
};
|
2020-04-24 23:36:52 +00:00
|
|
|
});
|
|
|
|
|
2021-02-05 17:12:51 +00:00
|
|
|
libraries = lib.makeExtensible (libraries: let
|
2020-04-24 23:36:52 +00:00
|
|
|
callPackage = newScope (libraries // buildLlvmTools // { inherit stdenv cmake libxml2 python3 isl release_version version fetch; });
|
|
|
|
in {
|
|
|
|
|
2021-05-28 09:39:13 +00:00
|
|
|
compiler-rt = callPackage ./compiler-rt {
|
|
|
|
inherit llvm_meta;
|
|
|
|
};
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
stdenv = overrideCC stdenv buildLlvmTools.clang;
|
|
|
|
|
|
|
|
libcxxStdenv = overrideCC stdenv buildLlvmTools.libcxxClang;
|
|
|
|
|
2021-05-28 09:39:13 +00:00
|
|
|
libcxx = callPackage ./libcxx {
|
|
|
|
inherit llvm_meta;
|
|
|
|
};
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2021-05-28 09:39:13 +00:00
|
|
|
libcxxabi = callPackage ./libcxxabi {
|
|
|
|
inherit llvm_meta;
|
|
|
|
};
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2021-05-28 09:39:13 +00:00
|
|
|
openmp = callPackage ./openmp {
|
|
|
|
inherit llvm_meta;
|
|
|
|
};
|
2020-04-24 23:36:52 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
in { inherit tools libraries; } // libraries // tools
|