[cfe-commits] r114146 - in /cfe/trunk/lib/Driver: ToolChains.cpp ToolChains.h
Daniel Dunbar
daniel at zuster.org
Thu Sep 16 18:16:06 PDT 2010
Author: ddunbar
Date: Thu Sep 16 20:16:06 2010
New Revision: 114146
URL: http://llvm.org/viewvc/llvm-project?rev=114146&view=rev
Log:
Driver/DarwinClang: The new toolchain definition is going to drop the -L inside
the GCC dir. Unfortunately, this breaks -lstdc++ on SnowLeopard, etc. because
the libstdc++ dylib was hiding there. Workaround this by providing the path to
the right -lstdc++.6 (the only version used in recent memory) if we can't see an
obvious -lstdc++, but can find = -lstdc++.6.
Modified:
cfe/trunk/lib/Driver/ToolChains.cpp
cfe/trunk/lib/Driver/ToolChains.h
Modified: cfe/trunk/lib/Driver/ToolChains.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains.cpp?rev=114146&r1=114145&r2=114146&view=diff
==============================================================================
--- cfe/trunk/lib/Driver/ToolChains.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains.cpp Thu Sep 16 20:16:06 2010
@@ -578,6 +578,52 @@
setTarget(iPhoneVersion, Major, Minor, Micro);
}
+void DarwinClang::AddClangCXXStdlibLibArgs(const ArgList &Args,
+ ArgStringList &CmdArgs) const {
+ CXXStdlibType Type = GetCXXStdlibType(Args);
+
+ switch (Type) {
+ case ToolChain::CST_Libcxx:
+ CmdArgs.push_back("-lc++");
+ break;
+
+ case ToolChain::CST_Libstdcxx: {
+ // Unfortunately, -lstdc++ doesn't always exist in the standard search path;
+ // it was previously found in the gcc lib dir. However, for all the Darwin
+ // platforms we care about it was -lstdc++.6, so we search for that
+ // explicitly if we can't see an obvious -lstdc++ candidate.
+
+ // Check in the sysroot first.
+ if (const Arg *A = Args.getLastArg(options::OPT_isysroot)) {
+ llvm::sys::Path P(A->getValue(Args));
+ P.appendComponent("usr");
+ P.appendComponent("lib");
+ P.appendComponent("libstdc++.dylib");
+
+ if (!P.exists()) {
+ P.eraseComponent();
+ P.appendComponent("libstdc++.6.dylib");
+ if (P.exists()) {
+ CmdArgs.push_back(Args.MakeArgString(P.str()));
+ return;
+ }
+ }
+ }
+
+ // Otherwise, look in the root.
+ if (!llvm::sys::Path("/usr/lib/libstdc++.dylib").exists() &&
+ llvm::sys::Path("/usr/lib/libstdc++.6.dylib").exists()) {
+ CmdArgs.push_back("/usr/lib/libstdc++.6.dylib");
+ return;
+ }
+
+ // Otherwise, let the linker search.
+ CmdArgs.push_back("-lstdc++");
+ break;
+ }
+ }
+}
+
DerivedArgList *Darwin::TranslateArgs(const DerivedArgList &Args,
const char *BoundArch) const {
DerivedArgList *DAL = new DerivedArgList(Args.getBaseArgs());
Modified: cfe/trunk/lib/Driver/ToolChains.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains.h?rev=114146&r1=114145&r2=114146&view=diff
==============================================================================
--- cfe/trunk/lib/Driver/ToolChains.h (original)
+++ cfe/trunk/lib/Driver/ToolChains.h Thu Sep 16 20:16:06 2010
@@ -223,6 +223,9 @@
virtual void AddLinkRuntimeLibArgs(const ArgList &Args,
ArgStringList &CmdArgs) const;
+ virtual void AddClangCXXStdlibLibArgs(const ArgList &Args,
+ ArgStringList &CmdArgs) const;
+
/// }
};
More information about the cfe-commits
mailing list