From f14a4d60b74625547ba7fc0572e42e9b61c0e54f Mon Sep 17 00:00:00 2001 From: Matthew Bauer Date: Mon, 27 Jan 2020 23:24:35 -0500 Subject: [PATCH] Revert "clang_7,clang_8,clang_9: fix compilation of HIP-code" This reverts commit 558af6fbc7c15f472658339668113f4d5c6440e0. This was meant for staging. Will apply there. --- .../llvm/7/clang/HIP-use-PATH-7.patch | 68 ---------------- .../compilers/llvm/7/clang/default.nix | 10 +-- pkgs/development/compilers/llvm/7/default.nix | 1 - .../llvm/8/clang/HIP-use-PATH-8.patch | 80 ------------------- .../compilers/llvm/8/clang/default.nix | 6 +- pkgs/development/compilers/llvm/8/default.nix | 1 - .../llvm/9/clang/HIP-use-PATH-9.patch | 80 ------------------- .../compilers/llvm/9/clang/default.nix | 6 +- pkgs/development/compilers/llvm/9/default.nix | 1 - 9 files changed, 7 insertions(+), 246 deletions(-) delete mode 100644 pkgs/development/compilers/llvm/7/clang/HIP-use-PATH-7.patch delete mode 100644 pkgs/development/compilers/llvm/8/clang/HIP-use-PATH-8.patch delete mode 100644 pkgs/development/compilers/llvm/9/clang/HIP-use-PATH-9.patch diff --git a/pkgs/development/compilers/llvm/7/clang/HIP-use-PATH-7.patch b/pkgs/development/compilers/llvm/7/clang/HIP-use-PATH-7.patch deleted file mode 100644 index 764dddd966c..00000000000 --- a/pkgs/development/compilers/llvm/7/clang/HIP-use-PATH-7.patch +++ /dev/null @@ -1,68 +0,0 @@ -From 8412cba68835f8f4cc527d02194b181faa5944d4 Mon Sep 17 00:00:00 2001 -From: =?UTF-8?q?Holger=20W=C3=BCnsche?= -Date: Tue, 21 Jan 2020 19:46:09 +0100 -Subject: [PATCH] [HIP] use GetProgramPath for executable discovery - -This change replaces the manual building of executable paths -using llvm::sys::path::append with GetProgramPath. -This enables adding other paths in case executables reside -in different directories and makes the code easier to read. - -Differential Revision: https://reviews.llvm.org/D72903 ---- - clang/lib/Driver/ToolChains/HIP.cpp | 18 ++++++------------ - 1 file changed, 6 insertions(+), 12 deletions(-) - -diff --git a/lib/Driver/ToolChains/HIP.cpp b/lib/Driver/ToolChains/HIP.cpp -index 03acf45a9b3..75fd3226c75 100644 ---- a/lib/Driver/ToolChains/HIP.cpp -+++ b/lib/Driver/ToolChains/HIP.cpp -@@ -98,9 +98,8 @@ const char *AMDGCN::Linker::constructLLVMLinkCommand( - const char *OutputFileName = - C.addTempFile(C.getArgs().MakeArgString(TmpName)); - CmdArgs.push_back(OutputFileName); -- SmallString<128> ExecPath(C.getDriver().Dir); -- llvm::sys::path::append(ExecPath, "llvm-link"); -- const char *Exec = Args.MakeArgString(ExecPath); -+ const char *Exec = -+ Args.MakeArgString(getToolChain().GetProgramPath("llvm-link")); - C.addCommand(llvm::make_unique(JA, *this, Exec, CmdArgs, Inputs)); - return OutputFileName; - } -@@ -141,9 +140,8 @@ const char *AMDGCN::Linker::constructOptCommand( - const char *OutputFileName = - C.addTempFile(C.getArgs().MakeArgString(TmpFileName)); - OptArgs.push_back(OutputFileName); -- SmallString<128> OptPath(C.getDriver().Dir); -- llvm::sys::path::append(OptPath, "opt"); -- const char *OptExec = Args.MakeArgString(OptPath); -+ const char *OptExec = -+ Args.MakeArgString(getToolChain().GetProgramPath("opt")); - C.addCommand(llvm::make_unique(JA, *this, OptExec, OptArgs, Inputs)); - return OutputFileName; - } -@@ -161,9 +159,7 @@ const char *AMDGCN::Linker::constructLlcCommand( - const char *LlcOutputFile = - C.addTempFile(C.getArgs().MakeArgString(LlcOutputFileName)); - LlcArgs.push_back(LlcOutputFile); -- SmallString<128> LlcPath(C.getDriver().Dir); -- llvm::sys::path::append(LlcPath, "llc"); -- const char *Llc = Args.MakeArgString(LlcPath); -+ const char *Llc = Args.MakeArgString(getToolChain().GetProgramPath("llc")); - C.addCommand(llvm::make_unique(JA, *this, Llc, LlcArgs, Inputs)); - return LlcOutputFile; - } -@@ -178,9 +174,7 @@ void AMDGCN::Linker::constructLldCommand(Compilation &C, const JobAction &JA, - ArgStringList LldArgs{"-flavor", "gnu", "--no-undefined", - "-shared", "-o", Output.getFilename(), - InputFileName}; -- SmallString<128> LldPath(C.getDriver().Dir); -- llvm::sys::path::append(LldPath, "lld"); -- const char *Lld = Args.MakeArgString(LldPath); -+ const char *Lld = Args.MakeArgString(getToolChain().GetProgramPath("lld")); - C.addCommand(llvm::make_unique(JA, *this, Lld, LldArgs, Inputs)); - } - --- -2.23.1 - diff --git a/pkgs/development/compilers/llvm/7/clang/default.nix b/pkgs/development/compilers/llvm/7/clang/default.nix index 825b4abb3e3..5ac9a7a2672 100644 --- a/pkgs/development/compilers/llvm/7/clang/default.nix +++ b/pkgs/development/compilers/llvm/7/clang/default.nix @@ -1,4 +1,4 @@ -{ stdenv, fetch, cmake, libxml2, llvm, version, clang-tools-extra_src, python, lld +{ stdenv, fetch, cmake, libxml2, llvm, version, clang-tools-extra_src, python , fixDarwinDylibNames , enableManpages ? false , enablePolly ? false # TODO: get this info from llvm (passthru?) @@ -22,7 +22,7 @@ let nativeBuildInputs = [ cmake python ] ++ stdenv.lib.optional enableManpages python.pkgs.sphinx; - buildInputs = [ libxml2 llvm lld ] + buildInputs = [ libxml2 llvm ] ++ stdenv.lib.optional stdenv.isDarwin fixDarwinDylibNames; cmakeFlags = [ @@ -38,11 +38,7 @@ let "-DLINK_POLLY_INTO_TOOLS=ON" ]; - patches = [ - ./purity.patch - # make clang -xhip use $PATH to find executables - ./HIP-use-PATH-7.patch - ]; + patches = [ ./purity.patch ]; postPatch = '' sed -i -e 's/DriverArgs.hasArg(options::OPT_nostdlibinc)/true/' \ diff --git a/pkgs/development/compilers/llvm/7/default.nix b/pkgs/development/compilers/llvm/7/default.nix index 2c3e285e22b..621a246225d 100644 --- a/pkgs/development/compilers/llvm/7/default.nix +++ b/pkgs/development/compilers/llvm/7/default.nix @@ -32,7 +32,6 @@ let llvm-polly = callPackage ./llvm.nix { enablePolly = true; }; clang-unwrapped = callPackage ./clang { - inherit (tools) lld; inherit clang-tools-extra_src; }; clang-polly-unwrapped = callPackage ./clang { diff --git a/pkgs/development/compilers/llvm/8/clang/HIP-use-PATH-8.patch b/pkgs/development/compilers/llvm/8/clang/HIP-use-PATH-8.patch deleted file mode 100644 index f4be100d1ab..00000000000 --- a/pkgs/development/compilers/llvm/8/clang/HIP-use-PATH-8.patch +++ /dev/null @@ -1,80 +0,0 @@ -From d9f1b7d7571b252e0ba2359ae6cfa93a9903c0e7 Mon Sep 17 00:00:00 2001 -From: =?UTF-8?q?Holger=20W=C3=BCnsche?= -Date: Tue, 21 Jan 2020 19:49:44 +0100 -Subject: [PATCH] [HIP] use GetProgramPath for executable discovery - -This change replaces the manual building of executable paths -using llvm::sys::path::append with GetProgramPath. -This enables adding other paths in case executables reside -in different directories and makes the code easier to read. - -Differential Revision: https://reviews.llvm.org/D72903 ---- - clang/lib/Driver/ToolChains/HIP.cpp | 23 ++++++++--------------- - 1 file changed, 8 insertions(+), 15 deletions(-) - -diff --git a/lib/Driver/ToolChains/HIP.cpp b/lang/lib/Driver/ToolChains/HIP.cpp -index 868765cf88e..31f2d68ec6c 100644 ---- a/lib/Driver/ToolChains/HIP.cpp -+++ b/lib/Driver/ToolChains/HIP.cpp -@@ -104,9 +104,8 @@ const char *AMDGCN::Linker::constructLLVMLinkCommand( - const char *OutputFileName = - C.addTempFile(C.getArgs().MakeArgString(TmpName)); - CmdArgs.push_back(OutputFileName); -- SmallString<128> ExecPath(C.getDriver().Dir); -- llvm::sys::path::append(ExecPath, "llvm-link"); -- const char *Exec = Args.MakeArgString(ExecPath); -+ const char *Exec = -+ Args.MakeArgString(getToolChain().GetProgramPath("llvm-link")); - C.addCommand(llvm::make_unique(JA, *this, Exec, CmdArgs, Inputs)); - return OutputFileName; - } -@@ -147,9 +146,8 @@ const char *AMDGCN::Linker::constructOptCommand( - const char *OutputFileName = - C.addTempFile(C.getArgs().MakeArgString(TmpFileName)); - OptArgs.push_back(OutputFileName); -- SmallString<128> OptPath(C.getDriver().Dir); -- llvm::sys::path::append(OptPath, "opt"); -- const char *OptExec = Args.MakeArgString(OptPath); -+ const char *OptExec = -+ Args.MakeArgString(getToolChain().GetProgramPath("opt")); - C.addCommand(llvm::make_unique(JA, *this, OptExec, OptArgs, Inputs)); - return OutputFileName; - } -@@ -167,9 +165,7 @@ const char *AMDGCN::Linker::constructLlcCommand( - const char *LlcOutputFile = - C.addTempFile(C.getArgs().MakeArgString(LlcOutputFileName)); - LlcArgs.push_back(LlcOutputFile); -- SmallString<128> LlcPath(C.getDriver().Dir); -- llvm::sys::path::append(LlcPath, "llc"); -- const char *Llc = Args.MakeArgString(LlcPath); -+ const char *Llc = Args.MakeArgString(getToolChain().GetProgramPath("llc")); - C.addCommand(llvm::make_unique(JA, *this, Llc, LlcArgs, Inputs)); - return LlcOutputFile; - } -@@ -184,9 +180,7 @@ void AMDGCN::Linker::constructLldCommand(Compilation &C, const JobAction &JA, - ArgStringList LldArgs{"-flavor", "gnu", "--no-undefined", - "-shared", "-o", Output.getFilename(), - InputFileName}; -- SmallString<128> LldPath(C.getDriver().Dir); -- llvm::sys::path::append(LldPath, "lld"); -- const char *Lld = Args.MakeArgString(LldPath); -+ const char *Lld = Args.MakeArgString(getToolChain().GetProgramPath("lld")); - C.addCommand(llvm::make_unique(JA, *this, Lld, LldArgs, Inputs)); - } - -@@ -218,9 +212,8 @@ void AMDGCN::constructHIPFatbinCommand(Compilation &C, const JobAction &JA, - Args.MakeArgString(std::string("-outputs=").append(OutputFileName)); - BundlerArgs.push_back(BundlerOutputArg); - -- SmallString<128> BundlerPath(C.getDriver().Dir); -- llvm::sys::path::append(BundlerPath, "clang-offload-bundler"); -- const char *Bundler = Args.MakeArgString(BundlerPath); -+ const char *Bundler = Args.MakeArgString( -+ T.getToolChain().GetProgramPath("clang-offload-bundler")); - C.addCommand(llvm::make_unique(JA, T, Bundler, BundlerArgs, Inputs)); - } - --- -2.23.1 - diff --git a/pkgs/development/compilers/llvm/8/clang/default.nix b/pkgs/development/compilers/llvm/8/clang/default.nix index 7d7b67adaf0..8c540e45b28 100644 --- a/pkgs/development/compilers/llvm/8/clang/default.nix +++ b/pkgs/development/compilers/llvm/8/clang/default.nix @@ -1,4 +1,4 @@ -{ stdenv, fetch, cmake, libxml2, llvm, version, clang-tools-extra_src, python, lld +{ stdenv, fetch, cmake, libxml2, llvm, version, clang-tools-extra_src, python , fixDarwinDylibNames , enableManpages ? false , enablePolly ? false # TODO: get this info from llvm (passthru?) @@ -22,7 +22,7 @@ let nativeBuildInputs = [ cmake python ] ++ stdenv.lib.optional enableManpages python.pkgs.sphinx; - buildInputs = [ libxml2 llvm lld ] + buildInputs = [ libxml2 llvm ] ++ stdenv.lib.optional stdenv.isDarwin fixDarwinDylibNames; cmakeFlags = [ @@ -50,8 +50,6 @@ let ./unwindlib.patch # https://reviews.llvm.org/D51899 ./compiler-rt-baremetal.patch - # make clang -xhip use $PATH to find executables - ./HIP-use-PATH-8.patch ]; postPatch = '' diff --git a/pkgs/development/compilers/llvm/8/default.nix b/pkgs/development/compilers/llvm/8/default.nix index f389d1814c0..36d7a14142b 100644 --- a/pkgs/development/compilers/llvm/8/default.nix +++ b/pkgs/development/compilers/llvm/8/default.nix @@ -32,7 +32,6 @@ let llvm-polly = callPackage ./llvm.nix { enablePolly = true; }; clang-unwrapped = callPackage ./clang { - inherit (tools) lld; inherit clang-tools-extra_src; }; clang-polly-unwrapped = callPackage ./clang { diff --git a/pkgs/development/compilers/llvm/9/clang/HIP-use-PATH-9.patch b/pkgs/development/compilers/llvm/9/clang/HIP-use-PATH-9.patch deleted file mode 100644 index 102d810ff68..00000000000 --- a/pkgs/development/compilers/llvm/9/clang/HIP-use-PATH-9.patch +++ /dev/null @@ -1,80 +0,0 @@ -From 7147e9774c74abcd1d6db24e24d0fd989c2b97dd Mon Sep 17 00:00:00 2001 -From: =?UTF-8?q?Holger=20W=C3=BCnsche?= -Date: Tue, 21 Jan 2020 19:52:04 +0100 -Subject: [PATCH] [HIP] use GetProgramPath for executable discovery - -This change replaces the manual building of executable paths -using llvm::sys::path::append with GetProgramPath. -This enables adding other paths in case executables reside -in different directories and makes the code easier to read. - -Differential Revision: https://reviews.llvm.org/D72903 ---- - clang/lib/Driver/ToolChains/HIP.cpp | 23 ++++++++--------------- - 1 file changed, 8 insertions(+), 15 deletions(-) - -diff --git a/lib/Driver/ToolChains/HIP.cpp b/lib/Driver/ToolChains/HIP.cpp -index 2ec97e798fd..735c302debb 100644 ---- a/lib/Driver/ToolChains/HIP.cpp -+++ b/lib/Driver/ToolChains/HIP.cpp -@@ -66,9 +66,8 @@ const char *AMDGCN::Linker::constructLLVMLinkCommand( - const char *OutputFileName = - C.addTempFile(C.getArgs().MakeArgString(TmpName)); - CmdArgs.push_back(OutputFileName); -- SmallString<128> ExecPath(C.getDriver().Dir); -- llvm::sys::path::append(ExecPath, "llvm-link"); -- const char *Exec = Args.MakeArgString(ExecPath); -+ const char *Exec = -+ Args.MakeArgString(getToolChain().GetProgramPath("llvm-link")); - C.addCommand(llvm::make_unique(JA, *this, Exec, CmdArgs, Inputs)); - return OutputFileName; - } -@@ -114,9 +113,8 @@ const char *AMDGCN::Linker::constructOptCommand( - const char *OutputFileName = - C.addTempFile(C.getArgs().MakeArgString(TmpFileName)); - OptArgs.push_back(OutputFileName); -- SmallString<128> OptPath(C.getDriver().Dir); -- llvm::sys::path::append(OptPath, "opt"); -- const char *OptExec = Args.MakeArgString(OptPath); -+ const char *OptExec = -+ Args.MakeArgString(getToolChain().GetProgramPath("opt")); - C.addCommand(llvm::make_unique(JA, *this, OptExec, OptArgs, Inputs)); - return OutputFileName; - } -@@ -156,9 +154,7 @@ const char *AMDGCN::Linker::constructLlcCommand( - const char *LlcOutputFile = - C.addTempFile(C.getArgs().MakeArgString(LlcOutputFileName)); - LlcArgs.push_back(LlcOutputFile); -- SmallString<128> LlcPath(C.getDriver().Dir); -- llvm::sys::path::append(LlcPath, "llc"); -- const char *Llc = Args.MakeArgString(LlcPath); -+ const char *Llc = Args.MakeArgString(getToolChain().GetProgramPath("llc")); - C.addCommand(llvm::make_unique(JA, *this, Llc, LlcArgs, Inputs)); - return LlcOutputFile; - } -@@ -172,9 +168,7 @@ void AMDGCN::Linker::constructLldCommand(Compilation &C, const JobAction &JA, - // The output from ld.lld is an HSA code object file. - ArgStringList LldArgs{ - "-flavor", "gnu", "-shared", "-o", Output.getFilename(), InputFileName}; -- SmallString<128> LldPath(C.getDriver().Dir); -- llvm::sys::path::append(LldPath, "lld"); -- const char *Lld = Args.MakeArgString(LldPath); -+ const char *Lld = Args.MakeArgString(getToolChain().GetProgramPath("lld")); - C.addCommand(llvm::make_unique(JA, *this, Lld, LldArgs, Inputs)); - } - -@@ -206,9 +200,8 @@ void AMDGCN::constructHIPFatbinCommand(Compilation &C, const JobAction &JA, - Args.MakeArgString(std::string("-outputs=").append(OutputFileName)); - BundlerArgs.push_back(BundlerOutputArg); - -- SmallString<128> BundlerPath(C.getDriver().Dir); -- llvm::sys::path::append(BundlerPath, "clang-offload-bundler"); -- const char *Bundler = Args.MakeArgString(BundlerPath); -+ const char *Bundler = Args.MakeArgString( -+ T.getToolChain().GetProgramPath("clang-offload-bundler")); - C.addCommand(llvm::make_unique(JA, T, Bundler, BundlerArgs, Inputs)); - } - --- -2.23.1 - diff --git a/pkgs/development/compilers/llvm/9/clang/default.nix b/pkgs/development/compilers/llvm/9/clang/default.nix index 1eefb9d0a83..1b779b118a7 100644 --- a/pkgs/development/compilers/llvm/9/clang/default.nix +++ b/pkgs/development/compilers/llvm/9/clang/default.nix @@ -1,4 +1,4 @@ -{ stdenv, fetch, cmake, libxml2, llvm, version, clang-tools-extra_src, python, lld +{ stdenv, fetch, cmake, libxml2, llvm, version, clang-tools-extra_src, python , fixDarwinDylibNames , enableManpages ? false , enablePolly ? false # TODO: get this info from llvm (passthru?) @@ -22,7 +22,7 @@ let nativeBuildInputs = [ cmake python ] ++ stdenv.lib.optional enableManpages python.pkgs.sphinx; - buildInputs = [ libxml2 llvm lld ] + buildInputs = [ libxml2 llvm ] ++ stdenv.lib.optional stdenv.isDarwin fixDarwinDylibNames; cmakeFlags = [ @@ -43,8 +43,6 @@ let ./purity.patch # https://reviews.llvm.org/D51899 ./compiler-rt-baremetal.patch - # make clang -xhip use $PATH to find executables - ./HIP-use-PATH-9.patch ]; postPatch = '' diff --git a/pkgs/development/compilers/llvm/9/default.nix b/pkgs/development/compilers/llvm/9/default.nix index 917641d6406..c9e8ce91f0c 100644 --- a/pkgs/development/compilers/llvm/9/default.nix +++ b/pkgs/development/compilers/llvm/9/default.nix @@ -32,7 +32,6 @@ let llvm-polly = callPackage ./llvm.nix { enablePolly = true; }; clang-unwrapped = callPackage ./clang { - inherit (tools) lld; inherit clang-tools-extra_src; }; clang-polly-unwrapped = callPackage ./clang {