From e6a4c83d20d7e8ae3866f751becb1f40ec7916b3 Mon Sep 17 00:00:00 2001 From: Randy Eckenrode Date: Mon, 23 Sep 2024 21:19:20 -0400 Subject: [PATCH] llvmPackages.compiler-rt: fix compiler-rt bootstrap on Darwin MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The first build of compiler-rt in the LLVM bootstrap is build without libc++ being available, which causes support for the `-g` flag to be detected incorrectly on Darwin. Overriding the check by specifying that it’s usable allows the first build of compiler-rt to succeed. --- .../compilers/llvm/common/compiler-rt/default.nix | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/pkgs/development/compilers/llvm/common/compiler-rt/default.nix b/pkgs/development/compilers/llvm/common/compiler-rt/default.nix index dad5c504f08a..8a2cec518033 100644 --- a/pkgs/development/compilers/llvm/common/compiler-rt/default.nix +++ b/pkgs/development/compilers/llvm/common/compiler-rt/default.nix @@ -136,6 +136,11 @@ stdenv.mkDerivation ({ "-DCOMPILER_RT_OS_DIR=baremetal" ] ++ lib.optionals (stdenv.hostPlatform.isDarwin) (lib.optionals (lib.versionAtLeast release_version "16") [ "-DCMAKE_LIPO=${lib.getBin stdenv.cc.bintools.bintools}/bin/${stdenv.cc.targetPrefix}lipo" + ] ++ lib.optionals (!haveLibcxx) [ + # Darwin fails to detect that the compiler supports the `-g` flag when there is no libc++ during the + # compiler-rt bootstrap, which prevents compiler-rt from building. The `-g` flag is required by the + # Darwin support, so force it to be enabled during the first stage of the compiler-rt bootstrap. + "-DCOMPILER_RT_HAS_G_FLAG=ON" ] ++ [ "-DDARWIN_macosx_CACHED_SYSROOT=${apple-sdk'.sdkroot}" "-DDARWIN_macosx_OVERRIDE_SDK_VERSION=${lib.versions.majorMinor (lib.getVersion apple-sdk)}"