2024-07-06 21:43:37 -07:00
|
|
|
|
{
|
|
|
|
|
lowPrio,
|
|
|
|
|
newScope,
|
|
|
|
|
pkgs,
|
|
|
|
|
lib,
|
|
|
|
|
stdenv,
|
|
|
|
|
preLibcCrossHeaders,
|
2023-11-27 08:02:52 +02:00
|
|
|
|
libxcrypt,
|
2024-07-06 21:43:37 -07:00
|
|
|
|
substitute,
|
2024-11-23 13:45:07 +01:00
|
|
|
|
replaceVars,
|
2024-07-06 21:43:37 -07:00
|
|
|
|
fetchFromGitHub,
|
|
|
|
|
fetchpatch,
|
2024-09-12 11:20:59 +01:00
|
|
|
|
fetchpatch2,
|
2024-07-06 21:43:37 -07:00
|
|
|
|
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,
|
2024-09-14 15:37:31 +01:00
|
|
|
|
# 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.
|
2024-07-06 21:43:37 -07:00
|
|
|
|
...
|
|
|
|
|
}@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;
|
2024-08-09 12:34:48 -07:00
|
|
|
|
path =
|
2024-08-12 20:50:07 -07:00
|
|
|
|
let
|
|
|
|
|
patches = {
|
|
|
|
|
"clang/gnu-install-dirs.patch" = [
|
|
|
|
|
{
|
|
|
|
|
before = "14";
|
|
|
|
|
path = ../12;
|
|
|
|
|
}
|
|
|
|
|
{
|
|
|
|
|
after = "19";
|
|
|
|
|
path = ../19;
|
|
|
|
|
}
|
|
|
|
|
];
|
|
|
|
|
"clang/purity.patch" = [
|
|
|
|
|
{
|
|
|
|
|
after = "18";
|
|
|
|
|
path = ../18;
|
|
|
|
|
}
|
|
|
|
|
{
|
|
|
|
|
before = "17";
|
|
|
|
|
after = "15";
|
|
|
|
|
path = ../15;
|
|
|
|
|
}
|
|
|
|
|
{
|
|
|
|
|
before = "16";
|
|
|
|
|
path = ../12;
|
|
|
|
|
}
|
|
|
|
|
];
|
|
|
|
|
"lld/add-table-base.patch" = [
|
|
|
|
|
{
|
|
|
|
|
after = "16";
|
|
|
|
|
path = ../16;
|
|
|
|
|
}
|
|
|
|
|
];
|
|
|
|
|
"lld/gnu-install-dirs.patch" = [
|
|
|
|
|
{
|
|
|
|
|
after = "18";
|
|
|
|
|
path = ../18;
|
|
|
|
|
}
|
|
|
|
|
{
|
|
|
|
|
before = "14";
|
|
|
|
|
path = ../12;
|
|
|
|
|
}
|
|
|
|
|
];
|
|
|
|
|
"llvm/gnu-install-dirs.patch" = [
|
2025-02-05 19:12:17 -08:00
|
|
|
|
{
|
|
|
|
|
after = "20";
|
|
|
|
|
path = ../20;
|
|
|
|
|
}
|
2024-08-12 20:50:07 -07:00
|
|
|
|
{
|
|
|
|
|
after = "18";
|
2025-02-05 19:12:17 -08:00
|
|
|
|
before = "20";
|
2024-08-12 20:50:07 -07:00
|
|
|
|
path = ../18;
|
|
|
|
|
}
|
|
|
|
|
];
|
|
|
|
|
"llvm/gnu-install-dirs-polly.patch" = [
|
|
|
|
|
{
|
2025-01-25 15:00:13 +00:00
|
|
|
|
after = "20";
|
|
|
|
|
path = ../20;
|
|
|
|
|
}
|
|
|
|
|
{
|
|
|
|
|
before = "20";
|
2024-08-12 20:50:07 -07:00
|
|
|
|
after = "18";
|
|
|
|
|
path = ../18;
|
|
|
|
|
}
|
|
|
|
|
{
|
|
|
|
|
before = "18";
|
|
|
|
|
after = "14";
|
|
|
|
|
path = ../14;
|
|
|
|
|
}
|
|
|
|
|
];
|
|
|
|
|
"llvm/llvm-lit-cfg-add-libs-to-dylib-path.patch" = [
|
|
|
|
|
{
|
|
|
|
|
before = "17";
|
|
|
|
|
after = "15";
|
|
|
|
|
path = ../15;
|
|
|
|
|
}
|
|
|
|
|
{
|
|
|
|
|
after = "17";
|
|
|
|
|
path = ../17;
|
|
|
|
|
}
|
|
|
|
|
];
|
|
|
|
|
"llvm/lit-shell-script-runner-set-dyld-library-path.patch" = [
|
|
|
|
|
{
|
|
|
|
|
after = "18";
|
|
|
|
|
path = ../18;
|
|
|
|
|
}
|
|
|
|
|
{
|
|
|
|
|
after = "16";
|
|
|
|
|
before = "18";
|
|
|
|
|
path = ../16;
|
|
|
|
|
}
|
|
|
|
|
];
|
|
|
|
|
"llvm/polly-lit-cfg-add-libs-to-dylib-path.patch" = [
|
|
|
|
|
{
|
|
|
|
|
after = "15";
|
|
|
|
|
path = ../15;
|
|
|
|
|
}
|
|
|
|
|
];
|
|
|
|
|
"libunwind/gnu-install-dirs.patch" = [
|
|
|
|
|
{
|
|
|
|
|
before = "17";
|
|
|
|
|
after = "15";
|
|
|
|
|
path = ../15;
|
|
|
|
|
}
|
|
|
|
|
];
|
|
|
|
|
"compiler-rt/X86-support-extension.patch" = [
|
|
|
|
|
{
|
|
|
|
|
after = "15";
|
|
|
|
|
path = ../15;
|
|
|
|
|
}
|
|
|
|
|
{
|
|
|
|
|
before = "15";
|
|
|
|
|
path = ../12;
|
|
|
|
|
}
|
|
|
|
|
];
|
2024-08-11 12:00:00 +00:00
|
|
|
|
"compiler-rt/armv6-scudo-libatomic.patch" = [
|
|
|
|
|
{
|
|
|
|
|
after = "19";
|
|
|
|
|
path = ../19;
|
|
|
|
|
}
|
|
|
|
|
{
|
|
|
|
|
after = "15";
|
|
|
|
|
before = "19";
|
|
|
|
|
path = ../15;
|
|
|
|
|
}
|
|
|
|
|
{
|
|
|
|
|
before = "15";
|
|
|
|
|
path = ../14;
|
|
|
|
|
}
|
|
|
|
|
];
|
2024-08-12 20:50:07 -07:00
|
|
|
|
"compiler-rt/armv7l.patch" = [
|
|
|
|
|
{
|
|
|
|
|
before = "15";
|
|
|
|
|
after = "13";
|
|
|
|
|
path = ../13;
|
|
|
|
|
}
|
|
|
|
|
];
|
|
|
|
|
"compiler-rt/gnu-install-dirs.patch" = [
|
|
|
|
|
{
|
|
|
|
|
before = "14";
|
|
|
|
|
path = ../12;
|
|
|
|
|
}
|
|
|
|
|
{
|
|
|
|
|
after = "13";
|
|
|
|
|
before = "15";
|
|
|
|
|
path = ../14;
|
|
|
|
|
}
|
|
|
|
|
{
|
|
|
|
|
after = "15";
|
|
|
|
|
before = "17";
|
|
|
|
|
path = ../15;
|
|
|
|
|
}
|
|
|
|
|
{
|
|
|
|
|
after = "16";
|
|
|
|
|
path = ../17;
|
|
|
|
|
}
|
|
|
|
|
];
|
|
|
|
|
"compiler-rt/darwin-targetconditionals.patch" = [
|
|
|
|
|
{
|
|
|
|
|
after = "13";
|
|
|
|
|
path = ../13;
|
|
|
|
|
}
|
|
|
|
|
];
|
|
|
|
|
"compiler-rt/codesign.patch" = [
|
|
|
|
|
{
|
|
|
|
|
after = "13";
|
|
|
|
|
path = ../13;
|
|
|
|
|
}
|
|
|
|
|
];
|
|
|
|
|
"compiler-rt/normalize-var.patch" = [
|
|
|
|
|
{
|
|
|
|
|
after = "16";
|
|
|
|
|
path = ../16;
|
|
|
|
|
}
|
|
|
|
|
{
|
|
|
|
|
before = "16";
|
|
|
|
|
path = ../12;
|
|
|
|
|
}
|
|
|
|
|
];
|
|
|
|
|
"lldb/procfs.patch" = [
|
|
|
|
|
{
|
|
|
|
|
after = "15";
|
|
|
|
|
path = ../15;
|
|
|
|
|
}
|
|
|
|
|
{
|
|
|
|
|
before = "15";
|
|
|
|
|
path = ../12;
|
|
|
|
|
}
|
|
|
|
|
];
|
|
|
|
|
"lldb/resource-dir.patch" = [
|
|
|
|
|
{
|
|
|
|
|
before = "16";
|
|
|
|
|
path = ../12;
|
|
|
|
|
}
|
|
|
|
|
];
|
|
|
|
|
"openmp/fix-find-tool.patch" = [
|
|
|
|
|
{
|
|
|
|
|
after = "17";
|
2024-08-21 19:42:31 -07:00
|
|
|
|
before = "19";
|
2024-08-12 20:50:07 -07:00
|
|
|
|
path = ../17;
|
|
|
|
|
}
|
|
|
|
|
];
|
|
|
|
|
"openmp/run-lit-directly.patch" = [
|
|
|
|
|
{
|
|
|
|
|
after = "16";
|
|
|
|
|
path = ../16;
|
|
|
|
|
}
|
|
|
|
|
{
|
|
|
|
|
after = "14";
|
|
|
|
|
before = "16";
|
|
|
|
|
path = ../14;
|
|
|
|
|
}
|
|
|
|
|
];
|
2024-08-24 20:05:35 -07:00
|
|
|
|
"libclc/use-default-paths.patch" = [
|
|
|
|
|
{
|
|
|
|
|
after = "19";
|
|
|
|
|
path = ../19;
|
|
|
|
|
}
|
|
|
|
|
];
|
2024-08-12 20:50:07 -07:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
constraints = patches."${p}" or null;
|
|
|
|
|
matchConstraint =
|
|
|
|
|
{
|
|
|
|
|
before ? null,
|
|
|
|
|
after ? null,
|
|
|
|
|
path,
|
|
|
|
|
}:
|
|
|
|
|
let
|
|
|
|
|
check = fn: value: if value == null then true else fn release_version value;
|
|
|
|
|
matchBefore = check lib.versionOlder before;
|
|
|
|
|
matchAfter = check lib.versionAtLeast after;
|
|
|
|
|
in
|
|
|
|
|
matchBefore && matchAfter;
|
|
|
|
|
|
|
|
|
|
patchDir =
|
|
|
|
|
toString
|
|
|
|
|
(
|
|
|
|
|
if constraints == null then
|
|
|
|
|
{ path = metadata.versionDir; }
|
|
|
|
|
else
|
|
|
|
|
(lib.findFirst matchConstraint { path = metadata.versionDir; } constraints)
|
|
|
|
|
).path;
|
|
|
|
|
in
|
|
|
|
|
"${patchDir}/${p}";
|
2024-07-06 21:43:37 -07:00
|
|
|
|
};
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
tools = lib.makeExtensible (
|
|
|
|
|
tools:
|
|
|
|
|
let
|
2024-10-11 11:41:49 +02:00
|
|
|
|
callPackage = newScope (tools // args // metadata);
|
2024-07-06 21:43:37 -07:00
|
|
|
|
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"
|
2024-11-07 09:43:39 +00:00
|
|
|
|
ln -s "${lib.getLib cc}/lib/clang/${clangVersion}/include" "$rsrc"
|
2024-07-06 21:43:37 -07:00
|
|
|
|
echo "-resource-dir=$rsrc" >> $out/nix-support/cc-cflags
|
|
|
|
|
'';
|
2023-11-27 08:02:52 +02:00
|
|
|
|
mkExtraBuildCommandsBasicRt =
|
|
|
|
|
cc:
|
|
|
|
|
mkExtraBuildCommands0 cc
|
|
|
|
|
+ ''
|
|
|
|
|
ln -s "${targetLlvmLibraries.compiler-rt-no-libc.out}/lib" "$rsrc/lib"
|
|
|
|
|
ln -s "${targetLlvmLibraries.compiler-rt-no-libc.out}/share" "$rsrc/share"
|
|
|
|
|
'';
|
2024-07-06 21:43:37 -07:00
|
|
|
|
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
|
2024-10-06 00:32:56 +02:00
|
|
|
|
++ lib.optionals (lib.versions.major metadata.release_version == "12") [
|
|
|
|
|
(metadata.getVersionFile "llvm/fix-llvm-issue-49955.patch")
|
|
|
|
|
|
|
|
|
|
# On older CPUs (e.g. Hydra/wendy) we'd be getting an error in this test.
|
|
|
|
|
(fetchpatch {
|
|
|
|
|
name = "uops-CMOV16rm-noreg.diff";
|
|
|
|
|
url = "https://github.com/llvm/llvm-project/commit/9e9f991ac033.diff";
|
|
|
|
|
sha256 = "sha256:12s8vr6ibri8b48h2z38f3afhwam10arfiqfy4yg37bmc054p5hi";
|
|
|
|
|
stripLen = 1;
|
|
|
|
|
})
|
|
|
|
|
]
|
2024-07-06 21:43:37 -07:00
|
|
|
|
++ [ (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=";
|
|
|
|
|
}
|
|
|
|
|
)
|
2024-10-06 00:32:56 +02:00
|
|
|
|
++ lib.optionals (lib.versionOlder metadata.release_version "14") [
|
2024-07-06 21:43:37 -07:00
|
|
|
|
# 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=";
|
|
|
|
|
})
|
|
|
|
|
]
|
|
|
|
|
++
|
|
|
|
|
lib.optional (lib.versions.major metadata.release_version == "17")
|
|
|
|
|
# resolves https://github.com/llvm/llvm-project/issues/75168
|
|
|
|
|
(
|
|
|
|
|
fetchpatch {
|
|
|
|
|
name = "fix-fzero-call-used-regs.patch";
|
|
|
|
|
url = "https://github.com/llvm/llvm-project/commit/f800c1f3b207e7bcdc8b4c7192928d9a078242a0.patch";
|
|
|
|
|
stripLen = 1;
|
|
|
|
|
hash = "sha256-e8YKrMy2rGcSJGC6er2V66cOnAnI+u1/yImkvsRsmg8=";
|
|
|
|
|
}
|
2024-07-12 11:16:51 -04:00
|
|
|
|
)
|
|
|
|
|
++ lib.optionals (lib.versions.major metadata.release_version == "18") [
|
|
|
|
|
# Reorgs one test so the next patch applies
|
|
|
|
|
(fetchpatch {
|
|
|
|
|
name = "osabi-test-reorg.patch";
|
|
|
|
|
url = "https://github.com/llvm/llvm-project/commit/06cecdc60ec9ebfdd4d8cdb2586d201272bdf6bd.patch";
|
|
|
|
|
stripLen = 1;
|
|
|
|
|
hash = "sha256-s9GZTNgzLS511Pzh6Wb1hEV68lxhmLWXjlybHBDMhvM=";
|
|
|
|
|
})
|
|
|
|
|
# Sets the OSABI for OpenBSD, needed for an LLD patch for OpenBSD.
|
|
|
|
|
# https://github.com/llvm/llvm-project/pull/98553
|
|
|
|
|
(fetchpatch {
|
|
|
|
|
name = "mc-set-openbsd-osabi.patch";
|
|
|
|
|
url = "https://github.com/llvm/llvm-project/commit/b64c1de714c50bec7493530446ebf5e540d5f96a.patch";
|
|
|
|
|
stripLen = 1;
|
|
|
|
|
hash = "sha256-fqw5gTSEOGs3kAguR4tINFG7Xja1RAje+q67HJt2nGg=";
|
|
|
|
|
})
|
2024-09-15 12:48:06 +02:00
|
|
|
|
]
|
|
|
|
|
++
|
|
|
|
|
lib.optionals
|
|
|
|
|
(lib.versionAtLeast metadata.release_version "17" && lib.versionOlder metadata.release_version "19")
|
|
|
|
|
[
|
|
|
|
|
# Fixes test-suite on glibc 2.40 (https://github.com/llvm/llvm-project/pull/100804)
|
|
|
|
|
(fetchpatch2 {
|
|
|
|
|
url = "https://github.com/llvm/llvm-project/commit/1e8df9e85a1ff213e5868bd822877695f27504ad.patch";
|
|
|
|
|
hash = "sha256-EX+PYGicK73lsL/J0kSZ4S5y1/NHIclBddhsnV6NPPI=";
|
|
|
|
|
stripLen = 1;
|
|
|
|
|
})
|
2025-02-05 19:12:17 -08:00
|
|
|
|
]
|
|
|
|
|
++
|
2025-02-17 22:08:22 -08:00
|
|
|
|
lib.optional (lib.versions.major metadata.release_version == "20")
|
2025-02-12 22:42:30 -08:00
|
|
|
|
# Fix OrcJIT tests with page sizes > 16k
|
|
|
|
|
# PR: https://github.com/llvm/llvm-project/pull/127115
|
|
|
|
|
(
|
|
|
|
|
fetchpatch {
|
|
|
|
|
url = "https://github.com/llvm/llvm-project/commit/415607e10b56d0e6c4661ff1ec5b9b46bf433cba.patch";
|
|
|
|
|
stripLen = 1;
|
|
|
|
|
hash = "sha256-vBbuduJB+NnNE9qtR93k64XKrwvc7w3vowjL/aT+iEA=";
|
|
|
|
|
}
|
|
|
|
|
);
|
2024-07-06 21:43:37 -07:00
|
|
|
|
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;
|
|
|
|
|
|
2024-12-18 22:23:34 +00:00
|
|
|
|
tblgen = callPackage ./tblgen.nix {
|
2025-02-05 19:05:38 -08:00
|
|
|
|
patches =
|
|
|
|
|
builtins.filter
|
|
|
|
|
# Crude method to drop polly patches if present, they're not needed for tblgen.
|
|
|
|
|
(p: (!lib.hasInfix "-polly" p))
|
|
|
|
|
tools.libllvm.patches;
|
2024-12-18 22:23:34 +00:00
|
|
|
|
clangPatches = [
|
|
|
|
|
# Would take tools.libclang.patches, but this introduces a cycle due
|
|
|
|
|
# to replacements depending on the llvm outpath (e.g. the LLVMgold patch).
|
|
|
|
|
# So take the only patch known to be necessary.
|
|
|
|
|
(metadata.getVersionFile "clang/gnu-install-dirs.patch")
|
|
|
|
|
];
|
|
|
|
|
};
|
2024-12-06 11:26:22 +00:00
|
|
|
|
|
2024-07-06 21:43:37 -07:00
|
|
|
|
libclang = callPackage ./clang {
|
|
|
|
|
patches =
|
|
|
|
|
[
|
|
|
|
|
(metadata.getVersionFile "clang/purity.patch")
|
|
|
|
|
# https://reviews.llvm.org/D51899
|
|
|
|
|
(metadata.getVersionFile "clang/gnu-install-dirs.patch")
|
2025-01-25 15:00:13 +00:00
|
|
|
|
]
|
|
|
|
|
++ lib.optionals (lib.versionOlder metadata.release_version "20") [
|
2024-11-16 11:48:51 -08:00
|
|
|
|
# https://github.com/llvm/llvm-project/pull/116476
|
|
|
|
|
# prevent clang ignoring warnings / errors for unsuppored
|
|
|
|
|
# options when building & linking a source file with trailing
|
|
|
|
|
# libraries. eg: `clang -munsupported hello.c -lc`
|
|
|
|
|
./clang/clang-unsupported-option.patch
|
2024-07-06 21:43:37 -07:00
|
|
|
|
]
|
2025-02-05 19:05:38 -08:00
|
|
|
|
++
|
|
|
|
|
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")
|
2024-11-24 22:32:46 +00:00
|
|
|
|
++ lib.optional (lib.versionOlder metadata.release_version "17") (
|
|
|
|
|
if lib.versionAtLeast metadata.release_version "14" then
|
|
|
|
|
fetchpatch {
|
|
|
|
|
name = "ignore-nostd-link.patch";
|
|
|
|
|
url = "https://github.com/llvm/llvm-project/commit/5b77e752dcd073846b89559d6c0e1a7699e58615.patch";
|
|
|
|
|
relative = "clang";
|
|
|
|
|
hash = "sha256-qzSAmoGY+7POkDhcGgQRPaNQ3+7PIcIc9cZuiE/eLkc=";
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
./clang/ignore-nostd-link-13.diff
|
|
|
|
|
)
|
2024-07-06 21:43:37 -07:00
|
|
|
|
++ [
|
2024-11-23 13:45:07 +01:00
|
|
|
|
(replaceVars
|
|
|
|
|
(
|
2024-07-06 21:43:37 -07:00
|
|
|
|
if (lib.versionOlder metadata.release_version "16") then
|
|
|
|
|
./clang/clang-11-15-LLVMgold-path.patch
|
|
|
|
|
else
|
2024-11-23 13:45:07 +01:00
|
|
|
|
./clang/clang-at-least-16-LLVMgold-path.patch
|
|
|
|
|
)
|
|
|
|
|
{
|
|
|
|
|
libllvmLibdir = "${tools.libllvm.lib}/lib";
|
|
|
|
|
}
|
|
|
|
|
)
|
2024-07-06 21:43:37 -07:00
|
|
|
|
]
|
2024-09-23 22:24:15 -04:00
|
|
|
|
# Backport version logic from Clang 16. This is needed by the following patch.
|
2024-10-13 20:54:28 -04:00
|
|
|
|
++ lib.optional (lib.versions.major metadata.release_version == "15") (fetchpatch {
|
2024-09-23 22:24:15 -04:00
|
|
|
|
name = "clang-darwin-Use-consistent-version-define-stringifying-logic.patch";
|
|
|
|
|
url = "https://github.com/llvm/llvm-project/commit/60a33ded751c86fff9ac1c4bdd2b341fbe4b0649.patch?full_index=1";
|
|
|
|
|
includes = [ "lib/Basic/Targets/OSTargets.cpp" ];
|
|
|
|
|
stripLen = 1;
|
|
|
|
|
hash = "sha256-YVTSg5eZLz3po2AUczPNXCK26JA3CuTh6Iqp7hAAKIs=";
|
|
|
|
|
})
|
|
|
|
|
# Backport `__ENVIRONMENT_OS_VERSION_MIN_REQUIRED__` support from Clang 17.
|
|
|
|
|
# This is needed by newer SDKs (14+).
|
2024-10-13 20:54:28 -04:00
|
|
|
|
++
|
|
|
|
|
lib.optional
|
|
|
|
|
(
|
|
|
|
|
lib.versionAtLeast (lib.versions.major metadata.release_version) "15"
|
|
|
|
|
&& lib.versionOlder (lib.versions.major metadata.release_version) "17"
|
|
|
|
|
)
|
|
|
|
|
(fetchpatch {
|
|
|
|
|
name = "clang-darwin-An-OS-version-preprocessor-define.patch";
|
|
|
|
|
url = "https://github.com/llvm/llvm-project/commit/c8e2dd8c6f490b68e41fe663b44535a8a21dfeab.patch?full_index=1";
|
|
|
|
|
includes = [ "lib/Basic/Targets/OSTargets.cpp" ];
|
|
|
|
|
stripLen = 1;
|
|
|
|
|
hash = "sha256-Vs32kql7N6qtLqc12FtZHURcbenA7+N3E/nRRX3jdig=";
|
|
|
|
|
})
|
2024-07-06 21:43:37 -07:00
|
|
|
|
++ lib.optional (lib.versions.major metadata.release_version == "18") (fetchpatch {
|
|
|
|
|
name = "tweak-tryCaptureVariable-for-unevaluated-lambdas.patch";
|
|
|
|
|
url = "https://github.com/llvm/llvm-project/commit/3d361b225fe89ce1d8c93639f27d689082bd8dad.patch";
|
|
|
|
|
# TreeTransform.h is not affected in LLVM 18.
|
|
|
|
|
excludes = [
|
|
|
|
|
"docs/ReleaseNotes.rst"
|
|
|
|
|
"lib/Sema/TreeTransform.h"
|
|
|
|
|
];
|
|
|
|
|
stripLen = 1;
|
|
|
|
|
hash = "sha256-1NKej08R9SPlbDY/5b0OKUsHjX07i9brR84yXiPwi7E=";
|
|
|
|
|
});
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
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"
|
2024-07-12 11:16:51 -04:00
|
|
|
|
) (metadata.getVersionFile "lld/add-table-base.patch")
|
|
|
|
|
++ lib.optional (lib.versions.major metadata.release_version == "18") (
|
|
|
|
|
# https://github.com/llvm/llvm-project/pull/97122
|
|
|
|
|
fetchpatch {
|
|
|
|
|
name = "more-openbsd-program-headers.patch";
|
|
|
|
|
url = "https://github.com/llvm/llvm-project/commit/d7fd8b19e560fbb613159625acd8046d0df75115.patch";
|
|
|
|
|
stripLen = 1;
|
|
|
|
|
hash = "sha256-7wTy7XDTx0+fhWQpW1KEuz7xJvpl42qMTUfd20KGOfA=";
|
|
|
|
|
}
|
|
|
|
|
);
|
2024-07-06 21:43:37 -07:00
|
|
|
|
};
|
|
|
|
|
|
2024-12-18 18:00:15 -08:00
|
|
|
|
lldbPlugins = lib.makeExtensible (
|
|
|
|
|
lldbPlugins:
|
|
|
|
|
let
|
2025-02-05 19:05:38 -08:00
|
|
|
|
callPackage = newScope (lldbPlugins // tools // args // metadata);
|
2024-12-18 18:00:15 -08:00
|
|
|
|
in
|
|
|
|
|
lib.recurseIntoAttrs { llef = callPackage ./lldb-plugins/llef.nix { }; }
|
|
|
|
|
);
|
|
|
|
|
|
2024-07-06 21:43:37 -07:00
|
|
|
|
lldb = callPackage ./lldb.nix (
|
|
|
|
|
{
|
|
|
|
|
patches =
|
|
|
|
|
let
|
|
|
|
|
resourceDirPatch = callPackage (
|
2024-11-23 13:45:07 +01:00
|
|
|
|
{ replaceVars, libclang }:
|
|
|
|
|
(replaceVars (metadata.getVersionFile "lldb/resource-dir.patch") {
|
|
|
|
|
|
2024-11-07 09:43:39 +00:00
|
|
|
|
clangLibDir = "${lib.getLib libclang}/lib";
|
2024-07-06 21:43:37 -07:00
|
|
|
|
}).overrideAttrs
|
|
|
|
|
(_: _: { name = "resource-dir.patch"; })
|
|
|
|
|
) { };
|
|
|
|
|
in
|
2024-09-12 11:20:59 +01:00
|
|
|
|
lib.optionals (lib.versionOlder metadata.release_version "15") [
|
|
|
|
|
# Fixes for SWIG 4
|
|
|
|
|
(fetchpatch2 {
|
|
|
|
|
url = "https://github.com/llvm/llvm-project/commit/81fc5f7909a4ef5a8d4b5da2a10f77f7cb01ba63.patch?full_index=1";
|
|
|
|
|
stripLen = 1;
|
|
|
|
|
hash = "sha256-Znw+C0uEw7lGETQLKPBZV/Ymo2UigZS+Hv/j1mUo7p0=";
|
|
|
|
|
})
|
|
|
|
|
(fetchpatch2 {
|
|
|
|
|
url = "https://github.com/llvm/llvm-project/commit/f0a25fe0b746f56295d5c02116ba28d2f965c175.patch?full_index=1";
|
|
|
|
|
stripLen = 1;
|
|
|
|
|
hash = "sha256-QzVeZzmc99xIMiO7n//b+RNAvmxghISKQD93U2zOgFI=";
|
|
|
|
|
})
|
|
|
|
|
]
|
|
|
|
|
++ lib.optionals (lib.versionOlder metadata.release_version "16") [
|
|
|
|
|
# Fixes for SWIG 4
|
|
|
|
|
(fetchpatch2 {
|
|
|
|
|
url = "https://github.com/llvm/llvm-project/commit/ba35c27ec9aa9807f5b4be2a0c33ca9b045accc7.patch?full_index=1";
|
|
|
|
|
stripLen = 1;
|
|
|
|
|
hash = "sha256-LXl+WbpmWZww5xMDrle3BM2Tw56v8k9LO1f1Z1/wDTs=";
|
|
|
|
|
})
|
|
|
|
|
(fetchpatch2 {
|
|
|
|
|
url = "https://github.com/llvm/llvm-project/commit/9ec115978ea2bdfc60800cd3c21264341cdc8b0a.patch?full_index=1";
|
|
|
|
|
stripLen = 1;
|
|
|
|
|
hash = "sha256-u0zSejEjfrH3ZoMFm1j+NVv2t5AP9cE5yhsrdTS1dG4=";
|
|
|
|
|
})
|
|
|
|
|
|
2024-07-06 21:43:37 -07:00
|
|
|
|
# FIXME: do we need this after 15?
|
|
|
|
|
(metadata.getVersionFile "lldb/procfs.patch")
|
2024-09-12 11:20:59 +01:00
|
|
|
|
]
|
2025-01-14 21:33:03 -08:00
|
|
|
|
++ lib.optional (lib.versionOlder metadata.release_version "18") (fetchpatch {
|
|
|
|
|
name = "libcxx-19-char_traits.patch";
|
|
|
|
|
url = "https://github.com/llvm/llvm-project/commit/68744ffbdd7daac41da274eef9ac0d191e11c16d.patch";
|
|
|
|
|
stripLen = 1;
|
|
|
|
|
hash = "sha256-QCGhsL/mi7610ZNb5SqxjRGjwJeK2rwtsFVGeG3PUGc=";
|
|
|
|
|
})
|
2025-01-14 21:34:50 -08:00
|
|
|
|
++ lib.optionals (lib.versionOlder metadata.release_version "17") [
|
|
|
|
|
resourceDirPatch
|
|
|
|
|
(fetchpatch {
|
|
|
|
|
name = "add-cstdio.patch";
|
|
|
|
|
url = "https://github.com/llvm/llvm-project/commit/73e15b5edb4fa4a77e68c299a6e3b21e610d351f.patch";
|
|
|
|
|
stripLen = 1;
|
|
|
|
|
hash = "sha256-eFcvxZaAuBsY/bda1h9212QevrXyvCHw8Cr9ngetDr0=";
|
|
|
|
|
})
|
|
|
|
|
]
|
2024-07-06 21:43:37 -07:00
|
|
|
|
++ lib.optional (lib.versionOlder metadata.release_version "14") (
|
|
|
|
|
metadata.getVersionFile "lldb/gnu-install-dirs.patch"
|
|
|
|
|
)
|
2024-10-05 19:45:28 +01:00
|
|
|
|
++ lib.optional (lib.versionAtLeast metadata.release_version "14") ./lldb/gnu-install-dirs.patch;
|
2024-07-06 21:43:37 -07:00
|
|
|
|
}
|
|
|
|
|
// 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 && !stdenv.targetPlatform.isFreeBSD) [
|
|
|
|
|
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 && !stdenv.targetPlatform.isFreeBSD
|
|
|
|
|
) "--unwindlib=libunwind"
|
|
|
|
|
++ lib.optional (
|
|
|
|
|
!stdenv.targetPlatform.isWasm
|
|
|
|
|
&& !stdenv.targetPlatform.isFreeBSD
|
|
|
|
|
&& stdenv.targetPlatform.useLLVM or false
|
|
|
|
|
) "-lunwind"
|
|
|
|
|
++ lib.optional stdenv.targetPlatform.isWasm "-fno-exceptions";
|
Revert "llvmPackages.clangUseLLVM: add --undefined-version by default"
This reverts commit 019d0919383f5b28f0339020bb85fb291000bf54.
My comments from the PR (which I only saw after it was merged):
> I'm not convinced this is a good idea — compiler authors turn things
> into errors for a reason, and as a distribution we have our part to
> play in getting problematic things fixed. It's fine to disable the
> errors for packages where it's not reasonably possible to get them
> fixed, but doing it globally means even packages that would be
> simple to fix properly don't get fixed.
> To expand a bit, the problem with this sort of thing is that it's
> very difficult later to tell when it can be removed. By setting this
> globally instead of setting it for individual packages that need it,
> we're effectively stuck with it forever, because it's impossible to
> tell if removing it is going to break any packages. If we mark
> packages individually, it's very easy to tell in future when those
> markings can be removed.
>
> This isn't a theoretical concern: something similar was done for
> pkgsMusl — some compatibility headers were added globally, instead
> of fixing individual affected packages, and now, even though we've
> discovered that the presence of those headers actually causes
> problems for other packages, it's impossible to know what the
> fallout would be of removing it. Let's not repeat this mistake.
So let's revert now, before it's too late.
2024-09-02 17:35:20 +02:00
|
|
|
|
nixSupport.cc-ldflags = lib.optionals (
|
|
|
|
|
!stdenv.targetPlatform.isWasm && !stdenv.targetPlatform.isFreeBSD
|
|
|
|
|
) [ "-L${targetLlvmLibraries.libunwind}/lib" ];
|
2024-07-06 21:43:37 -07:00
|
|
|
|
}
|
|
|
|
|
);
|
|
|
|
|
|
2023-11-27 08:02:52 +02:00
|
|
|
|
clangWithLibcAndBasicRtAndLibcxx = wrapCCWith (
|
|
|
|
|
rec {
|
|
|
|
|
cc = tools.clang-unwrapped;
|
|
|
|
|
libcxx = targetLlvmLibraries.libcxx;
|
|
|
|
|
bintools = bintools';
|
|
|
|
|
extraPackages =
|
|
|
|
|
[ targetLlvmLibraries.compiler-rt-no-libc ]
|
2024-09-23 22:06:54 -04:00
|
|
|
|
++ lib.optionals
|
|
|
|
|
(
|
|
|
|
|
!stdenv.targetPlatform.isWasm && !stdenv.targetPlatform.isFreeBSD && !stdenv.targetPlatform.isDarwin
|
|
|
|
|
)
|
|
|
|
|
[
|
|
|
|
|
targetLlvmLibraries.libunwind
|
|
|
|
|
];
|
2023-11-27 08:02:52 +02:00
|
|
|
|
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-no-libc}/lib" >> $out/nix-support/cc-cflags
|
|
|
|
|
''
|
2024-09-23 22:06:54 -04:00
|
|
|
|
+ lib.optionalString (!stdenv.targetPlatform.isWasm && !stdenv.targetPlatform.isDarwin) ''
|
2023-11-27 08:02:52 +02:00
|
|
|
|
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
|
|
|
|
|
''
|
|
|
|
|
)
|
|
|
|
|
+ mkExtraBuildCommandsBasicRt cc;
|
|
|
|
|
}
|
|
|
|
|
// lib.optionalAttrs (lib.versionAtLeast metadata.release_version "14") {
|
|
|
|
|
nixSupport.cc-cflags =
|
|
|
|
|
[
|
|
|
|
|
"-rtlib=compiler-rt"
|
|
|
|
|
"-Wno-unused-command-line-argument"
|
|
|
|
|
"-B${targetLlvmLibraries.compiler-rt-no-libc}/lib"
|
|
|
|
|
]
|
|
|
|
|
++ lib.optional (
|
2024-09-23 22:06:54 -04:00
|
|
|
|
!stdenv.targetPlatform.isWasm && !stdenv.targetPlatform.isFreeBSD && !stdenv.targetPlatform.isDarwin
|
2023-11-27 08:02:52 +02:00
|
|
|
|
) "--unwindlib=libunwind"
|
|
|
|
|
++ lib.optional (
|
|
|
|
|
!stdenv.targetPlatform.isWasm
|
|
|
|
|
&& !stdenv.targetPlatform.isFreeBSD
|
|
|
|
|
&& stdenv.targetPlatform.useLLVM or false
|
|
|
|
|
) "-lunwind"
|
|
|
|
|
++ lib.optional stdenv.targetPlatform.isWasm "-fno-exceptions";
|
|
|
|
|
nixSupport.cc-ldflags = lib.optionals (
|
2024-09-23 22:06:54 -04:00
|
|
|
|
!stdenv.targetPlatform.isWasm && !stdenv.targetPlatform.isFreeBSD && !stdenv.targetPlatform.isDarwin
|
2023-11-27 08:02:52 +02:00
|
|
|
|
) [ "-L${targetLlvmLibraries.libunwind}/lib" ];
|
|
|
|
|
}
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
clangWithLibcAndBasicRt = wrapCCWith (
|
2024-07-06 21:43:37 -07:00
|
|
|
|
rec {
|
|
|
|
|
cc = tools.clang-unwrapped;
|
|
|
|
|
libcxx = null;
|
|
|
|
|
bintools = bintools';
|
2023-11-27 08:02:52 +02:00
|
|
|
|
extraPackages = [ targetLlvmLibraries.compiler-rt-no-libc ];
|
2024-07-06 21:43:37 -07:00
|
|
|
|
extraBuildCommands =
|
|
|
|
|
lib.optionalString (lib.versions.major metadata.release_version == "13") ''
|
|
|
|
|
echo "-rtlib=compiler-rt" >> $out/nix-support/cc-cflags
|
2023-11-27 08:02:52 +02:00
|
|
|
|
echo "-B${targetLlvmLibraries.compiler-rt-no-libc}/lib" >> $out/nix-support/cc-cflags
|
2024-07-06 21:43:37 -07:00
|
|
|
|
echo "-nostdlib++" >> $out/nix-support/cc-cflags
|
|
|
|
|
''
|
2023-11-27 08:02:52 +02:00
|
|
|
|
+ mkExtraBuildCommandsBasicRt cc;
|
2024-07-06 21:43:37 -07:00
|
|
|
|
}
|
|
|
|
|
// lib.optionalAttrs (lib.versionAtLeast metadata.release_version "14") {
|
|
|
|
|
nixSupport.cc-cflags =
|
|
|
|
|
[
|
|
|
|
|
"-rtlib=compiler-rt"
|
2023-11-27 08:02:52 +02:00
|
|
|
|
"-B${targetLlvmLibraries.compiler-rt-no-libc}/lib"
|
2024-07-06 21:43:37 -07:00
|
|
|
|
"-nostdlib++"
|
|
|
|
|
]
|
|
|
|
|
++ lib.optional (
|
|
|
|
|
lib.versionAtLeast metadata.release_version "15" && stdenv.targetPlatform.isWasm
|
|
|
|
|
) "-fno-exceptions";
|
|
|
|
|
}
|
|
|
|
|
);
|
|
|
|
|
|
2023-11-27 08:02:52 +02:00
|
|
|
|
clangNoLibcWithBasicRt = wrapCCWith (
|
2024-07-06 21:43:37 -07:00
|
|
|
|
rec {
|
|
|
|
|
cc = tools.clang-unwrapped;
|
|
|
|
|
libcxx = null;
|
|
|
|
|
bintools = bintoolsNoLibc';
|
2023-11-27 08:02:52 +02:00
|
|
|
|
extraPackages = [ targetLlvmLibraries.compiler-rt-no-libc ];
|
2024-07-06 21:43:37 -07:00
|
|
|
|
extraBuildCommands =
|
|
|
|
|
lib.optionalString (lib.versions.major metadata.release_version == "13") ''
|
|
|
|
|
echo "-rtlib=compiler-rt" >> $out/nix-support/cc-cflags
|
2023-11-27 08:02:52 +02:00
|
|
|
|
echo "-B${targetLlvmLibraries.compiler-rt-no-libc}/lib" >> $out/nix-support/cc-cflags
|
2024-07-06 21:43:37 -07:00
|
|
|
|
''
|
2023-11-27 08:02:52 +02:00
|
|
|
|
+ mkExtraBuildCommandsBasicRt cc;
|
2024-07-06 21:43:37 -07:00
|
|
|
|
}
|
|
|
|
|
// lib.optionalAttrs (lib.versionAtLeast metadata.release_version "14") {
|
|
|
|
|
nixSupport.cc-cflags =
|
|
|
|
|
[
|
|
|
|
|
"-rtlib=compiler-rt"
|
2023-11-27 08:02:52 +02:00
|
|
|
|
"-B${targetLlvmLibraries.compiler-rt-no-libc}/lib"
|
2024-07-06 21:43:37 -07:00
|
|
|
|
]
|
|
|
|
|
++ lib.optional (
|
|
|
|
|
lib.versionAtLeast metadata.release_version "15" && stdenv.targetPlatform.isWasm
|
|
|
|
|
) "-fno-exceptions";
|
|
|
|
|
}
|
|
|
|
|
);
|
|
|
|
|
|
2023-11-27 08:02:52 +02:00
|
|
|
|
clangNoLibcNoRt = wrapCCWith (
|
2024-07-06 21:43:37 -07:00
|
|
|
|
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";
|
|
|
|
|
}
|
|
|
|
|
);
|
|
|
|
|
|
2023-11-27 08:02:52 +02:00
|
|
|
|
# This is an "oddly ordered" bootstrap just for Darwin. Probably
|
|
|
|
|
# don't want it otherwise.
|
2024-07-06 21:43:37 -07:00
|
|
|
|
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" ]; };
|
2023-11-27 08:02:52 +02:00
|
|
|
|
|
|
|
|
|
# Aliases
|
|
|
|
|
clangNoCompilerRt = tools.clangNoLibcNoRt;
|
|
|
|
|
clangNoLibc = tools.clangNoLibcWithBasicRt;
|
|
|
|
|
clangNoLibcxx = tools.clangWithLibcAndBasicRt;
|
2024-07-06 21:43:37 -07:00
|
|
|
|
}
|
|
|
|
|
// 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 { };
|
|
|
|
|
}
|
2024-03-02 22:08:04 +08:00
|
|
|
|
// lib.optionalAttrs (lib.versionAtLeast metadata.release_version "19") {
|
|
|
|
|
bolt = callPackage ./bolt {
|
|
|
|
|
patches = lib.optionals (lib.versions.major metadata.release_version == "19") [
|
|
|
|
|
(fetchpatch {
|
|
|
|
|
url = "https://github.com/llvm/llvm-project/commit/abc2eae68290c453e1899a94eccc4ed5ea3b69c1.patch";
|
|
|
|
|
hash = "sha256-oxCxOjhi5BhNBEraWalEwa1rS3Mx9CuQgRVZ2hrbd7M=";
|
|
|
|
|
})
|
2024-11-05 22:49:32 -08:00
|
|
|
|
(fetchpatch {
|
|
|
|
|
url = "https://github.com/llvm/llvm-project/commit/5909979869edca359bcbca74042c2939d900680e.patch";
|
|
|
|
|
hash = "sha256-l4rQHYbblEADBXaZIdqTG0sZzH4fEQvYiqhLYNZDMa8=";
|
|
|
|
|
})
|
2024-03-02 22:08:04 +08:00
|
|
|
|
];
|
|
|
|
|
};
|
|
|
|
|
}
|
2024-07-06 21:43:37 -07:00
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
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 =
|
2024-10-12 18:31:24 +02:00
|
|
|
|
lib.optional (lib.versionOlder metadata.release_version "15") (
|
|
|
|
|
metadata.getVersionFile "compiler-rt/codesign.patch"
|
|
|
|
|
) # Revert compiler-rt commit that makes codesign mandatory
|
2024-07-06 21:43:37 -07:00
|
|
|
|
++ [
|
|
|
|
|
(metadata.getVersionFile "compiler-rt/X86-support-extension.patch") # Add support for i486 i586 i686 by reusing i386 config
|
|
|
|
|
]
|
2024-11-17 13:38:00 -08:00
|
|
|
|
++ lib.optional (lib.versions.major metadata.release_version == "12") (fetchpatch {
|
|
|
|
|
# fixes the parallel build on aarch64 darwin
|
|
|
|
|
name = "fix-symlink-race-aarch64-darwin.patch";
|
|
|
|
|
url = "https://github.com/llvm/llvm-project/commit/b31080c596246bc26d2493cfd5e07f053cf9541c.patch";
|
|
|
|
|
relative = "compiler-rt";
|
|
|
|
|
hash = "sha256-Cv2NC8402yU7QaTR6TzdH+qyWRy+tTote7KKWtKRWFQ=";
|
|
|
|
|
})
|
2024-07-06 21:43:37 -07:00
|
|
|
|
++ lib.optional (
|
2024-10-06 00:32:56 +02:00
|
|
|
|
lib.versions.major metadata.release_version == "12"
|
|
|
|
|
|| (
|
|
|
|
|
lib.versionAtLeast metadata.release_version "14" && lib.versionOlder metadata.release_version "18"
|
|
|
|
|
)
|
2024-07-06 21:43:37 -07:00
|
|
|
|
) (metadata.getVersionFile "compiler-rt/gnu-install-dirs.patch")
|
2024-11-05 22:00:19 -08:00
|
|
|
|
++
|
|
|
|
|
lib.optional
|
|
|
|
|
(lib.versionAtLeast metadata.release_version "13" && lib.versionOlder metadata.release_version "18")
|
|
|
|
|
(fetchpatch {
|
|
|
|
|
name = "cfi_startproc-after-label.patch";
|
|
|
|
|
url = "https://github.com/llvm/llvm-project/commit/7939ce39dac0078fef7183d6198598b99c652c88.patch";
|
|
|
|
|
stripLen = 1;
|
|
|
|
|
hash = "sha256-tGqXsYvUllFrPa/r/dsKVlwx5IrcJGccuR1WAtUg7/o=";
|
|
|
|
|
})
|
2024-07-06 21:43:37 -07:00
|
|
|
|
++ [
|
|
|
|
|
# ld-wrapper dislikes `-rpath-link //nix/store`, so we normalize away the
|
|
|
|
|
# extra `/`.
|
|
|
|
|
(metadata.getVersionFile "compiler-rt/normalize-var.patch")
|
|
|
|
|
]
|
|
|
|
|
++
|
2024-10-06 00:32:56 +02:00
|
|
|
|
lib.optional
|
|
|
|
|
(lib.versionAtLeast metadata.release_version "13" && lib.versionOlder metadata.release_version "18")
|
2024-07-06 21:43:37 -07:00
|
|
|
|
# Prevent a compilation error on darwin
|
|
|
|
|
(metadata.getVersionFile "compiler-rt/darwin-targetconditionals.patch")
|
2024-10-06 00:32:56 +02:00
|
|
|
|
# TODO: make unconditional and remove in <15 section below. Causes rebuilds.
|
2024-08-11 12:00:00 +00:00
|
|
|
|
++ lib.optionals (lib.versionAtLeast metadata.release_version "15") [
|
|
|
|
|
# See: https://github.com/NixOS/nixpkgs/pull/186575
|
|
|
|
|
./compiler-rt/darwin-plistbuddy-workaround.patch
|
|
|
|
|
]
|
2024-07-06 21:43:37 -07:00
|
|
|
|
++
|
|
|
|
|
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
|
2024-08-11 12:00:00 +00:00
|
|
|
|
]
|
2024-10-06 00:32:56 +02:00
|
|
|
|
++
|
|
|
|
|
lib.optionals
|
|
|
|
|
(lib.versionAtLeast metadata.release_version "13" && lib.versionOlder metadata.release_version "18")
|
|
|
|
|
[
|
|
|
|
|
# Fix build on armv6l
|
|
|
|
|
./compiler-rt/armv6-scudo-no-yield.patch
|
|
|
|
|
]
|
2024-08-11 12:00:00 +00:00
|
|
|
|
++ [
|
|
|
|
|
# Fix build on armv6l
|
|
|
|
|
./compiler-rt/armv6-no-ldrexd-strexd.patch
|
2024-10-06 00:32:56 +02:00
|
|
|
|
]
|
|
|
|
|
++ lib.optionals (lib.versionAtLeast metadata.release_version "13") [
|
2024-08-11 12:00:00 +00:00
|
|
|
|
(metadata.getVersionFile "compiler-rt/armv6-scudo-libatomic.patch")
|
2024-07-21 21:28:35 -07:00
|
|
|
|
]
|
2025-01-25 15:00:13 +00:00
|
|
|
|
++ lib.optional (lib.versions.major metadata.release_version == "19") (fetchpatch {
|
2024-08-03 23:07:14 -07:00
|
|
|
|
url = "https://github.com/llvm/llvm-project/pull/99837/commits/14ae0a660a38e1feb151928a14f35ff0f4487351.patch";
|
|
|
|
|
hash = "sha256-JykABCaNNhYhZQxCvKiBn54DZ5ZguksgCHnpdwWF2no=";
|
|
|
|
|
relative = "compiler-rt";
|
2025-02-07 14:35:28 -08:00
|
|
|
|
});
|
2024-07-06 21:43:37 -07:00
|
|
|
|
in
|
2024-12-08 19:56:12 -08:00
|
|
|
|
(
|
|
|
|
|
{
|
|
|
|
|
compiler-rt-libc = callPackage ./compiler-rt (
|
|
|
|
|
let
|
|
|
|
|
# temp rename to avoid infinite recursion
|
|
|
|
|
stdenv =
|
|
|
|
|
# Darwin needs to use a bootstrap stdenv to avoid an infinite recursion when cross-compiling.
|
|
|
|
|
if args.stdenv.hostPlatform.isDarwin then
|
|
|
|
|
overrideCC darwin.bootstrapStdenv buildLlvmTools.clangWithLibcAndBasicRtAndLibcxx
|
|
|
|
|
else if args.stdenv.hostPlatform.useLLVM or false then
|
|
|
|
|
overrideCC args.stdenv buildLlvmTools.clangWithLibcAndBasicRtAndLibcxx
|
|
|
|
|
else
|
|
|
|
|
args.stdenv;
|
|
|
|
|
in
|
|
|
|
|
{
|
|
|
|
|
patches = compiler-rtPatches;
|
|
|
|
|
inherit stdenv;
|
|
|
|
|
}
|
|
|
|
|
// lib.optionalAttrs (stdenv.hostPlatform.useLLVM or false) {
|
|
|
|
|
libxcrypt = (libxcrypt.override { inherit stdenv; }).overrideAttrs (old: {
|
|
|
|
|
configureFlags = old.configureFlags ++ [ "--disable-symvers" ];
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
compiler-rt-no-libc = callPackage ./compiler-rt {
|
|
|
|
|
patches = compiler-rtPatches;
|
|
|
|
|
doFakeLibgcc = stdenv.hostPlatform.useLLVM or false;
|
2023-11-27 08:02:52 +02:00
|
|
|
|
stdenv =
|
2024-09-23 22:06:54 -04:00
|
|
|
|
# Darwin needs to use a bootstrap stdenv to avoid an infinite recursion when cross-compiling.
|
2024-12-08 19:56:12 -08:00
|
|
|
|
if stdenv.hostPlatform.isDarwin then
|
|
|
|
|
overrideCC darwin.bootstrapStdenv buildLlvmTools.clangNoLibcNoRt
|
2023-11-27 08:02:52 +02:00
|
|
|
|
else
|
2024-12-08 19:56:12 -08:00
|
|
|
|
overrideCC stdenv buildLlvmTools.clangNoLibcNoRt;
|
|
|
|
|
};
|
2024-07-06 21:43:37 -07:00
|
|
|
|
|
2024-12-08 19:56:12 -08:00
|
|
|
|
compiler-rt =
|
|
|
|
|
if
|
|
|
|
|
stdenv.hostPlatform.libc == null
|
|
|
|
|
# Building the with-libc compiler-rt and WASM doesn't yet work,
|
|
|
|
|
# because wasilibc doesn't provide some expected things. See
|
|
|
|
|
# compiler-rt's file for further details.
|
|
|
|
|
|| stdenv.hostPlatform.isWasm
|
|
|
|
|
# Failing `#include <term.h>` in
|
|
|
|
|
# `lib/sanitizer_common/sanitizer_platform_limits_freebsd.cpp`
|
|
|
|
|
# sanitizers, not sure where to get it.
|
|
|
|
|
|| stdenv.hostPlatform.isFreeBSD
|
|
|
|
|
then
|
|
|
|
|
libraries.compiler-rt-no-libc
|
2024-07-06 21:43:37 -07:00
|
|
|
|
else
|
2024-12-08 19:56:12 -08:00
|
|
|
|
libraries.compiler-rt-libc;
|
2024-07-06 21:43:37 -07:00
|
|
|
|
|
2024-12-08 19:56:12 -08:00
|
|
|
|
stdenv = overrideCC stdenv buildLlvmTools.clang;
|
2024-07-06 21:43:37 -07:00
|
|
|
|
|
2024-12-08 19:56:12 -08:00
|
|
|
|
libcxxStdenv = overrideCC stdenv buildLlvmTools.libcxxClang;
|
2024-07-06 21:43:37 -07:00
|
|
|
|
|
2024-12-08 19:56:12 -08:00
|
|
|
|
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;
|
|
|
|
|
substitutions = [
|
|
|
|
|
"--replace-fail"
|
|
|
|
|
"/cmake/"
|
|
|
|
|
"/llvm/cmake/"
|
|
|
|
|
];
|
|
|
|
|
})
|
|
|
|
|
]
|
|
|
|
|
++ lib.optional stdenv.hostPlatform.isMusl (substitute {
|
|
|
|
|
src = ./libcxx/libcxx-0001-musl-hacks.patch;
|
2024-07-06 21:43:37 -07:00
|
|
|
|
substitutions = [
|
|
|
|
|
"--replace-fail"
|
2024-12-08 19:56:12 -08:00
|
|
|
|
"/include/"
|
|
|
|
|
"/libcxx/include/"
|
2024-07-06 21:43:37 -07:00
|
|
|
|
];
|
|
|
|
|
})
|
2024-12-08 19:56:12 -08:00
|
|
|
|
);
|
|
|
|
|
stdenv =
|
|
|
|
|
if stdenv.hostPlatform.isDarwin then
|
|
|
|
|
overrideCC darwin.bootstrapStdenv buildLlvmTools.clangWithLibcAndBasicRt
|
|
|
|
|
else
|
|
|
|
|
overrideCC stdenv buildLlvmTools.clangWithLibcAndBasicRt;
|
|
|
|
|
}
|
|
|
|
|
// 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"
|
2024-10-05 19:45:28 +01:00
|
|
|
|
);
|
2024-12-08 19:56:12 -08:00
|
|
|
|
stdenv = overrideCC stdenv buildLlvmTools.clangWithLibcAndBasicRt;
|
|
|
|
|
};
|
2024-07-06 21:43:37 -07:00
|
|
|
|
|
2024-12-08 19:56:12 -08:00
|
|
|
|
openmp = callPackage ./openmp {
|
|
|
|
|
patches =
|
|
|
|
|
lib.optional (
|
|
|
|
|
lib.versionAtLeast metadata.release_version "15" && lib.versionOlder metadata.release_version "19"
|
|
|
|
|
) (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=";
|
|
|
|
|
}
|
|
|
|
|
);
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
// lib.optionalAttrs (lib.versionAtLeast metadata.release_version "20") {
|
|
|
|
|
libc-overlay = callPackage ./libc {
|
|
|
|
|
isFullBuild = false;
|
2025-02-10 20:30:09 -08:00
|
|
|
|
# Use clang due to "gnu::naked" not working on aarch64.
|
|
|
|
|
# Issue: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=77882
|
|
|
|
|
stdenv = overrideCC stdenv buildLlvmTools.clang;
|
2024-12-08 19:56:12 -08:00
|
|
|
|
};
|
2024-07-06 21:43:37 -07:00
|
|
|
|
|
2024-12-08 19:56:12 -08:00
|
|
|
|
libc-full = callPackage ./libc {
|
|
|
|
|
isFullBuild = true;
|
2025-02-10 20:30:09 -08:00
|
|
|
|
# Use clang due to "gnu::naked" not working on aarch64.
|
|
|
|
|
# Issue: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=77882
|
|
|
|
|
stdenv = overrideCC stdenv buildLlvmTools.clangNoLibcNoRt;
|
2024-12-08 19:56:12 -08:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
libc = if stdenv.targetPlatform.libc == "llvm" then libraries.libc-full else libraries.libc-overlay;
|
|
|
|
|
}
|
|
|
|
|
)
|
2024-07-06 21:43:37 -07:00
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
noExtend = extensible: lib.attrsets.removeAttrs extensible [ "extend" ];
|
|
|
|
|
in
|
|
|
|
|
{
|
2024-12-18 18:00:15 -08:00
|
|
|
|
inherit tools libraries;
|
2024-07-06 21:43:37 -07:00
|
|
|
|
inherit (metadata) release_version;
|
|
|
|
|
}
|
|
|
|
|
// (noExtend libraries)
|
|
|
|
|
// (noExtend tools)
|