mirror of
https://github.com/NixOS/nixpkgs.git
synced 2025-02-12 23:23:36 +00:00
Merge pull request #329706 from obsidiansystems/backport-325175-to-release-24.05
[Backport 24.05] llvmPackages_{13,14,15,16,17,18,git}: commonify the default.nix
This commit is contained in:
commit
6a68f91003
@ -149,6 +149,9 @@ let
|
||||
# python3 = pkgs.python3; # don't use python-boot
|
||||
# });
|
||||
|
||||
# Wrapper for standalone command line utilities
|
||||
clang-tools = callPackage ../common/clang-tools { };
|
||||
|
||||
# pick clang appropriate for package set we are targeting
|
||||
clang =
|
||||
/**/ if stdenv.targetPlatform.libc == null then tools.clangNoLibc
|
||||
|
@ -1,430 +0,0 @@
|
||||
{ lowPrio, newScope, pkgs, lib, stdenv
|
||||
, preLibcCrossHeaders
|
||||
, substitute, substituteAll, fetchFromGitHub, fetchpatch
|
||||
, overrideCC, wrapCCWith, wrapBintoolsWith
|
||||
, buildLlvmTools # tools, but from the previous stage, for cross
|
||||
, targetLlvmLibraries # libraries, but from the next stage, for cross
|
||||
, targetLlvm
|
||||
# This is the default binutils, but with *this* version of LLD rather
|
||||
# than the default LLVM version's, if LLD is the choice. We use these for
|
||||
# the `useLLVM` bootstrapping below.
|
||||
, bootBintoolsNoLibc ?
|
||||
if stdenv.targetPlatform.linker == "lld"
|
||||
then null
|
||||
else pkgs.bintoolsNoLibc
|
||||
, bootBintools ?
|
||||
if stdenv.targetPlatform.linker == "lld"
|
||||
then null
|
||||
else pkgs.bintools
|
||||
, darwin
|
||||
# LLVM release information; specify one of these but not both:
|
||||
, gitRelease ? null
|
||||
# i.e.:
|
||||
# {
|
||||
# version = /* i.e. "15.0.0" */;
|
||||
# rev = /* commit SHA */;
|
||||
# rev-version = /* human readable version; i.e. "unstable-2022-26-07" */;
|
||||
# sha256 = /* checksum for this release, can omit if specifying your own `monorepoSrc` */;
|
||||
# }
|
||||
, officialRelease ? { version = "13.0.1"; sha256 = "06dv6h5dmvzdxbif2s8njki6h32796v368dyb5945x8gjj72xh7k"; }
|
||||
# i.e.:
|
||||
# {
|
||||
# version = /* i.e. "15.0.0" */;
|
||||
# candidate = /* optional; if specified, should be: "rcN" */
|
||||
# sha256 = /* checksum for this release, can omit if specifying your own `monorepoSrc` */;
|
||||
# }
|
||||
# By default, we'll try to fetch a release from `github:llvm/llvm-project`
|
||||
# corresponding to the `gitRelease` or `officialRelease` specified.
|
||||
#
|
||||
# You can provide your own LLVM source by specifying this arg but then it's up
|
||||
# to you to make sure that the LLVM repo given matches the release configuration
|
||||
# specified.
|
||||
, monorepoSrc ? null
|
||||
# Allows passthrough to packages via newScope. This makes it possible to
|
||||
# do `(llvmPackages.override { <someLlvmDependency> = bar; }).clang` and get
|
||||
# an llvmPackages whose packages are overridden in an internally consistent way.
|
||||
, ...
|
||||
}@args:
|
||||
|
||||
assert
|
||||
lib.assertMsg
|
||||
(lib.xor
|
||||
(gitRelease != null)
|
||||
(officialRelease != null))
|
||||
("must specify `gitRelease` or `officialRelease`" +
|
||||
(lib.optionalString (gitRelease != null) " — not both"));
|
||||
let
|
||||
monorepoSrc' = monorepoSrc;
|
||||
in let
|
||||
metadata = rec {
|
||||
# Import releaseInfo separately to avoid infinite recursion
|
||||
inherit (import ../common/common-let.nix { inherit lib gitRelease officialRelease; }) releaseInfo;
|
||||
inherit (releaseInfo) release_version version;
|
||||
inherit (import ../common/common-let.nix { inherit lib fetchFromGitHub release_version gitRelease officialRelease monorepoSrc'; }) llvm_meta monorepoSrc;
|
||||
src = monorepoSrc;
|
||||
};
|
||||
|
||||
tools = lib.makeExtensible (tools: let
|
||||
callPackage = newScope (tools // args // metadata
|
||||
# Previously monorepoSrc was erroneously not being passed through.
|
||||
// { monorepoSrc = null; } # Preserve a bug during #307211, TODO: remove; causes llvm 13 rebuild.
|
||||
);
|
||||
mkExtraBuildCommands0 = cc: ''
|
||||
rsrc="$out/resource-root"
|
||||
mkdir "$rsrc"
|
||||
ln -s "${cc.lib}/lib/clang/${metadata.release_version}/include" "$rsrc"
|
||||
echo "-resource-dir=$rsrc" >> $out/nix-support/cc-cflags
|
||||
'';
|
||||
mkExtraBuildCommands = cc: mkExtraBuildCommands0 cc + ''
|
||||
ln -s "${targetLlvmLibraries.compiler-rt.out}/lib" "$rsrc/lib"
|
||||
ln -s "${targetLlvmLibraries.compiler-rt.out}/share" "$rsrc/share"
|
||||
'';
|
||||
|
||||
bintoolsNoLibc' =
|
||||
if bootBintoolsNoLibc == null
|
||||
then tools.bintoolsNoLibc
|
||||
else bootBintoolsNoLibc;
|
||||
bintools' =
|
||||
if bootBintools == null
|
||||
then tools.bintools
|
||||
else bootBintools;
|
||||
|
||||
in {
|
||||
|
||||
libllvm = callPackage ../common/llvm {
|
||||
patches = [
|
||||
# When cross-compiling we configure llvm-config-native with an approximation
|
||||
# of the flags used for the normal LLVM build. To avoid the need for building
|
||||
# a native libLLVM.so (which would fail) we force llvm-config to be linked
|
||||
# statically against the necessary LLVM components always.
|
||||
../common/llvm/llvm-config-link-static.patch
|
||||
|
||||
./llvm/gnu-install-dirs.patch
|
||||
|
||||
# Fix random compiler crashes: https://bugs.llvm.org/show_bug.cgi?id=50611
|
||||
(fetchpatch {
|
||||
url = "https://raw.githubusercontent.com/archlinux/svntogit-packages/4764a4f8c920912a2bfd8b0eea57273acfe0d8a8/trunk/no-strict-aliasing-DwarfCompileUnit.patch";
|
||||
sha256 = "18l6mrvm2vmwm77ckcnbjvh6ybvn72rhrb799d4qzwac4x2ifl7g";
|
||||
stripLen = 1;
|
||||
})
|
||||
|
||||
# Fix musl build.
|
||||
(fetchpatch {
|
||||
url = "https://github.com/llvm/llvm-project/commit/5cd554303ead0f8891eee3cd6d25cb07f5a7bf67.patch";
|
||||
relative = "llvm";
|
||||
hash = "sha256-XPbvNJ45SzjMGlNUgt/IgEvM2dHQpDOe6woUJY+nUYA=";
|
||||
})
|
||||
|
||||
# Backport gcc-13 fixes with missing includes.
|
||||
(fetchpatch {
|
||||
name = "signals-gcc-13.patch";
|
||||
url = "https://github.com/llvm/llvm-project/commit/ff1681ddb303223973653f7f5f3f3435b48a1983.patch";
|
||||
hash = "sha256-CXwYxQezTq5vdmc8Yn88BUAEly6YZ5VEIA6X3y5NNOs=";
|
||||
stripLen = 1;
|
||||
})
|
||||
(fetchpatch {
|
||||
name = "base64-gcc-13.patch";
|
||||
url = "https://github.com/llvm/llvm-project/commit/5e9be93566f39ee6cecd579401e453eccfbe81e5.patch";
|
||||
hash = "sha256-PAwrVrvffPd7tphpwCkYiz+67szPRzRB2TXBvKfzQ7U=";
|
||||
stripLen = 1;
|
||||
})
|
||||
];
|
||||
pollyPatches = [
|
||||
./llvm/gnu-install-dirs-polly.patch
|
||||
];
|
||||
};
|
||||
|
||||
# `llvm` historically had the binaries. When choosing an output explicitly,
|
||||
# we need to reintroduce `outputSpecified` to get the expected behavior e.g. of lib.get*
|
||||
llvm = tools.libllvm;
|
||||
|
||||
libclang = callPackage ../common/clang {
|
||||
patches = [
|
||||
./clang/purity.patch
|
||||
# https://reviews.llvm.org/D51899
|
||||
./clang/gnu-install-dirs.patch
|
||||
# Revert of https://reviews.llvm.org/D100879
|
||||
# The malloc alignment assumption is incorrect for jemalloc and causes
|
||||
# mis-compilation in firefox.
|
||||
# See: https://bugzilla.mozilla.org/show_bug.cgi?id=1741454
|
||||
./clang/revert-malloc-alignment-assumption.patch
|
||||
../common/clang/add-nostdlibinc-flag.patch
|
||||
(substituteAll {
|
||||
src = ../common/clang/clang-11-15-LLVMgold-path.patch;
|
||||
libllvmLibdir = "${tools.libllvm.lib}/lib";
|
||||
})
|
||||
];
|
||||
};
|
||||
|
||||
clang-unwrapped = tools.libclang;
|
||||
|
||||
llvm-manpages = lowPrio (tools.libllvm.override {
|
||||
enableManpages = true;
|
||||
python3 = pkgs.python3; # don't use python-boot
|
||||
});
|
||||
|
||||
clang-manpages = lowPrio (tools.libclang.override {
|
||||
enableManpages = true;
|
||||
python3 = pkgs.python3; # don't use python-boot
|
||||
});
|
||||
|
||||
# TODO: lldb/docs/index.rst:155:toctree contains reference to nonexisting document 'design/structureddataplugins'
|
||||
# lldb-manpages = lowPrio (tools.lldb.override {
|
||||
# enableManpages = true;
|
||||
# python3 = pkgs.python3; # don't use python-boot
|
||||
# });
|
||||
|
||||
# pick clang appropriate for package set we are targeting
|
||||
clang =
|
||||
/**/ if stdenv.targetPlatform.libc == null then tools.clangNoLibc
|
||||
else if stdenv.targetPlatform.useLLVM or false then tools.clangUseLLVM
|
||||
else if (pkgs.targetPackages.stdenv or stdenv).cc.isGNU then tools.libstdcxxClang
|
||||
else tools.libcxxClang;
|
||||
|
||||
libstdcxxClang = wrapCCWith rec {
|
||||
cc = tools.clang-unwrapped;
|
||||
# libstdcxx is taken from gcc in an ad-hoc way in cc-wrapper.
|
||||
libcxx = null;
|
||||
extraPackages = [
|
||||
targetLlvmLibraries.compiler-rt
|
||||
];
|
||||
extraBuildCommands = mkExtraBuildCommands cc;
|
||||
};
|
||||
|
||||
libcxxClang = wrapCCWith rec {
|
||||
cc = tools.clang-unwrapped;
|
||||
libcxx = targetLlvmLibraries.libcxx;
|
||||
extraPackages = [
|
||||
targetLlvmLibraries.compiler-rt
|
||||
];
|
||||
extraBuildCommands = mkExtraBuildCommands cc;
|
||||
};
|
||||
|
||||
lld = callPackage ../common/lld {
|
||||
patches = [
|
||||
./lld/gnu-install-dirs.patch
|
||||
];
|
||||
};
|
||||
|
||||
lldb = callPackage ../common/lldb.nix {
|
||||
patches =
|
||||
let
|
||||
resourceDirPatch = callPackage
|
||||
({ substituteAll, libclang }: substituteAll
|
||||
{
|
||||
src = ./lldb/resource-dir.patch;
|
||||
clangLibDir = "${libclang.lib}/lib";
|
||||
})
|
||||
{ };
|
||||
in
|
||||
[
|
||||
./lldb/procfs.patch
|
||||
resourceDirPatch
|
||||
./lldb/gnu-install-dirs.patch
|
||||
]
|
||||
# This is a stopgap solution if/until the macOS SDK used for x86_64 is
|
||||
# updated.
|
||||
#
|
||||
# The older 10.12 SDK used on x86_64 as of this writing has a `mach/machine.h`
|
||||
# header that does not define `CPU_SUBTYPE_ARM64E` so we replace the one use
|
||||
# of this preprocessor symbol in `lldb` with its expansion.
|
||||
#
|
||||
# See here for some context:
|
||||
# https://github.com/NixOS/nixpkgs/pull/194634#issuecomment-1272129132
|
||||
++ lib.optional (
|
||||
stdenv.targetPlatform.isDarwin
|
||||
&& !stdenv.targetPlatform.isAarch64
|
||||
&& (lib.versionOlder darwin.apple_sdk.sdk.version "11.0")
|
||||
) ./lldb/cpu_subtype_arm64e_replacement.patch;
|
||||
};
|
||||
|
||||
# Below, is the LLVM bootstrapping logic. It handles building a
|
||||
# fully LLVM toolchain from scratch. No GCC toolchain should be
|
||||
# pulled in. As a consequence, it is very quick to build different
|
||||
# targets provided by LLVM and we can also build for what GCC
|
||||
# doesn’t support like LLVM. Probably we should move to some other
|
||||
# file.
|
||||
|
||||
bintools-unwrapped = callPackage ../common/bintools.nix { };
|
||||
|
||||
bintoolsNoLibc = wrapBintoolsWith {
|
||||
bintools = tools.bintools-unwrapped;
|
||||
libc = preLibcCrossHeaders;
|
||||
};
|
||||
|
||||
bintools = wrapBintoolsWith {
|
||||
bintools = tools.bintools-unwrapped;
|
||||
};
|
||||
|
||||
clangUseLLVM = wrapCCWith rec {
|
||||
cc = tools.clang-unwrapped;
|
||||
libcxx = targetLlvmLibraries.libcxx;
|
||||
bintools = bintools';
|
||||
extraPackages = [
|
||||
targetLlvmLibraries.compiler-rt
|
||||
] ++ lib.optionals (!stdenv.targetPlatform.isWasm) [
|
||||
targetLlvmLibraries.libunwind
|
||||
];
|
||||
extraBuildCommands = ''
|
||||
echo "-rtlib=compiler-rt -Wno-unused-command-line-argument" >> $out/nix-support/cc-cflags
|
||||
echo "-B${targetLlvmLibraries.compiler-rt}/lib" >> $out/nix-support/cc-cflags
|
||||
'' + lib.optionalString (!stdenv.targetPlatform.isWasm) ''
|
||||
echo "--unwindlib=libunwind" >> $out/nix-support/cc-cflags
|
||||
echo "-L${targetLlvmLibraries.libunwind}/lib" >> $out/nix-support/cc-ldflags
|
||||
'' + lib.optionalString (!stdenv.targetPlatform.isWasm && stdenv.targetPlatform.useLLVM or false) ''
|
||||
echo "-lunwind" >> $out/nix-support/cc-ldflags
|
||||
'' + lib.optionalString stdenv.targetPlatform.isWasm ''
|
||||
echo "-fno-exceptions" >> $out/nix-support/cc-cflags
|
||||
'' + mkExtraBuildCommands cc;
|
||||
};
|
||||
|
||||
clangNoLibcxx = wrapCCWith rec {
|
||||
cc = tools.clang-unwrapped;
|
||||
libcxx = null;
|
||||
bintools = bintools';
|
||||
extraPackages = [
|
||||
targetLlvmLibraries.compiler-rt
|
||||
];
|
||||
extraBuildCommands = ''
|
||||
echo "-rtlib=compiler-rt" >> $out/nix-support/cc-cflags
|
||||
echo "-B${targetLlvmLibraries.compiler-rt}/lib" >> $out/nix-support/cc-cflags
|
||||
echo "-nostdlib++" >> $out/nix-support/cc-cflags
|
||||
'' + mkExtraBuildCommands cc;
|
||||
};
|
||||
|
||||
clangNoLibc = wrapCCWith rec {
|
||||
cc = tools.clang-unwrapped;
|
||||
libcxx = null;
|
||||
bintools = bintoolsNoLibc';
|
||||
extraPackages = [
|
||||
targetLlvmLibraries.compiler-rt
|
||||
];
|
||||
extraBuildCommands = ''
|
||||
echo "-rtlib=compiler-rt" >> $out/nix-support/cc-cflags
|
||||
echo "-B${targetLlvmLibraries.compiler-rt}/lib" >> $out/nix-support/cc-cflags
|
||||
'' + mkExtraBuildCommands cc;
|
||||
};
|
||||
|
||||
clangNoCompilerRt = wrapCCWith rec {
|
||||
cc = tools.clang-unwrapped;
|
||||
libcxx = null;
|
||||
bintools = bintoolsNoLibc';
|
||||
extraPackages = [ ];
|
||||
extraBuildCommands = ''
|
||||
echo "-nostartfiles" >> $out/nix-support/cc-cflags
|
||||
'' + mkExtraBuildCommands0 cc;
|
||||
};
|
||||
|
||||
clangNoCompilerRtWithLibc = wrapCCWith rec {
|
||||
cc = tools.clang-unwrapped;
|
||||
libcxx = null;
|
||||
bintools = bintools';
|
||||
extraPackages = [ ];
|
||||
extraBuildCommands = mkExtraBuildCommands0 cc;
|
||||
};
|
||||
|
||||
});
|
||||
|
||||
libraries = lib.makeExtensible (libraries: let
|
||||
callPackage = newScope (libraries // buildLlvmTools // args // metadata
|
||||
# Previously monorepoSrc was erroneously not being passed through.
|
||||
// { monorepoSrc = null; } # Preserve a bug during #307211, TODO: remove; causes llvm 13 rebuild.
|
||||
);
|
||||
in {
|
||||
|
||||
compiler-rt-libc = callPackage ../common/compiler-rt {
|
||||
patches = [
|
||||
./compiler-rt/codesign.patch # Revert compiler-rt commit that makes codesign mandatory
|
||||
./compiler-rt/X86-support-extension.patch # Add support for i486 i586 i686 by reusing i386 config
|
||||
# ld-wrapper dislikes `-rpath-link //nix/store`, so we normalize away the
|
||||
# extra `/`.
|
||||
./compiler-rt/normalize-var.patch
|
||||
# Prevent a compilation error on darwin
|
||||
./compiler-rt/darwin-targetconditionals.patch
|
||||
../common/compiler-rt/darwin-plistbuddy-workaround.patch
|
||||
./compiler-rt/armv7l.patch
|
||||
# Fix build on armv6l
|
||||
../common/compiler-rt/armv6-mcr-dmb.patch
|
||||
../common/compiler-rt/armv6-sync-ops-no-thumb.patch
|
||||
../common/compiler-rt/armv6-no-ldrexd-strexd.patch
|
||||
../common/compiler-rt/armv6-scudo-no-yield.patch
|
||||
../common/compiler-rt/armv6-scudo-libatomic.patch
|
||||
];
|
||||
stdenv = if stdenv.hostPlatform.useLLVM or false
|
||||
then overrideCC stdenv buildLlvmTools.clangNoCompilerRtWithLibc
|
||||
else stdenv;
|
||||
};
|
||||
|
||||
compiler-rt-no-libc = callPackage ../common/compiler-rt {
|
||||
patches = [
|
||||
./compiler-rt/codesign.patch # Revert compiler-rt commit that makes codesign mandatory
|
||||
./compiler-rt/X86-support-extension.patch # Add support for i486 i586 i686 by reusing i386 config
|
||||
# ld-wrapper dislikes `-rpath-link //nix/store`, so we normalize away the
|
||||
# extra `/`.
|
||||
./compiler-rt/normalize-var.patch
|
||||
# Prevent a compilation error on darwin
|
||||
./compiler-rt/darwin-targetconditionals.patch
|
||||
../common/compiler-rt/darwin-plistbuddy-workaround.patch
|
||||
./compiler-rt/armv7l.patch
|
||||
# Fix build on armv6l
|
||||
../common/compiler-rt/armv6-mcr-dmb.patch
|
||||
../common/compiler-rt/armv6-sync-ops-no-thumb.patch
|
||||
../common/compiler-rt/armv6-no-ldrexd-strexd.patch
|
||||
../common/compiler-rt/armv6-scudo-no-yield.patch
|
||||
../common/compiler-rt/armv6-scudo-libatomic.patch
|
||||
];
|
||||
stdenv = if stdenv.hostPlatform.useLLVM or false
|
||||
then overrideCC stdenv buildLlvmTools.clangNoCompilerRt
|
||||
else stdenv;
|
||||
};
|
||||
|
||||
# N.B. condition is safe because without useLLVM both are the same.
|
||||
compiler-rt = if stdenv.hostPlatform.isAndroid
|
||||
then libraries.compiler-rt-libc
|
||||
else libraries.compiler-rt-no-libc;
|
||||
|
||||
stdenv = overrideCC stdenv buildLlvmTools.clang;
|
||||
|
||||
libcxxStdenv = overrideCC stdenv buildLlvmTools.libcxxClang;
|
||||
|
||||
libcxx = callPackage ../common/libcxx {
|
||||
patches = [
|
||||
(substitute {
|
||||
src = ../common/libcxxabi/wasm.patch;
|
||||
replacements = [
|
||||
"--replace-fail" "/cmake/" "/llvm/cmake/"
|
||||
];
|
||||
})
|
||||
] ++ lib.optionals stdenv.hostPlatform.isMusl [
|
||||
(substitute {
|
||||
src = ../common/libcxx/libcxx-0001-musl-hacks.patch;
|
||||
replacements = [
|
||||
"--replace-fail" "/include/" "/libcxx/include/"
|
||||
];
|
||||
})
|
||||
];
|
||||
stdenv = overrideCC stdenv buildLlvmTools.clangNoLibcxx;
|
||||
# TODO: remove this, causes LLVM 13 packages rebuild.
|
||||
inherit (metadata) monorepoSrc; # Preserve bug during #307211 refactor.
|
||||
};
|
||||
|
||||
libunwind = callPackage ../common/libunwind {
|
||||
patches = [
|
||||
./libunwind/gnu-install-dirs.patch
|
||||
];
|
||||
stdenv = overrideCC stdenv buildLlvmTools.clangNoLibcxx;
|
||||
};
|
||||
|
||||
openmp = callPackage ../common/openmp {
|
||||
patches = [
|
||||
# Fix cross.
|
||||
(fetchpatch {
|
||||
url = "https://github.com/llvm/llvm-project/commit/5e2358c781b85a18d1463fd924d2741d4ae5e42e.patch";
|
||||
hash = "sha256-UxIlAifXnexF/MaraPW0Ut6q+sf3e7y1fMdEv1q103A=";
|
||||
})
|
||||
];
|
||||
};
|
||||
});
|
||||
noExtend = extensible: lib.attrsets.removeAttrs extensible [ "extend" ];
|
||||
|
||||
in { inherit tools libraries; inherit (metadata) release_version; } // (noExtend libraries) // (noExtend tools)
|
@ -1,398 +0,0 @@
|
||||
{ lowPrio, newScope, pkgs, lib, stdenv
|
||||
, preLibcCrossHeaders
|
||||
, substitute, substituteAll, fetchFromGitHub, fetchpatch
|
||||
, overrideCC, wrapCCWith, wrapBintoolsWith
|
||||
, buildLlvmTools # tools, but from the previous stage, for cross
|
||||
, targetLlvmLibraries # libraries, but from the next stage, for cross
|
||||
, targetLlvm
|
||||
# This is the default binutils, but with *this* version of LLD rather
|
||||
# than the default LLVM version's, if LLD is the choice. We use these for
|
||||
# the `useLLVM` bootstrapping below.
|
||||
, bootBintoolsNoLibc ?
|
||||
if stdenv.targetPlatform.linker == "lld"
|
||||
then null
|
||||
else pkgs.bintoolsNoLibc
|
||||
, bootBintools ?
|
||||
if stdenv.targetPlatform.linker == "lld"
|
||||
then null
|
||||
else pkgs.bintools
|
||||
, darwin
|
||||
# LLVM release information; specify one of these but not both:
|
||||
, gitRelease ? null
|
||||
# i.e.:
|
||||
# {
|
||||
# version = /* i.e. "15.0.0" */;
|
||||
# rev = /* commit SHA */;
|
||||
# rev-version = /* human readable version; i.e. "unstable-2022-26-07" */;
|
||||
# sha256 = /* checksum for this release, can omit if specifying your own `monorepoSrc` */;
|
||||
# }
|
||||
, officialRelease ? { version = "14.0.6"; sha256 = "sha256-vffu4HilvYwtzwgq+NlS26m65DGbp6OSSne2aje1yJE="; }
|
||||
# i.e.:
|
||||
# {
|
||||
# version = /* i.e. "15.0.0" */;
|
||||
# candidate = /* optional; if specified, should be: "rcN" */
|
||||
# sha256 = /* checksum for this release, can omit if specifying your own `monorepoSrc` */;
|
||||
# }
|
||||
# By default, we'll try to fetch a release from `github:llvm/llvm-project`
|
||||
# corresponding to the `gitRelease` or `officialRelease` specified.
|
||||
#
|
||||
# You can provide your own LLVM source by specifying this arg but then it's up
|
||||
# to you to make sure that the LLVM repo given matches the release configuration
|
||||
# specified.
|
||||
, monorepoSrc ? null
|
||||
# Allows passthrough to packages via newScope. This makes it possible to
|
||||
# do `(llvmPackages.override { <someLlvmDependency> = bar; }).clang` and get
|
||||
# an llvmPackages whose packages are overridden in an internally consistent way.
|
||||
, ...
|
||||
}@args:
|
||||
|
||||
assert
|
||||
lib.assertMsg
|
||||
(lib.xor
|
||||
(gitRelease != null)
|
||||
(officialRelease != null))
|
||||
("must specify `gitRelease` or `officialRelease`" +
|
||||
(lib.optionalString (gitRelease != null) " — not both"));
|
||||
let
|
||||
monorepoSrc' = monorepoSrc;
|
||||
in let
|
||||
|
||||
metadata = rec {
|
||||
# Import releaseInfo separately to avoid infinite recursion
|
||||
inherit (import ../common/common-let.nix { inherit lib gitRelease officialRelease; }) releaseInfo;
|
||||
inherit (releaseInfo) release_version version;
|
||||
inherit (import ../common/common-let.nix { inherit lib fetchFromGitHub release_version gitRelease officialRelease monorepoSrc'; }) llvm_meta monorepoSrc;
|
||||
};
|
||||
|
||||
tools = lib.makeExtensible (tools: let
|
||||
callPackage = newScope (tools // args // metadata);
|
||||
mkExtraBuildCommands0 = cc: ''
|
||||
rsrc="$out/resource-root"
|
||||
mkdir "$rsrc"
|
||||
ln -s "${cc.lib}/lib/clang/${metadata.release_version}/include" "$rsrc"
|
||||
echo "-resource-dir=$rsrc" >> $out/nix-support/cc-cflags
|
||||
'';
|
||||
mkExtraBuildCommands = cc: mkExtraBuildCommands0 cc + ''
|
||||
ln -s "${targetLlvmLibraries.compiler-rt.out}/lib" "$rsrc/lib"
|
||||
ln -s "${targetLlvmLibraries.compiler-rt.out}/share" "$rsrc/share"
|
||||
'';
|
||||
|
||||
bintoolsNoLibc' =
|
||||
if bootBintoolsNoLibc == null
|
||||
then tools.bintoolsNoLibc
|
||||
else bootBintoolsNoLibc;
|
||||
bintools' =
|
||||
if bootBintools == null
|
||||
then tools.bintools
|
||||
else bootBintools;
|
||||
|
||||
in {
|
||||
|
||||
libllvm = callPackage ../common/llvm {
|
||||
patches = [
|
||||
./llvm/gnu-install-dirs.patch
|
||||
|
||||
# Fix musl build.
|
||||
(fetchpatch {
|
||||
url = "https://github.com/llvm/llvm-project/commit/5cd554303ead0f8891eee3cd6d25cb07f5a7bf67.patch";
|
||||
relative = "llvm";
|
||||
hash = "sha256-XPbvNJ45SzjMGlNUgt/IgEvM2dHQpDOe6woUJY+nUYA=";
|
||||
})
|
||||
# fix RuntimeDyld usage on aarch64-linux (e.g. python312Packages.numba tests)
|
||||
(fetchpatch {
|
||||
url = "https://github.com/llvm/llvm-project/commit/2e1b838a889f9793d4bcd5dbfe10db9796b77143.patch";
|
||||
relative = "llvm";
|
||||
hash = "sha256-Ot45P/iwaR4hkcM3xtLwfryQNgHI6pv6ADjv98tgdZA=";
|
||||
})
|
||||
];
|
||||
pollyPatches = [
|
||||
./llvm/gnu-install-dirs-polly.patch
|
||||
];
|
||||
};
|
||||
|
||||
# `llvm` historically had the binaries. When choosing an output explicitly,
|
||||
# we need to reintroduce `outputSpecified` to get the expected behavior e.g. of lib.get*
|
||||
llvm = tools.libllvm;
|
||||
|
||||
libclang = callPackage ../common/clang {
|
||||
patches = [
|
||||
./clang/purity.patch
|
||||
# https://reviews.llvm.org/D51899
|
||||
./clang/gnu-install-dirs.patch
|
||||
../common/clang/add-nostdlibinc-flag.patch
|
||||
(substituteAll {
|
||||
src = ../common/clang/clang-11-15-LLVMgold-path.patch;
|
||||
libllvmLibdir = "${tools.libllvm.lib}/lib";
|
||||
})
|
||||
];
|
||||
};
|
||||
|
||||
clang-unwrapped = tools.libclang;
|
||||
|
||||
llvm-manpages = lowPrio (tools.libllvm.override {
|
||||
enableManpages = true;
|
||||
python3 = pkgs.python3; # don't use python-boot
|
||||
});
|
||||
|
||||
clang-manpages = lowPrio (tools.libclang.override {
|
||||
enableManpages = true;
|
||||
python3 = pkgs.python3; # don't use python-boot
|
||||
});
|
||||
|
||||
# TODO: lldb/docs/index.rst:155:toctree contains reference to nonexisting document 'design/structureddataplugins'
|
||||
# lldb-manpages = lowPrio (tools.lldb.override {
|
||||
# enableManpages = true;
|
||||
# python3 = pkgs.python3; # don't use python-boot
|
||||
# });
|
||||
|
||||
# pick clang appropriate for package set we are targeting
|
||||
clang =
|
||||
/**/ if stdenv.targetPlatform.libc == null then tools.clangNoLibc
|
||||
else if stdenv.targetPlatform.useLLVM or false then tools.clangUseLLVM
|
||||
else if (pkgs.targetPackages.stdenv or stdenv).cc.isGNU then tools.libstdcxxClang
|
||||
else tools.libcxxClang;
|
||||
|
||||
libstdcxxClang = wrapCCWith rec {
|
||||
cc = tools.clang-unwrapped;
|
||||
# libstdcxx is taken from gcc in an ad-hoc way in cc-wrapper.
|
||||
libcxx = null;
|
||||
extraPackages = [
|
||||
targetLlvmLibraries.compiler-rt
|
||||
];
|
||||
extraBuildCommands = mkExtraBuildCommands cc;
|
||||
};
|
||||
|
||||
libcxxClang = wrapCCWith rec {
|
||||
cc = tools.clang-unwrapped;
|
||||
libcxx = targetLlvmLibraries.libcxx;
|
||||
extraPackages = [
|
||||
targetLlvmLibraries.compiler-rt
|
||||
];
|
||||
extraBuildCommands = mkExtraBuildCommands cc;
|
||||
};
|
||||
|
||||
lld = callPackage ../common/lld {
|
||||
patches = [
|
||||
./lld/gnu-install-dirs.patch
|
||||
./lld/fix-root-src-dir.patch
|
||||
];
|
||||
};
|
||||
|
||||
lldb = callPackage ../common/lldb.nix {
|
||||
patches =
|
||||
let
|
||||
resourceDirPatch = callPackage
|
||||
({ substituteAll, libclang }: substituteAll
|
||||
{
|
||||
src = ./lldb/resource-dir.patch;
|
||||
clangLibDir = "${libclang.lib}/lib";
|
||||
})
|
||||
{ };
|
||||
in
|
||||
[
|
||||
./lldb/procfs.patch
|
||||
resourceDirPatch
|
||||
../common/lldb/gnu-install-dirs.patch
|
||||
]
|
||||
# This is a stopgap solution if/until the macOS SDK used for x86_64 is
|
||||
# updated.
|
||||
#
|
||||
# The older 10.12 SDK used on x86_64 as of this writing has a `mach/machine.h`
|
||||
# header that does not define `CPU_SUBTYPE_ARM64E` so we replace the one use
|
||||
# of this preprocessor symbol in `lldb` with its expansion.
|
||||
#
|
||||
# See here for some context:
|
||||
# https://github.com/NixOS/nixpkgs/pull/194634#issuecomment-1272129132
|
||||
++ lib.optional (
|
||||
stdenv.targetPlatform.isDarwin
|
||||
&& !stdenv.targetPlatform.isAarch64
|
||||
&& (lib.versionOlder darwin.apple_sdk.sdk.version "11.0")
|
||||
) ./lldb/cpu_subtype_arm64e_replacement.patch;
|
||||
};
|
||||
|
||||
# Below, is the LLVM bootstrapping logic. It handles building a
|
||||
# fully LLVM toolchain from scratch. No GCC toolchain should be
|
||||
# pulled in. As a consequence, it is very quick to build different
|
||||
# targets provided by LLVM and we can also build for what GCC
|
||||
# doesn’t support like LLVM. Probably we should move to some other
|
||||
# file.
|
||||
|
||||
bintools-unwrapped = callPackage ../common/bintools.nix { };
|
||||
|
||||
bintoolsNoLibc = wrapBintoolsWith {
|
||||
bintools = tools.bintools-unwrapped;
|
||||
libc = preLibcCrossHeaders;
|
||||
};
|
||||
|
||||
bintools = wrapBintoolsWith {
|
||||
bintools = tools.bintools-unwrapped;
|
||||
};
|
||||
|
||||
clangUseLLVM = wrapCCWith rec {
|
||||
cc = tools.clang-unwrapped;
|
||||
libcxx = targetLlvmLibraries.libcxx;
|
||||
bintools = bintools';
|
||||
extraPackages = [
|
||||
targetLlvmLibraries.compiler-rt
|
||||
] ++ lib.optionals (!stdenv.targetPlatform.isWasm) [
|
||||
targetLlvmLibraries.libunwind
|
||||
];
|
||||
extraBuildCommands = mkExtraBuildCommands cc;
|
||||
nixSupport.cc-cflags =
|
||||
[ "-rtlib=compiler-rt"
|
||||
"-Wno-unused-command-line-argument"
|
||||
"-B${targetLlvmLibraries.compiler-rt}/lib"
|
||||
]
|
||||
++ lib.optional (!stdenv.targetPlatform.isWasm) "--unwindlib=libunwind"
|
||||
++ lib.optional
|
||||
(!stdenv.targetPlatform.isWasm && stdenv.targetPlatform.useLLVM or false)
|
||||
"-lunwind"
|
||||
++ lib.optional stdenv.targetPlatform.isWasm "-fno-exceptions";
|
||||
nixSupport.cc-ldflags = lib.optionals (!stdenv.targetPlatform.isWasm) [ "-L${targetLlvmLibraries.libunwind}/lib" ];
|
||||
};
|
||||
|
||||
clangNoLibcxx = wrapCCWith rec {
|
||||
cc = tools.clang-unwrapped;
|
||||
libcxx = null;
|
||||
bintools = bintools';
|
||||
extraPackages = [
|
||||
targetLlvmLibraries.compiler-rt
|
||||
];
|
||||
extraBuildCommands = mkExtraBuildCommands cc;
|
||||
nixSupport.cc-cflags = [
|
||||
"-rtlib=compiler-rt"
|
||||
"-B${targetLlvmLibraries.compiler-rt}/lib"
|
||||
"-nostdlib++"
|
||||
];
|
||||
};
|
||||
|
||||
clangNoLibc = wrapCCWith rec {
|
||||
cc = tools.clang-unwrapped;
|
||||
libcxx = null;
|
||||
bintools = bintoolsNoLibc';
|
||||
extraPackages = [
|
||||
targetLlvmLibraries.compiler-rt
|
||||
];
|
||||
extraBuildCommands = mkExtraBuildCommands cc;
|
||||
nixSupport.cc-cflags = [
|
||||
"-rtlib=compiler-rt"
|
||||
"-B${targetLlvmLibraries.compiler-rt}/lib"
|
||||
];
|
||||
};
|
||||
|
||||
clangNoCompilerRt = wrapCCWith rec {
|
||||
cc = tools.clang-unwrapped;
|
||||
libcxx = null;
|
||||
bintools = bintoolsNoLibc';
|
||||
extraPackages = [ ];
|
||||
extraBuildCommands = mkExtraBuildCommands0 cc;
|
||||
nixSupport.cc-cflags = [ "-nostartfiles" ];
|
||||
};
|
||||
|
||||
clangNoCompilerRtWithLibc = wrapCCWith rec {
|
||||
cc = tools.clang-unwrapped;
|
||||
libcxx = null;
|
||||
bintools = bintools';
|
||||
extraPackages = [ ];
|
||||
extraBuildCommands = mkExtraBuildCommands0 cc;
|
||||
};
|
||||
|
||||
});
|
||||
|
||||
libraries = lib.makeExtensible (libraries: let
|
||||
callPackage = newScope (libraries // buildLlvmTools // args // metadata);
|
||||
in {
|
||||
|
||||
compiler-rt-libc = callPackage ../common/compiler-rt {
|
||||
patches = [
|
||||
./compiler-rt/codesign.patch # Revert compiler-rt commit that makes codesign mandatory
|
||||
./compiler-rt/X86-support-extension.patch # Add support for i486 i586 i686 by reusing i386 config
|
||||
./compiler-rt/gnu-install-dirs.patch
|
||||
# ld-wrapper dislikes `-rpath-link //nix/store`, so we normalize away the
|
||||
# extra `/`.
|
||||
./compiler-rt/normalize-var.patch
|
||||
# Prevent a compilation error on darwin
|
||||
./compiler-rt/darwin-targetconditionals.patch
|
||||
../common/compiler-rt/darwin-plistbuddy-workaround.patch
|
||||
./compiler-rt/armv7l.patch
|
||||
# Fix build on armv6l
|
||||
../common/compiler-rt/armv6-mcr-dmb.patch
|
||||
../common/compiler-rt/armv6-sync-ops-no-thumb.patch
|
||||
../common/compiler-rt/armv6-no-ldrexd-strexd.patch
|
||||
../common/compiler-rt/armv6-scudo-no-yield.patch
|
||||
../common/compiler-rt/armv6-scudo-libatomic.patch
|
||||
];
|
||||
stdenv = if stdenv.hostPlatform.useLLVM or false
|
||||
then overrideCC stdenv buildLlvmTools.clangNoCompilerRtWithLibc
|
||||
else stdenv;
|
||||
};
|
||||
|
||||
compiler-rt-no-libc = callPackage ../common/compiler-rt {
|
||||
patches = [
|
||||
./compiler-rt/codesign.patch # Revert compiler-rt commit that makes codesign mandatory
|
||||
./compiler-rt/X86-support-extension.patch # Add support for i486 i586 i686 by reusing i386 config
|
||||
./compiler-rt/gnu-install-dirs.patch
|
||||
# ld-wrapper dislikes `-rpath-link //nix/store`, so we normalize away the
|
||||
# extra `/`.
|
||||
./compiler-rt/normalize-var.patch
|
||||
# Prevent a compilation error on darwin
|
||||
./compiler-rt/darwin-targetconditionals.patch
|
||||
../common/compiler-rt/darwin-plistbuddy-workaround.patch
|
||||
./compiler-rt/armv7l.patch
|
||||
# Fix build on armv6l
|
||||
../common/compiler-rt/armv6-mcr-dmb.patch
|
||||
../common/compiler-rt/armv6-sync-ops-no-thumb.patch
|
||||
../common/compiler-rt/armv6-no-ldrexd-strexd.patch
|
||||
../common/compiler-rt/armv6-scudo-no-yield.patch
|
||||
../common/compiler-rt/armv6-scudo-libatomic.patch
|
||||
];
|
||||
stdenv = if stdenv.hostPlatform.useLLVM or false
|
||||
then overrideCC stdenv buildLlvmTools.clangNoCompilerRt
|
||||
else stdenv;
|
||||
};
|
||||
|
||||
# N.B. condition is safe because without useLLVM both are the same.
|
||||
compiler-rt = if stdenv.hostPlatform.isAndroid
|
||||
then libraries.compiler-rt-libc
|
||||
else libraries.compiler-rt-no-libc;
|
||||
|
||||
stdenv = overrideCC stdenv buildLlvmTools.clang;
|
||||
|
||||
libcxxStdenv = overrideCC stdenv buildLlvmTools.libcxxClang;
|
||||
|
||||
libcxx = callPackage ../common/libcxx {
|
||||
patches = [
|
||||
(substitute {
|
||||
src = ../common/libcxxabi/wasm.patch;
|
||||
replacements = [
|
||||
"--replace-fail" "/cmake/" "/llvm/cmake/"
|
||||
];
|
||||
})
|
||||
] ++ lib.optionals stdenv.hostPlatform.isMusl [
|
||||
(substitute {
|
||||
src = ../common/libcxx/libcxx-0001-musl-hacks.patch;
|
||||
replacements = [
|
||||
"--replace-fail" "/include/" "/libcxx/include/"
|
||||
];
|
||||
})
|
||||
];
|
||||
stdenv = overrideCC stdenv buildLlvmTools.clangNoLibcxx;
|
||||
};
|
||||
|
||||
libunwind = callPackage ../common/libunwind {
|
||||
patches = [
|
||||
./libunwind/gnu-install-dirs.patch
|
||||
];
|
||||
stdenv = overrideCC stdenv buildLlvmTools.clangNoLibcxx;
|
||||
};
|
||||
|
||||
openmp = callPackage ../common/openmp {
|
||||
patches = [
|
||||
./openmp/gnu-install-dirs.patch
|
||||
./openmp/run-lit-directly.patch
|
||||
];
|
||||
};
|
||||
});
|
||||
noExtend = extensible: lib.attrsets.removeAttrs extensible [ "extend" ];
|
||||
|
||||
in { inherit tools libraries; inherit (metadata) release_version; } // (noExtend libraries) // (noExtend tools)
|
@ -1,452 +0,0 @@
|
||||
{ lowPrio, newScope, pkgs, lib, stdenv
|
||||
, preLibcCrossHeaders
|
||||
, substitute, substituteAll, fetchFromGitHub, fetchpatch
|
||||
, overrideCC, wrapCCWith, wrapBintoolsWith
|
||||
, buildLlvmTools # tools, but from the previous stage, for cross
|
||||
, targetLlvmLibraries # libraries, but from the next stage, for cross
|
||||
, targetLlvm
|
||||
# This is the default binutils, but with *this* version of LLD rather
|
||||
# than the default LLVM version's, if LLD is the choice. We use these for
|
||||
# the `useLLVM` bootstrapping below.
|
||||
, bootBintoolsNoLibc ?
|
||||
if stdenv.targetPlatform.linker == "lld"
|
||||
then null
|
||||
else pkgs.bintoolsNoLibc
|
||||
, bootBintools ?
|
||||
if stdenv.targetPlatform.linker == "lld"
|
||||
then null
|
||||
else pkgs.bintools
|
||||
, darwin
|
||||
# LLVM release information; specify one of these but not both:
|
||||
, gitRelease ? null
|
||||
# i.e.:
|
||||
# {
|
||||
# version = /* i.e. "15.0.0" */;
|
||||
# rev = /* commit SHA */;
|
||||
# rev-version = /* human readable version; i.e. "unstable-2022-26-07" */;
|
||||
# sha256 = /* checksum for this release, can omit if specifying your own `monorepoSrc` */;
|
||||
# }
|
||||
, officialRelease ? { version = "15.0.7"; sha256 = "sha256-wjuZQyXQ/jsmvy6y1aksCcEDXGBjuhpgngF3XQJ/T4s="; }
|
||||
# i.e.:
|
||||
# {
|
||||
# version = /* i.e. "15.0.0" */;
|
||||
# candidate = /* optional; if specified, should be: "rcN" */
|
||||
# sha256 = /* checksum for this release, can omit if specifying your own `monorepoSrc` */;
|
||||
# }
|
||||
# By default, we'll try to fetch a release from `github:llvm/llvm-project`
|
||||
# corresponding to the `gitRelease` or `officialRelease` specified.
|
||||
#
|
||||
# You can provide your own LLVM source by specifying this arg but then it's up
|
||||
# to you to make sure that the LLVM repo given matches the release configuration
|
||||
# specified.
|
||||
, monorepoSrc ? null
|
||||
# Allows passthrough to packages via newScope. This makes it possible to
|
||||
# do `(llvmPackages.override { <someLlvmDependency> = bar; }).clang` and get
|
||||
# an llvmPackages whose packages are overridden in an internally consistent way.
|
||||
, ...
|
||||
}@args:
|
||||
|
||||
assert
|
||||
lib.assertMsg
|
||||
(lib.xor
|
||||
(gitRelease != null)
|
||||
(officialRelease != null))
|
||||
("must specify `gitRelease` or `officialRelease`" +
|
||||
(lib.optionalString (gitRelease != null) " — not both"));
|
||||
let
|
||||
monorepoSrc' = monorepoSrc;
|
||||
in let
|
||||
|
||||
metadata = rec {
|
||||
# Import releaseInfo separately to avoid infinite recursion
|
||||
inherit (import ../common/common-let.nix { inherit lib gitRelease officialRelease; }) releaseInfo;
|
||||
inherit (releaseInfo) release_version version;
|
||||
inherit (import ../common/common-let.nix { inherit lib fetchFromGitHub release_version gitRelease officialRelease monorepoSrc'; }) llvm_meta monorepoSrc;
|
||||
};
|
||||
|
||||
lldbPlugins = lib.makeExtensible (lldbPlugins: let
|
||||
callPackage = newScope (lldbPlugins // { inherit stdenv; inherit (tools) lldb; });
|
||||
in {
|
||||
llef = callPackage ../common/lldb-plugins/llef.nix {};
|
||||
});
|
||||
|
||||
tools = lib.makeExtensible (tools: let
|
||||
callPackage = newScope (tools // args // metadata);
|
||||
mkExtraBuildCommands0 = cc: ''
|
||||
rsrc="$out/resource-root"
|
||||
mkdir "$rsrc"
|
||||
ln -s "${cc.lib}/lib/clang/${metadata.release_version}/include" "$rsrc"
|
||||
echo "-resource-dir=$rsrc" >> $out/nix-support/cc-cflags
|
||||
'';
|
||||
mkExtraBuildCommands = cc: mkExtraBuildCommands0 cc + ''
|
||||
ln -s "${targetLlvmLibraries.compiler-rt.out}/lib" "$rsrc/lib"
|
||||
ln -s "${targetLlvmLibraries.compiler-rt.out}/share" "$rsrc/share"
|
||||
'';
|
||||
|
||||
bintoolsNoLibc' =
|
||||
if bootBintoolsNoLibc == null
|
||||
then tools.bintoolsNoLibc
|
||||
else bootBintoolsNoLibc;
|
||||
bintools' =
|
||||
if bootBintools == null
|
||||
then tools.bintools
|
||||
else bootBintools;
|
||||
|
||||
in {
|
||||
|
||||
libllvm = callPackage ../common/llvm {
|
||||
patches = [
|
||||
./llvm/gnu-install-dirs.patch
|
||||
|
||||
# Running the tests involves invoking binaries (like `opt`) that depend on
|
||||
# the LLVM dylibs and reference them by absolute install path (i.e. their
|
||||
# nix store path).
|
||||
#
|
||||
# Because we have not yet run the install phase (we're running these tests
|
||||
# as part of `checkPhase` instead of `installCheckPhase`) these absolute
|
||||
# paths do not exist yet; to work around this we point the loader (`ld` on
|
||||
# unix, `dyld` on macOS) at the `lib` directory which will later become this
|
||||
# package's `lib` output.
|
||||
#
|
||||
# Previously we would just set `LD_LIBRARY_PATH` to include the build `lib`
|
||||
# dir but:
|
||||
# - this doesn't generalize well to other platforms; `lit` doesn't forward
|
||||
# `DYLD_LIBRARY_PATH` (macOS):
|
||||
# + https://github.com/llvm/llvm-project/blob/0d89963df354ee309c15f67dc47c8ab3cb5d0fb2/llvm/utils/lit/lit/TestingConfig.py#L26
|
||||
# - even if `lit` forwarded this env var, we actually cannot set
|
||||
# `DYLD_LIBRARY_PATH` in the child processes `lit` launches because
|
||||
# `DYLD_LIBRARY_PATH` (and `DYLD_FALLBACK_LIBRARY_PATH`) is cleared for
|
||||
# "protected processes" (i.e. the python interpreter that runs `lit`):
|
||||
# https://stackoverflow.com/a/35570229
|
||||
# - other LLVM subprojects deal with this issue by having their `lit`
|
||||
# configuration set these env vars for us; it makes sense to do the same
|
||||
# for LLVM:
|
||||
# + https://github.com/llvm/llvm-project/blob/4c106cfdf7cf7eec861ad3983a3dd9a9e8f3a8ae/clang-tools-extra/test/Unit/lit.cfg.py#L22-L31
|
||||
#
|
||||
# !!! TODO: look into upstreaming this patch
|
||||
./llvm/llvm-lit-cfg-add-libs-to-dylib-path.patch
|
||||
|
||||
# `lit` has a mode where it executes run lines as a shell script which is
|
||||
# constructs; this is problematic for macOS because it means that there's
|
||||
# another process in between `lit` and the binaries being tested. As noted
|
||||
# above, this means that `DYLD_LIBRARY_PATH` is cleared which means that our
|
||||
# tests fail with dyld errors.
|
||||
#
|
||||
# To get around this we patch `lit` to reintroduce `DYLD_LIBRARY_PATH`, when
|
||||
# present in the test configuration.
|
||||
#
|
||||
# It's not clear to me why this isn't an issue for LLVM developers running
|
||||
# on macOS (nothing about this _seems_ nix specific)..
|
||||
./llvm/lit-shell-script-runner-set-dyld-library-path.patch
|
||||
|
||||
# Fix musl build.
|
||||
(fetchpatch {
|
||||
url = "https://github.com/llvm/llvm-project/commit/5cd554303ead0f8891eee3cd6d25cb07f5a7bf67.patch";
|
||||
relative = "llvm";
|
||||
hash = "sha256-XPbvNJ45SzjMGlNUgt/IgEvM2dHQpDOe6woUJY+nUYA=";
|
||||
})
|
||||
];
|
||||
pollyPatches = [
|
||||
./llvm/gnu-install-dirs-polly.patch
|
||||
|
||||
# Just like the `llvm-lit-cfg` patch, but for `polly`.
|
||||
./llvm/polly-lit-cfg-add-libs-to-dylib-path.patch
|
||||
];
|
||||
};
|
||||
|
||||
# `llvm` historically had the binaries. When choosing an output explicitly,
|
||||
# we need to reintroduce `outputSpecified` to get the expected behavior e.g. of lib.get*
|
||||
llvm = tools.libllvm;
|
||||
|
||||
libclang = callPackage ../common/clang {
|
||||
patches = [
|
||||
./clang/purity.patch
|
||||
# https://reviews.llvm.org/D51899
|
||||
./clang/gnu-install-dirs.patch
|
||||
../common/clang/add-nostdlibinc-flag.patch
|
||||
(substituteAll {
|
||||
src = ../common/clang/clang-11-15-LLVMgold-path.patch;
|
||||
libllvmLibdir = "${tools.libllvm.lib}/lib";
|
||||
})
|
||||
];
|
||||
};
|
||||
|
||||
clang-unwrapped = tools.libclang;
|
||||
|
||||
llvm-manpages = lowPrio (tools.libllvm.override {
|
||||
enableManpages = true;
|
||||
python3 = pkgs.python3; # don't use python-boot
|
||||
});
|
||||
|
||||
clang-manpages = lowPrio (tools.libclang.override {
|
||||
enableManpages = true;
|
||||
python3 = pkgs.python3; # don't use python-boot
|
||||
});
|
||||
|
||||
lldb-manpages = lowPrio (tools.lldb.override {
|
||||
enableManpages = true;
|
||||
python3 = pkgs.python3; # don't use python-boot
|
||||
});
|
||||
|
||||
# pick clang appropriate for package set we are targeting
|
||||
clang =
|
||||
/**/ if stdenv.targetPlatform.libc == null then tools.clangNoLibc
|
||||
else if stdenv.targetPlatform.useLLVM or false then tools.clangUseLLVM
|
||||
else if (pkgs.targetPackages.stdenv or stdenv).cc.isGNU then tools.libstdcxxClang
|
||||
else tools.libcxxClang;
|
||||
|
||||
libstdcxxClang = wrapCCWith rec {
|
||||
cc = tools.clang-unwrapped;
|
||||
# libstdcxx is taken from gcc in an ad-hoc way in cc-wrapper.
|
||||
libcxx = null;
|
||||
extraPackages = [
|
||||
targetLlvmLibraries.compiler-rt
|
||||
];
|
||||
extraBuildCommands = mkExtraBuildCommands cc;
|
||||
};
|
||||
|
||||
libcxxClang = wrapCCWith rec {
|
||||
cc = tools.clang-unwrapped;
|
||||
libcxx = targetLlvmLibraries.libcxx;
|
||||
extraPackages = [
|
||||
targetLlvmLibraries.compiler-rt
|
||||
];
|
||||
extraBuildCommands = mkExtraBuildCommands cc;
|
||||
};
|
||||
|
||||
lld = callPackage ../common/lld {
|
||||
patches = [
|
||||
./lld/gnu-install-dirs.patch
|
||||
];
|
||||
};
|
||||
|
||||
lldb = callPackage ../common/lldb.nix {
|
||||
patches =
|
||||
let
|
||||
resourceDirPatch = callPackage
|
||||
({ substituteAll, libclang }: substituteAll
|
||||
{
|
||||
src = ./lldb/resource-dir.patch;
|
||||
clangLibDir = "${libclang.lib}/lib";
|
||||
})
|
||||
{ };
|
||||
in
|
||||
[
|
||||
./lldb/procfs.patch
|
||||
resourceDirPatch
|
||||
../common/lldb/gnu-install-dirs.patch
|
||||
]
|
||||
# This is a stopgap solution if/until the macOS SDK used for x86_64 is
|
||||
# updated.
|
||||
#
|
||||
# The older 10.12 SDK used on x86_64 as of this writing has a `mach/machine.h`
|
||||
# header that does not define `CPU_SUBTYPE_ARM64E` so we replace the one use
|
||||
# of this preprocessor symbol in `lldb` with its expansion.
|
||||
#
|
||||
# See here for some context:
|
||||
# https://github.com/NixOS/nixpkgs/pull/194634#issuecomment-1272129132
|
||||
++ lib.optional (
|
||||
stdenv.targetPlatform.isDarwin
|
||||
&& !stdenv.targetPlatform.isAarch64
|
||||
&& (lib.versionOlder darwin.apple_sdk.sdk.version "11.0")
|
||||
) ./lldb/cpu_subtype_arm64e_replacement.patch;
|
||||
};
|
||||
|
||||
# Below, is the LLVM bootstrapping logic. It handles building a
|
||||
# fully LLVM toolchain from scratch. No GCC toolchain should be
|
||||
# pulled in. As a consequence, it is very quick to build different
|
||||
# targets provided by LLVM and we can also build for what GCC
|
||||
# doesn’t support like LLVM. Probably we should move to some other
|
||||
# file.
|
||||
|
||||
bintools-unwrapped = callPackage ../common/bintools.nix { };
|
||||
|
||||
bintoolsNoLibc = wrapBintoolsWith {
|
||||
bintools = tools.bintools-unwrapped;
|
||||
libc = preLibcCrossHeaders;
|
||||
};
|
||||
|
||||
bintools = wrapBintoolsWith {
|
||||
bintools = tools.bintools-unwrapped;
|
||||
};
|
||||
|
||||
clangUseLLVM = wrapCCWith rec {
|
||||
cc = tools.clang-unwrapped;
|
||||
libcxx = targetLlvmLibraries.libcxx;
|
||||
bintools = bintools';
|
||||
extraPackages = [
|
||||
targetLlvmLibraries.compiler-rt
|
||||
] ++ lib.optionals (!stdenv.targetPlatform.isWasm) [
|
||||
targetLlvmLibraries.libunwind
|
||||
];
|
||||
extraBuildCommands = mkExtraBuildCommands cc;
|
||||
nixSupport.cc-cflags =
|
||||
[ "-rtlib=compiler-rt"
|
||||
"-Wno-unused-command-line-argument"
|
||||
"-B${targetLlvmLibraries.compiler-rt}/lib"
|
||||
]
|
||||
++ lib.optional (!stdenv.targetPlatform.isWasm) "--unwindlib=libunwind"
|
||||
++ lib.optional
|
||||
(!stdenv.targetPlatform.isWasm && stdenv.targetPlatform.useLLVM or false)
|
||||
"-lunwind"
|
||||
++ lib.optional stdenv.targetPlatform.isWasm "-fno-exceptions";
|
||||
nixSupport.cc-ldflags = lib.optionals (!stdenv.targetPlatform.isWasm) [ "-L${targetLlvmLibraries.libunwind}/lib" ];
|
||||
};
|
||||
|
||||
clangNoLibcxx = wrapCCWith rec {
|
||||
cc = tools.clang-unwrapped;
|
||||
libcxx = null;
|
||||
bintools = bintools';
|
||||
extraPackages = [
|
||||
targetLlvmLibraries.compiler-rt
|
||||
];
|
||||
extraBuildCommands = mkExtraBuildCommands cc;
|
||||
nixSupport.cc-cflags =
|
||||
[
|
||||
"-rtlib=compiler-rt"
|
||||
"-B${targetLlvmLibraries.compiler-rt}/lib"
|
||||
"-nostdlib++"
|
||||
]
|
||||
++ lib.optional stdenv.targetPlatform.isWasm "-fno-exceptions";
|
||||
};
|
||||
|
||||
clangNoLibc = wrapCCWith rec {
|
||||
cc = tools.clang-unwrapped;
|
||||
libcxx = null;
|
||||
bintools = bintoolsNoLibc';
|
||||
extraPackages = [
|
||||
targetLlvmLibraries.compiler-rt
|
||||
];
|
||||
extraBuildCommands = mkExtraBuildCommands cc;
|
||||
nixSupport.cc-cflags =
|
||||
[
|
||||
"-rtlib=compiler-rt"
|
||||
"-B${targetLlvmLibraries.compiler-rt}/lib"
|
||||
]
|
||||
++ lib.optional stdenv.targetPlatform.isWasm "-fno-exceptions";
|
||||
};
|
||||
|
||||
clangNoCompilerRt = wrapCCWith rec {
|
||||
cc = tools.clang-unwrapped;
|
||||
libcxx = null;
|
||||
bintools = bintoolsNoLibc';
|
||||
extraPackages = [ ];
|
||||
extraBuildCommands = mkExtraBuildCommands0 cc;
|
||||
nixSupport.cc-cflags =
|
||||
[
|
||||
"-nostartfiles"
|
||||
]
|
||||
++ lib.optional stdenv.targetPlatform.isWasm "-fno-exceptions";
|
||||
};
|
||||
|
||||
clangNoCompilerRtWithLibc = wrapCCWith (rec {
|
||||
cc = tools.clang-unwrapped;
|
||||
libcxx = null;
|
||||
bintools = bintools';
|
||||
extraPackages = [ ];
|
||||
extraBuildCommands = mkExtraBuildCommands0 cc;
|
||||
} // lib.optionalAttrs stdenv.targetPlatform.isWasm {
|
||||
nixSupport.cc-cflags = [ "-fno-exceptions" ];
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
libraries = lib.makeExtensible (libraries: let
|
||||
callPackage = newScope (libraries // buildLlvmTools // args // metadata);
|
||||
in {
|
||||
|
||||
compiler-rt-libc = callPackage ../common/compiler-rt {
|
||||
patches = [
|
||||
./compiler-rt/X86-support-extension.patch # Add support for i486 i586 i686 by reusing i386 config
|
||||
./compiler-rt/gnu-install-dirs.patch
|
||||
# ld-wrapper dislikes `-rpath-link //nix/store`, so we normalize away the
|
||||
# extra `/`.
|
||||
./compiler-rt/normalize-var.patch
|
||||
# Prevent a compilation error on darwin
|
||||
./compiler-rt/darwin-targetconditionals.patch
|
||||
# See: https://github.com/NixOS/nixpkgs/pull/186575
|
||||
../common/compiler-rt/darwin-plistbuddy-workaround.patch
|
||||
# See: https://github.com/NixOS/nixpkgs/pull/194634#discussion_r999829893
|
||||
../common/compiler-rt/armv7l-15.patch
|
||||
];
|
||||
stdenv = if stdenv.hostPlatform.useLLVM or false
|
||||
then overrideCC stdenv buildLlvmTools.clangNoCompilerRtWithLibc
|
||||
else stdenv;
|
||||
};
|
||||
|
||||
compiler-rt-no-libc = callPackage ../common/compiler-rt {
|
||||
patches = [
|
||||
./compiler-rt/X86-support-extension.patch # Add support for i486 i586 i686 by reusing i386 config
|
||||
./compiler-rt/gnu-install-dirs.patch
|
||||
# ld-wrapper dislikes `-rpath-link //nix/store`, so we normalize away the
|
||||
# extra `/`.
|
||||
./compiler-rt/normalize-var.patch
|
||||
# Prevent a compilation error on darwin
|
||||
./compiler-rt/darwin-targetconditionals.patch
|
||||
# See: https://github.com/NixOS/nixpkgs/pull/186575
|
||||
../common/compiler-rt/darwin-plistbuddy-workaround.patch
|
||||
# See: https://github.com/NixOS/nixpkgs/pull/194634#discussion_r999829893
|
||||
../common/compiler-rt/armv7l-15.patch
|
||||
];
|
||||
stdenv = if stdenv.hostPlatform.useLLVM or false
|
||||
then overrideCC stdenv buildLlvmTools.clangNoCompilerRt
|
||||
else stdenv;
|
||||
};
|
||||
|
||||
# N.B. condition is safe because without useLLVM both are the same.
|
||||
compiler-rt = if stdenv.hostPlatform.isAndroid
|
||||
then libraries.compiler-rt-libc
|
||||
else libraries.compiler-rt-no-libc;
|
||||
|
||||
stdenv = overrideCC stdenv buildLlvmTools.clang;
|
||||
|
||||
libcxxStdenv = overrideCC stdenv buildLlvmTools.libcxxClang;
|
||||
|
||||
# `libcxx` requires a fairly modern C++ compiler,
|
||||
# so: we use the clang from this LLVM package set instead of the regular
|
||||
# stdenv's compiler.
|
||||
libcxx = callPackage ../common/libcxx {
|
||||
patches = [
|
||||
# See:
|
||||
# - https://reviews.llvm.org/D133566
|
||||
# - https://github.com/NixOS/nixpkgs/issues/214524#issuecomment-1429146432
|
||||
# !!! Drop in LLVM 16+
|
||||
(fetchpatch {
|
||||
url = "https://github.com/llvm/llvm-project/commit/57c7bb3ec89565c68f858d316504668f9d214d59.patch";
|
||||
hash = "sha256-B07vHmSjy5BhhkGSj3e1E0XmMv5/9+mvC/k70Z29VwY=";
|
||||
})
|
||||
(substitute {
|
||||
src = ../common/libcxxabi/wasm.patch;
|
||||
replacements = [
|
||||
"--replace-fail" "/cmake/" "/llvm/cmake/"
|
||||
];
|
||||
})
|
||||
] ++ lib.optionals stdenv.hostPlatform.isMusl [
|
||||
(substitute {
|
||||
src = ../common/libcxx/libcxx-0001-musl-hacks.patch;
|
||||
replacements = [
|
||||
"--replace-fail" "/include/" "/libcxx/include/"
|
||||
];
|
||||
})
|
||||
];
|
||||
stdenv = overrideCC stdenv buildLlvmTools.clangNoLibcxx;
|
||||
};
|
||||
|
||||
libunwind = callPackage ../common/libunwind {
|
||||
patches = [
|
||||
./libunwind/gnu-install-dirs.patch
|
||||
];
|
||||
stdenv = overrideCC stdenv buildLlvmTools.clangNoLibcxx;
|
||||
};
|
||||
|
||||
openmp = callPackage ../common/openmp {
|
||||
patches = [
|
||||
./openmp/fix-find-tool.patch
|
||||
./openmp/gnu-install-dirs.patch
|
||||
./openmp/run-lit-directly.patch
|
||||
];
|
||||
};
|
||||
});
|
||||
noExtend = extensible: lib.attrsets.removeAttrs extensible [ "extend" ];
|
||||
|
||||
in { inherit tools libraries lldbPlugins; inherit (metadata) release_version; } // (noExtend libraries) // (noExtend tools)
|
@ -1,434 +0,0 @@
|
||||
{ lowPrio, newScope, pkgs, lib, stdenv
|
||||
, preLibcCrossHeaders
|
||||
, substitute, substituteAll, fetchFromGitHub
|
||||
, overrideCC, wrapCCWith, wrapBintoolsWith
|
||||
, buildLlvmTools # tools, but from the previous stage, for cross
|
||||
, targetLlvmLibraries # libraries, but from the next stage, for cross
|
||||
, targetLlvm
|
||||
# This is the default binutils, but with *this* version of LLD rather
|
||||
# than the default LLVM verion's, if LLD is the choice. We use these for
|
||||
# the `useLLVM` bootstrapping below.
|
||||
, bootBintoolsNoLibc ?
|
||||
if stdenv.targetPlatform.linker == "lld"
|
||||
then null
|
||||
else pkgs.bintoolsNoLibc
|
||||
, bootBintools ?
|
||||
if stdenv.targetPlatform.linker == "lld"
|
||||
then null
|
||||
else pkgs.bintools
|
||||
, darwin
|
||||
# LLVM release information; specify one of these but not both:
|
||||
, gitRelease ? null
|
||||
# i.e.:
|
||||
# {
|
||||
# version = /* i.e. "15.0.0" */;
|
||||
# rev = /* commit SHA */;
|
||||
# rev-version = /* human readable version; i.e. "unstable-2022-26-07" */;
|
||||
# sha256 = /* checksum for this release, can omit if specifying your own `monorepoSrc` */;
|
||||
# }
|
||||
, officialRelease ? { version = "16.0.6"; sha256 = "sha256-fspqSReX+VD+Nl/Cfq+tDcdPtnQPV1IRopNDfd5VtUs="; }
|
||||
# i.e.:
|
||||
# {
|
||||
# version = /* i.e. "15.0.0" */;
|
||||
# candidate = /* optional; if specified, should be: "rcN" */
|
||||
# sha256 = /* checksum for this release, can omit if specifying your own `monorepoSrc` */;
|
||||
# }
|
||||
# By default, we'll try to fetch a release from `github:llvm/llvm-project`
|
||||
# corresponding to the `gitRelease` or `officialRelease` specified.
|
||||
#
|
||||
# You can provide your own LLVM source by specifying this arg but then it's up
|
||||
# to you to make sure that the LLVM repo given matches the release configuration
|
||||
# specified.
|
||||
, monorepoSrc ? null
|
||||
# Allows passthrough to packages via newScope. This makes it possible to
|
||||
# do `(llvmPackages.override { <someLlvmDependency> = bar; }).clang` and get
|
||||
# an llvmPackages whose packages are overridden in an internally consistent way.
|
||||
, ...
|
||||
}@args:
|
||||
|
||||
assert
|
||||
lib.assertMsg
|
||||
(lib.xor
|
||||
(gitRelease != null)
|
||||
(officialRelease != null))
|
||||
("must specify `gitRelease` or `officialRelease`" +
|
||||
(lib.optionalString (gitRelease != null) " — not both"));
|
||||
let
|
||||
monorepoSrc' = monorepoSrc;
|
||||
in let
|
||||
|
||||
metadata = rec {
|
||||
# Import releaseInfo separately to avoid infinite recursion
|
||||
inherit (import ../common/common-let.nix { inherit lib gitRelease officialRelease; }) releaseInfo;
|
||||
inherit (releaseInfo) release_version version;
|
||||
inherit (import ../common/common-let.nix { inherit lib fetchFromGitHub release_version gitRelease officialRelease monorepoSrc'; }) llvm_meta monorepoSrc;
|
||||
};
|
||||
|
||||
lldbPlugins = lib.makeExtensible (lldbPlugins: let
|
||||
callPackage = newScope (lldbPlugins // { inherit stdenv; inherit (tools) lldb; });
|
||||
in {
|
||||
llef = callPackage ../common/lldb-plugins/llef.nix {};
|
||||
});
|
||||
|
||||
tools = lib.makeExtensible (tools: let
|
||||
callPackage = newScope (tools // args // metadata);
|
||||
major = lib.versions.major metadata.release_version;
|
||||
mkExtraBuildCommands0 = cc: ''
|
||||
rsrc="$out/resource-root"
|
||||
mkdir "$rsrc"
|
||||
ln -s "${cc.lib}/lib/clang/${major}/include" "$rsrc"
|
||||
echo "-resource-dir=$rsrc" >> $out/nix-support/cc-cflags
|
||||
'';
|
||||
mkExtraBuildCommands = cc: mkExtraBuildCommands0 cc + ''
|
||||
ln -s "${targetLlvmLibraries.compiler-rt.out}/lib" "$rsrc/lib"
|
||||
ln -s "${targetLlvmLibraries.compiler-rt.out}/share" "$rsrc/share"
|
||||
'';
|
||||
|
||||
bintoolsNoLibc' =
|
||||
if bootBintoolsNoLibc == null
|
||||
then tools.bintoolsNoLibc
|
||||
else bootBintoolsNoLibc;
|
||||
bintools' =
|
||||
if bootBintools == null
|
||||
then tools.bintools
|
||||
else bootBintools;
|
||||
|
||||
in {
|
||||
|
||||
libllvm = callPackage ../common/llvm {
|
||||
patches = [
|
||||
./llvm/gnu-install-dirs.patch
|
||||
|
||||
# Running the tests involves invoking binaries (like `opt`) that depend on
|
||||
# the LLVM dylibs and reference them by absolute install path (i.e. their
|
||||
# nix store path).
|
||||
#
|
||||
# Because we have not yet run the install phase (we're running these tests
|
||||
# as part of `checkPhase` instead of `installCheckPhase`) these absolute
|
||||
# paths do not exist yet; to work around this we point the loader (`ld` on
|
||||
# unix, `dyld` on macOS) at the `lib` directory which will later become this
|
||||
# package's `lib` output.
|
||||
#
|
||||
# Previously we would just set `LD_LIBRARY_PATH` to include the build `lib`
|
||||
# dir but:
|
||||
# - this doesn't generalize well to other platforms; `lit` doesn't forward
|
||||
# `DYLD_LIBRARY_PATH` (macOS):
|
||||
# + https://github.com/llvm/llvm-project/blob/0d89963df354ee309c15f67dc47c8ab3cb5d0fb2/llvm/utils/lit/lit/TestingConfig.py#L26
|
||||
# - even if `lit` forwarded this env var, we actually cannot set
|
||||
# `DYLD_LIBRARY_PATH` in the child processes `lit` launches because
|
||||
# `DYLD_LIBRARY_PATH` (and `DYLD_FALLBACK_LIBRARY_PATH`) is cleared for
|
||||
# "protected processes" (i.e. the python interpreter that runs `lit`):
|
||||
# https://stackoverflow.com/a/35570229
|
||||
# - other LLVM subprojects deal with this issue by having their `lit`
|
||||
# configuration set these env vars for us; it makes sense to do the same
|
||||
# for LLVM:
|
||||
# + https://github.com/llvm/llvm-project/blob/4c106cfdf7cf7eec861ad3983a3dd9a9e8f3a8ae/clang-tools-extra/test/Unit/lit.cfg.py#L22-L31
|
||||
#
|
||||
# !!! TODO: look into upstreaming this patch
|
||||
./llvm/llvm-lit-cfg-add-libs-to-dylib-path.patch
|
||||
|
||||
# `lit` has a mode where it executes run lines as a shell script which is
|
||||
# constructs; this is problematic for macOS because it means that there's
|
||||
# another process in between `lit` and the binaries being tested. As noted
|
||||
# above, this means that `DYLD_LIBRARY_PATH` is cleared which means that our
|
||||
# tests fail with dyld errors.
|
||||
#
|
||||
# To get around this we patch `lit` to reintroduce `DYLD_LIBRARY_PATH`, when
|
||||
# present in the test configuration.
|
||||
#
|
||||
# It's not clear to me why this isn't an issue for LLVM developers running
|
||||
# on macOS (nothing about this _seems_ nix specific)..
|
||||
./llvm/lit-shell-script-runner-set-dyld-library-path.patch
|
||||
];
|
||||
pollyPatches = [
|
||||
./llvm/gnu-install-dirs-polly.patch
|
||||
|
||||
# Just like the `llvm-lit-cfg` patch, but for `polly`.
|
||||
./llvm/polly-lit-cfg-add-libs-to-dylib-path.patch
|
||||
];
|
||||
};
|
||||
|
||||
# `llvm` historically had the binaries. When choosing an output explicitly,
|
||||
# we need to reintroduce `outputSpecified` to get the expected behavior e.g. of lib.get*
|
||||
llvm = tools.libllvm;
|
||||
|
||||
libclang = callPackage ../common/clang {
|
||||
patches = [
|
||||
./clang/purity.patch
|
||||
# https://reviews.llvm.org/D51899
|
||||
./clang/gnu-install-dirs.patch
|
||||
../common/clang/add-nostdlibinc-flag.patch
|
||||
(substituteAll {
|
||||
src = ../common/clang/clang-at-least-16-LLVMgold-path.patch;
|
||||
libllvmLibdir = "${tools.libllvm.lib}/lib";
|
||||
})
|
||||
];
|
||||
};
|
||||
|
||||
clang-unwrapped = tools.libclang;
|
||||
|
||||
llvm-manpages = lowPrio (tools.libllvm.override {
|
||||
enableManpages = true;
|
||||
python3 = pkgs.python3; # don't use python-boot
|
||||
});
|
||||
|
||||
clang-manpages = lowPrio (tools.libclang.override {
|
||||
enableManpages = true;
|
||||
python3 = pkgs.python3; # don't use python-boot
|
||||
});
|
||||
|
||||
lldb-manpages = lowPrio (tools.lldb.override {
|
||||
enableManpages = true;
|
||||
python3 = pkgs.python3; # don't use python-boot
|
||||
});
|
||||
|
||||
# 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;
|
||||
|
||||
libstdcxxClang = wrapCCWith rec {
|
||||
cc = tools.clang-unwrapped;
|
||||
# libstdcxx is taken from gcc in an ad-hoc way in cc-wrapper.
|
||||
libcxx = null;
|
||||
extraPackages = [
|
||||
targetLlvmLibraries.compiler-rt
|
||||
];
|
||||
extraBuildCommands = mkExtraBuildCommands cc;
|
||||
};
|
||||
|
||||
libcxxClang = wrapCCWith rec {
|
||||
cc = tools.clang-unwrapped;
|
||||
libcxx = targetLlvmLibraries.libcxx;
|
||||
extraPackages = [
|
||||
targetLlvmLibraries.compiler-rt
|
||||
];
|
||||
extraBuildCommands = mkExtraBuildCommands cc;
|
||||
};
|
||||
|
||||
lld = callPackage ../common/lld {
|
||||
patches = [
|
||||
./lld/gnu-install-dirs.patch
|
||||
./lld/add-table-base.patch
|
||||
];
|
||||
};
|
||||
|
||||
mlir = callPackage ../common/mlir {};
|
||||
|
||||
lldb = callPackage ../common/lldb.nix {
|
||||
src = callPackage ({ runCommand }: runCommand "lldb-src-${metadata.version}" {} ''
|
||||
mkdir -p "$out"
|
||||
cp -r ${monorepoSrc}/cmake "$out"
|
||||
cp -r ${monorepoSrc}/lldb "$out"
|
||||
'') { };
|
||||
patches =
|
||||
let
|
||||
resourceDirPatch = callPackage
|
||||
({ substituteAll, libclang }: substituteAll
|
||||
{
|
||||
src = ./lldb/resource-dir.patch;
|
||||
clangLibDir = "${libclang.lib}/lib";
|
||||
})
|
||||
{ };
|
||||
in
|
||||
[
|
||||
# FIXME: do we need this? ./procfs.patch
|
||||
resourceDirPatch
|
||||
../common/lldb/gnu-install-dirs.patch
|
||||
]
|
||||
# This is a stopgap solution if/until the macOS SDK used for x86_64 is
|
||||
# updated.
|
||||
#
|
||||
# The older 10.12 SDK used on x86_64 as of this writing has a `mach/machine.h`
|
||||
# header that does not define `CPU_SUBTYPE_ARM64E` so we replace the one use
|
||||
# of this preprocessor symbol in `lldb` with its expansion.
|
||||
#
|
||||
# See here for some context:
|
||||
# https://github.com/NixOS/nixpkgs/pull/194634#issuecomment-1272129132
|
||||
++ lib.optional (
|
||||
stdenv.targetPlatform.isDarwin
|
||||
&& !stdenv.targetPlatform.isAarch64
|
||||
&& (lib.versionOlder darwin.apple_sdk.sdk.version "11.0")
|
||||
) ./lldb/cpu_subtype_arm64e_replacement.patch;
|
||||
};
|
||||
|
||||
# Below, is the LLVM bootstrapping logic. It handles building a
|
||||
# fully LLVM toolchain from scratch. No GCC toolchain should be
|
||||
# pulled in. As a consequence, it is very quick to build different
|
||||
# targets provided by LLVM and we can also build for what GCC
|
||||
# doesn’t support like LLVM. Probably we should move to some other
|
||||
# file.
|
||||
|
||||
bintools-unwrapped = callPackage ../common/bintools.nix { };
|
||||
|
||||
bintoolsNoLibc = wrapBintoolsWith {
|
||||
bintools = tools.bintools-unwrapped;
|
||||
libc = preLibcCrossHeaders;
|
||||
};
|
||||
|
||||
bintools = wrapBintoolsWith {
|
||||
bintools = tools.bintools-unwrapped;
|
||||
};
|
||||
|
||||
clangUseLLVM = wrapCCWith rec {
|
||||
cc = tools.clang-unwrapped;
|
||||
libcxx = targetLlvmLibraries.libcxx;
|
||||
bintools = bintools';
|
||||
extraPackages = [
|
||||
targetLlvmLibraries.compiler-rt
|
||||
] ++ lib.optionals (!stdenv.targetPlatform.isWasm) [
|
||||
targetLlvmLibraries.libunwind
|
||||
];
|
||||
extraBuildCommands = mkExtraBuildCommands cc;
|
||||
nixSupport.cc-cflags =
|
||||
[ "-rtlib=compiler-rt"
|
||||
"-Wno-unused-command-line-argument"
|
||||
"-B${targetLlvmLibraries.compiler-rt}/lib"
|
||||
]
|
||||
++ lib.optional (!stdenv.targetPlatform.isWasm) "--unwindlib=libunwind"
|
||||
++ lib.optional
|
||||
(!stdenv.targetPlatform.isWasm && stdenv.targetPlatform.useLLVM or false)
|
||||
"-lunwind"
|
||||
++ lib.optional stdenv.targetPlatform.isWasm "-fno-exceptions";
|
||||
nixSupport.cc-ldflags = lib.optionals (!stdenv.targetPlatform.isWasm) [ "-L${targetLlvmLibraries.libunwind}/lib" ];
|
||||
};
|
||||
|
||||
clangNoLibcxx = wrapCCWith rec {
|
||||
cc = tools.clang-unwrapped;
|
||||
libcxx = null;
|
||||
bintools = bintools';
|
||||
extraPackages = [
|
||||
targetLlvmLibraries.compiler-rt
|
||||
];
|
||||
extraBuildCommands = mkExtraBuildCommands cc;
|
||||
nixSupport.cc-cflags =
|
||||
[
|
||||
"-rtlib=compiler-rt"
|
||||
"-B${targetLlvmLibraries.compiler-rt}/lib"
|
||||
"-nostdlib++"
|
||||
]
|
||||
++ lib.optional stdenv.targetPlatform.isWasm "-fno-exceptions";
|
||||
};
|
||||
|
||||
clangNoLibc = wrapCCWith rec {
|
||||
cc = tools.clang-unwrapped;
|
||||
libcxx = null;
|
||||
bintools = bintoolsNoLibc';
|
||||
extraPackages = [
|
||||
targetLlvmLibraries.compiler-rt
|
||||
];
|
||||
extraBuildCommands = mkExtraBuildCommands cc;
|
||||
nixSupport.cc-cflags =
|
||||
[
|
||||
"-rtlib=compiler-rt"
|
||||
"-B${targetLlvmLibraries.compiler-rt}/lib"
|
||||
]
|
||||
++ lib.optional stdenv.targetPlatform.isWasm "-fno-exceptions";
|
||||
};
|
||||
|
||||
clangNoCompilerRt = wrapCCWith rec {
|
||||
cc = tools.clang-unwrapped;
|
||||
libcxx = null;
|
||||
bintools = bintoolsNoLibc';
|
||||
extraPackages = [ ];
|
||||
extraBuildCommands = mkExtraBuildCommands0 cc;
|
||||
nixSupport.cc-cflags =
|
||||
[
|
||||
"-nostartfiles"
|
||||
]
|
||||
++ lib.optional stdenv.targetPlatform.isWasm "-fno-exceptions";
|
||||
};
|
||||
|
||||
clangNoCompilerRtWithLibc = wrapCCWith (rec {
|
||||
cc = tools.clang-unwrapped;
|
||||
libcxx = null;
|
||||
bintools = bintools';
|
||||
extraPackages = [ ];
|
||||
extraBuildCommands = mkExtraBuildCommands0 cc;
|
||||
} // lib.optionalAttrs stdenv.targetPlatform.isWasm {
|
||||
nixSupport.cc-cflags = [ "-fno-exceptions" ];
|
||||
});
|
||||
|
||||
# Has to be in tools despite mostly being a library,
|
||||
# because we use a native helper executable from a
|
||||
# non-cross build in cross builds.
|
||||
libclc = callPackage ../common/libclc.nix {};
|
||||
});
|
||||
|
||||
libraries = lib.makeExtensible (libraries: let
|
||||
callPackage = newScope (libraries // buildLlvmTools // args // metadata);
|
||||
in {
|
||||
|
||||
compiler-rt-libc = callPackage ../common/compiler-rt {
|
||||
patches = [
|
||||
./compiler-rt/X86-support-extension.patch # Add support for i486 i586 i686 by reusing i386 config
|
||||
./compiler-rt/gnu-install-dirs.patch
|
||||
# ld-wrapper dislikes `-rpath-link //nix/store`, so we normalize away the
|
||||
# extra `/`.
|
||||
./compiler-rt/normalize-var.patch
|
||||
# Prevent a compilation error on darwin
|
||||
./compiler-rt/darwin-targetconditionals.patch
|
||||
# See: https://github.com/NixOS/nixpkgs/pull/186575
|
||||
../common/compiler-rt/darwin-plistbuddy-workaround.patch
|
||||
# See: https://github.com/NixOS/nixpkgs/pull/194634#discussion_r999829893
|
||||
# ../common/compiler-rt/armv7l-15.patch
|
||||
];
|
||||
stdenv = if stdenv.hostPlatform.useLLVM or false || (stdenv.hostPlatform.isDarwin && stdenv.hostPlatform.isStatic)
|
||||
then overrideCC stdenv buildLlvmTools.clangNoCompilerRtWithLibc
|
||||
else stdenv;
|
||||
};
|
||||
|
||||
compiler-rt-no-libc = callPackage ../common/compiler-rt {
|
||||
patches = [
|
||||
./compiler-rt/X86-support-extension.patch # Add support for i486 i586 i686 by reusing i386 config
|
||||
./compiler-rt/gnu-install-dirs.patch
|
||||
# ld-wrapper dislikes `-rpath-link //nix/store`, so we normalize away the
|
||||
# extra `/`.
|
||||
./compiler-rt/normalize-var.patch
|
||||
# Prevent a compilation error on darwin
|
||||
./compiler-rt/darwin-targetconditionals.patch
|
||||
# See: https://github.com/NixOS/nixpkgs/pull/186575
|
||||
../common/compiler-rt/darwin-plistbuddy-workaround.patch
|
||||
# See: https://github.com/NixOS/nixpkgs/pull/194634#discussion_r999829893
|
||||
# ../common/compiler-rt/armv7l-15.patch
|
||||
];
|
||||
stdenv = if stdenv.hostPlatform.useLLVM or false
|
||||
then overrideCC stdenv buildLlvmTools.clangNoCompilerRt
|
||||
else stdenv;
|
||||
};
|
||||
|
||||
# N.B. condition is safe because without useLLVM both are the same.
|
||||
compiler-rt = if stdenv.hostPlatform.isAndroid || stdenv.hostPlatform.isDarwin
|
||||
then libraries.compiler-rt-libc
|
||||
else libraries.compiler-rt-no-libc;
|
||||
|
||||
stdenv = overrideCC stdenv buildLlvmTools.clang;
|
||||
|
||||
libcxxStdenv = overrideCC stdenv buildLlvmTools.libcxxClang;
|
||||
|
||||
# `libcxx` requires a fairly modern C++ compiler,
|
||||
# so: we use the clang from this LLVM package set instead of the regular
|
||||
# stdenv's compiler.
|
||||
libcxx = callPackage ../common/libcxx {
|
||||
stdenv = overrideCC stdenv buildLlvmTools.clangNoLibcxx;
|
||||
};
|
||||
|
||||
libunwind = callPackage ../common/libunwind {
|
||||
patches = [
|
||||
./libunwind/gnu-install-dirs.patch
|
||||
];
|
||||
stdenv = overrideCC stdenv buildLlvmTools.clangNoLibcxx;
|
||||
};
|
||||
|
||||
openmp = callPackage ../common/openmp {
|
||||
patches = [
|
||||
./openmp/fix-find-tool.patch
|
||||
./openmp/gnu-install-dirs.patch
|
||||
./openmp/run-lit-directly.patch
|
||||
];
|
||||
};
|
||||
});
|
||||
noExtend = extensible: lib.attrsets.removeAttrs extensible [ "extend" ];
|
||||
|
||||
in { inherit tools libraries lldbPlugins; inherit (metadata) release_version; } // (noExtend libraries) // (noExtend tools)
|
@ -1,423 +0,0 @@
|
||||
{ lowPrio, newScope, pkgs, lib, stdenv
|
||||
, preLibcCrossHeaders
|
||||
, substitute, substituteAll, fetchFromGitHub, fetchpatch
|
||||
, overrideCC, wrapCCWith, wrapBintoolsWith
|
||||
, buildLlvmTools # tools, but from the previous stage, for cross
|
||||
, targetLlvmLibraries # libraries, but from the next stage, for cross
|
||||
, targetLlvm
|
||||
# This is the default binutils, but with *this* version of LLD rather
|
||||
# than the default LLVM verion's, if LLD is the choice. We use these for
|
||||
# the `useLLVM` bootstrapping below.
|
||||
, bootBintoolsNoLibc ?
|
||||
if stdenv.targetPlatform.linker == "lld"
|
||||
then null
|
||||
else pkgs.bintoolsNoLibc
|
||||
, bootBintools ?
|
||||
if stdenv.targetPlatform.linker == "lld"
|
||||
then null
|
||||
else pkgs.bintools
|
||||
, darwin
|
||||
# LLVM release information; specify one of these but not both:
|
||||
, gitRelease ? null
|
||||
# i.e.:
|
||||
# {
|
||||
# version = /* i.e. "15.0.0" */;
|
||||
# rev = /* commit SHA */;
|
||||
# rev-version = /* human readable version; i.e. "unstable-2022-26-07" */;
|
||||
# sha256 = /* checksum for this release, can omit if specifying your own `monorepoSrc` */;
|
||||
# }
|
||||
, officialRelease ? { version = "17.0.6"; sha256 = "sha256-8MEDLLhocshmxoEBRSKlJ/GzJ8nfuzQ8qn0X/vLA+ag="; }
|
||||
# i.e.:
|
||||
# {
|
||||
# version = /* i.e. "15.0.0" */;
|
||||
# candidate = /* optional; if specified, should be: "rcN" */
|
||||
# sha256 = /* checksum for this release, can omit if specifying your own `monorepoSrc` */;
|
||||
# }
|
||||
# By default, we'll try to fetch a release from `github:llvm/llvm-project`
|
||||
# corresponding to the `gitRelease` or `officialRelease` specified.
|
||||
#
|
||||
# You can provide your own LLVM source by specifying this arg but then it's up
|
||||
# to you to make sure that the LLVM repo given matches the release configuration
|
||||
# specified.
|
||||
, monorepoSrc ? null
|
||||
# Allows passthrough to packages via newScope. This makes it possible to
|
||||
# do `(llvmPackages.override { <someLlvmDependency> = bar; }).clang` and get
|
||||
# an llvmPackages whose packages are overridden in an internally consistent way.
|
||||
, ...
|
||||
}@args:
|
||||
|
||||
assert
|
||||
lib.assertMsg
|
||||
(lib.xor
|
||||
(gitRelease != null)
|
||||
(officialRelease != null))
|
||||
("must specify `gitRelease` or `officialRelease`" +
|
||||
(lib.optionalString (gitRelease != null) " — not both"));
|
||||
let
|
||||
monorepoSrc' = monorepoSrc;
|
||||
in let
|
||||
|
||||
metadata = rec {
|
||||
# Import releaseInfo separately to avoid infinite recursion
|
||||
inherit (import ../common/common-let.nix { inherit lib gitRelease officialRelease; }) releaseInfo;
|
||||
inherit (releaseInfo) release_version version;
|
||||
inherit (import ../common/common-let.nix { inherit lib fetchFromGitHub gitRelease release_version officialRelease monorepoSrc'; }) llvm_meta monorepoSrc;
|
||||
};
|
||||
|
||||
tools = lib.makeExtensible (tools: let
|
||||
callPackage = newScope (tools // args // metadata);
|
||||
major = lib.versions.major metadata.release_version;
|
||||
mkExtraBuildCommands0 = cc: ''
|
||||
rsrc="$out/resource-root"
|
||||
mkdir "$rsrc"
|
||||
ln -s "${cc.lib}/lib/clang/${major}/include" "$rsrc"
|
||||
echo "-resource-dir=$rsrc" >> $out/nix-support/cc-cflags
|
||||
'';
|
||||
mkExtraBuildCommands = cc: mkExtraBuildCommands0 cc + ''
|
||||
ln -s "${targetLlvmLibraries.compiler-rt.out}/lib" "$rsrc/lib"
|
||||
ln -s "${targetLlvmLibraries.compiler-rt.out}/share" "$rsrc/share"
|
||||
'';
|
||||
|
||||
bintoolsNoLibc' =
|
||||
if bootBintoolsNoLibc == null
|
||||
then tools.bintoolsNoLibc
|
||||
else bootBintoolsNoLibc;
|
||||
bintools' =
|
||||
if bootBintools == null
|
||||
then tools.bintools
|
||||
else bootBintools;
|
||||
|
||||
in {
|
||||
|
||||
libllvm = callPackage ../common/llvm {
|
||||
patches = [
|
||||
./llvm/gnu-install-dirs.patch
|
||||
|
||||
# Running the tests involves invoking binaries (like `opt`) that depend on
|
||||
# the LLVM dylibs and reference them by absolute install path (i.e. their
|
||||
# nix store path).
|
||||
#
|
||||
# Because we have not yet run the install phase (we're running these tests
|
||||
# as part of `checkPhase` instead of `installCheckPhase`) these absolute
|
||||
# paths do not exist yet; to work around this we point the loader (`ld` on
|
||||
# unix, `dyld` on macOS) at the `lib` directory which will later become this
|
||||
# package's `lib` output.
|
||||
#
|
||||
# Previously we would just set `LD_LIBRARY_PATH` to include the build `lib`
|
||||
# dir but:
|
||||
# - this doesn't generalize well to other platforms; `lit` doesn't forward
|
||||
# `DYLD_LIBRARY_PATH` (macOS):
|
||||
# + https://github.com/llvm/llvm-project/blob/0d89963df354ee309c15f67dc47c8ab3cb5d0fb2/llvm/utils/lit/lit/TestingConfig.py#L26
|
||||
# - even if `lit` forwarded this env var, we actually cannot set
|
||||
# `DYLD_LIBRARY_PATH` in the child processes `lit` launches because
|
||||
# `DYLD_LIBRARY_PATH` (and `DYLD_FALLBACK_LIBRARY_PATH`) is cleared for
|
||||
# "protected processes" (i.e. the python interpreter that runs `lit`):
|
||||
# https://stackoverflow.com/a/35570229
|
||||
# - other LLVM subprojects deal with this issue by having their `lit`
|
||||
# configuration set these env vars for us; it makes sense to do the same
|
||||
# for LLVM:
|
||||
# + https://github.com/llvm/llvm-project/blob/4c106cfdf7cf7eec861ad3983a3dd9a9e8f3a8ae/clang-tools-extra/test/Unit/lit.cfg.py#L22-L31
|
||||
#
|
||||
# !!! TODO: look into upstreaming this patch
|
||||
./llvm/llvm-lit-cfg-add-libs-to-dylib-path.patch
|
||||
|
||||
# `lit` has a mode where it executes run lines as a shell script which is
|
||||
# constructs; this is problematic for macOS because it means that there's
|
||||
# another process in between `lit` and the binaries being tested. As noted
|
||||
# above, this means that `DYLD_LIBRARY_PATH` is cleared which means that our
|
||||
# tests fail with dyld errors.
|
||||
#
|
||||
# To get around this we patch `lit` to reintroduce `DYLD_LIBRARY_PATH`, when
|
||||
# present in the test configuration.
|
||||
#
|
||||
# It's not clear to me why this isn't an issue for LLVM developers running
|
||||
# on macOS (nothing about this _seems_ nix specific)..
|
||||
./llvm/lit-shell-script-runner-set-dyld-library-path.patch
|
||||
];
|
||||
pollyPatches = [
|
||||
./llvm/gnu-install-dirs-polly.patch
|
||||
|
||||
# Just like the `llvm-lit-cfg` patch, but for `polly`.
|
||||
./llvm/polly-lit-cfg-add-libs-to-dylib-path.patch
|
||||
];
|
||||
};
|
||||
|
||||
# `llvm` historically had the binaries. When choosing an output explicitly,
|
||||
# we need to reintroduce `outputSpecified` to get the expected behavior e.g. of lib.get*
|
||||
llvm = tools.libllvm;
|
||||
|
||||
libclang = callPackage ../common/clang {
|
||||
patches = [
|
||||
./clang/purity.patch
|
||||
# https://reviews.llvm.org/D51899
|
||||
./clang/gnu-install-dirs.patch
|
||||
../common/clang/add-nostdlibinc-flag.patch
|
||||
(substituteAll {
|
||||
src = ../common/clang/clang-at-least-16-LLVMgold-path.patch;
|
||||
libllvmLibdir = "${tools.libllvm.lib}/lib";
|
||||
})
|
||||
];
|
||||
};
|
||||
|
||||
clang-unwrapped = tools.libclang;
|
||||
|
||||
llvm-manpages = lowPrio (tools.libllvm.override {
|
||||
enableManpages = true;
|
||||
python3 = pkgs.python3; # don't use python-boot
|
||||
});
|
||||
|
||||
clang-manpages = lowPrio (tools.libclang.override {
|
||||
enableManpages = true;
|
||||
python3 = pkgs.python3; # don't use python-boot
|
||||
});
|
||||
|
||||
lldb-manpages = lowPrio (tools.lldb.override {
|
||||
enableManpages = true;
|
||||
python3 = pkgs.python3; # don't use python-boot
|
||||
});
|
||||
|
||||
# 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;
|
||||
|
||||
libstdcxxClang = wrapCCWith rec {
|
||||
cc = tools.clang-unwrapped;
|
||||
# libstdcxx is taken from gcc in an ad-hoc way in cc-wrapper.
|
||||
libcxx = null;
|
||||
extraPackages = [
|
||||
targetLlvmLibraries.compiler-rt
|
||||
];
|
||||
extraBuildCommands = mkExtraBuildCommands cc;
|
||||
};
|
||||
|
||||
libcxxClang = wrapCCWith rec {
|
||||
cc = tools.clang-unwrapped;
|
||||
libcxx = targetLlvmLibraries.libcxx;
|
||||
extraPackages = [
|
||||
targetLlvmLibraries.compiler-rt
|
||||
];
|
||||
extraBuildCommands = mkExtraBuildCommands cc;
|
||||
};
|
||||
|
||||
lld = callPackage ../common/lld {
|
||||
patches = [
|
||||
./lld/gnu-install-dirs.patch
|
||||
./lld/add-table-base.patch
|
||||
];
|
||||
};
|
||||
|
||||
mlir = callPackage ../common/mlir {};
|
||||
|
||||
lldb = callPackage ../common/lldb.nix {
|
||||
src = callPackage ({ runCommand }: runCommand "lldb-src-${metadata.version}" {} ''
|
||||
mkdir -p "$out"
|
||||
cp -r ${monorepoSrc}/cmake "$out"
|
||||
cp -r ${monorepoSrc}/lldb "$out"
|
||||
'') { };
|
||||
patches =
|
||||
[
|
||||
# FIXME: do we need this? ./procfs.patch
|
||||
../common/lldb/gnu-install-dirs.patch
|
||||
]
|
||||
# This is a stopgap solution if/until the macOS SDK used for x86_64 is
|
||||
# updated.
|
||||
#
|
||||
# The older 10.12 SDK used on x86_64 as of this writing has a `mach/machine.h`
|
||||
# header that does not define `CPU_SUBTYPE_ARM64E` so we replace the one use
|
||||
# of this preprocessor symbol in `lldb` with its expansion.
|
||||
#
|
||||
# See here for some context:
|
||||
# https://github.com/NixOS/nixpkgs/pull/194634#issuecomment-1272129132
|
||||
++ lib.optional (
|
||||
stdenv.targetPlatform.isDarwin
|
||||
&& !stdenv.targetPlatform.isAarch64
|
||||
&& (lib.versionOlder darwin.apple_sdk.sdk.version "11.0")
|
||||
) ./lldb/cpu_subtype_arm64e_replacement.patch;
|
||||
};
|
||||
|
||||
# Below, is the LLVM bootstrapping logic. It handles building a
|
||||
# fully LLVM toolchain from scratch. No GCC toolchain should be
|
||||
# pulled in. As a consequence, it is very quick to build different
|
||||
# targets provided by LLVM and we can also build for what GCC
|
||||
# doesn’t support like LLVM. Probably we should move to some other
|
||||
# file.
|
||||
|
||||
bintools-unwrapped = callPackage ../common/bintools.nix { };
|
||||
|
||||
bintoolsNoLibc = wrapBintoolsWith {
|
||||
bintools = tools.bintools-unwrapped;
|
||||
libc = preLibcCrossHeaders;
|
||||
};
|
||||
|
||||
bintools = wrapBintoolsWith {
|
||||
bintools = tools.bintools-unwrapped;
|
||||
};
|
||||
|
||||
clangUseLLVM = wrapCCWith rec {
|
||||
cc = tools.clang-unwrapped;
|
||||
libcxx = targetLlvmLibraries.libcxx;
|
||||
bintools = bintools';
|
||||
extraPackages = [
|
||||
targetLlvmLibraries.compiler-rt
|
||||
] ++ lib.optionals (!stdenv.targetPlatform.isWasm) [
|
||||
targetLlvmLibraries.libunwind
|
||||
];
|
||||
extraBuildCommands = mkExtraBuildCommands cc;
|
||||
nixSupport.cc-cflags =
|
||||
[ "-rtlib=compiler-rt"
|
||||
"-Wno-unused-command-line-argument"
|
||||
"-B${targetLlvmLibraries.compiler-rt}/lib"
|
||||
]
|
||||
++ lib.optional (!stdenv.targetPlatform.isWasm) "--unwindlib=libunwind"
|
||||
++ lib.optional
|
||||
(!stdenv.targetPlatform.isWasm && stdenv.targetPlatform.useLLVM or false)
|
||||
"-lunwind"
|
||||
++ lib.optional stdenv.targetPlatform.isWasm "-fno-exceptions";
|
||||
nixSupport.cc-ldflags = lib.optionals (!stdenv.targetPlatform.isWasm) [ "-L${targetLlvmLibraries.libunwind}/lib" ];
|
||||
};
|
||||
|
||||
clangNoLibcxx = wrapCCWith rec {
|
||||
cc = tools.clang-unwrapped;
|
||||
libcxx = null;
|
||||
bintools = bintools';
|
||||
extraPackages = [
|
||||
targetLlvmLibraries.compiler-rt
|
||||
];
|
||||
extraBuildCommands = mkExtraBuildCommands cc;
|
||||
nixSupport.cc-cflags =
|
||||
[
|
||||
"-rtlib=compiler-rt"
|
||||
"-B${targetLlvmLibraries.compiler-rt}/lib"
|
||||
"-nostdlib++"
|
||||
]
|
||||
++ lib.optional stdenv.targetPlatform.isWasm "-fno-exceptions";
|
||||
};
|
||||
|
||||
clangNoLibc = wrapCCWith rec {
|
||||
cc = tools.clang-unwrapped;
|
||||
libcxx = null;
|
||||
bintools = bintoolsNoLibc';
|
||||
extraPackages = [
|
||||
targetLlvmLibraries.compiler-rt
|
||||
];
|
||||
extraBuildCommands = mkExtraBuildCommands cc;
|
||||
nixSupport.cc-cflags =
|
||||
[
|
||||
"-rtlib=compiler-rt"
|
||||
"-B${targetLlvmLibraries.compiler-rt}/lib"
|
||||
]
|
||||
++ lib.optional stdenv.targetPlatform.isWasm "-fno-exceptions";
|
||||
};
|
||||
|
||||
clangNoCompilerRt = wrapCCWith rec {
|
||||
cc = tools.clang-unwrapped;
|
||||
libcxx = null;
|
||||
bintools = bintoolsNoLibc';
|
||||
extraPackages = [ ];
|
||||
extraBuildCommands = mkExtraBuildCommands0 cc;
|
||||
nixSupport.cc-cflags =
|
||||
[
|
||||
"-nostartfiles"
|
||||
]
|
||||
++ lib.optional stdenv.targetPlatform.isWasm "-fno-exceptions";
|
||||
};
|
||||
|
||||
clangNoCompilerRtWithLibc = wrapCCWith (rec {
|
||||
cc = tools.clang-unwrapped;
|
||||
libcxx = null;
|
||||
bintools = bintools';
|
||||
extraPackages = [ ];
|
||||
extraBuildCommands = mkExtraBuildCommands0 cc;
|
||||
} // lib.optionalAttrs stdenv.targetPlatform.isWasm {
|
||||
nixSupport.cc-cflags = [ "-fno-exceptions" ];
|
||||
});
|
||||
|
||||
# Has to be in tools despite mostly being a library,
|
||||
# because we use a native helper executable from a
|
||||
# non-cross build in cross builds.
|
||||
libclc = callPackage ../common/libclc.nix {};
|
||||
});
|
||||
|
||||
libraries = lib.makeExtensible (libraries: let
|
||||
callPackage = newScope (libraries // buildLlvmTools // args // metadata);
|
||||
in {
|
||||
|
||||
compiler-rt-libc = callPackage ../common/compiler-rt {
|
||||
patches = [
|
||||
./compiler-rt/X86-support-extension.patch # Add support for i486 i586 i686 by reusing i386 config
|
||||
./compiler-rt/gnu-install-dirs.patch
|
||||
# ld-wrapper dislikes `-rpath-link //nix/store`, so we normalize away the
|
||||
# extra `/`.
|
||||
./compiler-rt/normalize-var.patch
|
||||
# Prevent a compilation error on darwin
|
||||
./compiler-rt/darwin-targetconditionals.patch
|
||||
# See: https://github.com/NixOS/nixpkgs/pull/186575
|
||||
../common/compiler-rt/darwin-plistbuddy-workaround.patch
|
||||
# See: https://github.com/NixOS/nixpkgs/pull/194634#discussion_r999829893
|
||||
# ../common/compiler-rt/armv7l-15.patch
|
||||
];
|
||||
stdenv = if stdenv.hostPlatform.useLLVM or false || (stdenv.hostPlatform.isDarwin && stdenv.hostPlatform.isStatic)
|
||||
then overrideCC stdenv buildLlvmTools.clangNoCompilerRtWithLibc
|
||||
else stdenv;
|
||||
};
|
||||
|
||||
compiler-rt-no-libc = callPackage ../common/compiler-rt {
|
||||
patches = [
|
||||
./compiler-rt/X86-support-extension.patch # Add support for i486 i586 i686 by reusing i386 config
|
||||
./compiler-rt/gnu-install-dirs.patch
|
||||
# ld-wrapper dislikes `-rpath-link //nix/store`, so we normalize away the
|
||||
# extra `/`.
|
||||
./compiler-rt/normalize-var.patch
|
||||
# Prevent a compilation error on darwin
|
||||
./compiler-rt/darwin-targetconditionals.patch
|
||||
# See: https://github.com/NixOS/nixpkgs/pull/186575
|
||||
../common/compiler-rt/darwin-plistbuddy-workaround.patch
|
||||
# See: https://github.com/NixOS/nixpkgs/pull/194634#discussion_r999829893
|
||||
# ../common/compiler-rt/armv7l-15.patch
|
||||
];
|
||||
stdenv = if stdenv.hostPlatform.useLLVM or false
|
||||
then overrideCC stdenv buildLlvmTools.clangNoCompilerRt
|
||||
else stdenv;
|
||||
};
|
||||
|
||||
# N.B. condition is safe because without useLLVM both are the same.
|
||||
compiler-rt = if stdenv.hostPlatform.isAndroid || stdenv.hostPlatform.isDarwin
|
||||
then libraries.compiler-rt-libc
|
||||
else libraries.compiler-rt-no-libc;
|
||||
|
||||
stdenv = overrideCC stdenv buildLlvmTools.clang;
|
||||
|
||||
libcxxStdenv = overrideCC stdenv buildLlvmTools.libcxxClang;
|
||||
|
||||
# `libcxx` requires a fairly modern C++ compiler,
|
||||
# so: we use the clang from this LLVM package set instead of the regular
|
||||
# stdenv's compiler.
|
||||
libcxx = callPackage ../common/libcxx {
|
||||
patches = lib.optionals (stdenv.isDarwin && lib.versionOlder stdenv.hostPlatform.darwinMinVersion "10.13") [
|
||||
# https://github.com/llvm/llvm-project/issues/64226
|
||||
(fetchpatch {
|
||||
name = "0042-mbstate_t-not-defined.patch";
|
||||
url = "https://github.com/macports/macports-ports/raw/acd8acb171f1658596ed1cf25da48d5b932e2d19/lang/llvm-17/files/0042-mbstate_t-not-defined.patch";
|
||||
hash = "sha256-jo+DYA6zuSv9OH3A0bYwY5TlkWprup4OKQ7rfK1WHBI=";
|
||||
})
|
||||
];
|
||||
stdenv = overrideCC stdenv buildLlvmTools.clangNoLibcxx;
|
||||
};
|
||||
|
||||
libunwind = callPackage ../common/libunwind {
|
||||
stdenv = overrideCC stdenv buildLlvmTools.clangNoLibcxx;
|
||||
};
|
||||
|
||||
openmp = callPackage ../common/openmp {
|
||||
patches = [
|
||||
./openmp/fix-find-tool.patch
|
||||
./openmp/gnu-install-dirs.patch
|
||||
./openmp/run-lit-directly.patch
|
||||
];
|
||||
};
|
||||
});
|
||||
noExtend = extensible: lib.attrsets.removeAttrs extensible [ "extend" ];
|
||||
|
||||
in { inherit tools libraries; inherit (metadata) release_version; } // (noExtend libraries) // (noExtend tools)
|
@ -1,411 +0,0 @@
|
||||
{ lowPrio, newScope, pkgs, lib, stdenv
|
||||
, preLibcCrossHeaders
|
||||
, substitute, substituteAll, fetchFromGitHub
|
||||
, overrideCC, wrapCCWith, wrapBintoolsWith
|
||||
, buildLlvmTools # tools, but from the previous stage, for cross
|
||||
, targetLlvmLibraries # libraries, but from the next stage, for cross
|
||||
, targetLlvm
|
||||
# This is the default binutils, but with *this* version of LLD rather
|
||||
# than the default LLVM verion's, if LLD is the choice. We use these for
|
||||
# the `useLLVM` bootstrapping below.
|
||||
, bootBintoolsNoLibc ?
|
||||
if stdenv.targetPlatform.linker == "lld"
|
||||
then null
|
||||
else pkgs.bintoolsNoLibc
|
||||
, bootBintools ?
|
||||
if stdenv.targetPlatform.linker == "lld"
|
||||
then null
|
||||
else pkgs.bintools
|
||||
, darwin
|
||||
# LLVM release information; specify one of these but not both:
|
||||
, gitRelease ? null
|
||||
# i.e.:
|
||||
# {
|
||||
# version = /* i.e. "15.0.0" */;
|
||||
# rev = /* commit SHA */;
|
||||
# rev-version = /* human readable version; i.e. "unstable-2022-26-07" */;
|
||||
# sha256 = /* checksum for this release, can omit if specifying your own `monorepoSrc` */;
|
||||
# }
|
||||
, officialRelease ? { version = "18.1.8"; sha256 = "sha256-iiZKMRo/WxJaBXct9GdAcAT3cz9d9pnAcO1mmR6oPNE="; }
|
||||
# i.e.:
|
||||
# {
|
||||
# version = /* i.e. "15.0.0" */;
|
||||
# candidate = /* optional; if specified, should be: "rcN" */
|
||||
# sha256 = /* checksum for this release, can omit if specifying your own `monorepoSrc` */;
|
||||
# }
|
||||
# By default, we'll try to fetch a release from `github:llvm/llvm-project`
|
||||
# corresponding to the `gitRelease` or `officialRelease` specified.
|
||||
#
|
||||
# You can provide your own LLVM source by specifying this arg but then it's up
|
||||
# to you to make sure that the LLVM repo given matches the release configuration
|
||||
# specified.
|
||||
, monorepoSrc ? null
|
||||
# Allows passthrough to packages via newScope. This makes it possible to
|
||||
# do `(llvmPackages.override { <someLlvmDependency> = bar; }).clang` and get
|
||||
# an llvmPackages whose packages are overridden in an internally consistent way.
|
||||
, ...
|
||||
}@args:
|
||||
|
||||
assert
|
||||
lib.assertMsg
|
||||
(lib.xor
|
||||
(gitRelease != null)
|
||||
(officialRelease != null))
|
||||
("must specify `gitRelease` or `officialRelease`" +
|
||||
(lib.optionalString (gitRelease != null) " — not both"));
|
||||
let
|
||||
monorepoSrc' = monorepoSrc;
|
||||
in let
|
||||
|
||||
metadata = rec {
|
||||
# Import releaseInfo separately to avoid infinite recursion
|
||||
inherit (import ../common/common-let.nix { inherit lib gitRelease officialRelease; }) releaseInfo;
|
||||
inherit (releaseInfo) release_version version;
|
||||
inherit (import ../common/common-let.nix { inherit lib fetchFromGitHub gitRelease release_version officialRelease monorepoSrc'; }) llvm_meta monorepoSrc;
|
||||
};
|
||||
|
||||
tools = lib.makeExtensible (tools: let
|
||||
callPackage = newScope (tools // args // metadata);
|
||||
major = lib.versions.major metadata.release_version;
|
||||
mkExtraBuildCommands0 = cc: ''
|
||||
rsrc="$out/resource-root"
|
||||
mkdir "$rsrc"
|
||||
ln -s "${cc.lib}/lib/clang/${major}/include" "$rsrc"
|
||||
echo "-resource-dir=$rsrc" >> $out/nix-support/cc-cflags
|
||||
'';
|
||||
mkExtraBuildCommands = cc: mkExtraBuildCommands0 cc + ''
|
||||
ln -s "${targetLlvmLibraries.compiler-rt.out}/lib" "$rsrc/lib"
|
||||
ln -s "${targetLlvmLibraries.compiler-rt.out}/share" "$rsrc/share"
|
||||
'';
|
||||
|
||||
bintoolsNoLibc' =
|
||||
if bootBintoolsNoLibc == null
|
||||
then tools.bintoolsNoLibc
|
||||
else bootBintoolsNoLibc;
|
||||
bintools' =
|
||||
if bootBintools == null
|
||||
then tools.bintools
|
||||
else bootBintools;
|
||||
|
||||
in {
|
||||
|
||||
libllvm = callPackage ../common/llvm {
|
||||
patches = [
|
||||
./llvm/gnu-install-dirs.patch
|
||||
|
||||
# Running the tests involves invoking binaries (like `opt`) that depend on
|
||||
# the LLVM dylibs and reference them by absolute install path (i.e. their
|
||||
# nix store path).
|
||||
#
|
||||
# Because we have not yet run the install phase (we're running these tests
|
||||
# as part of `checkPhase` instead of `installCheckPhase`) these absolute
|
||||
# paths do not exist yet; to work around this we point the loader (`ld` on
|
||||
# unix, `dyld` on macOS) at the `lib` directory which will later become this
|
||||
# package's `lib` output.
|
||||
#
|
||||
# Previously we would just set `LD_LIBRARY_PATH` to include the build `lib`
|
||||
# dir but:
|
||||
# - this doesn't generalize well to other platforms; `lit` doesn't forward
|
||||
# `DYLD_LIBRARY_PATH` (macOS):
|
||||
# + https://github.com/llvm/llvm-project/blob/0d89963df354ee309c15f67dc47c8ab3cb5d0fb2/llvm/utils/lit/lit/TestingConfig.py#L26
|
||||
# - even if `lit` forwarded this env var, we actually cannot set
|
||||
# `DYLD_LIBRARY_PATH` in the child processes `lit` launches because
|
||||
# `DYLD_LIBRARY_PATH` (and `DYLD_FALLBACK_LIBRARY_PATH`) is cleared for
|
||||
# "protected processes" (i.e. the python interpreter that runs `lit`):
|
||||
# https://stackoverflow.com/a/35570229
|
||||
# - other LLVM subprojects deal with this issue by having their `lit`
|
||||
# configuration set these env vars for us; it makes sense to do the same
|
||||
# for LLVM:
|
||||
# + https://github.com/llvm/llvm-project/blob/4c106cfdf7cf7eec861ad3983a3dd9a9e8f3a8ae/clang-tools-extra/test/Unit/lit.cfg.py#L22-L31
|
||||
#
|
||||
# !!! TODO: look into upstreaming this patch
|
||||
./llvm/llvm-lit-cfg-add-libs-to-dylib-path.patch
|
||||
|
||||
# `lit` has a mode where it executes run lines as a shell script which is
|
||||
# constructs; this is problematic for macOS because it means that there's
|
||||
# another process in between `lit` and the binaries being tested. As noted
|
||||
# above, this means that `DYLD_LIBRARY_PATH` is cleared which means that our
|
||||
# tests fail with dyld errors.
|
||||
#
|
||||
# To get around this we patch `lit` to reintroduce `DYLD_LIBRARY_PATH`, when
|
||||
# present in the test configuration.
|
||||
#
|
||||
# It's not clear to me why this isn't an issue for LLVM developers running
|
||||
# on macOS (nothing about this _seems_ nix specific)..
|
||||
./llvm/lit-shell-script-runner-set-dyld-library-path.patch
|
||||
];
|
||||
pollyPatches = [
|
||||
./llvm/gnu-install-dirs-polly.patch
|
||||
|
||||
# Just like the `llvm-lit-cfg` patch, but for `polly`.
|
||||
./llvm/polly-lit-cfg-add-libs-to-dylib-path.patch
|
||||
];
|
||||
};
|
||||
|
||||
# `llvm` historically had the binaries. When choosing an output explicitly,
|
||||
# we need to reintroduce `outputSpecified` to get the expected behavior e.g. of lib.get*
|
||||
llvm = tools.libllvm;
|
||||
|
||||
libclang = callPackage ../common/clang {
|
||||
patches = [
|
||||
./clang/purity.patch
|
||||
# https://reviews.llvm.org/D51899
|
||||
./clang/gnu-install-dirs.patch
|
||||
../common/clang/add-nostdlibinc-flag.patch
|
||||
(substituteAll {
|
||||
src = ../common/clang/clang-at-least-16-LLVMgold-path.patch;
|
||||
libllvmLibdir = "${tools.libllvm.lib}/lib";
|
||||
})
|
||||
];
|
||||
};
|
||||
|
||||
clang-unwrapped = tools.libclang;
|
||||
|
||||
llvm-manpages = lowPrio (tools.libllvm.override {
|
||||
enableManpages = true;
|
||||
python3 = pkgs.python3; # don't use python-boot
|
||||
});
|
||||
|
||||
clang-manpages = lowPrio (tools.libclang.override {
|
||||
enableManpages = true;
|
||||
python3 = pkgs.python3; # don't use python-boot
|
||||
});
|
||||
|
||||
lldb-manpages = lowPrio (tools.lldb.override {
|
||||
enableManpages = true;
|
||||
python3 = pkgs.python3; # don't use python-boot
|
||||
});
|
||||
|
||||
# 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;
|
||||
|
||||
libstdcxxClang = wrapCCWith rec {
|
||||
cc = tools.clang-unwrapped;
|
||||
# libstdcxx is taken from gcc in an ad-hoc way in cc-wrapper.
|
||||
libcxx = null;
|
||||
extraPackages = [
|
||||
targetLlvmLibraries.compiler-rt
|
||||
];
|
||||
extraBuildCommands = mkExtraBuildCommands cc;
|
||||
};
|
||||
|
||||
libcxxClang = wrapCCWith rec {
|
||||
cc = tools.clang-unwrapped;
|
||||
libcxx = targetLlvmLibraries.libcxx;
|
||||
extraPackages = [
|
||||
targetLlvmLibraries.compiler-rt
|
||||
];
|
||||
extraBuildCommands = mkExtraBuildCommands cc;
|
||||
};
|
||||
|
||||
lld = callPackage ../common/lld {
|
||||
patches = [
|
||||
./lld/gnu-install-dirs.patch
|
||||
];
|
||||
};
|
||||
|
||||
mlir = callPackage ../common/mlir {};
|
||||
|
||||
lldb = callPackage ../common/lldb.nix {
|
||||
src = callPackage ({ runCommand }: runCommand "lldb-src-${metadata.version}" {} ''
|
||||
mkdir -p "$out"
|
||||
cp -r ${monorepoSrc}/cmake "$out"
|
||||
cp -r ${monorepoSrc}/lldb "$out"
|
||||
'') { };
|
||||
patches =
|
||||
[
|
||||
# FIXME: do we need this? ./procfs.patch
|
||||
../common/lldb/gnu-install-dirs.patch
|
||||
]
|
||||
# This is a stopgap solution if/until the macOS SDK used for x86_64 is
|
||||
# updated.
|
||||
#
|
||||
# The older 10.12 SDK used on x86_64 as of this writing has a `mach/machine.h`
|
||||
# header that does not define `CPU_SUBTYPE_ARM64E` so we replace the one use
|
||||
# of this preprocessor symbol in `lldb` with its expansion.
|
||||
#
|
||||
# See here for some context:
|
||||
# https://github.com/NixOS/nixpkgs/pull/194634#issuecomment-1272129132
|
||||
++ lib.optional (
|
||||
stdenv.targetPlatform.isDarwin
|
||||
&& !stdenv.targetPlatform.isAarch64
|
||||
&& (lib.versionOlder darwin.apple_sdk.sdk.version "11.0")
|
||||
) ./lldb/cpu_subtype_arm64e_replacement.patch;
|
||||
};
|
||||
|
||||
# Below, is the LLVM bootstrapping logic. It handles building a
|
||||
# fully LLVM toolchain from scratch. No GCC toolchain should be
|
||||
# pulled in. As a consequence, it is very quick to build different
|
||||
# targets provided by LLVM and we can also build for what GCC
|
||||
# doesn’t support like LLVM. Probably we should move to some other
|
||||
# file.
|
||||
|
||||
bintools-unwrapped = callPackage ../common/bintools.nix { };
|
||||
|
||||
bintoolsNoLibc = wrapBintoolsWith {
|
||||
bintools = tools.bintools-unwrapped;
|
||||
libc = preLibcCrossHeaders;
|
||||
};
|
||||
|
||||
bintools = wrapBintoolsWith {
|
||||
bintools = tools.bintools-unwrapped;
|
||||
};
|
||||
|
||||
clangUseLLVM = wrapCCWith rec {
|
||||
cc = tools.clang-unwrapped;
|
||||
libcxx = targetLlvmLibraries.libcxx;
|
||||
bintools = bintools';
|
||||
extraPackages = [
|
||||
targetLlvmLibraries.compiler-rt
|
||||
] ++ lib.optionals (!stdenv.targetPlatform.isWasm) [
|
||||
targetLlvmLibraries.libunwind
|
||||
];
|
||||
extraBuildCommands = mkExtraBuildCommands cc;
|
||||
nixSupport.cc-cflags =
|
||||
[ "-rtlib=compiler-rt"
|
||||
"-Wno-unused-command-line-argument"
|
||||
"-B${targetLlvmLibraries.compiler-rt}/lib"
|
||||
]
|
||||
++ lib.optional (!stdenv.targetPlatform.isWasm) "--unwindlib=libunwind"
|
||||
++ lib.optional
|
||||
(!stdenv.targetPlatform.isWasm && stdenv.targetPlatform.useLLVM or false)
|
||||
"-lunwind"
|
||||
++ lib.optional stdenv.targetPlatform.isWasm "-fno-exceptions";
|
||||
nixSupport.cc-ldflags = lib.optionals (!stdenv.targetPlatform.isWasm) [ "-L${targetLlvmLibraries.libunwind}/lib" ];
|
||||
};
|
||||
|
||||
clangNoLibcxx = wrapCCWith rec {
|
||||
cc = tools.clang-unwrapped;
|
||||
libcxx = null;
|
||||
bintools = bintools';
|
||||
extraPackages = [
|
||||
targetLlvmLibraries.compiler-rt
|
||||
];
|
||||
extraBuildCommands = mkExtraBuildCommands cc;
|
||||
nixSupport.cc-cflags =
|
||||
[
|
||||
"-rtlib=compiler-rt"
|
||||
"-B${targetLlvmLibraries.compiler-rt}/lib"
|
||||
"-nostdlib++"
|
||||
]
|
||||
++ lib.optional stdenv.targetPlatform.isWasm "-fno-exceptions";
|
||||
};
|
||||
|
||||
clangNoLibc = wrapCCWith rec {
|
||||
cc = tools.clang-unwrapped;
|
||||
libcxx = null;
|
||||
bintools = bintoolsNoLibc';
|
||||
extraPackages = [
|
||||
targetLlvmLibraries.compiler-rt
|
||||
];
|
||||
extraBuildCommands = mkExtraBuildCommands cc;
|
||||
nixSupport.cc-cflags =
|
||||
[
|
||||
"-rtlib=compiler-rt"
|
||||
"-B${targetLlvmLibraries.compiler-rt}/lib"
|
||||
]
|
||||
++ lib.optional stdenv.targetPlatform.isWasm "-fno-exceptions";
|
||||
};
|
||||
|
||||
clangNoCompilerRt = wrapCCWith rec {
|
||||
cc = tools.clang-unwrapped;
|
||||
libcxx = null;
|
||||
bintools = bintoolsNoLibc';
|
||||
extraPackages = [ ];
|
||||
extraBuildCommands = mkExtraBuildCommands0 cc;
|
||||
nixSupport.cc-cflags =
|
||||
[
|
||||
"-nostartfiles"
|
||||
]
|
||||
++ lib.optional stdenv.targetPlatform.isWasm "-fno-exceptions";
|
||||
};
|
||||
|
||||
clangNoCompilerRtWithLibc = wrapCCWith (rec {
|
||||
cc = tools.clang-unwrapped;
|
||||
libcxx = null;
|
||||
bintools = bintools';
|
||||
extraPackages = [ ];
|
||||
extraBuildCommands = mkExtraBuildCommands0 cc;
|
||||
} // lib.optionalAttrs stdenv.targetPlatform.isWasm {
|
||||
nixSupport.cc-cflags = [ "-fno-exceptions" ];
|
||||
});
|
||||
|
||||
# Has to be in tools despite mostly being a library,
|
||||
# because we use a native helper executable from a
|
||||
# non-cross build in cross builds.
|
||||
libclc = callPackage ../common/libclc.nix {};
|
||||
});
|
||||
|
||||
libraries = lib.makeExtensible (libraries: let
|
||||
callPackage = newScope (libraries // buildLlvmTools // args // metadata);
|
||||
in {
|
||||
|
||||
compiler-rt-libc = callPackage ../common/compiler-rt {
|
||||
patches = [
|
||||
./compiler-rt/X86-support-extension.patch # Add support for i486 i586 i686 by reusing i386 config
|
||||
# ld-wrapper dislikes `-rpath-link //nix/store`, so we normalize away the
|
||||
# extra `/`.
|
||||
./compiler-rt/normalize-var.patch
|
||||
# See: https://github.com/NixOS/nixpkgs/pull/186575
|
||||
../common/compiler-rt/darwin-plistbuddy-workaround.patch
|
||||
# See: https://github.com/NixOS/nixpkgs/pull/194634#discussion_r999829893
|
||||
# ../common/compiler-rt/armv7l-15.patch
|
||||
];
|
||||
stdenv = if stdenv.hostPlatform.useLLVM or false || (stdenv.hostPlatform.isDarwin && stdenv.hostPlatform.isStatic)
|
||||
then overrideCC stdenv buildLlvmTools.clangNoCompilerRtWithLibc
|
||||
else stdenv;
|
||||
};
|
||||
|
||||
compiler-rt-no-libc = callPackage ../common/compiler-rt {
|
||||
patches = [
|
||||
./compiler-rt/X86-support-extension.patch # Add support for i486 i586 i686 by reusing i386 config
|
||||
# ld-wrapper dislikes `-rpath-link //nix/store`, so we normalize away the
|
||||
# extra `/`.
|
||||
./compiler-rt/normalize-var.patch
|
||||
# See: https://github.com/NixOS/nixpkgs/pull/186575
|
||||
../common/compiler-rt/darwin-plistbuddy-workaround.patch
|
||||
# See: https://github.com/NixOS/nixpkgs/pull/194634#discussion_r999829893
|
||||
# ../common/compiler-rt/armv7l-15.patch
|
||||
];
|
||||
stdenv = if stdenv.hostPlatform.useLLVM or false
|
||||
then overrideCC stdenv buildLlvmTools.clangNoCompilerRt
|
||||
else stdenv;
|
||||
};
|
||||
|
||||
# N.B. condition is safe because without useLLVM both are the same.
|
||||
compiler-rt = if stdenv.hostPlatform.isAndroid || stdenv.hostPlatform.isDarwin
|
||||
then libraries.compiler-rt-libc
|
||||
else libraries.compiler-rt-no-libc;
|
||||
|
||||
stdenv = overrideCC stdenv buildLlvmTools.clang;
|
||||
|
||||
libcxxStdenv = overrideCC stdenv buildLlvmTools.libcxxClang;
|
||||
|
||||
# `libcxx` requires a fairly modern C++ compiler,
|
||||
# so: we use the clang from this LLVM package set instead of the regular
|
||||
# stdenv's compiler.
|
||||
libcxx = callPackage ../common/libcxx {
|
||||
patches = lib.optionals (stdenv.isDarwin && lib.versionOlder stdenv.hostPlatform.darwinMinVersion "10.13") [
|
||||
# https://github.com/llvm/llvm-project/issues/64226
|
||||
./libcxx/0001-darwin-10.12-mbstate_t-fix.patch
|
||||
];
|
||||
stdenv = overrideCC stdenv buildLlvmTools.clangNoLibcxx;
|
||||
};
|
||||
|
||||
libunwind = callPackage ../common/libunwind {
|
||||
stdenv = overrideCC stdenv buildLlvmTools.clangNoLibcxx;
|
||||
};
|
||||
|
||||
openmp = callPackage ../common/openmp {
|
||||
patches = [
|
||||
./openmp/fix-find-tool.patch
|
||||
./openmp/run-lit-directly.patch
|
||||
];
|
||||
};
|
||||
});
|
||||
noExtend = extensible: lib.attrsets.removeAttrs extensible [ "extend" ];
|
||||
|
||||
in { inherit tools libraries; inherit (metadata) release_version; } // (noExtend libraries) // (noExtend tools)
|
@ -1,17 +1,22 @@
|
||||
{ lib, stdenv, llvmPackages, enableLibcxx ? false }:
|
||||
# enableLibcxx will use the c++ headers from clang instead of gcc.
|
||||
# This shouldn't have any effect on platforms that use clang as the default compiler already.
|
||||
{
|
||||
lib,
|
||||
stdenv,
|
||||
clang-unwrapped,
|
||||
clang,
|
||||
libcxxClang,
|
||||
llvm_meta,
|
||||
# enableLibcxx will use the c++ headers from clang instead of gcc.
|
||||
# This shouldn't have any effect on platforms that use clang as the default compiler already.
|
||||
enableLibcxx ? false,
|
||||
}:
|
||||
|
||||
let
|
||||
unwrapped = llvmPackages.clang-unwrapped;
|
||||
|
||||
in stdenv.mkDerivation {
|
||||
inherit unwrapped;
|
||||
stdenv.mkDerivation {
|
||||
unwrapped = clang-unwrapped;
|
||||
|
||||
pname = "clang-tools";
|
||||
version = lib.getVersion unwrapped;
|
||||
version = lib.getVersion clang-unwrapped;
|
||||
dontUnpack = true;
|
||||
clang = if enableLibcxx then llvmPackages.libcxxClang else llvmPackages.clang;
|
||||
clang = if enableLibcxx then libcxxClang else clang;
|
||||
|
||||
installPhase = ''
|
||||
runHook preInstall
|
||||
@ -47,7 +52,7 @@ in stdenv.mkDerivation {
|
||||
runHook postInstall
|
||||
'';
|
||||
|
||||
meta = unwrapped.meta // {
|
||||
meta = llvm_meta // {
|
||||
description = "Standalone command line tools for C++ development";
|
||||
maintainers = with lib.maintainers; [ patryk27 ];
|
||||
};
|
@ -4,7 +4,8 @@
|
||||
, gitRelease ? null
|
||||
, officialRelease ? null
|
||||
, monorepoSrc' ? null
|
||||
}:
|
||||
, version ? null,
|
||||
}@args:
|
||||
|
||||
rec {
|
||||
llvm_meta = {
|
||||
@ -27,11 +28,11 @@ rec {
|
||||
releaseInfo =
|
||||
if gitRelease != null then rec {
|
||||
original = gitRelease;
|
||||
release_version = original.version;
|
||||
release_version = args.version or original.version;
|
||||
version = gitRelease.rev-version;
|
||||
} else rec {
|
||||
original = officialRelease;
|
||||
release_version = original.version;
|
||||
release_version = args.version or original.version;
|
||||
version =
|
||||
if original ? candidate then
|
||||
"${release_version}-${original.candidate}"
|
||||
|
712
pkgs/development/compilers/llvm/common/default.nix
Normal file
712
pkgs/development/compilers/llvm/common/default.nix
Normal file
@ -0,0 +1,712 @@
|
||||
{
|
||||
lowPrio,
|
||||
newScope,
|
||||
pkgs,
|
||||
lib,
|
||||
stdenv,
|
||||
preLibcCrossHeaders,
|
||||
substitute,
|
||||
substituteAll,
|
||||
fetchFromGitHub,
|
||||
fetchpatch,
|
||||
overrideCC,
|
||||
wrapCCWith,
|
||||
wrapBintoolsWith,
|
||||
buildLlvmTools, # tools, but from the previous stage, for cross
|
||||
targetLlvmLibraries, # libraries, but from the next stage, for cross
|
||||
targetLlvm,
|
||||
# This is the default binutils, but with *this* version of LLD rather
|
||||
# than the default LLVM version's, if LLD is the choice. We use these for
|
||||
# the `useLLVM` bootstrapping below.
|
||||
bootBintoolsNoLibc ? if stdenv.targetPlatform.linker == "lld" then null else pkgs.bintoolsNoLibc,
|
||||
bootBintools ? if stdenv.targetPlatform.linker == "lld" then null else pkgs.bintools,
|
||||
darwin,
|
||||
gitRelease ? null,
|
||||
officialRelease ? null,
|
||||
monorepoSrc ? null,
|
||||
version ? null,
|
||||
...
|
||||
}@args:
|
||||
|
||||
assert lib.assertMsg (lib.xor (gitRelease != null) (officialRelease != null)) (
|
||||
"must specify `gitRelease` or `officialRelease`"
|
||||
+ (lib.optionalString (gitRelease != null) " — not both")
|
||||
);
|
||||
|
||||
let
|
||||
monorepoSrc' = monorepoSrc;
|
||||
|
||||
metadata = rec {
|
||||
# Import releaseInfo separately to avoid infinite recursion
|
||||
inherit
|
||||
(import ./common-let.nix {
|
||||
inherit (args)
|
||||
lib
|
||||
gitRelease
|
||||
officialRelease
|
||||
version
|
||||
;
|
||||
})
|
||||
releaseInfo
|
||||
;
|
||||
inherit (releaseInfo) release_version version;
|
||||
inherit
|
||||
(import ./common-let.nix {
|
||||
inherit
|
||||
lib
|
||||
fetchFromGitHub
|
||||
release_version
|
||||
gitRelease
|
||||
officialRelease
|
||||
monorepoSrc'
|
||||
version
|
||||
;
|
||||
})
|
||||
llvm_meta
|
||||
monorepoSrc
|
||||
;
|
||||
src = monorepoSrc;
|
||||
versionDir =
|
||||
(builtins.toString ../.)
|
||||
+ "/${if (gitRelease != null) then "git" else lib.versions.major release_version}";
|
||||
getVersionFile =
|
||||
p:
|
||||
builtins.path {
|
||||
name = builtins.baseNameOf p;
|
||||
path = "${metadata.versionDir}/${p}";
|
||||
};
|
||||
};
|
||||
|
||||
lldbPlugins = lib.makeExtensible (
|
||||
lldbPlugins:
|
||||
let
|
||||
callPackage = newScope (
|
||||
lldbPlugins
|
||||
// {
|
||||
inherit stdenv;
|
||||
inherit (tools) lldb;
|
||||
}
|
||||
);
|
||||
in
|
||||
{
|
||||
llef = callPackage ./lldb-plugins/llef.nix { };
|
||||
}
|
||||
);
|
||||
|
||||
tools = lib.makeExtensible (
|
||||
tools:
|
||||
let
|
||||
callPackage = newScope (
|
||||
tools
|
||||
// args
|
||||
// metadata
|
||||
# Previously monorepoSrc was erroneously not being passed through.
|
||||
// lib.optionalAttrs (lib.versionOlder metadata.release_version "14") { monorepoSrc = null; } # Preserve a bug during #307211, TODO: remove; causes llvm 13 rebuild.
|
||||
);
|
||||
clangVersion =
|
||||
if (lib.versionOlder metadata.release_version "16") then
|
||||
metadata.release_version
|
||||
else
|
||||
lib.versions.major metadata.release_version;
|
||||
mkExtraBuildCommands0 = cc: ''
|
||||
rsrc="$out/resource-root"
|
||||
mkdir "$rsrc"
|
||||
ln -s "${cc.lib}/lib/clang/${clangVersion}/include" "$rsrc"
|
||||
echo "-resource-dir=$rsrc" >> $out/nix-support/cc-cflags
|
||||
'';
|
||||
mkExtraBuildCommands =
|
||||
cc:
|
||||
mkExtraBuildCommands0 cc
|
||||
+ ''
|
||||
ln -s "${targetLlvmLibraries.compiler-rt.out}/lib" "$rsrc/lib"
|
||||
ln -s "${targetLlvmLibraries.compiler-rt.out}/share" "$rsrc/share"
|
||||
'';
|
||||
|
||||
bintoolsNoLibc' = if bootBintoolsNoLibc == null then tools.bintoolsNoLibc else bootBintoolsNoLibc;
|
||||
bintools' = if bootBintools == null then tools.bintools else bootBintools;
|
||||
in
|
||||
{
|
||||
libllvm = callPackage ./llvm {
|
||||
patches =
|
||||
lib.optional (lib.versionOlder metadata.release_version "14") ./llvm/llvm-config-link-static.patch
|
||||
++ [ (metadata.getVersionFile "llvm/gnu-install-dirs.patch") ]
|
||||
++ lib.optionals (lib.versionAtLeast metadata.release_version "15") [
|
||||
# Running the tests involves invoking binaries (like `opt`) that depend on
|
||||
# the LLVM dylibs and reference them by absolute install path (i.e. their
|
||||
# nix store path).
|
||||
#
|
||||
# Because we have not yet run the install phase (we're running these tests
|
||||
# as part of `checkPhase` instead of `installCheckPhase`) these absolute
|
||||
# paths do not exist yet; to work around this we point the loader (`ld` on
|
||||
# unix, `dyld` on macOS) at the `lib` directory which will later become this
|
||||
# package's `lib` output.
|
||||
#
|
||||
# Previously we would just set `LD_LIBRARY_PATH` to include the build `lib`
|
||||
# dir but:
|
||||
# - this doesn't generalize well to other platforms; `lit` doesn't forward
|
||||
# `DYLD_LIBRARY_PATH` (macOS):
|
||||
# + https://github.com/llvm/llvm-project/blob/0d89963df354ee309c15f67dc47c8ab3cb5d0fb2/llvm/utils/lit/lit/TestingConfig.py#L26
|
||||
# - even if `lit` forwarded this env var, we actually cannot set
|
||||
# `DYLD_LIBRARY_PATH` in the child processes `lit` launches because
|
||||
# `DYLD_LIBRARY_PATH` (and `DYLD_FALLBACK_LIBRARY_PATH`) is cleared for
|
||||
# "protected processes" (i.e. the python interpreter that runs `lit`):
|
||||
# https://stackoverflow.com/a/35570229
|
||||
# - other LLVM subprojects deal with this issue by having their `lit`
|
||||
# configuration set these env vars for us; it makes sense to do the same
|
||||
# for LLVM:
|
||||
# + https://github.com/llvm/llvm-project/blob/4c106cfdf7cf7eec861ad3983a3dd9a9e8f3a8ae/clang-tools-extra/test/Unit/lit.cfg.py#L22-L31
|
||||
#
|
||||
# !!! TODO: look into upstreaming this patch
|
||||
(metadata.getVersionFile "llvm/llvm-lit-cfg-add-libs-to-dylib-path.patch")
|
||||
|
||||
# `lit` has a mode where it executes run lines as a shell script which is
|
||||
# constructs; this is problematic for macOS because it means that there's
|
||||
# another process in between `lit` and the binaries being tested. As noted
|
||||
# above, this means that `DYLD_LIBRARY_PATH` is cleared which means that our
|
||||
# tests fail with dyld errors.
|
||||
#
|
||||
# To get around this we patch `lit` to reintroduce `DYLD_LIBRARY_PATH`, when
|
||||
# present in the test configuration.
|
||||
#
|
||||
# It's not clear to me why this isn't an issue for LLVM developers running
|
||||
# on macOS (nothing about this _seems_ nix specific)..
|
||||
(metadata.getVersionFile "llvm/lit-shell-script-runner-set-dyld-library-path.patch")
|
||||
]
|
||||
++
|
||||
lib.optional (lib.versions.major metadata.release_version == "13")
|
||||
# Fix random compiler crashes: https://bugs.llvm.org/show_bug.cgi?id=50611
|
||||
(
|
||||
fetchpatch {
|
||||
url = "https://raw.githubusercontent.com/archlinux/svntogit-packages/4764a4f8c920912a2bfd8b0eea57273acfe0d8a8/trunk/no-strict-aliasing-DwarfCompileUnit.patch";
|
||||
sha256 = "18l6mrvm2vmwm77ckcnbjvh6ybvn72rhrb799d4qzwac4x2ifl7g";
|
||||
stripLen = 1;
|
||||
}
|
||||
)
|
||||
++
|
||||
lib.optional (lib.versionOlder metadata.release_version "16")
|
||||
# Fix musl build.
|
||||
(
|
||||
fetchpatch {
|
||||
url = "https://github.com/llvm/llvm-project/commit/5cd554303ead0f8891eee3cd6d25cb07f5a7bf67.patch";
|
||||
relative = "llvm";
|
||||
hash = "sha256-XPbvNJ45SzjMGlNUgt/IgEvM2dHQpDOe6woUJY+nUYA=";
|
||||
}
|
||||
)
|
||||
++ lib.optionals (lib.versions.major metadata.release_version == "13") [
|
||||
# Backport gcc-13 fixes with missing includes.
|
||||
(fetchpatch {
|
||||
name = "signals-gcc-13.patch";
|
||||
url = "https://github.com/llvm/llvm-project/commit/ff1681ddb303223973653f7f5f3f3435b48a1983.patch";
|
||||
hash = "sha256-CXwYxQezTq5vdmc8Yn88BUAEly6YZ5VEIA6X3y5NNOs=";
|
||||
stripLen = 1;
|
||||
})
|
||||
(fetchpatch {
|
||||
name = "base64-gcc-13.patch";
|
||||
url = "https://github.com/llvm/llvm-project/commit/5e9be93566f39ee6cecd579401e453eccfbe81e5.patch";
|
||||
hash = "sha256-PAwrVrvffPd7tphpwCkYiz+67szPRzRB2TXBvKfzQ7U=";
|
||||
stripLen = 1;
|
||||
})
|
||||
]
|
||||
++ lib.optionals (lib.versions.major metadata.release_version == "14") [
|
||||
# fix RuntimeDyld usage on aarch64-linux (e.g. python312Packages.numba tests)
|
||||
(fetchpatch {
|
||||
url = "https://github.com/llvm/llvm-project/commit/2e1b838a889f9793d4bcd5dbfe10db9796b77143.patch";
|
||||
relative = "llvm";
|
||||
hash = "sha256-Ot45P/iwaR4hkcM3xtLwfryQNgHI6pv6ADjv98tgdZA=";
|
||||
})
|
||||
];
|
||||
pollyPatches =
|
||||
[ (metadata.getVersionFile "llvm/gnu-install-dirs-polly.patch") ]
|
||||
++ lib.optional (lib.versionAtLeast metadata.release_version "15")
|
||||
# Just like the `llvm-lit-cfg` patch, but for `polly`.
|
||||
(metadata.getVersionFile "llvm/polly-lit-cfg-add-libs-to-dylib-path.patch");
|
||||
};
|
||||
|
||||
# `llvm` historically had the binaries. When choosing an output explicitly,
|
||||
# we need to reintroduce `outputSpecified` to get the expected behavior e.g. of lib.get*
|
||||
llvm = tools.libllvm;
|
||||
|
||||
libclang = callPackage ./clang {
|
||||
patches =
|
||||
[
|
||||
(metadata.getVersionFile "clang/purity.patch")
|
||||
# https://reviews.llvm.org/D51899
|
||||
(metadata.getVersionFile "clang/gnu-install-dirs.patch")
|
||||
]
|
||||
++ lib.optional (lib.versions.major metadata.release_version == "13")
|
||||
# Revert of https://reviews.llvm.org/D100879
|
||||
# The malloc alignment assumption is incorrect for jemalloc and causes
|
||||
# mis-compilation in firefox.
|
||||
# See: https://bugzilla.mozilla.org/show_bug.cgi?id=1741454
|
||||
(metadata.getVersionFile "clang/revert-malloc-alignment-assumption.patch")
|
||||
++ [
|
||||
./clang/add-nostdlibinc-flag.patch
|
||||
(substituteAll {
|
||||
src =
|
||||
if (lib.versionOlder metadata.release_version "16") then
|
||||
./clang/clang-11-15-LLVMgold-path.patch
|
||||
else
|
||||
./clang/clang-at-least-16-LLVMgold-path.patch;
|
||||
libllvmLibdir = "${tools.libllvm.lib}/lib";
|
||||
})
|
||||
];
|
||||
};
|
||||
|
||||
clang-unwrapped = tools.libclang;
|
||||
|
||||
llvm-manpages = lowPrio (
|
||||
tools.libllvm.override {
|
||||
enableManpages = true;
|
||||
python3 = pkgs.python3; # don't use python-boot
|
||||
}
|
||||
);
|
||||
|
||||
clang-manpages = lowPrio (
|
||||
tools.libclang.override {
|
||||
enableManpages = true;
|
||||
python3 = pkgs.python3; # don't use python-boot
|
||||
}
|
||||
);
|
||||
|
||||
# Wrapper for standalone command line utilities
|
||||
clang-tools = callPackage ./clang-tools { };
|
||||
|
||||
# pick clang appropriate for package set we are targeting
|
||||
clang =
|
||||
if stdenv.targetPlatform.libc == null then
|
||||
tools.clangNoLibc
|
||||
else if stdenv.targetPlatform.useLLVM or false then
|
||||
tools.clangUseLLVM
|
||||
else if (pkgs.targetPackages.stdenv or args.stdenv).cc.isGNU then
|
||||
tools.libstdcxxClang
|
||||
else
|
||||
tools.libcxxClang;
|
||||
|
||||
libstdcxxClang = wrapCCWith rec {
|
||||
cc = tools.clang-unwrapped;
|
||||
# libstdcxx is taken from gcc in an ad-hoc way in cc-wrapper.
|
||||
libcxx = null;
|
||||
extraPackages = [ targetLlvmLibraries.compiler-rt ];
|
||||
extraBuildCommands = mkExtraBuildCommands cc;
|
||||
};
|
||||
|
||||
libcxxClang = wrapCCWith rec {
|
||||
cc = tools.clang-unwrapped;
|
||||
libcxx = targetLlvmLibraries.libcxx;
|
||||
extraPackages = [ targetLlvmLibraries.compiler-rt ];
|
||||
extraBuildCommands = mkExtraBuildCommands cc;
|
||||
};
|
||||
|
||||
lld = callPackage ./lld {
|
||||
patches =
|
||||
[ (metadata.getVersionFile "lld/gnu-install-dirs.patch") ]
|
||||
++ lib.optional (lib.versions.major metadata.release_version == "14") (
|
||||
metadata.getVersionFile "lld/fix-root-src-dir.patch"
|
||||
)
|
||||
++ lib.optional (
|
||||
lib.versionAtLeast metadata.release_version "16" && lib.versionOlder metadata.release_version "18"
|
||||
) (metadata.getVersionFile "lld/add-table-base.patch");
|
||||
};
|
||||
|
||||
lldb = callPackage ./lldb.nix (
|
||||
{
|
||||
patches =
|
||||
let
|
||||
resourceDirPatch = callPackage (
|
||||
{ substituteAll, libclang }:
|
||||
(substituteAll {
|
||||
src = metadata.getVersionFile "lldb/resource-dir.patch";
|
||||
clangLibDir = "${libclang.lib}/lib";
|
||||
}).overrideAttrs
|
||||
(_: _: { name = "resource-dir.patch"; })
|
||||
) { };
|
||||
in
|
||||
lib.optional (lib.versionOlder metadata.release_version "16")
|
||||
# FIXME: do we need this after 15?
|
||||
(metadata.getVersionFile "lldb/procfs.patch")
|
||||
++ lib.optional (lib.versionOlder metadata.release_version "17") resourceDirPatch
|
||||
++ lib.optional (lib.versionOlder metadata.release_version "14") (
|
||||
metadata.getVersionFile "lldb/gnu-install-dirs.patch"
|
||||
)
|
||||
++ lib.optional (lib.versionAtLeast metadata.release_version "14") ./lldb/gnu-install-dirs.patch
|
||||
# This is a stopgap solution if/until the macOS SDK used for x86_64 is
|
||||
# updated.
|
||||
#
|
||||
# The older 10.12 SDK used on x86_64 as of this writing has a `mach/machine.h`
|
||||
# header that does not define `CPU_SUBTYPE_ARM64E` so we replace the one use
|
||||
# of this preprocessor symbol in `lldb` with its expansion.
|
||||
#
|
||||
# See here for some context:
|
||||
# https://github.com/NixOS/nixpkgs/pull/194634#issuecomment-1272129132
|
||||
++ lib.optional (
|
||||
stdenv.targetPlatform.isDarwin
|
||||
&& !stdenv.targetPlatform.isAarch64
|
||||
&& lib.versionOlder darwin.apple_sdk.sdk.version "11.0"
|
||||
) (metadata.getVersionFile "lldb/cpu_subtype_arm64e_replacement.patch");
|
||||
}
|
||||
// lib.optionalAttrs (lib.versions.major metadata.release_version == "16") {
|
||||
src = callPackage (
|
||||
{ runCommand }:
|
||||
runCommand "lldb-src-${metadata.version}" { } ''
|
||||
mkdir -p "$out"
|
||||
cp -r ${monorepoSrc}/cmake "$out"
|
||||
cp -r ${monorepoSrc}/lldb "$out"
|
||||
''
|
||||
) { };
|
||||
}
|
||||
);
|
||||
|
||||
# Below, is the LLVM bootstrapping logic. It handles building a
|
||||
# fully LLVM toolchain from scratch. No GCC toolchain should be
|
||||
# pulled in. As a consequence, it is very quick to build different
|
||||
# targets provided by LLVM and we can also build for what GCC
|
||||
# doesn’t support like LLVM. Probably we should move to some other
|
||||
# file.
|
||||
|
||||
bintools-unwrapped = callPackage ./bintools.nix { };
|
||||
|
||||
bintoolsNoLibc = wrapBintoolsWith {
|
||||
bintools = tools.bintools-unwrapped;
|
||||
libc = preLibcCrossHeaders;
|
||||
};
|
||||
|
||||
bintools = wrapBintoolsWith { bintools = tools.bintools-unwrapped; };
|
||||
|
||||
clangUseLLVM = wrapCCWith (
|
||||
rec {
|
||||
cc = tools.clang-unwrapped;
|
||||
libcxx = targetLlvmLibraries.libcxx;
|
||||
bintools = bintools';
|
||||
extraPackages = [
|
||||
targetLlvmLibraries.compiler-rt
|
||||
] ++ lib.optionals (!stdenv.targetPlatform.isWasm) [ targetLlvmLibraries.libunwind ];
|
||||
extraBuildCommands =
|
||||
lib.optionalString (lib.versions.major metadata.release_version == "13") (
|
||||
''
|
||||
echo "-rtlib=compiler-rt -Wno-unused-command-line-argument" >> $out/nix-support/cc-cflags
|
||||
echo "-B${targetLlvmLibraries.compiler-rt}/lib" >> $out/nix-support/cc-cflags
|
||||
''
|
||||
+ lib.optionalString (!stdenv.targetPlatform.isWasm) ''
|
||||
echo "--unwindlib=libunwind" >> $out/nix-support/cc-cflags
|
||||
echo "-L${targetLlvmLibraries.libunwind}/lib" >> $out/nix-support/cc-ldflags
|
||||
''
|
||||
+ lib.optionalString (!stdenv.targetPlatform.isWasm && stdenv.targetPlatform.useLLVM or false) ''
|
||||
echo "-lunwind" >> $out/nix-support/cc-ldflags
|
||||
''
|
||||
+ lib.optionalString stdenv.targetPlatform.isWasm ''
|
||||
echo "-fno-exceptions" >> $out/nix-support/cc-cflags
|
||||
''
|
||||
)
|
||||
+ mkExtraBuildCommands cc;
|
||||
}
|
||||
// lib.optionalAttrs (lib.versionAtLeast metadata.release_version "14") {
|
||||
nixSupport.cc-cflags =
|
||||
[
|
||||
"-rtlib=compiler-rt"
|
||||
"-Wno-unused-command-line-argument"
|
||||
"-B${targetLlvmLibraries.compiler-rt}/lib"
|
||||
]
|
||||
++ lib.optional (!stdenv.targetPlatform.isWasm) "--unwindlib=libunwind"
|
||||
++ lib.optional (!stdenv.targetPlatform.isWasm && stdenv.targetPlatform.useLLVM or false) "-lunwind"
|
||||
++ lib.optional stdenv.targetPlatform.isWasm "-fno-exceptions";
|
||||
nixSupport.cc-ldflags = lib.optionals (!stdenv.targetPlatform.isWasm) [
|
||||
"-L${targetLlvmLibraries.libunwind}/lib"
|
||||
];
|
||||
}
|
||||
);
|
||||
|
||||
clangNoLibcxx = wrapCCWith (
|
||||
rec {
|
||||
cc = tools.clang-unwrapped;
|
||||
libcxx = null;
|
||||
bintools = bintools';
|
||||
extraPackages = [ targetLlvmLibraries.compiler-rt ];
|
||||
extraBuildCommands =
|
||||
lib.optionalString (lib.versions.major metadata.release_version == "13") ''
|
||||
echo "-rtlib=compiler-rt" >> $out/nix-support/cc-cflags
|
||||
echo "-B${targetLlvmLibraries.compiler-rt}/lib" >> $out/nix-support/cc-cflags
|
||||
echo "-nostdlib++" >> $out/nix-support/cc-cflags
|
||||
''
|
||||
+ mkExtraBuildCommands cc;
|
||||
}
|
||||
// lib.optionalAttrs (lib.versionAtLeast metadata.release_version "14") {
|
||||
nixSupport.cc-cflags =
|
||||
[
|
||||
"-rtlib=compiler-rt"
|
||||
"-B${targetLlvmLibraries.compiler-rt}/lib"
|
||||
"-nostdlib++"
|
||||
]
|
||||
++ lib.optional (
|
||||
lib.versionAtLeast metadata.release_version "15" && stdenv.targetPlatform.isWasm
|
||||
) "-fno-exceptions";
|
||||
}
|
||||
);
|
||||
|
||||
clangNoLibc = wrapCCWith (
|
||||
rec {
|
||||
cc = tools.clang-unwrapped;
|
||||
libcxx = null;
|
||||
bintools = bintoolsNoLibc';
|
||||
extraPackages = [ targetLlvmLibraries.compiler-rt ];
|
||||
extraBuildCommands =
|
||||
lib.optionalString (lib.versions.major metadata.release_version == "13") ''
|
||||
echo "-rtlib=compiler-rt" >> $out/nix-support/cc-cflags
|
||||
echo "-B${targetLlvmLibraries.compiler-rt}/lib" >> $out/nix-support/cc-cflags
|
||||
''
|
||||
+ mkExtraBuildCommands cc;
|
||||
}
|
||||
// lib.optionalAttrs (lib.versionAtLeast metadata.release_version "14") {
|
||||
nixSupport.cc-cflags =
|
||||
[
|
||||
"-rtlib=compiler-rt"
|
||||
"-B${targetLlvmLibraries.compiler-rt}/lib"
|
||||
]
|
||||
++ lib.optional (
|
||||
lib.versionAtLeast metadata.release_version "15" && stdenv.targetPlatform.isWasm
|
||||
) "-fno-exceptions";
|
||||
}
|
||||
);
|
||||
|
||||
clangNoCompilerRt = wrapCCWith (
|
||||
rec {
|
||||
cc = tools.clang-unwrapped;
|
||||
libcxx = null;
|
||||
bintools = bintoolsNoLibc';
|
||||
extraPackages = [ ];
|
||||
extraBuildCommands =
|
||||
lib.optionalString (lib.versions.major metadata.release_version == "13") ''
|
||||
echo "-nostartfiles" >> $out/nix-support/cc-cflags
|
||||
''
|
||||
+ mkExtraBuildCommands0 cc;
|
||||
}
|
||||
// lib.optionalAttrs (lib.versionAtLeast metadata.release_version "14") {
|
||||
nixSupport.cc-cflags =
|
||||
[ "-nostartfiles" ]
|
||||
++ lib.optional (
|
||||
lib.versionAtLeast metadata.release_version "15" && stdenv.targetPlatform.isWasm
|
||||
) "-fno-exceptions";
|
||||
}
|
||||
);
|
||||
|
||||
clangNoCompilerRtWithLibc =
|
||||
wrapCCWith rec {
|
||||
cc = tools.clang-unwrapped;
|
||||
libcxx = null;
|
||||
bintools = bintools';
|
||||
extraPackages = [ ];
|
||||
extraBuildCommands = mkExtraBuildCommands0 cc;
|
||||
}
|
||||
// lib.optionalAttrs (
|
||||
lib.versionAtLeast metadata.release_version "15" && stdenv.targetPlatform.isWasm
|
||||
) { nixSupport.cc-cflags = [ "-fno-exceptions" ]; };
|
||||
}
|
||||
// lib.optionalAttrs (lib.versionAtLeast metadata.release_version "15") {
|
||||
# TODO: pre-15: lldb/docs/index.rst:155:toctree contains reference to nonexisting document 'design/structureddataplugins'
|
||||
lldb-manpages = lowPrio (
|
||||
tools.lldb.override {
|
||||
enableManpages = true;
|
||||
python3 = pkgs.python3; # don't use python-boot
|
||||
}
|
||||
);
|
||||
}
|
||||
// lib.optionalAttrs (lib.versionAtLeast metadata.release_version "16") {
|
||||
mlir = callPackage ./mlir { };
|
||||
libclc = callPackage ./libclc.nix { };
|
||||
}
|
||||
);
|
||||
|
||||
libraries = lib.makeExtensible (
|
||||
libraries:
|
||||
let
|
||||
callPackage = newScope (
|
||||
libraries
|
||||
// buildLlvmTools
|
||||
// args
|
||||
// metadata
|
||||
# Previously monorepoSrc was erroneously not being passed through.
|
||||
// lib.optionalAttrs (lib.versionOlder metadata.release_version "14") { monorepoSrc = null; } # Preserve a bug during #307211, TODO: remove; causes llvm 13 rebuild.
|
||||
);
|
||||
|
||||
compiler-rtPatches =
|
||||
lib.optional (lib.versionOlder metadata.release_version "15") (
|
||||
metadata.getVersionFile "compiler-rt/codesign.patch"
|
||||
) # Revert compiler-rt commit that makes codesign mandatory
|
||||
++ [
|
||||
(metadata.getVersionFile "compiler-rt/X86-support-extension.patch") # Add support for i486 i586 i686 by reusing i386 config
|
||||
]
|
||||
++ lib.optional (
|
||||
lib.versionAtLeast metadata.release_version "14" && lib.versionOlder metadata.release_version "18"
|
||||
) (metadata.getVersionFile "compiler-rt/gnu-install-dirs.patch")
|
||||
++ [
|
||||
# ld-wrapper dislikes `-rpath-link //nix/store`, so we normalize away the
|
||||
# extra `/`.
|
||||
(metadata.getVersionFile "compiler-rt/normalize-var.patch")
|
||||
]
|
||||
++
|
||||
lib.optional (lib.versionOlder metadata.release_version "18")
|
||||
# Prevent a compilation error on darwin
|
||||
(metadata.getVersionFile "compiler-rt/darwin-targetconditionals.patch")
|
||||
++
|
||||
lib.optional (lib.versionAtLeast metadata.release_version "15")
|
||||
# See: https://github.com/NixOS/nixpkgs/pull/186575
|
||||
./compiler-rt/darwin-plistbuddy-workaround.patch
|
||||
++
|
||||
lib.optional (lib.versions.major metadata.release_version == "15")
|
||||
# See: https://github.com/NixOS/nixpkgs/pull/194634#discussion_r999829893
|
||||
./compiler-rt/armv7l-15.patch
|
||||
++ lib.optionals (lib.versionOlder metadata.release_version "15") [
|
||||
./compiler-rt/darwin-plistbuddy-workaround.patch
|
||||
(metadata.getVersionFile "compiler-rt/armv7l.patch")
|
||||
# Fix build on armv6l
|
||||
./compiler-rt/armv6-mcr-dmb.patch
|
||||
./compiler-rt/armv6-sync-ops-no-thumb.patch
|
||||
./compiler-rt/armv6-no-ldrexd-strexd.patch
|
||||
./compiler-rt/armv6-scudo-no-yield.patch
|
||||
./compiler-rt/armv6-scudo-libatomic.patch
|
||||
];
|
||||
in
|
||||
{
|
||||
compiler-rt-libc = callPackage ./compiler-rt {
|
||||
patches = compiler-rtPatches;
|
||||
stdenv =
|
||||
if
|
||||
stdenv.hostPlatform.useLLVM or false
|
||||
|| (
|
||||
lib.versionAtLeast metadata.release_version "16"
|
||||
&& stdenv.hostPlatform.isDarwin
|
||||
&& stdenv.hostPlatform.isStatic
|
||||
)
|
||||
then
|
||||
overrideCC stdenv buildLlvmTools.clangNoCompilerRtWithLibc
|
||||
else
|
||||
args.stdenv;
|
||||
};
|
||||
|
||||
compiler-rt-no-libc = callPackage ./compiler-rt {
|
||||
patches = compiler-rtPatches;
|
||||
stdenv =
|
||||
if stdenv.hostPlatform.useLLVM or false then
|
||||
overrideCC stdenv buildLlvmTools.clangNoCompilerRt
|
||||
else
|
||||
stdenv;
|
||||
};
|
||||
|
||||
# N.B. condition is safe because without useLLVM both are the same.
|
||||
compiler-rt =
|
||||
if
|
||||
stdenv.hostPlatform.isAndroid
|
||||
|| (lib.versionAtLeast metadata.release_version "16" && stdenv.hostPlatform.isDarwin)
|
||||
then
|
||||
libraries.compiler-rt-libc
|
||||
else
|
||||
libraries.compiler-rt-no-libc;
|
||||
|
||||
stdenv = overrideCC stdenv buildLlvmTools.clang;
|
||||
|
||||
libcxxStdenv = overrideCC stdenv buildLlvmTools.libcxxClang;
|
||||
|
||||
libcxx = callPackage ./libcxx (
|
||||
{
|
||||
patches =
|
||||
lib.optionals (lib.versionOlder metadata.release_version "16") (
|
||||
lib.optional (lib.versions.major metadata.release_version == "15")
|
||||
# See:
|
||||
# - https://reviews.llvm.org/D133566
|
||||
# - https://github.com/NixOS/nixpkgs/issues/214524#issuecomment-1429146432
|
||||
# !!! Drop in LLVM 16+
|
||||
(
|
||||
fetchpatch {
|
||||
url = "https://github.com/llvm/llvm-project/commit/57c7bb3ec89565c68f858d316504668f9d214d59.patch";
|
||||
hash = "sha256-B07vHmSjy5BhhkGSj3e1E0XmMv5/9+mvC/k70Z29VwY=";
|
||||
}
|
||||
)
|
||||
++ [
|
||||
(substitute {
|
||||
src = ./libcxxabi/wasm.patch;
|
||||
replacements = [
|
||||
"--replace-fail"
|
||||
"/cmake/"
|
||||
"/llvm/cmake/"
|
||||
];
|
||||
})
|
||||
]
|
||||
++ lib.optional stdenv.hostPlatform.isMusl (substitute {
|
||||
src = ./libcxx/libcxx-0001-musl-hacks.patch;
|
||||
replacements = [
|
||||
"--replace-fail"
|
||||
"/include/"
|
||||
"/libcxx/include/"
|
||||
];
|
||||
})
|
||||
)
|
||||
++
|
||||
lib.optional
|
||||
(
|
||||
lib.versions.major metadata.release_version == "17"
|
||||
&& stdenv.isDarwin
|
||||
&& lib.versionOlder stdenv.hostPlatform.darwinMinVersion "10.13"
|
||||
)
|
||||
# https://github.com/llvm/llvm-project/issues/64226
|
||||
(
|
||||
fetchpatch {
|
||||
name = "0042-mbstate_t-not-defined.patch";
|
||||
url = "https://github.com/macports/macports-ports/raw/acd8acb171f1658596ed1cf25da48d5b932e2d19/lang/llvm-17/files/0042-mbstate_t-not-defined.patch";
|
||||
hash = "sha256-jo+DYA6zuSv9OH3A0bYwY5TlkWprup4OKQ7rfK1WHBI=";
|
||||
}
|
||||
)
|
||||
++
|
||||
lib.optional
|
||||
(
|
||||
lib.versionAtLeast metadata.release_version "18"
|
||||
&& stdenv.isDarwin
|
||||
&& lib.versionOlder stdenv.hostPlatform.darwinMinVersion "10.13"
|
||||
)
|
||||
# https://github.com/llvm/llvm-project/issues/64226
|
||||
(metadata.getVersionFile "libcxx/0001-darwin-10.12-mbstate_t-fix.patch");
|
||||
stdenv = overrideCC stdenv buildLlvmTools.clangNoLibcxx;
|
||||
}
|
||||
// lib.optionalAttrs (lib.versionOlder metadata.release_version "14") {
|
||||
# TODO: remove this, causes LLVM 13 packages rebuild.
|
||||
inherit (metadata) monorepoSrc; # Preserve bug during #307211 refactor.
|
||||
}
|
||||
);
|
||||
|
||||
libunwind = callPackage ./libunwind {
|
||||
patches = lib.optional (lib.versionOlder metadata.release_version "17") (
|
||||
metadata.getVersionFile "libunwind/gnu-install-dirs.patch"
|
||||
);
|
||||
stdenv = overrideCC stdenv buildLlvmTools.clangNoLibcxx;
|
||||
};
|
||||
|
||||
openmp = callPackage ./openmp {
|
||||
patches =
|
||||
lib.optional (lib.versionAtLeast metadata.release_version "15") (
|
||||
metadata.getVersionFile "openmp/fix-find-tool.patch"
|
||||
)
|
||||
++ lib.optional (
|
||||
lib.versionAtLeast metadata.release_version "14" && lib.versionOlder metadata.release_version "18"
|
||||
) (metadata.getVersionFile "openmp/gnu-install-dirs.patch")
|
||||
++ lib.optional (lib.versionAtLeast metadata.release_version "14") (
|
||||
metadata.getVersionFile "openmp/run-lit-directly.patch"
|
||||
)
|
||||
++
|
||||
lib.optional (lib.versionOlder metadata.release_version "14")
|
||||
# Fix cross.
|
||||
(
|
||||
fetchpatch {
|
||||
url = "https://github.com/llvm/llvm-project/commit/5e2358c781b85a18d1463fd924d2741d4ae5e42e.patch";
|
||||
hash = "sha256-UxIlAifXnexF/MaraPW0Ut6q+sf3e7y1fMdEv1q103A=";
|
||||
}
|
||||
);
|
||||
};
|
||||
}
|
||||
);
|
||||
|
||||
noExtend = extensible: lib.attrsets.removeAttrs extensible [ "extend" ];
|
||||
in
|
||||
{
|
||||
inherit tools libraries lldbPlugins;
|
||||
inherit (metadata) release_version;
|
||||
}
|
||||
// (noExtend libraries)
|
||||
// (noExtend tools)
|
86
pkgs/development/compilers/llvm/default.nix
Normal file
86
pkgs/development/compilers/llvm/default.nix
Normal file
@ -0,0 +1,86 @@
|
||||
{
|
||||
lib,
|
||||
callPackage,
|
||||
stdenvAdapters,
|
||||
buildPackages,
|
||||
targetPackages,
|
||||
stdenv,
|
||||
gcc12Stdenv,
|
||||
pkgs,
|
||||
# This is the default binutils, but with *this* version of LLD rather
|
||||
# than the default LLVM version's, if LLD is the choice. We use these for
|
||||
# the `useLLVM` bootstrapping below.
|
||||
bootBintoolsNoLibc ? if stdenv.targetPlatform.linker == "lld" then null else pkgs.bintoolsNoLibc,
|
||||
bootBintools ? if stdenv.targetPlatform.linker == "lld" then null else pkgs.bintools,
|
||||
llvmVersions ? { },
|
||||
}:
|
||||
let
|
||||
versions = {
|
||||
"13.0.1".officialRelease.sha256 = "06dv6h5dmvzdxbif2s8njki6h32796v368dyb5945x8gjj72xh7k";
|
||||
"14.0.6".officialRelease.sha256 = "sha256-vffu4HilvYwtzwgq+NlS26m65DGbp6OSSne2aje1yJE=";
|
||||
"15.0.7".officialRelease.sha256 = "sha256-wjuZQyXQ/jsmvy6y1aksCcEDXGBjuhpgngF3XQJ/T4s=";
|
||||
"16.0.6".officialRelease.sha256 = "sha256-fspqSReX+VD+Nl/Cfq+tDcdPtnQPV1IRopNDfd5VtUs=";
|
||||
"17.0.6".officialRelease.sha256 = "sha256-8MEDLLhocshmxoEBRSKlJ/GzJ8nfuzQ8qn0X/vLA+ag=";
|
||||
"18.1.8".officialRelease.sha256 = "sha256-iiZKMRo/WxJaBXct9GdAcAT3cz9d9pnAcO1mmR6oPNE=";
|
||||
"19.0.0-git".gitRelease = {
|
||||
rev = "cebf77fb936a7270c7e3fa5c4a7e76216321d385";
|
||||
rev-version = "19.0.0-unstable-2024-04-07";
|
||||
sha256 = "sha256-616tscgsiFgHQcXW4KzK5srrudYizQFnJVM6K0qRf+I=";
|
||||
};
|
||||
} // llvmVersions;
|
||||
|
||||
mkPackage =
|
||||
{
|
||||
name ? null,
|
||||
officialRelease ? null,
|
||||
gitRelease ? null,
|
||||
monorepoSrc ? null,
|
||||
version ? null,
|
||||
}@args:
|
||||
let
|
||||
args' = {
|
||||
name = null;
|
||||
officialRelease = null;
|
||||
gitRelease = null;
|
||||
monorepoSrc = null;
|
||||
version = null;
|
||||
} // args;
|
||||
inherit
|
||||
(import ./common/common-let.nix {
|
||||
inherit lib;
|
||||
inherit (args') gitRelease officialRelease version;
|
||||
})
|
||||
releaseInfo
|
||||
;
|
||||
inherit (releaseInfo) release_version;
|
||||
attrName =
|
||||
args.name or (if (gitRelease != null) then "git" else lib.versions.major release_version);
|
||||
in
|
||||
callPackage ./common {
|
||||
inherit (stdenvAdapters) overrideCC;
|
||||
buildLlvmTools = buildPackages."llvmPackages_${attrName}".tools;
|
||||
targetLlvmLibraries =
|
||||
targetPackages."llvmPackages_${attrName}".libraries or llvmPackages."${attrName}".libraries;
|
||||
targetLlvm = targetPackages."llvmPackages_${attrName}".llvm or llvmPackages."${attrName}".llvm;
|
||||
stdenv =
|
||||
if (lib.versions.major release_version == "13" && stdenv.cc.cc.isGNU or false) then
|
||||
gcc12Stdenv
|
||||
else
|
||||
stdenv; # does not build with gcc13
|
||||
inherit bootBintoolsNoLibc bootBintools;
|
||||
inherit (args')
|
||||
officialRelease
|
||||
gitRelease
|
||||
monorepoSrc
|
||||
version
|
||||
;
|
||||
};
|
||||
|
||||
llvmPackages = lib.mapAttrs' (
|
||||
version: args:
|
||||
lib.nameValuePair (if (args ? gitRelease) then "git" else lib.versions.major version) (
|
||||
mkPackage (args // { inherit version; })
|
||||
)
|
||||
) versions;
|
||||
in
|
||||
llvmPackages
|
@ -1,416 +0,0 @@
|
||||
{ lowPrio, newScope, pkgs, lib, stdenv
|
||||
, preLibcCrossHeaders
|
||||
, substitute, substituteAll, fetchFromGitHub, fetchpatch
|
||||
, overrideCC, wrapCCWith, wrapBintoolsWith
|
||||
, buildLlvmTools # tools, but from the previous stage, for cross
|
||||
, targetLlvmLibraries # libraries, but from the next stage, for cross
|
||||
, targetLlvm
|
||||
# This is the default binutils, but with *this* version of LLD rather
|
||||
# than the default LLVM verion's, if LLD is the choice. We use these for
|
||||
# the `useLLVM` bootstrapping below.
|
||||
, bootBintoolsNoLibc ?
|
||||
if stdenv.targetPlatform.linker == "lld"
|
||||
then null
|
||||
else pkgs.bintoolsNoLibc
|
||||
, bootBintools ?
|
||||
if stdenv.targetPlatform.linker == "lld"
|
||||
then null
|
||||
else pkgs.bintools
|
||||
, darwin
|
||||
# LLVM release information; specify one of these but not both:
|
||||
, gitRelease ? {
|
||||
version = "19.0.0-git";
|
||||
rev = "cebf77fb936a7270c7e3fa5c4a7e76216321d385";
|
||||
rev-version = "19.0.0-unstable-2024-04-07";
|
||||
sha256 = "sha256-616tscgsiFgHQcXW4KzK5srrudYizQFnJVM6K0qRf+I=";
|
||||
}
|
||||
# i.e.:
|
||||
# {
|
||||
# version = /* i.e. "15.0.0" */;
|
||||
# rev = /* commit SHA */;
|
||||
# rev-version = /* human readable version; i.e. "15.0.0-unstable-2022-07-26" */;
|
||||
# sha256 = /* checksum for this release, can omit if specifying your own `monorepoSrc` */;
|
||||
# }
|
||||
, officialRelease ? null
|
||||
# i.e.:
|
||||
# {
|
||||
# version = /* i.e. "15.0.0" */;
|
||||
# candidate = /* optional; if specified, should be: "rcN" */
|
||||
# sha256 = /* checksum for this release, can omit if specifying your own `monorepoSrc` */;
|
||||
# }
|
||||
# By default, we'll try to fetch a release from `github:llvm/llvm-project`
|
||||
# corresponding to the `gitRelease` or `officialRelease` specified.
|
||||
#
|
||||
# You can provide your own LLVM source by specifying this arg but then it's up
|
||||
# to you to make sure that the LLVM repo given matches the release configuration
|
||||
# specified.
|
||||
, monorepoSrc ? null
|
||||
# Allows passthrough to packages via newScope. This makes it possible to
|
||||
# do `(llvmPackages.override { <someLlvmDependency> = bar; }).clang` and get
|
||||
# an llvmPackages whose packages are overridden in an internally consistent way.
|
||||
, ...
|
||||
}@args:
|
||||
|
||||
assert
|
||||
lib.assertMsg
|
||||
(lib.xor
|
||||
(gitRelease != null)
|
||||
(officialRelease != null))
|
||||
("must specify `gitRelease` or `officialRelease`" +
|
||||
(lib.optionalString (gitRelease != null) " — not both"));
|
||||
let
|
||||
monorepoSrc' = monorepoSrc;
|
||||
in let
|
||||
|
||||
metadata = rec {
|
||||
# Import releaseInfo separately to avoid infinite recursion
|
||||
inherit (import ../common/common-let.nix { inherit lib gitRelease officialRelease; }) releaseInfo;
|
||||
inherit (releaseInfo) release_version version;
|
||||
inherit (import ../common/common-let.nix { inherit lib fetchFromGitHub gitRelease release_version officialRelease monorepoSrc'; }) llvm_meta monorepoSrc;
|
||||
};
|
||||
|
||||
tools = lib.makeExtensible (tools: let
|
||||
callPackage = newScope (tools // args // metadata);
|
||||
major = lib.versions.major metadata.release_version;
|
||||
mkExtraBuildCommands0 = cc: ''
|
||||
rsrc="$out/resource-root"
|
||||
mkdir "$rsrc"
|
||||
ln -s "${cc.lib}/lib/clang/${major}/include" "$rsrc"
|
||||
echo "-resource-dir=$rsrc" >> $out/nix-support/cc-cflags
|
||||
'';
|
||||
mkExtraBuildCommands = cc: mkExtraBuildCommands0 cc + ''
|
||||
ln -s "${targetLlvmLibraries.compiler-rt.out}/lib" "$rsrc/lib"
|
||||
ln -s "${targetLlvmLibraries.compiler-rt.out}/share" "$rsrc/share"
|
||||
'';
|
||||
|
||||
bintoolsNoLibc' =
|
||||
if bootBintoolsNoLibc == null
|
||||
then tools.bintoolsNoLibc
|
||||
else bootBintoolsNoLibc;
|
||||
bintools' =
|
||||
if bootBintools == null
|
||||
then tools.bintools
|
||||
else bootBintools;
|
||||
|
||||
in {
|
||||
|
||||
libllvm = callPackage ../common/llvm {
|
||||
patches = [
|
||||
./llvm/gnu-install-dirs.patch
|
||||
|
||||
# Running the tests involves invoking binaries (like `opt`) that depend on
|
||||
# the LLVM dylibs and reference them by absolute install path (i.e. their
|
||||
# nix store path).
|
||||
#
|
||||
# Because we have not yet run the install phase (we're running these tests
|
||||
# as part of `checkPhase` instead of `installCheckPhase`) these absolute
|
||||
# paths do not exist yet; to work around this we point the loader (`ld` on
|
||||
# unix, `dyld` on macOS) at the `lib` directory which will later become this
|
||||
# package's `lib` output.
|
||||
#
|
||||
# Previously we would just set `LD_LIBRARY_PATH` to include the build `lib`
|
||||
# dir but:
|
||||
# - this doesn't generalize well to other platforms; `lit` doesn't forward
|
||||
# `DYLD_LIBRARY_PATH` (macOS):
|
||||
# + https://github.com/llvm/llvm-project/blob/0d89963df354ee309c15f67dc47c8ab3cb5d0fb2/llvm/utils/lit/lit/TestingConfig.py#L26
|
||||
# - even if `lit` forwarded this env var, we actually cannot set
|
||||
# `DYLD_LIBRARY_PATH` in the child processes `lit` launches because
|
||||
# `DYLD_LIBRARY_PATH` (and `DYLD_FALLBACK_LIBRARY_PATH`) is cleared for
|
||||
# "protected processes" (i.e. the python interpreter that runs `lit`):
|
||||
# https://stackoverflow.com/a/35570229
|
||||
# - other LLVM subprojects deal with this issue by having their `lit`
|
||||
# configuration set these env vars for us; it makes sense to do the same
|
||||
# for LLVM:
|
||||
# + https://github.com/llvm/llvm-project/blob/4c106cfdf7cf7eec861ad3983a3dd9a9e8f3a8ae/clang-tools-extra/test/Unit/lit.cfg.py#L22-L31
|
||||
#
|
||||
# !!! TODO: look into upstreaming this patch
|
||||
./llvm/llvm-lit-cfg-add-libs-to-dylib-path.patch
|
||||
|
||||
# `lit` has a mode where it executes run lines as a shell script which is
|
||||
# constructs; this is problematic for macOS because it means that there's
|
||||
# another process in between `lit` and the binaries being tested. As noted
|
||||
# above, this means that `DYLD_LIBRARY_PATH` is cleared which means that our
|
||||
# tests fail with dyld errors.
|
||||
#
|
||||
# To get around this we patch `lit` to reintroduce `DYLD_LIBRARY_PATH`, when
|
||||
# present in the test configuration.
|
||||
#
|
||||
# It's not clear to me why this isn't an issue for LLVM developers running
|
||||
# on macOS (nothing about this _seems_ nix specific)..
|
||||
./llvm/lit-shell-script-runner-set-dyld-library-path.patch
|
||||
];
|
||||
pollyPatches = [
|
||||
./llvm/gnu-install-dirs-polly.patch
|
||||
|
||||
# Just like the `llvm-lit-cfg` patch, but for `polly`.
|
||||
./llvm/polly-lit-cfg-add-libs-to-dylib-path.patch
|
||||
];
|
||||
};
|
||||
|
||||
# `llvm` historically had the binaries. When choosing an output explicitly,
|
||||
# we need to reintroduce `outputSpecified` to get the expected behavior e.g. of lib.get*
|
||||
llvm = tools.libllvm;
|
||||
|
||||
libclang = callPackage ../common/clang {
|
||||
patches = [
|
||||
./clang/purity.patch
|
||||
# https://reviews.llvm.org/D51899
|
||||
./clang/gnu-install-dirs.patch
|
||||
../common/clang/add-nostdlibinc-flag.patch
|
||||
(substituteAll {
|
||||
src = ../common/clang/clang-at-least-16-LLVMgold-path.patch;
|
||||
libllvmLibdir = "${tools.libllvm.lib}/lib";
|
||||
})
|
||||
];
|
||||
};
|
||||
|
||||
clang-unwrapped = tools.libclang;
|
||||
|
||||
llvm-manpages = lowPrio (tools.libllvm.override {
|
||||
enableManpages = true;
|
||||
python3 = pkgs.python3; # don't use python-boot
|
||||
});
|
||||
|
||||
clang-manpages = lowPrio (tools.libclang.override {
|
||||
enableManpages = true;
|
||||
python3 = pkgs.python3; # don't use python-boot
|
||||
});
|
||||
|
||||
lldb-manpages = lowPrio (tools.lldb.override {
|
||||
enableManpages = true;
|
||||
python3 = pkgs.python3; # don't use python-boot
|
||||
});
|
||||
|
||||
# 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;
|
||||
|
||||
libstdcxxClang = wrapCCWith rec {
|
||||
cc = tools.clang-unwrapped;
|
||||
# libstdcxx is taken from gcc in an ad-hoc way in cc-wrapper.
|
||||
libcxx = null;
|
||||
extraPackages = [
|
||||
targetLlvmLibraries.compiler-rt
|
||||
];
|
||||
extraBuildCommands = mkExtraBuildCommands cc;
|
||||
};
|
||||
|
||||
libcxxClang = wrapCCWith rec {
|
||||
cc = tools.clang-unwrapped;
|
||||
libcxx = targetLlvmLibraries.libcxx;
|
||||
extraPackages = [
|
||||
targetLlvmLibraries.compiler-rt
|
||||
];
|
||||
extraBuildCommands = mkExtraBuildCommands cc;
|
||||
};
|
||||
|
||||
lld = callPackage ../common/lld {
|
||||
patches = [
|
||||
./lld/gnu-install-dirs.patch
|
||||
];
|
||||
};
|
||||
|
||||
mlir = callPackage ../common/mlir {};
|
||||
|
||||
lldb = callPackage ../common/lldb.nix {
|
||||
src = callPackage ({ runCommand }: runCommand "lldb-src-${metadata.version}" {} ''
|
||||
mkdir -p "$out"
|
||||
cp -r ${monorepoSrc}/cmake "$out"
|
||||
cp -r ${monorepoSrc}/lldb "$out"
|
||||
'') { };
|
||||
patches =
|
||||
[
|
||||
# FIXME: do we need this? ./procfs.patch
|
||||
../common/lldb/gnu-install-dirs.patch
|
||||
]
|
||||
# This is a stopgap solution if/until the macOS SDK used for x86_64 is
|
||||
# updated.
|
||||
#
|
||||
# The older 10.12 SDK used on x86_64 as of this writing has a `mach/machine.h`
|
||||
# header that does not define `CPU_SUBTYPE_ARM64E` so we replace the one use
|
||||
# of this preprocessor symbol in `lldb` with its expansion.
|
||||
#
|
||||
# See here for some context:
|
||||
# https://github.com/NixOS/nixpkgs/pull/194634#issuecomment-1272129132
|
||||
++ lib.optional (
|
||||
stdenv.targetPlatform.isDarwin
|
||||
&& !stdenv.targetPlatform.isAarch64
|
||||
&& (lib.versionOlder darwin.apple_sdk.sdk.version "11.0")
|
||||
) ./lldb/cpu_subtype_arm64e_replacement.patch;
|
||||
};
|
||||
|
||||
# Below, is the LLVM bootstrapping logic. It handles building a
|
||||
# fully LLVM toolchain from scratch. No GCC toolchain should be
|
||||
# pulled in. As a consequence, it is very quick to build different
|
||||
# targets provided by LLVM and we can also build for what GCC
|
||||
# doesn’t support like LLVM. Probably we should move to some other
|
||||
# file.
|
||||
|
||||
bintools-unwrapped = callPackage ../common/bintools.nix { };
|
||||
|
||||
bintoolsNoLibc = wrapBintoolsWith {
|
||||
bintools = tools.bintools-unwrapped;
|
||||
libc = preLibcCrossHeaders;
|
||||
};
|
||||
|
||||
bintools = wrapBintoolsWith {
|
||||
bintools = tools.bintools-unwrapped;
|
||||
};
|
||||
|
||||
clangUseLLVM = wrapCCWith rec {
|
||||
cc = tools.clang-unwrapped;
|
||||
libcxx = targetLlvmLibraries.libcxx;
|
||||
bintools = bintools';
|
||||
extraPackages = [
|
||||
targetLlvmLibraries.compiler-rt
|
||||
] ++ lib.optionals (!stdenv.targetPlatform.isWasm) [
|
||||
targetLlvmLibraries.libunwind
|
||||
];
|
||||
extraBuildCommands = mkExtraBuildCommands cc;
|
||||
nixSupport.cc-cflags =
|
||||
[ "-rtlib=compiler-rt"
|
||||
"-Wno-unused-command-line-argument"
|
||||
"-B${targetLlvmLibraries.compiler-rt}/lib"
|
||||
]
|
||||
++ lib.optional (!stdenv.targetPlatform.isWasm) "--unwindlib=libunwind"
|
||||
++ lib.optional
|
||||
(!stdenv.targetPlatform.isWasm && stdenv.targetPlatform.useLLVM or false)
|
||||
"-lunwind"
|
||||
++ lib.optional stdenv.targetPlatform.isWasm "-fno-exceptions";
|
||||
nixSupport.cc-ldflags = lib.optionals (!stdenv.targetPlatform.isWasm) [ "-L${targetLlvmLibraries.libunwind}/lib" ];
|
||||
};
|
||||
|
||||
clangNoLibcxx = wrapCCWith rec {
|
||||
cc = tools.clang-unwrapped;
|
||||
libcxx = null;
|
||||
bintools = bintools';
|
||||
extraPackages = [
|
||||
targetLlvmLibraries.compiler-rt
|
||||
];
|
||||
extraBuildCommands = mkExtraBuildCommands cc;
|
||||
nixSupport.cc-cflags =
|
||||
[
|
||||
"-rtlib=compiler-rt"
|
||||
"-B${targetLlvmLibraries.compiler-rt}/lib"
|
||||
"-nostdlib++"
|
||||
]
|
||||
++ lib.optional stdenv.targetPlatform.isWasm "-fno-exceptions";
|
||||
};
|
||||
|
||||
clangNoLibc = wrapCCWith rec {
|
||||
cc = tools.clang-unwrapped;
|
||||
libcxx = null;
|
||||
bintools = bintoolsNoLibc';
|
||||
extraPackages = [
|
||||
targetLlvmLibraries.compiler-rt
|
||||
];
|
||||
extraBuildCommands = mkExtraBuildCommands cc;
|
||||
nixSupport.cc-cflags =
|
||||
[
|
||||
"-rtlib=compiler-rt"
|
||||
"-B${targetLlvmLibraries.compiler-rt}/lib"
|
||||
]
|
||||
++ lib.optional stdenv.targetPlatform.isWasm "-fno-exceptions";
|
||||
};
|
||||
|
||||
clangNoCompilerRt = wrapCCWith rec {
|
||||
cc = tools.clang-unwrapped;
|
||||
libcxx = null;
|
||||
bintools = bintoolsNoLibc';
|
||||
extraPackages = [ ];
|
||||
extraBuildCommands = mkExtraBuildCommands0 cc;
|
||||
nixSupport.cc-cflags =
|
||||
[
|
||||
"-nostartfiles"
|
||||
]
|
||||
++ lib.optional stdenv.targetPlatform.isWasm "-fno-exceptions";
|
||||
};
|
||||
|
||||
clangNoCompilerRtWithLibc = wrapCCWith (rec {
|
||||
cc = tools.clang-unwrapped;
|
||||
libcxx = null;
|
||||
bintools = bintools';
|
||||
extraPackages = [ ];
|
||||
extraBuildCommands = mkExtraBuildCommands0 cc;
|
||||
} // lib.optionalAttrs stdenv.targetPlatform.isWasm {
|
||||
nixSupport.cc-cflags = [ "-fno-exceptions" ];
|
||||
});
|
||||
|
||||
# Has to be in tools despite mostly being a library,
|
||||
# because we use a native helper executable from a
|
||||
# non-cross build in cross builds.
|
||||
libclc = callPackage ../common/libclc.nix {};
|
||||
});
|
||||
|
||||
libraries = lib.makeExtensible (libraries: let
|
||||
callPackage = newScope (libraries // buildLlvmTools // args // metadata);
|
||||
in {
|
||||
|
||||
compiler-rt-libc = callPackage ../common/compiler-rt {
|
||||
patches = [
|
||||
./compiler-rt/X86-support-extension.patch # Add support for i486 i586 i686 by reusing i386 config
|
||||
# ld-wrapper dislikes `-rpath-link //nix/store`, so we normalize away the
|
||||
# extra `/`.
|
||||
./compiler-rt/normalize-var.patch
|
||||
# See: https://github.com/NixOS/nixpkgs/pull/186575
|
||||
../common/compiler-rt/darwin-plistbuddy-workaround.patch
|
||||
# See: https://github.com/NixOS/nixpkgs/pull/194634#discussion_r999829893
|
||||
# ../common/compiler-rt/armv7l-15.patch
|
||||
];
|
||||
stdenv = if stdenv.hostPlatform.useLLVM or false || (stdenv.hostPlatform.isDarwin && stdenv.hostPlatform.isStatic)
|
||||
then overrideCC stdenv buildLlvmTools.clangNoCompilerRtWithLibc
|
||||
else stdenv;
|
||||
};
|
||||
|
||||
compiler-rt-no-libc = callPackage ../common/compiler-rt {
|
||||
patches = [
|
||||
./compiler-rt/X86-support-extension.patch # Add support for i486 i586 i686 by reusing i386 config
|
||||
# ld-wrapper dislikes `-rpath-link //nix/store`, so we normalize away the
|
||||
# extra `/`.
|
||||
./compiler-rt/normalize-var.patch
|
||||
# See: https://github.com/NixOS/nixpkgs/pull/186575
|
||||
../common/compiler-rt/darwin-plistbuddy-workaround.patch
|
||||
# See: https://github.com/NixOS/nixpkgs/pull/194634#discussion_r999829893
|
||||
# ../common/compiler-rt/armv7l-15.patch
|
||||
];
|
||||
stdenv = if stdenv.hostPlatform.useLLVM or false
|
||||
then overrideCC stdenv buildLlvmTools.clangNoCompilerRt
|
||||
else stdenv;
|
||||
};
|
||||
|
||||
# N.B. condition is safe because without useLLVM both are the same.
|
||||
compiler-rt = if stdenv.hostPlatform.isAndroid || stdenv.hostPlatform.isDarwin
|
||||
then libraries.compiler-rt-libc
|
||||
else libraries.compiler-rt-no-libc;
|
||||
|
||||
stdenv = overrideCC stdenv buildLlvmTools.clang;
|
||||
|
||||
libcxxStdenv = overrideCC stdenv buildLlvmTools.libcxxClang;
|
||||
|
||||
# `libcxx` requires a fairly modern C++ compiler,
|
||||
# so: we use the clang from this LLVM package set instead of the regular
|
||||
# stdenv's compiler.
|
||||
libcxx = callPackage ../common/libcxx {
|
||||
patches = lib.optionals (stdenv.isDarwin && lib.versionOlder stdenv.hostPlatform.darwinMinVersion "10.13") [
|
||||
# https://github.com/llvm/llvm-project/issues/64226
|
||||
./libcxx/0001-darwin-10.12-mbstate_t-fix.patch
|
||||
];
|
||||
stdenv = overrideCC stdenv buildLlvmTools.clangNoLibcxx;
|
||||
};
|
||||
|
||||
libunwind = callPackage ../common/libunwind {
|
||||
stdenv = overrideCC stdenv buildLlvmTools.clangNoLibcxx;
|
||||
};
|
||||
|
||||
openmp = callPackage ../common/openmp {
|
||||
patches = [
|
||||
./openmp/fix-find-tool.patch
|
||||
./openmp/run-lit-directly.patch
|
||||
];
|
||||
};
|
||||
});
|
||||
noExtend = extensible: lib.attrsets.removeAttrs extensible [ "extend" ];
|
||||
|
||||
in { inherit tools libraries; inherit (metadata) release_version; } // (noExtend libraries) // (noExtend tools)
|
@ -403,13 +403,13 @@ let
|
||||
stdenv.override (
|
||||
old:
|
||||
{
|
||||
buildPlatform = mkPlatform newVersion old.buildPlatform;
|
||||
hostPlatform = mkPlatform newVersion old.hostPlatform;
|
||||
targetPlatform = mkPlatform newVersion old.targetPlatform;
|
||||
buildPlatform = mkPlatform newVersion stdenv.buildPlatform;
|
||||
hostPlatform = mkPlatform newVersion stdenv.hostPlatform;
|
||||
targetPlatform = mkPlatform newVersion stdenv.targetPlatform;
|
||||
}
|
||||
# Only perform replacements if the SDK version has changed. Changing only the
|
||||
# deployment target does not require replacing the libc or SDK dependencies.
|
||||
// lib.optionalAttrs (old.hostPlatform.darwinSdkVersion != darwinSdkVersion) {
|
||||
// lib.optionalAttrs (stdenv.hostPlatform.darwinSdkVersion != darwinSdkVersion) {
|
||||
allowedRequisites = null;
|
||||
|
||||
mkDerivationFromStdenv = extendMkDerivationArgs old (mapInputsToSDK [
|
||||
|
@ -231,7 +231,16 @@ mapAliases ({
|
||||
clang_10 = throw "clang_10 has been removed from nixpkgs"; # Added 2024-01-26
|
||||
clang_11 = throw "clang_11 has been removed from nixpkgs"; # Added 2023-01-24
|
||||
|
||||
clang-tools_12 = llvmPackages_12.clang-tools; # Added 2024-04-22
|
||||
clang-tools_13 = llvmPackages_13.clang-tools; # Added 2024-04-22
|
||||
clang-tools_14 = llvmPackages_14.clang-tools; # Added 2024-04-22
|
||||
clang-tools_15 = llvmPackages_15.clang-tools; # Added 2024-04-22
|
||||
clang-tools_16 = llvmPackages_16.clang-tools; # Added 2024-04-22
|
||||
clang-tools_17 = llvmPackages_17.clang-tools; # Added 2024-04-22
|
||||
clang-tools_18 = llvmPackages_18.clang-tools; # Added 2024-04-22
|
||||
|
||||
cq-editor = throw "cq-editor has been removed, as it use a dependency that was disabled since python 3.8 and was last updated in 2021"; # Added 2024-05-13
|
||||
|
||||
### D ###
|
||||
|
||||
dagger = throw "'dagger' has been removed from nixpkgs, as the trademark policy of the upstream project is incompatible"; # Added 2023-10-16
|
||||
@ -1427,12 +1436,6 @@ mapAliases ({
|
||||
|
||||
# LLVM packages for (integration) testing that should not be used inside Nixpkgs:
|
||||
llvmPackages_latest = llvmPackages_18;
|
||||
llvmPackages_git = recurseIntoAttrs (callPackage ../development/compilers/llvm/git {
|
||||
inherit (stdenvAdapters) overrideCC;
|
||||
buildLlvmTools = buildPackages.llvmPackages_git.tools;
|
||||
targetLlvmLibraries = targetPackages.llvmPackages_git.libraries or llvmPackages_git.libraries;
|
||||
targetLlvm = targetPackages.llvmPackages_git.llvm or llvmPackages_git.llvm;
|
||||
});
|
||||
|
||||
/* If these are in the scope of all-packages.nix, they cause collisions
|
||||
between mixed versions of qt. See:
|
||||
|
@ -15249,31 +15249,7 @@ with pkgs;
|
||||
clang_16 = llvmPackages_16.clang;
|
||||
clang_17 = llvmPackages_17.clang;
|
||||
|
||||
clang-tools = callPackage ../development/tools/clang-tools { };
|
||||
|
||||
clang-tools_12 = callPackage ../development/tools/clang-tools {
|
||||
llvmPackages = llvmPackages_12;
|
||||
};
|
||||
|
||||
clang-tools_13 = callPackage ../development/tools/clang-tools {
|
||||
llvmPackages = llvmPackages_13;
|
||||
};
|
||||
|
||||
clang-tools_14 = callPackage ../development/tools/clang-tools {
|
||||
llvmPackages = llvmPackages_14;
|
||||
};
|
||||
|
||||
clang-tools_15 = callPackage ../development/tools/clang-tools {
|
||||
llvmPackages = llvmPackages_15;
|
||||
};
|
||||
|
||||
clang-tools_16 = callPackage ../development/tools/clang-tools {
|
||||
llvmPackages = llvmPackages_16;
|
||||
};
|
||||
|
||||
clang-tools_17 = callPackage ../development/tools/clang-tools {
|
||||
llvmPackages = llvmPackages_17;
|
||||
};
|
||||
clang-tools = llvmPackages.clang-tools;
|
||||
|
||||
clang-analyzer = callPackage ../development/tools/analysis/clang-analyzer {
|
||||
llvmPackages = llvmPackages_14;
|
||||
@ -16297,66 +16273,33 @@ with pkgs;
|
||||
targetLlvm = targetPackages.llvmPackages_12.llvm or llvmPackages_12.llvm;
|
||||
}));
|
||||
|
||||
llvmPackages_13 = recurseIntoAttrs (callPackage ../development/compilers/llvm/13 ({
|
||||
inherit (stdenvAdapters) overrideCC;
|
||||
buildLlvmTools = buildPackages.llvmPackages_13.tools;
|
||||
targetLlvmLibraries = targetPackages.llvmPackages_13.libraries or llvmPackages_13.libraries;
|
||||
targetLlvm = targetPackages.llvmPackages_13.llvm or llvmPackages_13.llvm;
|
||||
stdenv = if stdenv.cc.cc.isGNU or false then gcc12Stdenv else stdenv; # does not build with gcc13
|
||||
}));
|
||||
inherit (rec {
|
||||
llvmPackagesSet = recurseIntoAttrs (callPackages ../development/compilers/llvm { });
|
||||
|
||||
llvmPackages_14 = recurseIntoAttrs (callPackage ../development/compilers/llvm/14 ({
|
||||
inherit (stdenvAdapters) overrideCC;
|
||||
buildLlvmTools = buildPackages.llvmPackages_14.tools;
|
||||
targetLlvmLibraries = targetPackages.llvmPackages_14.libraries or llvmPackages_14.libraries;
|
||||
targetLlvm = targetPackages.llvmPackages_14.llvm or llvmPackages_14.llvm;
|
||||
}));
|
||||
llvmPackages_13 = llvmPackagesSet."13";
|
||||
llvmPackages_14 = llvmPackagesSet."14";
|
||||
llvmPackages_15 = llvmPackagesSet."15";
|
||||
llvmPackages_16 = llvmPackagesSet."16";
|
||||
llvmPackages_17 = llvmPackagesSet."17";
|
||||
|
||||
llvmPackages_15 = recurseIntoAttrs (callPackage ../development/compilers/llvm/15 ({
|
||||
inherit (stdenvAdapters) overrideCC;
|
||||
buildLlvmTools = buildPackages.llvmPackages_15.tools;
|
||||
targetLlvmLibraries = targetPackages.llvmPackages_15.libraries or llvmPackages_15.libraries;
|
||||
targetLlvm = targetPackages.llvmPackages_15.llvm or llvmPackages_15.llvm;
|
||||
}));
|
||||
llvmPackages_18 = llvmPackagesSet."18";
|
||||
clang_18 = llvmPackages_18.clang;
|
||||
lld_18 = llvmPackages_18.lld;
|
||||
lldb_18 = llvmPackages_18.lldb;
|
||||
llvm_18 = llvmPackages_18.llvm;
|
||||
|
||||
llvmPackages_16 = recurseIntoAttrs (callPackage ../development/compilers/llvm/16 ({
|
||||
inherit (stdenvAdapters) overrideCC;
|
||||
buildLlvmTools = buildPackages.llvmPackages_16.tools;
|
||||
targetLlvmLibraries = targetPackages.llvmPackages_16.libraries or llvmPackages_16.libraries;
|
||||
targetLlvm = targetPackages.llvmPackages_16.llvm or llvmPackages_16.llvm;
|
||||
}));
|
||||
|
||||
llvmPackages_17 = recurseIntoAttrs (callPackage ../development/compilers/llvm/17 ({
|
||||
inherit (stdenvAdapters) overrideCC;
|
||||
buildLlvmTools = buildPackages.llvmPackages_17.tools;
|
||||
targetLlvmLibraries = targetPackages.llvmPackages_17.libraries or llvmPackages_17.libraries;
|
||||
targetLlvm = targetPackages.llvmPackages_17.llvm or llvmPackages_17.llvm;
|
||||
}));
|
||||
|
||||
inherit
|
||||
(rec {
|
||||
llvmPackages_18 = recurseIntoAttrs (callPackage ../development/compilers/llvm/18 ({
|
||||
inherit (stdenvAdapters) overrideCC;
|
||||
buildLlvmTools = buildPackages.llvmPackages_18.tools;
|
||||
targetLlvmLibraries = targetPackages.llvmPackages_18.libraries or llvmPackages_18.libraries;
|
||||
targetLlvm = targetPackages.llvmPackages_18.llvm or llvmPackages_18.llvm;
|
||||
}));
|
||||
|
||||
clang_18 = llvmPackages_18.clang;
|
||||
lld_18 = llvmPackages_18.lld;
|
||||
lldb_18 = llvmPackages_18.lldb;
|
||||
llvm_18 = llvmPackages_18.llvm;
|
||||
|
||||
clang-tools_18 = callPackage ../development/tools/clang-tools {
|
||||
llvmPackages = llvmPackages_18;
|
||||
};
|
||||
})
|
||||
llvmPackages_18
|
||||
clang_18
|
||||
lld_18
|
||||
lldb_18
|
||||
llvm_18
|
||||
clang-tools_18;
|
||||
llvmPackages_git = llvmPackagesSet.git;
|
||||
}) llvmPackages_13
|
||||
llvmPackages_14
|
||||
llvmPackages_15
|
||||
llvmPackages_16
|
||||
llvmPackages_17
|
||||
llvmPackages_18
|
||||
clang_18
|
||||
lld_18
|
||||
lldb_18
|
||||
llvm_18
|
||||
llvmPackages_git;
|
||||
|
||||
lorri = callPackage ../tools/misc/lorri {
|
||||
inherit (darwin.apple_sdk.frameworks) CoreServices Security;
|
||||
|
Loading…
Reference in New Issue
Block a user