[llvm-branch-commits] [cfe-branch] r243064 - Merging r242905:
Hans Wennborg
hans at hanshq.net
Thu Jul 23 16:13:24 PDT 2015
Author: hans
Date: Thu Jul 23 18:13:24 2015
New Revision: 243064
URL: http://llvm.org/viewvc/llvm-project?rev=243064&view=rev
Log:
Merging r242905:
------------------------------------------------------------------------
r242905 | rnk | 2015-07-22 09:01:38 -0700 (Wed, 22 Jul 2015) | 7 lines
[mingw] Add support for -rtlib option and -stdlib option to the mingw driver
Now clang should be able to use compiler-rt and libc++ on mingw.
Based on a patch by Martell Malone.
Differential Revision: http://reviews.llvm.org/D11237
------------------------------------------------------------------------
Modified:
cfe/branches/release_37/ (props changed)
cfe/branches/release_37/lib/Driver/MinGWToolChain.cpp
cfe/branches/release_37/lib/Driver/Tools.cpp
Propchange: cfe/branches/release_37/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Thu Jul 23 18:13:24 2015
@@ -1,4 +1,4 @@
/cfe/branches/type-system-rewrite:134693-134817
-/cfe/trunk:242244,242285,242293,242297,242313,242382,242422,242499,242574,242660,242662,242667,242678,242766,243018
+/cfe/trunk:242244,242285,242293,242297,242313,242382,242422,242499,242574,242660,242662,242667,242678,242766,242905,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=243064&r1=243063&r2=243064&view=diff
==============================================================================
--- cfe/branches/release_37/lib/Driver/MinGWToolChain.cpp (original)
+++ cfe/branches/release_37/lib/Driver/MinGWToolChain.cpp Thu Jul 23 18:13:24 2015
@@ -192,16 +192,18 @@ void MinGW::AddClangSystemIncludeArgs(co
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, IncludeDir.c_str());
+ }
addSystemInclude(DriverArgs, CC1Args, Base + Arch + "include");
addSystemInclude(DriverArgs, CC1Args, Base + "include");
}
@@ -212,19 +214,29 @@ void MinGW::AddClangCXXStdlibIncludeArgs
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;
}
}
Modified: cfe/branches/release_37/lib/Driver/Tools.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/release_37/lib/Driver/Tools.cpp?rev=243064&r1=243063&r2=243064&view=diff
==============================================================================
--- cfe/branches/release_37/lib/Driver/Tools.cpp (original)
+++ cfe/branches/release_37/lib/Driver/Tools.cpp Thu Jul 23 18:13:24 2015
@@ -2243,8 +2243,7 @@ static void CollectArgsForIntegratedAsse
// 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)
@@ -2270,10 +2269,12 @@ SmallString<128> tools::getCompilerRT(co
: "";
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 + "-" +
@@ -7816,6 +7817,7 @@ void gnutools::Assembler::ConstructJob(C
static void AddLibgcc(const llvm::Triple &Triple, const Driver &D,
ArgStringList &CmdArgs, const ArgList &Args) {
bool isAndroid = Triple.getEnvironment() == llvm::Triple::Android;
+ bool isCygMing = Triple.isOSCygMing();
bool StaticLibgcc = Args.hasArg(options::OPT_static_libgcc) ||
Args.hasArg(options::OPT_static);
if (!D.CCCIsCXX())
@@ -7825,10 +7827,10 @@ static void AddLibgcc(const llvm::Triple
if (D.CCCIsCXX())
CmdArgs.push_back("-lgcc");
} else {
- if (!D.CCCIsCXX())
+ if (!D.CCCIsCXX() && !isCygMing)
CmdArgs.push_back("--as-needed");
CmdArgs.push_back("-lgcc_s");
- if (!D.CCCIsCXX())
+ if (!D.CCCIsCXX() && !isCygMing)
CmdArgs.push_back("--no-as-needed");
}
@@ -8910,15 +8912,10 @@ void MinGW::Linker::AddLibGCC(const ArgL
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");
- }
+
+ // Add libgcc or compiler-rt.
+ AddRunTimeLibs(getToolChain(), getToolChain().getDriver(), CmdArgs, Args);
+
CmdArgs.push_back("-lmoldname");
CmdArgs.push_back("-lmingwex");
CmdArgs.push_back("-lmsvcrt");
More information about the llvm-branch-commits
mailing list