From 44165d3657676d19a9e46d1b773ec740582223c6 Mon Sep 17 00:00:00 2001 From: Jyun-Yan You Date: Thu, 29 Sep 2022 23:08:22 +0800 Subject: [PATCH] llvmPackages_{14, git}.clang: add nostdlibinc flag Fix header search paths as #153963 --- .../llvm/14/clang/add-nostdlibinc-flag.patch | 18 ++++++++++++++++++ .../compilers/llvm/14/clang/default.nix | 5 +---- .../llvm/git/clang/add-nostdlibinc-flag.patch | 18 ++++++++++++++++++ .../compilers/llvm/git/clang/default.nix | 5 +---- 4 files changed, 38 insertions(+), 8 deletions(-) create mode 100644 pkgs/development/compilers/llvm/14/clang/add-nostdlibinc-flag.patch create mode 100644 pkgs/development/compilers/llvm/git/clang/add-nostdlibinc-flag.patch diff --git a/pkgs/development/compilers/llvm/14/clang/add-nostdlibinc-flag.patch b/pkgs/development/compilers/llvm/14/clang/add-nostdlibinc-flag.patch new file mode 100644 index 0000000000000..b73cd0185eb6c --- /dev/null +++ b/pkgs/development/compilers/llvm/14/clang/add-nostdlibinc-flag.patch @@ -0,0 +1,18 @@ +diff --git a/lib/Driver/Driver.cpp b/lib/Driver/Driver.cpp +index 3bfddeefc7b2..05b11d9e562d 100644 +--- a/lib/Driver/Driver.cpp ++++ b/lib/Driver/Driver.cpp +@@ -482,6 +482,13 @@ DerivedArgList *Driver::TranslateInputArgs(const InputArgList &Args) const { + } + #endif + ++ { ++ Arg *A = DAL->MakeFlagArg(/*BaseArg=*/nullptr, ++ Opts.getOption(options::OPT_nostdlibinc)); ++ A->claim(); ++ DAL->append(A); ++ } ++ + return DAL; + } + diff --git a/pkgs/development/compilers/llvm/14/clang/default.nix b/pkgs/development/compilers/llvm/14/clang/default.nix index 5ff02d68de426..6b775efcc039d 100644 --- a/pkgs/development/compilers/llvm/14/clang/default.nix +++ b/pkgs/development/compilers/llvm/14/clang/default.nix @@ -45,6 +45,7 @@ let ./purity.patch # https://reviews.llvm.org/D51899 ./gnu-install-dirs.patch + ./add-nostdlibinc-flag.patch (substituteAll { src = ../../clang-11-12-LLVMgold-path.patch; libllvmLibdir = "${libllvm.lib}/lib"; @@ -54,10 +55,6 @@ let postPatch = '' (cd tools && ln -s ../../clang-tools-extra extra) - sed -i -e 's/DriverArgs.hasArg(options::OPT_nostdlibinc)/true/' \ - -e 's/Args.hasArg(options::OPT_nostdlibinc)/true/' \ - lib/Driver/ToolChains/*.cpp - # Patch for standalone doc building sed -i '1s,^,find_package(Sphinx REQUIRED)\n,' docs/CMakeLists.txt '' + lib.optionalString stdenv.hostPlatform.isMusl '' diff --git a/pkgs/development/compilers/llvm/git/clang/add-nostdlibinc-flag.patch b/pkgs/development/compilers/llvm/git/clang/add-nostdlibinc-flag.patch new file mode 100644 index 0000000000000..80c2eb3623832 --- /dev/null +++ b/pkgs/development/compilers/llvm/git/clang/add-nostdlibinc-flag.patch @@ -0,0 +1,18 @@ +diff --git a/lib/Driver/Driver.cpp b/lib/Driver/Driver.cpp +index 3f29afd35971..223d2769cdfc 100644 +--- a/lib/Driver/Driver.cpp ++++ b/lib/Driver/Driver.cpp +@@ -491,6 +491,13 @@ DerivedArgList *Driver::TranslateInputArgs(const InputArgList &Args) const { + } + #endif + ++ { ++ Arg *A = DAL->MakeFlagArg(/*BaseArg=*/nullptr, ++ Opts.getOption(options::OPT_nostdlibinc)); ++ A->claim(); ++ DAL->append(A); ++ } ++ + return DAL; + } + diff --git a/pkgs/development/compilers/llvm/git/clang/default.nix b/pkgs/development/compilers/llvm/git/clang/default.nix index 3110bef09e969..3df0e5042b8dc 100644 --- a/pkgs/development/compilers/llvm/git/clang/default.nix +++ b/pkgs/development/compilers/llvm/git/clang/default.nix @@ -46,6 +46,7 @@ let ./purity.patch # https://reviews.llvm.org/D51899 ./gnu-install-dirs.patch + ./add-nostdlibinc-flag.patch (substituteAll { src = ../../clang-11-12-LLVMgold-path.patch; libllvmLibdir = "${libllvm.lib}/lib"; @@ -55,10 +56,6 @@ let postPatch = '' (cd tools && ln -s ../../clang-tools-extra extra) - sed -i -e 's/DriverArgs.hasArg(options::OPT_nostdlibinc)/true/' \ - -e 's/Args.hasArg(options::OPT_nostdlibinc)/true/' \ - lib/Driver/ToolChains/*.cpp - # Patch for standalone doc building sed -i '1s,^,find_package(Sphinx REQUIRED)\n,' docs/CMakeLists.txt '' + lib.optionalString stdenv.hostPlatform.isMusl ''