forked from OSchip/llvm-project
Support mingw toolchain include and lib directories on Arch Linux.
Thanks to Thomas Pochtrager for testing this! llvm-svn: 242660
This commit is contained in:
parent
82efabbb27
commit
658df8b2ee
|
@ -26,6 +26,8 @@ MinGW::MinGW(const Driver &D, const llvm::Triple &Triple, const ArgList &Args)
|
||||||
|
|
||||||
llvm::SmallString<1024> LibDir;
|
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
|
#ifdef LLVM_ON_WIN32
|
||||||
if (getDriver().SysRoot.size())
|
if (getDriver().SysRoot.size())
|
||||||
Base = getDriver().SysRoot;
|
Base = getDriver().SysRoot;
|
||||||
|
@ -36,42 +38,48 @@ MinGW::MinGW(const Driver &D, const llvm::Triple &Triple, const ArgList &Args)
|
||||||
else
|
else
|
||||||
Base = llvm::sys::path::parent_path(getDriver().getInstalledDir());
|
Base = llvm::sys::path::parent_path(getDriver().getInstalledDir());
|
||||||
Base += llvm::sys::path::get_separator();
|
Base += llvm::sys::path::get_separator();
|
||||||
LibDir = Base;
|
|
||||||
llvm::sys::path::append(LibDir, "lib", "gcc");
|
|
||||||
#else
|
#else
|
||||||
if (getDriver().SysRoot.size())
|
if (getDriver().SysRoot.size())
|
||||||
Base = getDriver().SysRoot;
|
Base = getDriver().SysRoot;
|
||||||
else
|
else
|
||||||
Base = "/usr/";
|
Base = "/usr/";
|
||||||
LibDir = Base;
|
|
||||||
llvm::sys::path::append(LibDir, "lib64", "gcc");
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
LibDir += llvm::sys::path::get_separator();
|
// By default Arch is for mingw-w64.
|
||||||
|
Arch = (getTriple().getArchName() + "-w64-mingw32").str();
|
||||||
// First look for mingw-w64.
|
// lib: Arch Linux, Ubuntu, Windows
|
||||||
Arch = getTriple().getArchName();
|
// lib64: openSUSE Linux
|
||||||
Arch += "-w64-mingw32";
|
for (StringRef Lib : {"lib", "lib64 "}) {
|
||||||
std::error_code EC;
|
LibDir = Base;
|
||||||
llvm::sys::fs::directory_iterator MingW64Entry(LibDir + Arch, EC);
|
llvm::sys::path::append(LibDir, Lib, "gcc");
|
||||||
if (!EC) {
|
LibDir += llvm::sys::path::get_separator();
|
||||||
GccLibDir = MingW64Entry->path();
|
std::error_code EC;
|
||||||
Ver = llvm::sys::path::filename(GccLibDir);
|
// First look for mingw-w64.
|
||||||
} else {
|
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.
|
// If mingw-w64 not found, try looking for mingw.org.
|
||||||
Arch = "mingw32";
|
llvm::sys::fs::directory_iterator MingwOrgEntry(LibDir + "mingw32", EC);
|
||||||
llvm::sys::fs::directory_iterator MingwOrgEntry(LibDir + Arch, EC);
|
if (!EC) {
|
||||||
if (!EC)
|
|
||||||
GccLibDir = MingwOrgEntry->path();
|
GccLibDir = MingwOrgEntry->path();
|
||||||
|
// Replace Arch with mingw32 arch.
|
||||||
|
Arch = "mingw32";
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Arch += llvm::sys::path::get_separator();
|
Arch += llvm::sys::path::get_separator();
|
||||||
// GccLibDir must precede Base/lib so that the
|
// GccLibDir must precede Base/lib so that the
|
||||||
// correct crtbegin.o ,cetend.o would be found.
|
// correct crtbegin.o ,cetend.o would be found.
|
||||||
getFilePaths().push_back(GccLibDir);
|
getFilePaths().push_back(GccLibDir);
|
||||||
getFilePaths().push_back(Base + "lib");
|
|
||||||
getFilePaths().push_back(Base + Arch + "lib");
|
getFilePaths().push_back(Base + Arch + "lib");
|
||||||
#ifdef LLVM_ON_UNIX
|
#ifdef LLVM_ON_WIN32
|
||||||
// For openSUSE.
|
getFilePaths().push_back(Base + "lib");
|
||||||
|
#else
|
||||||
|
// openSUSE
|
||||||
getFilePaths().push_back(Base + Arch + "sys-root/mingw/lib");
|
getFilePaths().push_back(Base + Arch + "sys-root/mingw/lib");
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
@ -134,7 +142,7 @@ void MinGW::AddClangSystemIncludeArgs(const ArgList &DriverArgs,
|
||||||
addSystemInclude(DriverArgs, CC1Args, IncludeDir.c_str());
|
addSystemInclude(DriverArgs, CC1Args, IncludeDir.c_str());
|
||||||
IncludeDir += "-fixed";
|
IncludeDir += "-fixed";
|
||||||
#ifdef LLVM_ON_UNIX
|
#ifdef LLVM_ON_UNIX
|
||||||
// For openSUSE.
|
// openSUSE
|
||||||
addSystemInclude(DriverArgs, CC1Args,
|
addSystemInclude(DriverArgs, CC1Args,
|
||||||
"/usr/x86_64-w64-mingw32/sys-root/mingw/include");
|
"/usr/x86_64-w64-mingw32/sys-root/mingw/include");
|
||||||
#endif
|
#endif
|
||||||
|
@ -149,23 +157,28 @@ void MinGW::AddClangCXXStdlibIncludeArgs(const ArgList &DriverArgs,
|
||||||
DriverArgs.hasArg(options::OPT_nostdincxx))
|
DriverArgs.hasArg(options::OPT_nostdincxx))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// C++ includes may be found in several locations depending on distribution.
|
// C++ includes locations are different with almost every mingw distribution.
|
||||||
|
//
|
||||||
// Windows
|
// 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-w64 msys2: $sysroot/include/c++/4.9.2
|
||||||
// mingw.org: GccLibDir/include/c++
|
// mingw.org: GccLibDir/include/c++
|
||||||
//
|
//
|
||||||
// Linux
|
// Linux
|
||||||
// -----
|
// -----
|
||||||
// openSUSE: GccLibDir/include/c++
|
// 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);
|
CppIncludeBases.emplace_back(Base);
|
||||||
llvm::sys::path::append(CppIncludeBases[0], Arch, "include", "c++");
|
llvm::sys::path::append(CppIncludeBases[0], Arch, "include", "c++");
|
||||||
CppIncludeBases.emplace_back(Base);
|
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);
|
CppIncludeBases.emplace_back(GccLibDir);
|
||||||
llvm::sys::path::append(CppIncludeBases[2], "include", "c++");
|
llvm::sys::path::append(CppIncludeBases[3], "include", "c++");
|
||||||
for (auto &CppIncludeBase : CppIncludeBases) {
|
for (auto &CppIncludeBase : CppIncludeBases) {
|
||||||
CppIncludeBase += llvm::sys::path::get_separator();
|
CppIncludeBase += llvm::sys::path::get_separator();
|
||||||
addSystemInclude(DriverArgs, CC1Args, CppIncludeBase);
|
addSystemInclude(DriverArgs, CC1Args, CppIncludeBase);
|
||||||
|
|
Loading…
Reference in New Issue