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