llvmPackages.libc: use clang by default (#381065)

This commit is contained in:
Tristan Ross
2025-02-11 18:53:52 -08:00
committed by GitHub
2 changed files with 23 additions and 14 deletions
@@ -1221,10 +1221,16 @@ let
// lib.optionalAttrs (lib.versionAtLeast metadata.release_version "20") {
libc-overlay = callPackage ./libc {
isFullBuild = false;
# 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;
};
libc-full = callPackage ./libc {
isFullBuild = true;
# 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;
};
libc = if stdenv.targetPlatform.libc == "llvm" then libraries.libc-full else libraries.libc-overlay;
@@ -14,6 +14,7 @@
ninja,
isFullBuild ? true,
linuxHeaders,
fetchpatch,
}:
let
pname = "libc";
@@ -25,26 +26,28 @@ let
cp -r ${monorepoSrc}/llvm "$out"
cp -r ${monorepoSrc}/${pname} "$out"
'');
stdenv' =
if stdenv.cc.isClang then
stdenv.override {
cc = stdenv.cc.override {
nixSupport = stdenv.cc.nixSupport // {
cc-cflags = lib.remove "-lunwind" (stdenv.cc.nixSupport.cc-cflags or [ ]);
};
};
}
else
stdenv;
in
stdenv'.mkDerivation (finalAttrs: {
inherit pname version patches;
stdenv.mkDerivation (finalAttrs: {
inherit pname version;
src = src';
sourceRoot = "${finalAttrs.src.name}/runtimes";
patches =
lib.optional (lib.versions.major version == "20")
# Removes invalid token from the LLVM version being placed in the namespace.
# Can be removed when LLVM 20 bumps to rc2.
# PR: https://github.com/llvm/llvm-project/pull/126284
(
fetchpatch {
url = "https://github.com/llvm/llvm-project/commit/3a3a3230d171e11842a9940b6da0f72022b1c5b3.patch";
stripLen = 1;
hash = "sha256-QiU1cWp+027ZZNVdvfGVwbIoRd9jqtSbftGsmaW1gig=";
}
)
++ patches;
nativeBuildInputs =
[
cmake