r242150 - Support mingw-w64 toolchain on openSUSE and likely other Linuxes

Yaron Keren yaron.keren at gmail.com
Tue Jul 14 08:02:09 PDT 2015


Author: yrnkrn
Date: Tue Jul 14 10:02:09 2015
New Revision: 242150

URL: http://llvm.org/viewvc/llvm-project?rev=242150&view=rev
Log:
Support mingw-w64 toolchain on openSUSE and likely other Linuxes

Thanks to Ismail Donmez for testing and to Joerg Sonnenbergerþ for his comments.


Modified:
    cfe/trunk/lib/Driver/MinGWToolChain.cpp

Modified: cfe/trunk/lib/Driver/MinGWToolChain.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/MinGWToolChain.cpp?rev=242150&r1=242149&r2=242150&view=diff
==============================================================================
--- cfe/trunk/lib/Driver/MinGWToolChain.cpp (original)
+++ cfe/trunk/lib/Driver/MinGWToolChain.cpp Tue Jul 14 10:02:09 2015
@@ -24,6 +24,9 @@ MinGW::MinGW(const Driver &D, const llvm
     : ToolChain(D, Triple, Args) {
   getProgramPaths().push_back(getDriver().getInstalledDir());
 
+  llvm::SmallString<1024> LibDir;
+
+#ifdef LLVM_ON_WIN32
   if (getDriver().SysRoot.size())
     Base = getDriver().SysRoot;
   else if (llvm::ErrorOr<std::string> GPPName =
@@ -33,8 +36,17 @@ MinGW::MinGW(const Driver &D, const llvm
   else
     Base = llvm::sys::path::parent_path(getDriver().getInstalledDir());
   Base += llvm::sys::path::get_separator();
-  llvm::SmallString<1024> LibDir(Base);
+  LibDir = Base;
   llvm::sys::path::append(LibDir, "lib", "gcc");
+#else
+  if (getDriver().SysRoot.size())
+    Base = getDriver().SysRoot;
+  else
+    Base = "/usr/";
+  LibDir = Base;
+  llvm::sys::path::append(LibDir, "lib64", "gcc");
+#endif
+
   LibDir += llvm::sys::path::get_separator();
 
   // First look for mingw-w64.
@@ -58,6 +70,10 @@ MinGW::MinGW(const Driver &D, const llvm
   getFilePaths().push_back(GccLibDir);
   getFilePaths().push_back(Base + "lib");
   getFilePaths().push_back(Base + Arch + "lib");
+#ifdef LLVM_ON_UNIX
+  // For openSUSE.
+  getFilePaths().push_back(Base + Arch + "sys-root/mingw/lib");
+#endif
 }
 
 bool MinGW::IsIntegratedAssemblerDefault() const { return true; }
@@ -117,6 +133,11 @@ void MinGW::AddClangSystemIncludeArgs(co
   llvm::sys::path::append(IncludeDir, "include");
   addSystemInclude(DriverArgs, CC1Args, IncludeDir.c_str());
   IncludeDir += "-fixed";
+#ifdef LLVM_ON_UNIX
+  // For 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");
@@ -129,9 +150,15 @@ void MinGW::AddClangCXXStdlibIncludeArgs
     return;
 
   // C++ includes may be found in several locations depending on distribution.
+  // Windows
+  // -------
   // mingw-w64 mingw-builds: $sysroot/i686-w64-mingw32/include/c++.
   // mingw-w64 msys2:        $sysroot/include/c++/4.9.2
   // mingw.org:              GccLibDir/include/c++
+  //
+  // Linux
+  // -----
+  // openSUSE:               GccLibDir/include/c++
   llvm::SmallVector<llvm::SmallString<1024>, 3> CppIncludeBases;
   CppIncludeBases.emplace_back(Base);
   llvm::sys::path::append(CppIncludeBases[0], Arch, "include", "c++");






More information about the cfe-commits mailing list