diff options
author | Daniel Dunbar <daniel@zuster.org> | 2010-09-17 01:16:06 +0000 |
---|---|---|
committer | Daniel Dunbar <daniel@zuster.org> | 2010-09-17 01:16:06 +0000 |
commit | 8fa86b1a44d0ea8a97df66a271dca5cfebdb38c0 (patch) | |
tree | 99dcc0f6c6c538ab7d4f4182dc58bfd6f51b6daf /clang/lib/Driver/ToolChains.cpp | |
parent | 7f9c92a9a0740c2e198ae3a38770b59150555ea0 (diff) | |
download | bcm5719-llvm-8fa86b1a44d0ea8a97df66a271dca5cfebdb38c0.tar.gz bcm5719-llvm-8fa86b1a44d0ea8a97df66a271dca5cfebdb38c0.zip |
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.
llvm-svn: 114146
Diffstat (limited to 'clang/lib/Driver/ToolChains.cpp')
-rw-r--r-- | clang/lib/Driver/ToolChains.cpp | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/clang/lib/Driver/ToolChains.cpp b/clang/lib/Driver/ToolChains.cpp index f5b45595fda..865f2904228 100644 --- a/clang/lib/Driver/ToolChains.cpp +++ b/clang/lib/Driver/ToolChains.cpp @@ -578,6 +578,52 @@ void Darwin::AddDeploymentTarget(DerivedArgList &Args) const { 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()); |