[llvm-branch-commits] [cfe-branch] r243061 - Merging r242660 and r242667:
Hans Wennborg
hans at hanshq.net
Thu Jul 23 16:07:25 PDT 2015
Author: hans
Date: Thu Jul 23 18:07:25 2015
New Revision: 243061
URL: http://llvm.org/viewvc/llvm-project?rev=243061&view=rev
Log:
Merging r242660 and r242667:
------------------------------------------------------------------------
r242660 | yrnkrn | 2015-07-19 23:38:39 -0700 (Sun, 19 Jul 2015) | 4 lines
Support mingw toolchain include and lib directories on Arch Linux.
Thanks to Thomas Pochtrager for testing this!
------------------------------------------------------------------------
------------------------------------------------------------------------
r242667 | yrnkrn | 2015-07-20 05:40:25 -0700 (Mon, 20 Jul 2015) | 3 lines
Remove erroneous space in "lib64" string constant.
------------------------------------------------------------------------
Modified:
cfe/branches/release_37/ (props changed)
cfe/branches/release_37/lib/Driver/MinGWToolChain.cpp
Propchange: cfe/branches/release_37/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Thu Jul 23 18:07:25 2015
@@ -1,4 +1,4 @@
/cfe/branches/type-system-rewrite:134693-134817
-/cfe/trunk:242244,242285,242293,242297,242313,242382,242422,242499,242574,242678,243018
+/cfe/trunk:242244,242285,242293,242297,242313,242382,242422,242499,242574,242660,242667,242678,243018
/cfe/trunk/test:170344
/cfe/trunk/test/SemaTemplate:126920
Modified: cfe/branches/release_37/lib/Driver/MinGWToolChain.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/release_37/lib/Driver/MinGWToolChain.cpp?rev=243061&r1=243060&r2=243061&view=diff
==============================================================================
--- cfe/branches/release_37/lib/Driver/MinGWToolChain.cpp (original)
+++ cfe/branches/release_37/lib/Driver/MinGWToolChain.cpp Thu Jul 23 18:07:25 2015
@@ -26,6 +26,8 @@ MinGW::MinGW(const Driver &D, const llvm
llvm::SmallString<1024> LibDir;
+ // In Windows there aren't any standard install locations, we search
+ // for gcc on the PATH. In Liunx the base is always /usr.
#ifdef LLVM_ON_WIN32
if (getDriver().SysRoot.size())
Base = getDriver().SysRoot;
@@ -36,42 +38,48 @@ MinGW::MinGW(const Driver &D, const llvm
else
Base = llvm::sys::path::parent_path(getDriver().getInstalledDir());
Base += llvm::sys::path::get_separator();
- 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.
- Arch = getTriple().getArchName();
- Arch += "-w64-mingw32";
- std::error_code EC;
- llvm::sys::fs::directory_iterator MingW64Entry(LibDir + Arch, EC);
- if (!EC) {
- GccLibDir = MingW64Entry->path();
- Ver = llvm::sys::path::filename(GccLibDir);
- } else {
+ // By default Arch is for mingw-w64.
+ Arch = (getTriple().getArchName() + "-w64-mingw32").str();
+ // lib: Arch Linux, Ubuntu, Windows
+ // lib64: openSUSE Linux
+ for (StringRef Lib : {"lib", "lib64"}) {
+ LibDir = Base;
+ llvm::sys::path::append(LibDir, Lib, "gcc");
+ LibDir += llvm::sys::path::get_separator();
+ std::error_code EC;
+ // First look for mingw-w64.
+ llvm::sys::fs::directory_iterator MingW64Entry(LibDir + Arch, EC);
+ if (!EC) {
+ GccLibDir = MingW64Entry->path();
+ Ver = llvm::sys::path::filename(GccLibDir);
+ break;
+ }
// If mingw-w64 not found, try looking for mingw.org.
- Arch = "mingw32";
- llvm::sys::fs::directory_iterator MingwOrgEntry(LibDir + Arch, EC);
- if (!EC)
+ llvm::sys::fs::directory_iterator MingwOrgEntry(LibDir + "mingw32", EC);
+ if (!EC) {
GccLibDir = MingwOrgEntry->path();
+ // Replace Arch with mingw32 arch.
+ Arch = "mingw32";
+ break;
+ }
}
+
Arch += llvm::sys::path::get_separator();
// GccLibDir must precede Base/lib so that the
// correct crtbegin.o ,cetend.o would be found.
getFilePaths().push_back(GccLibDir);
- getFilePaths().push_back(Base + "lib");
getFilePaths().push_back(Base + Arch + "lib");
-#ifdef LLVM_ON_UNIX
- // For openSUSE.
+#ifdef LLVM_ON_WIN32
+ getFilePaths().push_back(Base + "lib");
+#else
+ // openSUSE
getFilePaths().push_back(Base + Arch + "sys-root/mingw/lib");
#endif
}
@@ -134,7 +142,7 @@ void MinGW::AddClangSystemIncludeArgs(co
addSystemInclude(DriverArgs, CC1Args, IncludeDir.c_str());
IncludeDir += "-fixed";
#ifdef LLVM_ON_UNIX
- // For openSUSE.
+ // openSUSE
addSystemInclude(DriverArgs, CC1Args,
"/usr/x86_64-w64-mingw32/sys-root/mingw/include");
#endif
@@ -149,23 +157,28 @@ void MinGW::AddClangCXXStdlibIncludeArgs
DriverArgs.hasArg(options::OPT_nostdincxx))
return;
- // C++ includes may be found in several locations depending on distribution.
+ // C++ includes locations are different with almost every mingw distribution.
+ //
// Windows
// -------
- // mingw-w64 mingw-builds: $sysroot/i686-w64-mingw32/include/c++.
+ // 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;
+ // Arch: $sysroot/i686-w64-mingw32/include/c++/5.1.0
+ //
+ 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], "include", "c++", Ver);
+ 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[2], "include", "c++");
+ llvm::sys::path::append(CppIncludeBases[3], "include", "c++");
for (auto &CppIncludeBase : CppIncludeBases) {
CppIncludeBase += llvm::sys::path::get_separator();
addSystemInclude(DriverArgs, CC1Args, CppIncludeBase);
More information about the llvm-branch-commits
mailing list