}
}
-DarwinGCC::DarwinGCC(const HostInfo &Host, const llvm::Triple& Triple)
- : Darwin(Host, Triple)
-{
- // We can only work with 4.2.1 currently.
- GCCVersion[0] = 4;
- GCCVersion[1] = 2;
- GCCVersion[2] = 1;
-
- // Set up the tool chain paths to match gcc.
- ToolChainDir = "i686-apple-darwin";
- ToolChainDir += llvm::utostr(DarwinVersion[0]);
- ToolChainDir += "/";
- ToolChainDir += llvm::utostr(GCCVersion[0]);
- ToolChainDir += '.';
- ToolChainDir += llvm::utostr(GCCVersion[1]);
- ToolChainDir += '.';
- ToolChainDir += llvm::utostr(GCCVersion[2]);
-
- // Try the next major version if that tool chain dir is invalid.
- std::string Tmp = "/usr/lib/gcc/" + ToolChainDir;
- bool Exists;
- if (llvm::sys::fs::exists(Tmp, Exists) || Exists) {
- std::string Next = "i686-apple-darwin";
- Next += llvm::utostr(DarwinVersion[0] + 1);
- Next += "/";
- Next += llvm::utostr(GCCVersion[0]);
- Next += '.';
- Next += llvm::utostr(GCCVersion[1]);
- Next += '.';
- Next += llvm::utostr(GCCVersion[2]);
-
- // Use that if it exists, otherwise hope the user isn't linking.
- //
- // FIXME: Drop dependency on gcc's tool chain.
- Tmp = "/usr/lib/gcc/" + Next;
- if (!llvm::sys::fs::exists(Tmp, Exists) && Exists)
- ToolChainDir = Next;
- }
-
- std::string Path;
- if (getArchName() == "x86_64") {
- Path = getDriver().Dir;
- Path += "/../lib/gcc/";
- Path += ToolChainDir;
- Path += "/x86_64";
- getFilePaths().push_back(Path);
-
- Path = "/usr/lib/gcc/";
- Path += ToolChainDir;
- Path += "/x86_64";
- getFilePaths().push_back(Path);
- }
-
- Path = getDriver().Dir;
- Path += "/../lib/gcc/";
- Path += ToolChainDir;
- getFilePaths().push_back(Path);
-
- Path = "/usr/lib/gcc/";
- Path += ToolChainDir;
- getFilePaths().push_back(Path);
-
- Path = getDriver().Dir;
- Path += "/../libexec/gcc/";
- Path += ToolChainDir;
- getProgramPaths().push_back(Path);
-
- Path = "/usr/libexec/gcc/";
- Path += ToolChainDir;
- getProgramPaths().push_back(Path);
-
- getProgramPaths().push_back(getDriver().getInstalledDir());
- if (getDriver().getInstalledDir() != getDriver().Dir)
- getProgramPaths().push_back(getDriver().Dir);
-}
-
Darwin::~Darwin() {
// Free tool implementations.
for (llvm::DenseMap<unsigned, Tool*>::iterator
return *T;
}
-void DarwinGCC::AddLinkSearchPathArgs(const ArgList &Args,
- ArgStringList &CmdArgs) const {
- std::string Tmp;
-
- // FIXME: Derive these correctly.
- if (getArchName() == "x86_64") {
- CmdArgs.push_back(Args.MakeArgString("-L/usr/lib/gcc/" + ToolChainDir +
- "/x86_64"));
- // Intentionally duplicated for (temporary) gcc bug compatibility.
- CmdArgs.push_back(Args.MakeArgString("-L/usr/lib/gcc/" + ToolChainDir +
- "/x86_64"));
- }
-
- CmdArgs.push_back(Args.MakeArgString("-L/usr/lib/" + ToolChainDir));
-
- Tmp = getDriver().Dir + "/../lib/gcc/" + ToolChainDir;
- bool Exists;
- if (!llvm::sys::fs::exists(Tmp, Exists) && Exists)
- CmdArgs.push_back(Args.MakeArgString("-L" + Tmp));
- Tmp = getDriver().Dir + "/../lib/gcc";
- if (!llvm::sys::fs::exists(Tmp, Exists) && Exists)
- CmdArgs.push_back(Args.MakeArgString("-L" + Tmp));
- CmdArgs.push_back(Args.MakeArgString("-L/usr/lib/gcc/" + ToolChainDir));
- // Intentionally duplicated for (temporary) gcc bug compatibility.
- CmdArgs.push_back(Args.MakeArgString("-L/usr/lib/gcc/" + ToolChainDir));
- Tmp = getDriver().Dir + "/../lib/" + ToolChainDir;
- if (!llvm::sys::fs::exists(Tmp, Exists) && Exists)
- CmdArgs.push_back(Args.MakeArgString("-L" + Tmp));
- Tmp = getDriver().Dir + "/../lib";
- if (!llvm::sys::fs::exists(Tmp, Exists) && Exists)
- CmdArgs.push_back(Args.MakeArgString("-L" + Tmp));
- CmdArgs.push_back(Args.MakeArgString("-L/usr/lib/gcc/" + ToolChainDir +
- "/../../../" + ToolChainDir));
- CmdArgs.push_back(Args.MakeArgString("-L/usr/lib/gcc/" + ToolChainDir +
- "/../../.."));
-}
-
-void DarwinGCC::AddLinkRuntimeLibArgs(const ArgList &Args,
- ArgStringList &CmdArgs) const {
- // Note that this routine is only used for targetting OS X.
-
- // Derived from libgcc and lib specs but refactored.
- if (Args.hasArg(options::OPT_static)) {
- CmdArgs.push_back("-lgcc_static");
- } else {
- if (Args.hasArg(options::OPT_static_libgcc)) {
- CmdArgs.push_back("-lgcc_eh");
- } else if (Args.hasArg(options::OPT_miphoneos_version_min_EQ)) {
- // Derived from darwin_iphoneos_libgcc spec.
- if (isTargetIPhoneOS()) {
- CmdArgs.push_back("-lgcc_s.1");
- } else {
- CmdArgs.push_back("-lgcc_s.10.5");
- }
- } else if (Args.hasArg(options::OPT_shared_libgcc) ||
- Args.hasFlag(options::OPT_fexceptions,
- options::OPT_fno_exceptions) ||
- Args.hasArg(options::OPT_fgnu_runtime)) {
- // FIXME: This is probably broken on 10.3?
- if (isMacosxVersionLT(10, 5))
- CmdArgs.push_back("-lgcc_s.10.4");
- else if (isMacosxVersionLT(10, 6))
- CmdArgs.push_back("-lgcc_s.10.5");
- } else {
- if (isMacosxVersionLT(10, 3, 9))
- ; // Do nothing.
- else if (isMacosxVersionLT(10, 5))
- CmdArgs.push_back("-lgcc_s.10.4");
- else if (isMacosxVersionLT(10, 6))
- CmdArgs.push_back("-lgcc_s.10.5");
- }
-
- if (isTargetIPhoneOS() || isMacosxVersionLT(10, 6)) {
- CmdArgs.push_back("-lgcc");
- CmdArgs.push_back("-lSystem");
- } else {
- CmdArgs.push_back("-lSystem");
- CmdArgs.push_back("-lgcc");
- }
- }
-}
DarwinClang::DarwinClang(const HostInfo &Host, const llvm::Triple& Triple)
: Darwin(Host, Triple)