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 | 27e738d | 2009-11-19 00:15:11 +0000 | [diff] [blame] | 17 | #include "clang/Driver/OptTable.h" |
Daniel Dunbar | 4e7e9cf | 2009-03-25 06:12:34 +0000 | [diff] [blame] | 18 | #include "clang/Driver/Option.h" |
Daniel Dunbar | 265e9ef | 2009-11-19 04:25:22 +0000 | [diff] [blame] | 19 | #include "clang/Driver/Options.h" |
Daniel Dunbar | c50b00d | 2009-03-23 16:15:50 +0000 | [diff] [blame] | 20 | |
| 21 | #include "llvm/ADT/StringExtras.h" |
Daniel Dunbar | 84ec96c | 2009-09-09 22:33:15 +0000 | [diff] [blame] | 22 | #include "llvm/Support/ErrorHandling.h" |
Daniel Dunbar | ec069ed | 2009-03-25 06:58:31 +0000 | [diff] [blame] | 23 | #include "llvm/Support/raw_ostream.h" |
Daniel Dunbar | c50b00d | 2009-03-23 16:15:50 +0000 | [diff] [blame] | 24 | #include "llvm/System/Path.h" |
| 25 | |
Daniel Dunbar | f36a06a | 2009-04-10 21:00:07 +0000 | [diff] [blame] | 26 | #include <cstdlib> // ::getenv |
| 27 | |
Daniel Dunbar | 3917608 | 2009-03-20 00:20:03 +0000 | [diff] [blame] | 28 | using namespace clang::driver; |
| 29 | using namespace clang::driver::toolchains; |
| 30 | |
Daniel Dunbar | f395528 | 2009-09-04 18:34:51 +0000 | [diff] [blame] | 31 | /// Darwin - Darwin tool chain for i386 and x86_64. |
Daniel Dunbar | 8eddb3f | 2009-03-20 00:57:52 +0000 | [diff] [blame] | 32 | |
Daniel Dunbar | f395528 | 2009-09-04 18:34:51 +0000 | [diff] [blame] | 33 | Darwin::Darwin(const HostInfo &Host, const llvm::Triple& Triple, |
Daniel Dunbar | cc8e189 | 2010-01-27 00:56:44 +0000 | [diff] [blame] | 34 | const unsigned (&_DarwinVersion)[3]) |
| 35 | : ToolChain(Host, Triple), TargetInitialized(false) |
Daniel Dunbar | 1d4612b | 2009-09-18 08:15:13 +0000 | [diff] [blame] | 36 | { |
Daniel Dunbar | c50b00d | 2009-03-23 16:15:50 +0000 | [diff] [blame] | 37 | DarwinVersion[0] = _DarwinVersion[0]; |
| 38 | DarwinVersion[1] = _DarwinVersion[1]; |
| 39 | DarwinVersion[2] = _DarwinVersion[2]; |
Daniel Dunbar | c50b00d | 2009-03-23 16:15:50 +0000 | [diff] [blame] | 40 | |
Daniel Dunbar | 02633b5 | 2009-03-26 16:23:12 +0000 | [diff] [blame] | 41 | llvm::raw_string_ostream(MacosxVersionMin) |
Benjamin Kramer | 87f9fd9 | 2009-10-21 21:05:07 +0000 | [diff] [blame] | 42 | << "10." << std::max(0, (int)DarwinVersion[0] - 4) << '.' |
| 43 | << DarwinVersion[1]; |
Daniel Dunbar | 1d4612b | 2009-09-18 08:15:13 +0000 | [diff] [blame] | 44 | } |
| 45 | |
Daniel Dunbar | eeff406 | 2010-01-22 02:04:58 +0000 | [diff] [blame] | 46 | // FIXME: Can we tablegen this? |
| 47 | static const char *GetArmArchForMArch(llvm::StringRef Value) { |
| 48 | if (Value == "armv6k") |
| 49 | return "armv6"; |
| 50 | |
| 51 | if (Value == "armv5tej") |
| 52 | return "armv5"; |
| 53 | |
| 54 | if (Value == "xscale") |
| 55 | return "xscale"; |
| 56 | |
| 57 | if (Value == "armv4t") |
| 58 | return "armv4t"; |
| 59 | |
| 60 | if (Value == "armv7" || Value == "armv7-a" || Value == "armv7-r" || |
| 61 | Value == "armv7-m" || Value == "armv7a" || Value == "armv7r" || |
| 62 | Value == "armv7m") |
| 63 | return "armv7"; |
| 64 | |
| 65 | return 0; |
| 66 | } |
| 67 | |
| 68 | // FIXME: Can we tablegen this? |
| 69 | static const char *GetArmArchForMCpu(llvm::StringRef Value) { |
| 70 | if (Value == "arm10tdmi" || Value == "arm1020t" || Value == "arm9e" || |
| 71 | Value == "arm946e-s" || Value == "arm966e-s" || |
| 72 | Value == "arm968e-s" || Value == "arm10e" || |
| 73 | Value == "arm1020e" || Value == "arm1022e" || Value == "arm926ej-s" || |
| 74 | Value == "arm1026ej-s") |
| 75 | return "armv5"; |
| 76 | |
| 77 | if (Value == "xscale") |
| 78 | return "xscale"; |
| 79 | |
| 80 | if (Value == "arm1136j-s" || Value == "arm1136jf-s" || |
| 81 | Value == "arm1176jz-s" || Value == "arm1176jzf-s") |
| 82 | return "armv6"; |
| 83 | |
| 84 | if (Value == "cortex-a8" || Value == "cortex-r4" || Value == "cortex-m3") |
| 85 | return "armv7"; |
| 86 | |
| 87 | return 0; |
| 88 | } |
| 89 | |
| 90 | llvm::StringRef Darwin::getDarwinArchName(const ArgList &Args) const { |
| 91 | switch (getTriple().getArch()) { |
| 92 | default: |
| 93 | return getArchName(); |
| 94 | |
| 95 | case llvm::Triple::arm: { |
| 96 | if (const Arg *A = Args.getLastArg(options::OPT_march_EQ)) |
| 97 | if (const char *Arch = GetArmArchForMArch(A->getValue(Args))) |
| 98 | return Arch; |
| 99 | |
| 100 | if (const Arg *A = Args.getLastArg(options::OPT_mcpu_EQ)) |
| 101 | if (const char *Arch = GetArmArchForMCpu(A->getValue(Args))) |
| 102 | return Arch; |
| 103 | |
| 104 | return "arm"; |
| 105 | } |
| 106 | } |
| 107 | } |
| 108 | |
Daniel Dunbar | 1d4612b | 2009-09-18 08:15:13 +0000 | [diff] [blame] | 109 | DarwinGCC::DarwinGCC(const HostInfo &Host, const llvm::Triple& Triple, |
| 110 | const unsigned (&DarwinVersion)[3], |
Daniel Dunbar | cc8e189 | 2010-01-27 00:56:44 +0000 | [diff] [blame] | 111 | const unsigned (&_GCCVersion)[3]) |
| 112 | : Darwin(Host, Triple, DarwinVersion) |
Daniel Dunbar | 1d4612b | 2009-09-18 08:15:13 +0000 | [diff] [blame] | 113 | { |
| 114 | GCCVersion[0] = _GCCVersion[0]; |
| 115 | GCCVersion[1] = _GCCVersion[1]; |
| 116 | GCCVersion[2] = _GCCVersion[2]; |
| 117 | |
| 118 | // Set up the tool chain paths to match gcc. |
Daniel Dunbar | c50b00d | 2009-03-23 16:15:50 +0000 | [diff] [blame] | 119 | ToolChainDir = "i686-apple-darwin"; |
Ted Kremenek | 55bac53 | 2009-10-07 03:21:11 +0000 | [diff] [blame] | 120 | ToolChainDir += llvm::utostr(DarwinVersion[0]); |
Daniel Dunbar | c50b00d | 2009-03-23 16:15:50 +0000 | [diff] [blame] | 121 | ToolChainDir += "/"; |
| 122 | ToolChainDir += llvm::utostr(GCCVersion[0]); |
| 123 | ToolChainDir += '.'; |
| 124 | ToolChainDir += llvm::utostr(GCCVersion[1]); |
| 125 | ToolChainDir += '.'; |
| 126 | ToolChainDir += llvm::utostr(GCCVersion[2]); |
| 127 | |
Daniel Dunbar | 74782b0 | 2009-10-20 19:25:43 +0000 | [diff] [blame] | 128 | // Try the next major version if that tool chain dir is invalid. |
Daniel Dunbar | 080fb19 | 2009-10-22 00:12:00 +0000 | [diff] [blame] | 129 | std::string Tmp = "/usr/lib/gcc/" + ToolChainDir; |
| 130 | if (!llvm::sys::Path(Tmp).exists()) { |
Daniel Dunbar | 74782b0 | 2009-10-20 19:25:43 +0000 | [diff] [blame] | 131 | std::string Next = "i686-apple-darwin"; |
| 132 | Next += llvm::utostr(DarwinVersion[0] + 1); |
| 133 | Next += "/"; |
| 134 | Next += llvm::utostr(GCCVersion[0]); |
| 135 | Next += '.'; |
| 136 | Next += llvm::utostr(GCCVersion[1]); |
| 137 | Next += '.'; |
| 138 | Next += llvm::utostr(GCCVersion[2]); |
| 139 | |
| 140 | // Use that if it exists, otherwise hope the user isn't linking. |
| 141 | // |
| 142 | // FIXME: Drop dependency on gcc's tool chain. |
Daniel Dunbar | 080fb19 | 2009-10-22 00:12:00 +0000 | [diff] [blame] | 143 | Tmp = "/usr/lib/gcc/" + Next; |
| 144 | if (llvm::sys::Path(Tmp).exists()) |
Daniel Dunbar | 74782b0 | 2009-10-20 19:25:43 +0000 | [diff] [blame] | 145 | ToolChainDir = Next; |
| 146 | } |
| 147 | |
Daniel Dunbar | c50b00d | 2009-03-23 16:15:50 +0000 | [diff] [blame] | 148 | std::string Path; |
| 149 | if (getArchName() == "x86_64") { |
Daniel Dunbar | ee788e7 | 2009-12-21 18:54:17 +0000 | [diff] [blame] | 150 | Path = getDriver().Dir; |
Daniel Dunbar | c50b00d | 2009-03-23 16:15:50 +0000 | [diff] [blame] | 151 | Path += "/../lib/gcc/"; |
Daniel Dunbar | 6b200b2 | 2009-09-18 08:14:36 +0000 | [diff] [blame] | 152 | Path += ToolChainDir; |
Daniel Dunbar | c50b00d | 2009-03-23 16:15:50 +0000 | [diff] [blame] | 153 | Path += "/x86_64"; |
| 154 | getFilePaths().push_back(Path); |
| 155 | |
| 156 | Path = "/usr/lib/gcc/"; |
Daniel Dunbar | 6b200b2 | 2009-09-18 08:14:36 +0000 | [diff] [blame] | 157 | Path += ToolChainDir; |
Daniel Dunbar | c50b00d | 2009-03-23 16:15:50 +0000 | [diff] [blame] | 158 | Path += "/x86_64"; |
| 159 | getFilePaths().push_back(Path); |
| 160 | } |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 161 | |
Daniel Dunbar | ee788e7 | 2009-12-21 18:54:17 +0000 | [diff] [blame] | 162 | Path = getDriver().Dir; |
Daniel Dunbar | c50b00d | 2009-03-23 16:15:50 +0000 | [diff] [blame] | 163 | Path += "/../lib/gcc/"; |
Daniel Dunbar | 6b200b2 | 2009-09-18 08:14:36 +0000 | [diff] [blame] | 164 | Path += ToolChainDir; |
Daniel Dunbar | c50b00d | 2009-03-23 16:15:50 +0000 | [diff] [blame] | 165 | getFilePaths().push_back(Path); |
| 166 | |
| 167 | Path = "/usr/lib/gcc/"; |
Daniel Dunbar | 6b200b2 | 2009-09-18 08:14:36 +0000 | [diff] [blame] | 168 | Path += ToolChainDir; |
Daniel Dunbar | c50b00d | 2009-03-23 16:15:50 +0000 | [diff] [blame] | 169 | getFilePaths().push_back(Path); |
| 170 | |
Daniel Dunbar | ee788e7 | 2009-12-21 18:54:17 +0000 | [diff] [blame] | 171 | Path = getDriver().Dir; |
Daniel Dunbar | c50b00d | 2009-03-23 16:15:50 +0000 | [diff] [blame] | 172 | Path += "/../libexec/gcc/"; |
Daniel Dunbar | 6b200b2 | 2009-09-18 08:14:36 +0000 | [diff] [blame] | 173 | Path += ToolChainDir; |
Daniel Dunbar | c50b00d | 2009-03-23 16:15:50 +0000 | [diff] [blame] | 174 | getProgramPaths().push_back(Path); |
| 175 | |
| 176 | Path = "/usr/libexec/gcc/"; |
Daniel Dunbar | 6b200b2 | 2009-09-18 08:14:36 +0000 | [diff] [blame] | 177 | Path += ToolChainDir; |
Daniel Dunbar | c50b00d | 2009-03-23 16:15:50 +0000 | [diff] [blame] | 178 | getProgramPaths().push_back(Path); |
| 179 | |
Daniel Dunbar | ee788e7 | 2009-12-21 18:54:17 +0000 | [diff] [blame] | 180 | getProgramPaths().push_back(getDriver().Dir); |
Daniel Dunbar | c50b00d | 2009-03-23 16:15:50 +0000 | [diff] [blame] | 181 | } |
| 182 | |
Daniel Dunbar | f395528 | 2009-09-04 18:34:51 +0000 | [diff] [blame] | 183 | Darwin::~Darwin() { |
Daniel Dunbar | 8eddb3f | 2009-03-20 00:57:52 +0000 | [diff] [blame] | 184 | // Free tool implementations. |
| 185 | for (llvm::DenseMap<unsigned, Tool*>::iterator |
| 186 | it = Tools.begin(), ie = Tools.end(); it != ie; ++it) |
| 187 | delete it->second; |
| 188 | } |
| 189 | |
Daniel Dunbar | f395528 | 2009-09-04 18:34:51 +0000 | [diff] [blame] | 190 | Tool &Darwin::SelectTool(const Compilation &C, const JobAction &JA) const { |
Daniel Dunbar | 8eddb3f | 2009-03-20 00:57:52 +0000 | [diff] [blame] | 191 | Action::ActionClass Key; |
Daniel Dunbar | ee788e7 | 2009-12-21 18:54:17 +0000 | [diff] [blame] | 192 | if (getDriver().ShouldUseClangCompiler(C, JA, getTriple())) |
Daniel Dunbar | 8eddb3f | 2009-03-20 00:57:52 +0000 | [diff] [blame] | 193 | Key = Action::AnalyzeJobClass; |
| 194 | else |
| 195 | Key = JA.getKind(); |
| 196 | |
| 197 | Tool *&T = Tools[Key]; |
| 198 | if (!T) { |
| 199 | switch (Key) { |
| 200 | case Action::InputClass: |
| 201 | case Action::BindArchClass: |
| 202 | assert(0 && "Invalid tool kind."); |
| 203 | case Action::PreprocessJobClass: |
Daniel Dunbar | 9120f17 | 2009-03-29 22:27:40 +0000 | [diff] [blame] | 204 | T = new tools::darwin::Preprocess(*this); break; |
Daniel Dunbar | 8eddb3f | 2009-03-20 00:57:52 +0000 | [diff] [blame] | 205 | case Action::AnalyzeJobClass: |
| 206 | T = new tools::Clang(*this); break; |
Daniel Dunbar | 9120f17 | 2009-03-29 22:27:40 +0000 | [diff] [blame] | 207 | case Action::PrecompileJobClass: |
Daniel Dunbar | 8eddb3f | 2009-03-20 00:57:52 +0000 | [diff] [blame] | 208 | case Action::CompileJobClass: |
Daniel Dunbar | 9120f17 | 2009-03-29 22:27:40 +0000 | [diff] [blame] | 209 | T = new tools::darwin::Compile(*this); break; |
Daniel Dunbar | 8eddb3f | 2009-03-20 00:57:52 +0000 | [diff] [blame] | 210 | case Action::AssembleJobClass: |
Daniel Dunbar | 8cac5f7 | 2009-03-20 16:06:39 +0000 | [diff] [blame] | 211 | T = new tools::darwin::Assemble(*this); break; |
Daniel Dunbar | 8eddb3f | 2009-03-20 00:57:52 +0000 | [diff] [blame] | 212 | case Action::LinkJobClass: |
Daniel Dunbar | 8f28962 | 2009-09-04 17:39:02 +0000 | [diff] [blame] | 213 | T = new tools::darwin::Link(*this); break; |
Daniel Dunbar | 8eddb3f | 2009-03-20 00:57:52 +0000 | [diff] [blame] | 214 | case Action::LipoJobClass: |
| 215 | T = new tools::darwin::Lipo(*this); break; |
| 216 | } |
| 217 | } |
| 218 | |
| 219 | return *T; |
| 220 | } |
| 221 | |
Daniel Dunbar | 1d4612b | 2009-09-18 08:15:13 +0000 | [diff] [blame] | 222 | void DarwinGCC::AddLinkSearchPathArgs(const ArgList &Args, |
| 223 | ArgStringList &CmdArgs) const { |
Daniel Dunbar | 6b200b2 | 2009-09-18 08:14:36 +0000 | [diff] [blame] | 224 | // FIXME: Derive these correctly. |
| 225 | if (getArchName() == "x86_64") { |
| 226 | CmdArgs.push_back(Args.MakeArgString("-L/usr/lib/gcc/" + ToolChainDir + |
| 227 | "/x86_64")); |
| 228 | // Intentionally duplicated for (temporary) gcc bug compatibility. |
| 229 | CmdArgs.push_back(Args.MakeArgString("-L/usr/lib/gcc/" + ToolChainDir + |
| 230 | "/x86_64")); |
| 231 | } |
| 232 | CmdArgs.push_back(Args.MakeArgString("-L/usr/lib/" + ToolChainDir)); |
| 233 | CmdArgs.push_back(Args.MakeArgString("-L/usr/lib/gcc/" + ToolChainDir)); |
| 234 | // Intentionally duplicated for (temporary) gcc bug compatibility. |
| 235 | CmdArgs.push_back(Args.MakeArgString("-L/usr/lib/gcc/" + ToolChainDir)); |
| 236 | CmdArgs.push_back(Args.MakeArgString("-L/usr/lib/gcc/" + ToolChainDir + |
| 237 | "/../../../" + ToolChainDir)); |
| 238 | CmdArgs.push_back(Args.MakeArgString("-L/usr/lib/gcc/" + ToolChainDir + |
| 239 | "/../../..")); |
| 240 | } |
| 241 | |
Daniel Dunbar | 1d4612b | 2009-09-18 08:15:13 +0000 | [diff] [blame] | 242 | void DarwinGCC::AddLinkRuntimeLibArgs(const ArgList &Args, |
| 243 | ArgStringList &CmdArgs) const { |
Daniel Dunbar | ce3fdf2 | 2010-01-27 00:57:03 +0000 | [diff] [blame^] | 244 | // Note that this routine is only used for targetting OS X. |
Daniel Dunbar | 6cd4154 | 2009-09-18 08:15:03 +0000 | [diff] [blame] | 245 | |
| 246 | // Derived from libgcc and lib specs but refactored. |
| 247 | if (Args.hasArg(options::OPT_static)) { |
| 248 | CmdArgs.push_back("-lgcc_static"); |
| 249 | } else { |
| 250 | if (Args.hasArg(options::OPT_static_libgcc)) { |
| 251 | CmdArgs.push_back("-lgcc_eh"); |
| 252 | } else if (Args.hasArg(options::OPT_miphoneos_version_min_EQ)) { |
| 253 | // Derived from darwin_iphoneos_libgcc spec. |
Daniel Dunbar | 251ca6c | 2010-01-27 00:56:37 +0000 | [diff] [blame] | 254 | if (isTargetIPhoneOS()) { |
Daniel Dunbar | 6cd4154 | 2009-09-18 08:15:03 +0000 | [diff] [blame] | 255 | CmdArgs.push_back("-lgcc_s.1"); |
| 256 | } else { |
| 257 | CmdArgs.push_back("-lgcc_s.10.5"); |
| 258 | } |
| 259 | } else if (Args.hasArg(options::OPT_shared_libgcc) || |
Daniel Dunbar | 8a0d94d | 2010-01-10 00:46:10 +0000 | [diff] [blame] | 260 | Args.hasFlag(options::OPT_fexceptions, |
| 261 | options::OPT_fno_exceptions) || |
Daniel Dunbar | 6cd4154 | 2009-09-18 08:15:03 +0000 | [diff] [blame] | 262 | Args.hasArg(options::OPT_fgnu_runtime)) { |
| 263 | // FIXME: This is probably broken on 10.3? |
Daniel Dunbar | ce3fdf2 | 2010-01-27 00:57:03 +0000 | [diff] [blame^] | 264 | if (isMacosxVersionLT(10, 5)) |
Daniel Dunbar | 6cd4154 | 2009-09-18 08:15:03 +0000 | [diff] [blame] | 265 | CmdArgs.push_back("-lgcc_s.10.4"); |
Daniel Dunbar | ce3fdf2 | 2010-01-27 00:57:03 +0000 | [diff] [blame^] | 266 | else if (isMacosxVersionLT(10, 6)) |
Daniel Dunbar | 6cd4154 | 2009-09-18 08:15:03 +0000 | [diff] [blame] | 267 | CmdArgs.push_back("-lgcc_s.10.5"); |
| 268 | } else { |
Daniel Dunbar | ce3fdf2 | 2010-01-27 00:57:03 +0000 | [diff] [blame^] | 269 | if (isMacosxVersionLT(10, 3, 9)) |
Daniel Dunbar | 6cd4154 | 2009-09-18 08:15:03 +0000 | [diff] [blame] | 270 | ; // Do nothing. |
Daniel Dunbar | ce3fdf2 | 2010-01-27 00:57:03 +0000 | [diff] [blame^] | 271 | else if (isMacosxVersionLT(10, 5)) |
Daniel Dunbar | 6cd4154 | 2009-09-18 08:15:03 +0000 | [diff] [blame] | 272 | CmdArgs.push_back("-lgcc_s.10.4"); |
Daniel Dunbar | ce3fdf2 | 2010-01-27 00:57:03 +0000 | [diff] [blame^] | 273 | else if (isMacosxVersionLT(10, 6)) |
Daniel Dunbar | 6cd4154 | 2009-09-18 08:15:03 +0000 | [diff] [blame] | 274 | CmdArgs.push_back("-lgcc_s.10.5"); |
| 275 | } |
| 276 | |
Daniel Dunbar | ce3fdf2 | 2010-01-27 00:57:03 +0000 | [diff] [blame^] | 277 | if (isTargetIPhoneOS() || isMacosxVersionLT(10, 6)) { |
Daniel Dunbar | 6cd4154 | 2009-09-18 08:15:03 +0000 | [diff] [blame] | 278 | CmdArgs.push_back("-lgcc"); |
| 279 | CmdArgs.push_back("-lSystem"); |
| 280 | } else { |
| 281 | CmdArgs.push_back("-lSystem"); |
| 282 | CmdArgs.push_back("-lgcc"); |
| 283 | } |
| 284 | } |
| 285 | } |
| 286 | |
Daniel Dunbar | 1d4612b | 2009-09-18 08:15:13 +0000 | [diff] [blame] | 287 | DarwinClang::DarwinClang(const HostInfo &Host, const llvm::Triple& Triple, |
Daniel Dunbar | cc8e189 | 2010-01-27 00:56:44 +0000 | [diff] [blame] | 288 | const unsigned (&DarwinVersion)[3]) |
| 289 | : Darwin(Host, Triple, DarwinVersion) |
Daniel Dunbar | 1d4612b | 2009-09-18 08:15:13 +0000 | [diff] [blame] | 290 | { |
| 291 | // We expect 'as', 'ld', etc. to be adjacent to our install dir. |
Daniel Dunbar | ee788e7 | 2009-12-21 18:54:17 +0000 | [diff] [blame] | 292 | getProgramPaths().push_back(getDriver().Dir); |
Daniel Dunbar | 1d4612b | 2009-09-18 08:15:13 +0000 | [diff] [blame] | 293 | } |
| 294 | |
| 295 | void DarwinClang::AddLinkSearchPathArgs(const ArgList &Args, |
| 296 | ArgStringList &CmdArgs) const { |
| 297 | // The Clang toolchain uses explicit paths for internal libraries. |
| 298 | } |
| 299 | |
| 300 | void DarwinClang::AddLinkRuntimeLibArgs(const ArgList &Args, |
| 301 | ArgStringList &CmdArgs) const { |
Daniel Dunbar | eec9910 | 2010-01-22 03:38:14 +0000 | [diff] [blame] | 302 | // Darwin doesn't support real static executables, don't link any runtime |
| 303 | // libraries with -static. |
| 304 | if (Args.hasArg(options::OPT_static)) |
Daniel Dunbar | 1d4612b | 2009-09-18 08:15:13 +0000 | [diff] [blame] | 305 | return; |
Daniel Dunbar | 1d4612b | 2009-09-18 08:15:13 +0000 | [diff] [blame] | 306 | |
| 307 | // Reject -static-libgcc for now, we can deal with this when and if someone |
| 308 | // cares. This is useful in situations where someone wants to statically link |
| 309 | // something like libstdc++, and needs its runtime support routines. |
| 310 | if (const Arg *A = Args.getLastArg(options::OPT_static_libgcc)) { |
Daniel Dunbar | ee788e7 | 2009-12-21 18:54:17 +0000 | [diff] [blame] | 311 | getDriver().Diag(clang::diag::err_drv_unsupported_opt) |
Daniel Dunbar | 1d4612b | 2009-09-18 08:15:13 +0000 | [diff] [blame] | 312 | << A->getAsString(Args); |
| 313 | return; |
| 314 | } |
| 315 | |
Daniel Dunbar | eec9910 | 2010-01-22 03:38:14 +0000 | [diff] [blame] | 316 | // Otherwise link libSystem, then the dynamic runtime library, and finally any |
| 317 | // target specific static runtime library. |
Daniel Dunbar | 1d4612b | 2009-09-18 08:15:13 +0000 | [diff] [blame] | 318 | CmdArgs.push_back("-lSystem"); |
Daniel Dunbar | eec9910 | 2010-01-22 03:38:14 +0000 | [diff] [blame] | 319 | |
| 320 | // Select the dynamic runtime library and the target specific static library. |
| 321 | const char *DarwinStaticLib = 0; |
Daniel Dunbar | 251ca6c | 2010-01-27 00:56:37 +0000 | [diff] [blame] | 322 | if (isTargetIPhoneOS()) { |
Daniel Dunbar | eec9910 | 2010-01-22 03:38:14 +0000 | [diff] [blame] | 323 | CmdArgs.push_back("-lgcc_s.1"); |
| 324 | |
| 325 | // We may need some static functions for armv6/thumb which are required to |
| 326 | // be in the same linkage unit as their caller. |
| 327 | if (getDarwinArchName(Args) == "armv6") |
| 328 | DarwinStaticLib = "libclang_rt.armv6.a"; |
| 329 | } else { |
Daniel Dunbar | eec9910 | 2010-01-22 03:38:14 +0000 | [diff] [blame] | 330 | // The dynamic runtime library was merged with libSystem for 10.6 and |
| 331 | // beyond; only 10.4 and 10.5 need an additional runtime library. |
Daniel Dunbar | ce3fdf2 | 2010-01-27 00:57:03 +0000 | [diff] [blame^] | 332 | if (isMacosxVersionLT(10, 5)) |
Daniel Dunbar | eec9910 | 2010-01-22 03:38:14 +0000 | [diff] [blame] | 333 | CmdArgs.push_back("-lgcc_s.10.4"); |
Daniel Dunbar | ce3fdf2 | 2010-01-27 00:57:03 +0000 | [diff] [blame^] | 334 | else if (isMacosxVersionLT(10, 6)) |
Daniel Dunbar | eec9910 | 2010-01-22 03:38:14 +0000 | [diff] [blame] | 335 | CmdArgs.push_back("-lgcc_s.10.5"); |
| 336 | |
| 337 | // For OS X, we only need a static runtime library when targetting 10.4, to |
| 338 | // provide versions of the static functions which were omitted from |
| 339 | // 10.4.dylib. |
Daniel Dunbar | ce3fdf2 | 2010-01-27 00:57:03 +0000 | [diff] [blame^] | 340 | if (isMacosxVersionLT(10, 5)) |
Daniel Dunbar | eec9910 | 2010-01-22 03:38:14 +0000 | [diff] [blame] | 341 | DarwinStaticLib = "libclang_rt.10.4.a"; |
| 342 | } |
| 343 | |
| 344 | /// Add the target specific static library, if needed. |
| 345 | if (DarwinStaticLib) { |
| 346 | llvm::sys::Path P(getDriver().ResourceDir); |
| 347 | P.appendComponent("lib"); |
| 348 | P.appendComponent("darwin"); |
| 349 | P.appendComponent(DarwinStaticLib); |
| 350 | |
| 351 | // For now, allow missing resource libraries to support developers who may |
| 352 | // not have compiler-rt checked out or integrated into their build. |
| 353 | if (!P.exists()) |
| 354 | getDriver().Diag(clang::diag::warn_drv_missing_resource_library) |
| 355 | << P.str(); |
| 356 | else |
| 357 | CmdArgs.push_back(Args.MakeArgString(P.str())); |
| 358 | } |
Daniel Dunbar | 1d4612b | 2009-09-18 08:15:13 +0000 | [diff] [blame] | 359 | } |
| 360 | |
Daniel Dunbar | 0dcb9a3 | 2009-09-09 18:36:12 +0000 | [diff] [blame] | 361 | DerivedArgList *Darwin::TranslateArgs(InputArgList &Args, |
| 362 | const char *BoundArch) const { |
Daniel Dunbar | 4e7e9cf | 2009-03-25 06:12:34 +0000 | [diff] [blame] | 363 | DerivedArgList *DAL = new DerivedArgList(Args, false); |
Daniel Dunbar | ee788e7 | 2009-12-21 18:54:17 +0000 | [diff] [blame] | 364 | const OptTable &Opts = getDriver().getOpts(); |
Daniel Dunbar | ec069ed | 2009-03-25 06:58:31 +0000 | [diff] [blame] | 365 | |
| 366 | // FIXME: We really want to get out of the tool chain level argument |
| 367 | // translation business, as it makes the driver functionality much |
| 368 | // more opaque. For now, we follow gcc closely solely for the |
| 369 | // purpose of easily achieving feature parity & testability. Once we |
| 370 | // have something that works, we should reevaluate each translation |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 371 | // and try to push it down into tool specific logic. |
Daniel Dunbar | ec069ed | 2009-03-25 06:58:31 +0000 | [diff] [blame] | 372 | |
Daniel Dunbar | 2603137 | 2010-01-27 00:56:25 +0000 | [diff] [blame] | 373 | Arg *OSXVersion = Args.getLastArg(options::OPT_mmacosx_version_min_EQ); |
| 374 | Arg *iPhoneVersion = Args.getLastArg(options::OPT_miphoneos_version_min_EQ); |
Daniel Dunbar | ff8857a | 2009-04-10 20:11:50 +0000 | [diff] [blame] | 375 | if (OSXVersion && iPhoneVersion) { |
Daniel Dunbar | ee788e7 | 2009-12-21 18:54:17 +0000 | [diff] [blame] | 376 | getDriver().Diag(clang::diag::err_drv_argument_not_allowed_with) |
Daniel Dunbar | ff8857a | 2009-04-10 20:11:50 +0000 | [diff] [blame] | 377 | << OSXVersion->getAsString(Args) |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 378 | << iPhoneVersion->getAsString(Args); |
Daniel Dunbar | 2603137 | 2010-01-27 00:56:25 +0000 | [diff] [blame] | 379 | iPhoneVersion = 0; |
Daniel Dunbar | ff8857a | 2009-04-10 20:11:50 +0000 | [diff] [blame] | 380 | } else if (!OSXVersion && !iPhoneVersion) { |
Daniel Dunbar | 816bc31 | 2010-01-26 01:45:19 +0000 | [diff] [blame] | 381 | // If neither OS X nor iPhoneOS targets were specified, check for |
| 382 | // environment defines. |
| 383 | const char *OSXTarget = ::getenv("MACOSX_DEPLOYMENT_TARGET"); |
| 384 | const char *iPhoneOSTarget = ::getenv("IPHONEOS_DEPLOYMENT_TARGET"); |
Daniel Dunbar | f36a06a | 2009-04-10 21:00:07 +0000 | [diff] [blame] | 385 | |
Daniel Dunbar | 816bc31 | 2010-01-26 01:45:19 +0000 | [diff] [blame] | 386 | // Ignore empty strings. |
| 387 | if (OSXTarget && OSXTarget[0] == '\0') |
| 388 | OSXTarget = 0; |
| 389 | if (iPhoneOSTarget && iPhoneOSTarget[0] == '\0') |
| 390 | iPhoneOSTarget = 0; |
| 391 | |
| 392 | if (OSXTarget && iPhoneOSTarget) { |
| 393 | getDriver().Diag(clang::diag::err_drv_conflicting_deployment_targets) |
| 394 | << OSXTarget << iPhoneOSTarget; |
| 395 | } else if (OSXTarget) { |
Daniel Dunbar | 30392de | 2009-09-04 18:35:21 +0000 | [diff] [blame] | 396 | const Option *O = Opts.getOption(options::OPT_mmacosx_version_min_EQ); |
Daniel Dunbar | 2603137 | 2010-01-27 00:56:25 +0000 | [diff] [blame] | 397 | OSXVersion = DAL->MakeJoinedArg(0, O, OSXTarget); |
| 398 | DAL->append(OSXVersion); |
Daniel Dunbar | 816bc31 | 2010-01-26 01:45:19 +0000 | [diff] [blame] | 399 | } else if (iPhoneOSTarget) { |
Daniel Dunbar | 30392de | 2009-09-04 18:35:21 +0000 | [diff] [blame] | 400 | const Option *O = Opts.getOption(options::OPT_miphoneos_version_min_EQ); |
Daniel Dunbar | 2603137 | 2010-01-27 00:56:25 +0000 | [diff] [blame] | 401 | iPhoneVersion = DAL->MakeJoinedArg(0, O, iPhoneOSTarget); |
| 402 | DAL->append(iPhoneVersion); |
Daniel Dunbar | 816bc31 | 2010-01-26 01:45:19 +0000 | [diff] [blame] | 403 | } else { |
Daniel Dunbar | cc8e189 | 2010-01-27 00:56:44 +0000 | [diff] [blame] | 404 | // Otherwise, choose a default platform based on the tool chain. |
| 405 | // |
| 406 | // FIXME: Don't hardcode default here. |
| 407 | if (getTriple().getArch() == llvm::Triple::arm || |
| 408 | getTriple().getArch() == llvm::Triple::thumb) { |
Daniel Dunbar | 816bc31 | 2010-01-26 01:45:19 +0000 | [diff] [blame] | 409 | const Option *O = Opts.getOption(options::OPT_miphoneos_version_min_EQ); |
Daniel Dunbar | cc8e189 | 2010-01-27 00:56:44 +0000 | [diff] [blame] | 410 | iPhoneVersion = DAL->MakeJoinedArg(0, O, "3.0"); |
Daniel Dunbar | 2603137 | 2010-01-27 00:56:25 +0000 | [diff] [blame] | 411 | DAL->append(iPhoneVersion); |
Daniel Dunbar | 816bc31 | 2010-01-26 01:45:19 +0000 | [diff] [blame] | 412 | } else { |
| 413 | const Option *O = Opts.getOption(options::OPT_mmacosx_version_min_EQ); |
Daniel Dunbar | 2603137 | 2010-01-27 00:56:25 +0000 | [diff] [blame] | 414 | OSXVersion = DAL->MakeJoinedArg(0, O, MacosxVersionMin); |
| 415 | DAL->append(OSXVersion); |
Daniel Dunbar | 816bc31 | 2010-01-26 01:45:19 +0000 | [diff] [blame] | 416 | } |
Daniel Dunbar | 30392de | 2009-09-04 18:35:21 +0000 | [diff] [blame] | 417 | } |
Daniel Dunbar | ec069ed | 2009-03-25 06:58:31 +0000 | [diff] [blame] | 418 | } |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 419 | |
Daniel Dunbar | 2603137 | 2010-01-27 00:56:25 +0000 | [diff] [blame] | 420 | // Set the tool chain target information. |
| 421 | unsigned Major, Minor, Micro; |
| 422 | bool HadExtra; |
| 423 | if (OSXVersion) { |
| 424 | assert(!iPhoneVersion && "Unknown target platform!"); |
| 425 | if (!Driver::GetReleaseVersion(OSXVersion->getValue(Args), Major, Minor, |
| 426 | Micro, HadExtra) || HadExtra || |
| 427 | Major != 10 || Minor >= 10 || Micro >= 10) |
| 428 | getDriver().Diag(clang::diag::err_drv_invalid_version_number) |
| 429 | << OSXVersion->getAsString(Args); |
| 430 | } else { |
| 431 | assert(iPhoneVersion && "Unknown target platform!"); |
| 432 | if (!Driver::GetReleaseVersion(iPhoneVersion->getValue(Args), Major, Minor, |
| 433 | Micro, HadExtra) || HadExtra || |
| 434 | Major >= 10 || Minor >= 100 || Micro >= 100) |
| 435 | getDriver().Diag(clang::diag::err_drv_invalid_version_number) |
| 436 | << iPhoneVersion->getAsString(Args); |
| 437 | } |
| 438 | setTarget(iPhoneVersion, Major, Minor, Micro); |
| 439 | |
Daniel Dunbar | 4e7e9cf | 2009-03-25 06:12:34 +0000 | [diff] [blame] | 440 | for (ArgList::iterator it = Args.begin(), ie = Args.end(); it != ie; ++it) { |
| 441 | Arg *A = *it; |
| 442 | |
| 443 | if (A->getOption().matches(options::OPT_Xarch__)) { |
| 444 | // FIXME: Canonicalize name. |
| 445 | if (getArchName() != A->getValue(Args, 0)) |
| 446 | continue; |
| 447 | |
| 448 | // FIXME: The arg is leaked here, and we should have a nicer |
| 449 | // interface for this. |
Daniel Dunbar | 4e7e9cf | 2009-03-25 06:12:34 +0000 | [diff] [blame] | 450 | unsigned Prev, Index = Prev = A->getIndex() + 1; |
Daniel Dunbar | ec069ed | 2009-03-25 06:58:31 +0000 | [diff] [blame] | 451 | Arg *XarchArg = Opts.ParseOneArg(Args, Index); |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 452 | |
Daniel Dunbar | 4e7e9cf | 2009-03-25 06:12:34 +0000 | [diff] [blame] | 453 | // If the argument parsing failed or more than one argument was |
| 454 | // consumed, the -Xarch_ argument's parameter tried to consume |
| 455 | // extra arguments. Emit an error and ignore. |
| 456 | // |
| 457 | // We also want to disallow any options which would alter the |
| 458 | // driver behavior; that isn't going to work in our model. We |
| 459 | // use isDriverOption() as an approximation, although things |
| 460 | // like -O4 are going to slip through. |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 461 | if (!XarchArg || Index > Prev + 1 || |
Daniel Dunbar | 4e7e9cf | 2009-03-25 06:12:34 +0000 | [diff] [blame] | 462 | XarchArg->getOption().isDriverOption()) { |
Daniel Dunbar | ee788e7 | 2009-12-21 18:54:17 +0000 | [diff] [blame] | 463 | getDriver().Diag(clang::diag::err_drv_invalid_Xarch_argument) |
Daniel Dunbar | 4e7e9cf | 2009-03-25 06:12:34 +0000 | [diff] [blame] | 464 | << A->getAsString(Args); |
| 465 | continue; |
| 466 | } |
| 467 | |
Daniel Dunbar | 478edc2 | 2009-03-29 22:29:05 +0000 | [diff] [blame] | 468 | XarchArg->setBaseArg(A); |
Daniel Dunbar | 4e7e9cf | 2009-03-25 06:12:34 +0000 | [diff] [blame] | 469 | A = XarchArg; |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 470 | } |
Daniel Dunbar | 4e7e9cf | 2009-03-25 06:12:34 +0000 | [diff] [blame] | 471 | |
Daniel Dunbar | ec069ed | 2009-03-25 06:58:31 +0000 | [diff] [blame] | 472 | // Sob. These is strictly gcc compatible for the time being. Apple |
| 473 | // gcc translates options twice, which means that self-expanding |
| 474 | // options add duplicates. |
Daniel Dunbar | 9e1f982 | 2009-11-19 04:14:53 +0000 | [diff] [blame] | 475 | switch ((options::ID) A->getOption().getID()) { |
Daniel Dunbar | ec069ed | 2009-03-25 06:58:31 +0000 | [diff] [blame] | 476 | default: |
| 477 | DAL->append(A); |
| 478 | break; |
| 479 | |
| 480 | case options::OPT_mkernel: |
| 481 | case options::OPT_fapple_kext: |
| 482 | DAL->append(A); |
Daniel Dunbar | 478edc2 | 2009-03-29 22:29:05 +0000 | [diff] [blame] | 483 | DAL->append(DAL->MakeFlagArg(A, Opts.getOption(options::OPT_static))); |
| 484 | DAL->append(DAL->MakeFlagArg(A, Opts.getOption(options::OPT_static))); |
Daniel Dunbar | ec069ed | 2009-03-25 06:58:31 +0000 | [diff] [blame] | 485 | break; |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 486 | |
Daniel Dunbar | ec069ed | 2009-03-25 06:58:31 +0000 | [diff] [blame] | 487 | case options::OPT_dependency_file: |
Daniel Dunbar | 478edc2 | 2009-03-29 22:29:05 +0000 | [diff] [blame] | 488 | DAL->append(DAL->MakeSeparateArg(A, Opts.getOption(options::OPT_MF), |
Daniel Dunbar | ec069ed | 2009-03-25 06:58:31 +0000 | [diff] [blame] | 489 | A->getValue(Args))); |
| 490 | break; |
| 491 | |
| 492 | case options::OPT_gfull: |
Daniel Dunbar | 478edc2 | 2009-03-29 22:29:05 +0000 | [diff] [blame] | 493 | DAL->append(DAL->MakeFlagArg(A, Opts.getOption(options::OPT_g_Flag))); |
| 494 | DAL->append(DAL->MakeFlagArg(A, |
Daniel Dunbar | ec069ed | 2009-03-25 06:58:31 +0000 | [diff] [blame] | 495 | Opts.getOption(options::OPT_fno_eliminate_unused_debug_symbols))); |
| 496 | break; |
| 497 | |
| 498 | case options::OPT_gused: |
Daniel Dunbar | 478edc2 | 2009-03-29 22:29:05 +0000 | [diff] [blame] | 499 | DAL->append(DAL->MakeFlagArg(A, Opts.getOption(options::OPT_g_Flag))); |
| 500 | DAL->append(DAL->MakeFlagArg(A, |
Daniel Dunbar | ec069ed | 2009-03-25 06:58:31 +0000 | [diff] [blame] | 501 | Opts.getOption(options::OPT_feliminate_unused_debug_symbols))); |
| 502 | break; |
| 503 | |
| 504 | case options::OPT_fterminated_vtables: |
| 505 | case options::OPT_findirect_virtual_calls: |
Daniel Dunbar | 478edc2 | 2009-03-29 22:29:05 +0000 | [diff] [blame] | 506 | DAL->append(DAL->MakeFlagArg(A, |
| 507 | Opts.getOption(options::OPT_fapple_kext))); |
| 508 | DAL->append(DAL->MakeFlagArg(A, Opts.getOption(options::OPT_static))); |
Daniel Dunbar | ec069ed | 2009-03-25 06:58:31 +0000 | [diff] [blame] | 509 | break; |
| 510 | |
| 511 | case options::OPT_shared: |
Daniel Dunbar | 478edc2 | 2009-03-29 22:29:05 +0000 | [diff] [blame] | 512 | DAL->append(DAL->MakeFlagArg(A, Opts.getOption(options::OPT_dynamiclib))); |
Daniel Dunbar | ec069ed | 2009-03-25 06:58:31 +0000 | [diff] [blame] | 513 | break; |
| 514 | |
| 515 | case options::OPT_fconstant_cfstrings: |
Daniel Dunbar | 478edc2 | 2009-03-29 22:29:05 +0000 | [diff] [blame] | 516 | DAL->append(DAL->MakeFlagArg(A, |
Daniel Dunbar | ec069ed | 2009-03-25 06:58:31 +0000 | [diff] [blame] | 517 | Opts.getOption(options::OPT_mconstant_cfstrings))); |
| 518 | break; |
| 519 | |
| 520 | case options::OPT_fno_constant_cfstrings: |
Daniel Dunbar | 478edc2 | 2009-03-29 22:29:05 +0000 | [diff] [blame] | 521 | DAL->append(DAL->MakeFlagArg(A, |
Daniel Dunbar | ec069ed | 2009-03-25 06:58:31 +0000 | [diff] [blame] | 522 | Opts.getOption(options::OPT_mno_constant_cfstrings))); |
| 523 | break; |
| 524 | |
| 525 | case options::OPT_Wnonportable_cfstrings: |
Daniel Dunbar | 478edc2 | 2009-03-29 22:29:05 +0000 | [diff] [blame] | 526 | DAL->append(DAL->MakeFlagArg(A, |
Daniel Dunbar | ec069ed | 2009-03-25 06:58:31 +0000 | [diff] [blame] | 527 | Opts.getOption(options::OPT_mwarn_nonportable_cfstrings))); |
| 528 | break; |
| 529 | |
| 530 | case options::OPT_Wno_nonportable_cfstrings: |
Daniel Dunbar | 478edc2 | 2009-03-29 22:29:05 +0000 | [diff] [blame] | 531 | DAL->append(DAL->MakeFlagArg(A, |
Daniel Dunbar | ec069ed | 2009-03-25 06:58:31 +0000 | [diff] [blame] | 532 | Opts.getOption(options::OPT_mno_warn_nonportable_cfstrings))); |
| 533 | break; |
| 534 | |
| 535 | case options::OPT_fpascal_strings: |
Daniel Dunbar | 478edc2 | 2009-03-29 22:29:05 +0000 | [diff] [blame] | 536 | DAL->append(DAL->MakeFlagArg(A, |
Daniel Dunbar | ec069ed | 2009-03-25 06:58:31 +0000 | [diff] [blame] | 537 | Opts.getOption(options::OPT_mpascal_strings))); |
| 538 | break; |
| 539 | |
| 540 | case options::OPT_fno_pascal_strings: |
Daniel Dunbar | 478edc2 | 2009-03-29 22:29:05 +0000 | [diff] [blame] | 541 | DAL->append(DAL->MakeFlagArg(A, |
Daniel Dunbar | ec069ed | 2009-03-25 06:58:31 +0000 | [diff] [blame] | 542 | Opts.getOption(options::OPT_mno_pascal_strings))); |
| 543 | break; |
| 544 | } |
Daniel Dunbar | 4e7e9cf | 2009-03-25 06:12:34 +0000 | [diff] [blame] | 545 | } |
| 546 | |
Daniel Dunbar | 84ec96c | 2009-09-09 22:33:15 +0000 | [diff] [blame] | 547 | if (getTriple().getArch() == llvm::Triple::x86 || |
| 548 | getTriple().getArch() == llvm::Triple::x86_64) |
Daniel Dunbar | e4bdae7 | 2009-11-19 04:00:53 +0000 | [diff] [blame] | 549 | if (!Args.hasArgNoClaim(options::OPT_mtune_EQ)) |
Daniel Dunbar | 84ec96c | 2009-09-09 22:33:15 +0000 | [diff] [blame] | 550 | DAL->append(DAL->MakeJoinedArg(0, Opts.getOption(options::OPT_mtune_EQ), |
| 551 | "core2")); |
| 552 | |
| 553 | // Add the arch options based on the particular spelling of -arch, to match |
| 554 | // how the driver driver works. |
| 555 | if (BoundArch) { |
| 556 | llvm::StringRef Name = BoundArch; |
| 557 | const Option *MCpu = Opts.getOption(options::OPT_mcpu_EQ); |
| 558 | const Option *MArch = Opts.getOption(options::OPT_march_EQ); |
| 559 | |
| 560 | // This code must be kept in sync with LLVM's getArchTypeForDarwinArch, |
| 561 | // which defines the list of which architectures we accept. |
| 562 | if (Name == "ppc") |
| 563 | ; |
| 564 | else if (Name == "ppc601") |
| 565 | DAL->append(DAL->MakeJoinedArg(0, MCpu, "601")); |
| 566 | else if (Name == "ppc603") |
| 567 | DAL->append(DAL->MakeJoinedArg(0, MCpu, "603")); |
| 568 | else if (Name == "ppc604") |
| 569 | DAL->append(DAL->MakeJoinedArg(0, MCpu, "604")); |
| 570 | else if (Name == "ppc604e") |
| 571 | DAL->append(DAL->MakeJoinedArg(0, MCpu, "604e")); |
| 572 | else if (Name == "ppc750") |
| 573 | DAL->append(DAL->MakeJoinedArg(0, MCpu, "750")); |
| 574 | else if (Name == "ppc7400") |
| 575 | DAL->append(DAL->MakeJoinedArg(0, MCpu, "7400")); |
| 576 | else if (Name == "ppc7450") |
| 577 | DAL->append(DAL->MakeJoinedArg(0, MCpu, "7450")); |
| 578 | else if (Name == "ppc970") |
| 579 | DAL->append(DAL->MakeJoinedArg(0, MCpu, "970")); |
| 580 | |
| 581 | else if (Name == "ppc64") |
Daniel Dunbar | 478edc2 | 2009-03-29 22:29:05 +0000 | [diff] [blame] | 582 | DAL->append(DAL->MakeFlagArg(0, Opts.getOption(options::OPT_m64))); |
Daniel Dunbar | ec069ed | 2009-03-25 06:58:31 +0000 | [diff] [blame] | 583 | |
Daniel Dunbar | 84ec96c | 2009-09-09 22:33:15 +0000 | [diff] [blame] | 584 | else if (Name == "i386") |
| 585 | ; |
| 586 | else if (Name == "i486") |
| 587 | DAL->append(DAL->MakeJoinedArg(0, MArch, "i486")); |
| 588 | else if (Name == "i586") |
| 589 | DAL->append(DAL->MakeJoinedArg(0, MArch, "i586")); |
| 590 | else if (Name == "i686") |
| 591 | DAL->append(DAL->MakeJoinedArg(0, MArch, "i686")); |
| 592 | else if (Name == "pentium") |
| 593 | DAL->append(DAL->MakeJoinedArg(0, MArch, "pentium")); |
| 594 | else if (Name == "pentium2") |
| 595 | DAL->append(DAL->MakeJoinedArg(0, MArch, "pentium2")); |
| 596 | else if (Name == "pentpro") |
| 597 | DAL->append(DAL->MakeJoinedArg(0, MArch, "pentiumpro")); |
| 598 | else if (Name == "pentIIm3") |
| 599 | DAL->append(DAL->MakeJoinedArg(0, MArch, "pentium2")); |
| 600 | |
| 601 | else if (Name == "x86_64") |
| 602 | DAL->append(DAL->MakeFlagArg(0, Opts.getOption(options::OPT_m64))); |
| 603 | |
| 604 | else if (Name == "arm") |
| 605 | DAL->append(DAL->MakeJoinedArg(0, MArch, "armv4t")); |
| 606 | else if (Name == "armv4t") |
| 607 | DAL->append(DAL->MakeJoinedArg(0, MArch, "armv4t")); |
| 608 | else if (Name == "armv5") |
| 609 | DAL->append(DAL->MakeJoinedArg(0, MArch, "armv5tej")); |
| 610 | else if (Name == "xscale") |
| 611 | DAL->append(DAL->MakeJoinedArg(0, MArch, "xscale")); |
| 612 | else if (Name == "armv6") |
| 613 | DAL->append(DAL->MakeJoinedArg(0, MArch, "armv6k")); |
| 614 | else if (Name == "armv7") |
| 615 | DAL->append(DAL->MakeJoinedArg(0, MArch, "armv7a")); |
| 616 | |
| 617 | else |
Jeffrey Yasskin | 9f61aa9 | 2009-12-12 05:05:38 +0000 | [diff] [blame] | 618 | llvm_unreachable("invalid Darwin arch"); |
Daniel Dunbar | 84ec96c | 2009-09-09 22:33:15 +0000 | [diff] [blame] | 619 | } |
Daniel Dunbar | ec069ed | 2009-03-25 06:58:31 +0000 | [diff] [blame] | 620 | |
Daniel Dunbar | 4e7e9cf | 2009-03-25 06:12:34 +0000 | [diff] [blame] | 621 | return DAL; |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 622 | } |
Daniel Dunbar | 8eddb3f | 2009-03-20 00:57:52 +0000 | [diff] [blame] | 623 | |
Daniel Dunbar | f395528 | 2009-09-04 18:34:51 +0000 | [diff] [blame] | 624 | bool Darwin::IsUnwindTablesDefault() const { |
Daniel Dunbar | 8eddb3f | 2009-03-20 00:57:52 +0000 | [diff] [blame] | 625 | // FIXME: Gross; we should probably have some separate target |
| 626 | // definition, possibly even reusing the one in clang. |
| 627 | return getArchName() == "x86_64"; |
| 628 | } |
| 629 | |
Daniel Dunbar | f2d8b9f | 2009-12-18 02:43:17 +0000 | [diff] [blame] | 630 | bool Darwin::UseDwarfDebugFlags() const { |
| 631 | if (const char *S = ::getenv("RC_DEBUG_OPTIONS")) |
| 632 | return S[0] != '\0'; |
| 633 | return false; |
| 634 | } |
| 635 | |
Daniel Dunbar | f395528 | 2009-09-04 18:34:51 +0000 | [diff] [blame] | 636 | const char *Darwin::GetDefaultRelocationModel() const { |
Daniel Dunbar | 8eddb3f | 2009-03-20 00:57:52 +0000 | [diff] [blame] | 637 | return "pic"; |
| 638 | } |
| 639 | |
Daniel Dunbar | f395528 | 2009-09-04 18:34:51 +0000 | [diff] [blame] | 640 | const char *Darwin::GetForcedPicModel() const { |
Daniel Dunbar | 8eddb3f | 2009-03-20 00:57:52 +0000 | [diff] [blame] | 641 | if (getArchName() == "x86_64") |
| 642 | return "pic"; |
| 643 | return 0; |
| 644 | } |
| 645 | |
Daniel Dunbar | 3917608 | 2009-03-20 00:20:03 +0000 | [diff] [blame] | 646 | /// Generic_GCC - A tool chain using the 'gcc' command to perform |
| 647 | /// all subcommands; this relies on gcc translating the majority of |
| 648 | /// command line options. |
| 649 | |
Daniel Dunbar | cb8ab23 | 2009-05-22 02:53:45 +0000 | [diff] [blame] | 650 | Generic_GCC::Generic_GCC(const HostInfo &Host, const llvm::Triple& Triple) |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 651 | : ToolChain(Host, Triple) { |
Daniel Dunbar | ee788e7 | 2009-12-21 18:54:17 +0000 | [diff] [blame] | 652 | getProgramPaths().push_back(getDriver().Dir); |
Daniel Dunbar | c50b00d | 2009-03-23 16:15:50 +0000 | [diff] [blame] | 653 | } |
| 654 | |
Daniel Dunbar | 3917608 | 2009-03-20 00:20:03 +0000 | [diff] [blame] | 655 | Generic_GCC::~Generic_GCC() { |
| 656 | // Free tool implementations. |
| 657 | for (llvm::DenseMap<unsigned, Tool*>::iterator |
| 658 | it = Tools.begin(), ie = Tools.end(); it != ie; ++it) |
| 659 | delete it->second; |
| 660 | } |
| 661 | |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 662 | Tool &Generic_GCC::SelectTool(const Compilation &C, |
Daniel Dunbar | 3917608 | 2009-03-20 00:20:03 +0000 | [diff] [blame] | 663 | const JobAction &JA) const { |
| 664 | Action::ActionClass Key; |
Daniel Dunbar | ee788e7 | 2009-12-21 18:54:17 +0000 | [diff] [blame] | 665 | if (getDriver().ShouldUseClangCompiler(C, JA, getTriple())) |
Daniel Dunbar | 3917608 | 2009-03-20 00:20:03 +0000 | [diff] [blame] | 666 | Key = Action::AnalyzeJobClass; |
| 667 | else |
| 668 | Key = JA.getKind(); |
| 669 | |
| 670 | Tool *&T = Tools[Key]; |
| 671 | if (!T) { |
| 672 | switch (Key) { |
Daniel Dunbar | 8eddb3f | 2009-03-20 00:57:52 +0000 | [diff] [blame] | 673 | case Action::InputClass: |
| 674 | case Action::BindArchClass: |
Daniel Dunbar | 3917608 | 2009-03-20 00:20:03 +0000 | [diff] [blame] | 675 | assert(0 && "Invalid tool kind."); |
| 676 | case Action::PreprocessJobClass: |
| 677 | T = new tools::gcc::Preprocess(*this); break; |
| 678 | case Action::PrecompileJobClass: |
| 679 | T = new tools::gcc::Precompile(*this); break; |
| 680 | case Action::AnalyzeJobClass: |
| 681 | T = new tools::Clang(*this); break; |
| 682 | case Action::CompileJobClass: |
| 683 | T = new tools::gcc::Compile(*this); break; |
| 684 | case Action::AssembleJobClass: |
| 685 | T = new tools::gcc::Assemble(*this); break; |
| 686 | case Action::LinkJobClass: |
| 687 | T = new tools::gcc::Link(*this); break; |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 688 | |
Daniel Dunbar | 8eddb3f | 2009-03-20 00:57:52 +0000 | [diff] [blame] | 689 | // This is a bit ungeneric, but the only platform using a driver |
| 690 | // driver is Darwin. |
| 691 | case Action::LipoJobClass: |
| 692 | T = new tools::darwin::Lipo(*this); break; |
Daniel Dunbar | 3917608 | 2009-03-20 00:20:03 +0000 | [diff] [blame] | 693 | } |
| 694 | } |
| 695 | |
| 696 | return *T; |
| 697 | } |
| 698 | |
Daniel Dunbar | 3917608 | 2009-03-20 00:20:03 +0000 | [diff] [blame] | 699 | bool Generic_GCC::IsUnwindTablesDefault() const { |
Daniel Dunbar | 8eddb3f | 2009-03-20 00:57:52 +0000 | [diff] [blame] | 700 | // FIXME: Gross; we should probably have some separate target |
| 701 | // definition, possibly even reusing the one in clang. |
Daniel Dunbar | 3917608 | 2009-03-20 00:20:03 +0000 | [diff] [blame] | 702 | return getArchName() == "x86_64"; |
| 703 | } |
| 704 | |
| 705 | const char *Generic_GCC::GetDefaultRelocationModel() const { |
| 706 | return "static"; |
| 707 | } |
| 708 | |
| 709 | const char *Generic_GCC::GetForcedPicModel() const { |
| 710 | return 0; |
| 711 | } |
Daniel Dunbar | f3cad36 | 2009-03-25 04:13:45 +0000 | [diff] [blame] | 712 | |
Daniel Dunbar | 0dcb9a3 | 2009-09-09 18:36:12 +0000 | [diff] [blame] | 713 | DerivedArgList *Generic_GCC::TranslateArgs(InputArgList &Args, |
| 714 | const char *BoundArch) const { |
Daniel Dunbar | f3cad36 | 2009-03-25 04:13:45 +0000 | [diff] [blame] | 715 | return new DerivedArgList(Args, true); |
| 716 | } |
Daniel Dunbar | 75358d2 | 2009-03-30 21:06:03 +0000 | [diff] [blame] | 717 | |
Daniel Dunbar | f7b8eec | 2009-06-29 20:52:51 +0000 | [diff] [blame] | 718 | /// OpenBSD - OpenBSD tool chain which can call as(1) and ld(1) directly. |
| 719 | |
| 720 | OpenBSD::OpenBSD(const HostInfo &Host, const llvm::Triple& Triple) |
| 721 | : Generic_GCC(Host, Triple) { |
Daniel Dunbar | ee788e7 | 2009-12-21 18:54:17 +0000 | [diff] [blame] | 722 | getFilePaths().push_back(getDriver().Dir + "/../lib"); |
Daniel Dunbar | f7b8eec | 2009-06-29 20:52:51 +0000 | [diff] [blame] | 723 | getFilePaths().push_back("/usr/lib"); |
| 724 | } |
| 725 | |
| 726 | Tool &OpenBSD::SelectTool(const Compilation &C, const JobAction &JA) const { |
| 727 | Action::ActionClass Key; |
Daniel Dunbar | ee788e7 | 2009-12-21 18:54:17 +0000 | [diff] [blame] | 728 | if (getDriver().ShouldUseClangCompiler(C, JA, getTriple())) |
Daniel Dunbar | f7b8eec | 2009-06-29 20:52:51 +0000 | [diff] [blame] | 729 | Key = Action::AnalyzeJobClass; |
| 730 | else |
| 731 | Key = JA.getKind(); |
| 732 | |
| 733 | Tool *&T = Tools[Key]; |
| 734 | if (!T) { |
| 735 | switch (Key) { |
| 736 | case Action::AssembleJobClass: |
| 737 | T = new tools::openbsd::Assemble(*this); break; |
| 738 | case Action::LinkJobClass: |
| 739 | T = new tools::openbsd::Link(*this); break; |
| 740 | default: |
| 741 | T = &Generic_GCC::SelectTool(C, JA); |
| 742 | } |
| 743 | } |
| 744 | |
| 745 | return *T; |
| 746 | } |
| 747 | |
Daniel Dunbar | 75358d2 | 2009-03-30 21:06:03 +0000 | [diff] [blame] | 748 | /// FreeBSD - FreeBSD tool chain which can call as(1) and ld(1) directly. |
| 749 | |
Daniel Dunbar | cb8ab23 | 2009-05-22 02:53:45 +0000 | [diff] [blame] | 750 | FreeBSD::FreeBSD(const HostInfo &Host, const llvm::Triple& Triple, bool Lib32) |
| 751 | : Generic_GCC(Host, Triple) { |
Daniel Dunbar | bc53466 | 2009-04-02 18:30:04 +0000 | [diff] [blame] | 752 | if (Lib32) { |
Daniel Dunbar | ee788e7 | 2009-12-21 18:54:17 +0000 | [diff] [blame] | 753 | getFilePaths().push_back(getDriver().Dir + "/../lib32"); |
Daniel Dunbar | bc53466 | 2009-04-02 18:30:04 +0000 | [diff] [blame] | 754 | getFilePaths().push_back("/usr/lib32"); |
| 755 | } else { |
Daniel Dunbar | ee788e7 | 2009-12-21 18:54:17 +0000 | [diff] [blame] | 756 | getFilePaths().push_back(getDriver().Dir + "/../lib"); |
Daniel Dunbar | bc53466 | 2009-04-02 18:30:04 +0000 | [diff] [blame] | 757 | getFilePaths().push_back("/usr/lib"); |
| 758 | } |
Daniel Dunbar | 75358d2 | 2009-03-30 21:06:03 +0000 | [diff] [blame] | 759 | } |
| 760 | |
| 761 | Tool &FreeBSD::SelectTool(const Compilation &C, const JobAction &JA) const { |
| 762 | Action::ActionClass Key; |
Daniel Dunbar | ee788e7 | 2009-12-21 18:54:17 +0000 | [diff] [blame] | 763 | if (getDriver().ShouldUseClangCompiler(C, JA, getTriple())) |
Daniel Dunbar | 75358d2 | 2009-03-30 21:06:03 +0000 | [diff] [blame] | 764 | Key = Action::AnalyzeJobClass; |
| 765 | else |
| 766 | Key = JA.getKind(); |
| 767 | |
| 768 | Tool *&T = Tools[Key]; |
| 769 | if (!T) { |
| 770 | switch (Key) { |
Daniel Dunbar | 68a31d4 | 2009-03-31 17:45:15 +0000 | [diff] [blame] | 771 | case Action::AssembleJobClass: |
| 772 | T = new tools::freebsd::Assemble(*this); break; |
Daniel Dunbar | 008f54a | 2009-04-01 19:36:32 +0000 | [diff] [blame] | 773 | case Action::LinkJobClass: |
| 774 | T = new tools::freebsd::Link(*this); break; |
Daniel Dunbar | 75358d2 | 2009-03-30 21:06:03 +0000 | [diff] [blame] | 775 | default: |
| 776 | T = &Generic_GCC::SelectTool(C, JA); |
| 777 | } |
| 778 | } |
| 779 | |
| 780 | return *T; |
| 781 | } |
Daniel Dunbar | 11e1b40 | 2009-05-02 18:28:39 +0000 | [diff] [blame] | 782 | |
Edward O'Callaghan | e7925a0 | 2009-08-22 01:06:46 +0000 | [diff] [blame] | 783 | /// AuroraUX - AuroraUX tool chain which can call as(1) and ld(1) directly. |
| 784 | |
| 785 | AuroraUX::AuroraUX(const HostInfo &Host, const llvm::Triple& Triple) |
| 786 | : Generic_GCC(Host, Triple) { |
| 787 | |
Daniel Dunbar | ee788e7 | 2009-12-21 18:54:17 +0000 | [diff] [blame] | 788 | getProgramPaths().push_back(getDriver().Dir); |
Edward O'Callaghan | e7925a0 | 2009-08-22 01:06:46 +0000 | [diff] [blame] | 789 | |
Daniel Dunbar | ee788e7 | 2009-12-21 18:54:17 +0000 | [diff] [blame] | 790 | getFilePaths().push_back(getDriver().Dir + "/../lib"); |
Edward O'Callaghan | e7925a0 | 2009-08-22 01:06:46 +0000 | [diff] [blame] | 791 | getFilePaths().push_back("/usr/lib"); |
| 792 | getFilePaths().push_back("/usr/sfw/lib"); |
| 793 | getFilePaths().push_back("/opt/gcc4/lib"); |
Edward O'Callaghan | 7adf949 | 2009-10-15 07:44:07 +0000 | [diff] [blame] | 794 | getFilePaths().push_back("/opt/gcc4/lib/gcc/i386-pc-solaris2.11/4.2.4"); |
Edward O'Callaghan | e7925a0 | 2009-08-22 01:06:46 +0000 | [diff] [blame] | 795 | |
| 796 | } |
| 797 | |
| 798 | Tool &AuroraUX::SelectTool(const Compilation &C, const JobAction &JA) const { |
| 799 | Action::ActionClass Key; |
Daniel Dunbar | ee788e7 | 2009-12-21 18:54:17 +0000 | [diff] [blame] | 800 | if (getDriver().ShouldUseClangCompiler(C, JA, getTriple())) |
Edward O'Callaghan | e7925a0 | 2009-08-22 01:06:46 +0000 | [diff] [blame] | 801 | Key = Action::AnalyzeJobClass; |
| 802 | else |
| 803 | Key = JA.getKind(); |
| 804 | |
| 805 | Tool *&T = Tools[Key]; |
| 806 | if (!T) { |
| 807 | switch (Key) { |
| 808 | case Action::AssembleJobClass: |
| 809 | T = new tools::auroraux::Assemble(*this); break; |
| 810 | case Action::LinkJobClass: |
| 811 | T = new tools::auroraux::Link(*this); break; |
| 812 | default: |
| 813 | T = &Generic_GCC::SelectTool(C, JA); |
| 814 | } |
| 815 | } |
| 816 | |
| 817 | return *T; |
| 818 | } |
| 819 | |
| 820 | |
Eli Friedman | 6b3454a | 2009-05-26 07:52:18 +0000 | [diff] [blame] | 821 | /// Linux toolchain (very bare-bones at the moment). |
| 822 | |
| 823 | Linux::Linux(const HostInfo &Host, const llvm::Triple& Triple) |
| 824 | : Generic_GCC(Host, Triple) { |
Daniel Dunbar | ee788e7 | 2009-12-21 18:54:17 +0000 | [diff] [blame] | 825 | getFilePaths().push_back(getDriver().Dir + "/../lib/clang/1.0/"); |
Eli Friedman | 6b3454a | 2009-05-26 07:52:18 +0000 | [diff] [blame] | 826 | getFilePaths().push_back("/lib/"); |
| 827 | getFilePaths().push_back("/usr/lib/"); |
Daniel Dunbar | a9822de | 2009-08-06 01:47:11 +0000 | [diff] [blame] | 828 | |
| 829 | // Depending on the Linux distribution, any combination of lib{,32,64} is |
| 830 | // possible. E.g. Debian uses lib and lib32 for mixed i386/x86-64 systems, |
| 831 | // openSUSE uses lib and lib64 for the same purpose. |
| 832 | getFilePaths().push_back("/lib32/"); |
| 833 | getFilePaths().push_back("/usr/lib32/"); |
| 834 | getFilePaths().push_back("/lib64/"); |
| 835 | getFilePaths().push_back("/usr/lib64/"); |
| 836 | |
Eli Friedman | 6b3454a | 2009-05-26 07:52:18 +0000 | [diff] [blame] | 837 | // FIXME: Figure out some way to get gcc's libdir |
| 838 | // (e.g. /usr/lib/gcc/i486-linux-gnu/4.3/ for Ubuntu 32-bit); we need |
| 839 | // crtbegin.o/crtend.o/etc., and want static versions of various |
| 840 | // libraries. If we had our own crtbegin.o/crtend.o/etc, we could probably |
| 841 | // get away with using shared versions in /usr/lib, though. |
| 842 | // We could fall back to the approach we used for includes (a massive |
| 843 | // list), but that's messy at best. |
| 844 | } |
| 845 | |
Daniel Dunbar | 11e1b40 | 2009-05-02 18:28:39 +0000 | [diff] [blame] | 846 | /// DragonFly - DragonFly tool chain which can call as(1) and ld(1) directly. |
| 847 | |
Daniel Dunbar | cb8ab23 | 2009-05-22 02:53:45 +0000 | [diff] [blame] | 848 | DragonFly::DragonFly(const HostInfo &Host, const llvm::Triple& Triple) |
| 849 | : Generic_GCC(Host, Triple) { |
Daniel Dunbar | 11e1b40 | 2009-05-02 18:28:39 +0000 | [diff] [blame] | 850 | |
| 851 | // Path mangling to find libexec |
Daniel Dunbar | ee788e7 | 2009-12-21 18:54:17 +0000 | [diff] [blame] | 852 | getProgramPaths().push_back(getDriver().Dir); |
Daniel Dunbar | 11e1b40 | 2009-05-02 18:28:39 +0000 | [diff] [blame] | 853 | |
Daniel Dunbar | ee788e7 | 2009-12-21 18:54:17 +0000 | [diff] [blame] | 854 | getFilePaths().push_back(getDriver().Dir + "/../lib"); |
Daniel Dunbar | 11e1b40 | 2009-05-02 18:28:39 +0000 | [diff] [blame] | 855 | getFilePaths().push_back("/usr/lib"); |
| 856 | getFilePaths().push_back("/usr/lib/gcc41"); |
| 857 | } |
| 858 | |
| 859 | Tool &DragonFly::SelectTool(const Compilation &C, const JobAction &JA) const { |
| 860 | Action::ActionClass Key; |
Daniel Dunbar | ee788e7 | 2009-12-21 18:54:17 +0000 | [diff] [blame] | 861 | if (getDriver().ShouldUseClangCompiler(C, JA, getTriple())) |
Daniel Dunbar | 11e1b40 | 2009-05-02 18:28:39 +0000 | [diff] [blame] | 862 | Key = Action::AnalyzeJobClass; |
| 863 | else |
| 864 | Key = JA.getKind(); |
| 865 | |
| 866 | Tool *&T = Tools[Key]; |
| 867 | if (!T) { |
| 868 | switch (Key) { |
| 869 | case Action::AssembleJobClass: |
| 870 | T = new tools::dragonfly::Assemble(*this); break; |
| 871 | case Action::LinkJobClass: |
| 872 | T = new tools::dragonfly::Link(*this); break; |
| 873 | default: |
| 874 | T = &Generic_GCC::SelectTool(C, JA); |
| 875 | } |
| 876 | } |
| 877 | |
| 878 | return *T; |
| 879 | } |