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 | 0f602de | 2010-05-20 21:48:38 +0000 | [diff] [blame] | 14 | #include "clang/Driver/Compilation.h" |
Daniel Dunbar | c50b00d | 2009-03-23 16:15:50 +0000 | [diff] [blame] | 15 | #include "clang/Driver/Driver.h" |
Daniel Dunbar | 4e7e9cf | 2009-03-25 06:12:34 +0000 | [diff] [blame] | 16 | #include "clang/Driver/DriverDiagnostic.h" |
Daniel Dunbar | c50b00d | 2009-03-23 16:15:50 +0000 | [diff] [blame] | 17 | #include "clang/Driver/HostInfo.h" |
Daniel Dunbar | 27e738d | 2009-11-19 00:15:11 +0000 | [diff] [blame] | 18 | #include "clang/Driver/OptTable.h" |
Daniel Dunbar | 4e7e9cf | 2009-03-25 06:12:34 +0000 | [diff] [blame] | 19 | #include "clang/Driver/Option.h" |
Daniel Dunbar | 265e9ef | 2009-11-19 04:25:22 +0000 | [diff] [blame] | 20 | #include "clang/Driver/Options.h" |
Daniel Dunbar | c50b00d | 2009-03-23 16:15:50 +0000 | [diff] [blame] | 21 | |
Daniel Dunbar | 00577ad | 2010-08-23 22:35:37 +0000 | [diff] [blame] | 22 | #include "llvm/ADT/SmallString.h" |
Daniel Dunbar | c50b00d | 2009-03-23 16:15:50 +0000 | [diff] [blame] | 23 | #include "llvm/ADT/StringExtras.h" |
Daniel Dunbar | 84ec96c | 2009-09-09 22:33:15 +0000 | [diff] [blame] | 24 | #include "llvm/Support/ErrorHandling.h" |
Daniel Dunbar | ec069ed | 2009-03-25 06:58:31 +0000 | [diff] [blame] | 25 | #include "llvm/Support/raw_ostream.h" |
Daniel Dunbar | c50b00d | 2009-03-23 16:15:50 +0000 | [diff] [blame] | 26 | #include "llvm/System/Path.h" |
| 27 | |
Daniel Dunbar | f36a06a | 2009-04-10 21:00:07 +0000 | [diff] [blame] | 28 | #include <cstdlib> // ::getenv |
| 29 | |
Daniel Dunbar | 3917608 | 2009-03-20 00:20:03 +0000 | [diff] [blame] | 30 | using namespace clang::driver; |
| 31 | using namespace clang::driver::toolchains; |
| 32 | |
Daniel Dunbar | f395528 | 2009-09-04 18:34:51 +0000 | [diff] [blame] | 33 | /// Darwin - Darwin tool chain for i386 and x86_64. |
Daniel Dunbar | 8eddb3f | 2009-03-20 00:57:52 +0000 | [diff] [blame] | 34 | |
Daniel Dunbar | 25b58eb | 2010-08-02 05:44:07 +0000 | [diff] [blame] | 35 | Darwin::Darwin(const HostInfo &Host, const llvm::Triple& Triple) |
Daniel Dunbar | cc8e189 | 2010-01-27 00:56:44 +0000 | [diff] [blame] | 36 | : ToolChain(Host, Triple), TargetInitialized(false) |
Daniel Dunbar | 1d4612b | 2009-09-18 08:15:13 +0000 | [diff] [blame] | 37 | { |
Daniel Dunbar | 25b58eb | 2010-08-02 05:44:07 +0000 | [diff] [blame] | 38 | // Compute the initial Darwin version based on the host. |
| 39 | bool HadExtra; |
| 40 | std::string OSName = Triple.getOSName(); |
| 41 | if (!Driver::GetReleaseVersion(&OSName[6], |
| 42 | DarwinVersion[0], DarwinVersion[1], |
| 43 | DarwinVersion[2], HadExtra)) |
| 44 | getDriver().Diag(clang::diag::err_drv_invalid_darwin_version) << OSName; |
| 45 | |
Daniel Dunbar | 02633b5 | 2009-03-26 16:23:12 +0000 | [diff] [blame] | 46 | llvm::raw_string_ostream(MacosxVersionMin) |
Daniel Dunbar | 25b58eb | 2010-08-02 05:44:07 +0000 | [diff] [blame] | 47 | << "10." << std::max(0, (int)DarwinVersion[0] - 4) << '.' |
| 48 | << DarwinVersion[1]; |
Daniel Dunbar | 1d4612b | 2009-09-18 08:15:13 +0000 | [diff] [blame] | 49 | } |
| 50 | |
Daniel Dunbar | 4180011 | 2010-08-02 05:43:56 +0000 | [diff] [blame] | 51 | types::ID Darwin::LookupTypeForExtension(const char *Ext) const { |
| 52 | types::ID Ty = types::lookupTypeForExtension(Ext); |
| 53 | |
| 54 | // Darwin always preprocesses assembly files (unless -x is used explicitly). |
| 55 | if (Ty == types::TY_PP_Asm) |
| 56 | return types::TY_Asm; |
| 57 | |
| 58 | return Ty; |
| 59 | } |
| 60 | |
Daniel Dunbar | eeff406 | 2010-01-22 02:04:58 +0000 | [diff] [blame] | 61 | // FIXME: Can we tablegen this? |
| 62 | static const char *GetArmArchForMArch(llvm::StringRef Value) { |
| 63 | if (Value == "armv6k") |
| 64 | return "armv6"; |
| 65 | |
| 66 | if (Value == "armv5tej") |
| 67 | return "armv5"; |
| 68 | |
| 69 | if (Value == "xscale") |
| 70 | return "xscale"; |
| 71 | |
| 72 | if (Value == "armv4t") |
| 73 | return "armv4t"; |
| 74 | |
| 75 | if (Value == "armv7" || Value == "armv7-a" || Value == "armv7-r" || |
| 76 | Value == "armv7-m" || Value == "armv7a" || Value == "armv7r" || |
| 77 | Value == "armv7m") |
| 78 | return "armv7"; |
| 79 | |
| 80 | return 0; |
| 81 | } |
| 82 | |
| 83 | // FIXME: Can we tablegen this? |
| 84 | static const char *GetArmArchForMCpu(llvm::StringRef Value) { |
| 85 | if (Value == "arm10tdmi" || Value == "arm1020t" || Value == "arm9e" || |
| 86 | Value == "arm946e-s" || Value == "arm966e-s" || |
| 87 | Value == "arm968e-s" || Value == "arm10e" || |
| 88 | Value == "arm1020e" || Value == "arm1022e" || Value == "arm926ej-s" || |
| 89 | Value == "arm1026ej-s") |
| 90 | return "armv5"; |
| 91 | |
| 92 | if (Value == "xscale") |
| 93 | return "xscale"; |
| 94 | |
| 95 | if (Value == "arm1136j-s" || Value == "arm1136jf-s" || |
| 96 | Value == "arm1176jz-s" || Value == "arm1176jzf-s") |
| 97 | return "armv6"; |
| 98 | |
| 99 | if (Value == "cortex-a8" || Value == "cortex-r4" || Value == "cortex-m3") |
| 100 | return "armv7"; |
| 101 | |
| 102 | return 0; |
| 103 | } |
| 104 | |
| 105 | llvm::StringRef Darwin::getDarwinArchName(const ArgList &Args) const { |
| 106 | switch (getTriple().getArch()) { |
| 107 | default: |
| 108 | return getArchName(); |
| 109 | |
| 110 | case llvm::Triple::arm: { |
| 111 | if (const Arg *A = Args.getLastArg(options::OPT_march_EQ)) |
| 112 | if (const char *Arch = GetArmArchForMArch(A->getValue(Args))) |
| 113 | return Arch; |
| 114 | |
| 115 | if (const Arg *A = Args.getLastArg(options::OPT_mcpu_EQ)) |
| 116 | if (const char *Arch = GetArmArchForMCpu(A->getValue(Args))) |
| 117 | return Arch; |
| 118 | |
| 119 | return "arm"; |
| 120 | } |
| 121 | } |
| 122 | } |
| 123 | |
Daniel Dunbar | 25b58eb | 2010-08-02 05:44:07 +0000 | [diff] [blame] | 124 | DarwinGCC::DarwinGCC(const HostInfo &Host, const llvm::Triple& Triple) |
| 125 | : Darwin(Host, Triple) |
Daniel Dunbar | 1d4612b | 2009-09-18 08:15:13 +0000 | [diff] [blame] | 126 | { |
Daniel Dunbar | c2bda62 | 2010-08-02 05:44:01 +0000 | [diff] [blame] | 127 | // We can only work with 4.2.1 currently. |
| 128 | GCCVersion[0] = 4; |
| 129 | GCCVersion[1] = 2; |
| 130 | GCCVersion[2] = 1; |
Daniel Dunbar | 1d4612b | 2009-09-18 08:15:13 +0000 | [diff] [blame] | 131 | |
| 132 | // Set up the tool chain paths to match gcc. |
Daniel Dunbar | c50b00d | 2009-03-23 16:15:50 +0000 | [diff] [blame] | 133 | ToolChainDir = "i686-apple-darwin"; |
Ted Kremenek | 55bac53 | 2009-10-07 03:21:11 +0000 | [diff] [blame] | 134 | ToolChainDir += llvm::utostr(DarwinVersion[0]); |
Daniel Dunbar | c50b00d | 2009-03-23 16:15:50 +0000 | [diff] [blame] | 135 | ToolChainDir += "/"; |
| 136 | ToolChainDir += llvm::utostr(GCCVersion[0]); |
| 137 | ToolChainDir += '.'; |
| 138 | ToolChainDir += llvm::utostr(GCCVersion[1]); |
| 139 | ToolChainDir += '.'; |
| 140 | ToolChainDir += llvm::utostr(GCCVersion[2]); |
| 141 | |
Daniel Dunbar | 74782b0 | 2009-10-20 19:25:43 +0000 | [diff] [blame] | 142 | // Try the next major version if that tool chain dir is invalid. |
Daniel Dunbar | 080fb19 | 2009-10-22 00:12:00 +0000 | [diff] [blame] | 143 | std::string Tmp = "/usr/lib/gcc/" + ToolChainDir; |
| 144 | if (!llvm::sys::Path(Tmp).exists()) { |
Daniel Dunbar | 74782b0 | 2009-10-20 19:25:43 +0000 | [diff] [blame] | 145 | std::string Next = "i686-apple-darwin"; |
| 146 | Next += llvm::utostr(DarwinVersion[0] + 1); |
| 147 | Next += "/"; |
| 148 | Next += llvm::utostr(GCCVersion[0]); |
| 149 | Next += '.'; |
| 150 | Next += llvm::utostr(GCCVersion[1]); |
| 151 | Next += '.'; |
| 152 | Next += llvm::utostr(GCCVersion[2]); |
| 153 | |
| 154 | // Use that if it exists, otherwise hope the user isn't linking. |
| 155 | // |
| 156 | // FIXME: Drop dependency on gcc's tool chain. |
Daniel Dunbar | 080fb19 | 2009-10-22 00:12:00 +0000 | [diff] [blame] | 157 | Tmp = "/usr/lib/gcc/" + Next; |
| 158 | if (llvm::sys::Path(Tmp).exists()) |
Daniel Dunbar | 74782b0 | 2009-10-20 19:25:43 +0000 | [diff] [blame] | 159 | ToolChainDir = Next; |
| 160 | } |
| 161 | |
Daniel Dunbar | c50b00d | 2009-03-23 16:15:50 +0000 | [diff] [blame] | 162 | std::string Path; |
| 163 | if (getArchName() == "x86_64") { |
Daniel Dunbar | ee788e7 | 2009-12-21 18:54:17 +0000 | [diff] [blame] | 164 | Path = getDriver().Dir; |
Daniel Dunbar | c50b00d | 2009-03-23 16:15:50 +0000 | [diff] [blame] | 165 | Path += "/../lib/gcc/"; |
Daniel Dunbar | 6b200b2 | 2009-09-18 08:14:36 +0000 | [diff] [blame] | 166 | Path += ToolChainDir; |
Daniel Dunbar | c50b00d | 2009-03-23 16:15:50 +0000 | [diff] [blame] | 167 | Path += "/x86_64"; |
| 168 | getFilePaths().push_back(Path); |
| 169 | |
| 170 | Path = "/usr/lib/gcc/"; |
Daniel Dunbar | 6b200b2 | 2009-09-18 08:14:36 +0000 | [diff] [blame] | 171 | Path += ToolChainDir; |
Daniel Dunbar | c50b00d | 2009-03-23 16:15:50 +0000 | [diff] [blame] | 172 | Path += "/x86_64"; |
| 173 | getFilePaths().push_back(Path); |
| 174 | } |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 175 | |
Daniel Dunbar | ee788e7 | 2009-12-21 18:54:17 +0000 | [diff] [blame] | 176 | Path = getDriver().Dir; |
Daniel Dunbar | c50b00d | 2009-03-23 16:15:50 +0000 | [diff] [blame] | 177 | Path += "/../lib/gcc/"; |
Daniel Dunbar | 6b200b2 | 2009-09-18 08:14:36 +0000 | [diff] [blame] | 178 | Path += ToolChainDir; |
Daniel Dunbar | c50b00d | 2009-03-23 16:15:50 +0000 | [diff] [blame] | 179 | getFilePaths().push_back(Path); |
| 180 | |
| 181 | Path = "/usr/lib/gcc/"; |
Daniel Dunbar | 6b200b2 | 2009-09-18 08:14:36 +0000 | [diff] [blame] | 182 | Path += ToolChainDir; |
Daniel Dunbar | c50b00d | 2009-03-23 16:15:50 +0000 | [diff] [blame] | 183 | getFilePaths().push_back(Path); |
| 184 | |
Daniel Dunbar | ee788e7 | 2009-12-21 18:54:17 +0000 | [diff] [blame] | 185 | Path = getDriver().Dir; |
Daniel Dunbar | c50b00d | 2009-03-23 16:15:50 +0000 | [diff] [blame] | 186 | Path += "/../libexec/gcc/"; |
Daniel Dunbar | 6b200b2 | 2009-09-18 08:14:36 +0000 | [diff] [blame] | 187 | Path += ToolChainDir; |
Daniel Dunbar | c50b00d | 2009-03-23 16:15:50 +0000 | [diff] [blame] | 188 | getProgramPaths().push_back(Path); |
| 189 | |
| 190 | Path = "/usr/libexec/gcc/"; |
Daniel Dunbar | 6b200b2 | 2009-09-18 08:14:36 +0000 | [diff] [blame] | 191 | Path += ToolChainDir; |
Daniel Dunbar | c50b00d | 2009-03-23 16:15:50 +0000 | [diff] [blame] | 192 | getProgramPaths().push_back(Path); |
| 193 | |
Daniel Dunbar | edf29b0 | 2010-08-01 22:29:51 +0000 | [diff] [blame] | 194 | getProgramPaths().push_back(getDriver().getInstalledDir()); |
| 195 | if (getDriver().getInstalledDir() != getDriver().Dir) |
| 196 | getProgramPaths().push_back(getDriver().Dir); |
Daniel Dunbar | c50b00d | 2009-03-23 16:15:50 +0000 | [diff] [blame] | 197 | } |
| 198 | |
Daniel Dunbar | f395528 | 2009-09-04 18:34:51 +0000 | [diff] [blame] | 199 | Darwin::~Darwin() { |
Daniel Dunbar | 8eddb3f | 2009-03-20 00:57:52 +0000 | [diff] [blame] | 200 | // Free tool implementations. |
| 201 | for (llvm::DenseMap<unsigned, Tool*>::iterator |
| 202 | it = Tools.begin(), ie = Tools.end(); it != ie; ++it) |
| 203 | delete it->second; |
| 204 | } |
| 205 | |
Daniel Dunbar | 00577ad | 2010-08-23 22:35:37 +0000 | [diff] [blame] | 206 | std::string Darwin::ComputeEffectiveClangTriple(const ArgList &Args) const { |
| 207 | llvm::Triple Triple(ComputeLLVMTriple(Args)); |
| 208 | |
| 209 | // If the target isn't initialized (e.g., an unknown Darwin platform, return |
| 210 | // the default triple). |
| 211 | if (!isTargetInitialized()) |
| 212 | return Triple.getTriple(); |
| 213 | |
| 214 | unsigned Version[3]; |
| 215 | getTargetVersion(Version); |
| 216 | |
| 217 | // Mangle the target version into the OS triple component. For historical |
| 218 | // reasons that make little sense, the version passed here is the "darwin" |
| 219 | // version, which drops the 10 and offsets by 4. See inverse code when |
| 220 | // setting the OS version preprocessor define. |
| 221 | if (!isTargetIPhoneOS()) { |
| 222 | Version[0] = Version[1] + 4; |
| 223 | Version[1] = Version[2]; |
| 224 | Version[2] = 0; |
| 225 | } else { |
| 226 | // Use the environment to communicate that we are targetting iPhoneOS. |
| 227 | Triple.setEnvironmentName("iphoneos"); |
| 228 | } |
| 229 | |
| 230 | llvm::SmallString<16> Str; |
| 231 | llvm::raw_svector_ostream(Str) << "darwin" << Version[0] |
| 232 | << "." << Version[1] << "." << Version[2]; |
| 233 | Triple.setOSName(Str.str()); |
| 234 | |
| 235 | return Triple.getTriple(); |
| 236 | } |
| 237 | |
Daniel Dunbar | f395528 | 2009-09-04 18:34:51 +0000 | [diff] [blame] | 238 | Tool &Darwin::SelectTool(const Compilation &C, const JobAction &JA) const { |
Daniel Dunbar | 8eddb3f | 2009-03-20 00:57:52 +0000 | [diff] [blame] | 239 | Action::ActionClass Key; |
Daniel Dunbar | ee788e7 | 2009-12-21 18:54:17 +0000 | [diff] [blame] | 240 | if (getDriver().ShouldUseClangCompiler(C, JA, getTriple())) |
Daniel Dunbar | 8eddb3f | 2009-03-20 00:57:52 +0000 | [diff] [blame] | 241 | Key = Action::AnalyzeJobClass; |
| 242 | else |
| 243 | Key = JA.getKind(); |
| 244 | |
Daniel Dunbar | 0f602de | 2010-05-20 21:48:38 +0000 | [diff] [blame] | 245 | // FIXME: This doesn't belong here, but ideally we will support static soon |
| 246 | // anyway. |
| 247 | bool HasStatic = (C.getArgs().hasArg(options::OPT_mkernel) || |
| 248 | C.getArgs().hasArg(options::OPT_static) || |
| 249 | C.getArgs().hasArg(options::OPT_fapple_kext)); |
| 250 | bool IsIADefault = IsIntegratedAssemblerDefault() && !HasStatic; |
| 251 | bool UseIntegratedAs = C.getArgs().hasFlag(options::OPT_integrated_as, |
| 252 | options::OPT_no_integrated_as, |
| 253 | IsIADefault); |
| 254 | |
Daniel Dunbar | 8eddb3f | 2009-03-20 00:57:52 +0000 | [diff] [blame] | 255 | Tool *&T = Tools[Key]; |
| 256 | if (!T) { |
| 257 | switch (Key) { |
| 258 | case Action::InputClass: |
| 259 | case Action::BindArchClass: |
| 260 | assert(0 && "Invalid tool kind."); |
| 261 | case Action::PreprocessJobClass: |
Daniel Dunbar | 9120f17 | 2009-03-29 22:27:40 +0000 | [diff] [blame] | 262 | T = new tools::darwin::Preprocess(*this); break; |
Daniel Dunbar | 8eddb3f | 2009-03-20 00:57:52 +0000 | [diff] [blame] | 263 | case Action::AnalyzeJobClass: |
| 264 | T = new tools::Clang(*this); break; |
Daniel Dunbar | 9120f17 | 2009-03-29 22:27:40 +0000 | [diff] [blame] | 265 | case Action::PrecompileJobClass: |
Daniel Dunbar | 8eddb3f | 2009-03-20 00:57:52 +0000 | [diff] [blame] | 266 | case Action::CompileJobClass: |
Daniel Dunbar | 9120f17 | 2009-03-29 22:27:40 +0000 | [diff] [blame] | 267 | T = new tools::darwin::Compile(*this); break; |
Daniel Dunbar | 0f602de | 2010-05-20 21:48:38 +0000 | [diff] [blame] | 268 | case Action::AssembleJobClass: { |
| 269 | if (UseIntegratedAs) |
| 270 | T = new tools::ClangAs(*this); |
| 271 | else |
| 272 | T = new tools::darwin::Assemble(*this); |
| 273 | break; |
| 274 | } |
Daniel Dunbar | 8eddb3f | 2009-03-20 00:57:52 +0000 | [diff] [blame] | 275 | case Action::LinkJobClass: |
Daniel Dunbar | 8f28962 | 2009-09-04 17:39:02 +0000 | [diff] [blame] | 276 | T = new tools::darwin::Link(*this); break; |
Daniel Dunbar | 8eddb3f | 2009-03-20 00:57:52 +0000 | [diff] [blame] | 277 | case Action::LipoJobClass: |
| 278 | T = new tools::darwin::Lipo(*this); break; |
Daniel Dunbar | 6e0f254 | 2010-06-04 18:28:36 +0000 | [diff] [blame] | 279 | case Action::DsymutilJobClass: |
| 280 | T = new tools::darwin::Dsymutil(*this); break; |
Daniel Dunbar | 8eddb3f | 2009-03-20 00:57:52 +0000 | [diff] [blame] | 281 | } |
| 282 | } |
| 283 | |
| 284 | return *T; |
| 285 | } |
| 286 | |
Daniel Dunbar | 1d4612b | 2009-09-18 08:15:13 +0000 | [diff] [blame] | 287 | void DarwinGCC::AddLinkSearchPathArgs(const ArgList &Args, |
| 288 | ArgStringList &CmdArgs) const { |
Daniel Dunbar | e3c153a | 2010-04-10 18:18:57 +0000 | [diff] [blame] | 289 | std::string Tmp; |
| 290 | |
Daniel Dunbar | 6b200b2 | 2009-09-18 08:14:36 +0000 | [diff] [blame] | 291 | // FIXME: Derive these correctly. |
| 292 | if (getArchName() == "x86_64") { |
| 293 | CmdArgs.push_back(Args.MakeArgString("-L/usr/lib/gcc/" + ToolChainDir + |
| 294 | "/x86_64")); |
| 295 | // Intentionally duplicated for (temporary) gcc bug compatibility. |
| 296 | CmdArgs.push_back(Args.MakeArgString("-L/usr/lib/gcc/" + ToolChainDir + |
| 297 | "/x86_64")); |
| 298 | } |
Daniel Dunbar | eab3bc4 | 2010-08-23 20:58:52 +0000 | [diff] [blame] | 299 | |
Daniel Dunbar | 6b200b2 | 2009-09-18 08:14:36 +0000 | [diff] [blame] | 300 | CmdArgs.push_back(Args.MakeArgString("-L/usr/lib/" + ToolChainDir)); |
Daniel Dunbar | e3c153a | 2010-04-10 18:18:57 +0000 | [diff] [blame] | 301 | |
| 302 | Tmp = getDriver().Dir + "/../lib/gcc/" + ToolChainDir; |
| 303 | if (llvm::sys::Path(Tmp).exists()) |
| 304 | CmdArgs.push_back(Args.MakeArgString("-L" + Tmp)); |
| 305 | Tmp = getDriver().Dir + "/../lib/gcc"; |
| 306 | if (llvm::sys::Path(Tmp).exists()) |
| 307 | CmdArgs.push_back(Args.MakeArgString("-L" + Tmp)); |
Daniel Dunbar | 6b200b2 | 2009-09-18 08:14:36 +0000 | [diff] [blame] | 308 | CmdArgs.push_back(Args.MakeArgString("-L/usr/lib/gcc/" + ToolChainDir)); |
| 309 | // Intentionally duplicated for (temporary) gcc bug compatibility. |
| 310 | CmdArgs.push_back(Args.MakeArgString("-L/usr/lib/gcc/" + ToolChainDir)); |
Daniel Dunbar | e3c153a | 2010-04-10 18:18:57 +0000 | [diff] [blame] | 311 | Tmp = getDriver().Dir + "/../lib/" + ToolChainDir; |
| 312 | if (llvm::sys::Path(Tmp).exists()) |
| 313 | CmdArgs.push_back(Args.MakeArgString("-L" + Tmp)); |
| 314 | Tmp = getDriver().Dir + "/../lib"; |
| 315 | if (llvm::sys::Path(Tmp).exists()) |
| 316 | CmdArgs.push_back(Args.MakeArgString("-L" + Tmp)); |
Daniel Dunbar | 6b200b2 | 2009-09-18 08:14:36 +0000 | [diff] [blame] | 317 | CmdArgs.push_back(Args.MakeArgString("-L/usr/lib/gcc/" + ToolChainDir + |
| 318 | "/../../../" + ToolChainDir)); |
| 319 | CmdArgs.push_back(Args.MakeArgString("-L/usr/lib/gcc/" + ToolChainDir + |
| 320 | "/../../..")); |
| 321 | } |
| 322 | |
Daniel Dunbar | 1d4612b | 2009-09-18 08:15:13 +0000 | [diff] [blame] | 323 | void DarwinGCC::AddLinkRuntimeLibArgs(const ArgList &Args, |
| 324 | ArgStringList &CmdArgs) const { |
Daniel Dunbar | ce3fdf2 | 2010-01-27 00:57:03 +0000 | [diff] [blame] | 325 | // Note that this routine is only used for targetting OS X. |
Daniel Dunbar | 6cd4154 | 2009-09-18 08:15:03 +0000 | [diff] [blame] | 326 | |
| 327 | // Derived from libgcc and lib specs but refactored. |
| 328 | if (Args.hasArg(options::OPT_static)) { |
| 329 | CmdArgs.push_back("-lgcc_static"); |
| 330 | } else { |
| 331 | if (Args.hasArg(options::OPT_static_libgcc)) { |
| 332 | CmdArgs.push_back("-lgcc_eh"); |
| 333 | } else if (Args.hasArg(options::OPT_miphoneos_version_min_EQ)) { |
| 334 | // Derived from darwin_iphoneos_libgcc spec. |
Daniel Dunbar | 251ca6c | 2010-01-27 00:56:37 +0000 | [diff] [blame] | 335 | if (isTargetIPhoneOS()) { |
Daniel Dunbar | 6cd4154 | 2009-09-18 08:15:03 +0000 | [diff] [blame] | 336 | CmdArgs.push_back("-lgcc_s.1"); |
| 337 | } else { |
| 338 | CmdArgs.push_back("-lgcc_s.10.5"); |
| 339 | } |
| 340 | } else if (Args.hasArg(options::OPT_shared_libgcc) || |
Daniel Dunbar | 8a0d94d | 2010-01-10 00:46:10 +0000 | [diff] [blame] | 341 | Args.hasFlag(options::OPT_fexceptions, |
| 342 | options::OPT_fno_exceptions) || |
Daniel Dunbar | 6cd4154 | 2009-09-18 08:15:03 +0000 | [diff] [blame] | 343 | Args.hasArg(options::OPT_fgnu_runtime)) { |
| 344 | // FIXME: This is probably broken on 10.3? |
Daniel Dunbar | ce3fdf2 | 2010-01-27 00:57:03 +0000 | [diff] [blame] | 345 | if (isMacosxVersionLT(10, 5)) |
Daniel Dunbar | 6cd4154 | 2009-09-18 08:15:03 +0000 | [diff] [blame] | 346 | CmdArgs.push_back("-lgcc_s.10.4"); |
Daniel Dunbar | ce3fdf2 | 2010-01-27 00:57:03 +0000 | [diff] [blame] | 347 | else if (isMacosxVersionLT(10, 6)) |
Daniel Dunbar | 6cd4154 | 2009-09-18 08:15:03 +0000 | [diff] [blame] | 348 | CmdArgs.push_back("-lgcc_s.10.5"); |
| 349 | } else { |
Daniel Dunbar | ce3fdf2 | 2010-01-27 00:57:03 +0000 | [diff] [blame] | 350 | if (isMacosxVersionLT(10, 3, 9)) |
Daniel Dunbar | 6cd4154 | 2009-09-18 08:15:03 +0000 | [diff] [blame] | 351 | ; // Do nothing. |
Daniel Dunbar | ce3fdf2 | 2010-01-27 00:57:03 +0000 | [diff] [blame] | 352 | else if (isMacosxVersionLT(10, 5)) |
Daniel Dunbar | 6cd4154 | 2009-09-18 08:15:03 +0000 | [diff] [blame] | 353 | CmdArgs.push_back("-lgcc_s.10.4"); |
Daniel Dunbar | ce3fdf2 | 2010-01-27 00:57:03 +0000 | [diff] [blame] | 354 | else if (isMacosxVersionLT(10, 6)) |
Daniel Dunbar | 6cd4154 | 2009-09-18 08:15:03 +0000 | [diff] [blame] | 355 | CmdArgs.push_back("-lgcc_s.10.5"); |
| 356 | } |
| 357 | |
Daniel Dunbar | ce3fdf2 | 2010-01-27 00:57:03 +0000 | [diff] [blame] | 358 | if (isTargetIPhoneOS() || isMacosxVersionLT(10, 6)) { |
Daniel Dunbar | 6cd4154 | 2009-09-18 08:15:03 +0000 | [diff] [blame] | 359 | CmdArgs.push_back("-lgcc"); |
| 360 | CmdArgs.push_back("-lSystem"); |
| 361 | } else { |
| 362 | CmdArgs.push_back("-lSystem"); |
| 363 | CmdArgs.push_back("-lgcc"); |
| 364 | } |
| 365 | } |
| 366 | } |
| 367 | |
Daniel Dunbar | 25b58eb | 2010-08-02 05:44:07 +0000 | [diff] [blame] | 368 | DarwinClang::DarwinClang(const HostInfo &Host, const llvm::Triple& Triple) |
| 369 | : Darwin(Host, Triple) |
Daniel Dunbar | 1d4612b | 2009-09-18 08:15:13 +0000 | [diff] [blame] | 370 | { |
| 371 | // We expect 'as', 'ld', etc. to be adjacent to our install dir. |
Daniel Dunbar | edf29b0 | 2010-08-01 22:29:51 +0000 | [diff] [blame] | 372 | getProgramPaths().push_back(getDriver().getInstalledDir()); |
| 373 | if (getDriver().getInstalledDir() != getDriver().Dir) |
| 374 | getProgramPaths().push_back(getDriver().Dir); |
Daniel Dunbar | 1d4612b | 2009-09-18 08:15:13 +0000 | [diff] [blame] | 375 | } |
| 376 | |
| 377 | void DarwinClang::AddLinkSearchPathArgs(const ArgList &Args, |
| 378 | ArgStringList &CmdArgs) const { |
| 379 | // The Clang toolchain uses explicit paths for internal libraries. |
Daniel Dunbar | 424b661 | 2010-06-30 23:56:13 +0000 | [diff] [blame] | 380 | |
| 381 | // Unfortunately, we still might depend on a few of the libraries that are |
| 382 | // only available in the gcc library directory (in particular |
| 383 | // libstdc++.dylib). For now, hardcode the path to the known install location. |
| 384 | llvm::sys::Path P(getDriver().Dir); |
| 385 | P.eraseComponent(); // .../usr/bin -> ../usr |
| 386 | P.appendComponent("lib"); |
| 387 | P.appendComponent("gcc"); |
| 388 | switch (getTriple().getArch()) { |
| 389 | default: |
| 390 | assert(0 && "Invalid Darwin arch!"); |
| 391 | case llvm::Triple::x86: |
| 392 | case llvm::Triple::x86_64: |
| 393 | P.appendComponent("i686-apple-darwin10"); |
| 394 | break; |
| 395 | case llvm::Triple::arm: |
| 396 | case llvm::Triple::thumb: |
| 397 | P.appendComponent("arm-apple-darwin10"); |
| 398 | break; |
| 399 | case llvm::Triple::ppc: |
| 400 | case llvm::Triple::ppc64: |
| 401 | P.appendComponent("powerpc-apple-darwin10"); |
| 402 | break; |
| 403 | } |
| 404 | P.appendComponent("4.2.1"); |
Daniel Dunbar | eab3bc4 | 2010-08-23 20:58:52 +0000 | [diff] [blame] | 405 | |
| 406 | // Determine the arch specific GCC subdirectory. |
| 407 | const char *ArchSpecificDir = 0; |
| 408 | switch (getTriple().getArch()) { |
| 409 | default: |
| 410 | break; |
| 411 | case llvm::Triple::arm: |
Daniel Dunbar | 3a0e392 | 2010-08-26 00:55:52 +0000 | [diff] [blame] | 412 | case llvm::Triple::thumb: { |
| 413 | std::string Triple = ComputeLLVMTriple(Args); |
| 414 | llvm::StringRef TripleStr = Triple; |
| 415 | if (TripleStr.startswith("armv5") || TripleStr.startswith("thumbv5")) |
| 416 | ArchSpecificDir = "v5"; |
| 417 | else if (TripleStr.startswith("armv6") || TripleStr.startswith("thumbv6")) |
| 418 | ArchSpecificDir = "v6"; |
| 419 | else if (TripleStr.startswith("armv7") || TripleStr.startswith("thumbv7")) |
| 420 | ArchSpecificDir = "v7"; |
Daniel Dunbar | eab3bc4 | 2010-08-23 20:58:52 +0000 | [diff] [blame] | 421 | break; |
Daniel Dunbar | 3a0e392 | 2010-08-26 00:55:52 +0000 | [diff] [blame] | 422 | } |
Daniel Dunbar | eab3bc4 | 2010-08-23 20:58:52 +0000 | [diff] [blame] | 423 | case llvm::Triple::ppc64: |
| 424 | ArchSpecificDir = "ppc64"; |
| 425 | break; |
| 426 | case llvm::Triple::x86_64: |
| 427 | ArchSpecificDir = "x86_64"; |
| 428 | break; |
| 429 | } |
| 430 | |
| 431 | if (ArchSpecificDir) { |
| 432 | P.appendComponent(ArchSpecificDir); |
Daniel Dunbar | eab3bc4 | 2010-08-23 20:58:52 +0000 | [diff] [blame] | 433 | if (P.exists()) |
| 434 | CmdArgs.push_back(Args.MakeArgString("-L" + P.str())); |
| 435 | P.eraseComponent(); |
| 436 | } |
| 437 | |
Daniel Dunbar | 424b661 | 2010-06-30 23:56:13 +0000 | [diff] [blame] | 438 | if (P.exists()) |
| 439 | CmdArgs.push_back(Args.MakeArgString("-L" + P.str())); |
Daniel Dunbar | 1d4612b | 2009-09-18 08:15:13 +0000 | [diff] [blame] | 440 | } |
| 441 | |
| 442 | void DarwinClang::AddLinkRuntimeLibArgs(const ArgList &Args, |
| 443 | ArgStringList &CmdArgs) const { |
Daniel Dunbar | eec9910 | 2010-01-22 03:38:14 +0000 | [diff] [blame] | 444 | // Darwin doesn't support real static executables, don't link any runtime |
| 445 | // libraries with -static. |
| 446 | if (Args.hasArg(options::OPT_static)) |
Daniel Dunbar | 1d4612b | 2009-09-18 08:15:13 +0000 | [diff] [blame] | 447 | return; |
Daniel Dunbar | 1d4612b | 2009-09-18 08:15:13 +0000 | [diff] [blame] | 448 | |
| 449 | // Reject -static-libgcc for now, we can deal with this when and if someone |
| 450 | // cares. This is useful in situations where someone wants to statically link |
| 451 | // something like libstdc++, and needs its runtime support routines. |
| 452 | if (const Arg *A = Args.getLastArg(options::OPT_static_libgcc)) { |
Daniel Dunbar | ee788e7 | 2009-12-21 18:54:17 +0000 | [diff] [blame] | 453 | getDriver().Diag(clang::diag::err_drv_unsupported_opt) |
Daniel Dunbar | 1d4612b | 2009-09-18 08:15:13 +0000 | [diff] [blame] | 454 | << A->getAsString(Args); |
| 455 | return; |
| 456 | } |
| 457 | |
Daniel Dunbar | eec9910 | 2010-01-22 03:38:14 +0000 | [diff] [blame] | 458 | // Otherwise link libSystem, then the dynamic runtime library, and finally any |
| 459 | // target specific static runtime library. |
Daniel Dunbar | 1d4612b | 2009-09-18 08:15:13 +0000 | [diff] [blame] | 460 | CmdArgs.push_back("-lSystem"); |
Daniel Dunbar | eec9910 | 2010-01-22 03:38:14 +0000 | [diff] [blame] | 461 | |
| 462 | // Select the dynamic runtime library and the target specific static library. |
| 463 | const char *DarwinStaticLib = 0; |
Daniel Dunbar | 251ca6c | 2010-01-27 00:56:37 +0000 | [diff] [blame] | 464 | if (isTargetIPhoneOS()) { |
Daniel Dunbar | eec9910 | 2010-01-22 03:38:14 +0000 | [diff] [blame] | 465 | CmdArgs.push_back("-lgcc_s.1"); |
| 466 | |
| 467 | // We may need some static functions for armv6/thumb which are required to |
| 468 | // be in the same linkage unit as their caller. |
| 469 | if (getDarwinArchName(Args) == "armv6") |
| 470 | DarwinStaticLib = "libclang_rt.armv6.a"; |
| 471 | } else { |
Daniel Dunbar | eec9910 | 2010-01-22 03:38:14 +0000 | [diff] [blame] | 472 | // The dynamic runtime library was merged with libSystem for 10.6 and |
| 473 | // beyond; only 10.4 and 10.5 need an additional runtime library. |
Daniel Dunbar | ce3fdf2 | 2010-01-27 00:57:03 +0000 | [diff] [blame] | 474 | if (isMacosxVersionLT(10, 5)) |
Daniel Dunbar | eec9910 | 2010-01-22 03:38:14 +0000 | [diff] [blame] | 475 | CmdArgs.push_back("-lgcc_s.10.4"); |
Daniel Dunbar | ce3fdf2 | 2010-01-27 00:57:03 +0000 | [diff] [blame] | 476 | else if (isMacosxVersionLT(10, 6)) |
Daniel Dunbar | eec9910 | 2010-01-22 03:38:14 +0000 | [diff] [blame] | 477 | CmdArgs.push_back("-lgcc_s.10.5"); |
| 478 | |
| 479 | // For OS X, we only need a static runtime library when targetting 10.4, to |
| 480 | // provide versions of the static functions which were omitted from |
| 481 | // 10.4.dylib. |
Daniel Dunbar | ce3fdf2 | 2010-01-27 00:57:03 +0000 | [diff] [blame] | 482 | if (isMacosxVersionLT(10, 5)) |
Daniel Dunbar | eec9910 | 2010-01-22 03:38:14 +0000 | [diff] [blame] | 483 | DarwinStaticLib = "libclang_rt.10.4.a"; |
| 484 | } |
| 485 | |
| 486 | /// Add the target specific static library, if needed. |
| 487 | if (DarwinStaticLib) { |
| 488 | llvm::sys::Path P(getDriver().ResourceDir); |
| 489 | P.appendComponent("lib"); |
| 490 | P.appendComponent("darwin"); |
| 491 | P.appendComponent(DarwinStaticLib); |
| 492 | |
| 493 | // For now, allow missing resource libraries to support developers who may |
| 494 | // not have compiler-rt checked out or integrated into their build. |
| 495 | if (!P.exists()) |
| 496 | getDriver().Diag(clang::diag::warn_drv_missing_resource_library) |
| 497 | << P.str(); |
| 498 | else |
| 499 | CmdArgs.push_back(Args.MakeArgString(P.str())); |
| 500 | } |
Daniel Dunbar | 1d4612b | 2009-09-18 08:15:13 +0000 | [diff] [blame] | 501 | } |
| 502 | |
Daniel Dunbar | 60baf0f | 2010-07-19 17:11:36 +0000 | [diff] [blame] | 503 | void Darwin::AddDeploymentTarget(DerivedArgList &Args) const { |
Daniel Dunbar | ee788e7 | 2009-12-21 18:54:17 +0000 | [diff] [blame] | 504 | const OptTable &Opts = getDriver().getOpts(); |
Daniel Dunbar | ec069ed | 2009-03-25 06:58:31 +0000 | [diff] [blame] | 505 | |
Daniel Dunbar | 2603137 | 2010-01-27 00:56:25 +0000 | [diff] [blame] | 506 | Arg *OSXVersion = Args.getLastArg(options::OPT_mmacosx_version_min_EQ); |
| 507 | Arg *iPhoneVersion = Args.getLastArg(options::OPT_miphoneos_version_min_EQ); |
Daniel Dunbar | ff8857a | 2009-04-10 20:11:50 +0000 | [diff] [blame] | 508 | if (OSXVersion && iPhoneVersion) { |
Daniel Dunbar | ee788e7 | 2009-12-21 18:54:17 +0000 | [diff] [blame] | 509 | getDriver().Diag(clang::diag::err_drv_argument_not_allowed_with) |
Daniel Dunbar | ff8857a | 2009-04-10 20:11:50 +0000 | [diff] [blame] | 510 | << OSXVersion->getAsString(Args) |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 511 | << iPhoneVersion->getAsString(Args); |
Daniel Dunbar | 2603137 | 2010-01-27 00:56:25 +0000 | [diff] [blame] | 512 | iPhoneVersion = 0; |
Daniel Dunbar | ff8857a | 2009-04-10 20:11:50 +0000 | [diff] [blame] | 513 | } else if (!OSXVersion && !iPhoneVersion) { |
Daniel Dunbar | 816bc31 | 2010-01-26 01:45:19 +0000 | [diff] [blame] | 514 | // If neither OS X nor iPhoneOS targets were specified, check for |
| 515 | // environment defines. |
| 516 | const char *OSXTarget = ::getenv("MACOSX_DEPLOYMENT_TARGET"); |
| 517 | const char *iPhoneOSTarget = ::getenv("IPHONEOS_DEPLOYMENT_TARGET"); |
Daniel Dunbar | f36a06a | 2009-04-10 21:00:07 +0000 | [diff] [blame] | 518 | |
Daniel Dunbar | 816bc31 | 2010-01-26 01:45:19 +0000 | [diff] [blame] | 519 | // Ignore empty strings. |
| 520 | if (OSXTarget && OSXTarget[0] == '\0') |
| 521 | OSXTarget = 0; |
| 522 | if (iPhoneOSTarget && iPhoneOSTarget[0] == '\0') |
| 523 | iPhoneOSTarget = 0; |
| 524 | |
Daniel Dunbar | 3905367 | 2010-02-02 17:31:12 +0000 | [diff] [blame] | 525 | // Diagnose conflicting deployment targets, and choose default platform |
| 526 | // based on the tool chain. |
| 527 | // |
| 528 | // FIXME: Don't hardcode default here. |
| 529 | if (OSXTarget && iPhoneOSTarget) { |
| 530 | // FIXME: We should see if we can get away with warning or erroring on |
| 531 | // this. Perhaps put under -pedantic? |
| 532 | if (getTriple().getArch() == llvm::Triple::arm || |
| 533 | getTriple().getArch() == llvm::Triple::thumb) |
Daniel Dunbar | 84d1e6e | 2010-03-20 08:47:42 +0000 | [diff] [blame] | 534 | OSXTarget = 0; |
Daniel Dunbar | 3905367 | 2010-02-02 17:31:12 +0000 | [diff] [blame] | 535 | else |
Daniel Dunbar | 84d1e6e | 2010-03-20 08:47:42 +0000 | [diff] [blame] | 536 | iPhoneOSTarget = 0; |
Daniel Dunbar | 3905367 | 2010-02-02 17:31:12 +0000 | [diff] [blame] | 537 | } |
Daniel Dunbar | 1a3c1d9 | 2010-01-29 17:02:25 +0000 | [diff] [blame] | 538 | |
Daniel Dunbar | 3905367 | 2010-02-02 17:31:12 +0000 | [diff] [blame] | 539 | if (OSXTarget) { |
Daniel Dunbar | 30392de | 2009-09-04 18:35:21 +0000 | [diff] [blame] | 540 | const Option *O = Opts.getOption(options::OPT_mmacosx_version_min_EQ); |
Daniel Dunbar | 60baf0f | 2010-07-19 17:11:36 +0000 | [diff] [blame] | 541 | OSXVersion = Args.MakeJoinedArg(0, O, OSXTarget); |
| 542 | Args.append(OSXVersion); |
Daniel Dunbar | 816bc31 | 2010-01-26 01:45:19 +0000 | [diff] [blame] | 543 | } else if (iPhoneOSTarget) { |
Daniel Dunbar | 30392de | 2009-09-04 18:35:21 +0000 | [diff] [blame] | 544 | const Option *O = Opts.getOption(options::OPT_miphoneos_version_min_EQ); |
Daniel Dunbar | 60baf0f | 2010-07-19 17:11:36 +0000 | [diff] [blame] | 545 | iPhoneVersion = Args.MakeJoinedArg(0, O, iPhoneOSTarget); |
| 546 | Args.append(iPhoneVersion); |
Daniel Dunbar | 816bc31 | 2010-01-26 01:45:19 +0000 | [diff] [blame] | 547 | } else { |
Daniel Dunbar | 2bb38d0 | 2010-07-15 16:18:06 +0000 | [diff] [blame] | 548 | // Otherwise, assume we are targeting OS X. |
| 549 | const Option *O = Opts.getOption(options::OPT_mmacosx_version_min_EQ); |
Daniel Dunbar | 60baf0f | 2010-07-19 17:11:36 +0000 | [diff] [blame] | 550 | OSXVersion = Args.MakeJoinedArg(0, O, MacosxVersionMin); |
| 551 | Args.append(OSXVersion); |
Daniel Dunbar | 30392de | 2009-09-04 18:35:21 +0000 | [diff] [blame] | 552 | } |
Daniel Dunbar | ec069ed | 2009-03-25 06:58:31 +0000 | [diff] [blame] | 553 | } |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 554 | |
Daniel Dunbar | 2603137 | 2010-01-27 00:56:25 +0000 | [diff] [blame] | 555 | // Set the tool chain target information. |
| 556 | unsigned Major, Minor, Micro; |
| 557 | bool HadExtra; |
| 558 | if (OSXVersion) { |
| 559 | assert(!iPhoneVersion && "Unknown target platform!"); |
| 560 | if (!Driver::GetReleaseVersion(OSXVersion->getValue(Args), Major, Minor, |
| 561 | Micro, HadExtra) || HadExtra || |
| 562 | Major != 10 || Minor >= 10 || Micro >= 10) |
| 563 | getDriver().Diag(clang::diag::err_drv_invalid_version_number) |
| 564 | << OSXVersion->getAsString(Args); |
| 565 | } else { |
| 566 | assert(iPhoneVersion && "Unknown target platform!"); |
| 567 | if (!Driver::GetReleaseVersion(iPhoneVersion->getValue(Args), Major, Minor, |
| 568 | Micro, HadExtra) || HadExtra || |
| 569 | Major >= 10 || Minor >= 100 || Micro >= 100) |
| 570 | getDriver().Diag(clang::diag::err_drv_invalid_version_number) |
| 571 | << iPhoneVersion->getAsString(Args); |
| 572 | } |
| 573 | setTarget(iPhoneVersion, Major, Minor, Micro); |
Daniel Dunbar | c0e665e | 2010-07-19 17:11:33 +0000 | [diff] [blame] | 574 | } |
| 575 | |
| 576 | DerivedArgList *Darwin::TranslateArgs(const DerivedArgList &Args, |
| 577 | const char *BoundArch) const { |
| 578 | DerivedArgList *DAL = new DerivedArgList(Args.getBaseArgs()); |
| 579 | const OptTable &Opts = getDriver().getOpts(); |
| 580 | |
| 581 | // FIXME: We really want to get out of the tool chain level argument |
| 582 | // translation business, as it makes the driver functionality much |
| 583 | // more opaque. For now, we follow gcc closely solely for the |
| 584 | // purpose of easily achieving feature parity & testability. Once we |
| 585 | // have something that works, we should reevaluate each translation |
| 586 | // and try to push it down into tool specific logic. |
Daniel Dunbar | 2603137 | 2010-01-27 00:56:25 +0000 | [diff] [blame] | 587 | |
Daniel Dunbar | 279c1db | 2010-06-11 22:00:26 +0000 | [diff] [blame] | 588 | for (ArgList::const_iterator it = Args.begin(), |
| 589 | ie = Args.end(); it != ie; ++it) { |
Daniel Dunbar | 4e7e9cf | 2009-03-25 06:12:34 +0000 | [diff] [blame] | 590 | Arg *A = *it; |
| 591 | |
| 592 | if (A->getOption().matches(options::OPT_Xarch__)) { |
| 593 | // FIXME: Canonicalize name. |
| 594 | if (getArchName() != A->getValue(Args, 0)) |
| 595 | continue; |
| 596 | |
Daniel Dunbar | 0e10031 | 2010-06-14 21:23:08 +0000 | [diff] [blame] | 597 | unsigned Index = Args.getBaseArgs().MakeIndex(A->getValue(Args, 1)); |
| 598 | unsigned Prev = Index; |
Daniel Dunbar | ec069ed | 2009-03-25 06:58:31 +0000 | [diff] [blame] | 599 | Arg *XarchArg = Opts.ParseOneArg(Args, Index); |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 600 | |
Daniel Dunbar | 4e7e9cf | 2009-03-25 06:12:34 +0000 | [diff] [blame] | 601 | // If the argument parsing failed or more than one argument was |
| 602 | // consumed, the -Xarch_ argument's parameter tried to consume |
| 603 | // extra arguments. Emit an error and ignore. |
| 604 | // |
| 605 | // We also want to disallow any options which would alter the |
| 606 | // driver behavior; that isn't going to work in our model. We |
| 607 | // use isDriverOption() as an approximation, although things |
| 608 | // like -O4 are going to slip through. |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 609 | if (!XarchArg || Index > Prev + 1 || |
Daniel Dunbar | 4e7e9cf | 2009-03-25 06:12:34 +0000 | [diff] [blame] | 610 | XarchArg->getOption().isDriverOption()) { |
Daniel Dunbar | ee788e7 | 2009-12-21 18:54:17 +0000 | [diff] [blame] | 611 | getDriver().Diag(clang::diag::err_drv_invalid_Xarch_argument) |
Daniel Dunbar | 4e7e9cf | 2009-03-25 06:12:34 +0000 | [diff] [blame] | 612 | << A->getAsString(Args); |
| 613 | continue; |
| 614 | } |
| 615 | |
Daniel Dunbar | 478edc2 | 2009-03-29 22:29:05 +0000 | [diff] [blame] | 616 | XarchArg->setBaseArg(A); |
Daniel Dunbar | 4e7e9cf | 2009-03-25 06:12:34 +0000 | [diff] [blame] | 617 | A = XarchArg; |
Daniel Dunbar | 0e10031 | 2010-06-14 21:23:08 +0000 | [diff] [blame] | 618 | |
| 619 | DAL->AddSynthesizedArg(A); |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 620 | } |
Daniel Dunbar | 4e7e9cf | 2009-03-25 06:12:34 +0000 | [diff] [blame] | 621 | |
Daniel Dunbar | ec069ed | 2009-03-25 06:58:31 +0000 | [diff] [blame] | 622 | // Sob. These is strictly gcc compatible for the time being. Apple |
| 623 | // gcc translates options twice, which means that self-expanding |
| 624 | // options add duplicates. |
Daniel Dunbar | 9e1f982 | 2009-11-19 04:14:53 +0000 | [diff] [blame] | 625 | switch ((options::ID) A->getOption().getID()) { |
Daniel Dunbar | ec069ed | 2009-03-25 06:58:31 +0000 | [diff] [blame] | 626 | default: |
| 627 | DAL->append(A); |
| 628 | break; |
| 629 | |
| 630 | case options::OPT_mkernel: |
| 631 | case options::OPT_fapple_kext: |
| 632 | DAL->append(A); |
Daniel Dunbar | 9d0863b | 2010-06-14 20:20:41 +0000 | [diff] [blame] | 633 | DAL->AddFlagArg(A, Opts.getOption(options::OPT_static)); |
| 634 | DAL->AddFlagArg(A, Opts.getOption(options::OPT_static)); |
Daniel Dunbar | ec069ed | 2009-03-25 06:58:31 +0000 | [diff] [blame] | 635 | break; |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 636 | |
Daniel Dunbar | ec069ed | 2009-03-25 06:58:31 +0000 | [diff] [blame] | 637 | case options::OPT_dependency_file: |
Daniel Dunbar | 9d0863b | 2010-06-14 20:20:41 +0000 | [diff] [blame] | 638 | DAL->AddSeparateArg(A, Opts.getOption(options::OPT_MF), |
| 639 | A->getValue(Args)); |
Daniel Dunbar | ec069ed | 2009-03-25 06:58:31 +0000 | [diff] [blame] | 640 | break; |
| 641 | |
| 642 | case options::OPT_gfull: |
Daniel Dunbar | 9d0863b | 2010-06-14 20:20:41 +0000 | [diff] [blame] | 643 | DAL->AddFlagArg(A, Opts.getOption(options::OPT_g_Flag)); |
| 644 | DAL->AddFlagArg(A, |
| 645 | Opts.getOption(options::OPT_fno_eliminate_unused_debug_symbols)); |
Daniel Dunbar | ec069ed | 2009-03-25 06:58:31 +0000 | [diff] [blame] | 646 | break; |
| 647 | |
| 648 | case options::OPT_gused: |
Daniel Dunbar | 9d0863b | 2010-06-14 20:20:41 +0000 | [diff] [blame] | 649 | DAL->AddFlagArg(A, Opts.getOption(options::OPT_g_Flag)); |
| 650 | DAL->AddFlagArg(A, |
| 651 | Opts.getOption(options::OPT_feliminate_unused_debug_symbols)); |
Daniel Dunbar | ec069ed | 2009-03-25 06:58:31 +0000 | [diff] [blame] | 652 | break; |
| 653 | |
| 654 | case options::OPT_fterminated_vtables: |
| 655 | case options::OPT_findirect_virtual_calls: |
Daniel Dunbar | 9d0863b | 2010-06-14 20:20:41 +0000 | [diff] [blame] | 656 | DAL->AddFlagArg(A, Opts.getOption(options::OPT_fapple_kext)); |
| 657 | DAL->AddFlagArg(A, Opts.getOption(options::OPT_static)); |
Daniel Dunbar | ec069ed | 2009-03-25 06:58:31 +0000 | [diff] [blame] | 658 | break; |
| 659 | |
| 660 | case options::OPT_shared: |
Daniel Dunbar | 9d0863b | 2010-06-14 20:20:41 +0000 | [diff] [blame] | 661 | DAL->AddFlagArg(A, Opts.getOption(options::OPT_dynamiclib)); |
Daniel Dunbar | ec069ed | 2009-03-25 06:58:31 +0000 | [diff] [blame] | 662 | break; |
| 663 | |
| 664 | case options::OPT_fconstant_cfstrings: |
Daniel Dunbar | 9d0863b | 2010-06-14 20:20:41 +0000 | [diff] [blame] | 665 | DAL->AddFlagArg(A, Opts.getOption(options::OPT_mconstant_cfstrings)); |
Daniel Dunbar | ec069ed | 2009-03-25 06:58:31 +0000 | [diff] [blame] | 666 | break; |
| 667 | |
| 668 | case options::OPT_fno_constant_cfstrings: |
Daniel Dunbar | 9d0863b | 2010-06-14 20:20:41 +0000 | [diff] [blame] | 669 | DAL->AddFlagArg(A, Opts.getOption(options::OPT_mno_constant_cfstrings)); |
Daniel Dunbar | ec069ed | 2009-03-25 06:58:31 +0000 | [diff] [blame] | 670 | break; |
| 671 | |
| 672 | case options::OPT_Wnonportable_cfstrings: |
Daniel Dunbar | 9d0863b | 2010-06-14 20:20:41 +0000 | [diff] [blame] | 673 | DAL->AddFlagArg(A, |
| 674 | Opts.getOption(options::OPT_mwarn_nonportable_cfstrings)); |
Daniel Dunbar | ec069ed | 2009-03-25 06:58:31 +0000 | [diff] [blame] | 675 | break; |
| 676 | |
| 677 | case options::OPT_Wno_nonportable_cfstrings: |
Daniel Dunbar | 9d0863b | 2010-06-14 20:20:41 +0000 | [diff] [blame] | 678 | DAL->AddFlagArg(A, |
| 679 | Opts.getOption(options::OPT_mno_warn_nonportable_cfstrings)); |
Daniel Dunbar | ec069ed | 2009-03-25 06:58:31 +0000 | [diff] [blame] | 680 | break; |
| 681 | |
| 682 | case options::OPT_fpascal_strings: |
Daniel Dunbar | 9d0863b | 2010-06-14 20:20:41 +0000 | [diff] [blame] | 683 | DAL->AddFlagArg(A, Opts.getOption(options::OPT_mpascal_strings)); |
Daniel Dunbar | ec069ed | 2009-03-25 06:58:31 +0000 | [diff] [blame] | 684 | break; |
| 685 | |
| 686 | case options::OPT_fno_pascal_strings: |
Daniel Dunbar | 9d0863b | 2010-06-14 20:20:41 +0000 | [diff] [blame] | 687 | DAL->AddFlagArg(A, Opts.getOption(options::OPT_mno_pascal_strings)); |
Daniel Dunbar | ec069ed | 2009-03-25 06:58:31 +0000 | [diff] [blame] | 688 | break; |
| 689 | } |
Daniel Dunbar | 4e7e9cf | 2009-03-25 06:12:34 +0000 | [diff] [blame] | 690 | } |
| 691 | |
Daniel Dunbar | 84ec96c | 2009-09-09 22:33:15 +0000 | [diff] [blame] | 692 | if (getTriple().getArch() == llvm::Triple::x86 || |
| 693 | getTriple().getArch() == llvm::Triple::x86_64) |
Daniel Dunbar | e4bdae7 | 2009-11-19 04:00:53 +0000 | [diff] [blame] | 694 | if (!Args.hasArgNoClaim(options::OPT_mtune_EQ)) |
Daniel Dunbar | 9d0863b | 2010-06-14 20:20:41 +0000 | [diff] [blame] | 695 | DAL->AddJoinedArg(0, Opts.getOption(options::OPT_mtune_EQ), "core2"); |
Daniel Dunbar | 84ec96c | 2009-09-09 22:33:15 +0000 | [diff] [blame] | 696 | |
| 697 | // Add the arch options based on the particular spelling of -arch, to match |
| 698 | // how the driver driver works. |
| 699 | if (BoundArch) { |
| 700 | llvm::StringRef Name = BoundArch; |
| 701 | const Option *MCpu = Opts.getOption(options::OPT_mcpu_EQ); |
| 702 | const Option *MArch = Opts.getOption(options::OPT_march_EQ); |
| 703 | |
| 704 | // This code must be kept in sync with LLVM's getArchTypeForDarwinArch, |
| 705 | // which defines the list of which architectures we accept. |
| 706 | if (Name == "ppc") |
| 707 | ; |
| 708 | else if (Name == "ppc601") |
Daniel Dunbar | 9d0863b | 2010-06-14 20:20:41 +0000 | [diff] [blame] | 709 | DAL->AddJoinedArg(0, MCpu, "601"); |
Daniel Dunbar | 84ec96c | 2009-09-09 22:33:15 +0000 | [diff] [blame] | 710 | else if (Name == "ppc603") |
Daniel Dunbar | 9d0863b | 2010-06-14 20:20:41 +0000 | [diff] [blame] | 711 | DAL->AddJoinedArg(0, MCpu, "603"); |
Daniel Dunbar | 84ec96c | 2009-09-09 22:33:15 +0000 | [diff] [blame] | 712 | else if (Name == "ppc604") |
Daniel Dunbar | 9d0863b | 2010-06-14 20:20:41 +0000 | [diff] [blame] | 713 | DAL->AddJoinedArg(0, MCpu, "604"); |
Daniel Dunbar | 84ec96c | 2009-09-09 22:33:15 +0000 | [diff] [blame] | 714 | else if (Name == "ppc604e") |
Daniel Dunbar | 9d0863b | 2010-06-14 20:20:41 +0000 | [diff] [blame] | 715 | DAL->AddJoinedArg(0, MCpu, "604e"); |
Daniel Dunbar | 84ec96c | 2009-09-09 22:33:15 +0000 | [diff] [blame] | 716 | else if (Name == "ppc750") |
Daniel Dunbar | 9d0863b | 2010-06-14 20:20:41 +0000 | [diff] [blame] | 717 | DAL->AddJoinedArg(0, MCpu, "750"); |
Daniel Dunbar | 84ec96c | 2009-09-09 22:33:15 +0000 | [diff] [blame] | 718 | else if (Name == "ppc7400") |
Daniel Dunbar | 9d0863b | 2010-06-14 20:20:41 +0000 | [diff] [blame] | 719 | DAL->AddJoinedArg(0, MCpu, "7400"); |
Daniel Dunbar | 84ec96c | 2009-09-09 22:33:15 +0000 | [diff] [blame] | 720 | else if (Name == "ppc7450") |
Daniel Dunbar | 9d0863b | 2010-06-14 20:20:41 +0000 | [diff] [blame] | 721 | DAL->AddJoinedArg(0, MCpu, "7450"); |
Daniel Dunbar | 84ec96c | 2009-09-09 22:33:15 +0000 | [diff] [blame] | 722 | else if (Name == "ppc970") |
Daniel Dunbar | 9d0863b | 2010-06-14 20:20:41 +0000 | [diff] [blame] | 723 | DAL->AddJoinedArg(0, MCpu, "970"); |
Daniel Dunbar | 84ec96c | 2009-09-09 22:33:15 +0000 | [diff] [blame] | 724 | |
| 725 | else if (Name == "ppc64") |
Daniel Dunbar | 9d0863b | 2010-06-14 20:20:41 +0000 | [diff] [blame] | 726 | DAL->AddFlagArg(0, Opts.getOption(options::OPT_m64)); |
Daniel Dunbar | ec069ed | 2009-03-25 06:58:31 +0000 | [diff] [blame] | 727 | |
Daniel Dunbar | 84ec96c | 2009-09-09 22:33:15 +0000 | [diff] [blame] | 728 | else if (Name == "i386") |
| 729 | ; |
| 730 | else if (Name == "i486") |
Daniel Dunbar | 9d0863b | 2010-06-14 20:20:41 +0000 | [diff] [blame] | 731 | DAL->AddJoinedArg(0, MArch, "i486"); |
Daniel Dunbar | 84ec96c | 2009-09-09 22:33:15 +0000 | [diff] [blame] | 732 | else if (Name == "i586") |
Daniel Dunbar | 9d0863b | 2010-06-14 20:20:41 +0000 | [diff] [blame] | 733 | DAL->AddJoinedArg(0, MArch, "i586"); |
Daniel Dunbar | 84ec96c | 2009-09-09 22:33:15 +0000 | [diff] [blame] | 734 | else if (Name == "i686") |
Daniel Dunbar | 9d0863b | 2010-06-14 20:20:41 +0000 | [diff] [blame] | 735 | DAL->AddJoinedArg(0, MArch, "i686"); |
Daniel Dunbar | 84ec96c | 2009-09-09 22:33:15 +0000 | [diff] [blame] | 736 | else if (Name == "pentium") |
Daniel Dunbar | 9d0863b | 2010-06-14 20:20:41 +0000 | [diff] [blame] | 737 | DAL->AddJoinedArg(0, MArch, "pentium"); |
Daniel Dunbar | 84ec96c | 2009-09-09 22:33:15 +0000 | [diff] [blame] | 738 | else if (Name == "pentium2") |
Daniel Dunbar | 9d0863b | 2010-06-14 20:20:41 +0000 | [diff] [blame] | 739 | DAL->AddJoinedArg(0, MArch, "pentium2"); |
Daniel Dunbar | 84ec96c | 2009-09-09 22:33:15 +0000 | [diff] [blame] | 740 | else if (Name == "pentpro") |
Daniel Dunbar | 9d0863b | 2010-06-14 20:20:41 +0000 | [diff] [blame] | 741 | DAL->AddJoinedArg(0, MArch, "pentiumpro"); |
Daniel Dunbar | 84ec96c | 2009-09-09 22:33:15 +0000 | [diff] [blame] | 742 | else if (Name == "pentIIm3") |
Daniel Dunbar | 9d0863b | 2010-06-14 20:20:41 +0000 | [diff] [blame] | 743 | DAL->AddJoinedArg(0, MArch, "pentium2"); |
Daniel Dunbar | 84ec96c | 2009-09-09 22:33:15 +0000 | [diff] [blame] | 744 | |
| 745 | else if (Name == "x86_64") |
Daniel Dunbar | 9d0863b | 2010-06-14 20:20:41 +0000 | [diff] [blame] | 746 | DAL->AddFlagArg(0, Opts.getOption(options::OPT_m64)); |
Daniel Dunbar | 84ec96c | 2009-09-09 22:33:15 +0000 | [diff] [blame] | 747 | |
| 748 | else if (Name == "arm") |
Daniel Dunbar | 9d0863b | 2010-06-14 20:20:41 +0000 | [diff] [blame] | 749 | DAL->AddJoinedArg(0, MArch, "armv4t"); |
Daniel Dunbar | 84ec96c | 2009-09-09 22:33:15 +0000 | [diff] [blame] | 750 | else if (Name == "armv4t") |
Daniel Dunbar | 9d0863b | 2010-06-14 20:20:41 +0000 | [diff] [blame] | 751 | DAL->AddJoinedArg(0, MArch, "armv4t"); |
Daniel Dunbar | 84ec96c | 2009-09-09 22:33:15 +0000 | [diff] [blame] | 752 | else if (Name == "armv5") |
Daniel Dunbar | 9d0863b | 2010-06-14 20:20:41 +0000 | [diff] [blame] | 753 | DAL->AddJoinedArg(0, MArch, "armv5tej"); |
Daniel Dunbar | 84ec96c | 2009-09-09 22:33:15 +0000 | [diff] [blame] | 754 | else if (Name == "xscale") |
Daniel Dunbar | 9d0863b | 2010-06-14 20:20:41 +0000 | [diff] [blame] | 755 | DAL->AddJoinedArg(0, MArch, "xscale"); |
Daniel Dunbar | 84ec96c | 2009-09-09 22:33:15 +0000 | [diff] [blame] | 756 | else if (Name == "armv6") |
Daniel Dunbar | 9d0863b | 2010-06-14 20:20:41 +0000 | [diff] [blame] | 757 | DAL->AddJoinedArg(0, MArch, "armv6k"); |
Daniel Dunbar | 84ec96c | 2009-09-09 22:33:15 +0000 | [diff] [blame] | 758 | else if (Name == "armv7") |
Daniel Dunbar | 9d0863b | 2010-06-14 20:20:41 +0000 | [diff] [blame] | 759 | DAL->AddJoinedArg(0, MArch, "armv7a"); |
Daniel Dunbar | 84ec96c | 2009-09-09 22:33:15 +0000 | [diff] [blame] | 760 | |
| 761 | else |
Jeffrey Yasskin | 9f61aa9 | 2009-12-12 05:05:38 +0000 | [diff] [blame] | 762 | llvm_unreachable("invalid Darwin arch"); |
Daniel Dunbar | 84ec96c | 2009-09-09 22:33:15 +0000 | [diff] [blame] | 763 | } |
Daniel Dunbar | ec069ed | 2009-03-25 06:58:31 +0000 | [diff] [blame] | 764 | |
Daniel Dunbar | 60baf0f | 2010-07-19 17:11:36 +0000 | [diff] [blame] | 765 | // Add an explicit version min argument for the deployment target. We do this |
| 766 | // after argument translation because -Xarch_ arguments may add a version min |
| 767 | // argument. |
| 768 | AddDeploymentTarget(*DAL); |
| 769 | |
Daniel Dunbar | 4e7e9cf | 2009-03-25 06:12:34 +0000 | [diff] [blame] | 770 | return DAL; |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 771 | } |
Daniel Dunbar | 8eddb3f | 2009-03-20 00:57:52 +0000 | [diff] [blame] | 772 | |
Daniel Dunbar | f395528 | 2009-09-04 18:34:51 +0000 | [diff] [blame] | 773 | bool Darwin::IsUnwindTablesDefault() const { |
Daniel Dunbar | 8eddb3f | 2009-03-20 00:57:52 +0000 | [diff] [blame] | 774 | // FIXME: Gross; we should probably have some separate target |
| 775 | // definition, possibly even reusing the one in clang. |
| 776 | return getArchName() == "x86_64"; |
| 777 | } |
| 778 | |
Daniel Dunbar | f2d8b9f | 2009-12-18 02:43:17 +0000 | [diff] [blame] | 779 | bool Darwin::UseDwarfDebugFlags() const { |
| 780 | if (const char *S = ::getenv("RC_DEBUG_OPTIONS")) |
| 781 | return S[0] != '\0'; |
| 782 | return false; |
| 783 | } |
| 784 | |
Daniel Dunbar | b2987d1 | 2010-02-10 18:49:11 +0000 | [diff] [blame] | 785 | bool Darwin::UseSjLjExceptions() const { |
| 786 | // Darwin uses SjLj exceptions on ARM. |
| 787 | return (getTriple().getArch() == llvm::Triple::arm || |
| 788 | getTriple().getArch() == llvm::Triple::thumb); |
| 789 | } |
| 790 | |
Daniel Dunbar | f395528 | 2009-09-04 18:34:51 +0000 | [diff] [blame] | 791 | const char *Darwin::GetDefaultRelocationModel() const { |
Daniel Dunbar | 8eddb3f | 2009-03-20 00:57:52 +0000 | [diff] [blame] | 792 | return "pic"; |
| 793 | } |
| 794 | |
Daniel Dunbar | f395528 | 2009-09-04 18:34:51 +0000 | [diff] [blame] | 795 | const char *Darwin::GetForcedPicModel() const { |
Daniel Dunbar | 8eddb3f | 2009-03-20 00:57:52 +0000 | [diff] [blame] | 796 | if (getArchName() == "x86_64") |
| 797 | return "pic"; |
| 798 | return 0; |
| 799 | } |
| 800 | |
Daniel Dunbar | 43a9b32 | 2010-04-10 16:20:23 +0000 | [diff] [blame] | 801 | bool Darwin::SupportsObjCGC() const { |
| 802 | // Garbage collection is supported everywhere except on iPhone OS. |
| 803 | return !isTargetIPhoneOS(); |
| 804 | } |
| 805 | |
Daniel Dunbar | 00577ad | 2010-08-23 22:35:37 +0000 | [diff] [blame] | 806 | std::string |
| 807 | Darwin_Generic_GCC::ComputeEffectiveClangTriple(const ArgList &Args) const { |
| 808 | return ComputeLLVMTriple(Args); |
| 809 | } |
| 810 | |
Daniel Dunbar | 3917608 | 2009-03-20 00:20:03 +0000 | [diff] [blame] | 811 | /// Generic_GCC - A tool chain using the 'gcc' command to perform |
| 812 | /// all subcommands; this relies on gcc translating the majority of |
| 813 | /// command line options. |
| 814 | |
Daniel Dunbar | cb8ab23 | 2009-05-22 02:53:45 +0000 | [diff] [blame] | 815 | Generic_GCC::Generic_GCC(const HostInfo &Host, const llvm::Triple& Triple) |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 816 | : ToolChain(Host, Triple) { |
Daniel Dunbar | edf29b0 | 2010-08-01 22:29:51 +0000 | [diff] [blame] | 817 | getProgramPaths().push_back(getDriver().getInstalledDir()); |
| 818 | if (getDriver().getInstalledDir() != getDriver().Dir.c_str()) |
| 819 | getProgramPaths().push_back(getDriver().Dir); |
Daniel Dunbar | c50b00d | 2009-03-23 16:15:50 +0000 | [diff] [blame] | 820 | } |
| 821 | |
Daniel Dunbar | 3917608 | 2009-03-20 00:20:03 +0000 | [diff] [blame] | 822 | Generic_GCC::~Generic_GCC() { |
| 823 | // Free tool implementations. |
| 824 | for (llvm::DenseMap<unsigned, Tool*>::iterator |
| 825 | it = Tools.begin(), ie = Tools.end(); it != ie; ++it) |
| 826 | delete it->second; |
| 827 | } |
| 828 | |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 829 | Tool &Generic_GCC::SelectTool(const Compilation &C, |
Daniel Dunbar | 3917608 | 2009-03-20 00:20:03 +0000 | [diff] [blame] | 830 | const JobAction &JA) const { |
| 831 | Action::ActionClass Key; |
Daniel Dunbar | ee788e7 | 2009-12-21 18:54:17 +0000 | [diff] [blame] | 832 | if (getDriver().ShouldUseClangCompiler(C, JA, getTriple())) |
Daniel Dunbar | 3917608 | 2009-03-20 00:20:03 +0000 | [diff] [blame] | 833 | Key = Action::AnalyzeJobClass; |
| 834 | else |
| 835 | Key = JA.getKind(); |
| 836 | |
| 837 | Tool *&T = Tools[Key]; |
| 838 | if (!T) { |
| 839 | switch (Key) { |
Daniel Dunbar | 8eddb3f | 2009-03-20 00:57:52 +0000 | [diff] [blame] | 840 | case Action::InputClass: |
| 841 | case Action::BindArchClass: |
Daniel Dunbar | 3917608 | 2009-03-20 00:20:03 +0000 | [diff] [blame] | 842 | assert(0 && "Invalid tool kind."); |
| 843 | case Action::PreprocessJobClass: |
| 844 | T = new tools::gcc::Preprocess(*this); break; |
| 845 | case Action::PrecompileJobClass: |
| 846 | T = new tools::gcc::Precompile(*this); break; |
| 847 | case Action::AnalyzeJobClass: |
| 848 | T = new tools::Clang(*this); break; |
| 849 | case Action::CompileJobClass: |
| 850 | T = new tools::gcc::Compile(*this); break; |
| 851 | case Action::AssembleJobClass: |
| 852 | T = new tools::gcc::Assemble(*this); break; |
| 853 | case Action::LinkJobClass: |
| 854 | T = new tools::gcc::Link(*this); break; |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 855 | |
Daniel Dunbar | 8eddb3f | 2009-03-20 00:57:52 +0000 | [diff] [blame] | 856 | // This is a bit ungeneric, but the only platform using a driver |
| 857 | // driver is Darwin. |
| 858 | case Action::LipoJobClass: |
| 859 | T = new tools::darwin::Lipo(*this); break; |
Daniel Dunbar | 6e0f254 | 2010-06-04 18:28:36 +0000 | [diff] [blame] | 860 | case Action::DsymutilJobClass: |
| 861 | T = new tools::darwin::Dsymutil(*this); break; |
Daniel Dunbar | 3917608 | 2009-03-20 00:20:03 +0000 | [diff] [blame] | 862 | } |
| 863 | } |
| 864 | |
| 865 | return *T; |
| 866 | } |
| 867 | |
Daniel Dunbar | 3917608 | 2009-03-20 00:20:03 +0000 | [diff] [blame] | 868 | bool Generic_GCC::IsUnwindTablesDefault() const { |
Daniel Dunbar | 8eddb3f | 2009-03-20 00:57:52 +0000 | [diff] [blame] | 869 | // FIXME: Gross; we should probably have some separate target |
| 870 | // definition, possibly even reusing the one in clang. |
Daniel Dunbar | 3917608 | 2009-03-20 00:20:03 +0000 | [diff] [blame] | 871 | return getArchName() == "x86_64"; |
| 872 | } |
| 873 | |
| 874 | const char *Generic_GCC::GetDefaultRelocationModel() const { |
| 875 | return "static"; |
| 876 | } |
| 877 | |
| 878 | const char *Generic_GCC::GetForcedPicModel() const { |
| 879 | return 0; |
| 880 | } |
Daniel Dunbar | f3cad36 | 2009-03-25 04:13:45 +0000 | [diff] [blame] | 881 | |
Chris Lattner | 3a47c4e | 2010-03-04 21:07:38 +0000 | [diff] [blame] | 882 | /// TCEToolChain - A tool chain using the llvm bitcode tools to perform |
| 883 | /// all subcommands. See http://tce.cs.tut.fi for our peculiar target. |
| 884 | /// Currently does not support anything else but compilation. |
| 885 | |
| 886 | TCEToolChain::TCEToolChain(const HostInfo &Host, const llvm::Triple& Triple) |
| 887 | : ToolChain(Host, Triple) { |
| 888 | // Path mangling to find libexec |
| 889 | std::string Path(getDriver().Dir); |
| 890 | |
| 891 | Path += "/../libexec"; |
| 892 | getProgramPaths().push_back(Path); |
| 893 | } |
| 894 | |
| 895 | TCEToolChain::~TCEToolChain() { |
| 896 | for (llvm::DenseMap<unsigned, Tool*>::iterator |
| 897 | it = Tools.begin(), ie = Tools.end(); it != ie; ++it) |
| 898 | delete it->second; |
| 899 | } |
| 900 | |
| 901 | bool TCEToolChain::IsMathErrnoDefault() const { |
| 902 | return true; |
| 903 | } |
| 904 | |
| 905 | bool TCEToolChain::IsUnwindTablesDefault() const { |
| 906 | return false; |
| 907 | } |
| 908 | |
| 909 | const char *TCEToolChain::GetDefaultRelocationModel() const { |
| 910 | return "static"; |
| 911 | } |
| 912 | |
| 913 | const char *TCEToolChain::GetForcedPicModel() const { |
| 914 | return 0; |
| 915 | } |
| 916 | |
| 917 | Tool &TCEToolChain::SelectTool(const Compilation &C, |
| 918 | const JobAction &JA) const { |
| 919 | Action::ActionClass Key; |
| 920 | Key = Action::AnalyzeJobClass; |
| 921 | |
| 922 | Tool *&T = Tools[Key]; |
| 923 | if (!T) { |
| 924 | switch (Key) { |
| 925 | case Action::PreprocessJobClass: |
| 926 | T = new tools::gcc::Preprocess(*this); break; |
| 927 | case Action::AnalyzeJobClass: |
| 928 | T = new tools::Clang(*this); break; |
| 929 | default: |
| 930 | assert(false && "Unsupported action for TCE target."); |
| 931 | } |
| 932 | } |
| 933 | return *T; |
| 934 | } |
| 935 | |
Daniel Dunbar | f7b8eec | 2009-06-29 20:52:51 +0000 | [diff] [blame] | 936 | /// OpenBSD - OpenBSD tool chain which can call as(1) and ld(1) directly. |
| 937 | |
| 938 | OpenBSD::OpenBSD(const HostInfo &Host, const llvm::Triple& Triple) |
| 939 | : Generic_GCC(Host, Triple) { |
Daniel Dunbar | ee788e7 | 2009-12-21 18:54:17 +0000 | [diff] [blame] | 940 | getFilePaths().push_back(getDriver().Dir + "/../lib"); |
Daniel Dunbar | f7b8eec | 2009-06-29 20:52:51 +0000 | [diff] [blame] | 941 | getFilePaths().push_back("/usr/lib"); |
| 942 | } |
| 943 | |
| 944 | Tool &OpenBSD::SelectTool(const Compilation &C, const JobAction &JA) const { |
| 945 | Action::ActionClass Key; |
Daniel Dunbar | ee788e7 | 2009-12-21 18:54:17 +0000 | [diff] [blame] | 946 | if (getDriver().ShouldUseClangCompiler(C, JA, getTriple())) |
Daniel Dunbar | f7b8eec | 2009-06-29 20:52:51 +0000 | [diff] [blame] | 947 | Key = Action::AnalyzeJobClass; |
| 948 | else |
| 949 | Key = JA.getKind(); |
| 950 | |
| 951 | Tool *&T = Tools[Key]; |
| 952 | if (!T) { |
| 953 | switch (Key) { |
| 954 | case Action::AssembleJobClass: |
| 955 | T = new tools::openbsd::Assemble(*this); break; |
| 956 | case Action::LinkJobClass: |
| 957 | T = new tools::openbsd::Link(*this); break; |
| 958 | default: |
| 959 | T = &Generic_GCC::SelectTool(C, JA); |
| 960 | } |
| 961 | } |
| 962 | |
| 963 | return *T; |
| 964 | } |
| 965 | |
Daniel Dunbar | 75358d2 | 2009-03-30 21:06:03 +0000 | [diff] [blame] | 966 | /// FreeBSD - FreeBSD tool chain which can call as(1) and ld(1) directly. |
| 967 | |
Daniel Dunbar | 214afe9 | 2010-08-02 05:43:59 +0000 | [diff] [blame] | 968 | FreeBSD::FreeBSD(const HostInfo &Host, const llvm::Triple& Triple) |
Daniel Dunbar | cb8ab23 | 2009-05-22 02:53:45 +0000 | [diff] [blame] | 969 | : Generic_GCC(Host, Triple) { |
Daniel Dunbar | 214afe9 | 2010-08-02 05:43:59 +0000 | [diff] [blame] | 970 | |
| 971 | // Determine if we are compiling 32-bit code on an x86_64 platform. |
| 972 | bool Lib32 = false; |
| 973 | if (Triple.getArch() == llvm::Triple::x86 && |
| 974 | llvm::Triple(getDriver().DefaultHostTriple).getArch() == |
| 975 | llvm::Triple::x86_64) |
| 976 | Lib32 = true; |
| 977 | |
Daniel Dunbar | 7fb2c25 | 2010-06-15 15:03:31 +0000 | [diff] [blame] | 978 | getProgramPaths().push_back(getDriver().Dir + "/../libexec"); |
| 979 | getProgramPaths().push_back("/usr/libexec"); |
Daniel Dunbar | bc53466 | 2009-04-02 18:30:04 +0000 | [diff] [blame] | 980 | if (Lib32) { |
Daniel Dunbar | ee788e7 | 2009-12-21 18:54:17 +0000 | [diff] [blame] | 981 | getFilePaths().push_back(getDriver().Dir + "/../lib32"); |
Daniel Dunbar | bc53466 | 2009-04-02 18:30:04 +0000 | [diff] [blame] | 982 | getFilePaths().push_back("/usr/lib32"); |
| 983 | } else { |
Daniel Dunbar | ee788e7 | 2009-12-21 18:54:17 +0000 | [diff] [blame] | 984 | getFilePaths().push_back(getDriver().Dir + "/../lib"); |
Daniel Dunbar | bc53466 | 2009-04-02 18:30:04 +0000 | [diff] [blame] | 985 | getFilePaths().push_back("/usr/lib"); |
| 986 | } |
Daniel Dunbar | 75358d2 | 2009-03-30 21:06:03 +0000 | [diff] [blame] | 987 | } |
| 988 | |
| 989 | Tool &FreeBSD::SelectTool(const Compilation &C, const JobAction &JA) const { |
| 990 | Action::ActionClass Key; |
Daniel Dunbar | ee788e7 | 2009-12-21 18:54:17 +0000 | [diff] [blame] | 991 | if (getDriver().ShouldUseClangCompiler(C, JA, getTriple())) |
Daniel Dunbar | 75358d2 | 2009-03-30 21:06:03 +0000 | [diff] [blame] | 992 | Key = Action::AnalyzeJobClass; |
| 993 | else |
| 994 | Key = JA.getKind(); |
| 995 | |
| 996 | Tool *&T = Tools[Key]; |
| 997 | if (!T) { |
| 998 | switch (Key) { |
Daniel Dunbar | 68a31d4 | 2009-03-31 17:45:15 +0000 | [diff] [blame] | 999 | case Action::AssembleJobClass: |
| 1000 | T = new tools::freebsd::Assemble(*this); break; |
Daniel Dunbar | 008f54a | 2009-04-01 19:36:32 +0000 | [diff] [blame] | 1001 | case Action::LinkJobClass: |
| 1002 | T = new tools::freebsd::Link(*this); break; |
Daniel Dunbar | 75358d2 | 2009-03-30 21:06:03 +0000 | [diff] [blame] | 1003 | default: |
| 1004 | T = &Generic_GCC::SelectTool(C, JA); |
| 1005 | } |
| 1006 | } |
| 1007 | |
| 1008 | return *T; |
| 1009 | } |
Daniel Dunbar | 11e1b40 | 2009-05-02 18:28:39 +0000 | [diff] [blame] | 1010 | |
Chris Lattner | 38e317d | 2010-07-07 16:01:42 +0000 | [diff] [blame] | 1011 | /// Minix - Minix tool chain which can call as(1) and ld(1) directly. |
| 1012 | |
| 1013 | Minix::Minix(const HostInfo &Host, const llvm::Triple& Triple) |
| 1014 | : Generic_GCC(Host, Triple) { |
| 1015 | getFilePaths().push_back(getDriver().Dir + "/../lib"); |
| 1016 | getFilePaths().push_back("/usr/lib"); |
| 1017 | getFilePaths().push_back("/usr/gnu/lib"); |
| 1018 | getFilePaths().push_back("/usr/gnu/lib/gcc/i686-pc-minix/4.4.3"); |
| 1019 | } |
| 1020 | |
| 1021 | Tool &Minix::SelectTool(const Compilation &C, const JobAction &JA) const { |
| 1022 | Action::ActionClass Key; |
| 1023 | if (getDriver().ShouldUseClangCompiler(C, JA, getTriple())) |
| 1024 | Key = Action::AnalyzeJobClass; |
| 1025 | else |
| 1026 | Key = JA.getKind(); |
| 1027 | |
| 1028 | Tool *&T = Tools[Key]; |
| 1029 | if (!T) { |
| 1030 | switch (Key) { |
| 1031 | case Action::AssembleJobClass: |
| 1032 | T = new tools::minix::Assemble(*this); break; |
| 1033 | case Action::LinkJobClass: |
| 1034 | T = new tools::minix::Link(*this); break; |
| 1035 | default: |
| 1036 | T = &Generic_GCC::SelectTool(C, JA); |
| 1037 | } |
| 1038 | } |
| 1039 | |
| 1040 | return *T; |
| 1041 | } |
| 1042 | |
Edward O'Callaghan | e7925a0 | 2009-08-22 01:06:46 +0000 | [diff] [blame] | 1043 | /// AuroraUX - AuroraUX tool chain which can call as(1) and ld(1) directly. |
| 1044 | |
| 1045 | AuroraUX::AuroraUX(const HostInfo &Host, const llvm::Triple& Triple) |
| 1046 | : Generic_GCC(Host, Triple) { |
| 1047 | |
Daniel Dunbar | edf29b0 | 2010-08-01 22:29:51 +0000 | [diff] [blame] | 1048 | getProgramPaths().push_back(getDriver().getInstalledDir()); |
| 1049 | if (getDriver().getInstalledDir() != getDriver().Dir.c_str()) |
| 1050 | getProgramPaths().push_back(getDriver().Dir); |
Edward O'Callaghan | e7925a0 | 2009-08-22 01:06:46 +0000 | [diff] [blame] | 1051 | |
Daniel Dunbar | ee788e7 | 2009-12-21 18:54:17 +0000 | [diff] [blame] | 1052 | getFilePaths().push_back(getDriver().Dir + "/../lib"); |
Edward O'Callaghan | e7925a0 | 2009-08-22 01:06:46 +0000 | [diff] [blame] | 1053 | getFilePaths().push_back("/usr/lib"); |
| 1054 | getFilePaths().push_back("/usr/sfw/lib"); |
| 1055 | getFilePaths().push_back("/opt/gcc4/lib"); |
Edward O'Callaghan | 7adf949 | 2009-10-15 07:44:07 +0000 | [diff] [blame] | 1056 | 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] | 1057 | |
| 1058 | } |
| 1059 | |
| 1060 | Tool &AuroraUX::SelectTool(const Compilation &C, const JobAction &JA) const { |
| 1061 | Action::ActionClass Key; |
Daniel Dunbar | ee788e7 | 2009-12-21 18:54:17 +0000 | [diff] [blame] | 1062 | if (getDriver().ShouldUseClangCompiler(C, JA, getTriple())) |
Edward O'Callaghan | e7925a0 | 2009-08-22 01:06:46 +0000 | [diff] [blame] | 1063 | Key = Action::AnalyzeJobClass; |
| 1064 | else |
| 1065 | Key = JA.getKind(); |
| 1066 | |
| 1067 | Tool *&T = Tools[Key]; |
| 1068 | if (!T) { |
| 1069 | switch (Key) { |
| 1070 | case Action::AssembleJobClass: |
| 1071 | T = new tools::auroraux::Assemble(*this); break; |
| 1072 | case Action::LinkJobClass: |
| 1073 | T = new tools::auroraux::Link(*this); break; |
| 1074 | default: |
| 1075 | T = &Generic_GCC::SelectTool(C, JA); |
| 1076 | } |
| 1077 | } |
| 1078 | |
| 1079 | return *T; |
| 1080 | } |
| 1081 | |
| 1082 | |
Eli Friedman | 6b3454a | 2009-05-26 07:52:18 +0000 | [diff] [blame] | 1083 | /// Linux toolchain (very bare-bones at the moment). |
| 1084 | |
| 1085 | Linux::Linux(const HostInfo &Host, const llvm::Triple& Triple) |
| 1086 | : Generic_GCC(Host, Triple) { |
Chris Lattner | 3f2cc6f | 2010-09-03 16:47:03 +0000 | [diff] [blame^] | 1087 | getFilePaths().push_back(getDriver().Dir + |
| 1088 | "/../lib/clang/" CLANG_VERSION_STRING "/"); |
Eli Friedman | 6b3454a | 2009-05-26 07:52:18 +0000 | [diff] [blame] | 1089 | getFilePaths().push_back("/lib/"); |
| 1090 | getFilePaths().push_back("/usr/lib/"); |
Daniel Dunbar | a9822de | 2009-08-06 01:47:11 +0000 | [diff] [blame] | 1091 | |
| 1092 | // Depending on the Linux distribution, any combination of lib{,32,64} is |
| 1093 | // possible. E.g. Debian uses lib and lib32 for mixed i386/x86-64 systems, |
| 1094 | // openSUSE uses lib and lib64 for the same purpose. |
| 1095 | getFilePaths().push_back("/lib32/"); |
| 1096 | getFilePaths().push_back("/usr/lib32/"); |
| 1097 | getFilePaths().push_back("/lib64/"); |
| 1098 | getFilePaths().push_back("/usr/lib64/"); |
| 1099 | |
Eli Friedman | 6b3454a | 2009-05-26 07:52:18 +0000 | [diff] [blame] | 1100 | // FIXME: Figure out some way to get gcc's libdir |
| 1101 | // (e.g. /usr/lib/gcc/i486-linux-gnu/4.3/ for Ubuntu 32-bit); we need |
| 1102 | // crtbegin.o/crtend.o/etc., and want static versions of various |
| 1103 | // libraries. If we had our own crtbegin.o/crtend.o/etc, we could probably |
| 1104 | // get away with using shared versions in /usr/lib, though. |
| 1105 | // We could fall back to the approach we used for includes (a massive |
| 1106 | // list), but that's messy at best. |
| 1107 | } |
| 1108 | |
Rafael Espindola | ba30bbe | 2010-08-10 00:25:48 +0000 | [diff] [blame] | 1109 | Tool &Linux::SelectTool(const Compilation &C, const JobAction &JA) const { |
| 1110 | Action::ActionClass Key; |
| 1111 | if (getDriver().ShouldUseClangCompiler(C, JA, getTriple())) |
| 1112 | Key = Action::AnalyzeJobClass; |
| 1113 | else |
| 1114 | Key = JA.getKind(); |
| 1115 | |
| 1116 | Tool *&T = Tools[Key]; |
| 1117 | if (!T) { |
| 1118 | switch (Key) { |
| 1119 | case Action::AssembleJobClass: |
| 1120 | T = new tools::linuxtools::Assemble(*this); break; |
| 1121 | default: |
| 1122 | T = &Generic_GCC::SelectTool(C, JA); |
| 1123 | } |
| 1124 | } |
| 1125 | |
| 1126 | return *T; |
| 1127 | } |
| 1128 | |
Daniel Dunbar | 11e1b40 | 2009-05-02 18:28:39 +0000 | [diff] [blame] | 1129 | /// DragonFly - DragonFly tool chain which can call as(1) and ld(1) directly. |
| 1130 | |
Daniel Dunbar | cb8ab23 | 2009-05-22 02:53:45 +0000 | [diff] [blame] | 1131 | DragonFly::DragonFly(const HostInfo &Host, const llvm::Triple& Triple) |
| 1132 | : Generic_GCC(Host, Triple) { |
Daniel Dunbar | 11e1b40 | 2009-05-02 18:28:39 +0000 | [diff] [blame] | 1133 | |
| 1134 | // Path mangling to find libexec |
Daniel Dunbar | edf29b0 | 2010-08-01 22:29:51 +0000 | [diff] [blame] | 1135 | getProgramPaths().push_back(getDriver().getInstalledDir()); |
| 1136 | if (getDriver().getInstalledDir() != getDriver().Dir.c_str()) |
| 1137 | getProgramPaths().push_back(getDriver().Dir); |
Daniel Dunbar | 11e1b40 | 2009-05-02 18:28:39 +0000 | [diff] [blame] | 1138 | |
Daniel Dunbar | ee788e7 | 2009-12-21 18:54:17 +0000 | [diff] [blame] | 1139 | getFilePaths().push_back(getDriver().Dir + "/../lib"); |
Daniel Dunbar | 11e1b40 | 2009-05-02 18:28:39 +0000 | [diff] [blame] | 1140 | getFilePaths().push_back("/usr/lib"); |
| 1141 | getFilePaths().push_back("/usr/lib/gcc41"); |
| 1142 | } |
| 1143 | |
| 1144 | Tool &DragonFly::SelectTool(const Compilation &C, const JobAction &JA) const { |
| 1145 | Action::ActionClass Key; |
Daniel Dunbar | ee788e7 | 2009-12-21 18:54:17 +0000 | [diff] [blame] | 1146 | if (getDriver().ShouldUseClangCompiler(C, JA, getTriple())) |
Daniel Dunbar | 11e1b40 | 2009-05-02 18:28:39 +0000 | [diff] [blame] | 1147 | Key = Action::AnalyzeJobClass; |
| 1148 | else |
| 1149 | Key = JA.getKind(); |
| 1150 | |
| 1151 | Tool *&T = Tools[Key]; |
| 1152 | if (!T) { |
| 1153 | switch (Key) { |
| 1154 | case Action::AssembleJobClass: |
| 1155 | T = new tools::dragonfly::Assemble(*this); break; |
| 1156 | case Action::LinkJobClass: |
| 1157 | T = new tools::dragonfly::Link(*this); break; |
| 1158 | default: |
| 1159 | T = &Generic_GCC::SelectTool(C, JA); |
| 1160 | } |
| 1161 | } |
| 1162 | |
| 1163 | return *T; |
| 1164 | } |
Michael J. Spencer | ff58e36 | 2010-08-21 21:55:07 +0000 | [diff] [blame] | 1165 | |
| 1166 | Windows::Windows(const HostInfo &Host, const llvm::Triple& Triple) |
| 1167 | : ToolChain(Host, Triple) { |
| 1168 | } |
| 1169 | |
| 1170 | Tool &Windows::SelectTool(const Compilation &C, const JobAction &JA) const { |
| 1171 | Action::ActionClass Key; |
| 1172 | if (getDriver().ShouldUseClangCompiler(C, JA, getTriple())) |
| 1173 | Key = Action::AnalyzeJobClass; |
| 1174 | else |
| 1175 | Key = JA.getKind(); |
| 1176 | |
| 1177 | Tool *&T = Tools[Key]; |
| 1178 | if (!T) { |
| 1179 | switch (Key) { |
| 1180 | case Action::InputClass: |
| 1181 | case Action::BindArchClass: |
Chandler Carruth | e97673f | 2010-08-22 06:56:37 +0000 | [diff] [blame] | 1182 | case Action::LipoJobClass: |
| 1183 | case Action::DsymutilJobClass: |
Michael J. Spencer | ff58e36 | 2010-08-21 21:55:07 +0000 | [diff] [blame] | 1184 | assert(0 && "Invalid tool kind."); |
| 1185 | case Action::PreprocessJobClass: |
| 1186 | case Action::PrecompileJobClass: |
| 1187 | case Action::AnalyzeJobClass: |
| 1188 | case Action::CompileJobClass: |
| 1189 | T = new tools::Clang(*this); break; |
| 1190 | case Action::AssembleJobClass: |
| 1191 | T = new tools::ClangAs(*this); break; |
| 1192 | case Action::LinkJobClass: |
| 1193 | T = new tools::visualstudio::Link(*this); break; |
| 1194 | } |
| 1195 | } |
| 1196 | |
| 1197 | return *T; |
| 1198 | } |
| 1199 | |
| 1200 | bool Windows::IsIntegratedAssemblerDefault() const { |
| 1201 | return true; |
| 1202 | } |
| 1203 | |
| 1204 | bool Windows::IsUnwindTablesDefault() const { |
| 1205 | // FIXME: Gross; we should probably have some separate target |
| 1206 | // definition, possibly even reusing the one in clang. |
| 1207 | return getArchName() == "x86_64"; |
| 1208 | } |
| 1209 | |
| 1210 | const char *Windows::GetDefaultRelocationModel() const { |
| 1211 | return "static"; |
| 1212 | } |
| 1213 | |
| 1214 | const char *Windows::GetForcedPicModel() const { |
| 1215 | if (getArchName() == "x86_64") |
| 1216 | return "pic"; |
| 1217 | return 0; |
| 1218 | } |