From d3114e05d777039ae04a9c39ce798140ccb81ed9 Mon Sep 17 00:00:00 2001 From: Randy Eckenrode Date: Mon, 23 Sep 2024 22:06:54 -0400 Subject: [PATCH] llvmPackages.compiler-rt: align Darwin bootstrap with other platforms Instead of using overrides in the stdenv bootstrap, Darwin will be relying on the LLVM bootstrap to build compiler-rt. The only special handling it needs is to use a stdenv with a bootstrap SDK instead of the default one (to avoid infinite recursions). --- .../compilers/llvm/common/default.nix | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/pkgs/development/compilers/llvm/common/default.nix b/pkgs/development/compilers/llvm/common/default.nix index c863d0d8a82a..35525e379f2b 100644 --- a/pkgs/development/compilers/llvm/common/default.nix +++ b/pkgs/development/compilers/llvm/common/default.nix @@ -1012,14 +1012,11 @@ let let # temp rename to avoid infinite recursion stdenv = - if args.stdenv.hostPlatform.useLLVM or false then + # 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 if - lib.versionAtLeast metadata.release_version "16" - && args.stdenv.hostPlatform.isDarwin - && args.stdenv.hostPlatform.isStatic - then - overrideCC args.stdenv buildLlvmTools.clangNoCompilerRtWithLibc else args.stdenv; in @@ -1038,10 +1035,10 @@ let patches = compiler-rtPatches; doFakeLibgcc = stdenv.hostPlatform.useLLVM or false; stdenv = - if stdenv.hostPlatform.isDarwin && stdenv.hostPlatform == stdenv.buildPlatform then - stdenv + # Darwin needs to use a bootstrap stdenv to avoid an infinite recursion when cross-compiling. + if stdenv.hostPlatform.isDarwin then + overrideCC darwin.bootstrapStdenv buildLlvmTools.clangNoLibcNoRt else - # TODO: make this branch unconditional next rebuild overrideCC stdenv buildLlvmTools.clangNoLibcNoRt; };