From 6011c500108d82fd6465a7d04c64a259cd43ee39 Mon Sep 17 00:00:00 2001 From: Randy Eckenrode Date: Sun, 7 Apr 2024 22:36:45 -0400 Subject: [PATCH] llvmPackages_{12,13,14,15,16,17,18,git}.clang: fix libLTO.dylib path MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Clang assumes that `libLTO.dylib` is located at `../lib` in the same prefix as `clang`, but that’s not true in nixpkgs. `libLTO.dylib` is actually located at `libllvm^lib/lib.libLTO.dylib`. --- pkgs/development/compilers/llvm/common/clang/default.nix | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/pkgs/development/compilers/llvm/common/clang/default.nix b/pkgs/development/compilers/llvm/common/clang/default.nix index 2373795b49fd8..58af0340a1399 100644 --- a/pkgs/development/compilers/llvm/common/clang/default.nix +++ b/pkgs/development/compilers/llvm/common/clang/default.nix @@ -71,7 +71,11 @@ let "-DCLANG_PSEUDO_GEN=${buildLlvmTools.libclang.dev}/bin/clang-pseudo-gen" ]); - postPatch = (if lib.versionOlder release_version "13" then '' + postPatch = '' + # Make sure clang passes the correct location of libLTO to ld64 + substituteInPlace lib/Driver/ToolChains/Darwin.cpp \ + --replace-fail 'StringRef P = llvm::sys::path::parent_path(D.Dir);' 'StringRef P = "${lib.getLib libllvm}";' + '' + (if lib.versionOlder release_version "13" then '' sed -i -e 's/DriverArgs.hasArg(options::OPT_nostdlibinc)/true/' \ -e 's/Args.hasArg(options::OPT_nostdlibinc)/true/' \ lib/Driver/ToolChains/*.cpp