diff options
author | rdivacky <rdivacky@FreeBSD.org> | 2009-10-14 18:03:49 +0000 |
---|---|---|
committer | rdivacky <rdivacky@FreeBSD.org> | 2009-10-14 18:03:49 +0000 |
commit | 9092c3e0fa01f3139b016d05d267a89e3b07747a (patch) | |
tree | 137ebebcae16fb0ce7ab4af456992bbd8d22fced /lib/Driver/ToolChains.cpp | |
parent | 4981926bf654fe5a2c3893f24ca44106b217e71e (diff) | |
download | FreeBSD-src-9092c3e0fa01f3139b016d05d267a89e3b07747a.zip FreeBSD-src-9092c3e0fa01f3139b016d05d267a89e3b07747a.tar.gz |
Update clang to r84119.
Diffstat (limited to 'lib/Driver/ToolChains.cpp')
-rw-r--r-- | lib/Driver/ToolChains.cpp | 392 |
1 files changed, 327 insertions, 65 deletions
diff --git a/lib/Driver/ToolChains.cpp b/lib/Driver/ToolChains.cpp index f663ed4..a5a48ad 100644 --- a/lib/Driver/ToolChains.cpp +++ b/lib/Driver/ToolChains.cpp @@ -17,6 +17,7 @@ #include "clang/Driver/Option.h" #include "llvm/ADT/StringExtras.h" +#include "llvm/Support/ErrorHandling.h" #include "llvm/Support/raw_ostream.h" #include "llvm/System/Path.h" @@ -25,21 +26,34 @@ using namespace clang::driver; using namespace clang::driver::toolchains; -/// Darwin_X86 - Darwin tool chain for i386 and x86_64. +/// Darwin - Darwin tool chain for i386 and x86_64. -Darwin_X86::Darwin_X86(const HostInfo &Host, const llvm::Triple& Triple, - const unsigned (&_DarwinVersion)[3], - const unsigned (&_GCCVersion)[3]) - : ToolChain(Host, Triple) { +Darwin::Darwin(const HostInfo &Host, const llvm::Triple& Triple, + const unsigned (&_DarwinVersion)[3], bool _IsIPhoneOS) + : ToolChain(Host, Triple), + IsIPhoneOS(_IsIPhoneOS) +{ DarwinVersion[0] = _DarwinVersion[0]; DarwinVersion[1] = _DarwinVersion[1]; DarwinVersion[2] = _DarwinVersion[2]; + + llvm::raw_string_ostream(MacosxVersionMin) + << "10." << DarwinVersion[0] - 4 << '.' << DarwinVersion[1]; + + // FIXME: Lift default up. + IPhoneOSVersionMin = "3.0"; +} + +DarwinGCC::DarwinGCC(const HostInfo &Host, const llvm::Triple& Triple, + const unsigned (&DarwinVersion)[3], + const unsigned (&_GCCVersion)[3], bool IsIPhoneOS) + : Darwin(Host, Triple, DarwinVersion, IsIPhoneOS) +{ GCCVersion[0] = _GCCVersion[0]; GCCVersion[1] = _GCCVersion[1]; GCCVersion[2] = _GCCVersion[2]; - llvm::raw_string_ostream(MacosxVersionMin) - << "10." << DarwinVersion[0] - 4 << '.' << DarwinVersion[1]; + // Set up the tool chain paths to match gcc. ToolChainDir = "i686-apple-darwin"; ToolChainDir += llvm::utostr(DarwinVersion[0]); @@ -54,32 +68,32 @@ Darwin_X86::Darwin_X86(const HostInfo &Host, const llvm::Triple& Triple, if (getArchName() == "x86_64") { Path = getHost().getDriver().Dir; Path += "/../lib/gcc/"; - Path += getToolChainDir(); + Path += ToolChainDir; Path += "/x86_64"; getFilePaths().push_back(Path); Path = "/usr/lib/gcc/"; - Path += getToolChainDir(); + Path += ToolChainDir; Path += "/x86_64"; getFilePaths().push_back(Path); } - + Path = getHost().getDriver().Dir; Path += "/../lib/gcc/"; - Path += getToolChainDir(); + Path += ToolChainDir; getFilePaths().push_back(Path); Path = "/usr/lib/gcc/"; - Path += getToolChainDir(); + Path += ToolChainDir; getFilePaths().push_back(Path); Path = getHost().getDriver().Dir; Path += "/../libexec/gcc/"; - Path += getToolChainDir(); + Path += ToolChainDir; getProgramPaths().push_back(Path); Path = "/usr/libexec/gcc/"; - Path += getToolChainDir(); + Path += ToolChainDir; getProgramPaths().push_back(Path); Path = getHost().getDriver().Dir; @@ -89,17 +103,16 @@ Darwin_X86::Darwin_X86(const HostInfo &Host, const llvm::Triple& Triple, getProgramPaths().push_back(getHost().getDriver().Dir); } -Darwin_X86::~Darwin_X86() { +Darwin::~Darwin() { // Free tool implementations. for (llvm::DenseMap<unsigned, Tool*>::iterator it = Tools.begin(), ie = Tools.end(); it != ie; ++it) delete it->second; } -Tool &Darwin_X86::SelectTool(const Compilation &C, - const JobAction &JA) const { +Tool &Darwin::SelectTool(const Compilation &C, const JobAction &JA) const { Action::ActionClass Key; - if (getHost().getDriver().ShouldUseClangCompiler(C, JA, getArchName())) + if (getHost().getDriver().ShouldUseClangCompiler(C, JA, getTriple())) Key = Action::AnalyzeJobClass; else Key = JA.getKind(); @@ -120,7 +133,7 @@ Tool &Darwin_X86::SelectTool(const Compilation &C, case Action::AssembleJobClass: T = new tools::darwin::Assemble(*this); break; case Action::LinkJobClass: - T = new tools::darwin::Link(*this, MacosxVersionMin.c_str()); break; + T = new tools::darwin::Link(*this); break; case Action::LipoJobClass: T = new tools::darwin::Lipo(*this); break; } @@ -129,7 +142,136 @@ Tool &Darwin_X86::SelectTool(const Compilation &C, return *T; } -DerivedArgList *Darwin_X86::TranslateArgs(InputArgList &Args) const { +void DarwinGCC::AddLinkSearchPathArgs(const ArgList &Args, + ArgStringList &CmdArgs) const { + // 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)); + 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)); + 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 { + unsigned MacosxVersionMin[3]; + getMacosxVersionMin(Args, MacosxVersionMin); + + // 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 (isIPhoneOS()) { + CmdArgs.push_back("-lgcc_s.1"); + } else { + CmdArgs.push_back("-lgcc_s.10.5"); + } + } else if (Args.hasArg(options::OPT_shared_libgcc) || + // FIXME: -fexceptions -fno-exceptions means no exceptions + Args.hasArg(options::OPT_fexceptions) || + Args.hasArg(options::OPT_fgnu_runtime)) { + // FIXME: This is probably broken on 10.3? + if (isMacosxVersionLT(MacosxVersionMin, 10, 5)) + CmdArgs.push_back("-lgcc_s.10.4"); + else if (isMacosxVersionLT(MacosxVersionMin, 10, 6)) + CmdArgs.push_back("-lgcc_s.10.5"); + } else { + if (isMacosxVersionLT(MacosxVersionMin, 10, 3, 9)) + ; // Do nothing. + else if (isMacosxVersionLT(MacosxVersionMin, 10, 5)) + CmdArgs.push_back("-lgcc_s.10.4"); + else if (isMacosxVersionLT(MacosxVersionMin, 10, 6)) + CmdArgs.push_back("-lgcc_s.10.5"); + } + + if (isIPhoneOS() || isMacosxVersionLT(MacosxVersionMin, 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, + const unsigned (&DarwinVersion)[3], + bool IsIPhoneOS) + : Darwin(Host, Triple, DarwinVersion, IsIPhoneOS) +{ + // Add the relative libexec dir (for clang-cc). + // + // FIXME: We should sink clang-cc into libexec/clang/<version>/. + std::string Path = getHost().getDriver().Dir; + Path += "/../libexec"; + getProgramPaths().push_back(Path); + + // We expect 'as', 'ld', etc. to be adjacent to our install dir. + getProgramPaths().push_back(getHost().getDriver().Dir); +} + +void DarwinClang::AddLinkSearchPathArgs(const ArgList &Args, + ArgStringList &CmdArgs) const { + // The Clang toolchain uses explicit paths for internal libraries. +} + +void DarwinClang::AddLinkRuntimeLibArgs(const ArgList &Args, + ArgStringList &CmdArgs) const { + // Check for static linking. + if (Args.hasArg(options::OPT_static)) { + // FIXME: We need to have compiler-rt available (perhaps as + // libclang_static.a) to link against. + return; + } + + // Reject -static-libgcc for now, we can deal with this when and if someone + // cares. This is useful in situations where someone wants to statically link + // something like libstdc++, and needs its runtime support routines. + if (const Arg *A = Args.getLastArg(options::OPT_static_libgcc)) { + getHost().getDriver().Diag(clang::diag::err_drv_unsupported_opt) + << A->getAsString(Args); + return; + } + + // Otherwise link libSystem, which should have the support routines. + // + // FIXME: This is only true for 10.6 and beyond. Legacy support isn't + // critical, but it should work... we should just link in the static + // compiler-rt library. + CmdArgs.push_back("-lSystem"); +} + +void Darwin::getMacosxVersionMin(const ArgList &Args, + unsigned (&Res)[3]) const { + if (Arg *A = Args.getLastArg(options::OPT_mmacosx_version_min_EQ)) { + bool HadExtra; + if (!Driver::GetReleaseVersion(A->getValue(Args), Res[0], Res[1], Res[2], + HadExtra) || + HadExtra) { + const Driver &D = getHost().getDriver(); + D.Diag(clang::diag::err_drv_invalid_version_number) + << A->getAsString(Args); + } + } else + return getMacosxVersion(Res); +} + +DerivedArgList *Darwin::TranslateArgs(InputArgList &Args, + const char *BoundArch) const { DerivedArgList *DAL = new DerivedArgList(Args, false); const OptTable &Opts = getHost().getDriver().getOpts(); @@ -138,30 +280,36 @@ DerivedArgList *Darwin_X86::TranslateArgs(InputArgList &Args) const { // more opaque. For now, we follow gcc closely solely for the // purpose of easily achieving feature parity & testability. Once we // have something that works, we should reevaluate each translation - // and try to push it down into tool specific logic. + // and try to push it down into tool specific logic. - Arg *OSXVersion = + Arg *OSXVersion = Args.getLastArg(options::OPT_mmacosx_version_min_EQ, false); Arg *iPhoneVersion = - Args.getLastArg(options::OPT_miphoneos_version_min_EQ, false); + Args.getLastArg(options::OPT_miphoneos_version_min_EQ, false); if (OSXVersion && iPhoneVersion) { getHost().getDriver().Diag(clang::diag::err_drv_argument_not_allowed_with) << OSXVersion->getAsString(Args) - << iPhoneVersion->getAsString(Args); + << iPhoneVersion->getAsString(Args); } else if (!OSXVersion && !iPhoneVersion) { // Chose the default version based on the arch. // - // FIXME: This will need to be fixed when we merge in arm support. - - // Look for MACOSX_DEPLOYMENT_TARGET, otherwise use the version - // from the host. - const char *Version = ::getenv("MACOSX_DEPLOYMENT_TARGET"); - if (!Version) - Version = MacosxVersionMin.c_str(); - const Option *O = Opts.getOption(options::OPT_mmacosx_version_min_EQ); - DAL->append(DAL->MakeJoinedArg(0, O, Version)); + // FIXME: Are there iPhone overrides for this? + + if (!isIPhoneOS()) { + // Look for MACOSX_DEPLOYMENT_TARGET, otherwise use the version + // from the host. + const char *Version = ::getenv("MACOSX_DEPLOYMENT_TARGET"); + if (!Version) + Version = MacosxVersionMin.c_str(); + const Option *O = Opts.getOption(options::OPT_mmacosx_version_min_EQ); + DAL->append(DAL->MakeJoinedArg(0, O, Version)); + } else { + const char *Version = IPhoneOSVersionMin.c_str(); + const Option *O = Opts.getOption(options::OPT_miphoneos_version_min_EQ); + DAL->append(DAL->MakeJoinedArg(0, O, Version)); + } } - + for (ArgList::iterator it = Args.begin(), ie = Args.end(); it != ie; ++it) { Arg *A = *it; @@ -174,7 +322,7 @@ DerivedArgList *Darwin_X86::TranslateArgs(InputArgList &Args) const { // interface for this. unsigned Prev, Index = Prev = A->getIndex() + 1; Arg *XarchArg = Opts.ParseOneArg(Args, Index); - + // If the argument parsing failed or more than one argument was // consumed, the -Xarch_ argument's parameter tried to consume // extra arguments. Emit an error and ignore. @@ -183,7 +331,7 @@ DerivedArgList *Darwin_X86::TranslateArgs(InputArgList &Args) const { // driver behavior; that isn't going to work in our model. We // use isDriverOption() as an approximation, although things // like -O4 are going to slip through. - if (!XarchArg || Index > Prev + 1 || + if (!XarchArg || Index > Prev + 1 || XarchArg->getOption().isDriverOption()) { getHost().getDriver().Diag(clang::diag::err_drv_invalid_Xarch_argument) << A->getAsString(Args); @@ -192,7 +340,7 @@ DerivedArgList *Darwin_X86::TranslateArgs(InputArgList &Args) const { XarchArg->setBaseArg(A); A = XarchArg; - } + } // Sob. These is strictly gcc compatible for the time being. Apple // gcc translates options twice, which means that self-expanding @@ -209,7 +357,7 @@ DerivedArgList *Darwin_X86::TranslateArgs(InputArgList &Args) const { DAL->append(DAL->MakeFlagArg(A, Opts.getOption(options::OPT_static))); DAL->append(DAL->MakeFlagArg(A, Opts.getOption(options::OPT_static))); break; - + case options::OPT_dependency_file: DAL->append(DAL->MakeSeparateArg(A, Opts.getOption(options::OPT_MF), A->getValue(Args))); @@ -270,35 +418,98 @@ DerivedArgList *Darwin_X86::TranslateArgs(InputArgList &Args) const { } } - // FIXME: Actually, gcc always adds this, but it is filtered for - // duplicates somewhere. This also changes the order of things, so - // look it up. - if (getArchName() == "x86_64") - if (!Args.hasArg(options::OPT_m64, false)) + if (getTriple().getArch() == llvm::Triple::x86 || + getTriple().getArch() == llvm::Triple::x86_64) + if (!Args.hasArg(options::OPT_mtune_EQ, false)) + DAL->append(DAL->MakeJoinedArg(0, Opts.getOption(options::OPT_mtune_EQ), + "core2")); + + // Add the arch options based on the particular spelling of -arch, to match + // how the driver driver works. + if (BoundArch) { + llvm::StringRef Name = BoundArch; + const Option *MCpu = Opts.getOption(options::OPT_mcpu_EQ); + const Option *MArch = Opts.getOption(options::OPT_march_EQ); + + // This code must be kept in sync with LLVM's getArchTypeForDarwinArch, + // which defines the list of which architectures we accept. + if (Name == "ppc") + ; + else if (Name == "ppc601") + DAL->append(DAL->MakeJoinedArg(0, MCpu, "601")); + else if (Name == "ppc603") + DAL->append(DAL->MakeJoinedArg(0, MCpu, "603")); + else if (Name == "ppc604") + DAL->append(DAL->MakeJoinedArg(0, MCpu, "604")); + else if (Name == "ppc604e") + DAL->append(DAL->MakeJoinedArg(0, MCpu, "604e")); + else if (Name == "ppc750") + DAL->append(DAL->MakeJoinedArg(0, MCpu, "750")); + else if (Name == "ppc7400") + DAL->append(DAL->MakeJoinedArg(0, MCpu, "7400")); + else if (Name == "ppc7450") + DAL->append(DAL->MakeJoinedArg(0, MCpu, "7450")); + else if (Name == "ppc970") + DAL->append(DAL->MakeJoinedArg(0, MCpu, "970")); + + else if (Name == "ppc64") + DAL->append(DAL->MakeFlagArg(0, Opts.getOption(options::OPT_m64))); + + else if (Name == "i386") + ; + else if (Name == "i486") + DAL->append(DAL->MakeJoinedArg(0, MArch, "i486")); + else if (Name == "i586") + DAL->append(DAL->MakeJoinedArg(0, MArch, "i586")); + else if (Name == "i686") + DAL->append(DAL->MakeJoinedArg(0, MArch, "i686")); + else if (Name == "pentium") + DAL->append(DAL->MakeJoinedArg(0, MArch, "pentium")); + else if (Name == "pentium2") + DAL->append(DAL->MakeJoinedArg(0, MArch, "pentium2")); + else if (Name == "pentpro") + DAL->append(DAL->MakeJoinedArg(0, MArch, "pentiumpro")); + else if (Name == "pentIIm3") + DAL->append(DAL->MakeJoinedArg(0, MArch, "pentium2")); + + else if (Name == "x86_64") DAL->append(DAL->MakeFlagArg(0, Opts.getOption(options::OPT_m64))); - if (!Args.hasArg(options::OPT_mtune_EQ, false)) - DAL->append(DAL->MakeJoinedArg(0, Opts.getOption(options::OPT_mtune_EQ), - "core2")); + else if (Name == "arm") + DAL->append(DAL->MakeJoinedArg(0, MArch, "armv4t")); + else if (Name == "armv4t") + DAL->append(DAL->MakeJoinedArg(0, MArch, "armv4t")); + else if (Name == "armv5") + DAL->append(DAL->MakeJoinedArg(0, MArch, "armv5tej")); + else if (Name == "xscale") + DAL->append(DAL->MakeJoinedArg(0, MArch, "xscale")); + else if (Name == "armv6") + DAL->append(DAL->MakeJoinedArg(0, MArch, "armv6k")); + else if (Name == "armv7") + DAL->append(DAL->MakeJoinedArg(0, MArch, "armv7a")); + + else + llvm::llvm_unreachable("invalid Darwin arch"); + } return DAL; -} +} -bool Darwin_X86::IsMathErrnoDefault() const { - return false; +bool Darwin::IsMathErrnoDefault() const { + return false; } -bool Darwin_X86::IsUnwindTablesDefault() const { +bool Darwin::IsUnwindTablesDefault() const { // FIXME: Gross; we should probably have some separate target // definition, possibly even reusing the one in clang. return getArchName() == "x86_64"; } -const char *Darwin_X86::GetDefaultRelocationModel() const { +const char *Darwin::GetDefaultRelocationModel() const { return "pic"; } -const char *Darwin_X86::GetForcedPicModel() const { +const char *Darwin::GetForcedPicModel() const { if (getArchName() == "x86_64") return "pic"; return 0; @@ -309,13 +520,12 @@ const char *Darwin_X86::GetForcedPicModel() const { /// command line options. Generic_GCC::Generic_GCC(const HostInfo &Host, const llvm::Triple& Triple) - : ToolChain(Host, Triple) -{ + : ToolChain(Host, Triple) { std::string Path(getHost().getDriver().Dir); Path += "/../libexec"; getProgramPaths().push_back(Path); - getProgramPaths().push_back(getHost().getDriver().Dir); + getProgramPaths().push_back(getHost().getDriver().Dir); } Generic_GCC::~Generic_GCC() { @@ -325,10 +535,10 @@ Generic_GCC::~Generic_GCC() { delete it->second; } -Tool &Generic_GCC::SelectTool(const Compilation &C, +Tool &Generic_GCC::SelectTool(const Compilation &C, const JobAction &JA) const { Action::ActionClass Key; - if (getHost().getDriver().ShouldUseClangCompiler(C, JA, getArchName())) + if (getHost().getDriver().ShouldUseClangCompiler(C, JA, getTriple())) Key = Action::AnalyzeJobClass; else Key = JA.getKind(); @@ -351,7 +561,7 @@ Tool &Generic_GCC::SelectTool(const Compilation &C, T = new tools::gcc::Assemble(*this); break; case Action::LinkJobClass: T = new tools::gcc::Link(*this); break; - + // This is a bit ungeneric, but the only platform using a driver // driver is Darwin. case Action::LipoJobClass: @@ -362,8 +572,8 @@ Tool &Generic_GCC::SelectTool(const Compilation &C, return *T; } -bool Generic_GCC::IsMathErrnoDefault() const { - return true; +bool Generic_GCC::IsMathErrnoDefault() const { + return true; } bool Generic_GCC::IsUnwindTablesDefault() const { @@ -380,7 +590,8 @@ const char *Generic_GCC::GetForcedPicModel() const { return 0; } -DerivedArgList *Generic_GCC::TranslateArgs(InputArgList &Args) const { +DerivedArgList *Generic_GCC::TranslateArgs(InputArgList &Args, + const char *BoundArch) const { return new DerivedArgList(Args, true); } @@ -394,7 +605,7 @@ OpenBSD::OpenBSD(const HostInfo &Host, const llvm::Triple& Triple) Tool &OpenBSD::SelectTool(const Compilation &C, const JobAction &JA) const { Action::ActionClass Key; - if (getHost().getDriver().ShouldUseClangCompiler(C, JA, getArchName())) + if (getHost().getDriver().ShouldUseClangCompiler(C, JA, getTriple())) Key = Action::AnalyzeJobClass; else Key = JA.getKind(); @@ -429,7 +640,7 @@ FreeBSD::FreeBSD(const HostInfo &Host, const llvm::Triple& Triple, bool Lib32) Tool &FreeBSD::SelectTool(const Compilation &C, const JobAction &JA) const { Action::ActionClass Key; - if (getHost().getDriver().ShouldUseClangCompiler(C, JA, getArchName())) + if (getHost().getDriver().ShouldUseClangCompiler(C, JA, getTriple())) Key = Action::AnalyzeJobClass; else Key = JA.getKind(); @@ -449,6 +660,48 @@ Tool &FreeBSD::SelectTool(const Compilation &C, const JobAction &JA) const { return *T; } +/// AuroraUX - AuroraUX tool chain which can call as(1) and ld(1) directly. + +AuroraUX::AuroraUX(const HostInfo &Host, const llvm::Triple& Triple) + : Generic_GCC(Host, Triple) { + + // Path mangling to find libexec + std::string Path(getHost().getDriver().Dir); + + Path += "/../libexec"; + getProgramPaths().push_back(Path); + getProgramPaths().push_back(getHost().getDriver().Dir); + + getFilePaths().push_back(getHost().getDriver().Dir + "/../lib"); + getFilePaths().push_back("/usr/lib"); + getFilePaths().push_back("/usr/sfw/lib"); + getFilePaths().push_back("/opt/gcc4/lib"); + +} + +Tool &AuroraUX::SelectTool(const Compilation &C, const JobAction &JA) const { + Action::ActionClass Key; + if (getHost().getDriver().ShouldUseClangCompiler(C, JA, getTriple())) + Key = Action::AnalyzeJobClass; + else + Key = JA.getKind(); + + Tool *&T = Tools[Key]; + if (!T) { + switch (Key) { + case Action::AssembleJobClass: + T = new tools::auroraux::Assemble(*this); break; + case Action::LinkJobClass: + T = new tools::auroraux::Link(*this); break; + default: + T = &Generic_GCC::SelectTool(C, JA); + } + } + + return *T; +} + + /// Linux toolchain (very bare-bones at the moment). Linux::Linux(const HostInfo &Host, const llvm::Triple& Triple) @@ -456,6 +709,15 @@ Linux::Linux(const HostInfo &Host, const llvm::Triple& Triple) getFilePaths().push_back(getHost().getDriver().Dir + "/../lib/clang/1.0/"); getFilePaths().push_back("/lib/"); getFilePaths().push_back("/usr/lib/"); + + // Depending on the Linux distribution, any combination of lib{,32,64} is + // possible. E.g. Debian uses lib and lib32 for mixed i386/x86-64 systems, + // openSUSE uses lib and lib64 for the same purpose. + getFilePaths().push_back("/lib32/"); + getFilePaths().push_back("/usr/lib32/"); + getFilePaths().push_back("/lib64/"); + getFilePaths().push_back("/usr/lib64/"); + // FIXME: Figure out some way to get gcc's libdir // (e.g. /usr/lib/gcc/i486-linux-gnu/4.3/ for Ubuntu 32-bit); we need // crtbegin.o/crtend.o/etc., and want static versions of various @@ -475,7 +737,7 @@ DragonFly::DragonFly(const HostInfo &Host, const llvm::Triple& Triple) Path += "/../libexec"; getProgramPaths().push_back(Path); - getProgramPaths().push_back(getHost().getDriver().Dir); + getProgramPaths().push_back(getHost().getDriver().Dir); getFilePaths().push_back(getHost().getDriver().Dir + "/../lib"); getFilePaths().push_back("/usr/lib"); @@ -484,7 +746,7 @@ DragonFly::DragonFly(const HostInfo &Host, const llvm::Triple& Triple) Tool &DragonFly::SelectTool(const Compilation &C, const JobAction &JA) const { Action::ActionClass Key; - if (getHost().getDriver().ShouldUseClangCompiler(C, JA, getArchName())) + if (getHost().getDriver().ShouldUseClangCompiler(C, JA, getTriple())) Key = Action::AnalyzeJobClass; else Key = JA.getKind(); |