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
|
2022-11-27 09:42:12 +00:00
|
|
|
, targetLlvm
|
2020-04-24 23:36:52 +00:00
|
|
|
}:
|
|
|
|
|
|
|
|
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;
|
2023-02-02 18:25:31 +00:00
|
|
|
maintainers = lib.teams.llvm.members;
|
2023-03-15 16:39:30 +00:00
|
|
|
|
|
|
|
# See llvm/cmake/config-ix.cmake.
|
|
|
|
platforms =
|
|
|
|
lib.platforms.aarch64 ++
|
|
|
|
lib.platforms.arm ++
|
|
|
|
lib.platforms.mips ++
|
|
|
|
lib.platforms.power ++
|
|
|
|
lib.platforms.s390x ++
|
|
|
|
lib.platforms.wasi ++
|
|
|
|
lib.platforms.x86;
|
2021-05-28 09:39:13 +00:00
|
|
|
};
|
|
|
|
|
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,
|
2021-10-28 06:52:43 +00:00
|
|
|
# we need to reintroduce `outputSpecified` to get the expected behavior e.g. of lib.get*
|
2023-03-04 12:14:45 +00:00
|
|
|
llvm = tools.libllvm;
|
2021-05-20 23:08:51 +00:00
|
|
|
|
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-10-28 06:52:43 +00:00
|
|
|
llvm-polly = tools.libllvm-polly.lib // { outputSpecified = false; };
|
2021-05-20 23:08:51 +00:00
|
|
|
|
|
|
|
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
|
|
|
};
|
|
|
|
|
2023-03-04 12:14:45 +00:00
|
|
|
clang-unwrapped = tools.libclang;
|
2021-05-20 23:08:51 +00:00
|
|
|
|
|
|
|
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
|
|
|
|
});
|
|
|
|
|
2022-01-26 04:04:25 +00:00
|
|
|
# pick clang appropriate for package set we are targeting
|
|
|
|
clang =
|
|
|
|
/**/ if stdenv.targetPlatform.useLLVM or false then tools.clangUseLLVM
|
|
|
|
else if (pkgs.targetPackages.stdenv or stdenv).cc.isGNU then tools.libstdcxxClang
|
|
|
|
else tools.libcxxClang;
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
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 = [
|
2023-02-02 18:25:31 +00:00
|
|
|
libcxx.cxxabi
|
2020-04-24 23:36:52 +00:00
|
|
|
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 {
|
2022-11-27 09:42:12 +00:00
|
|
|
inherit llvm_meta targetLlvm;
|
2021-05-28 09:39:13 +00:00
|
|
|
};
|
2020-04-24 23:36:52 +00:00
|
|
|
});
|
|
|
|
|
2021-08-27 14:25:00 +00:00
|
|
|
in { inherit tools libraries release_version; } // libraries // tools
|