From f30f8ee969e6a395da091e7a8053e779b39686ff Mon Sep 17 00:00:00 2001 From: sternenseemann Date: Sat, 12 Oct 2024 18:36:45 +0200 Subject: [PATCH] llvmPackages_12.clang: use nostdlibinc patch instead of sed command Seems like the patch we've written for LLVM 13 and above also works for LLVM 12 which seems a little more robust. (cherry picked from commit 37437849deb116c22c01191f5ecbef2c7b30f1f7) --- .../compilers/llvm/common/clang/default.nix | 12 +----------- pkgs/development/compilers/llvm/common/default.nix | 4 +--- 2 files changed, 2 insertions(+), 14 deletions(-) diff --git a/pkgs/development/compilers/llvm/common/clang/default.nix b/pkgs/development/compilers/llvm/common/clang/default.nix index f842e11530e2..44e13c48fd4b 100644 --- a/pkgs/development/compilers/llvm/common/clang/default.nix +++ b/pkgs/development/compilers/llvm/common/clang/default.nix @@ -78,17 +78,7 @@ let substituteInPlace lib/Driver/ToolChains/Darwin.cpp \ --replace-fail 'StringRef P = llvm::sys::path::parent_path(D.Dir);' 'StringRef P = "${lib.getLib libllvm}";' (cd tools && ln -s ../../clang-tools-extra extra) - '' + lib.optionalString ( - lib.versionOlder release_version "13" - # See the comment on the `add-nostdlibinc-flag.patch` patch in - # `../default.nix` for why we skip Darwin here. - && (!stdenv.hostPlatform.isDarwin || !stdenv.targetPlatform.isDarwin - ) '' - sed -i -e 's/DriverArgs.hasArg(options::OPT_nostdlibinc)/true/' \ - -e 's/Args.hasArg(options::OPT_nostdlibinc)/true/' \ - lib/Driver/ToolChains/*.cpp - '' - + lib.optionalString (lib.versionOlder release_version "13") '' + '' + lib.optionalString (lib.versionOlder release_version "13") '' substituteInPlace tools/extra/clangd/quality/CompletionModel.cmake \ --replace ' ''${CMAKE_SOURCE_DIR}/../clang-tools-extra' ' ''${CMAKE_SOURCE_DIR}/tools/extra' '' diff --git a/pkgs/development/compilers/llvm/common/default.nix b/pkgs/development/compilers/llvm/common/default.nix index 8349e506c666..fa1f61bfd5d1 100644 --- a/pkgs/development/compilers/llvm/common/default.nix +++ b/pkgs/development/compilers/llvm/common/default.nix @@ -555,9 +555,7 @@ let # compilers breaking libclang when we can do Linux‐to‐Darwin # cross‐compilation again. ++ lib.optional ( - # TODO: This also applies for clang == 12, do we need it? - lib.versionAtLeast metadata.release_version "13" && - (!args.stdenv.hostPlatform.isDarwin || !args.stdenv.targetPlatform.isDarwin) + !args.stdenv.hostPlatform.isDarwin || !args.stdenv.targetPlatform.isDarwin ) ./clang/add-nostdlibinc-flag.patch ++ [ (substituteAll {