martell updated this revision to Diff 30322.
martell added a comment.

Updated to latest svn.

After some hard testing on windows I discovered we do not need to pass the 
exception library when using libc++.dll because it is a shared library.

That is the reason why the code already contains
if (!TC.getTriple().isOSWindows())

since we don't handle a OPT_static_libgcc equivalent for compiler-rt
it makes more sense to leave this code alone

Please Review

Many Thanks
Martell


http://reviews.llvm.org/D11237

Files:
  tools/clang/lib/Driver/MinGWToolChain.cpp
  tools/clang/lib/Driver/Tools.cpp
  tools/clang/lib/Driver/Tools.h

Index: tools/clang/lib/Driver/Tools.h
===================================================================
--- tools/clang/lib/Driver/Tools.h
+++ tools/clang/lib/Driver/Tools.h
@@ -702,9 +702,6 @@
                     const InputInfo &Output, const InputInfoList &Inputs,
                     const llvm::opt::ArgList &TCArgs,
                     const char *LinkingOutput) const override;
-
-private:
-  void AddLibGCC(const llvm::opt::ArgList &Args, ArgStringList &CmdArgs) const;
 };
 } // end namespace MinGW
 
Index: tools/clang/lib/Driver/Tools.cpp
===================================================================
--- tools/clang/lib/Driver/Tools.cpp
+++ tools/clang/lib/Driver/Tools.cpp
@@ -2247,8 +2247,7 @@
 
 // Until ARM libraries are build separately, we have them all in one library
 static StringRef getArchNameForCompilerRTLib(const ToolChain &TC) {
-  if (TC.getTriple().isOSWindows() &&
-      !TC.getTriple().isWindowsItaniumEnvironment() &&
+  if (TC.getTriple().isWindowsMSVCEnvironment() &&
       TC.getArch() == llvm::Triple::x86)
     return "i386";
   if (TC.getArch() == llvm::Triple::arm || TC.getArch() == llvm::Triple::armeb)
@@ -2274,10 +2273,12 @@
                         : "";
 
   bool IsOSWindows = TC.getTriple().isOSWindows();
+  bool IsITANMSVCWindows = TC.getTriple().isWindowsMSVCEnvironment() ||
+                           TC.getTriple().isWindowsItaniumEnvironment();
   StringRef Arch = getArchNameForCompilerRTLib(TC);
-  const char *Prefix = IsOSWindows ? "" : "lib";
+  const char *Prefix = IsITANMSVCWindows ? "" : "lib";
   const char *Suffix =
-      Shared ? (IsOSWindows ? ".dll" : ".so") : (IsOSWindows ? ".lib" : ".a");
+      Shared ? (IsOSWindows ? ".dll" : ".so") : (IsITANMSVCWindows ? ".lib" : ".a");
 
   SmallString<128> Path = getCompilerRTLibDir(TC);
   llvm::sys::path::append(Path, Prefix + Twine("clang_rt.") + Component + "-" +
@@ -7836,6 +7842,7 @@
 static void AddLibgcc(const llvm::Triple &Triple, const Driver &D,
                       ArgStringList &CmdArgs, const ArgList &Args) {
   bool isAndroid = Triple.getEnvironment() == llvm::Triple::Android;
+  bool isWindows = Triple.getOS() == llvm::Triple::Win32;
   bool StaticLibgcc = Args.hasArg(options::OPT_static_libgcc) ||
                       Args.hasArg(options::OPT_static);
   if (!D.CCCIsCXX())
@@ -7845,10 +7852,10 @@
     if (D.CCCIsCXX())
       CmdArgs.push_back("-lgcc");
   } else {
-    if (!D.CCCIsCXX())
+    if (!D.CCCIsCXX() && !isWindows)
       CmdArgs.push_back("--as-needed");
     CmdArgs.push_back("-lgcc_s");
-    if (!D.CCCIsCXX())
+    if (!D.CCCIsCXX() && !isWindows)
       CmdArgs.push_back("--no-as-needed");
   }
 
@@ -8925,25 +8932,6 @@
                    SplitDebugName(Args, Inputs[0]));
 }
 
-void MinGW::Linker::AddLibGCC(const ArgList &Args,
-                              ArgStringList &CmdArgs) const {
-  if (Args.hasArg(options::OPT_mthreads))
-    CmdArgs.push_back("-lmingwthrd");
-  CmdArgs.push_back("-lmingw32");
-  if (Args.hasArg(options::OPT_shared) ||
-      Args.hasArg(options::OPT_shared_libgcc) ||
-      !Args.hasArg(options::OPT_static_libgcc)) {
-    CmdArgs.push_back("-lgcc_s");
-    CmdArgs.push_back("-lgcc");
-  } else {
-    CmdArgs.push_back("-lgcc");
-    CmdArgs.push_back("-lgcc_eh");
-  }
-  CmdArgs.push_back("-lmoldname");
-  CmdArgs.push_back("-lmingwex");
-  CmdArgs.push_back("-lmsvcrt");
-}
-
 void MinGW::Linker::ConstructJob(Compilation &C, const JobAction &JA,
                                  const InputInfo &Output,
                                  const InputInfoList &Inputs,
@@ -9071,7 +9059,15 @@
       if (Args.hasArg(options::OPT_fopenmp))
         CmdArgs.push_back("-lgomp");
 
-      AddLibGCC(Args, CmdArgs);
+      if (Args.hasArg(options::OPT_mthreads))
+        CmdArgs.push_back("-lmingwthrd");
+      CmdArgs.push_back("-lmingw32");
+
+      AddRunTimeLibs(TC, D, CmdArgs, Args);
+
+      CmdArgs.push_back("-lmoldname");
+      CmdArgs.push_back("-lmingwex");
+      CmdArgs.push_back("-lmsvcrt");
 
       if (Args.hasArg(options::OPT_pg))
         CmdArgs.push_back("-lgmon");
@@ -9091,8 +9087,19 @@
 
       if (Args.hasArg(options::OPT_static))
         CmdArgs.push_back("--end-group");
-      else if (!LinkerName.equals_lower("lld"))
-        AddLibGCC(Args, CmdArgs);
+      else if (!LinkerName.equals_lower("lld")) {
+
+        if (Args.hasArg(options::OPT_mthreads))
+          CmdArgs.push_back("-lmingwthrd");
+        CmdArgs.push_back("-lmingw32");
+
+        AddRunTimeLibs(TC, D, CmdArgs, Args);
+
+        CmdArgs.push_back("-lmoldname");
+        CmdArgs.push_back("-lmingwex");
+        CmdArgs.push_back("-lmsvcrt");
+
+      }
     }
 
     if (!Args.hasArg(options::OPT_nostartfiles)) {
Index: tools/clang/lib/Driver/MinGWToolChain.cpp
===================================================================
--- tools/clang/lib/Driver/MinGWToolChain.cpp
+++ tools/clang/lib/Driver/MinGWToolChain.cpp
@@ -192,18 +192,20 @@
   if (DriverArgs.hasArg(options::OPT_nostdlibinc))
     return;
 
-  llvm::SmallString<1024> IncludeDir(GccLibDir);
-  llvm::sys::path::append(IncludeDir, "include");
-  addSystemInclude(DriverArgs, CC1Args, IncludeDir.c_str());
-  IncludeDir += "-fixed";
+if (GetRuntimeLibType(DriverArgs) == ToolChain::RLT_Libgcc) {
+    llvm::SmallString<1024> IncludeDir(GccLibDir);
+    llvm::sys::path::append(IncludeDir, "include");
+    addSystemInclude(DriverArgs, CC1Args, IncludeDir.c_str());
+    IncludeDir += "-fixed";
 #ifdef LLVM_ON_UNIX
-  // openSUSE
-  addSystemInclude(DriverArgs, CC1Args,
-                   "/usr/x86_64-w64-mingw32/sys-root/mingw/include");
+    // openSUSE
+    addSystemInclude(DriverArgs, CC1Args,
+                     "/usr/x86_64-w64-mingw32/sys-root/mingw/include");
 #endif
-  addSystemInclude(DriverArgs, CC1Args, IncludeDir.c_str());
-  addSystemInclude(DriverArgs, CC1Args, Base + Arch + "include");
-  addSystemInclude(DriverArgs, CC1Args, Base + "include");
+    addSystemInclude(DriverArgs, CC1Args, IncludeDir.c_str());
+  }
+    addSystemInclude(DriverArgs, CC1Args, Base + Arch + "include");
+    addSystemInclude(DriverArgs, CC1Args, Base + "include");
 }
 
 void MinGW::AddClangCXXStdlibIncludeArgs(const ArgList &DriverArgs,
@@ -212,19 +214,29 @@
       DriverArgs.hasArg(options::OPT_nostdincxx))
     return;
 
-  llvm::SmallVector<llvm::SmallString<1024>, 4> CppIncludeBases;
-  CppIncludeBases.emplace_back(Base);
-  llvm::sys::path::append(CppIncludeBases[0], Arch, "include", "c++");
-  CppIncludeBases.emplace_back(Base);
-  llvm::sys::path::append(CppIncludeBases[1], Arch, "include", "c++", Ver);
-  CppIncludeBases.emplace_back(Base);
-  llvm::sys::path::append(CppIncludeBases[2], "include", "c++", Ver);
-  CppIncludeBases.emplace_back(GccLibDir);
-  llvm::sys::path::append(CppIncludeBases[3], "include", "c++");
-  for (auto &CppIncludeBase : CppIncludeBases) {
-    CppIncludeBase += llvm::sys::path::get_separator();
-    addSystemInclude(DriverArgs, CC1Args, CppIncludeBase);
-    addSystemInclude(DriverArgs, CC1Args, CppIncludeBase + Arch);
-    addSystemInclude(DriverArgs, CC1Args, CppIncludeBase + "backward");
+  switch (GetCXXStdlibType(DriverArgs)) {
+  case ToolChain::CST_Libcxx:
+    addSystemInclude(DriverArgs, CC1Args, Base        + "include" +
+                     llvm::sys::path::get_separator() + "c++"     +
+                     llvm::sys::path::get_separator() + "v1");
+    break;
+
+  case ToolChain::CST_Libstdcxx:
+    llvm::SmallVector<llvm::SmallString<1024>, 4> CppIncludeBases;
+    CppIncludeBases.emplace_back(Base);
+    llvm::sys::path::append(CppIncludeBases[0], Arch, "include", "c++");
+    CppIncludeBases.emplace_back(Base);
+    llvm::sys::path::append(CppIncludeBases[1], Arch, "include", "c++", Ver);
+    CppIncludeBases.emplace_back(Base);
+    llvm::sys::path::append(CppIncludeBases[2], "include", "c++", Ver);
+    CppIncludeBases.emplace_back(GccLibDir);
+    llvm::sys::path::append(CppIncludeBases[3], "include", "c++");
+    for (auto &CppIncludeBase : CppIncludeBases) {
+      CppIncludeBase += llvm::sys::path::get_separator();
+      addSystemInclude(DriverArgs, CC1Args, CppIncludeBase);
+      addSystemInclude(DriverArgs, CC1Args, CppIncludeBase + Arch);
+      addSystemInclude(DriverArgs, CC1Args, CppIncludeBase + "backward");
+    }
+    break;
   }
 }
_______________________________________________
cfe-commits mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits

Reply via email to