      Loader = "ld-linux.so.2";
      break;
    case llvm::Triple::systemz:
-@@ -631,7 +631,7 @@ std::string Linux::getDynamicLinker(const ArgList &Args) const {
+@@ -635,8 +635,10 @@ std::string Linux::getDynamicLinker(const ArgList &Args) const {
+     break;
    case llvm::Triple::x86_64: {
      bool X32 = Triple.getEnvironment() == llvm::Triple::GNUX32;
- 
+-
 -    LibDir = X32 ? "libx32" : "lib64";
-+    LibDir = "lib";
++    if (Triple.getEnvironment() == llvm::Triple::GNU)
++      LibDir = X32 ? "libx32" : "lib64";
++    else
++      LibDir = "lib";
      Loader = X32 ? "ld-linux-x32.so.2" : "ld-linux-x86-64.so.2";
      break;
    }
 -- 
-2.20.1
+2.21.0
 

     Loader =
         (tools::ppc::hasPPCAbiArg(Args, "elfv1")) ? "ld64.so.1" : "ld64.so.2";
     break;
@@ -617,7 +617,7 @@ std::string Linux::getDynamicLinker(const ArgList &Args) const {
     Loader = "ld-linux.so.2";
     break;
   case llvm::Triple::sparcv9:

in multilib case OE switches the base libdir
for 64bit to /lib64 instead of /lib

Make sure that the change only happens for cross
compilation on x86_64 architecture

Signed-off-by: Khem Raj <raj.khem@gmail.com>
---
 clang/lib/Driver/ToolChains/Linux.cpp | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)

diff --git a/clang/lib/Driver/ToolChains/Linux.cpp b/clang/lib/Driver/ToolChains/Linux.cpp
index e9169e91fd4..9c08a794f5c 100644
--- a/clang/lib/Driver/ToolChains/Linux.cpp
+++ b/clang/lib/Driver/ToolChains/Linux.cpp
@@ -595,12 +595,12 @@ std::string Linux::getDynamicLinker(const ArgList &Args) const {
     Loader = "ld.so.1";
     break;
   case llvm::Triple::ppc64:
