Daniel Dunbar | 3917608 | 2009-03-20 00:20:03 +0000 | [diff] [blame] | 1 | //===--- ToolChains.cpp - ToolChain Implementations ---------------------*-===// |
| 2 | // |
| 3 | // The LLVM Compiler Infrastructure |
| 4 | // |
| 5 | // This file is distributed under the University of Illinois Open Source |
| 6 | // License. See LICENSE.TXT for details. |
| 7 | // |
| 8 | //===----------------------------------------------------------------------===// |
| 9 | |
| 10 | #include "ToolChains.h" |
| 11 | |
Daniel Dunbar | f3cad36 | 2009-03-25 04:13:45 +0000 | [diff] [blame] | 12 | #include "clang/Driver/Arg.h" |
| 13 | #include "clang/Driver/ArgList.h" |
Daniel Dunbar | c50b00d | 2009-03-23 16:15:50 +0000 | [diff] [blame] | 14 | #include "clang/Driver/Driver.h" |
Daniel Dunbar | 4e7e9cf | 2009-03-25 06:12:34 +0000 | [diff] [blame] | 15 | #include "clang/Driver/DriverDiagnostic.h" |
Daniel Dunbar | c50b00d | 2009-03-23 16:15:50 +0000 | [diff] [blame] | 16 | #include "clang/Driver/HostInfo.h" |
Daniel Dunbar | 4e7e9cf | 2009-03-25 06:12:34 +0000 | [diff] [blame] | 17 | #include "clang/Driver/Option.h" |
Daniel Dunbar | c50b00d | 2009-03-23 16:15:50 +0000 | [diff] [blame] | 18 | |
| 19 | #include "llvm/ADT/StringExtras.h" |
Daniel Dunbar | 84ec96c | 2009-09-09 22:33:15 +0000 | [diff] [blame] | 20 | #include "llvm/Support/ErrorHandling.h" |
Daniel Dunbar | ec069ed | 2009-03-25 06:58:31 +0000 | [diff] [blame] | 21 | #include "llvm/Support/raw_ostream.h" |
Daniel Dunbar | c50b00d | 2009-03-23 16:15:50 +0000 | [diff] [blame] | 22 | #include "llvm/System/Path.h" |
| 23 | |
Daniel Dunbar | f36a06a | 2009-04-10 21:00:07 +0000 | [diff] [blame] | 24 | #include <cstdlib> // ::getenv |
| 25 | |
Daniel Dunbar | 3917608 | 2009-03-20 00:20:03 +0000 | [diff] [blame] | 26 | using namespace clang::driver; |
| 27 | using namespace clang::driver::toolchains; |
| 28 | |
Daniel Dunbar | f395528 | 2009-09-04 18:34:51 +0000 | [diff] [blame] | 29 | /// Darwin - Darwin tool chain for i386 and x86_64. |
Daniel Dunbar | 8eddb3f | 2009-03-20 00:57:52 +0000 | [diff] [blame] | 30 | |
Daniel Dunbar | f395528 | 2009-09-04 18:34:51 +0000 | [diff] [blame] | 31 | Darwin::Darwin(const HostInfo &Host, const llvm::Triple& Triple, |
| 32 | const unsigned (&_DarwinVersion)[3], |
Daniel Dunbar | 30392de | 2009-09-04 18:35:21 +0000 | [diff] [blame] | 33 | const unsigned (&_GCCVersion)[3], |
| 34 | bool _IsIPhone) |
Daniel Dunbar | cb8ab23 | 2009-05-22 02:53:45 +0000 | [diff] [blame] | 35 | : ToolChain(Host, Triple) { |
Daniel Dunbar | c50b00d | 2009-03-23 16:15:50 +0000 | [diff] [blame] | 36 | DarwinVersion[0] = _DarwinVersion[0]; |
| 37 | DarwinVersion[1] = _DarwinVersion[1]; |
| 38 | DarwinVersion[2] = _DarwinVersion[2]; |
| 39 | GCCVersion[0] = _GCCVersion[0]; |
| 40 | GCCVersion[1] = _GCCVersion[1]; |
| 41 | GCCVersion[2] = _GCCVersion[2]; |
Daniel Dunbar | 30392de | 2009-09-04 18:35:21 +0000 | [diff] [blame] | 42 | IsIPhone = _IsIPhone; |
Daniel Dunbar | c50b00d | 2009-03-23 16:15:50 +0000 | [diff] [blame] | 43 | |
Daniel Dunbar | 02633b5 | 2009-03-26 16:23:12 +0000 | [diff] [blame] | 44 | llvm::raw_string_ostream(MacosxVersionMin) |
| 45 | << "10." << DarwinVersion[0] - 4 << '.' << DarwinVersion[1]; |
| 46 | |
Daniel Dunbar | 30392de | 2009-09-04 18:35:21 +0000 | [diff] [blame] | 47 | // FIXME: Lift default up. |
| 48 | IPhoneOSVersionMin = "3.0"; |
| 49 | |
Daniel Dunbar | c50b00d | 2009-03-23 16:15:50 +0000 | [diff] [blame] | 50 | ToolChainDir = "i686-apple-darwin"; |
| 51 | ToolChainDir += llvm::utostr(DarwinVersion[0]); |
| 52 | ToolChainDir += "/"; |
| 53 | ToolChainDir += llvm::utostr(GCCVersion[0]); |
| 54 | ToolChainDir += '.'; |
| 55 | ToolChainDir += llvm::utostr(GCCVersion[1]); |
| 56 | ToolChainDir += '.'; |
| 57 | ToolChainDir += llvm::utostr(GCCVersion[2]); |
| 58 | |
| 59 | std::string Path; |
| 60 | if (getArchName() == "x86_64") { |
| 61 | Path = getHost().getDriver().Dir; |
| 62 | Path += "/../lib/gcc/"; |
Daniel Dunbar | 6b200b2 | 2009-09-18 08:14:36 +0000 | [diff] [blame^] | 63 | Path += ToolChainDir; |
Daniel Dunbar | c50b00d | 2009-03-23 16:15:50 +0000 | [diff] [blame] | 64 | Path += "/x86_64"; |
| 65 | getFilePaths().push_back(Path); |
| 66 | |
| 67 | Path = "/usr/lib/gcc/"; |
Daniel Dunbar | 6b200b2 | 2009-09-18 08:14:36 +0000 | [diff] [blame^] | 68 | Path += ToolChainDir; |
Daniel Dunbar | c50b00d | 2009-03-23 16:15:50 +0000 | [diff] [blame] | 69 | Path += "/x86_64"; |
| 70 | getFilePaths().push_back(Path); |
| 71 | } |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 72 | |
Daniel Dunbar | c50b00d | 2009-03-23 16:15:50 +0000 | [diff] [blame] | 73 | Path = getHost().getDriver().Dir; |
| 74 | Path += "/../lib/gcc/"; |
Daniel Dunbar | 6b200b2 | 2009-09-18 08:14:36 +0000 | [diff] [blame^] | 75 | Path += ToolChainDir; |
Daniel Dunbar | c50b00d | 2009-03-23 16:15:50 +0000 | [diff] [blame] | 76 | getFilePaths().push_back(Path); |
| 77 | |
| 78 | Path = "/usr/lib/gcc/"; |
Daniel Dunbar | 6b200b2 | 2009-09-18 08:14:36 +0000 | [diff] [blame^] | 79 | Path += ToolChainDir; |
Daniel Dunbar | c50b00d | 2009-03-23 16:15:50 +0000 | [diff] [blame] | 80 | getFilePaths().push_back(Path); |
| 81 | |
| 82 | Path = getHost().getDriver().Dir; |
| 83 | Path += "/../libexec/gcc/"; |
Daniel Dunbar | 6b200b2 | 2009-09-18 08:14:36 +0000 | [diff] [blame^] | 84 | Path += ToolChainDir; |
Daniel Dunbar | c50b00d | 2009-03-23 16:15:50 +0000 | [diff] [blame] | 85 | getProgramPaths().push_back(Path); |
| 86 | |
| 87 | Path = "/usr/libexec/gcc/"; |
Daniel Dunbar | 6b200b2 | 2009-09-18 08:14:36 +0000 | [diff] [blame^] | 88 | Path += ToolChainDir; |
Daniel Dunbar | c50b00d | 2009-03-23 16:15:50 +0000 | [diff] [blame] | 89 | getProgramPaths().push_back(Path); |
| 90 | |
Daniel Dunbar | 82fa7c5 | 2009-03-24 04:07:10 +0000 | [diff] [blame] | 91 | Path = getHost().getDriver().Dir; |
| 92 | Path += "/../libexec"; |
| 93 | getProgramPaths().push_back(Path); |
| 94 | |
Daniel Dunbar | c50b00d | 2009-03-23 16:15:50 +0000 | [diff] [blame] | 95 | getProgramPaths().push_back(getHost().getDriver().Dir); |
| 96 | } |
| 97 | |
Daniel Dunbar | f395528 | 2009-09-04 18:34:51 +0000 | [diff] [blame] | 98 | Darwin::~Darwin() { |
Daniel Dunbar | 8eddb3f | 2009-03-20 00:57:52 +0000 | [diff] [blame] | 99 | // Free tool implementations. |
| 100 | for (llvm::DenseMap<unsigned, Tool*>::iterator |
| 101 | it = Tools.begin(), ie = Tools.end(); it != ie; ++it) |
| 102 | delete it->second; |
| 103 | } |
| 104 | |
Daniel Dunbar | f395528 | 2009-09-04 18:34:51 +0000 | [diff] [blame] | 105 | Tool &Darwin::SelectTool(const Compilation &C, const JobAction &JA) const { |
Daniel Dunbar | 8eddb3f | 2009-03-20 00:57:52 +0000 | [diff] [blame] | 106 | Action::ActionClass Key; |
Daniel Dunbar | a6046be | 2009-09-08 23:36:55 +0000 | [diff] [blame] | 107 | if (getHost().getDriver().ShouldUseClangCompiler(C, JA, getTriple())) |
Daniel Dunbar | 8eddb3f | 2009-03-20 00:57:52 +0000 | [diff] [blame] | 108 | Key = Action::AnalyzeJobClass; |
| 109 | else |
| 110 | Key = JA.getKind(); |
| 111 | |
| 112 | Tool *&T = Tools[Key]; |
| 113 | if (!T) { |
| 114 | switch (Key) { |
| 115 | case Action::InputClass: |
| 116 | case Action::BindArchClass: |
| 117 | assert(0 && "Invalid tool kind."); |
| 118 | case Action::PreprocessJobClass: |
Daniel Dunbar | 9120f17 | 2009-03-29 22:27:40 +0000 | [diff] [blame] | 119 | T = new tools::darwin::Preprocess(*this); break; |
Daniel Dunbar | 8eddb3f | 2009-03-20 00:57:52 +0000 | [diff] [blame] | 120 | case Action::AnalyzeJobClass: |
| 121 | T = new tools::Clang(*this); break; |
Daniel Dunbar | 9120f17 | 2009-03-29 22:27:40 +0000 | [diff] [blame] | 122 | case Action::PrecompileJobClass: |
Daniel Dunbar | 8eddb3f | 2009-03-20 00:57:52 +0000 | [diff] [blame] | 123 | case Action::CompileJobClass: |
Daniel Dunbar | 9120f17 | 2009-03-29 22:27:40 +0000 | [diff] [blame] | 124 | T = new tools::darwin::Compile(*this); break; |
Daniel Dunbar | 8eddb3f | 2009-03-20 00:57:52 +0000 | [diff] [blame] | 125 | case Action::AssembleJobClass: |
Daniel Dunbar | 8cac5f7 | 2009-03-20 16:06:39 +0000 | [diff] [blame] | 126 | T = new tools::darwin::Assemble(*this); break; |
Daniel Dunbar | 8eddb3f | 2009-03-20 00:57:52 +0000 | [diff] [blame] | 127 | case Action::LinkJobClass: |
Daniel Dunbar | 8f28962 | 2009-09-04 17:39:02 +0000 | [diff] [blame] | 128 | T = new tools::darwin::Link(*this); break; |
Daniel Dunbar | 8eddb3f | 2009-03-20 00:57:52 +0000 | [diff] [blame] | 129 | case Action::LipoJobClass: |
| 130 | T = new tools::darwin::Lipo(*this); break; |
| 131 | } |
| 132 | } |
| 133 | |
| 134 | return *T; |
| 135 | } |
| 136 | |
Daniel Dunbar | 6b200b2 | 2009-09-18 08:14:36 +0000 | [diff] [blame^] | 137 | void Darwin::AddLinkSearchPathArgs(const ArgList &Args, |
| 138 | ArgStringList &CmdArgs) const { |
| 139 | // FIXME: Derive these correctly. |
| 140 | if (getArchName() == "x86_64") { |
| 141 | CmdArgs.push_back(Args.MakeArgString("-L/usr/lib/gcc/" + ToolChainDir + |
| 142 | "/x86_64")); |
| 143 | // Intentionally duplicated for (temporary) gcc bug compatibility. |
| 144 | CmdArgs.push_back(Args.MakeArgString("-L/usr/lib/gcc/" + ToolChainDir + |
| 145 | "/x86_64")); |
| 146 | } |
| 147 | CmdArgs.push_back(Args.MakeArgString("-L/usr/lib/" + ToolChainDir)); |
| 148 | CmdArgs.push_back(Args.MakeArgString("-L/usr/lib/gcc/" + ToolChainDir)); |
| 149 | // Intentionally duplicated for (temporary) gcc bug compatibility. |
| 150 | CmdArgs.push_back(Args.MakeArgString("-L/usr/lib/gcc/" + ToolChainDir)); |
| 151 | CmdArgs.push_back(Args.MakeArgString("-L/usr/lib/gcc/" + ToolChainDir + |
| 152 | "/../../../" + ToolChainDir)); |
| 153 | CmdArgs.push_back(Args.MakeArgString("-L/usr/lib/gcc/" + ToolChainDir + |
| 154 | "/../../..")); |
| 155 | } |
| 156 | |
Daniel Dunbar | 0dcb9a3 | 2009-09-09 18:36:12 +0000 | [diff] [blame] | 157 | DerivedArgList *Darwin::TranslateArgs(InputArgList &Args, |
| 158 | const char *BoundArch) const { |
Daniel Dunbar | 4e7e9cf | 2009-03-25 06:12:34 +0000 | [diff] [blame] | 159 | DerivedArgList *DAL = new DerivedArgList(Args, false); |
Daniel Dunbar | ec069ed | 2009-03-25 06:58:31 +0000 | [diff] [blame] | 160 | const OptTable &Opts = getHost().getDriver().getOpts(); |
| 161 | |
| 162 | // FIXME: We really want to get out of the tool chain level argument |
| 163 | // translation business, as it makes the driver functionality much |
| 164 | // more opaque. For now, we follow gcc closely solely for the |
| 165 | // purpose of easily achieving feature parity & testability. Once we |
| 166 | // have something that works, we should reevaluate each translation |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 167 | // and try to push it down into tool specific logic. |
Daniel Dunbar | ec069ed | 2009-03-25 06:58:31 +0000 | [diff] [blame] | 168 | |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 169 | Arg *OSXVersion = |
Daniel Dunbar | ff8857a | 2009-04-10 20:11:50 +0000 | [diff] [blame] | 170 | Args.getLastArg(options::OPT_mmacosx_version_min_EQ, false); |
| 171 | Arg *iPhoneVersion = |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 172 | Args.getLastArg(options::OPT_miphoneos_version_min_EQ, false); |
Daniel Dunbar | ff8857a | 2009-04-10 20:11:50 +0000 | [diff] [blame] | 173 | if (OSXVersion && iPhoneVersion) { |
| 174 | getHost().getDriver().Diag(clang::diag::err_drv_argument_not_allowed_with) |
| 175 | << OSXVersion->getAsString(Args) |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 176 | << iPhoneVersion->getAsString(Args); |
Daniel Dunbar | ff8857a | 2009-04-10 20:11:50 +0000 | [diff] [blame] | 177 | } else if (!OSXVersion && !iPhoneVersion) { |
| 178 | // Chose the default version based on the arch. |
| 179 | // |
Daniel Dunbar | 30392de | 2009-09-04 18:35:21 +0000 | [diff] [blame] | 180 | // FIXME: Are there iPhone overrides for this? |
Daniel Dunbar | f36a06a | 2009-04-10 21:00:07 +0000 | [diff] [blame] | 181 | |
Daniel Dunbar | 30392de | 2009-09-04 18:35:21 +0000 | [diff] [blame] | 182 | if (!isIPhone()) { |
| 183 | // Look for MACOSX_DEPLOYMENT_TARGET, otherwise use the version |
| 184 | // from the host. |
| 185 | const char *Version = ::getenv("MACOSX_DEPLOYMENT_TARGET"); |
| 186 | if (!Version) |
| 187 | Version = MacosxVersionMin.c_str(); |
| 188 | const Option *O = Opts.getOption(options::OPT_mmacosx_version_min_EQ); |
| 189 | DAL->append(DAL->MakeJoinedArg(0, O, Version)); |
| 190 | } else { |
| 191 | const char *Version = IPhoneOSVersionMin.c_str(); |
| 192 | const Option *O = Opts.getOption(options::OPT_miphoneos_version_min_EQ); |
| 193 | DAL->append(DAL->MakeJoinedArg(0, O, Version)); |
| 194 | } |
Daniel Dunbar | ec069ed | 2009-03-25 06:58:31 +0000 | [diff] [blame] | 195 | } |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 196 | |
Daniel Dunbar | 4e7e9cf | 2009-03-25 06:12:34 +0000 | [diff] [blame] | 197 | for (ArgList::iterator it = Args.begin(), ie = Args.end(); it != ie; ++it) { |
| 198 | Arg *A = *it; |
| 199 | |
| 200 | if (A->getOption().matches(options::OPT_Xarch__)) { |
| 201 | // FIXME: Canonicalize name. |
| 202 | if (getArchName() != A->getValue(Args, 0)) |
| 203 | continue; |
| 204 | |
| 205 | // FIXME: The arg is leaked here, and we should have a nicer |
| 206 | // interface for this. |
Daniel Dunbar | 4e7e9cf | 2009-03-25 06:12:34 +0000 | [diff] [blame] | 207 | unsigned Prev, Index = Prev = A->getIndex() + 1; |
Daniel Dunbar | ec069ed | 2009-03-25 06:58:31 +0000 | [diff] [blame] | 208 | Arg *XarchArg = Opts.ParseOneArg(Args, Index); |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 209 | |
Daniel Dunbar | 4e7e9cf | 2009-03-25 06:12:34 +0000 | [diff] [blame] | 210 | // If the argument parsing failed or more than one argument was |
| 211 | // consumed, the -Xarch_ argument's parameter tried to consume |
| 212 | // extra arguments. Emit an error and ignore. |
| 213 | // |
| 214 | // We also want to disallow any options which would alter the |
| 215 | // driver behavior; that isn't going to work in our model. We |
| 216 | // use isDriverOption() as an approximation, although things |
| 217 | // like -O4 are going to slip through. |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 218 | if (!XarchArg || Index > Prev + 1 || |
Daniel Dunbar | 4e7e9cf | 2009-03-25 06:12:34 +0000 | [diff] [blame] | 219 | XarchArg->getOption().isDriverOption()) { |
Daniel Dunbar | ec069ed | 2009-03-25 06:58:31 +0000 | [diff] [blame] | 220 | getHost().getDriver().Diag(clang::diag::err_drv_invalid_Xarch_argument) |
Daniel Dunbar | 4e7e9cf | 2009-03-25 06:12:34 +0000 | [diff] [blame] | 221 | << A->getAsString(Args); |
| 222 | continue; |
| 223 | } |
| 224 | |
Daniel Dunbar | 478edc2 | 2009-03-29 22:29:05 +0000 | [diff] [blame] | 225 | XarchArg->setBaseArg(A); |
Daniel Dunbar | 4e7e9cf | 2009-03-25 06:12:34 +0000 | [diff] [blame] | 226 | A = XarchArg; |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 227 | } |
Daniel Dunbar | 4e7e9cf | 2009-03-25 06:12:34 +0000 | [diff] [blame] | 228 | |
Daniel Dunbar | ec069ed | 2009-03-25 06:58:31 +0000 | [diff] [blame] | 229 | // Sob. These is strictly gcc compatible for the time being. Apple |
| 230 | // gcc translates options twice, which means that self-expanding |
| 231 | // options add duplicates. |
| 232 | options::ID id = A->getOption().getId(); |
| 233 | switch (id) { |
| 234 | default: |
| 235 | DAL->append(A); |
| 236 | break; |
| 237 | |
| 238 | case options::OPT_mkernel: |
| 239 | case options::OPT_fapple_kext: |
| 240 | DAL->append(A); |
Daniel Dunbar | 478edc2 | 2009-03-29 22:29:05 +0000 | [diff] [blame] | 241 | DAL->append(DAL->MakeFlagArg(A, Opts.getOption(options::OPT_static))); |
| 242 | DAL->append(DAL->MakeFlagArg(A, Opts.getOption(options::OPT_static))); |
Daniel Dunbar | ec069ed | 2009-03-25 06:58:31 +0000 | [diff] [blame] | 243 | break; |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 244 | |
Daniel Dunbar | ec069ed | 2009-03-25 06:58:31 +0000 | [diff] [blame] | 245 | case options::OPT_dependency_file: |
Daniel Dunbar | 478edc2 | 2009-03-29 22:29:05 +0000 | [diff] [blame] | 246 | DAL->append(DAL->MakeSeparateArg(A, Opts.getOption(options::OPT_MF), |
Daniel Dunbar | ec069ed | 2009-03-25 06:58:31 +0000 | [diff] [blame] | 247 | A->getValue(Args))); |
| 248 | break; |
| 249 | |
| 250 | case options::OPT_gfull: |
Daniel Dunbar | 478edc2 | 2009-03-29 22:29:05 +0000 | [diff] [blame] | 251 | DAL->append(DAL->MakeFlagArg(A, Opts.getOption(options::OPT_g_Flag))); |
| 252 | DAL->append(DAL->MakeFlagArg(A, |
Daniel Dunbar | ec069ed | 2009-03-25 06:58:31 +0000 | [diff] [blame] | 253 | Opts.getOption(options::OPT_fno_eliminate_unused_debug_symbols))); |
| 254 | break; |
| 255 | |
| 256 | case options::OPT_gused: |
Daniel Dunbar | 478edc2 | 2009-03-29 22:29:05 +0000 | [diff] [blame] | 257 | DAL->append(DAL->MakeFlagArg(A, Opts.getOption(options::OPT_g_Flag))); |
| 258 | DAL->append(DAL->MakeFlagArg(A, |
Daniel Dunbar | ec069ed | 2009-03-25 06:58:31 +0000 | [diff] [blame] | 259 | Opts.getOption(options::OPT_feliminate_unused_debug_symbols))); |
| 260 | break; |
| 261 | |
| 262 | case options::OPT_fterminated_vtables: |
| 263 | case options::OPT_findirect_virtual_calls: |
Daniel Dunbar | 478edc2 | 2009-03-29 22:29:05 +0000 | [diff] [blame] | 264 | DAL->append(DAL->MakeFlagArg(A, |
| 265 | Opts.getOption(options::OPT_fapple_kext))); |
| 266 | DAL->append(DAL->MakeFlagArg(A, Opts.getOption(options::OPT_static))); |
Daniel Dunbar | ec069ed | 2009-03-25 06:58:31 +0000 | [diff] [blame] | 267 | break; |
| 268 | |
| 269 | case options::OPT_shared: |
Daniel Dunbar | 478edc2 | 2009-03-29 22:29:05 +0000 | [diff] [blame] | 270 | DAL->append(DAL->MakeFlagArg(A, Opts.getOption(options::OPT_dynamiclib))); |
Daniel Dunbar | ec069ed | 2009-03-25 06:58:31 +0000 | [diff] [blame] | 271 | break; |
| 272 | |
| 273 | case options::OPT_fconstant_cfstrings: |
Daniel Dunbar | 478edc2 | 2009-03-29 22:29:05 +0000 | [diff] [blame] | 274 | DAL->append(DAL->MakeFlagArg(A, |
Daniel Dunbar | ec069ed | 2009-03-25 06:58:31 +0000 | [diff] [blame] | 275 | Opts.getOption(options::OPT_mconstant_cfstrings))); |
| 276 | break; |
| 277 | |
| 278 | case options::OPT_fno_constant_cfstrings: |
Daniel Dunbar | 478edc2 | 2009-03-29 22:29:05 +0000 | [diff] [blame] | 279 | DAL->append(DAL->MakeFlagArg(A, |
Daniel Dunbar | ec069ed | 2009-03-25 06:58:31 +0000 | [diff] [blame] | 280 | Opts.getOption(options::OPT_mno_constant_cfstrings))); |
| 281 | break; |
| 282 | |
| 283 | case options::OPT_Wnonportable_cfstrings: |
Daniel Dunbar | 478edc2 | 2009-03-29 22:29:05 +0000 | [diff] [blame] | 284 | DAL->append(DAL->MakeFlagArg(A, |
Daniel Dunbar | ec069ed | 2009-03-25 06:58:31 +0000 | [diff] [blame] | 285 | Opts.getOption(options::OPT_mwarn_nonportable_cfstrings))); |
| 286 | break; |
| 287 | |
| 288 | case options::OPT_Wno_nonportable_cfstrings: |
Daniel Dunbar | 478edc2 | 2009-03-29 22:29:05 +0000 | [diff] [blame] | 289 | DAL->append(DAL->MakeFlagArg(A, |
Daniel Dunbar | ec069ed | 2009-03-25 06:58:31 +0000 | [diff] [blame] | 290 | Opts.getOption(options::OPT_mno_warn_nonportable_cfstrings))); |
| 291 | break; |
| 292 | |
| 293 | case options::OPT_fpascal_strings: |
Daniel Dunbar | 478edc2 | 2009-03-29 22:29:05 +0000 | [diff] [blame] | 294 | DAL->append(DAL->MakeFlagArg(A, |
Daniel Dunbar | ec069ed | 2009-03-25 06:58:31 +0000 | [diff] [blame] | 295 | Opts.getOption(options::OPT_mpascal_strings))); |
| 296 | break; |
| 297 | |
| 298 | case options::OPT_fno_pascal_strings: |
Daniel Dunbar | 478edc2 | 2009-03-29 22:29:05 +0000 | [diff] [blame] | 299 | DAL->append(DAL->MakeFlagArg(A, |
Daniel Dunbar | ec069ed | 2009-03-25 06:58:31 +0000 | [diff] [blame] | 300 | Opts.getOption(options::OPT_mno_pascal_strings))); |
| 301 | break; |
| 302 | } |
Daniel Dunbar | 4e7e9cf | 2009-03-25 06:12:34 +0000 | [diff] [blame] | 303 | } |
| 304 | |
Daniel Dunbar | 84ec96c | 2009-09-09 22:33:15 +0000 | [diff] [blame] | 305 | if (getTriple().getArch() == llvm::Triple::x86 || |
| 306 | getTriple().getArch() == llvm::Triple::x86_64) |
| 307 | if (!Args.hasArg(options::OPT_mtune_EQ, false)) |
| 308 | DAL->append(DAL->MakeJoinedArg(0, Opts.getOption(options::OPT_mtune_EQ), |
| 309 | "core2")); |
| 310 | |
| 311 | // Add the arch options based on the particular spelling of -arch, to match |
| 312 | // how the driver driver works. |
| 313 | if (BoundArch) { |
| 314 | llvm::StringRef Name = BoundArch; |
| 315 | const Option *MCpu = Opts.getOption(options::OPT_mcpu_EQ); |
| 316 | const Option *MArch = Opts.getOption(options::OPT_march_EQ); |
| 317 | |
| 318 | // This code must be kept in sync with LLVM's getArchTypeForDarwinArch, |
| 319 | // which defines the list of which architectures we accept. |
| 320 | if (Name == "ppc") |
| 321 | ; |
| 322 | else if (Name == "ppc601") |
| 323 | DAL->append(DAL->MakeJoinedArg(0, MCpu, "601")); |
| 324 | else if (Name == "ppc603") |
| 325 | DAL->append(DAL->MakeJoinedArg(0, MCpu, "603")); |
| 326 | else if (Name == "ppc604") |
| 327 | DAL->append(DAL->MakeJoinedArg(0, MCpu, "604")); |
| 328 | else if (Name == "ppc604e") |
| 329 | DAL->append(DAL->MakeJoinedArg(0, MCpu, "604e")); |
| 330 | else if (Name == "ppc750") |
| 331 | DAL->append(DAL->MakeJoinedArg(0, MCpu, "750")); |
| 332 | else if (Name == "ppc7400") |
| 333 | DAL->append(DAL->MakeJoinedArg(0, MCpu, "7400")); |
| 334 | else if (Name == "ppc7450") |
| 335 | DAL->append(DAL->MakeJoinedArg(0, MCpu, "7450")); |
| 336 | else if (Name == "ppc970") |
| 337 | DAL->append(DAL->MakeJoinedArg(0, MCpu, "970")); |
| 338 | |
| 339 | else if (Name == "ppc64") |
Daniel Dunbar | 478edc2 | 2009-03-29 22:29:05 +0000 | [diff] [blame] | 340 | DAL->append(DAL->MakeFlagArg(0, Opts.getOption(options::OPT_m64))); |
Daniel Dunbar | ec069ed | 2009-03-25 06:58:31 +0000 | [diff] [blame] | 341 | |
Daniel Dunbar | 84ec96c | 2009-09-09 22:33:15 +0000 | [diff] [blame] | 342 | else if (Name == "i386") |
| 343 | ; |
| 344 | else if (Name == "i486") |
| 345 | DAL->append(DAL->MakeJoinedArg(0, MArch, "i486")); |
| 346 | else if (Name == "i586") |
| 347 | DAL->append(DAL->MakeJoinedArg(0, MArch, "i586")); |
| 348 | else if (Name == "i686") |
| 349 | DAL->append(DAL->MakeJoinedArg(0, MArch, "i686")); |
| 350 | else if (Name == "pentium") |
| 351 | DAL->append(DAL->MakeJoinedArg(0, MArch, "pentium")); |
| 352 | else if (Name == "pentium2") |
| 353 | DAL->append(DAL->MakeJoinedArg(0, MArch, "pentium2")); |
| 354 | else if (Name == "pentpro") |
| 355 | DAL->append(DAL->MakeJoinedArg(0, MArch, "pentiumpro")); |
| 356 | else if (Name == "pentIIm3") |
| 357 | DAL->append(DAL->MakeJoinedArg(0, MArch, "pentium2")); |
| 358 | |
| 359 | else if (Name == "x86_64") |
| 360 | DAL->append(DAL->MakeFlagArg(0, Opts.getOption(options::OPT_m64))); |
| 361 | |
| 362 | else if (Name == "arm") |
| 363 | DAL->append(DAL->MakeJoinedArg(0, MArch, "armv4t")); |
| 364 | else if (Name == "armv4t") |
| 365 | DAL->append(DAL->MakeJoinedArg(0, MArch, "armv4t")); |
| 366 | else if (Name == "armv5") |
| 367 | DAL->append(DAL->MakeJoinedArg(0, MArch, "armv5tej")); |
| 368 | else if (Name == "xscale") |
| 369 | DAL->append(DAL->MakeJoinedArg(0, MArch, "xscale")); |
| 370 | else if (Name == "armv6") |
| 371 | DAL->append(DAL->MakeJoinedArg(0, MArch, "armv6k")); |
| 372 | else if (Name == "armv7") |
| 373 | DAL->append(DAL->MakeJoinedArg(0, MArch, "armv7a")); |
| 374 | |
| 375 | else |
| 376 | llvm::llvm_unreachable("invalid Darwin arch"); |
| 377 | } |
Daniel Dunbar | ec069ed | 2009-03-25 06:58:31 +0000 | [diff] [blame] | 378 | |
Daniel Dunbar | 4e7e9cf | 2009-03-25 06:12:34 +0000 | [diff] [blame] | 379 | return DAL; |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 380 | } |
Daniel Dunbar | 8eddb3f | 2009-03-20 00:57:52 +0000 | [diff] [blame] | 381 | |
Daniel Dunbar | f395528 | 2009-09-04 18:34:51 +0000 | [diff] [blame] | 382 | bool Darwin::IsMathErrnoDefault() const { |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 383 | return false; |
Daniel Dunbar | 8eddb3f | 2009-03-20 00:57:52 +0000 | [diff] [blame] | 384 | } |
| 385 | |
Daniel Dunbar | f395528 | 2009-09-04 18:34:51 +0000 | [diff] [blame] | 386 | bool Darwin::IsUnwindTablesDefault() const { |
Daniel Dunbar | 8eddb3f | 2009-03-20 00:57:52 +0000 | [diff] [blame] | 387 | // FIXME: Gross; we should probably have some separate target |
| 388 | // definition, possibly even reusing the one in clang. |
| 389 | return getArchName() == "x86_64"; |
| 390 | } |
| 391 | |
Daniel Dunbar | f395528 | 2009-09-04 18:34:51 +0000 | [diff] [blame] | 392 | const char *Darwin::GetDefaultRelocationModel() const { |
Daniel Dunbar | 8eddb3f | 2009-03-20 00:57:52 +0000 | [diff] [blame] | 393 | return "pic"; |
| 394 | } |
| 395 | |
Daniel Dunbar | f395528 | 2009-09-04 18:34:51 +0000 | [diff] [blame] | 396 | const char *Darwin::GetForcedPicModel() const { |
Daniel Dunbar | 8eddb3f | 2009-03-20 00:57:52 +0000 | [diff] [blame] | 397 | if (getArchName() == "x86_64") |
| 398 | return "pic"; |
| 399 | return 0; |
| 400 | } |
| 401 | |
Daniel Dunbar | 3917608 | 2009-03-20 00:20:03 +0000 | [diff] [blame] | 402 | /// Generic_GCC - A tool chain using the 'gcc' command to perform |
| 403 | /// all subcommands; this relies on gcc translating the majority of |
| 404 | /// command line options. |
| 405 | |
Daniel Dunbar | cb8ab23 | 2009-05-22 02:53:45 +0000 | [diff] [blame] | 406 | Generic_GCC::Generic_GCC(const HostInfo &Host, const llvm::Triple& Triple) |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 407 | : ToolChain(Host, Triple) { |
Daniel Dunbar | 82fa7c5 | 2009-03-24 04:07:10 +0000 | [diff] [blame] | 408 | std::string Path(getHost().getDriver().Dir); |
| 409 | Path += "/../libexec"; |
| 410 | getProgramPaths().push_back(Path); |
| 411 | |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 412 | getProgramPaths().push_back(getHost().getDriver().Dir); |
Daniel Dunbar | c50b00d | 2009-03-23 16:15:50 +0000 | [diff] [blame] | 413 | } |
| 414 | |
Daniel Dunbar | 3917608 | 2009-03-20 00:20:03 +0000 | [diff] [blame] | 415 | Generic_GCC::~Generic_GCC() { |
| 416 | // Free tool implementations. |
| 417 | for (llvm::DenseMap<unsigned, Tool*>::iterator |
| 418 | it = Tools.begin(), ie = Tools.end(); it != ie; ++it) |
| 419 | delete it->second; |
| 420 | } |
| 421 | |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 422 | Tool &Generic_GCC::SelectTool(const Compilation &C, |
Daniel Dunbar | 3917608 | 2009-03-20 00:20:03 +0000 | [diff] [blame] | 423 | const JobAction &JA) const { |
| 424 | Action::ActionClass Key; |
Daniel Dunbar | a6046be | 2009-09-08 23:36:55 +0000 | [diff] [blame] | 425 | if (getHost().getDriver().ShouldUseClangCompiler(C, JA, getTriple())) |
Daniel Dunbar | 3917608 | 2009-03-20 00:20:03 +0000 | [diff] [blame] | 426 | Key = Action::AnalyzeJobClass; |
| 427 | else |
| 428 | Key = JA.getKind(); |
| 429 | |
| 430 | Tool *&T = Tools[Key]; |
| 431 | if (!T) { |
| 432 | switch (Key) { |
Daniel Dunbar | 8eddb3f | 2009-03-20 00:57:52 +0000 | [diff] [blame] | 433 | case Action::InputClass: |
| 434 | case Action::BindArchClass: |
Daniel Dunbar | 3917608 | 2009-03-20 00:20:03 +0000 | [diff] [blame] | 435 | assert(0 && "Invalid tool kind."); |
| 436 | case Action::PreprocessJobClass: |
| 437 | T = new tools::gcc::Preprocess(*this); break; |
| 438 | case Action::PrecompileJobClass: |
| 439 | T = new tools::gcc::Precompile(*this); break; |
| 440 | case Action::AnalyzeJobClass: |
| 441 | T = new tools::Clang(*this); break; |
| 442 | case Action::CompileJobClass: |
| 443 | T = new tools::gcc::Compile(*this); break; |
| 444 | case Action::AssembleJobClass: |
| 445 | T = new tools::gcc::Assemble(*this); break; |
| 446 | case Action::LinkJobClass: |
| 447 | T = new tools::gcc::Link(*this); break; |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 448 | |
Daniel Dunbar | 8eddb3f | 2009-03-20 00:57:52 +0000 | [diff] [blame] | 449 | // This is a bit ungeneric, but the only platform using a driver |
| 450 | // driver is Darwin. |
| 451 | case Action::LipoJobClass: |
| 452 | T = new tools::darwin::Lipo(*this); break; |
Daniel Dunbar | 3917608 | 2009-03-20 00:20:03 +0000 | [diff] [blame] | 453 | } |
| 454 | } |
| 455 | |
| 456 | return *T; |
| 457 | } |
| 458 | |
Daniel Dunbar | f395528 | 2009-09-04 18:34:51 +0000 | [diff] [blame] | 459 | bool Generic_GCC::IsMathErrnoDefault() const { |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 460 | return true; |
Daniel Dunbar | 3917608 | 2009-03-20 00:20:03 +0000 | [diff] [blame] | 461 | } |
| 462 | |
| 463 | bool Generic_GCC::IsUnwindTablesDefault() const { |
Daniel Dunbar | 8eddb3f | 2009-03-20 00:57:52 +0000 | [diff] [blame] | 464 | // FIXME: Gross; we should probably have some separate target |
| 465 | // definition, possibly even reusing the one in clang. |
Daniel Dunbar | 3917608 | 2009-03-20 00:20:03 +0000 | [diff] [blame] | 466 | return getArchName() == "x86_64"; |
| 467 | } |
| 468 | |
| 469 | const char *Generic_GCC::GetDefaultRelocationModel() const { |
| 470 | return "static"; |
| 471 | } |
| 472 | |
| 473 | const char *Generic_GCC::GetForcedPicModel() const { |
| 474 | return 0; |
| 475 | } |
Daniel Dunbar | f3cad36 | 2009-03-25 04:13:45 +0000 | [diff] [blame] | 476 | |
Daniel Dunbar | 0dcb9a3 | 2009-09-09 18:36:12 +0000 | [diff] [blame] | 477 | DerivedArgList *Generic_GCC::TranslateArgs(InputArgList &Args, |
| 478 | const char *BoundArch) const { |
Daniel Dunbar | f3cad36 | 2009-03-25 04:13:45 +0000 | [diff] [blame] | 479 | return new DerivedArgList(Args, true); |
| 480 | } |
Daniel Dunbar | 75358d2 | 2009-03-30 21:06:03 +0000 | [diff] [blame] | 481 | |
Daniel Dunbar | f7b8eec | 2009-06-29 20:52:51 +0000 | [diff] [blame] | 482 | /// OpenBSD - OpenBSD tool chain which can call as(1) and ld(1) directly. |
| 483 | |
| 484 | OpenBSD::OpenBSD(const HostInfo &Host, const llvm::Triple& Triple) |
| 485 | : Generic_GCC(Host, Triple) { |
| 486 | getFilePaths().push_back(getHost().getDriver().Dir + "/../lib"); |
| 487 | getFilePaths().push_back("/usr/lib"); |
| 488 | } |
| 489 | |
| 490 | Tool &OpenBSD::SelectTool(const Compilation &C, const JobAction &JA) const { |
| 491 | Action::ActionClass Key; |
Daniel Dunbar | a6046be | 2009-09-08 23:36:55 +0000 | [diff] [blame] | 492 | if (getHost().getDriver().ShouldUseClangCompiler(C, JA, getTriple())) |
Daniel Dunbar | f7b8eec | 2009-06-29 20:52:51 +0000 | [diff] [blame] | 493 | Key = Action::AnalyzeJobClass; |
| 494 | else |
| 495 | Key = JA.getKind(); |
| 496 | |
| 497 | Tool *&T = Tools[Key]; |
| 498 | if (!T) { |
| 499 | switch (Key) { |
| 500 | case Action::AssembleJobClass: |
| 501 | T = new tools::openbsd::Assemble(*this); break; |
| 502 | case Action::LinkJobClass: |
| 503 | T = new tools::openbsd::Link(*this); break; |
| 504 | default: |
| 505 | T = &Generic_GCC::SelectTool(C, JA); |
| 506 | } |
| 507 | } |
| 508 | |
| 509 | return *T; |
| 510 | } |
| 511 | |
Daniel Dunbar | 75358d2 | 2009-03-30 21:06:03 +0000 | [diff] [blame] | 512 | /// FreeBSD - FreeBSD tool chain which can call as(1) and ld(1) directly. |
| 513 | |
Daniel Dunbar | cb8ab23 | 2009-05-22 02:53:45 +0000 | [diff] [blame] | 514 | FreeBSD::FreeBSD(const HostInfo &Host, const llvm::Triple& Triple, bool Lib32) |
| 515 | : Generic_GCC(Host, Triple) { |
Daniel Dunbar | bc53466 | 2009-04-02 18:30:04 +0000 | [diff] [blame] | 516 | if (Lib32) { |
Daniel Dunbar | 75358d2 | 2009-03-30 21:06:03 +0000 | [diff] [blame] | 517 | getFilePaths().push_back(getHost().getDriver().Dir + "/../lib32"); |
Daniel Dunbar | bc53466 | 2009-04-02 18:30:04 +0000 | [diff] [blame] | 518 | getFilePaths().push_back("/usr/lib32"); |
| 519 | } else { |
Daniel Dunbar | 75358d2 | 2009-03-30 21:06:03 +0000 | [diff] [blame] | 520 | getFilePaths().push_back(getHost().getDriver().Dir + "/../lib"); |
Daniel Dunbar | bc53466 | 2009-04-02 18:30:04 +0000 | [diff] [blame] | 521 | getFilePaths().push_back("/usr/lib"); |
| 522 | } |
Daniel Dunbar | 75358d2 | 2009-03-30 21:06:03 +0000 | [diff] [blame] | 523 | } |
| 524 | |
| 525 | Tool &FreeBSD::SelectTool(const Compilation &C, const JobAction &JA) const { |
| 526 | Action::ActionClass Key; |
Daniel Dunbar | a6046be | 2009-09-08 23:36:55 +0000 | [diff] [blame] | 527 | if (getHost().getDriver().ShouldUseClangCompiler(C, JA, getTriple())) |
Daniel Dunbar | 75358d2 | 2009-03-30 21:06:03 +0000 | [diff] [blame] | 528 | Key = Action::AnalyzeJobClass; |
| 529 | else |
| 530 | Key = JA.getKind(); |
| 531 | |
| 532 | Tool *&T = Tools[Key]; |
| 533 | if (!T) { |
| 534 | switch (Key) { |
Daniel Dunbar | 68a31d4 | 2009-03-31 17:45:15 +0000 | [diff] [blame] | 535 | case Action::AssembleJobClass: |
| 536 | T = new tools::freebsd::Assemble(*this); break; |
Daniel Dunbar | 008f54a | 2009-04-01 19:36:32 +0000 | [diff] [blame] | 537 | case Action::LinkJobClass: |
| 538 | T = new tools::freebsd::Link(*this); break; |
Daniel Dunbar | 75358d2 | 2009-03-30 21:06:03 +0000 | [diff] [blame] | 539 | default: |
| 540 | T = &Generic_GCC::SelectTool(C, JA); |
| 541 | } |
| 542 | } |
| 543 | |
| 544 | return *T; |
| 545 | } |
Daniel Dunbar | 11e1b40 | 2009-05-02 18:28:39 +0000 | [diff] [blame] | 546 | |
Edward O'Callaghan | e7925a0 | 2009-08-22 01:06:46 +0000 | [diff] [blame] | 547 | /// AuroraUX - AuroraUX tool chain which can call as(1) and ld(1) directly. |
| 548 | |
| 549 | AuroraUX::AuroraUX(const HostInfo &Host, const llvm::Triple& Triple) |
| 550 | : Generic_GCC(Host, Triple) { |
| 551 | |
| 552 | // Path mangling to find libexec |
| 553 | std::string Path(getHost().getDriver().Dir); |
| 554 | |
| 555 | Path += "/../libexec"; |
| 556 | getProgramPaths().push_back(Path); |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 557 | getProgramPaths().push_back(getHost().getDriver().Dir); |
Edward O'Callaghan | e7925a0 | 2009-08-22 01:06:46 +0000 | [diff] [blame] | 558 | |
| 559 | getFilePaths().push_back(getHost().getDriver().Dir + "/../lib"); |
| 560 | getFilePaths().push_back("/usr/lib"); |
| 561 | getFilePaths().push_back("/usr/sfw/lib"); |
| 562 | getFilePaths().push_back("/opt/gcc4/lib"); |
| 563 | |
| 564 | } |
| 565 | |
| 566 | Tool &AuroraUX::SelectTool(const Compilation &C, const JobAction &JA) const { |
| 567 | Action::ActionClass Key; |
Daniel Dunbar | a6046be | 2009-09-08 23:36:55 +0000 | [diff] [blame] | 568 | if (getHost().getDriver().ShouldUseClangCompiler(C, JA, getTriple())) |
Edward O'Callaghan | e7925a0 | 2009-08-22 01:06:46 +0000 | [diff] [blame] | 569 | Key = Action::AnalyzeJobClass; |
| 570 | else |
| 571 | Key = JA.getKind(); |
| 572 | |
| 573 | Tool *&T = Tools[Key]; |
| 574 | if (!T) { |
| 575 | switch (Key) { |
| 576 | case Action::AssembleJobClass: |
| 577 | T = new tools::auroraux::Assemble(*this); break; |
| 578 | case Action::LinkJobClass: |
| 579 | T = new tools::auroraux::Link(*this); break; |
| 580 | default: |
| 581 | T = &Generic_GCC::SelectTool(C, JA); |
| 582 | } |
| 583 | } |
| 584 | |
| 585 | return *T; |
| 586 | } |
| 587 | |
| 588 | |
Eli Friedman | 6b3454a | 2009-05-26 07:52:18 +0000 | [diff] [blame] | 589 | /// Linux toolchain (very bare-bones at the moment). |
| 590 | |
| 591 | Linux::Linux(const HostInfo &Host, const llvm::Triple& Triple) |
| 592 | : Generic_GCC(Host, Triple) { |
| 593 | getFilePaths().push_back(getHost().getDriver().Dir + "/../lib/clang/1.0/"); |
| 594 | getFilePaths().push_back("/lib/"); |
| 595 | getFilePaths().push_back("/usr/lib/"); |
Daniel Dunbar | a9822de | 2009-08-06 01:47:11 +0000 | [diff] [blame] | 596 | |
| 597 | // Depending on the Linux distribution, any combination of lib{,32,64} is |
| 598 | // possible. E.g. Debian uses lib and lib32 for mixed i386/x86-64 systems, |
| 599 | // openSUSE uses lib and lib64 for the same purpose. |
| 600 | getFilePaths().push_back("/lib32/"); |
| 601 | getFilePaths().push_back("/usr/lib32/"); |
| 602 | getFilePaths().push_back("/lib64/"); |
| 603 | getFilePaths().push_back("/usr/lib64/"); |
| 604 | |
Eli Friedman | 6b3454a | 2009-05-26 07:52:18 +0000 | [diff] [blame] | 605 | // FIXME: Figure out some way to get gcc's libdir |
| 606 | // (e.g. /usr/lib/gcc/i486-linux-gnu/4.3/ for Ubuntu 32-bit); we need |
| 607 | // crtbegin.o/crtend.o/etc., and want static versions of various |
| 608 | // libraries. If we had our own crtbegin.o/crtend.o/etc, we could probably |
| 609 | // get away with using shared versions in /usr/lib, though. |
| 610 | // We could fall back to the approach we used for includes (a massive |
| 611 | // list), but that's messy at best. |
| 612 | } |
| 613 | |
Daniel Dunbar | 11e1b40 | 2009-05-02 18:28:39 +0000 | [diff] [blame] | 614 | /// DragonFly - DragonFly tool chain which can call as(1) and ld(1) directly. |
| 615 | |
Daniel Dunbar | cb8ab23 | 2009-05-22 02:53:45 +0000 | [diff] [blame] | 616 | DragonFly::DragonFly(const HostInfo &Host, const llvm::Triple& Triple) |
| 617 | : Generic_GCC(Host, Triple) { |
Daniel Dunbar | 11e1b40 | 2009-05-02 18:28:39 +0000 | [diff] [blame] | 618 | |
| 619 | // Path mangling to find libexec |
| 620 | std::string Path(getHost().getDriver().Dir); |
| 621 | |
| 622 | Path += "/../libexec"; |
| 623 | getProgramPaths().push_back(Path); |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 624 | getProgramPaths().push_back(getHost().getDriver().Dir); |
Daniel Dunbar | 11e1b40 | 2009-05-02 18:28:39 +0000 | [diff] [blame] | 625 | |
| 626 | getFilePaths().push_back(getHost().getDriver().Dir + "/../lib"); |
| 627 | getFilePaths().push_back("/usr/lib"); |
| 628 | getFilePaths().push_back("/usr/lib/gcc41"); |
| 629 | } |
| 630 | |
| 631 | Tool &DragonFly::SelectTool(const Compilation &C, const JobAction &JA) const { |
| 632 | Action::ActionClass Key; |
Daniel Dunbar | a6046be | 2009-09-08 23:36:55 +0000 | [diff] [blame] | 633 | if (getHost().getDriver().ShouldUseClangCompiler(C, JA, getTriple())) |
Daniel Dunbar | 11e1b40 | 2009-05-02 18:28:39 +0000 | [diff] [blame] | 634 | Key = Action::AnalyzeJobClass; |
| 635 | else |
| 636 | Key = JA.getKind(); |
| 637 | |
| 638 | Tool *&T = Tools[Key]; |
| 639 | if (!T) { |
| 640 | switch (Key) { |
| 641 | case Action::AssembleJobClass: |
| 642 | T = new tools::dragonfly::Assemble(*this); break; |
| 643 | case Action::LinkJobClass: |
| 644 | T = new tools::dragonfly::Link(*this); break; |
| 645 | default: |
| 646 | T = &Generic_GCC::SelectTool(C, JA); |
| 647 | } |
| 648 | } |
| 649 | |
| 650 | return *T; |
| 651 | } |