Daniel Dunbar | 47ac7d2 | 2009-03-18 06:00:36 +0000 | [diff] [blame] | 1 | //===--- Tools.cpp - Tools 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 "Tools.h" |
| 11 | |
Daniel Dunbar | 5f12232 | 2009-12-15 01:02:52 +0000 | [diff] [blame] | 12 | #include "clang/Basic/Version.h" |
Daniel Dunbar | 1d46033 | 2009-03-18 10:01:51 +0000 | [diff] [blame] | 13 | #include "clang/Driver/Action.h" |
Daniel Dunbar | 871adcf | 2009-03-18 07:06:02 +0000 | [diff] [blame] | 14 | #include "clang/Driver/Arg.h" |
Daniel Dunbar | b488c1d | 2009-03-18 08:07:30 +0000 | [diff] [blame] | 15 | #include "clang/Driver/ArgList.h" |
Daniel Dunbar | ee848a7 | 2009-10-29 02:39:57 +0000 | [diff] [blame] | 16 | #include "clang/Driver/Driver.h" |
| 17 | #include "clang/Driver/DriverDiagnostic.h" |
Daniel Dunbar | 871adcf | 2009-03-18 07:06:02 +0000 | [diff] [blame] | 18 | #include "clang/Driver/Compilation.h" |
| 19 | #include "clang/Driver/Job.h" |
Daniel Dunbar | b488c1d | 2009-03-18 08:07:30 +0000 | [diff] [blame] | 20 | #include "clang/Driver/HostInfo.h" |
| 21 | #include "clang/Driver/Option.h" |
Daniel Dunbar | 265e9ef | 2009-11-19 04:25:22 +0000 | [diff] [blame] | 22 | #include "clang/Driver/Options.h" |
Daniel Dunbar | b488c1d | 2009-03-18 08:07:30 +0000 | [diff] [blame] | 23 | #include "clang/Driver/ToolChain.h" |
Daniel Dunbar | 871adcf | 2009-03-18 07:06:02 +0000 | [diff] [blame] | 24 | #include "clang/Driver/Util.h" |
| 25 | |
Daniel Dunbar | 8813764 | 2009-09-09 22:32:48 +0000 | [diff] [blame] | 26 | #include "llvm/ADT/SmallString.h" |
Douglas Gregor | 55d3f7a | 2009-10-29 00:41:01 +0000 | [diff] [blame] | 27 | #include "llvm/ADT/StringSwitch.h" |
Daniel Dunbar | 5b750fe | 2009-09-09 22:32:34 +0000 | [diff] [blame] | 28 | #include "llvm/ADT/Twine.h" |
Daniel Dunbar | 02633b5 | 2009-03-26 16:23:12 +0000 | [diff] [blame] | 29 | #include "llvm/Support/Format.h" |
| 30 | #include "llvm/Support/raw_ostream.h" |
Daniel Dunbar | f86fedd | 2009-11-14 22:04:54 +0000 | [diff] [blame] | 31 | #include "llvm/System/Host.h" |
Daniel Dunbar | 55efe14 | 2009-11-04 06:24:47 +0000 | [diff] [blame] | 32 | #include "llvm/System/Process.h" |
Daniel Dunbar | 871adcf | 2009-03-18 07:06:02 +0000 | [diff] [blame] | 33 | |
| 34 | #include "InputInfo.h" |
Daniel Dunbar | 02633b5 | 2009-03-26 16:23:12 +0000 | [diff] [blame] | 35 | #include "ToolChains.h" |
Daniel Dunbar | 871adcf | 2009-03-18 07:06:02 +0000 | [diff] [blame] | 36 | |
Daniel Dunbar | 47ac7d2 | 2009-03-18 06:00:36 +0000 | [diff] [blame] | 37 | using namespace clang::driver; |
| 38 | using namespace clang::driver::tools; |
| 39 | |
Daniel Dunbar | 88a3d6c | 2009-09-10 01:21:05 +0000 | [diff] [blame] | 40 | /// CheckPreprocessingOptions - Perform some validation of preprocessing |
| 41 | /// arguments that is shared with gcc. |
| 42 | static void CheckPreprocessingOptions(const Driver &D, const ArgList &Args) { |
| 43 | if (Arg *A = Args.getLastArg(options::OPT_C, options::OPT_CC)) |
| 44 | if (!Args.hasArg(options::OPT_E)) |
| 45 | D.Diag(clang::diag::err_drv_argument_only_allowed_with) |
| 46 | << A->getAsString(Args) << "-E"; |
| 47 | } |
| 48 | |
Daniel Dunbar | e2fd664 | 2009-09-10 01:21:12 +0000 | [diff] [blame] | 49 | /// CheckCodeGenerationOptions - Perform some validation of code generation |
| 50 | /// arguments that is shared with gcc. |
| 51 | static void CheckCodeGenerationOptions(const Driver &D, const ArgList &Args) { |
| 52 | // In gcc, only ARM checks this, but it seems reasonable to check universally. |
| 53 | if (Args.hasArg(options::OPT_static)) |
| 54 | if (const Arg *A = Args.getLastArg(options::OPT_dynamic, |
| 55 | options::OPT_mdynamic_no_pic)) |
| 56 | D.Diag(clang::diag::err_drv_argument_not_allowed_with) |
| 57 | << A->getAsString(Args) << "-static"; |
| 58 | } |
| 59 | |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 60 | void Clang::AddPreprocessingOptions(const Driver &D, |
Douglas Gregor | df91ef3 | 2009-04-18 00:34:01 +0000 | [diff] [blame] | 61 | const ArgList &Args, |
Daniel Dunbar | c21c485 | 2009-04-08 23:54:23 +0000 | [diff] [blame] | 62 | ArgStringList &CmdArgs, |
| 63 | const InputInfo &Output, |
| 64 | const InputInfoList &Inputs) const { |
Daniel Dunbar | c21c485 | 2009-04-08 23:54:23 +0000 | [diff] [blame] | 65 | Arg *A; |
Daniel Dunbar | 3a183d3 | 2009-06-08 21:48:20 +0000 | [diff] [blame] | 66 | |
Daniel Dunbar | 88a3d6c | 2009-09-10 01:21:05 +0000 | [diff] [blame] | 67 | CheckPreprocessingOptions(D, Args); |
| 68 | |
| 69 | Args.AddLastArg(CmdArgs, options::OPT_C); |
| 70 | Args.AddLastArg(CmdArgs, options::OPT_CC); |
Daniel Dunbar | 3a183d3 | 2009-06-08 21:48:20 +0000 | [diff] [blame] | 71 | |
| 72 | // Handle dependency file generation. |
Daniel Dunbar | c21c485 | 2009-04-08 23:54:23 +0000 | [diff] [blame] | 73 | if ((A = Args.getLastArg(options::OPT_M)) || |
| 74 | (A = Args.getLastArg(options::OPT_MM)) || |
| 75 | (A = Args.getLastArg(options::OPT_MD)) || |
| 76 | (A = Args.getLastArg(options::OPT_MMD))) { |
| 77 | // Determine the output location. |
| 78 | const char *DepFile; |
| 79 | if (Output.getType() == types::TY_Dependencies) { |
| 80 | if (Output.isPipe()) |
| 81 | DepFile = "-"; |
| 82 | else |
| 83 | DepFile = Output.getFilename(); |
| 84 | } else if (Arg *MF = Args.getLastArg(options::OPT_MF)) { |
| 85 | DepFile = MF->getValue(Args); |
Daniel Dunbar | b827a05 | 2009-11-19 03:26:40 +0000 | [diff] [blame] | 86 | } else if (A->getOption().matches(options::OPT_M) || |
| 87 | A->getOption().matches(options::OPT_MM)) { |
Daniel Dunbar | c21c485 | 2009-04-08 23:54:23 +0000 | [diff] [blame] | 88 | DepFile = "-"; |
| 89 | } else { |
| 90 | DepFile = darwin::CC1::getDependencyFileName(Args, Inputs); |
| 91 | } |
| 92 | CmdArgs.push_back("-dependency-file"); |
| 93 | CmdArgs.push_back(DepFile); |
| 94 | |
| 95 | // Add an -MT option if the user didn't specify their own. |
Daniel Dunbar | e0be8b1 | 2009-09-08 16:39:16 +0000 | [diff] [blame] | 96 | // |
Daniel Dunbar | c21c485 | 2009-04-08 23:54:23 +0000 | [diff] [blame] | 97 | // FIXME: This should use -MQ, when we support it. |
| 98 | if (!Args.hasArg(options::OPT_MT) && !Args.hasArg(options::OPT_MQ)) { |
| 99 | const char *DepTarget; |
| 100 | |
| 101 | // If user provided -o, that is the dependency target, except |
| 102 | // when we are only generating a dependency file. |
| 103 | Arg *OutputOpt = Args.getLastArg(options::OPT_o); |
| 104 | if (OutputOpt && Output.getType() != types::TY_Dependencies) { |
| 105 | DepTarget = OutputOpt->getValue(Args); |
| 106 | } else { |
| 107 | // Otherwise derive from the base input. |
| 108 | // |
| 109 | // FIXME: This should use the computed output file location. |
| 110 | llvm::sys::Path P(Inputs[0].getBaseInput()); |
| 111 | |
| 112 | P.eraseSuffix(); |
| 113 | P.appendSuffix("o"); |
Daniel Dunbar | 8813764 | 2009-09-09 22:32:48 +0000 | [diff] [blame] | 114 | DepTarget = Args.MakeArgString(P.getLast()); |
Daniel Dunbar | c21c485 | 2009-04-08 23:54:23 +0000 | [diff] [blame] | 115 | } |
| 116 | |
| 117 | CmdArgs.push_back("-MT"); |
| 118 | CmdArgs.push_back(DepTarget); |
| 119 | } |
| 120 | |
Daniel Dunbar | b827a05 | 2009-11-19 03:26:40 +0000 | [diff] [blame] | 121 | if (A->getOption().matches(options::OPT_M) || |
| 122 | A->getOption().matches(options::OPT_MD)) |
Daniel Dunbar | c21c485 | 2009-04-08 23:54:23 +0000 | [diff] [blame] | 123 | CmdArgs.push_back("-sys-header-deps"); |
| 124 | } |
| 125 | |
| 126 | Args.AddLastArg(CmdArgs, options::OPT_MP); |
| 127 | Args.AddAllArgs(CmdArgs, options::OPT_MT); |
| 128 | |
Douglas Gregor | df91ef3 | 2009-04-18 00:34:01 +0000 | [diff] [blame] | 129 | // Add -i* options, and automatically translate to |
| 130 | // -include-pch/-include-pth for transparent PCH support. It's |
| 131 | // wonky, but we include looking for .gch so we can support seamless |
| 132 | // replacement into a build system already set up to be generating |
| 133 | // .gch files. |
Daniel Dunbar | cdd9686 | 2009-11-25 11:53:23 +0000 | [diff] [blame] | 134 | for (arg_iterator it = Args.filtered_begin(options::OPT_clang_i_Group), |
| 135 | ie = Args.filtered_end(); it != ie; ++it) { |
| 136 | const Arg *A = it; |
Daniel Dunbar | c21c485 | 2009-04-08 23:54:23 +0000 | [diff] [blame] | 137 | |
| 138 | if (A->getOption().matches(options::OPT_include)) { |
Daniel Dunbar | 0ebd932 | 2009-10-15 20:02:44 +0000 | [diff] [blame] | 139 | // Use PCH if the user requested it, except for C++ (for now). |
| 140 | bool UsePCH = D.CCCUsePCH; |
| 141 | if (types::isCXX(Inputs[0].getType())) |
| 142 | UsePCH = false; |
| 143 | |
Daniel Dunbar | c21c485 | 2009-04-08 23:54:23 +0000 | [diff] [blame] | 144 | bool FoundPTH = false; |
Douglas Gregor | df91ef3 | 2009-04-18 00:34:01 +0000 | [diff] [blame] | 145 | bool FoundPCH = false; |
Daniel Dunbar | c21c485 | 2009-04-08 23:54:23 +0000 | [diff] [blame] | 146 | llvm::sys::Path P(A->getValue(Args)); |
Daniel Dunbar | 0ebd932 | 2009-10-15 20:02:44 +0000 | [diff] [blame] | 147 | if (UsePCH) { |
Douglas Gregor | df91ef3 | 2009-04-18 00:34:01 +0000 | [diff] [blame] | 148 | P.appendSuffix("pch"); |
Daniel Dunbar | c21c485 | 2009-04-08 23:54:23 +0000 | [diff] [blame] | 149 | if (P.exists()) |
Douglas Gregor | df91ef3 | 2009-04-18 00:34:01 +0000 | [diff] [blame] | 150 | FoundPCH = true; |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 151 | else |
Douglas Gregor | df91ef3 | 2009-04-18 00:34:01 +0000 | [diff] [blame] | 152 | P.eraseSuffix(); |
Daniel Dunbar | c21c485 | 2009-04-08 23:54:23 +0000 | [diff] [blame] | 153 | } |
| 154 | |
Douglas Gregor | df91ef3 | 2009-04-18 00:34:01 +0000 | [diff] [blame] | 155 | if (!FoundPCH) { |
| 156 | P.appendSuffix("pth"); |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 157 | if (P.exists()) |
Douglas Gregor | df91ef3 | 2009-04-18 00:34:01 +0000 | [diff] [blame] | 158 | FoundPTH = true; |
| 159 | else |
| 160 | P.eraseSuffix(); |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 161 | } |
| 162 | |
Douglas Gregor | df91ef3 | 2009-04-18 00:34:01 +0000 | [diff] [blame] | 163 | if (!FoundPCH && !FoundPTH) { |
| 164 | P.appendSuffix("gch"); |
| 165 | if (P.exists()) { |
Daniel Dunbar | 0ebd932 | 2009-10-15 20:02:44 +0000 | [diff] [blame] | 166 | FoundPCH = UsePCH; |
| 167 | FoundPTH = !UsePCH; |
Douglas Gregor | df91ef3 | 2009-04-18 00:34:01 +0000 | [diff] [blame] | 168 | } |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 169 | else |
Douglas Gregor | df91ef3 | 2009-04-18 00:34:01 +0000 | [diff] [blame] | 170 | P.eraseSuffix(); |
| 171 | } |
| 172 | |
| 173 | if (FoundPCH || FoundPTH) { |
Daniel Dunbar | c21c485 | 2009-04-08 23:54:23 +0000 | [diff] [blame] | 174 | A->claim(); |
Daniel Dunbar | 0ebd932 | 2009-10-15 20:02:44 +0000 | [diff] [blame] | 175 | if (UsePCH) |
Douglas Gregor | df91ef3 | 2009-04-18 00:34:01 +0000 | [diff] [blame] | 176 | CmdArgs.push_back("-include-pch"); |
| 177 | else |
| 178 | CmdArgs.push_back("-include-pth"); |
Daniel Dunbar | 8813764 | 2009-09-09 22:32:48 +0000 | [diff] [blame] | 179 | CmdArgs.push_back(Args.MakeArgString(P.str())); |
Daniel Dunbar | c21c485 | 2009-04-08 23:54:23 +0000 | [diff] [blame] | 180 | continue; |
| 181 | } |
| 182 | } |
| 183 | |
| 184 | // Not translated, render as usual. |
| 185 | A->claim(); |
| 186 | A->render(Args, CmdArgs); |
| 187 | } |
| 188 | |
| 189 | Args.AddAllArgs(CmdArgs, options::OPT_D, options::OPT_U); |
| 190 | Args.AddAllArgs(CmdArgs, options::OPT_I_Group, options::OPT_F); |
| 191 | |
| 192 | // Add -Wp, and -Xassembler if using the preprocessor. |
| 193 | |
| 194 | // FIXME: There is a very unfortunate problem here, some troubled |
| 195 | // souls abuse -Wp, to pass preprocessor options in gcc syntax. To |
| 196 | // really support that we would have to parse and then translate |
| 197 | // those options. :( |
| 198 | Args.AddAllArgValues(CmdArgs, options::OPT_Wp_COMMA, |
| 199 | options::OPT_Xpreprocessor); |
Daniel Dunbar | 607d7f6 | 2009-10-29 01:53:44 +0000 | [diff] [blame] | 200 | |
| 201 | // -I- is a deprecated GCC feature, reject it. |
| 202 | if (Arg *A = Args.getLastArg(options::OPT_I_)) |
| 203 | D.Diag(clang::diag::err_drv_I_dash_not_supported) << A->getAsString(Args); |
Daniel Dunbar | c21c485 | 2009-04-08 23:54:23 +0000 | [diff] [blame] | 204 | } |
| 205 | |
Daniel Dunbar | 728a512 | 2009-09-10 06:49:20 +0000 | [diff] [blame] | 206 | /// getARMTargetCPU - Get the (LLVM) name of the ARM cpu we are targetting. |
| 207 | // |
| 208 | // FIXME: tblgen this. |
Daniel Dunbar | a31100e | 2009-11-20 22:21:52 +0000 | [diff] [blame] | 209 | static const char *getARMTargetCPU(const ArgList &Args) { |
Daniel Dunbar | 728a512 | 2009-09-10 06:49:20 +0000 | [diff] [blame] | 210 | // FIXME: Warn on inconsistent use of -mcpu and -march. |
Daniel Dunbar | b163ef7 | 2009-09-10 04:57:17 +0000 | [diff] [blame] | 211 | |
| 212 | // If we have -mcpu=, use that. |
| 213 | if (Arg *A = Args.getLastArg(options::OPT_mcpu_EQ)) |
| 214 | return A->getValue(Args); |
| 215 | |
| 216 | // Otherwise, if we have -march= choose the base CPU for that arch. |
| 217 | if (Arg *A = Args.getLastArg(options::OPT_march_EQ)) { |
| 218 | llvm::StringRef MArch = A->getValue(Args); |
| 219 | |
| 220 | if (MArch == "armv2" || MArch == "armv2a") |
| 221 | return "arm2"; |
| 222 | if (MArch == "armv3") |
| 223 | return "arm6"; |
| 224 | if (MArch == "armv3m") |
| 225 | return "arm7m"; |
| 226 | if (MArch == "armv4" || MArch == "armv4t") |
| 227 | return "arm7tdmi"; |
| 228 | if (MArch == "armv5" || MArch == "armv5t") |
| 229 | return "arm10tdmi"; |
| 230 | if (MArch == "armv5e" || MArch == "armv5te") |
| 231 | return "arm1026ejs"; |
| 232 | if (MArch == "armv5tej") |
| 233 | return "arm926ejs"; |
| 234 | if (MArch == "armv6" || MArch == "armv6k") |
| 235 | return "arm1136jf-s"; |
| 236 | if (MArch == "armv6j") |
| 237 | return "arm1136j-s"; |
| 238 | if (MArch == "armv6z" || MArch == "armv6zk") |
| 239 | return "arm1176jzf-s"; |
| 240 | if (MArch == "armv6t2") |
| 241 | return "arm1156t2-s"; |
| 242 | if (MArch == "armv7" || MArch == "armv7a" || MArch == "armv7-a") |
| 243 | return "cortex-a8"; |
| 244 | if (MArch == "armv7r" || MArch == "armv7-r") |
| 245 | return "cortex-r4"; |
| 246 | if (MArch == "armv7m" || MArch == "armv7-m") |
| 247 | return "cortex-m3"; |
| 248 | if (MArch == "ep9312") |
| 249 | return "ep9312"; |
| 250 | if (MArch == "iwmmxt") |
| 251 | return "iwmmxt"; |
| 252 | if (MArch == "xscale") |
| 253 | return "xscale"; |
| 254 | } |
| 255 | |
| 256 | // Otherwise return the most base CPU LLVM supports. |
| 257 | return "arm7tdmi"; |
| 258 | } |
| 259 | |
Daniel Dunbar | 1d65e4b | 2009-09-10 22:59:51 +0000 | [diff] [blame] | 260 | /// getLLVMArchSuffixForARM - Get the LLVM arch name to use for a particular |
Daniel Dunbar | 728a512 | 2009-09-10 06:49:20 +0000 | [diff] [blame] | 261 | /// CPU. |
| 262 | // |
| 263 | // FIXME: This is redundant with -mcpu, why does LLVM use this. |
| 264 | // FIXME: tblgen this, or kill it! |
Daniel Dunbar | 1d65e4b | 2009-09-10 22:59:51 +0000 | [diff] [blame] | 265 | static const char *getLLVMArchSuffixForARM(llvm::StringRef CPU) { |
Daniel Dunbar | 728a512 | 2009-09-10 06:49:20 +0000 | [diff] [blame] | 266 | if (CPU == "arm7tdmi" || CPU == "arm7tdmi-s" || CPU == "arm710t" || |
| 267 | CPU == "arm720t" || CPU == "arm9" || CPU == "arm9tdmi" || |
| 268 | CPU == "arm920" || CPU == "arm920t" || CPU == "arm922t" || |
| 269 | CPU == "arm940t" || CPU == "ep9312") |
Daniel Dunbar | 1d65e4b | 2009-09-10 22:59:51 +0000 | [diff] [blame] | 270 | return "v4t"; |
Daniel Dunbar | 728a512 | 2009-09-10 06:49:20 +0000 | [diff] [blame] | 271 | |
| 272 | if (CPU == "arm10tdmi" || CPU == "arm1020t") |
Daniel Dunbar | 1d65e4b | 2009-09-10 22:59:51 +0000 | [diff] [blame] | 273 | return "v5"; |
Daniel Dunbar | 728a512 | 2009-09-10 06:49:20 +0000 | [diff] [blame] | 274 | |
| 275 | if (CPU == "arm9e" || CPU == "arm926ej-s" || CPU == "arm946e-s" || |
| 276 | CPU == "arm966e-s" || CPU == "arm968e-s" || CPU == "arm10e" || |
| 277 | CPU == "arm1020e" || CPU == "arm1022e" || CPU == "xscale" || |
| 278 | CPU == "iwmmxt") |
Daniel Dunbar | 1d65e4b | 2009-09-10 22:59:51 +0000 | [diff] [blame] | 279 | return "v5e"; |
Daniel Dunbar | 728a512 | 2009-09-10 06:49:20 +0000 | [diff] [blame] | 280 | |
| 281 | if (CPU == "arm1136j-s" || CPU == "arm1136jf-s" || CPU == "arm1176jz-s" || |
| 282 | CPU == "arm1176jzf-s" || CPU == "mpcorenovfp" || CPU == "mpcore") |
Daniel Dunbar | 1d65e4b | 2009-09-10 22:59:51 +0000 | [diff] [blame] | 283 | return "v6"; |
Daniel Dunbar | 728a512 | 2009-09-10 06:49:20 +0000 | [diff] [blame] | 284 | |
| 285 | if (CPU == "arm1156t2-s" || CPU == "arm1156t2f-s") |
Daniel Dunbar | 1d65e4b | 2009-09-10 22:59:51 +0000 | [diff] [blame] | 286 | return "v6t2"; |
Daniel Dunbar | 728a512 | 2009-09-10 06:49:20 +0000 | [diff] [blame] | 287 | |
| 288 | if (CPU == "cortex-a8" || CPU == "cortex-a9") |
Daniel Dunbar | 1d65e4b | 2009-09-10 22:59:51 +0000 | [diff] [blame] | 289 | return "v7"; |
Daniel Dunbar | 728a512 | 2009-09-10 06:49:20 +0000 | [diff] [blame] | 290 | |
Daniel Dunbar | 1d65e4b | 2009-09-10 22:59:51 +0000 | [diff] [blame] | 291 | return ""; |
Daniel Dunbar | 728a512 | 2009-09-10 06:49:20 +0000 | [diff] [blame] | 292 | } |
| 293 | |
| 294 | /// getLLVMTriple - Get the LLVM triple to use for a particular toolchain, which |
| 295 | /// may depend on command line arguments. |
| 296 | static std::string getLLVMTriple(const ToolChain &TC, const ArgList &Args) { |
| 297 | switch (TC.getTriple().getArch()) { |
| 298 | default: |
| 299 | return TC.getTripleString(); |
| 300 | |
| 301 | case llvm::Triple::arm: |
| 302 | case llvm::Triple::thumb: { |
Daniel Dunbar | f4aa4f61 | 2009-09-11 01:14:50 +0000 | [diff] [blame] | 303 | // FIXME: Factor into subclasses. |
Daniel Dunbar | 728a512 | 2009-09-10 06:49:20 +0000 | [diff] [blame] | 304 | llvm::Triple Triple = TC.getTriple(); |
Daniel Dunbar | f4aa4f61 | 2009-09-11 01:14:50 +0000 | [diff] [blame] | 305 | |
| 306 | // Thumb2 is the default for V7 on Darwin. |
| 307 | // |
| 308 | // FIXME: Thumb should just be another -target-feaure, not in the triple. |
| 309 | llvm::StringRef Suffix = getLLVMArchSuffixForARM(getARMTargetCPU(Args)); |
| 310 | bool ThumbDefault = |
| 311 | (Suffix == "v7" && TC.getTriple().getOS() == llvm::Triple::Darwin); |
Daniel Dunbar | 1d65e4b | 2009-09-10 22:59:51 +0000 | [diff] [blame] | 312 | std::string ArchName = "arm"; |
Daniel Dunbar | f4aa4f61 | 2009-09-11 01:14:50 +0000 | [diff] [blame] | 313 | if (Args.hasFlag(options::OPT_mthumb, options::OPT_mno_thumb, ThumbDefault)) |
| 314 | ArchName = "thumb"; |
| 315 | Triple.setArchName(ArchName + Suffix.str()); |
| 316 | |
Daniel Dunbar | 728a512 | 2009-09-10 06:49:20 +0000 | [diff] [blame] | 317 | return Triple.getTriple(); |
| 318 | } |
| 319 | } |
| 320 | } |
| 321 | |
Daniel Dunbar | 1f95e65 | 2009-11-17 06:37:03 +0000 | [diff] [blame] | 322 | // FIXME: Move to target hook. |
| 323 | static bool isSignedCharDefault(const llvm::Triple &Triple) { |
| 324 | switch (Triple.getArch()) { |
| 325 | default: |
| 326 | return true; |
| 327 | |
| 328 | case llvm::Triple::ppc: |
| 329 | case llvm::Triple::ppc64: |
| 330 | if (Triple.getOS() == llvm::Triple::Darwin) |
| 331 | return true; |
| 332 | return false; |
| 333 | |
| 334 | case llvm::Triple::systemz: |
| 335 | return false; |
| 336 | } |
| 337 | } |
| 338 | |
Daniel Dunbar | b163ef7 | 2009-09-10 04:57:17 +0000 | [diff] [blame] | 339 | void Clang::AddARMTargetArgs(const ArgList &Args, |
| 340 | ArgStringList &CmdArgs) const { |
Daniel Dunbar | cbd1933 | 2009-09-10 23:00:09 +0000 | [diff] [blame] | 341 | const Driver &D = getToolChain().getHost().getDriver(); |
| 342 | |
Daniel Dunbar | 2030d8f | 2009-09-14 00:34:46 +0000 | [diff] [blame] | 343 | // Select the ABI to use. |
| 344 | // |
| 345 | // FIXME: Support -meabi. |
| 346 | const char *ABIName = 0; |
| 347 | if (Arg *A = Args.getLastArg(options::OPT_mabi_EQ)) { |
| 348 | ABIName = A->getValue(Args); |
| 349 | } else { |
| 350 | // Select the default based on the platform. |
| 351 | switch (getToolChain().getTriple().getOS()) { |
| 352 | // FIXME: Is this right for non-Darwin and non-Linux? |
| 353 | default: |
| 354 | ABIName = "aapcs"; |
| 355 | break; |
| 356 | |
| 357 | case llvm::Triple::Darwin: |
| 358 | ABIName = "apcs-gnu"; |
| 359 | break; |
| 360 | |
| 361 | case llvm::Triple::Linux: |
| 362 | ABIName = "aapcs-linux"; |
| 363 | break; |
| 364 | } |
| 365 | } |
| 366 | CmdArgs.push_back("-target-abi"); |
| 367 | CmdArgs.push_back(ABIName); |
| 368 | |
Daniel Dunbar | b163ef7 | 2009-09-10 04:57:17 +0000 | [diff] [blame] | 369 | // Set the CPU based on -march= and -mcpu=. |
Daniel Dunbar | 38b48af | 2009-12-18 06:30:12 +0000 | [diff] [blame] | 370 | CmdArgs.push_back("-target-cpu"); |
Daniel Dunbar | a31100e | 2009-11-20 22:21:52 +0000 | [diff] [blame] | 371 | CmdArgs.push_back(getARMTargetCPU(Args)); |
Daniel Dunbar | b163ef7 | 2009-09-10 04:57:17 +0000 | [diff] [blame] | 372 | |
Daniel Dunbar | cbd1933 | 2009-09-10 23:00:09 +0000 | [diff] [blame] | 373 | // Select the float ABI as determined by -msoft-float, -mhard-float, and |
| 374 | // -mfloat-abi=. |
| 375 | llvm::StringRef FloatABI; |
| 376 | if (Arg *A = Args.getLastArg(options::OPT_msoft_float, |
| 377 | options::OPT_mhard_float, |
| 378 | options::OPT_mfloat_abi_EQ)) { |
| 379 | if (A->getOption().matches(options::OPT_msoft_float)) |
| 380 | FloatABI = "soft"; |
| 381 | else if (A->getOption().matches(options::OPT_mhard_float)) |
| 382 | FloatABI = "hard"; |
| 383 | else { |
| 384 | FloatABI = A->getValue(Args); |
| 385 | if (FloatABI != "soft" && FloatABI != "softfp" && FloatABI != "hard") { |
| 386 | D.Diag(clang::diag::err_drv_invalid_mfloat_abi) |
| 387 | << A->getAsString(Args); |
| 388 | FloatABI = "soft"; |
| 389 | } |
| 390 | } |
| 391 | } |
| 392 | |
| 393 | // If unspecified, choose the default based on the platform. |
| 394 | if (FloatABI.empty()) { |
| 395 | // FIXME: This is wrong for non-Darwin, we don't have a mechanism yet for |
| 396 | // distinguishing things like linux-eabi vs linux-elf. |
| 397 | switch (getToolChain().getTriple().getOS()) { |
| 398 | case llvm::Triple::Darwin: { |
| 399 | // Darwin defaults to "softfp" for v6 and v7. |
| 400 | // |
| 401 | // FIXME: Factor out an ARM class so we can cache the arch somewhere. |
| 402 | llvm::StringRef ArchName = getLLVMArchSuffixForARM(getARMTargetCPU(Args)); |
| 403 | if (ArchName.startswith("v6") || ArchName.startswith("v7")) |
| 404 | FloatABI = "softfp"; |
| 405 | else |
| 406 | FloatABI = "soft"; |
| 407 | break; |
| 408 | } |
| 409 | |
| 410 | default: |
| 411 | // Assume "soft", but warn the user we are guessing. |
| 412 | FloatABI = "soft"; |
| 413 | D.Diag(clang::diag::warn_drv_assuming_mfloat_abi_is) << "soft"; |
| 414 | break; |
| 415 | } |
| 416 | } |
| 417 | |
| 418 | if (FloatABI == "soft") { |
| 419 | // Floating point operations and argument passing are soft. |
| 420 | // |
| 421 | // FIXME: This changes CPP defines, we need -target-soft-float. |
Daniel Dunbar | 3b31526 | 2009-11-30 08:42:00 +0000 | [diff] [blame] | 422 | CmdArgs.push_back("-msoft-float"); |
Daniel Dunbar | 87667aa | 2009-12-08 19:49:51 +0000 | [diff] [blame] | 423 | CmdArgs.push_back("-mfloat-abi"); |
| 424 | CmdArgs.push_back("soft"); |
Daniel Dunbar | cbd1933 | 2009-09-10 23:00:09 +0000 | [diff] [blame] | 425 | } else if (FloatABI == "softfp") { |
| 426 | // Floating point operations are hard, but argument passing is soft. |
Daniel Dunbar | 87667aa | 2009-12-08 19:49:51 +0000 | [diff] [blame] | 427 | CmdArgs.push_back("-mfloat-abi"); |
| 428 | CmdArgs.push_back("soft"); |
Daniel Dunbar | cbd1933 | 2009-09-10 23:00:09 +0000 | [diff] [blame] | 429 | } else { |
| 430 | // Floating point operations and argument passing are hard. |
| 431 | assert(FloatABI == "hard" && "Invalid float abi!"); |
Daniel Dunbar | 87667aa | 2009-12-08 19:49:51 +0000 | [diff] [blame] | 432 | CmdArgs.push_back("-mfloat-abi"); |
| 433 | CmdArgs.push_back("hard"); |
Daniel Dunbar | cbd1933 | 2009-09-10 23:00:09 +0000 | [diff] [blame] | 434 | } |
Daniel Dunbar | b163ef7 | 2009-09-10 04:57:17 +0000 | [diff] [blame] | 435 | } |
| 436 | |
Daniel Dunbar | 6acda16 | 2009-09-09 22:33:08 +0000 | [diff] [blame] | 437 | void Clang::AddX86TargetArgs(const ArgList &Args, |
| 438 | ArgStringList &CmdArgs) const { |
Daniel Dunbar | e6ad3f9 | 2009-09-10 22:59:57 +0000 | [diff] [blame] | 439 | if (!Args.hasFlag(options::OPT_mred_zone, |
| 440 | options::OPT_mno_red_zone, |
| 441 | true) || |
| 442 | Args.hasArg(options::OPT_mkernel) || |
| 443 | Args.hasArg(options::OPT_fapple_kext)) |
Daniel Dunbar | 66861e0 | 2009-11-20 22:21:36 +0000 | [diff] [blame] | 444 | CmdArgs.push_back("-disable-red-zone"); |
Daniel Dunbar | e6ad3f9 | 2009-09-10 22:59:57 +0000 | [diff] [blame] | 445 | |
Daniel Dunbar | e6ad3f9 | 2009-09-10 22:59:57 +0000 | [diff] [blame] | 446 | if (Args.hasFlag(options::OPT_msoft_float, |
| 447 | options::OPT_mno_soft_float, |
| 448 | false)) |
Daniel Dunbar | 66861e0 | 2009-11-20 22:21:36 +0000 | [diff] [blame] | 449 | CmdArgs.push_back("-no-implicit-float"); |
Daniel Dunbar | e6ad3f9 | 2009-09-10 22:59:57 +0000 | [diff] [blame] | 450 | |
Daniel Dunbar | f86fedd | 2009-11-14 22:04:54 +0000 | [diff] [blame] | 451 | const char *CPUName = 0; |
Daniel Dunbar | 6acda16 | 2009-09-09 22:33:08 +0000 | [diff] [blame] | 452 | if (const Arg *A = Args.getLastArg(options::OPT_march_EQ)) { |
Daniel Dunbar | f86fedd | 2009-11-14 22:04:54 +0000 | [diff] [blame] | 453 | if (llvm::StringRef(A->getValue(Args)) == "native") { |
| 454 | // FIXME: Reject attempts to use -march=native unless the target matches |
| 455 | // the host. |
| 456 | // |
| 457 | // FIXME: We should also incorporate the detected target features for use |
| 458 | // with -native. |
| 459 | std::string CPU = llvm::sys::getHostCPUName(); |
| 460 | if (!CPU.empty()) |
| 461 | CPUName = Args.MakeArgString(CPU); |
| 462 | } else |
| 463 | CPUName = A->getValue(Args); |
| 464 | } |
Daniel Dunbar | 6acda16 | 2009-09-09 22:33:08 +0000 | [diff] [blame] | 465 | |
Daniel Dunbar | f86fedd | 2009-11-14 22:04:54 +0000 | [diff] [blame] | 466 | // Select the default CPU if none was given (or detection failed). |
| 467 | if (!CPUName) { |
Daniel Dunbar | 6acda16 | 2009-09-09 22:33:08 +0000 | [diff] [blame] | 468 | // FIXME: Need target hooks. |
| 469 | if (memcmp(getToolChain().getOS().c_str(), "darwin", 6) == 0) { |
| 470 | if (getToolChain().getArchName() == "x86_64") |
Daniel Dunbar | f86fedd | 2009-11-14 22:04:54 +0000 | [diff] [blame] | 471 | CPUName = "core2"; |
Daniel Dunbar | 6acda16 | 2009-09-09 22:33:08 +0000 | [diff] [blame] | 472 | else if (getToolChain().getArchName() == "i386") |
Daniel Dunbar | f86fedd | 2009-11-14 22:04:54 +0000 | [diff] [blame] | 473 | CPUName = "yonah"; |
Daniel Dunbar | 6acda16 | 2009-09-09 22:33:08 +0000 | [diff] [blame] | 474 | } else { |
| 475 | if (getToolChain().getArchName() == "x86_64") |
Daniel Dunbar | f86fedd | 2009-11-14 22:04:54 +0000 | [diff] [blame] | 476 | CPUName = "x86-64"; |
Daniel Dunbar | 6acda16 | 2009-09-09 22:33:08 +0000 | [diff] [blame] | 477 | else if (getToolChain().getArchName() == "i386") |
Daniel Dunbar | f86fedd | 2009-11-14 22:04:54 +0000 | [diff] [blame] | 478 | CPUName = "pentium4"; |
Daniel Dunbar | 6acda16 | 2009-09-09 22:33:08 +0000 | [diff] [blame] | 479 | } |
| 480 | } |
| 481 | |
Daniel Dunbar | f86fedd | 2009-11-14 22:04:54 +0000 | [diff] [blame] | 482 | if (CPUName) { |
Daniel Dunbar | 38b48af | 2009-12-18 06:30:12 +0000 | [diff] [blame] | 483 | CmdArgs.push_back("-target-cpu"); |
Daniel Dunbar | f86fedd | 2009-11-14 22:04:54 +0000 | [diff] [blame] | 484 | CmdArgs.push_back(CPUName); |
| 485 | } |
| 486 | |
Daniel Dunbar | cdd9686 | 2009-11-25 11:53:23 +0000 | [diff] [blame] | 487 | for (arg_iterator it = Args.filtered_begin(options::OPT_m_x86_Features_Group), |
| 488 | ie = Args.filtered_end(); it != ie; ++it) { |
| 489 | llvm::StringRef Name = it->getOption().getName(); |
| 490 | it->claim(); |
Daniel Dunbar | 6acda16 | 2009-09-09 22:33:08 +0000 | [diff] [blame] | 491 | |
Daniel Dunbar | cdd9686 | 2009-11-25 11:53:23 +0000 | [diff] [blame] | 492 | // Skip over "-m". |
| 493 | assert(Name.startswith("-m") && "Invalid feature name."); |
| 494 | Name = Name.substr(2); |
Daniel Dunbar | 6acda16 | 2009-09-09 22:33:08 +0000 | [diff] [blame] | 495 | |
Daniel Dunbar | cdd9686 | 2009-11-25 11:53:23 +0000 | [diff] [blame] | 496 | bool IsNegative = Name.startswith("no-"); |
| 497 | if (IsNegative) |
| 498 | Name = Name.substr(3); |
Daniel Dunbar | 6acda16 | 2009-09-09 22:33:08 +0000 | [diff] [blame] | 499 | |
Daniel Dunbar | cdd9686 | 2009-11-25 11:53:23 +0000 | [diff] [blame] | 500 | CmdArgs.push_back("-target-feature"); |
| 501 | CmdArgs.push_back(Args.MakeArgString((IsNegative ? "-" : "+") + Name)); |
Daniel Dunbar | 6acda16 | 2009-09-09 22:33:08 +0000 | [diff] [blame] | 502 | } |
| 503 | } |
| 504 | |
Fariborz Jahanian | 85caf03 | 2009-10-01 20:30:46 +0000 | [diff] [blame] | 505 | static bool needsExceptions(const ArgList &Args, types::ID InputType, |
| 506 | const llvm::Triple &Triple) { |
Rafael Espindola | f759df0 | 2009-10-01 13:33:33 +0000 | [diff] [blame] | 507 | if (Arg *A = Args.getLastArg(options::OPT_fexceptions, |
| 508 | options::OPT_fno_exceptions)) { |
| 509 | if (A->getOption().matches(options::OPT_fexceptions)) |
| 510 | return true; |
| 511 | else |
| 512 | return false; |
| 513 | } |
| 514 | switch (InputType) { |
| 515 | case types::TY_CXX: case types::TY_CXXHeader: |
| 516 | case types::TY_PP_CXX: case types::TY_PP_CXXHeader: |
| 517 | case types::TY_ObjCXX: case types::TY_ObjCXXHeader: |
| 518 | case types::TY_PP_ObjCXX: case types::TY_PP_ObjCXXHeader: |
| 519 | return true; |
Fariborz Jahanian | 85caf03 | 2009-10-01 20:30:46 +0000 | [diff] [blame] | 520 | |
Rafael Espindola | f759df0 | 2009-10-01 13:33:33 +0000 | [diff] [blame] | 521 | case types::TY_ObjC: case types::TY_ObjCHeader: |
| 522 | case types::TY_PP_ObjC: case types::TY_PP_ObjCHeader: |
| 523 | if (Args.hasArg(options::OPT_fobjc_nonfragile_abi)) |
| 524 | return true; |
Fariborz Jahanian | 85caf03 | 2009-10-01 20:30:46 +0000 | [diff] [blame] | 525 | if (Triple.getOS() != llvm::Triple::Darwin) |
Rafael Espindola | f759df0 | 2009-10-01 13:33:33 +0000 | [diff] [blame] | 526 | return false; |
Fariborz Jahanian | 85caf03 | 2009-10-01 20:30:46 +0000 | [diff] [blame] | 527 | return (Triple.getDarwinMajorNumber() >= 9 && |
| 528 | Triple.getArch() == llvm::Triple::x86_64); |
| 529 | |
Rafael Espindola | f759df0 | 2009-10-01 13:33:33 +0000 | [diff] [blame] | 530 | default: |
| 531 | return false; |
| 532 | } |
| 533 | } |
| 534 | |
Daniel Dunbar | dd4fe00 | 2009-10-30 18:12:20 +0000 | [diff] [blame] | 535 | /// getEffectiveClangTriple - Get the "effective" target triple, which is the |
| 536 | /// triple for the target but with the OS version potentially modified for |
| 537 | /// Darwin's -mmacosx-version-min. |
| 538 | static std::string getEffectiveClangTriple(const Driver &D, |
| 539 | const ToolChain &TC, |
| 540 | const ArgList &Args) { |
| 541 | llvm::Triple Triple(getLLVMTriple(TC, Args)); |
| 542 | |
| 543 | if (Triple.getOS() != llvm::Triple::Darwin) { |
| 544 | // Diagnose use of -mmacosx-version-min and -miphoneos-version-min on |
| 545 | // non-Darwin. |
| 546 | if (Arg *A = Args.getLastArg(options::OPT_mmacosx_version_min_EQ, |
| 547 | options::OPT_miphoneos_version_min_EQ)) |
| 548 | D.Diag(clang::diag::err_drv_clang_unsupported) << A->getAsString(Args); |
| 549 | return Triple.getTriple(); |
| 550 | } |
| 551 | |
| 552 | // If -mmacosx-version-min=10.3.9 is specified, change the effective triple |
| 553 | // from being something like powerpc-apple-darwin9 to powerpc-apple-darwin7. |
| 554 | if (Arg *A = Args.getLastArg(options::OPT_mmacosx_version_min_EQ)) { |
| 555 | unsigned Major, Minor, Micro; |
| 556 | bool HadExtra; |
| 557 | if (!Driver::GetReleaseVersion(A->getValue(Args), Major, Minor, Micro, |
| 558 | HadExtra) || HadExtra || |
| 559 | Major != 10) |
| 560 | D.Diag(clang::diag::err_drv_invalid_version_number) |
| 561 | << A->getAsString(Args); |
| 562 | |
| 563 | // Mangle the MacOS version min number into the Darwin number: e.g. 10.3.9 |
| 564 | // is darwin7.9. |
| 565 | llvm::SmallString<16> Str; |
| 566 | llvm::raw_svector_ostream(Str) << "darwin" << Minor + 4 << "." << Micro; |
| 567 | Triple.setOSName(Str.str()); |
| 568 | } else if (Arg *A = Args.getLastArg(options::OPT_miphoneos_version_min_EQ)) { |
| 569 | unsigned Major, Minor, Micro; |
| 570 | bool HadExtra; |
| 571 | if (!Driver::GetReleaseVersion(A->getValue(Args), Major, Minor, Micro, |
| 572 | HadExtra) || HadExtra) |
| 573 | D.Diag(clang::diag::err_drv_invalid_version_number) |
| 574 | << A->getAsString(Args); |
| 575 | |
| 576 | // Mangle the iPhoneOS version number into the Darwin number: e.g. 2.0 is 2 |
| 577 | // -> 9.2.0. |
| 578 | llvm::SmallString<16> Str; |
| 579 | llvm::raw_svector_ostream(Str) << "darwin9." << Major << "." << Minor; |
| 580 | Triple.setOSName(Str.str()); |
| 581 | } |
| 582 | |
| 583 | return Triple.getTriple(); |
| 584 | } |
| 585 | |
Daniel Dunbar | 47ac7d2 | 2009-03-18 06:00:36 +0000 | [diff] [blame] | 586 | void Clang::ConstructJob(Compilation &C, const JobAction &JA, |
Daniel Dunbar | 871adcf | 2009-03-18 07:06:02 +0000 | [diff] [blame] | 587 | Job &Dest, |
| 588 | const InputInfo &Output, |
Daniel Dunbar | 62cf601 | 2009-03-18 06:07:59 +0000 | [diff] [blame] | 589 | const InputInfoList &Inputs, |
Daniel Dunbar | 1d46033 | 2009-03-18 10:01:51 +0000 | [diff] [blame] | 590 | const ArgList &Args, |
Daniel Dunbar | 47ac7d2 | 2009-03-18 06:00:36 +0000 | [diff] [blame] | 591 | const char *LinkingOutput) const { |
Daniel Dunbar | 5c1aaaf | 2009-04-07 19:18:24 +0000 | [diff] [blame] | 592 | const Driver &D = getToolChain().getHost().getDriver(); |
Daniel Dunbar | b488c1d | 2009-03-18 08:07:30 +0000 | [diff] [blame] | 593 | ArgStringList CmdArgs; |
| 594 | |
Daniel Dunbar | 077ba6a | 2009-03-31 20:53:55 +0000 | [diff] [blame] | 595 | assert(Inputs.size() == 1 && "Unable to handle multiple inputs."); |
| 596 | |
Daniel Dunbar | 8ff5b28 | 2009-12-11 23:00:49 +0000 | [diff] [blame] | 597 | // Invoke ourselves in -cc1 mode. |
| 598 | // |
| 599 | // FIXME: Implement custom jobs for internal actions. |
| 600 | CmdArgs.push_back("-cc1"); |
| 601 | |
Daniel Dunbar | dd4fe00 | 2009-10-30 18:12:20 +0000 | [diff] [blame] | 602 | // Add the "effective" target triple. |
Daniel Dunbar | af07f93 | 2009-03-31 17:35:15 +0000 | [diff] [blame] | 603 | CmdArgs.push_back("-triple"); |
Daniel Dunbar | dd4fe00 | 2009-10-30 18:12:20 +0000 | [diff] [blame] | 604 | std::string TripleStr = getEffectiveClangTriple(D, getToolChain(), Args); |
| 605 | CmdArgs.push_back(Args.MakeArgString(TripleStr)); |
Daniel Dunbar | 728a512 | 2009-09-10 06:49:20 +0000 | [diff] [blame] | 606 | |
Daniel Dunbar | dd4fe00 | 2009-10-30 18:12:20 +0000 | [diff] [blame] | 607 | // Select the appropriate action. |
Daniel Dunbar | 1d46033 | 2009-03-18 10:01:51 +0000 | [diff] [blame] | 608 | if (isa<AnalyzeJobAction>(JA)) { |
| 609 | assert(JA.getType() == types::TY_Plist && "Invalid output type."); |
| 610 | CmdArgs.push_back("-analyze"); |
| 611 | } else if (isa<PreprocessJobAction>(JA)) { |
Daniel Dunbar | cd8e4c4 | 2009-03-30 06:36:42 +0000 | [diff] [blame] | 612 | if (Output.getType() == types::TY_Dependencies) |
| 613 | CmdArgs.push_back("-Eonly"); |
| 614 | else |
| 615 | CmdArgs.push_back("-E"); |
Daniel Dunbar | 1d46033 | 2009-03-18 10:01:51 +0000 | [diff] [blame] | 616 | } else if (isa<PrecompileJobAction>(JA)) { |
Daniel Dunbar | 0ebd932 | 2009-10-15 20:02:44 +0000 | [diff] [blame] | 617 | // Use PCH if the user requested it, except for C++ (for now). |
| 618 | bool UsePCH = D.CCCUsePCH; |
| 619 | if (types::isCXX(Inputs[0].getType())) |
| 620 | UsePCH = false; |
| 621 | |
| 622 | if (UsePCH) |
Douglas Gregor | df91ef3 | 2009-04-18 00:34:01 +0000 | [diff] [blame] | 623 | CmdArgs.push_back("-emit-pch"); |
| 624 | else |
| 625 | CmdArgs.push_back("-emit-pth"); |
Daniel Dunbar | 1d46033 | 2009-03-18 10:01:51 +0000 | [diff] [blame] | 626 | } else { |
| 627 | assert(isa<CompileJobAction>(JA) && "Invalid action for clang tool."); |
Daniel Dunbar | c21c485 | 2009-04-08 23:54:23 +0000 | [diff] [blame] | 628 | |
Daniel Dunbar | 1d46033 | 2009-03-18 10:01:51 +0000 | [diff] [blame] | 629 | if (JA.getType() == types::TY_Nothing) { |
| 630 | CmdArgs.push_back("-fsyntax-only"); |
| 631 | } else if (JA.getType() == types::TY_LLVMAsm) { |
| 632 | CmdArgs.push_back("-emit-llvm"); |
| 633 | } else if (JA.getType() == types::TY_LLVMBC) { |
| 634 | CmdArgs.push_back("-emit-llvm-bc"); |
| 635 | } else if (JA.getType() == types::TY_PP_Asm) { |
Daniel Dunbar | e3b8d07 | 2009-09-17 00:47:53 +0000 | [diff] [blame] | 636 | CmdArgs.push_back("-S"); |
Daniel Dunbar | 5915fbf | 2009-09-01 16:57:46 +0000 | [diff] [blame] | 637 | } else if (JA.getType() == types::TY_AST) { |
| 638 | CmdArgs.push_back("-emit-pch"); |
Daniel Dunbar | 1d46033 | 2009-03-18 10:01:51 +0000 | [diff] [blame] | 639 | } |
Daniel Dunbar | b488c1d | 2009-03-18 08:07:30 +0000 | [diff] [blame] | 640 | } |
| 641 | |
Daniel Dunbar | 1d46033 | 2009-03-18 10:01:51 +0000 | [diff] [blame] | 642 | // The make clang go fast button. |
| 643 | CmdArgs.push_back("-disable-free"); |
| 644 | |
Daniel Dunbar | c9abc04 | 2009-04-08 05:11:16 +0000 | [diff] [blame] | 645 | // Set the main file name, so that debug info works even with |
| 646 | // -save-temps. |
| 647 | CmdArgs.push_back("-main-file-name"); |
| 648 | CmdArgs.push_back(darwin::CC1::getBaseInputName(Args, Inputs)); |
| 649 | |
Daniel Dunbar | 3bbc753 | 2009-04-08 18:03:55 +0000 | [diff] [blame] | 650 | // Some flags which affect the language (via preprocessor |
| 651 | // defines). See darwin::CC1::AddCPPArgs. |
| 652 | if (Args.hasArg(options::OPT_static)) |
| 653 | CmdArgs.push_back("-static-define"); |
| 654 | |
Daniel Dunbar | 1d46033 | 2009-03-18 10:01:51 +0000 | [diff] [blame] | 655 | if (isa<AnalyzeJobAction>(JA)) { |
Ted Kremenek | b8bb3e7 | 2009-09-25 05:55:59 +0000 | [diff] [blame] | 656 | // Enable region store model by default. |
| 657 | CmdArgs.push_back("-analyzer-store=region"); |
| 658 | |
Ted Kremenek | b40d06d | 2009-12-07 22:26:14 +0000 | [diff] [blame] | 659 | // Treat blocks as analysis entry points. |
| 660 | CmdArgs.push_back("-analyzer-opt-analyze-nested-blocks"); |
| 661 | |
Daniel Dunbar | 1d46033 | 2009-03-18 10:01:51 +0000 | [diff] [blame] | 662 | // Add default argument set. |
Daniel Dunbar | d8fc0f2 | 2009-05-22 00:38:15 +0000 | [diff] [blame] | 663 | if (!Args.hasArg(options::OPT__analyzer_no_default_checks)) { |
| 664 | CmdArgs.push_back("-warn-dead-stores"); |
Ted Kremenek | 1172751 | 2009-07-24 20:03:11 +0000 | [diff] [blame] | 665 | CmdArgs.push_back("-warn-security-syntactic"); |
Daniel Dunbar | d8fc0f2 | 2009-05-22 00:38:15 +0000 | [diff] [blame] | 666 | CmdArgs.push_back("-checker-cfref"); |
| 667 | CmdArgs.push_back("-analyzer-eagerly-assume"); |
| 668 | CmdArgs.push_back("-warn-objc-methodsigs"); |
| 669 | // Do not enable the missing -dealloc check. |
| 670 | // '-warn-objc-missing-dealloc', |
| 671 | CmdArgs.push_back("-warn-objc-unused-ivars"); |
| 672 | } |
Daniel Dunbar | c21c485 | 2009-04-08 23:54:23 +0000 | [diff] [blame] | 673 | |
Daniel Dunbar | d8fc0f2 | 2009-05-22 00:38:15 +0000 | [diff] [blame] | 674 | // Set the output format. The default is plist, for (lame) historical |
| 675 | // reasons. |
| 676 | CmdArgs.push_back("-analyzer-output"); |
| 677 | if (Arg *A = Args.getLastArg(options::OPT__analyzer_output)) |
| 678 | CmdArgs.push_back(A->getValue(Args)); |
| 679 | else |
| 680 | CmdArgs.push_back("plist"); |
Daniel Dunbar | 1d46033 | 2009-03-18 10:01:51 +0000 | [diff] [blame] | 681 | |
| 682 | // Add -Xanalyzer arguments when running as analyzer. |
| 683 | Args.AddAllArgValues(CmdArgs, options::OPT_Xanalyzer); |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 684 | } |
| 685 | |
Daniel Dunbar | e2fd664 | 2009-09-10 01:21:12 +0000 | [diff] [blame] | 686 | CheckCodeGenerationOptions(D, Args); |
| 687 | |
Daniel Dunbar | bc85be8 | 2009-04-29 18:32:25 +0000 | [diff] [blame] | 688 | // Perform argument translation for LLVM backend. This |
| 689 | // takes some care in reconciling with llvm-gcc. The |
| 690 | // issue is that llvm-gcc translates these options based on |
| 691 | // the values in cc1, whereas we are processing based on |
| 692 | // the driver arguments. |
Daniel Dunbar | c21c485 | 2009-04-08 23:54:23 +0000 | [diff] [blame] | 693 | |
Daniel Dunbar | bc85be8 | 2009-04-29 18:32:25 +0000 | [diff] [blame] | 694 | // This comes from the default translation the driver + cc1 |
| 695 | // would do to enable flag_pic. |
| 696 | // |
| 697 | // FIXME: Centralize this code. |
| 698 | bool PICEnabled = (Args.hasArg(options::OPT_fPIC) || |
| 699 | Args.hasArg(options::OPT_fpic) || |
| 700 | Args.hasArg(options::OPT_fPIE) || |
| 701 | Args.hasArg(options::OPT_fpie)); |
| 702 | bool PICDisabled = (Args.hasArg(options::OPT_mkernel) || |
| 703 | Args.hasArg(options::OPT_static)); |
| 704 | const char *Model = getToolChain().GetForcedPicModel(); |
| 705 | if (!Model) { |
| 706 | if (Args.hasArg(options::OPT_mdynamic_no_pic)) |
| 707 | Model = "dynamic-no-pic"; |
| 708 | else if (PICDisabled) |
| 709 | Model = "static"; |
| 710 | else if (PICEnabled) |
| 711 | Model = "pic"; |
Daniel Dunbar | 1d46033 | 2009-03-18 10:01:51 +0000 | [diff] [blame] | 712 | else |
Daniel Dunbar | bc85be8 | 2009-04-29 18:32:25 +0000 | [diff] [blame] | 713 | Model = getToolChain().GetDefaultRelocationModel(); |
Daniel Dunbar | 1d46033 | 2009-03-18 10:01:51 +0000 | [diff] [blame] | 714 | } |
Daniel Dunbar | f219e7c | 2009-11-29 07:18:39 +0000 | [diff] [blame] | 715 | if (llvm::StringRef(Model) != "pic") { |
| 716 | CmdArgs.push_back("-mrelocation-model"); |
| 717 | CmdArgs.push_back(Model); |
| 718 | } |
Daniel Dunbar | bc85be8 | 2009-04-29 18:32:25 +0000 | [diff] [blame] | 719 | |
| 720 | // Infer the __PIC__ value. |
| 721 | // |
| 722 | // FIXME: This isn't quite right on Darwin, which always sets |
| 723 | // __PIC__=2. |
| 724 | if (strcmp(Model, "pic") == 0 || strcmp(Model, "dynamic-no-pic") == 0) { |
Daniel Dunbar | 7674352 | 2009-11-29 02:39:08 +0000 | [diff] [blame] | 725 | CmdArgs.push_back("-pic-level"); |
| 726 | CmdArgs.push_back(Args.hasArg(options::OPT_fPIC) ? "2" : "1"); |
Daniel Dunbar | bc85be8 | 2009-04-29 18:32:25 +0000 | [diff] [blame] | 727 | } |
Tanya Lattner | 59876c2 | 2009-11-04 01:18:09 +0000 | [diff] [blame] | 728 | if (!Args.hasFlag(options::OPT_fmerge_all_constants, |
| 729 | options::OPT_fno_merge_all_constants)) |
Daniel Dunbar | 66861e0 | 2009-11-20 22:21:36 +0000 | [diff] [blame] | 730 | CmdArgs.push_back("-no-merge-all-constants"); |
Daniel Dunbar | 6bea73b | 2009-09-16 06:17:29 +0000 | [diff] [blame] | 731 | |
Daniel Dunbar | f219e7c | 2009-11-29 07:18:39 +0000 | [diff] [blame] | 732 | // LLVM Code Generator Options. |
| 733 | |
| 734 | // FIXME: Set --enable-unsafe-fp-math. |
| 735 | if (Args.hasFlag(options::OPT_fno_omit_frame_pointer, |
| 736 | options::OPT_fomit_frame_pointer)) |
| 737 | CmdArgs.push_back("-mdisable-fp-elim"); |
| 738 | if (!Args.hasFlag(options::OPT_fzero_initialized_in_bss, |
| 739 | options::OPT_fno_zero_initialized_in_bss)) |
| 740 | CmdArgs.push_back("-mno-zero-initialized-in-bss"); |
| 741 | if (Args.hasArg(options::OPT_dA) || Args.hasArg(options::OPT_fverbose_asm)) |
| 742 | CmdArgs.push_back("-masm-verbose"); |
| 743 | if (Args.hasArg(options::OPT_fdebug_pass_structure)) { |
| 744 | CmdArgs.push_back("-mdebug-pass"); |
| 745 | CmdArgs.push_back("Structure"); |
| 746 | } |
| 747 | if (Args.hasArg(options::OPT_fdebug_pass_arguments)) { |
| 748 | CmdArgs.push_back("-mdebug-pass"); |
| 749 | CmdArgs.push_back("Arguments"); |
| 750 | } |
| 751 | |
Daniel Dunbar | 6bea73b | 2009-09-16 06:17:29 +0000 | [diff] [blame] | 752 | // This is a coarse approximation of what llvm-gcc actually does, both |
| 753 | // -fasynchronous-unwind-tables and -fnon-call-exceptions interact in more |
| 754 | // complicated ways. |
| 755 | bool AsynchronousUnwindTables = |
| 756 | Args.hasFlag(options::OPT_fasynchronous_unwind_tables, |
| 757 | options::OPT_fno_asynchronous_unwind_tables, |
| 758 | getToolChain().IsUnwindTablesDefault() && |
| 759 | !Args.hasArg(options::OPT_mkernel)); |
| 760 | if (Args.hasFlag(options::OPT_funwind_tables, options::OPT_fno_unwind_tables, |
| 761 | AsynchronousUnwindTables)) |
Daniel Dunbar | f219e7c | 2009-11-29 07:18:39 +0000 | [diff] [blame] | 762 | CmdArgs.push_back("-munwind-tables"); |
| 763 | |
| 764 | if (Arg *A = Args.getLastArg(options::OPT_flimited_precision_EQ)) { |
| 765 | CmdArgs.push_back("-mlimit-float-precision"); |
| 766 | CmdArgs.push_back(A->getValue(Args)); |
| 767 | } |
Daniel Dunbar | bc85be8 | 2009-04-29 18:32:25 +0000 | [diff] [blame] | 768 | |
Daniel Dunbar | 868bd0a | 2009-05-06 03:16:41 +0000 | [diff] [blame] | 769 | // FIXME: Handle -mtune=. |
| 770 | (void) Args.hasArg(options::OPT_mtune_EQ); |
Daniel Dunbar | bc85be8 | 2009-04-29 18:32:25 +0000 | [diff] [blame] | 771 | |
Benjamin Kramer | 8e9ef0d | 2009-08-05 14:30:52 +0000 | [diff] [blame] | 772 | if (Arg *A = Args.getLastArg(options::OPT_mcmodel_EQ)) { |
Daniel Dunbar | f219e7c | 2009-11-29 07:18:39 +0000 | [diff] [blame] | 773 | CmdArgs.push_back("-mcode-model"); |
Benjamin Kramer | 8e9ef0d | 2009-08-05 14:30:52 +0000 | [diff] [blame] | 774 | CmdArgs.push_back(A->getValue(Args)); |
| 775 | } |
| 776 | |
Daniel Dunbar | 6acda16 | 2009-09-09 22:33:08 +0000 | [diff] [blame] | 777 | // Add target specific cpu and features flags. |
| 778 | switch(getToolChain().getTriple().getArch()) { |
| 779 | default: |
| 780 | break; |
Daniel Dunbar | 868bd0a | 2009-05-06 03:16:41 +0000 | [diff] [blame] | 781 | |
Daniel Dunbar | b163ef7 | 2009-09-10 04:57:17 +0000 | [diff] [blame] | 782 | case llvm::Triple::arm: |
| 783 | case llvm::Triple::thumb: |
| 784 | AddARMTargetArgs(Args, CmdArgs); |
| 785 | break; |
| 786 | |
Daniel Dunbar | 6acda16 | 2009-09-09 22:33:08 +0000 | [diff] [blame] | 787 | case llvm::Triple::x86: |
| 788 | case llvm::Triple::x86_64: |
| 789 | AddX86TargetArgs(Args, CmdArgs); |
| 790 | break; |
Daniel Dunbar | bc85be8 | 2009-04-29 18:32:25 +0000 | [diff] [blame] | 791 | } |
| 792 | |
Daniel Dunbar | 53e8484 | 2009-11-19 04:55:23 +0000 | [diff] [blame] | 793 | // -fmath-errno is default. |
| 794 | if (!Args.hasFlag(options::OPT_fmath_errno, |
Daniel Dunbar | bc85be8 | 2009-04-29 18:32:25 +0000 | [diff] [blame] | 795 | options::OPT_fno_math_errno, |
| 796 | getToolChain().IsMathErrnoDefault())) |
Daniel Dunbar | 53e8484 | 2009-11-19 04:55:23 +0000 | [diff] [blame] | 797 | CmdArgs.push_back("-fno-math-errno"); |
Daniel Dunbar | bc85be8 | 2009-04-29 18:32:25 +0000 | [diff] [blame] | 798 | |
Daniel Dunbar | bc85be8 | 2009-04-29 18:32:25 +0000 | [diff] [blame] | 799 | Arg *Unsupported; |
| 800 | if ((Unsupported = Args.getLastArg(options::OPT_MG)) || |
Daniel Dunbar | 95a0da7 | 2009-05-13 19:05:04 +0000 | [diff] [blame] | 801 | (Unsupported = Args.getLastArg(options::OPT_MQ)) || |
Ted Kremenek | 6feaf57 | 2009-12-12 00:38:18 +0000 | [diff] [blame] | 802 | (Unsupported = Args.getLastArg(options::OPT_iframework)) || |
| 803 | (Unsupported = Args.getLastArg(options::OPT_fshort_enums))) |
Daniel Dunbar | e027a4b | 2009-05-22 19:02:20 +0000 | [diff] [blame] | 804 | D.Diag(clang::diag::err_drv_clang_unsupported) |
Daniel Dunbar | bc85be8 | 2009-04-29 18:32:25 +0000 | [diff] [blame] | 805 | << Unsupported->getOption().getName(); |
Daniel Dunbar | 1d46033 | 2009-03-18 10:01:51 +0000 | [diff] [blame] | 806 | |
| 807 | Args.AddAllArgs(CmdArgs, options::OPT_v); |
Daniel Dunbar | 1d46033 | 2009-03-18 10:01:51 +0000 | [diff] [blame] | 808 | Args.AddLastArg(CmdArgs, options::OPT_P); |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 809 | Args.AddLastArg(CmdArgs, options::OPT_print_ivar_layout); |
Daniel Dunbar | 1d46033 | 2009-03-18 10:01:51 +0000 | [diff] [blame] | 810 | |
| 811 | // Special case debug options to only pass -g to clang. This is |
| 812 | // wrong. |
| 813 | if (Args.hasArg(options::OPT_g_Group)) |
| 814 | CmdArgs.push_back("-g"); |
| 815 | |
| 816 | Args.AddLastArg(CmdArgs, options::OPT_nostdinc); |
Rafael Espindola | 8d737cc | 2009-10-26 13:36:57 +0000 | [diff] [blame] | 817 | Args.AddLastArg(CmdArgs, options::OPT_nobuiltininc); |
Daniel Dunbar | 1d46033 | 2009-03-18 10:01:51 +0000 | [diff] [blame] | 818 | |
Daniel Dunbar | 5f12232 | 2009-12-15 01:02:52 +0000 | [diff] [blame] | 819 | // Pass the path to compiler resource files. |
| 820 | // |
| 821 | // FIXME: Get this from a configuration object. |
| 822 | llvm::sys::Path P(D.Dir); |
| 823 | P.eraseComponent(); // Remove /bin from foo/bin |
| 824 | P.appendComponent("lib"); |
| 825 | P.appendComponent("clang"); |
| 826 | P.appendComponent(CLANG_VERSION_STRING); |
| 827 | CmdArgs.push_back("-resource-dir"); |
| 828 | CmdArgs.push_back(Args.MakeArgString(P.str())); |
Daniel Dunbar | 2ac9fc2 | 2009-04-07 21:42:00 +0000 | [diff] [blame] | 829 | |
Daniel Dunbar | c21c485 | 2009-04-08 23:54:23 +0000 | [diff] [blame] | 830 | // Add preprocessing options like -I, -D, etc. if we are using the |
| 831 | // preprocessor. |
| 832 | // |
| 833 | // FIXME: Support -fpreprocessed |
| 834 | types::ID InputType = Inputs[0].getType(); |
| 835 | if (types::getPreprocessedType(InputType) != types::TY_INVALID) |
Douglas Gregor | df91ef3 | 2009-04-18 00:34:01 +0000 | [diff] [blame] | 836 | AddPreprocessingOptions(D, Args, CmdArgs, Output, Inputs); |
Daniel Dunbar | 1d46033 | 2009-03-18 10:01:51 +0000 | [diff] [blame] | 837 | |
Daniel Dunbar | 20f0eac | 2009-09-17 06:53:36 +0000 | [diff] [blame] | 838 | // Manually translate -O to -O2 and -O4 to -O3; let clang reject |
Daniel Dunbar | 337a627 | 2009-03-24 20:17:30 +0000 | [diff] [blame] | 839 | // others. |
| 840 | if (Arg *A = Args.getLastArg(options::OPT_O_Group)) { |
Daniel Dunbar | b827a05 | 2009-11-19 03:26:40 +0000 | [diff] [blame] | 841 | if (A->getOption().matches(options::OPT_O4)) |
Daniel Dunbar | 337a627 | 2009-03-24 20:17:30 +0000 | [diff] [blame] | 842 | CmdArgs.push_back("-O3"); |
| 843 | else if (A->getValue(Args)[0] == '\0') |
Daniel Dunbar | 20f0eac | 2009-09-17 06:53:36 +0000 | [diff] [blame] | 844 | CmdArgs.push_back("-O2"); |
Daniel Dunbar | 1d46033 | 2009-03-18 10:01:51 +0000 | [diff] [blame] | 845 | else |
Daniel Dunbar | 5697aa0 | 2009-03-18 23:39:35 +0000 | [diff] [blame] | 846 | A->render(Args, CmdArgs); |
Daniel Dunbar | 1d46033 | 2009-03-18 10:01:51 +0000 | [diff] [blame] | 847 | } |
| 848 | |
Daniel Dunbar | 6e8371e | 2009-10-29 02:24:45 +0000 | [diff] [blame] | 849 | Args.AddAllArgs(CmdArgs, options::OPT_W_Group); |
| 850 | Args.AddLastArg(CmdArgs, options::OPT_pedantic); |
| 851 | Args.AddLastArg(CmdArgs, options::OPT_pedantic_errors); |
Daniel Dunbar | 1d46033 | 2009-03-18 10:01:51 +0000 | [diff] [blame] | 852 | Args.AddLastArg(CmdArgs, options::OPT_w); |
Daniel Dunbar | d573d26 | 2009-04-07 22:13:21 +0000 | [diff] [blame] | 853 | |
| 854 | // Handle -{std, ansi, trigraphs} -- take the last of -{std, ansi} |
| 855 | // (-ansi is equivalent to -std=c89). |
| 856 | // |
| 857 | // If a std is supplied, only add -trigraphs if it follows the |
| 858 | // option. |
| 859 | if (Arg *Std = Args.getLastArg(options::OPT_std_EQ, options::OPT_ansi)) { |
| 860 | if (Std->getOption().matches(options::OPT_ansi)) |
Nuno Lopes | 528365d | 2009-10-16 14:28:06 +0000 | [diff] [blame] | 861 | if (types::isCXX(InputType)) |
Daniel Dunbar | 294691e | 2009-11-04 06:24:38 +0000 | [diff] [blame] | 862 | CmdArgs.push_back("-std=c++98"); |
Nuno Lopes | 528365d | 2009-10-16 14:28:06 +0000 | [diff] [blame] | 863 | else |
Daniel Dunbar | 294691e | 2009-11-04 06:24:38 +0000 | [diff] [blame] | 864 | CmdArgs.push_back("-std=c89"); |
Daniel Dunbar | d573d26 | 2009-04-07 22:13:21 +0000 | [diff] [blame] | 865 | else |
| 866 | Std->render(Args, CmdArgs); |
| 867 | |
| 868 | if (Arg *A = Args.getLastArg(options::OPT_trigraphs)) |
| 869 | if (A->getIndex() > Std->getIndex()) |
| 870 | A->render(Args, CmdArgs); |
Daniel Dunbar | a3ff202 | 2009-04-26 01:10:38 +0000 | [diff] [blame] | 871 | } else { |
| 872 | // Honor -std-default. |
| 873 | Args.AddAllArgsTranslated(CmdArgs, options::OPT_std_default_EQ, |
| 874 | "-std=", /*Joined=*/true); |
Daniel Dunbar | d573d26 | 2009-04-07 22:13:21 +0000 | [diff] [blame] | 875 | Args.AddLastArg(CmdArgs, options::OPT_trigraphs); |
Daniel Dunbar | a3ff202 | 2009-04-26 01:10:38 +0000 | [diff] [blame] | 876 | } |
Daniel Dunbar | c21c485 | 2009-04-08 23:54:23 +0000 | [diff] [blame] | 877 | |
Daniel Dunbar | 1d46033 | 2009-03-18 10:01:51 +0000 | [diff] [blame] | 878 | if (Arg *A = Args.getLastArg(options::OPT_ftemplate_depth_)) { |
| 879 | CmdArgs.push_back("-ftemplate-depth"); |
| 880 | CmdArgs.push_back(A->getValue(Args)); |
| 881 | } |
| 882 | |
Daniel Dunbar | e4bdae7 | 2009-11-19 04:00:53 +0000 | [diff] [blame] | 883 | if (Args.hasArg(options::OPT__relocatable_pch)) |
Daniel Dunbar | 66861e0 | 2009-11-20 22:21:36 +0000 | [diff] [blame] | 884 | CmdArgs.push_back("-relocatable-pch"); |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 885 | |
Daniel Dunbar | 294691e | 2009-11-04 06:24:38 +0000 | [diff] [blame] | 886 | if (Arg *A = Args.getLastArg(options::OPT_fconstant_string_class_EQ)) { |
| 887 | CmdArgs.push_back("-fconstant-string-class"); |
| 888 | CmdArgs.push_back(A->getValue(Args)); |
| 889 | } |
David Chisnall | 8a5a9aa | 2009-08-31 16:41:57 +0000 | [diff] [blame] | 890 | |
Daniel Dunbar | 55efe14 | 2009-11-04 06:24:47 +0000 | [diff] [blame] | 891 | // Pass -fmessage-length=. |
Daniel Dunbar | a28690e | 2009-11-30 08:40:54 +0000 | [diff] [blame] | 892 | CmdArgs.push_back("-fmessage-length"); |
Daniel Dunbar | 55efe14 | 2009-11-04 06:24:47 +0000 | [diff] [blame] | 893 | if (Arg *A = Args.getLastArg(options::OPT_fmessage_length_EQ)) { |
Daniel Dunbar | a28690e | 2009-11-30 08:40:54 +0000 | [diff] [blame] | 894 | CmdArgs.push_back(A->getValue(Args)); |
Daniel Dunbar | 55efe14 | 2009-11-04 06:24:47 +0000 | [diff] [blame] | 895 | } else { |
| 896 | // If -fmessage-length=N was not specified, determine whether this is a |
| 897 | // terminal and, if so, implicitly define -fmessage-length appropriately. |
| 898 | unsigned N = llvm::sys::Process::StandardErrColumns(); |
Daniel Dunbar | 55efe14 | 2009-11-04 06:24:47 +0000 | [diff] [blame] | 899 | CmdArgs.push_back(Args.MakeArgString(llvm::Twine(N))); |
| 900 | } |
| 901 | |
Daniel Dunbar | ba8d861 | 2009-12-03 18:42:11 +0000 | [diff] [blame] | 902 | if (const Arg *A = Args.getLastArg(options::OPT_fvisibility_EQ)) { |
| 903 | CmdArgs.push_back("-fvisibility"); |
| 904 | CmdArgs.push_back(A->getValue(Args)); |
| 905 | } |
| 906 | |
| 907 | // Forward -f (flag) options which we can pass directly. |
Mike Stump | 9c276ae | 2009-12-12 01:27:46 +0000 | [diff] [blame] | 908 | Args.AddLastArg(CmdArgs, options::OPT_fcatch_undefined_behavior); |
Daniel Dunbar | 3aaf082 | 2009-04-07 21:51:40 +0000 | [diff] [blame] | 909 | Args.AddLastArg(CmdArgs, options::OPT_femit_all_decls); |
Daniel Dunbar | 3aaf082 | 2009-04-07 21:51:40 +0000 | [diff] [blame] | 910 | Args.AddLastArg(CmdArgs, options::OPT_ffreestanding); |
| 911 | Args.AddLastArg(CmdArgs, options::OPT_fheinous_gnu_extensions); |
Daniel Dunbar | 3aaf082 | 2009-04-07 21:51:40 +0000 | [diff] [blame] | 912 | Args.AddLastArg(CmdArgs, options::OPT_flax_vector_conversions); |
Daniel Dunbar | 3aaf082 | 2009-04-07 21:51:40 +0000 | [diff] [blame] | 913 | Args.AddLastArg(CmdArgs, options::OPT_fno_caret_diagnostics); |
| 914 | Args.AddLastArg(CmdArgs, options::OPT_fno_show_column); |
| 915 | Args.AddLastArg(CmdArgs, options::OPT_fobjc_gc_only); |
| 916 | Args.AddLastArg(CmdArgs, options::OPT_fobjc_gc); |
Fariborz Jahanian | 34e6577 | 2009-05-22 20:17:16 +0000 | [diff] [blame] | 917 | Args.AddLastArg(CmdArgs, options::OPT_fobjc_sender_dependent_dispatch); |
Chris Lattner | 182e092 | 2009-04-21 05:34:31 +0000 | [diff] [blame] | 918 | Args.AddLastArg(CmdArgs, options::OPT_fdiagnostics_print_source_range_info); |
Daniel Dunbar | 3aaf082 | 2009-04-07 21:51:40 +0000 | [diff] [blame] | 919 | Args.AddLastArg(CmdArgs, options::OPT_ftime_report); |
| 920 | Args.AddLastArg(CmdArgs, options::OPT_ftrapv); |
Daniel Dunbar | 3aaf082 | 2009-04-07 21:51:40 +0000 | [diff] [blame] | 921 | Args.AddLastArg(CmdArgs, options::OPT_fwritable_strings); |
Daniel Dunbar | 1d46033 | 2009-03-18 10:01:51 +0000 | [diff] [blame] | 922 | |
Daniel Dunbar | 5345c39 | 2009-09-03 04:54:28 +0000 | [diff] [blame] | 923 | Args.AddLastArg(CmdArgs, options::OPT_pthread); |
| 924 | |
Daniel Dunbar | 9e5cc6b | 2009-11-17 08:07:36 +0000 | [diff] [blame] | 925 | // -stack-protector=0 is default. |
| 926 | unsigned StackProtectorLevel = 0; |
Bill Wendling | 45483f7 | 2009-06-28 07:36:13 +0000 | [diff] [blame] | 927 | if (Arg *A = Args.getLastArg(options::OPT_fno_stack_protector, |
| 928 | options::OPT_fstack_protector_all, |
| 929 | options::OPT_fstack_protector)) { |
Daniel Dunbar | 9e5cc6b | 2009-11-17 08:07:36 +0000 | [diff] [blame] | 930 | if (A->getOption().matches(options::OPT_fstack_protector)) |
| 931 | StackProtectorLevel = 1; |
| 932 | else if (A->getOption().matches(options::OPT_fstack_protector_all)) |
| 933 | StackProtectorLevel = 2; |
| 934 | } else |
| 935 | StackProtectorLevel = getToolChain().GetDefaultStackProtectorLevel(); |
| 936 | if (StackProtectorLevel) { |
| 937 | CmdArgs.push_back("-stack-protector"); |
| 938 | CmdArgs.push_back(Args.MakeArgString(llvm::Twine(StackProtectorLevel))); |
Bill Wendling | 45483f7 | 2009-06-28 07:36:13 +0000 | [diff] [blame] | 939 | } |
| 940 | |
Daniel Dunbar | 48d1ef7 | 2009-04-07 21:16:11 +0000 | [diff] [blame] | 941 | // Forward -f options with positive and negative forms; we translate |
| 942 | // these by hand. |
| 943 | |
Daniel Dunbar | 9e5cc6b | 2009-11-17 08:07:36 +0000 | [diff] [blame] | 944 | // -fbuiltin is default. |
Daniel Dunbar | 48d1ef7 | 2009-04-07 21:16:11 +0000 | [diff] [blame] | 945 | if (!Args.hasFlag(options::OPT_fbuiltin, options::OPT_fno_builtin)) |
Daniel Dunbar | 53e8484 | 2009-11-19 04:55:23 +0000 | [diff] [blame] | 946 | CmdArgs.push_back("-fno-builtin"); |
Daniel Dunbar | 48d1ef7 | 2009-04-07 21:16:11 +0000 | [diff] [blame] | 947 | |
Nuno Lopes | fc28448 | 2009-12-16 16:59:22 +0000 | [diff] [blame] | 948 | if (!Args.hasFlag(options::OPT_fassume_sane_operator_new, |
| 949 | options::OPT_fno_assume_sane_operator_new)) |
| 950 | CmdArgs.push_back("-fno-assume-sane-operator-new"); |
| 951 | |
Daniel Dunbar | 9e5cc6b | 2009-11-17 08:07:36 +0000 | [diff] [blame] | 952 | // -fblocks=0 is default. |
| 953 | if (Args.hasFlag(options::OPT_fblocks, options::OPT_fno_blocks, |
David Chisnall | 5e530af | 2009-11-17 19:33:30 +0000 | [diff] [blame] | 954 | getToolChain().IsBlocksDefault())) { |
| 955 | Args.AddLastArg(CmdArgs, options::OPT_fblock_introspection); |
Daniel Dunbar | 9e5cc6b | 2009-11-17 08:07:36 +0000 | [diff] [blame] | 956 | CmdArgs.push_back("-fblocks"); |
David Chisnall | 5e530af | 2009-11-17 19:33:30 +0000 | [diff] [blame] | 957 | } |
Daniel Dunbar | 48d1ef7 | 2009-04-07 21:16:11 +0000 | [diff] [blame] | 958 | |
Daniel Dunbar | 6d2eb4d | 2009-11-25 10:14:30 +0000 | [diff] [blame] | 959 | // -fexceptions=0 is default. |
Fariborz Jahanian | 85caf03 | 2009-10-01 20:30:46 +0000 | [diff] [blame] | 960 | if (needsExceptions(Args, InputType, getToolChain().getTriple())) |
Rafael Espindola | f759df0 | 2009-10-01 13:33:33 +0000 | [diff] [blame] | 961 | CmdArgs.push_back("-fexceptions"); |
Mike Stump | 738f8c2 | 2009-07-31 23:15:31 +0000 | [diff] [blame] | 962 | |
Daniel Dunbar | 0be42c4 | 2009-11-17 07:06:20 +0000 | [diff] [blame] | 963 | // -frtti is default. |
Mike Stump | 738f8c2 | 2009-07-31 23:15:31 +0000 | [diff] [blame] | 964 | if (!Args.hasFlag(options::OPT_frtti, options::OPT_fno_rtti)) |
Daniel Dunbar | 53e8484 | 2009-11-19 04:55:23 +0000 | [diff] [blame] | 965 | CmdArgs.push_back("-fno-rtti"); |
Mike Stump | 738f8c2 | 2009-07-31 23:15:31 +0000 | [diff] [blame] | 966 | |
Daniel Dunbar | 1f95e65 | 2009-11-17 06:37:03 +0000 | [diff] [blame] | 967 | // -fsigned-char is default. |
Daniel Dunbar | 6d2eb4d | 2009-11-25 10:14:30 +0000 | [diff] [blame] | 968 | if (!Args.hasFlag(options::OPT_fsigned_char, options::OPT_funsigned_char, |
Daniel Dunbar | 1f95e65 | 2009-11-17 06:37:03 +0000 | [diff] [blame] | 969 | isSignedCharDefault(getToolChain().getTriple()))) |
Daniel Dunbar | 7674352 | 2009-11-29 02:39:08 +0000 | [diff] [blame] | 970 | CmdArgs.push_back("-fno-signed-char"); |
Eli Friedman | 5a77973 | 2009-06-05 07:21:14 +0000 | [diff] [blame] | 971 | |
Daniel Dunbar | 0be42c4 | 2009-11-17 07:06:20 +0000 | [diff] [blame] | 972 | // -fms-extensions=0 is default. |
Daniel Dunbar | 6d2eb4d | 2009-11-25 10:14:30 +0000 | [diff] [blame] | 973 | if (Args.hasFlag(options::OPT_fms_extensions, options::OPT_fno_ms_extensions, |
Daniel Dunbar | 0be42c4 | 2009-11-17 07:06:20 +0000 | [diff] [blame] | 974 | getToolChain().getTriple().getOS() == llvm::Triple::Win32)) |
| 975 | CmdArgs.push_back("-fms-extensions"); |
| 976 | |
Daniel Dunbar | c5a97ec | 2009-11-17 07:07:28 +0000 | [diff] [blame] | 977 | // -fnext-runtime is default. |
Daniel Dunbar | 6d2eb4d | 2009-11-25 10:14:30 +0000 | [diff] [blame] | 978 | if (!Args.hasFlag(options::OPT_fnext_runtime, options::OPT_fgnu_runtime, |
Daniel Dunbar | c5a97ec | 2009-11-17 07:07:28 +0000 | [diff] [blame] | 979 | getToolChain().getTriple().getOS() == llvm::Triple::Darwin)) |
| 980 | CmdArgs.push_back("-fgnu-runtime"); |
| 981 | |
Daniel Dunbar | 9e5cc6b | 2009-11-17 08:07:36 +0000 | [diff] [blame] | 982 | // -fobjc-nonfragile-abi=0 is default. |
| 983 | if (types::isObjC(InputType)) { |
| 984 | if (Args.hasArg(options::OPT_fobjc_nonfragile_abi) || |
| 985 | getToolChain().IsObjCNonFragileABIDefault()) |
| 986 | CmdArgs.push_back("-fobjc-nonfragile-abi"); |
| 987 | } |
| 988 | |
John Thompson | a6fda12 | 2009-11-05 20:14:16 +0000 | [diff] [blame] | 989 | // -fshort-wchar default varies depending on platform; only |
| 990 | // pass if specified. |
| 991 | if (Arg *A = Args.getLastArg(options::OPT_fshort_wchar)) { |
| 992 | if (A->getOption().matches(options::OPT_fshort_wchar)) |
| 993 | CmdArgs.push_back("-fshort-wchar"); |
| 994 | } |
| 995 | |
Daniel Dunbar | ee848a7 | 2009-10-29 02:39:57 +0000 | [diff] [blame] | 996 | // -fno-pascal-strings is default, only pass non-default. If the tool chain |
| 997 | // happened to translate to -mpascal-strings, we want to back translate here. |
Daniel Dunbar | 82d0068 | 2009-04-07 23:51:44 +0000 | [diff] [blame] | 998 | // |
| 999 | // FIXME: This is gross; that translation should be pulled from the |
| 1000 | // tool chain. |
Daniel Dunbar | c21c485 | 2009-04-08 23:54:23 +0000 | [diff] [blame] | 1001 | if (Args.hasFlag(options::OPT_fpascal_strings, |
Daniel Dunbar | 82d0068 | 2009-04-07 23:51:44 +0000 | [diff] [blame] | 1002 | options::OPT_fno_pascal_strings, |
| 1003 | false) || |
| 1004 | Args.hasFlag(options::OPT_mpascal_strings, |
| 1005 | options::OPT_mno_pascal_strings, |
| 1006 | false)) |
Daniel Dunbar | 48d1ef7 | 2009-04-07 21:16:11 +0000 | [diff] [blame] | 1007 | CmdArgs.push_back("-fpascal-strings"); |
| 1008 | |
| 1009 | // -fcommon is default, only pass non-default. |
| 1010 | if (!Args.hasFlag(options::OPT_fcommon, options::OPT_fno_common)) |
| 1011 | CmdArgs.push_back("-fno-common"); |
| 1012 | |
Daniel Dunbar | 70d3c92 | 2009-04-15 02:37:43 +0000 | [diff] [blame] | 1013 | // -fsigned-bitfields is default, and clang doesn't yet support |
| 1014 | // --funsigned-bitfields. |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 1015 | if (!Args.hasFlag(options::OPT_fsigned_bitfields, |
Daniel Dunbar | 70d3c92 | 2009-04-15 02:37:43 +0000 | [diff] [blame] | 1016 | options::OPT_funsigned_bitfields)) |
| 1017 | D.Diag(clang::diag::warn_drv_clang_unsupported) |
| 1018 | << Args.getLastArg(options::OPT_funsigned_bitfields)->getAsString(Args); |
| 1019 | |
Daniel Dunbar | 49138fc | 2009-04-19 21:09:34 +0000 | [diff] [blame] | 1020 | // -fdiagnostics-fixit-info is default, only pass non-default. |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 1021 | if (!Args.hasFlag(options::OPT_fdiagnostics_fixit_info, |
Daniel Dunbar | 49138fc | 2009-04-19 21:09:34 +0000 | [diff] [blame] | 1022 | options::OPT_fno_diagnostics_fixit_info)) |
| 1023 | CmdArgs.push_back("-fno-diagnostics-fixit-info"); |
| 1024 | |
Daniel Dunbar | 9e820ee | 2009-04-16 06:32:38 +0000 | [diff] [blame] | 1025 | // Enable -fdiagnostics-show-option by default. |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 1026 | if (Args.hasFlag(options::OPT_fdiagnostics_show_option, |
Daniel Dunbar | 9e820ee | 2009-04-16 06:32:38 +0000 | [diff] [blame] | 1027 | options::OPT_fno_diagnostics_show_option)) |
| 1028 | CmdArgs.push_back("-fdiagnostics-show-option"); |
Daniel Dunbar | 838be48 | 2009-11-04 06:24:57 +0000 | [diff] [blame] | 1029 | |
| 1030 | // Color diagnostics are the default, unless the terminal doesn't support |
| 1031 | // them. |
| 1032 | if (Args.hasFlag(options::OPT_fcolor_diagnostics, |
| 1033 | options::OPT_fno_color_diagnostics) && |
| 1034 | llvm::sys::Process::StandardErrHasColors()) |
| 1035 | CmdArgs.push_back("-fcolor-diagnostics"); |
| 1036 | |
Daniel Dunbar | 75eb1d6 | 2009-06-08 21:13:54 +0000 | [diff] [blame] | 1037 | if (!Args.hasFlag(options::OPT_fshow_source_location, |
| 1038 | options::OPT_fno_show_source_location)) |
| 1039 | CmdArgs.push_back("-fno-show-source-location"); |
Daniel Dunbar | 9e820ee | 2009-04-16 06:32:38 +0000 | [diff] [blame] | 1040 | |
Daniel Dunbar | 7695fba | 2009-04-19 21:20:32 +0000 | [diff] [blame] | 1041 | // -fdollars-in-identifiers default varies depending on platform and |
| 1042 | // language; only pass if specified. |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 1043 | if (Arg *A = Args.getLastArg(options::OPT_fdollars_in_identifiers, |
Daniel Dunbar | 7695fba | 2009-04-19 21:20:32 +0000 | [diff] [blame] | 1044 | options::OPT_fno_dollars_in_identifiers)) { |
| 1045 | if (A->getOption().matches(options::OPT_fdollars_in_identifiers)) |
Daniel Dunbar | 8663b18 | 2009-12-16 20:10:18 +0000 | [diff] [blame] | 1046 | CmdArgs.push_back("-fdollars-in-identifiers"); |
Daniel Dunbar | 7695fba | 2009-04-19 21:20:32 +0000 | [diff] [blame] | 1047 | else |
Daniel Dunbar | 8663b18 | 2009-12-16 20:10:18 +0000 | [diff] [blame] | 1048 | CmdArgs.push_back("-fno-dollars-in-identifiers"); |
Daniel Dunbar | 7695fba | 2009-04-19 21:20:32 +0000 | [diff] [blame] | 1049 | } |
| 1050 | |
Daniel Dunbar | e027a4b | 2009-05-22 19:02:20 +0000 | [diff] [blame] | 1051 | // -funit-at-a-time is default, and we don't support -fno-unit-at-a-time for |
| 1052 | // practical purposes. |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 1053 | if (Arg *A = Args.getLastArg(options::OPT_funit_at_a_time, |
Daniel Dunbar | e027a4b | 2009-05-22 19:02:20 +0000 | [diff] [blame] | 1054 | options::OPT_fno_unit_at_a_time)) { |
| 1055 | if (A->getOption().matches(options::OPT_fno_unit_at_a_time)) |
Edward O'Callaghan | c376910 | 2009-10-13 16:41:34 +0000 | [diff] [blame] | 1056 | D.Diag(clang::diag::warn_drv_clang_unsupported) << A->getAsString(Args); |
Daniel Dunbar | e027a4b | 2009-05-22 19:02:20 +0000 | [diff] [blame] | 1057 | } |
Eli Friedman | ceb5c5b | 2009-07-14 21:58:17 +0000 | [diff] [blame] | 1058 | |
Daniel Dunbar | 2ba9157 | 2009-09-10 03:37:02 +0000 | [diff] [blame] | 1059 | // Default to -fno-builtin-str{cat,cpy} on Darwin for ARM. |
Daniel Dunbar | f84a4a4 | 2009-09-10 04:57:27 +0000 | [diff] [blame] | 1060 | // |
Daniel Dunbar | 8ff5b28 | 2009-12-11 23:00:49 +0000 | [diff] [blame] | 1061 | // FIXME: This is disabled until clang -cc1 supports -fno-builtin-foo. PR4941. |
Daniel Dunbar | f84a4a4 | 2009-09-10 04:57:27 +0000 | [diff] [blame] | 1062 | #if 0 |
Daniel Dunbar | 2ba9157 | 2009-09-10 03:37:02 +0000 | [diff] [blame] | 1063 | if (getToolChain().getTriple().getOS() == llvm::Triple::Darwin && |
| 1064 | (getToolChain().getTriple().getArch() == llvm::Triple::arm || |
| 1065 | getToolChain().getTriple().getArch() == llvm::Triple::thumb)) { |
| 1066 | if (!Args.hasArg(options::OPT_fbuiltin_strcat)) |
| 1067 | CmdArgs.push_back("-fno-builtin-strcat"); |
| 1068 | if (!Args.hasArg(options::OPT_fbuiltin_strcpy)) |
| 1069 | CmdArgs.push_back("-fno-builtin-strcpy"); |
| 1070 | } |
Daniel Dunbar | f84a4a4 | 2009-09-10 04:57:27 +0000 | [diff] [blame] | 1071 | #endif |
Daniel Dunbar | 2ba9157 | 2009-09-10 03:37:02 +0000 | [diff] [blame] | 1072 | |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 1073 | if (Arg *A = Args.getLastArg(options::OPT_traditional, |
Eli Friedman | ceb5c5b | 2009-07-14 21:58:17 +0000 | [diff] [blame] | 1074 | options::OPT_traditional_cpp)) |
| 1075 | D.Diag(clang::diag::err_drv_clang_unsupported) << A->getAsString(Args); |
| 1076 | |
Daniel Dunbar | 1d46033 | 2009-03-18 10:01:51 +0000 | [diff] [blame] | 1077 | Args.AddLastArg(CmdArgs, options::OPT_dM); |
Chris Lattner | d82df3a | 2009-04-12 01:56:53 +0000 | [diff] [blame] | 1078 | Args.AddLastArg(CmdArgs, options::OPT_dD); |
Daniel Dunbar | 1d46033 | 2009-03-18 10:01:51 +0000 | [diff] [blame] | 1079 | |
| 1080 | Args.AddAllArgValues(CmdArgs, options::OPT_Xclang); |
Daniel Dunbar | e528028 | 2009-06-03 16:16:27 +0000 | [diff] [blame] | 1081 | Args.AddAllArgValues(CmdArgs, options::OPT_mllvm); |
Daniel Dunbar | 1d46033 | 2009-03-18 10:01:51 +0000 | [diff] [blame] | 1082 | |
Daniel Dunbar | cd8e4c4 | 2009-03-30 06:36:42 +0000 | [diff] [blame] | 1083 | if (Output.getType() == types::TY_Dependencies) { |
| 1084 | // Handled with other dependency code. |
Daniel Dunbar | a5a7bd0 | 2009-03-30 00:34:04 +0000 | [diff] [blame] | 1085 | } else if (Output.isPipe()) { |
Daniel Dunbar | b488c1d | 2009-03-18 08:07:30 +0000 | [diff] [blame] | 1086 | CmdArgs.push_back("-o"); |
| 1087 | CmdArgs.push_back("-"); |
Daniel Dunbar | 115a792 | 2009-03-19 07:29:38 +0000 | [diff] [blame] | 1088 | } else if (Output.isFilename()) { |
Daniel Dunbar | b488c1d | 2009-03-18 08:07:30 +0000 | [diff] [blame] | 1089 | CmdArgs.push_back("-o"); |
Daniel Dunbar | 115a792 | 2009-03-19 07:29:38 +0000 | [diff] [blame] | 1090 | CmdArgs.push_back(Output.getFilename()); |
| 1091 | } else { |
| 1092 | assert(Output.isNothing() && "Invalid output."); |
Daniel Dunbar | b488c1d | 2009-03-18 08:07:30 +0000 | [diff] [blame] | 1093 | } |
| 1094 | |
Daniel Dunbar | 1d46033 | 2009-03-18 10:01:51 +0000 | [diff] [blame] | 1095 | for (InputInfoList::const_iterator |
| 1096 | it = Inputs.begin(), ie = Inputs.end(); it != ie; ++it) { |
| 1097 | const InputInfo &II = *it; |
| 1098 | CmdArgs.push_back("-x"); |
| 1099 | CmdArgs.push_back(types::getTypeName(II.getType())); |
| 1100 | if (II.isPipe()) |
| 1101 | CmdArgs.push_back("-"); |
Daniel Dunbar | 115a792 | 2009-03-19 07:29:38 +0000 | [diff] [blame] | 1102 | else if (II.isFilename()) |
| 1103 | CmdArgs.push_back(II.getFilename()); |
Daniel Dunbar | 1d46033 | 2009-03-18 10:01:51 +0000 | [diff] [blame] | 1104 | else |
Daniel Dunbar | 115a792 | 2009-03-19 07:29:38 +0000 | [diff] [blame] | 1105 | II.getInputArg().renderAsInput(Args, CmdArgs); |
Daniel Dunbar | 1d46033 | 2009-03-18 10:01:51 +0000 | [diff] [blame] | 1106 | } |
Daniel Dunbar | c21c485 | 2009-04-08 23:54:23 +0000 | [diff] [blame] | 1107 | |
Chris Lattner | e6113de | 2009-11-03 19:50:27 +0000 | [diff] [blame] | 1108 | Args.AddAllArgs(CmdArgs, options::OPT_undef); |
| 1109 | |
Daniel Dunbar | c21c485 | 2009-04-08 23:54:23 +0000 | [diff] [blame] | 1110 | const char *Exec = |
Daniel Dunbar | 8ff5b28 | 2009-12-11 23:00:49 +0000 | [diff] [blame] | 1111 | Args.MakeArgString(getToolChain().GetProgramPath(C, "clang")); |
Daniel Dunbar | f2d8b9f | 2009-12-18 02:43:17 +0000 | [diff] [blame] | 1112 | |
| 1113 | // Optionally embed the -cc1 level arguments into the debug info, for build |
| 1114 | // analysis. |
| 1115 | if (getToolChain().UseDwarfDebugFlags()) { |
| 1116 | llvm::SmallString<256> Flags; |
| 1117 | Flags += Exec; |
| 1118 | for (unsigned i = 0, e = CmdArgs.size(); i != e; ++i) { |
| 1119 | Flags += " "; |
| 1120 | Flags += CmdArgs[i]; |
| 1121 | } |
| 1122 | CmdArgs.push_back("-dwarf-debug-flags"); |
| 1123 | CmdArgs.push_back(Args.MakeArgString(Flags.str())); |
| 1124 | } |
| 1125 | |
Daniel Dunbar | daab7b1 | 2009-12-02 03:23:25 +0000 | [diff] [blame] | 1126 | Dest.addCommand(new Command(JA, *this, Exec, CmdArgs)); |
Daniel Dunbar | a880db0 | 2009-03-23 19:03:36 +0000 | [diff] [blame] | 1127 | |
Daniel Dunbar | 5c1aaaf | 2009-04-07 19:18:24 +0000 | [diff] [blame] | 1128 | // Explicitly warn that these options are unsupported, even though |
| 1129 | // we are allowing compilation to continue. |
Daniel Dunbar | cdd9686 | 2009-11-25 11:53:23 +0000 | [diff] [blame] | 1130 | for (arg_iterator it = Args.filtered_begin(options::OPT_pg), |
| 1131 | ie = Args.filtered_end(); it != ie; ++it) { |
| 1132 | it->claim(); |
| 1133 | D.Diag(clang::diag::warn_drv_clang_unsupported) << it->getAsString(Args); |
Daniel Dunbar | 5c1aaaf | 2009-04-07 19:18:24 +0000 | [diff] [blame] | 1134 | } |
| 1135 | |
Daniel Dunbar | 68fb469 | 2009-04-03 20:51:31 +0000 | [diff] [blame] | 1136 | // Claim some arguments which clang supports automatically. |
| 1137 | |
| 1138 | // -fpch-preprocess is used with gcc to add a special marker in the |
| 1139 | // -output to include the PCH file. Clang's PTH solution is |
| 1140 | // -completely transparent, so we do not need to deal with it at |
| 1141 | // -all. |
| 1142 | Args.ClaimAllArgs(options::OPT_fpch_preprocess); |
Daniel Dunbar | c21c485 | 2009-04-08 23:54:23 +0000 | [diff] [blame] | 1143 | |
Daniel Dunbar | a880db0 | 2009-03-23 19:03:36 +0000 | [diff] [blame] | 1144 | // Claim some arguments which clang doesn't support, but we don't |
| 1145 | // care to warn the user about. |
Daniel Dunbar | cdd9686 | 2009-11-25 11:53:23 +0000 | [diff] [blame] | 1146 | Args.ClaimAllArgs(options::OPT_clang_ignored_f_Group); |
| 1147 | Args.ClaimAllArgs(options::OPT_clang_ignored_m_Group); |
Daniel Dunbar | 47ac7d2 | 2009-03-18 06:00:36 +0000 | [diff] [blame] | 1148 | } |
| 1149 | |
Daniel Dunbar | b488c1d | 2009-03-18 08:07:30 +0000 | [diff] [blame] | 1150 | void gcc::Common::ConstructJob(Compilation &C, const JobAction &JA, |
| 1151 | Job &Dest, |
| 1152 | const InputInfo &Output, |
| 1153 | const InputInfoList &Inputs, |
Daniel Dunbar | 1d46033 | 2009-03-18 10:01:51 +0000 | [diff] [blame] | 1154 | const ArgList &Args, |
Daniel Dunbar | b488c1d | 2009-03-18 08:07:30 +0000 | [diff] [blame] | 1155 | const char *LinkingOutput) const { |
Daniel Dunbar | a8304f6 | 2009-05-02 20:14:53 +0000 | [diff] [blame] | 1156 | const Driver &D = getToolChain().getHost().getDriver(); |
Daniel Dunbar | b488c1d | 2009-03-18 08:07:30 +0000 | [diff] [blame] | 1157 | ArgStringList CmdArgs; |
Daniel Dunbar | 47ac7d2 | 2009-03-18 06:00:36 +0000 | [diff] [blame] | 1158 | |
Daniel Dunbar | c21c485 | 2009-04-08 23:54:23 +0000 | [diff] [blame] | 1159 | for (ArgList::const_iterator |
Daniel Dunbar | 1d46033 | 2009-03-18 10:01:51 +0000 | [diff] [blame] | 1160 | it = Args.begin(), ie = Args.end(); it != ie; ++it) { |
Daniel Dunbar | b488c1d | 2009-03-18 08:07:30 +0000 | [diff] [blame] | 1161 | Arg *A = *it; |
Daniel Dunbar | 7587719 | 2009-03-19 07:55:12 +0000 | [diff] [blame] | 1162 | if (A->getOption().hasForwardToGCC()) { |
| 1163 | // It is unfortunate that we have to claim here, as this means |
| 1164 | // we will basically never report anything interesting for |
Daniel Dunbar | 6ecc7a9 | 2009-05-02 21:41:52 +0000 | [diff] [blame] | 1165 | // platforms using a generic gcc, even if we are just using gcc |
| 1166 | // to get to the assembler. |
Daniel Dunbar | 7587719 | 2009-03-19 07:55:12 +0000 | [diff] [blame] | 1167 | A->claim(); |
Daniel Dunbar | 1d46033 | 2009-03-18 10:01:51 +0000 | [diff] [blame] | 1168 | A->render(Args, CmdArgs); |
Daniel Dunbar | 7587719 | 2009-03-19 07:55:12 +0000 | [diff] [blame] | 1169 | } |
Daniel Dunbar | b488c1d | 2009-03-18 08:07:30 +0000 | [diff] [blame] | 1170 | } |
Daniel Dunbar | c21c485 | 2009-04-08 23:54:23 +0000 | [diff] [blame] | 1171 | |
Daniel Dunbar | b488c1d | 2009-03-18 08:07:30 +0000 | [diff] [blame] | 1172 | RenderExtraToolArgs(CmdArgs); |
| 1173 | |
| 1174 | // If using a driver driver, force the arch. |
Daniel Dunbar | 7cfe31a | 2009-05-22 02:21:04 +0000 | [diff] [blame] | 1175 | const std::string &Arch = getToolChain().getArchName(); |
Daniel Dunbar | b488c1d | 2009-03-18 08:07:30 +0000 | [diff] [blame] | 1176 | if (getToolChain().getHost().useDriverDriver()) { |
| 1177 | CmdArgs.push_back("-arch"); |
Daniel Dunbar | bf54a06 | 2009-04-01 20:33:11 +0000 | [diff] [blame] | 1178 | |
| 1179 | // FIXME: Remove these special cases. |
Daniel Dunbar | 7cfe31a | 2009-05-22 02:21:04 +0000 | [diff] [blame] | 1180 | if (Arch == "powerpc") |
| 1181 | CmdArgs.push_back("ppc"); |
| 1182 | else if (Arch == "powerpc64") |
| 1183 | CmdArgs.push_back("ppc64"); |
| 1184 | else |
Daniel Dunbar | 8813764 | 2009-09-09 22:32:48 +0000 | [diff] [blame] | 1185 | CmdArgs.push_back(Args.MakeArgString(Arch)); |
Daniel Dunbar | b488c1d | 2009-03-18 08:07:30 +0000 | [diff] [blame] | 1186 | } |
| 1187 | |
Daniel Dunbar | 6ecc7a9 | 2009-05-02 21:41:52 +0000 | [diff] [blame] | 1188 | // Try to force gcc to match the tool chain we want, if we recognize |
| 1189 | // the arch. |
Daniel Dunbar | 7cfe31a | 2009-05-22 02:21:04 +0000 | [diff] [blame] | 1190 | // |
| 1191 | // FIXME: The triple class should directly provide the information we want |
| 1192 | // here. |
| 1193 | if (Arch == "i386" || Arch == "powerpc") |
Daniel Dunbar | 6ecc7a9 | 2009-05-02 21:41:52 +0000 | [diff] [blame] | 1194 | CmdArgs.push_back("-m32"); |
Daniel Dunbar | 7cfe31a | 2009-05-22 02:21:04 +0000 | [diff] [blame] | 1195 | else if (Arch == "x86_64" || Arch == "powerpc64") |
Daniel Dunbar | 6ecc7a9 | 2009-05-02 21:41:52 +0000 | [diff] [blame] | 1196 | CmdArgs.push_back("-m64"); |
| 1197 | |
Daniel Dunbar | b488c1d | 2009-03-18 08:07:30 +0000 | [diff] [blame] | 1198 | if (Output.isPipe()) { |
| 1199 | CmdArgs.push_back("-o"); |
| 1200 | CmdArgs.push_back("-"); |
Daniel Dunbar | 115a792 | 2009-03-19 07:29:38 +0000 | [diff] [blame] | 1201 | } else if (Output.isFilename()) { |
Daniel Dunbar | b488c1d | 2009-03-18 08:07:30 +0000 | [diff] [blame] | 1202 | CmdArgs.push_back("-o"); |
Daniel Dunbar | 115a792 | 2009-03-19 07:29:38 +0000 | [diff] [blame] | 1203 | CmdArgs.push_back(Output.getFilename()); |
| 1204 | } else { |
| 1205 | assert(Output.isNothing() && "Unexpected output"); |
Daniel Dunbar | b488c1d | 2009-03-18 08:07:30 +0000 | [diff] [blame] | 1206 | CmdArgs.push_back("-fsyntax-only"); |
Daniel Dunbar | 115a792 | 2009-03-19 07:29:38 +0000 | [diff] [blame] | 1207 | } |
Daniel Dunbar | b488c1d | 2009-03-18 08:07:30 +0000 | [diff] [blame] | 1208 | |
| 1209 | |
| 1210 | // Only pass -x if gcc will understand it; otherwise hope gcc |
| 1211 | // understands the suffix correctly. The main use case this would go |
| 1212 | // wrong in is for linker inputs if they happened to have an odd |
| 1213 | // suffix; really the only way to get this to happen is a command |
| 1214 | // like '-x foobar a.c' which will treat a.c like a linker input. |
| 1215 | // |
| 1216 | // FIXME: For the linker case specifically, can we safely convert |
| 1217 | // inputs into '-Wl,' options? |
| 1218 | for (InputInfoList::const_iterator |
| 1219 | it = Inputs.begin(), ie = Inputs.end(); it != ie; ++it) { |
| 1220 | const InputInfo &II = *it; |
Daniel Dunbar | a8304f6 | 2009-05-02 20:14:53 +0000 | [diff] [blame] | 1221 | |
Daniel Dunbar | 5915fbf | 2009-09-01 16:57:46 +0000 | [diff] [blame] | 1222 | // Don't try to pass LLVM or AST inputs to a generic gcc. |
Daniel Dunbar | a8304f6 | 2009-05-02 20:14:53 +0000 | [diff] [blame] | 1223 | if (II.getType() == types::TY_LLVMBC) |
| 1224 | D.Diag(clang::diag::err_drv_no_linker_llvm_support) |
Daniel Dunbar | 8813764 | 2009-09-09 22:32:48 +0000 | [diff] [blame] | 1225 | << getToolChain().getTripleString(); |
Daniel Dunbar | 5915fbf | 2009-09-01 16:57:46 +0000 | [diff] [blame] | 1226 | else if (II.getType() == types::TY_AST) |
| 1227 | D.Diag(clang::diag::err_drv_no_ast_support) |
Daniel Dunbar | 8813764 | 2009-09-09 22:32:48 +0000 | [diff] [blame] | 1228 | << getToolChain().getTripleString(); |
Daniel Dunbar | a8304f6 | 2009-05-02 20:14:53 +0000 | [diff] [blame] | 1229 | |
Daniel Dunbar | b488c1d | 2009-03-18 08:07:30 +0000 | [diff] [blame] | 1230 | if (types::canTypeBeUserSpecified(II.getType())) { |
| 1231 | CmdArgs.push_back("-x"); |
| 1232 | CmdArgs.push_back(types::getTypeName(II.getType())); |
| 1233 | } |
| 1234 | |
| 1235 | if (II.isPipe()) |
| 1236 | CmdArgs.push_back("-"); |
Daniel Dunbar | 115a792 | 2009-03-19 07:29:38 +0000 | [diff] [blame] | 1237 | else if (II.isFilename()) |
| 1238 | CmdArgs.push_back(II.getFilename()); |
Daniel Dunbar | b488c1d | 2009-03-18 08:07:30 +0000 | [diff] [blame] | 1239 | else |
Daniel Dunbar | 115a792 | 2009-03-19 07:29:38 +0000 | [diff] [blame] | 1240 | // Don't render as input, we need gcc to do the translations. |
| 1241 | II.getInputArg().render(Args, CmdArgs); |
Daniel Dunbar | b488c1d | 2009-03-18 08:07:30 +0000 | [diff] [blame] | 1242 | } |
| 1243 | |
Daniel Dunbar | c21c485 | 2009-04-08 23:54:23 +0000 | [diff] [blame] | 1244 | const char *GCCName = |
Daniel Dunbar | 78d8a08 | 2009-04-01 23:34:41 +0000 | [diff] [blame] | 1245 | getToolChain().getHost().getDriver().CCCGenericGCCName.c_str(); |
Daniel Dunbar | c21c485 | 2009-04-08 23:54:23 +0000 | [diff] [blame] | 1246 | const char *Exec = |
Daniel Dunbar | 5ed34f4 | 2009-09-09 22:33:00 +0000 | [diff] [blame] | 1247 | Args.MakeArgString(getToolChain().GetProgramPath(C, GCCName)); |
Daniel Dunbar | daab7b1 | 2009-12-02 03:23:25 +0000 | [diff] [blame] | 1248 | Dest.addCommand(new Command(JA, *this, Exec, CmdArgs)); |
Daniel Dunbar | 47ac7d2 | 2009-03-18 06:00:36 +0000 | [diff] [blame] | 1249 | } |
| 1250 | |
Daniel Dunbar | b488c1d | 2009-03-18 08:07:30 +0000 | [diff] [blame] | 1251 | void gcc::Preprocess::RenderExtraToolArgs(ArgStringList &CmdArgs) const { |
| 1252 | CmdArgs.push_back("-E"); |
Daniel Dunbar | 47ac7d2 | 2009-03-18 06:00:36 +0000 | [diff] [blame] | 1253 | } |
| 1254 | |
Daniel Dunbar | b488c1d | 2009-03-18 08:07:30 +0000 | [diff] [blame] | 1255 | void gcc::Precompile::RenderExtraToolArgs(ArgStringList &CmdArgs) const { |
| 1256 | // The type is good enough. |
Daniel Dunbar | 47ac7d2 | 2009-03-18 06:00:36 +0000 | [diff] [blame] | 1257 | } |
| 1258 | |
Daniel Dunbar | b488c1d | 2009-03-18 08:07:30 +0000 | [diff] [blame] | 1259 | void gcc::Compile::RenderExtraToolArgs(ArgStringList &CmdArgs) const { |
| 1260 | CmdArgs.push_back("-S"); |
Daniel Dunbar | 47ac7d2 | 2009-03-18 06:00:36 +0000 | [diff] [blame] | 1261 | } |
| 1262 | |
Daniel Dunbar | b488c1d | 2009-03-18 08:07:30 +0000 | [diff] [blame] | 1263 | void gcc::Assemble::RenderExtraToolArgs(ArgStringList &CmdArgs) const { |
| 1264 | CmdArgs.push_back("-c"); |
Daniel Dunbar | 47ac7d2 | 2009-03-18 06:00:36 +0000 | [diff] [blame] | 1265 | } |
Daniel Dunbar | b488c1d | 2009-03-18 08:07:30 +0000 | [diff] [blame] | 1266 | |
| 1267 | void gcc::Link::RenderExtraToolArgs(ArgStringList &CmdArgs) const { |
| 1268 | // The types are (hopefully) good enough. |
| 1269 | } |
| 1270 | |
Daniel Dunbar | 40f1265 | 2009-03-29 17:08:39 +0000 | [diff] [blame] | 1271 | const char *darwin::CC1::getCC1Name(types::ID Type) const { |
| 1272 | switch (Type) { |
| 1273 | default: |
| 1274 | assert(0 && "Unexpected type for Darwin CC1 tool."); |
| 1275 | case types::TY_Asm: |
| 1276 | case types::TY_C: case types::TY_CHeader: |
| 1277 | case types::TY_PP_C: case types::TY_PP_CHeader: |
| 1278 | return "cc1"; |
| 1279 | case types::TY_ObjC: case types::TY_ObjCHeader: |
| 1280 | case types::TY_PP_ObjC: case types::TY_PP_ObjCHeader: |
| 1281 | return "cc1obj"; |
| 1282 | case types::TY_CXX: case types::TY_CXXHeader: |
| 1283 | case types::TY_PP_CXX: case types::TY_PP_CXXHeader: |
| 1284 | return "cc1plus"; |
| 1285 | case types::TY_ObjCXX: case types::TY_ObjCXXHeader: |
| 1286 | case types::TY_PP_ObjCXX: case types::TY_PP_ObjCXXHeader: |
| 1287 | return "cc1objplus"; |
| 1288 | } |
| 1289 | } |
| 1290 | |
Daniel Dunbar | c21c485 | 2009-04-08 23:54:23 +0000 | [diff] [blame] | 1291 | const char *darwin::CC1::getBaseInputName(const ArgList &Args, |
Daniel Dunbar | a5a7bd0 | 2009-03-30 00:34:04 +0000 | [diff] [blame] | 1292 | const InputInfoList &Inputs) { |
Daniel Dunbar | a3ec60e | 2009-03-29 18:40:18 +0000 | [diff] [blame] | 1293 | llvm::sys::Path P(Inputs[0].getBaseInput()); |
Daniel Dunbar | 8813764 | 2009-09-09 22:32:48 +0000 | [diff] [blame] | 1294 | return Args.MakeArgString(P.getLast()); |
Daniel Dunbar | a3ec60e | 2009-03-29 18:40:18 +0000 | [diff] [blame] | 1295 | } |
| 1296 | |
Daniel Dunbar | c21c485 | 2009-04-08 23:54:23 +0000 | [diff] [blame] | 1297 | const char *darwin::CC1::getBaseInputStem(const ArgList &Args, |
Daniel Dunbar | a5a7bd0 | 2009-03-30 00:34:04 +0000 | [diff] [blame] | 1298 | const InputInfoList &Inputs) { |
Daniel Dunbar | a3ec60e | 2009-03-29 18:40:18 +0000 | [diff] [blame] | 1299 | const char *Str = getBaseInputName(Args, Inputs); |
| 1300 | |
| 1301 | if (const char *End = strchr(Str, '.')) |
Daniel Dunbar | 8813764 | 2009-09-09 22:32:48 +0000 | [diff] [blame] | 1302 | return Args.MakeArgString(std::string(Str, End)); |
Daniel Dunbar | a3ec60e | 2009-03-29 18:40:18 +0000 | [diff] [blame] | 1303 | |
| 1304 | return Str; |
| 1305 | } |
| 1306 | |
| 1307 | const char * |
Daniel Dunbar | c21c485 | 2009-04-08 23:54:23 +0000 | [diff] [blame] | 1308 | darwin::CC1::getDependencyFileName(const ArgList &Args, |
Daniel Dunbar | a5a7bd0 | 2009-03-30 00:34:04 +0000 | [diff] [blame] | 1309 | const InputInfoList &Inputs) { |
Daniel Dunbar | a3ec60e | 2009-03-29 18:40:18 +0000 | [diff] [blame] | 1310 | // FIXME: Think about this more. |
| 1311 | std::string Res; |
| 1312 | |
| 1313 | if (Arg *OutputOpt = Args.getLastArg(options::OPT_o)) { |
| 1314 | std::string Str(OutputOpt->getValue(Args)); |
Daniel Dunbar | c21c485 | 2009-04-08 23:54:23 +0000 | [diff] [blame] | 1315 | |
Daniel Dunbar | a3ec60e | 2009-03-29 18:40:18 +0000 | [diff] [blame] | 1316 | Res = Str.substr(0, Str.rfind('.')); |
| 1317 | } else |
Daniel Dunbar | a5a7bd0 | 2009-03-30 00:34:04 +0000 | [diff] [blame] | 1318 | Res = darwin::CC1::getBaseInputStem(Args, Inputs); |
Daniel Dunbar | a3ec60e | 2009-03-29 18:40:18 +0000 | [diff] [blame] | 1319 | |
Daniel Dunbar | 8813764 | 2009-09-09 22:32:48 +0000 | [diff] [blame] | 1320 | return Args.MakeArgString(Res + ".d"); |
Daniel Dunbar | a3ec60e | 2009-03-29 18:40:18 +0000 | [diff] [blame] | 1321 | } |
| 1322 | |
Daniel Dunbar | c21c485 | 2009-04-08 23:54:23 +0000 | [diff] [blame] | 1323 | void darwin::CC1::AddCC1Args(const ArgList &Args, |
Daniel Dunbar | a3ec60e | 2009-03-29 18:40:18 +0000 | [diff] [blame] | 1324 | ArgStringList &CmdArgs) const { |
Daniel Dunbar | e2fd664 | 2009-09-10 01:21:12 +0000 | [diff] [blame] | 1325 | const Driver &D = getToolChain().getHost().getDriver(); |
| 1326 | |
| 1327 | CheckCodeGenerationOptions(D, Args); |
| 1328 | |
Daniel Dunbar | a3ec60e | 2009-03-29 18:40:18 +0000 | [diff] [blame] | 1329 | // Derived from cc1 spec. |
Daniel Dunbar | a3ec60e | 2009-03-29 18:40:18 +0000 | [diff] [blame] | 1330 | if (!Args.hasArg(options::OPT_mkernel) && !Args.hasArg(options::OPT_static) && |
| 1331 | !Args.hasArg(options::OPT_mdynamic_no_pic)) |
| 1332 | CmdArgs.push_back("-fPIC"); |
| 1333 | |
Daniel Dunbar | 2ba9157 | 2009-09-10 03:37:02 +0000 | [diff] [blame] | 1334 | if (getToolChain().getTriple().getArch() == llvm::Triple::arm || |
| 1335 | getToolChain().getTriple().getArch() == llvm::Triple::thumb) { |
| 1336 | if (!Args.hasArg(options::OPT_fbuiltin_strcat)) |
| 1337 | CmdArgs.push_back("-fno-builtin-strcat"); |
| 1338 | if (!Args.hasArg(options::OPT_fbuiltin_strcpy)) |
| 1339 | CmdArgs.push_back("-fno-builtin-strcpy"); |
| 1340 | } |
| 1341 | |
Daniel Dunbar | a3ec60e | 2009-03-29 18:40:18 +0000 | [diff] [blame] | 1342 | // gcc has some code here to deal with when no -mmacosx-version-min |
| 1343 | // and no -miphoneos-version-min is present, but this never happens |
| 1344 | // due to tool chain specific argument translation. |
| 1345 | |
Daniel Dunbar | a3ec60e | 2009-03-29 18:40:18 +0000 | [diff] [blame] | 1346 | if (Args.hasArg(options::OPT_g_Flag) && |
| 1347 | !Args.hasArg(options::OPT_fno_eliminate_unused_debug_symbols)) |
| 1348 | CmdArgs.push_back("-feliminate-unused-debug-symbols"); |
| 1349 | } |
| 1350 | |
| 1351 | void darwin::CC1::AddCC1OptionsArgs(const ArgList &Args, ArgStringList &CmdArgs, |
| 1352 | const InputInfoList &Inputs, |
| 1353 | const ArgStringList &OutputArgs) const { |
| 1354 | const Driver &D = getToolChain().getHost().getDriver(); |
| 1355 | |
| 1356 | // Derived from cc1_options spec. |
| 1357 | if (Args.hasArg(options::OPT_fast) || |
| 1358 | Args.hasArg(options::OPT_fastf) || |
| 1359 | Args.hasArg(options::OPT_fastcp)) |
| 1360 | CmdArgs.push_back("-O3"); |
Daniel Dunbar | c21c485 | 2009-04-08 23:54:23 +0000 | [diff] [blame] | 1361 | |
Daniel Dunbar | a3ec60e | 2009-03-29 18:40:18 +0000 | [diff] [blame] | 1362 | if (Arg *A = Args.getLastArg(options::OPT_pg)) |
| 1363 | if (Args.hasArg(options::OPT_fomit_frame_pointer)) |
| 1364 | D.Diag(clang::diag::err_drv_argument_not_allowed_with) |
| 1365 | << A->getAsString(Args) << "-fomit-frame-pointer"; |
| 1366 | |
| 1367 | AddCC1Args(Args, CmdArgs); |
| 1368 | |
| 1369 | if (!Args.hasArg(options::OPT_Q)) |
| 1370 | CmdArgs.push_back("-quiet"); |
| 1371 | |
| 1372 | CmdArgs.push_back("-dumpbase"); |
Daniel Dunbar | a5a7bd0 | 2009-03-30 00:34:04 +0000 | [diff] [blame] | 1373 | CmdArgs.push_back(darwin::CC1::getBaseInputName(Args, Inputs)); |
Daniel Dunbar | a3ec60e | 2009-03-29 18:40:18 +0000 | [diff] [blame] | 1374 | |
| 1375 | Args.AddAllArgs(CmdArgs, options::OPT_d_Group); |
| 1376 | |
| 1377 | Args.AddAllArgs(CmdArgs, options::OPT_m_Group); |
| 1378 | Args.AddAllArgs(CmdArgs, options::OPT_a_Group); |
| 1379 | |
| 1380 | // FIXME: The goal is to use the user provided -o if that is our |
| 1381 | // final output, otherwise to drive from the original input |
| 1382 | // name. Find a clean way to go about this. |
| 1383 | if ((Args.hasArg(options::OPT_c) || Args.hasArg(options::OPT_S)) && |
| 1384 | Args.hasArg(options::OPT_o)) { |
| 1385 | Arg *OutputOpt = Args.getLastArg(options::OPT_o); |
| 1386 | CmdArgs.push_back("-auxbase-strip"); |
| 1387 | CmdArgs.push_back(OutputOpt->getValue(Args)); |
| 1388 | } else { |
| 1389 | CmdArgs.push_back("-auxbase"); |
Daniel Dunbar | a5a7bd0 | 2009-03-30 00:34:04 +0000 | [diff] [blame] | 1390 | CmdArgs.push_back(darwin::CC1::getBaseInputStem(Args, Inputs)); |
Daniel Dunbar | a3ec60e | 2009-03-29 18:40:18 +0000 | [diff] [blame] | 1391 | } |
| 1392 | |
| 1393 | Args.AddAllArgs(CmdArgs, options::OPT_g_Group); |
| 1394 | |
| 1395 | Args.AddAllArgs(CmdArgs, options::OPT_O); |
| 1396 | // FIXME: -Wall is getting some special treatment. Investigate. |
| 1397 | Args.AddAllArgs(CmdArgs, options::OPT_W_Group, options::OPT_pedantic_Group); |
| 1398 | Args.AddLastArg(CmdArgs, options::OPT_w); |
Daniel Dunbar | c21c485 | 2009-04-08 23:54:23 +0000 | [diff] [blame] | 1399 | Args.AddAllArgs(CmdArgs, options::OPT_std_EQ, options::OPT_ansi, |
Daniel Dunbar | a3ec60e | 2009-03-29 18:40:18 +0000 | [diff] [blame] | 1400 | options::OPT_trigraphs); |
Daniel Dunbar | a3ff202 | 2009-04-26 01:10:38 +0000 | [diff] [blame] | 1401 | if (!Args.getLastArg(options::OPT_std_EQ, options::OPT_ansi)) { |
| 1402 | // Honor -std-default. |
| 1403 | Args.AddAllArgsTranslated(CmdArgs, options::OPT_std_default_EQ, |
| 1404 | "-std=", /*Joined=*/true); |
| 1405 | } |
| 1406 | |
Daniel Dunbar | a3ec60e | 2009-03-29 18:40:18 +0000 | [diff] [blame] | 1407 | if (Args.hasArg(options::OPT_v)) |
| 1408 | CmdArgs.push_back("-version"); |
| 1409 | if (Args.hasArg(options::OPT_pg)) |
| 1410 | CmdArgs.push_back("-p"); |
| 1411 | Args.AddLastArg(CmdArgs, options::OPT_p); |
Daniel Dunbar | c21c485 | 2009-04-08 23:54:23 +0000 | [diff] [blame] | 1412 | |
Daniel Dunbar | a3ec60e | 2009-03-29 18:40:18 +0000 | [diff] [blame] | 1413 | // The driver treats -fsyntax-only specially. |
Daniel Dunbar | 2ba9157 | 2009-09-10 03:37:02 +0000 | [diff] [blame] | 1414 | if (getToolChain().getTriple().getArch() == llvm::Triple::arm || |
| 1415 | getToolChain().getTriple().getArch() == llvm::Triple::thumb) { |
| 1416 | // Removes -fbuiltin-str{cat,cpy}; these aren't recognized by cc1 but are |
| 1417 | // used to inhibit the default -fno-builtin-str{cat,cpy}. |
| 1418 | // |
| 1419 | // FIXME: Should we grow a better way to deal with "removing" args? |
Daniel Dunbar | cdd9686 | 2009-11-25 11:53:23 +0000 | [diff] [blame] | 1420 | for (arg_iterator it = Args.filtered_begin(options::OPT_f_Group, |
| 1421 | options::OPT_fsyntax_only), |
| 1422 | ie = Args.filtered_end(); it != ie; ++it) { |
| 1423 | if (!it->getOption().matches(options::OPT_fbuiltin_strcat) && |
| 1424 | !it->getOption().matches(options::OPT_fbuiltin_strcpy)) { |
| 1425 | it->claim(); |
| 1426 | it->render(Args, CmdArgs); |
Daniel Dunbar | 2ba9157 | 2009-09-10 03:37:02 +0000 | [diff] [blame] | 1427 | } |
| 1428 | } |
| 1429 | } else |
| 1430 | Args.AddAllArgs(CmdArgs, options::OPT_f_Group, options::OPT_fsyntax_only); |
Daniel Dunbar | c21c485 | 2009-04-08 23:54:23 +0000 | [diff] [blame] | 1431 | |
Daniel Dunbar | a3ec60e | 2009-03-29 18:40:18 +0000 | [diff] [blame] | 1432 | Args.AddAllArgs(CmdArgs, options::OPT_undef); |
| 1433 | if (Args.hasArg(options::OPT_Qn)) |
| 1434 | CmdArgs.push_back("-fno-ident"); |
Daniel Dunbar | c21c485 | 2009-04-08 23:54:23 +0000 | [diff] [blame] | 1435 | |
Daniel Dunbar | a3ec60e | 2009-03-29 18:40:18 +0000 | [diff] [blame] | 1436 | // FIXME: This isn't correct. |
| 1437 | //Args.AddLastArg(CmdArgs, options::OPT__help) |
| 1438 | //Args.AddLastArg(CmdArgs, options::OPT__targetHelp) |
| 1439 | |
| 1440 | CmdArgs.append(OutputArgs.begin(), OutputArgs.end()); |
| 1441 | |
| 1442 | // FIXME: Still don't get what is happening here. Investigate. |
| 1443 | Args.AddAllArgs(CmdArgs, options::OPT__param); |
| 1444 | |
| 1445 | if (Args.hasArg(options::OPT_fmudflap) || |
| 1446 | Args.hasArg(options::OPT_fmudflapth)) { |
| 1447 | CmdArgs.push_back("-fno-builtin"); |
| 1448 | CmdArgs.push_back("-fno-merge-constants"); |
| 1449 | } |
Daniel Dunbar | c21c485 | 2009-04-08 23:54:23 +0000 | [diff] [blame] | 1450 | |
Daniel Dunbar | a3ec60e | 2009-03-29 18:40:18 +0000 | [diff] [blame] | 1451 | if (Args.hasArg(options::OPT_coverage)) { |
| 1452 | CmdArgs.push_back("-fprofile-arcs"); |
| 1453 | CmdArgs.push_back("-ftest-coverage"); |
| 1454 | } |
| 1455 | |
| 1456 | if (types::isCXX(Inputs[0].getType())) |
| 1457 | CmdArgs.push_back("-D__private_extern__=extern"); |
| 1458 | } |
| 1459 | |
| 1460 | void darwin::CC1::AddCPPOptionsArgs(const ArgList &Args, ArgStringList &CmdArgs, |
| 1461 | const InputInfoList &Inputs, |
| 1462 | const ArgStringList &OutputArgs) const { |
| 1463 | // Derived from cpp_options |
| 1464 | AddCPPUniqueOptionsArgs(Args, CmdArgs, Inputs); |
Daniel Dunbar | c21c485 | 2009-04-08 23:54:23 +0000 | [diff] [blame] | 1465 | |
Daniel Dunbar | a3ec60e | 2009-03-29 18:40:18 +0000 | [diff] [blame] | 1466 | CmdArgs.append(OutputArgs.begin(), OutputArgs.end()); |
| 1467 | |
| 1468 | AddCC1Args(Args, CmdArgs); |
| 1469 | |
| 1470 | // NOTE: The code below has some commonality with cpp_options, but |
| 1471 | // in classic gcc style ends up sending things in different |
| 1472 | // orders. This may be a good merge candidate once we drop pedantic |
| 1473 | // compatibility. |
| 1474 | |
| 1475 | Args.AddAllArgs(CmdArgs, options::OPT_m_Group); |
Daniel Dunbar | c21c485 | 2009-04-08 23:54:23 +0000 | [diff] [blame] | 1476 | Args.AddAllArgs(CmdArgs, options::OPT_std_EQ, options::OPT_ansi, |
Daniel Dunbar | a3ec60e | 2009-03-29 18:40:18 +0000 | [diff] [blame] | 1477 | options::OPT_trigraphs); |
Daniel Dunbar | a3ff202 | 2009-04-26 01:10:38 +0000 | [diff] [blame] | 1478 | if (!Args.getLastArg(options::OPT_std_EQ, options::OPT_ansi)) { |
| 1479 | // Honor -std-default. |
| 1480 | Args.AddAllArgsTranslated(CmdArgs, options::OPT_std_default_EQ, |
| 1481 | "-std=", /*Joined=*/true); |
| 1482 | } |
Daniel Dunbar | a3ec60e | 2009-03-29 18:40:18 +0000 | [diff] [blame] | 1483 | Args.AddAllArgs(CmdArgs, options::OPT_W_Group, options::OPT_pedantic_Group); |
| 1484 | Args.AddLastArg(CmdArgs, options::OPT_w); |
Daniel Dunbar | c21c485 | 2009-04-08 23:54:23 +0000 | [diff] [blame] | 1485 | |
Daniel Dunbar | a3ec60e | 2009-03-29 18:40:18 +0000 | [diff] [blame] | 1486 | // The driver treats -fsyntax-only specially. |
| 1487 | Args.AddAllArgs(CmdArgs, options::OPT_f_Group, options::OPT_fsyntax_only); |
| 1488 | |
| 1489 | if (Args.hasArg(options::OPT_g_Group) && !Args.hasArg(options::OPT_g0) && |
| 1490 | !Args.hasArg(options::OPT_fno_working_directory)) |
| 1491 | CmdArgs.push_back("-fworking-directory"); |
| 1492 | |
| 1493 | Args.AddAllArgs(CmdArgs, options::OPT_O); |
| 1494 | Args.AddAllArgs(CmdArgs, options::OPT_undef); |
| 1495 | if (Args.hasArg(options::OPT_save_temps)) |
| 1496 | CmdArgs.push_back("-fpch-preprocess"); |
| 1497 | } |
| 1498 | |
Daniel Dunbar | c21c485 | 2009-04-08 23:54:23 +0000 | [diff] [blame] | 1499 | void darwin::CC1::AddCPPUniqueOptionsArgs(const ArgList &Args, |
Daniel Dunbar | a3ec60e | 2009-03-29 18:40:18 +0000 | [diff] [blame] | 1500 | ArgStringList &CmdArgs, |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 1501 | const InputInfoList &Inputs) const { |
Daniel Dunbar | a3ec60e | 2009-03-29 18:40:18 +0000 | [diff] [blame] | 1502 | const Driver &D = getToolChain().getHost().getDriver(); |
| 1503 | |
Daniel Dunbar | 88a3d6c | 2009-09-10 01:21:05 +0000 | [diff] [blame] | 1504 | CheckPreprocessingOptions(D, Args); |
| 1505 | |
Daniel Dunbar | a3ec60e | 2009-03-29 18:40:18 +0000 | [diff] [blame] | 1506 | // Derived from cpp_unique_options. |
Daniel Dunbar | 88a3d6c | 2009-09-10 01:21:05 +0000 | [diff] [blame] | 1507 | // -{C,CC} only with -E is checked in CheckPreprocessingOptions(). |
| 1508 | Args.AddLastArg(CmdArgs, options::OPT_C); |
| 1509 | Args.AddLastArg(CmdArgs, options::OPT_CC); |
Daniel Dunbar | a3ec60e | 2009-03-29 18:40:18 +0000 | [diff] [blame] | 1510 | if (!Args.hasArg(options::OPT_Q)) |
| 1511 | CmdArgs.push_back("-quiet"); |
| 1512 | Args.AddAllArgs(CmdArgs, options::OPT_nostdinc); |
| 1513 | Args.AddLastArg(CmdArgs, options::OPT_v); |
| 1514 | Args.AddAllArgs(CmdArgs, options::OPT_I_Group, options::OPT_F); |
| 1515 | Args.AddLastArg(CmdArgs, options::OPT_P); |
| 1516 | |
| 1517 | // FIXME: Handle %I properly. |
| 1518 | if (getToolChain().getArchName() == "x86_64") { |
| 1519 | CmdArgs.push_back("-imultilib"); |
| 1520 | CmdArgs.push_back("x86_64"); |
| 1521 | } |
| 1522 | |
| 1523 | if (Args.hasArg(options::OPT_MD)) { |
| 1524 | CmdArgs.push_back("-MD"); |
Daniel Dunbar | a5a7bd0 | 2009-03-30 00:34:04 +0000 | [diff] [blame] | 1525 | CmdArgs.push_back(darwin::CC1::getDependencyFileName(Args, Inputs)); |
Daniel Dunbar | a3ec60e | 2009-03-29 18:40:18 +0000 | [diff] [blame] | 1526 | } |
| 1527 | |
| 1528 | if (Args.hasArg(options::OPT_MMD)) { |
| 1529 | CmdArgs.push_back("-MMD"); |
Daniel Dunbar | a5a7bd0 | 2009-03-30 00:34:04 +0000 | [diff] [blame] | 1530 | CmdArgs.push_back(darwin::CC1::getDependencyFileName(Args, Inputs)); |
Daniel Dunbar | a3ec60e | 2009-03-29 18:40:18 +0000 | [diff] [blame] | 1531 | } |
| 1532 | |
| 1533 | Args.AddLastArg(CmdArgs, options::OPT_M); |
| 1534 | Args.AddLastArg(CmdArgs, options::OPT_MM); |
| 1535 | Args.AddAllArgs(CmdArgs, options::OPT_MF); |
| 1536 | Args.AddLastArg(CmdArgs, options::OPT_MG); |
| 1537 | Args.AddLastArg(CmdArgs, options::OPT_MP); |
| 1538 | Args.AddAllArgs(CmdArgs, options::OPT_MQ); |
| 1539 | Args.AddAllArgs(CmdArgs, options::OPT_MT); |
| 1540 | if (!Args.hasArg(options::OPT_M) && !Args.hasArg(options::OPT_MM) && |
| 1541 | (Args.hasArg(options::OPT_MD) || Args.hasArg(options::OPT_MMD))) { |
| 1542 | if (Arg *OutputOpt = Args.getLastArg(options::OPT_o)) { |
| 1543 | CmdArgs.push_back("-MQ"); |
| 1544 | CmdArgs.push_back(OutputOpt->getValue(Args)); |
| 1545 | } |
| 1546 | } |
| 1547 | |
| 1548 | Args.AddLastArg(CmdArgs, options::OPT_remap); |
| 1549 | if (Args.hasArg(options::OPT_g3)) |
| 1550 | CmdArgs.push_back("-dD"); |
| 1551 | Args.AddLastArg(CmdArgs, options::OPT_H); |
| 1552 | |
| 1553 | AddCPPArgs(Args, CmdArgs); |
| 1554 | |
| 1555 | Args.AddAllArgs(CmdArgs, options::OPT_D, options::OPT_U, options::OPT_A); |
| 1556 | Args.AddAllArgs(CmdArgs, options::OPT_i_Group); |
| 1557 | |
| 1558 | for (InputInfoList::const_iterator |
| 1559 | it = Inputs.begin(), ie = Inputs.end(); it != ie; ++it) { |
| 1560 | const InputInfo &II = *it; |
Daniel Dunbar | c21c485 | 2009-04-08 23:54:23 +0000 | [diff] [blame] | 1561 | |
Daniel Dunbar | a3ec60e | 2009-03-29 18:40:18 +0000 | [diff] [blame] | 1562 | if (II.isPipe()) |
| 1563 | CmdArgs.push_back("-"); |
| 1564 | else |
| 1565 | CmdArgs.push_back(II.getFilename()); |
| 1566 | } |
| 1567 | |
| 1568 | Args.AddAllArgValues(CmdArgs, options::OPT_Wp_COMMA, |
| 1569 | options::OPT_Xpreprocessor); |
| 1570 | |
| 1571 | if (Args.hasArg(options::OPT_fmudflap)) { |
| 1572 | CmdArgs.push_back("-D_MUDFLAP"); |
| 1573 | CmdArgs.push_back("-include"); |
| 1574 | CmdArgs.push_back("mf-runtime.h"); |
| 1575 | } |
| 1576 | |
| 1577 | if (Args.hasArg(options::OPT_fmudflapth)) { |
| 1578 | CmdArgs.push_back("-D_MUDFLAP"); |
| 1579 | CmdArgs.push_back("-D_MUDFLAPTH"); |
| 1580 | CmdArgs.push_back("-include"); |
| 1581 | CmdArgs.push_back("mf-runtime.h"); |
| 1582 | } |
| 1583 | } |
| 1584 | |
Daniel Dunbar | c21c485 | 2009-04-08 23:54:23 +0000 | [diff] [blame] | 1585 | void darwin::CC1::AddCPPArgs(const ArgList &Args, |
Daniel Dunbar | a3ec60e | 2009-03-29 18:40:18 +0000 | [diff] [blame] | 1586 | ArgStringList &CmdArgs) const { |
| 1587 | // Derived from cpp spec. |
| 1588 | |
| 1589 | if (Args.hasArg(options::OPT_static)) { |
| 1590 | // The gcc spec is broken here, it refers to dynamic but |
| 1591 | // that has been translated. Start by being bug compatible. |
Daniel Dunbar | c21c485 | 2009-04-08 23:54:23 +0000 | [diff] [blame] | 1592 | |
Daniel Dunbar | a3ec60e | 2009-03-29 18:40:18 +0000 | [diff] [blame] | 1593 | // if (!Args.hasArg(arglist.parser.dynamicOption)) |
| 1594 | CmdArgs.push_back("-D__STATIC__"); |
| 1595 | } else |
| 1596 | CmdArgs.push_back("-D__DYNAMIC__"); |
| 1597 | |
| 1598 | if (Args.hasArg(options::OPT_pthread)) |
| 1599 | CmdArgs.push_back("-D_REENTRANT"); |
| 1600 | } |
| 1601 | |
Daniel Dunbar | 40f1265 | 2009-03-29 17:08:39 +0000 | [diff] [blame] | 1602 | void darwin::Preprocess::ConstructJob(Compilation &C, const JobAction &JA, |
Daniel Dunbar | c21c485 | 2009-04-08 23:54:23 +0000 | [diff] [blame] | 1603 | Job &Dest, const InputInfo &Output, |
| 1604 | const InputInfoList &Inputs, |
| 1605 | const ArgList &Args, |
Daniel Dunbar | 40f1265 | 2009-03-29 17:08:39 +0000 | [diff] [blame] | 1606 | const char *LinkingOutput) const { |
| 1607 | ArgStringList CmdArgs; |
| 1608 | |
| 1609 | assert(Inputs.size() == 1 && "Unexpected number of inputs!"); |
| 1610 | |
| 1611 | CmdArgs.push_back("-E"); |
| 1612 | |
| 1613 | if (Args.hasArg(options::OPT_traditional) || |
Daniel Dunbar | 40f1265 | 2009-03-29 17:08:39 +0000 | [diff] [blame] | 1614 | Args.hasArg(options::OPT_traditional_cpp)) |
| 1615 | CmdArgs.push_back("-traditional-cpp"); |
Daniel Dunbar | c21c485 | 2009-04-08 23:54:23 +0000 | [diff] [blame] | 1616 | |
Daniel Dunbar | 40f1265 | 2009-03-29 17:08:39 +0000 | [diff] [blame] | 1617 | ArgStringList OutputArgs; |
| 1618 | if (Output.isFilename()) { |
| 1619 | OutputArgs.push_back("-o"); |
| 1620 | OutputArgs.push_back(Output.getFilename()); |
| 1621 | } else { |
| 1622 | assert(Output.isPipe() && "Unexpected CC1 output."); |
| 1623 | } |
| 1624 | |
Daniel Dunbar | 9120f17 | 2009-03-29 22:27:40 +0000 | [diff] [blame] | 1625 | if (Args.hasArg(options::OPT_E)) { |
| 1626 | AddCPPOptionsArgs(Args, CmdArgs, Inputs, OutputArgs); |
| 1627 | } else { |
| 1628 | AddCPPOptionsArgs(Args, CmdArgs, Inputs, ArgStringList()); |
| 1629 | CmdArgs.append(OutputArgs.begin(), OutputArgs.end()); |
| 1630 | } |
Daniel Dunbar | c21c485 | 2009-04-08 23:54:23 +0000 | [diff] [blame] | 1631 | |
Daniel Dunbar | 8a2073a | 2009-04-03 01:27:06 +0000 | [diff] [blame] | 1632 | Args.AddAllArgs(CmdArgs, options::OPT_d_Group); |
| 1633 | |
Daniel Dunbar | 40f1265 | 2009-03-29 17:08:39 +0000 | [diff] [blame] | 1634 | const char *CC1Name = getCC1Name(Inputs[0].getType()); |
Daniel Dunbar | c21c485 | 2009-04-08 23:54:23 +0000 | [diff] [blame] | 1635 | const char *Exec = |
Daniel Dunbar | 5ed34f4 | 2009-09-09 22:33:00 +0000 | [diff] [blame] | 1636 | Args.MakeArgString(getToolChain().GetProgramPath(C, CC1Name)); |
Daniel Dunbar | daab7b1 | 2009-12-02 03:23:25 +0000 | [diff] [blame] | 1637 | Dest.addCommand(new Command(JA, *this, Exec, CmdArgs)); |
Daniel Dunbar | 40f1265 | 2009-03-29 17:08:39 +0000 | [diff] [blame] | 1638 | } |
| 1639 | |
| 1640 | void darwin::Compile::ConstructJob(Compilation &C, const JobAction &JA, |
Daniel Dunbar | c21c485 | 2009-04-08 23:54:23 +0000 | [diff] [blame] | 1641 | Job &Dest, const InputInfo &Output, |
| 1642 | const InputInfoList &Inputs, |
| 1643 | const ArgList &Args, |
Daniel Dunbar | 40f1265 | 2009-03-29 17:08:39 +0000 | [diff] [blame] | 1644 | const char *LinkingOutput) const { |
| 1645 | const Driver &D = getToolChain().getHost().getDriver(); |
| 1646 | ArgStringList CmdArgs; |
| 1647 | |
| 1648 | assert(Inputs.size() == 1 && "Unexpected number of inputs!"); |
| 1649 | |
| 1650 | types::ID InputType = Inputs[0].getType(); |
| 1651 | const Arg *A; |
Eli Friedman | ceb5c5b | 2009-07-14 21:58:17 +0000 | [diff] [blame] | 1652 | if ((A = Args.getLastArg(options::OPT_traditional))) |
Daniel Dunbar | 40f1265 | 2009-03-29 17:08:39 +0000 | [diff] [blame] | 1653 | D.Diag(clang::diag::err_drv_argument_only_allowed_with) |
| 1654 | << A->getAsString(Args) << "-E"; |
| 1655 | |
| 1656 | if (Output.getType() == types::TY_LLVMAsm) |
| 1657 | CmdArgs.push_back("-emit-llvm"); |
| 1658 | else if (Output.getType() == types::TY_LLVMBC) |
| 1659 | CmdArgs.push_back("-emit-llvm-bc"); |
Daniel Dunbar | 5915fbf | 2009-09-01 16:57:46 +0000 | [diff] [blame] | 1660 | else if (Output.getType() == types::TY_AST) |
| 1661 | D.Diag(clang::diag::err_drv_no_ast_support) |
Daniel Dunbar | 8813764 | 2009-09-09 22:32:48 +0000 | [diff] [blame] | 1662 | << getToolChain().getTripleString(); |
Daniel Dunbar | 40f1265 | 2009-03-29 17:08:39 +0000 | [diff] [blame] | 1663 | |
| 1664 | ArgStringList OutputArgs; |
| 1665 | if (Output.getType() != types::TY_PCH) { |
| 1666 | OutputArgs.push_back("-o"); |
| 1667 | if (Output.isPipe()) |
| 1668 | OutputArgs.push_back("-"); |
| 1669 | else if (Output.isNothing()) |
| 1670 | OutputArgs.push_back("/dev/null"); |
| 1671 | else |
| 1672 | OutputArgs.push_back(Output.getFilename()); |
| 1673 | } |
| 1674 | |
| 1675 | // There is no need for this level of compatibility, but it makes |
| 1676 | // diffing easier. |
| 1677 | bool OutputArgsEarly = (Args.hasArg(options::OPT_fsyntax_only) || |
| 1678 | Args.hasArg(options::OPT_S)); |
| 1679 | |
| 1680 | if (types::getPreprocessedType(InputType) != types::TY_INVALID) { |
Daniel Dunbar | a3ec60e | 2009-03-29 18:40:18 +0000 | [diff] [blame] | 1681 | AddCPPUniqueOptionsArgs(Args, CmdArgs, Inputs); |
Daniel Dunbar | 40f1265 | 2009-03-29 17:08:39 +0000 | [diff] [blame] | 1682 | if (OutputArgsEarly) { |
| 1683 | AddCC1OptionsArgs(Args, CmdArgs, Inputs, OutputArgs); |
| 1684 | } else { |
| 1685 | AddCC1OptionsArgs(Args, CmdArgs, Inputs, ArgStringList()); |
| 1686 | CmdArgs.append(OutputArgs.begin(), OutputArgs.end()); |
| 1687 | } |
| 1688 | } else { |
| 1689 | CmdArgs.push_back("-fpreprocessed"); |
Daniel Dunbar | c21c485 | 2009-04-08 23:54:23 +0000 | [diff] [blame] | 1690 | |
Daniel Dunbar | 40f1265 | 2009-03-29 17:08:39 +0000 | [diff] [blame] | 1691 | for (InputInfoList::const_iterator |
| 1692 | it = Inputs.begin(), ie = Inputs.end(); it != ie; ++it) { |
| 1693 | const InputInfo &II = *it; |
| 1694 | |
Daniel Dunbar | 5915fbf | 2009-09-01 16:57:46 +0000 | [diff] [blame] | 1695 | // Reject AST inputs. |
| 1696 | if (II.getType() == types::TY_AST) { |
| 1697 | D.Diag(clang::diag::err_drv_no_ast_support) |
Daniel Dunbar | 8813764 | 2009-09-09 22:32:48 +0000 | [diff] [blame] | 1698 | << getToolChain().getTripleString(); |
Daniel Dunbar | 5915fbf | 2009-09-01 16:57:46 +0000 | [diff] [blame] | 1699 | return; |
| 1700 | } |
| 1701 | |
Daniel Dunbar | 40f1265 | 2009-03-29 17:08:39 +0000 | [diff] [blame] | 1702 | if (II.isPipe()) |
| 1703 | CmdArgs.push_back("-"); |
| 1704 | else |
| 1705 | CmdArgs.push_back(II.getFilename()); |
| 1706 | } |
| 1707 | |
| 1708 | if (OutputArgsEarly) { |
| 1709 | AddCC1OptionsArgs(Args, CmdArgs, Inputs, OutputArgs); |
| 1710 | } else { |
| 1711 | AddCC1OptionsArgs(Args, CmdArgs, Inputs, ArgStringList()); |
| 1712 | CmdArgs.append(OutputArgs.begin(), OutputArgs.end()); |
| 1713 | } |
| 1714 | } |
Daniel Dunbar | c21c485 | 2009-04-08 23:54:23 +0000 | [diff] [blame] | 1715 | |
Daniel Dunbar | 40f1265 | 2009-03-29 17:08:39 +0000 | [diff] [blame] | 1716 | if (Output.getType() == types::TY_PCH) { |
| 1717 | assert(Output.isFilename() && "Invalid PCH output."); |
| 1718 | |
| 1719 | CmdArgs.push_back("-o"); |
| 1720 | // NOTE: gcc uses a temp .s file for this, but there doesn't seem |
| 1721 | // to be a good reason. |
| 1722 | CmdArgs.push_back("/dev/null"); |
Daniel Dunbar | c21c485 | 2009-04-08 23:54:23 +0000 | [diff] [blame] | 1723 | |
Daniel Dunbar | e6c9ae1 | 2009-11-21 02:31:29 +0000 | [diff] [blame] | 1724 | CmdArgs.push_back("--output-pch="); |
Daniel Dunbar | 40f1265 | 2009-03-29 17:08:39 +0000 | [diff] [blame] | 1725 | CmdArgs.push_back(Output.getFilename()); |
Daniel Dunbar | c21c485 | 2009-04-08 23:54:23 +0000 | [diff] [blame] | 1726 | } |
Daniel Dunbar | 40f1265 | 2009-03-29 17:08:39 +0000 | [diff] [blame] | 1727 | |
| 1728 | const char *CC1Name = getCC1Name(Inputs[0].getType()); |
Daniel Dunbar | c21c485 | 2009-04-08 23:54:23 +0000 | [diff] [blame] | 1729 | const char *Exec = |
Daniel Dunbar | 5ed34f4 | 2009-09-09 22:33:00 +0000 | [diff] [blame] | 1730 | Args.MakeArgString(getToolChain().GetProgramPath(C, CC1Name)); |
Daniel Dunbar | daab7b1 | 2009-12-02 03:23:25 +0000 | [diff] [blame] | 1731 | Dest.addCommand(new Command(JA, *this, Exec, CmdArgs)); |
Daniel Dunbar | 40f1265 | 2009-03-29 17:08:39 +0000 | [diff] [blame] | 1732 | } |
| 1733 | |
Daniel Dunbar | 8cac5f7 | 2009-03-20 16:06:39 +0000 | [diff] [blame] | 1734 | void darwin::Assemble::ConstructJob(Compilation &C, const JobAction &JA, |
Daniel Dunbar | c21c485 | 2009-04-08 23:54:23 +0000 | [diff] [blame] | 1735 | Job &Dest, const InputInfo &Output, |
| 1736 | const InputInfoList &Inputs, |
| 1737 | const ArgList &Args, |
Daniel Dunbar | 8cac5f7 | 2009-03-20 16:06:39 +0000 | [diff] [blame] | 1738 | const char *LinkingOutput) const { |
| 1739 | ArgStringList CmdArgs; |
| 1740 | |
| 1741 | assert(Inputs.size() == 1 && "Unexpected number of inputs."); |
| 1742 | const InputInfo &Input = Inputs[0]; |
| 1743 | |
| 1744 | // Bit of a hack, this is only used for original inputs. |
Daniel Dunbar | c21c485 | 2009-04-08 23:54:23 +0000 | [diff] [blame] | 1745 | // |
Daniel Dunbar | 8e4fea6 | 2009-04-01 00:27:44 +0000 | [diff] [blame] | 1746 | // FIXME: This is broken for preprocessed .s inputs. |
Daniel Dunbar | 8cac5f7 | 2009-03-20 16:06:39 +0000 | [diff] [blame] | 1747 | if (Input.isFilename() && |
Daniel Dunbar | 8e4fea6 | 2009-04-01 00:27:44 +0000 | [diff] [blame] | 1748 | strcmp(Input.getFilename(), Input.getBaseInput()) == 0) { |
| 1749 | if (Args.hasArg(options::OPT_gstabs)) |
| 1750 | CmdArgs.push_back("--gstabs"); |
| 1751 | else if (Args.hasArg(options::OPT_g_Group)) |
| 1752 | CmdArgs.push_back("--gdwarf2"); |
| 1753 | } |
Daniel Dunbar | c21c485 | 2009-04-08 23:54:23 +0000 | [diff] [blame] | 1754 | |
Daniel Dunbar | 8cac5f7 | 2009-03-20 16:06:39 +0000 | [diff] [blame] | 1755 | // Derived from asm spec. |
Daniel Dunbar | cc6f803 | 2009-09-09 18:36:27 +0000 | [diff] [blame] | 1756 | AddDarwinArch(Args, CmdArgs); |
Daniel Dunbar | 8cac5f7 | 2009-03-20 16:06:39 +0000 | [diff] [blame] | 1757 | |
Daniel Dunbar | 1d4612b | 2009-09-18 08:15:13 +0000 | [diff] [blame] | 1758 | if (!getDarwinToolChain().isIPhoneOS() || |
Daniel Dunbar | cc6f803 | 2009-09-09 18:36:27 +0000 | [diff] [blame] | 1759 | Args.hasArg(options::OPT_force__cpusubtype__ALL)) |
| 1760 | CmdArgs.push_back("-force_cpusubtype_ALL"); |
| 1761 | |
Daniel Dunbar | 0e2679d | 2009-08-24 22:26:16 +0000 | [diff] [blame] | 1762 | if (getToolChain().getTriple().getArch() != llvm::Triple::x86_64 && |
| 1763 | (Args.hasArg(options::OPT_mkernel) || |
Daniel Dunbar | 8cac5f7 | 2009-03-20 16:06:39 +0000 | [diff] [blame] | 1764 | Args.hasArg(options::OPT_static) || |
Daniel Dunbar | 0e2679d | 2009-08-24 22:26:16 +0000 | [diff] [blame] | 1765 | Args.hasArg(options::OPT_fapple_kext))) |
Daniel Dunbar | c21c485 | 2009-04-08 23:54:23 +0000 | [diff] [blame] | 1766 | CmdArgs.push_back("-static"); |
| 1767 | |
Daniel Dunbar | 8cac5f7 | 2009-03-20 16:06:39 +0000 | [diff] [blame] | 1768 | Args.AddAllArgValues(CmdArgs, options::OPT_Wa_COMMA, |
| 1769 | options::OPT_Xassembler); |
| 1770 | |
| 1771 | assert(Output.isFilename() && "Unexpected lipo output."); |
| 1772 | CmdArgs.push_back("-o"); |
| 1773 | CmdArgs.push_back(Output.getFilename()); |
| 1774 | |
| 1775 | if (Input.isPipe()) { |
| 1776 | CmdArgs.push_back("-"); |
| 1777 | } else { |
| 1778 | assert(Input.isFilename() && "Invalid input."); |
| 1779 | CmdArgs.push_back(Input.getFilename()); |
| 1780 | } |
| 1781 | |
| 1782 | // asm_final spec is empty. |
| 1783 | |
Daniel Dunbar | c21c485 | 2009-04-08 23:54:23 +0000 | [diff] [blame] | 1784 | const char *Exec = |
Daniel Dunbar | 5ed34f4 | 2009-09-09 22:33:00 +0000 | [diff] [blame] | 1785 | Args.MakeArgString(getToolChain().GetProgramPath(C, "as")); |
Daniel Dunbar | daab7b1 | 2009-12-02 03:23:25 +0000 | [diff] [blame] | 1786 | Dest.addCommand(new Command(JA, *this, Exec, CmdArgs)); |
Daniel Dunbar | 8cac5f7 | 2009-03-20 16:06:39 +0000 | [diff] [blame] | 1787 | } |
Daniel Dunbar | ff7488d | 2009-03-20 00:52:38 +0000 | [diff] [blame] | 1788 | |
Daniel Dunbar | 02633b5 | 2009-03-26 16:23:12 +0000 | [diff] [blame] | 1789 | /// Helper routine for seeing if we should use dsymutil; this is a |
| 1790 | /// gcc compatible hack, we should remove it and use the input |
| 1791 | /// type information. |
| 1792 | static bool isSourceSuffix(const char *Str) { |
| 1793 | // match: 'C', 'CPP', 'c', 'cc', 'cp', 'c++', 'cpp', 'cxx', 'm', |
| 1794 | // 'mm'. |
Douglas Gregor | 55d3f7a | 2009-10-29 00:41:01 +0000 | [diff] [blame] | 1795 | return llvm::StringSwitch<bool>(Str) |
| 1796 | .Case("C", true) |
| 1797 | .Case("c", true) |
| 1798 | .Case("m", true) |
| 1799 | .Case("cc", true) |
| 1800 | .Case("cp", true) |
| 1801 | .Case("mm", true) |
| 1802 | .Case("CPP", true) |
| 1803 | .Case("c++", true) |
| 1804 | .Case("cpp", true) |
| 1805 | .Case("cxx", true) |
| 1806 | .Default(false); |
Daniel Dunbar | 02633b5 | 2009-03-26 16:23:12 +0000 | [diff] [blame] | 1807 | } |
| 1808 | |
Daniel Dunbar | 78dbd58 | 2009-09-04 18:35:31 +0000 | [diff] [blame] | 1809 | // FIXME: Can we tablegen this? |
| 1810 | static const char *GetArmArchForMArch(llvm::StringRef Value) { |
| 1811 | if (Value == "armv6k") |
| 1812 | return "armv6"; |
| 1813 | |
| 1814 | if (Value == "armv5tej") |
| 1815 | return "armv5"; |
| 1816 | |
| 1817 | if (Value == "xscale") |
| 1818 | return "xscale"; |
| 1819 | |
| 1820 | if (Value == "armv4t") |
| 1821 | return "armv4t"; |
| 1822 | |
| 1823 | if (Value == "armv7" || Value == "armv7-a" || Value == "armv7-r" || |
| 1824 | Value == "armv7-m" || Value == "armv7a" || Value == "armv7r" || |
| 1825 | Value == "armv7m") |
| 1826 | return "armv7"; |
| 1827 | |
| 1828 | return 0; |
| 1829 | } |
| 1830 | |
| 1831 | // FIXME: Can we tablegen this? |
| 1832 | static const char *GetArmArchForMCpu(llvm::StringRef Value) { |
| 1833 | if (Value == "arm10tdmi" || Value == "arm1020t" || Value == "arm9e" || |
| 1834 | Value == "arm946e-s" || Value == "arm966e-s" || |
| 1835 | Value == "arm968e-s" || Value == "arm10e" || |
| 1836 | Value == "arm1020e" || Value == "arm1022e" || Value == "arm926ej-s" || |
| 1837 | Value == "arm1026ej-s") |
| 1838 | return "armv5"; |
| 1839 | |
| 1840 | if (Value == "xscale") |
| 1841 | return "xscale"; |
| 1842 | |
| 1843 | if (Value == "arm1136j-s" || Value == "arm1136jf-s" || |
| 1844 | Value == "arm1176jz-s" || Value == "arm1176jzf-s") |
| 1845 | return "armv6"; |
| 1846 | |
| 1847 | if (Value == "cortex-a8" || Value == "cortex-r4" || Value == "cortex-m3") |
| 1848 | return "armv7"; |
| 1849 | |
| 1850 | return 0; |
| 1851 | } |
| 1852 | |
Daniel Dunbar | fbefe6b | 2009-09-09 18:36:20 +0000 | [diff] [blame] | 1853 | void darwin::DarwinTool::AddDarwinArch(const ArgList &Args, |
| 1854 | ArgStringList &CmdArgs) const { |
Daniel Dunbar | 02633b5 | 2009-03-26 16:23:12 +0000 | [diff] [blame] | 1855 | // Derived from darwin_arch spec. |
| 1856 | CmdArgs.push_back("-arch"); |
Daniel Dunbar | 78dbd58 | 2009-09-04 18:35:31 +0000 | [diff] [blame] | 1857 | |
| 1858 | switch (getToolChain().getTriple().getArch()) { |
| 1859 | default: |
Daniel Dunbar | 8813764 | 2009-09-09 22:32:48 +0000 | [diff] [blame] | 1860 | CmdArgs.push_back(Args.MakeArgString(getToolChain().getArchName())); |
Daniel Dunbar | 78dbd58 | 2009-09-04 18:35:31 +0000 | [diff] [blame] | 1861 | break; |
| 1862 | |
| 1863 | case llvm::Triple::arm: { |
Daniel Dunbar | 78dbd58 | 2009-09-04 18:35:31 +0000 | [diff] [blame] | 1864 | if (const Arg *A = Args.getLastArg(options::OPT_march_EQ)) { |
| 1865 | if (const char *Arch = GetArmArchForMArch(A->getValue(Args))) { |
| 1866 | CmdArgs.push_back(Arch); |
| 1867 | return; |
| 1868 | } |
| 1869 | } |
| 1870 | |
| 1871 | if (const Arg *A = Args.getLastArg(options::OPT_mcpu_EQ)) { |
| 1872 | if (const char *Arch = GetArmArchForMCpu(A->getValue(Args))) { |
| 1873 | CmdArgs.push_back(Arch); |
| 1874 | return; |
| 1875 | } |
| 1876 | } |
| 1877 | |
| 1878 | CmdArgs.push_back("arm"); |
| 1879 | CmdArgs.push_back("-force_cpusubtype_ALL"); |
| 1880 | return; |
| 1881 | } |
| 1882 | } |
Daniel Dunbar | 02633b5 | 2009-03-26 16:23:12 +0000 | [diff] [blame] | 1883 | } |
| 1884 | |
Daniel Dunbar | fbefe6b | 2009-09-09 18:36:20 +0000 | [diff] [blame] | 1885 | void darwin::DarwinTool::AddDarwinSubArch(const ArgList &Args, |
| 1886 | ArgStringList &CmdArgs) const { |
Daniel Dunbar | 02633b5 | 2009-03-26 16:23:12 +0000 | [diff] [blame] | 1887 | // Derived from darwin_subarch spec, not sure what the distinction |
| 1888 | // exists for but at least for this chain it is the same. |
| 1889 | AddDarwinArch(Args, CmdArgs); |
| 1890 | } |
| 1891 | |
Daniel Dunbar | c21c485 | 2009-04-08 23:54:23 +0000 | [diff] [blame] | 1892 | void darwin::Link::AddLinkArgs(const ArgList &Args, |
Daniel Dunbar | 02633b5 | 2009-03-26 16:23:12 +0000 | [diff] [blame] | 1893 | ArgStringList &CmdArgs) const { |
| 1894 | const Driver &D = getToolChain().getHost().getDriver(); |
| 1895 | |
| 1896 | // Derived from the "link" spec. |
| 1897 | Args.AddAllArgs(CmdArgs, options::OPT_static); |
| 1898 | if (!Args.hasArg(options::OPT_static)) |
| 1899 | CmdArgs.push_back("-dynamic"); |
| 1900 | if (Args.hasArg(options::OPT_fgnu_runtime)) { |
| 1901 | // FIXME: gcc replaces -lobjc in forward args with -lobjc-gnu |
| 1902 | // here. How do we wish to handle such things? |
| 1903 | } |
Daniel Dunbar | c21c485 | 2009-04-08 23:54:23 +0000 | [diff] [blame] | 1904 | |
Daniel Dunbar | 02633b5 | 2009-03-26 16:23:12 +0000 | [diff] [blame] | 1905 | if (!Args.hasArg(options::OPT_dynamiclib)) { |
| 1906 | if (Args.hasArg(options::OPT_force__cpusubtype__ALL)) { |
| 1907 | AddDarwinArch(Args, CmdArgs); |
| 1908 | CmdArgs.push_back("-force_cpusubtype_ALL"); |
| 1909 | } else |
| 1910 | AddDarwinSubArch(Args, CmdArgs); |
| 1911 | |
| 1912 | Args.AddLastArg(CmdArgs, options::OPT_bundle); |
| 1913 | Args.AddAllArgs(CmdArgs, options::OPT_bundle__loader); |
| 1914 | Args.AddAllArgs(CmdArgs, options::OPT_client__name); |
| 1915 | |
| 1916 | Arg *A; |
| 1917 | if ((A = Args.getLastArg(options::OPT_compatibility__version)) || |
| 1918 | (A = Args.getLastArg(options::OPT_current__version)) || |
| 1919 | (A = Args.getLastArg(options::OPT_install__name))) |
| 1920 | D.Diag(clang::diag::err_drv_argument_only_allowed_with) |
| 1921 | << A->getAsString(Args) << "-dynamiclib"; |
| 1922 | |
| 1923 | Args.AddLastArg(CmdArgs, options::OPT_force__flat__namespace); |
| 1924 | Args.AddLastArg(CmdArgs, options::OPT_keep__private__externs); |
| 1925 | Args.AddLastArg(CmdArgs, options::OPT_private__bundle); |
| 1926 | } else { |
| 1927 | CmdArgs.push_back("-dylib"); |
| 1928 | |
| 1929 | Arg *A; |
| 1930 | if ((A = Args.getLastArg(options::OPT_bundle)) || |
| 1931 | (A = Args.getLastArg(options::OPT_bundle__loader)) || |
| 1932 | (A = Args.getLastArg(options::OPT_client__name)) || |
| 1933 | (A = Args.getLastArg(options::OPT_force__flat__namespace)) || |
| 1934 | (A = Args.getLastArg(options::OPT_keep__private__externs)) || |
| 1935 | (A = Args.getLastArg(options::OPT_private__bundle))) |
| 1936 | D.Diag(clang::diag::err_drv_argument_not_allowed_with) |
| 1937 | << A->getAsString(Args) << "-dynamiclib"; |
Daniel Dunbar | c21c485 | 2009-04-08 23:54:23 +0000 | [diff] [blame] | 1938 | |
Daniel Dunbar | 02633b5 | 2009-03-26 16:23:12 +0000 | [diff] [blame] | 1939 | Args.AddAllArgsTranslated(CmdArgs, options::OPT_compatibility__version, |
| 1940 | "-dylib_compatibility_version"); |
| 1941 | Args.AddAllArgsTranslated(CmdArgs, options::OPT_current__version, |
| 1942 | "-dylib_current_version"); |
| 1943 | |
| 1944 | if (Args.hasArg(options::OPT_force__cpusubtype__ALL)) { |
| 1945 | AddDarwinArch(Args, CmdArgs); |
Daniel Dunbar | c21c485 | 2009-04-08 23:54:23 +0000 | [diff] [blame] | 1946 | // NOTE: We don't add -force_cpusubtype_ALL on this path. Ok. |
Daniel Dunbar | 02633b5 | 2009-03-26 16:23:12 +0000 | [diff] [blame] | 1947 | } else |
| 1948 | AddDarwinSubArch(Args, CmdArgs); |
| 1949 | |
| 1950 | Args.AddAllArgsTranslated(CmdArgs, options::OPT_install__name, |
| 1951 | "-dylib_install_name"); |
| 1952 | } |
| 1953 | |
| 1954 | Args.AddLastArg(CmdArgs, options::OPT_all__load); |
| 1955 | Args.AddAllArgs(CmdArgs, options::OPT_allowable__client); |
| 1956 | Args.AddLastArg(CmdArgs, options::OPT_bind__at__load); |
Daniel Dunbar | 1d4612b | 2009-09-18 08:15:13 +0000 | [diff] [blame] | 1957 | if (getDarwinToolChain().isIPhoneOS()) |
Daniel Dunbar | d82f8fa | 2009-09-04 18:35:41 +0000 | [diff] [blame] | 1958 | Args.AddLastArg(CmdArgs, options::OPT_arch__errors__fatal); |
Daniel Dunbar | 02633b5 | 2009-03-26 16:23:12 +0000 | [diff] [blame] | 1959 | Args.AddLastArg(CmdArgs, options::OPT_dead__strip); |
| 1960 | Args.AddLastArg(CmdArgs, options::OPT_no__dead__strip__inits__and__terms); |
| 1961 | Args.AddAllArgs(CmdArgs, options::OPT_dylib__file); |
| 1962 | Args.AddLastArg(CmdArgs, options::OPT_dynamic); |
| 1963 | Args.AddAllArgs(CmdArgs, options::OPT_exported__symbols__list); |
| 1964 | Args.AddLastArg(CmdArgs, options::OPT_flat__namespace); |
| 1965 | Args.AddAllArgs(CmdArgs, options::OPT_headerpad__max__install__names); |
| 1966 | Args.AddAllArgs(CmdArgs, options::OPT_image__base); |
| 1967 | Args.AddAllArgs(CmdArgs, options::OPT_init); |
| 1968 | |
Daniel Dunbar | 30392de | 2009-09-04 18:35:21 +0000 | [diff] [blame] | 1969 | if (!Args.hasArg(options::OPT_mmacosx_version_min_EQ) && |
| 1970 | !Args.hasArg(options::OPT_miphoneos_version_min_EQ)) { |
| 1971 | // Add default version min. |
Daniel Dunbar | 1d4612b | 2009-09-18 08:15:13 +0000 | [diff] [blame] | 1972 | if (!getDarwinToolChain().isIPhoneOS()) { |
Daniel Dunbar | c21c485 | 2009-04-08 23:54:23 +0000 | [diff] [blame] | 1973 | CmdArgs.push_back("-macosx_version_min"); |
| 1974 | CmdArgs.push_back(getDarwinToolChain().getMacosxVersionStr()); |
Daniel Dunbar | 30392de | 2009-09-04 18:35:21 +0000 | [diff] [blame] | 1975 | } else { |
| 1976 | CmdArgs.push_back("-iphoneos_version_min"); |
| 1977 | CmdArgs.push_back(getDarwinToolChain().getIPhoneOSVersionStr()); |
Daniel Dunbar | c21c485 | 2009-04-08 23:54:23 +0000 | [diff] [blame] | 1978 | } |
Daniel Dunbar | 02633b5 | 2009-03-26 16:23:12 +0000 | [diff] [blame] | 1979 | } |
| 1980 | |
Daniel Dunbar | 30392de | 2009-09-04 18:35:21 +0000 | [diff] [blame] | 1981 | // Adding all arguments doesn't make sense here but this is what |
| 1982 | // gcc does. |
| 1983 | Args.AddAllArgsTranslated(CmdArgs, options::OPT_mmacosx_version_min_EQ, |
Daniel Dunbar | 294691e | 2009-11-04 06:24:38 +0000 | [diff] [blame] | 1984 | "-macosx_version_min"); |
Daniel Dunbar | 02633b5 | 2009-03-26 16:23:12 +0000 | [diff] [blame] | 1985 | Args.AddAllArgsTranslated(CmdArgs, options::OPT_miphoneos_version_min_EQ, |
| 1986 | "-iphoneos_version_min"); |
| 1987 | Args.AddLastArg(CmdArgs, options::OPT_nomultidefs); |
| 1988 | Args.AddLastArg(CmdArgs, options::OPT_multi__module); |
| 1989 | Args.AddLastArg(CmdArgs, options::OPT_single__module); |
| 1990 | Args.AddAllArgs(CmdArgs, options::OPT_multiply__defined); |
| 1991 | Args.AddAllArgs(CmdArgs, options::OPT_multiply__defined__unused); |
Daniel Dunbar | c21c485 | 2009-04-08 23:54:23 +0000 | [diff] [blame] | 1992 | |
Daniel Dunbar | 02633b5 | 2009-03-26 16:23:12 +0000 | [diff] [blame] | 1993 | if (Args.hasArg(options::OPT_fpie)) |
| 1994 | CmdArgs.push_back("-pie"); |
| 1995 | |
| 1996 | Args.AddLastArg(CmdArgs, options::OPT_prebind); |
| 1997 | Args.AddLastArg(CmdArgs, options::OPT_noprebind); |
| 1998 | Args.AddLastArg(CmdArgs, options::OPT_nofixprebinding); |
| 1999 | Args.AddLastArg(CmdArgs, options::OPT_prebind__all__twolevel__modules); |
| 2000 | Args.AddLastArg(CmdArgs, options::OPT_read__only__relocs); |
| 2001 | Args.AddAllArgs(CmdArgs, options::OPT_sectcreate); |
| 2002 | Args.AddAllArgs(CmdArgs, options::OPT_sectorder); |
| 2003 | Args.AddAllArgs(CmdArgs, options::OPT_seg1addr); |
| 2004 | Args.AddAllArgs(CmdArgs, options::OPT_segprot); |
| 2005 | Args.AddAllArgs(CmdArgs, options::OPT_segaddr); |
| 2006 | Args.AddAllArgs(CmdArgs, options::OPT_segs__read__only__addr); |
| 2007 | Args.AddAllArgs(CmdArgs, options::OPT_segs__read__write__addr); |
| 2008 | Args.AddAllArgs(CmdArgs, options::OPT_seg__addr__table); |
| 2009 | Args.AddAllArgs(CmdArgs, options::OPT_seg__addr__table__filename); |
| 2010 | Args.AddAllArgs(CmdArgs, options::OPT_sub__library); |
| 2011 | Args.AddAllArgs(CmdArgs, options::OPT_sub__umbrella); |
Daniel Dunbar | d82f8fa | 2009-09-04 18:35:41 +0000 | [diff] [blame] | 2012 | |
Daniel Dunbar | 02633b5 | 2009-03-26 16:23:12 +0000 | [diff] [blame] | 2013 | Args.AddAllArgsTranslated(CmdArgs, options::OPT_isysroot, "-syslibroot"); |
Daniel Dunbar | 1d4612b | 2009-09-18 08:15:13 +0000 | [diff] [blame] | 2014 | if (getDarwinToolChain().isIPhoneOS()) { |
Daniel Dunbar | d82f8fa | 2009-09-04 18:35:41 +0000 | [diff] [blame] | 2015 | if (!Args.hasArg(options::OPT_isysroot)) { |
| 2016 | CmdArgs.push_back("-syslibroot"); |
| 2017 | CmdArgs.push_back("/Developer/SDKs/Extra"); |
| 2018 | } |
| 2019 | } |
| 2020 | |
Daniel Dunbar | 02633b5 | 2009-03-26 16:23:12 +0000 | [diff] [blame] | 2021 | Args.AddLastArg(CmdArgs, options::OPT_twolevel__namespace); |
| 2022 | Args.AddLastArg(CmdArgs, options::OPT_twolevel__namespace__hints); |
| 2023 | Args.AddAllArgs(CmdArgs, options::OPT_umbrella); |
| 2024 | Args.AddAllArgs(CmdArgs, options::OPT_undefined); |
| 2025 | Args.AddAllArgs(CmdArgs, options::OPT_unexported__symbols__list); |
Daniel Dunbar | 02633b5 | 2009-03-26 16:23:12 +0000 | [diff] [blame] | 2026 | |
Daniel Dunbar | d82f8fa | 2009-09-04 18:35:41 +0000 | [diff] [blame] | 2027 | Args.AddAllArgs(CmdArgs, options::OPT_weak__reference__mismatches); |
Daniel Dunbar | 02633b5 | 2009-03-26 16:23:12 +0000 | [diff] [blame] | 2028 | if (!Args.hasArg(options::OPT_weak__reference__mismatches)) { |
| 2029 | CmdArgs.push_back("-weak_reference_mismatches"); |
| 2030 | CmdArgs.push_back("non-weak"); |
| 2031 | } |
| 2032 | |
| 2033 | Args.AddLastArg(CmdArgs, options::OPT_X_Flag); |
| 2034 | Args.AddAllArgs(CmdArgs, options::OPT_y); |
| 2035 | Args.AddLastArg(CmdArgs, options::OPT_w); |
| 2036 | Args.AddAllArgs(CmdArgs, options::OPT_pagezero__size); |
| 2037 | Args.AddAllArgs(CmdArgs, options::OPT_segs__read__); |
| 2038 | Args.AddLastArg(CmdArgs, options::OPT_seglinkedit); |
| 2039 | Args.AddLastArg(CmdArgs, options::OPT_noseglinkedit); |
| 2040 | Args.AddAllArgs(CmdArgs, options::OPT_sectalign); |
| 2041 | Args.AddAllArgs(CmdArgs, options::OPT_sectobjectsymbols); |
| 2042 | Args.AddAllArgs(CmdArgs, options::OPT_segcreate); |
| 2043 | Args.AddLastArg(CmdArgs, options::OPT_whyload); |
| 2044 | Args.AddLastArg(CmdArgs, options::OPT_whatsloaded); |
| 2045 | Args.AddAllArgs(CmdArgs, options::OPT_dylinker__install__name); |
| 2046 | Args.AddLastArg(CmdArgs, options::OPT_dylinker); |
| 2047 | Args.AddLastArg(CmdArgs, options::OPT_Mach); |
| 2048 | } |
| 2049 | |
| 2050 | void darwin::Link::ConstructJob(Compilation &C, const JobAction &JA, |
Daniel Dunbar | c21c485 | 2009-04-08 23:54:23 +0000 | [diff] [blame] | 2051 | Job &Dest, const InputInfo &Output, |
| 2052 | const InputInfoList &Inputs, |
| 2053 | const ArgList &Args, |
Daniel Dunbar | 02633b5 | 2009-03-26 16:23:12 +0000 | [diff] [blame] | 2054 | const char *LinkingOutput) const { |
| 2055 | assert(Output.getType() == types::TY_Image && "Invalid linker output type."); |
Daniel Dunbar | e0be8b1 | 2009-09-08 16:39:16 +0000 | [diff] [blame] | 2056 | |
Daniel Dunbar | 02633b5 | 2009-03-26 16:23:12 +0000 | [diff] [blame] | 2057 | // The logic here is derived from gcc's behavior; most of which |
| 2058 | // comes from specs (starting with link_command). Consult gcc for |
| 2059 | // more information. |
Daniel Dunbar | 02633b5 | 2009-03-26 16:23:12 +0000 | [diff] [blame] | 2060 | ArgStringList CmdArgs; |
| 2061 | |
| 2062 | // I'm not sure why this particular decomposition exists in gcc, but |
| 2063 | // we follow suite for ease of comparison. |
| 2064 | AddLinkArgs(Args, CmdArgs); |
| 2065 | |
Daniel Dunbar | 02633b5 | 2009-03-26 16:23:12 +0000 | [diff] [blame] | 2066 | Args.AddAllArgs(CmdArgs, options::OPT_d_Flag); |
| 2067 | Args.AddAllArgs(CmdArgs, options::OPT_s); |
| 2068 | Args.AddAllArgs(CmdArgs, options::OPT_t); |
| 2069 | Args.AddAllArgs(CmdArgs, options::OPT_Z_Flag); |
| 2070 | Args.AddAllArgs(CmdArgs, options::OPT_u_Group); |
| 2071 | Args.AddAllArgs(CmdArgs, options::OPT_A); |
| 2072 | Args.AddLastArg(CmdArgs, options::OPT_e); |
| 2073 | Args.AddAllArgs(CmdArgs, options::OPT_m_Separate); |
| 2074 | Args.AddAllArgs(CmdArgs, options::OPT_r); |
| 2075 | |
Daniel Dunbar | 02633b5 | 2009-03-26 16:23:12 +0000 | [diff] [blame] | 2076 | CmdArgs.push_back("-o"); |
| 2077 | CmdArgs.push_back(Output.getFilename()); |
| 2078 | |
Daniel Dunbar | 608d04c | 2009-09-18 08:14:55 +0000 | [diff] [blame] | 2079 | |
Daniel Dunbar | ae54af2 | 2009-09-18 08:14:24 +0000 | [diff] [blame] | 2080 | unsigned MacosxVersionMin[3]; |
Daniel Dunbar | 48d5aae | 2009-09-18 08:14:46 +0000 | [diff] [blame] | 2081 | getDarwinToolChain().getMacosxVersionMin(Args, MacosxVersionMin); |
Daniel Dunbar | c21c485 | 2009-04-08 23:54:23 +0000 | [diff] [blame] | 2082 | |
Daniel Dunbar | 02633b5 | 2009-03-26 16:23:12 +0000 | [diff] [blame] | 2083 | if (!Args.hasArg(options::OPT_A) && |
| 2084 | !Args.hasArg(options::OPT_nostdlib) && |
| 2085 | !Args.hasArg(options::OPT_nostartfiles)) { |
| 2086 | // Derived from startfile spec. |
| 2087 | if (Args.hasArg(options::OPT_dynamiclib)) { |
Daniel Dunbar | c21c485 | 2009-04-08 23:54:23 +0000 | [diff] [blame] | 2088 | // Derived from darwin_dylib1 spec. |
Daniel Dunbar | 608d04c | 2009-09-18 08:14:55 +0000 | [diff] [blame] | 2089 | if (getDarwinToolChain().isMacosxVersionLT(MacosxVersionMin, 10, 5)) |
Daniel Dunbar | 02633b5 | 2009-03-26 16:23:12 +0000 | [diff] [blame] | 2090 | CmdArgs.push_back("-ldylib1.o"); |
Daniel Dunbar | 608d04c | 2009-09-18 08:14:55 +0000 | [diff] [blame] | 2091 | else if (getDarwinToolChain().isMacosxVersionLT(MacosxVersionMin, 10, 6)) |
Daniel Dunbar | 02633b5 | 2009-03-26 16:23:12 +0000 | [diff] [blame] | 2092 | CmdArgs.push_back("-ldylib1.10.5.o"); |
| 2093 | } else { |
| 2094 | if (Args.hasArg(options::OPT_bundle)) { |
Daniel Dunbar | 8a8d8af | 2009-04-01 03:17:40 +0000 | [diff] [blame] | 2095 | if (!Args.hasArg(options::OPT_static)) { |
| 2096 | // Derived from darwin_bundle1 spec. |
Daniel Dunbar | 608d04c | 2009-09-18 08:14:55 +0000 | [diff] [blame] | 2097 | if (getDarwinToolChain().isMacosxVersionLT(MacosxVersionMin, 10, 6)) |
Daniel Dunbar | 8a8d8af | 2009-04-01 03:17:40 +0000 | [diff] [blame] | 2098 | CmdArgs.push_back("-lbundle1.o"); |
| 2099 | } |
Daniel Dunbar | 02633b5 | 2009-03-26 16:23:12 +0000 | [diff] [blame] | 2100 | } else { |
| 2101 | if (Args.hasArg(options::OPT_pg)) { |
| 2102 | if (Args.hasArg(options::OPT_static) || |
| 2103 | Args.hasArg(options::OPT_object) || |
| 2104 | Args.hasArg(options::OPT_preload)) { |
| 2105 | CmdArgs.push_back("-lgcrt0.o"); |
| 2106 | } else { |
| 2107 | CmdArgs.push_back("-lgcrt1.o"); |
Daniel Dunbar | c21c485 | 2009-04-08 23:54:23 +0000 | [diff] [blame] | 2108 | |
Daniel Dunbar | 02633b5 | 2009-03-26 16:23:12 +0000 | [diff] [blame] | 2109 | // darwin_crt2 spec is empty. |
Daniel Dunbar | c21c485 | 2009-04-08 23:54:23 +0000 | [diff] [blame] | 2110 | } |
Daniel Dunbar | 02633b5 | 2009-03-26 16:23:12 +0000 | [diff] [blame] | 2111 | } else { |
| 2112 | if (Args.hasArg(options::OPT_static) || |
| 2113 | Args.hasArg(options::OPT_object) || |
| 2114 | Args.hasArg(options::OPT_preload)) { |
| 2115 | CmdArgs.push_back("-lcrt0.o"); |
| 2116 | } else { |
| 2117 | // Derived from darwin_crt1 spec. |
Daniel Dunbar | 1d4612b | 2009-09-18 08:15:13 +0000 | [diff] [blame] | 2118 | if (getDarwinToolChain().isIPhoneOS()) { |
Daniel Dunbar | ae33f8f | 2009-09-04 18:35:47 +0000 | [diff] [blame] | 2119 | CmdArgs.push_back("-lcrt1.o"); |
Daniel Dunbar | 608d04c | 2009-09-18 08:14:55 +0000 | [diff] [blame] | 2120 | } else if (getDarwinToolChain().isMacosxVersionLT(MacosxVersionMin, |
| 2121 | 10, 5)) |
Daniel Dunbar | 02633b5 | 2009-03-26 16:23:12 +0000 | [diff] [blame] | 2122 | CmdArgs.push_back("-lcrt1.o"); |
Daniel Dunbar | 608d04c | 2009-09-18 08:14:55 +0000 | [diff] [blame] | 2123 | else if (getDarwinToolChain().isMacosxVersionLT(MacosxVersionMin, |
| 2124 | 10, 6)) |
Daniel Dunbar | 02633b5 | 2009-03-26 16:23:12 +0000 | [diff] [blame] | 2125 | CmdArgs.push_back("-lcrt1.10.5.o"); |
Daniel Dunbar | 8a8d8af | 2009-04-01 03:17:40 +0000 | [diff] [blame] | 2126 | else |
| 2127 | CmdArgs.push_back("-lcrt1.10.6.o"); |
Daniel Dunbar | c21c485 | 2009-04-08 23:54:23 +0000 | [diff] [blame] | 2128 | |
Daniel Dunbar | 8a8d8af | 2009-04-01 03:17:40 +0000 | [diff] [blame] | 2129 | // darwin_crt2 spec is empty. |
Daniel Dunbar | 02633b5 | 2009-03-26 16:23:12 +0000 | [diff] [blame] | 2130 | } |
| 2131 | } |
| 2132 | } |
| 2133 | } |
| 2134 | |
| 2135 | if (Args.hasArg(options::OPT_shared_libgcc) && |
| 2136 | !Args.hasArg(options::OPT_miphoneos_version_min_EQ) && |
Daniel Dunbar | 608d04c | 2009-09-18 08:14:55 +0000 | [diff] [blame] | 2137 | getDarwinToolChain().isMacosxVersionLT(MacosxVersionMin, 10, 5)) { |
Daniel Dunbar | 8813764 | 2009-09-09 22:32:48 +0000 | [diff] [blame] | 2138 | const char *Str = |
Daniel Dunbar | 5ed34f4 | 2009-09-09 22:33:00 +0000 | [diff] [blame] | 2139 | Args.MakeArgString(getToolChain().GetFilePath(C, "crt3.o")); |
Daniel Dunbar | 8813764 | 2009-09-09 22:32:48 +0000 | [diff] [blame] | 2140 | CmdArgs.push_back(Str); |
Daniel Dunbar | 02633b5 | 2009-03-26 16:23:12 +0000 | [diff] [blame] | 2141 | } |
| 2142 | } |
| 2143 | |
| 2144 | Args.AddAllArgs(CmdArgs, options::OPT_L); |
Daniel Dunbar | c21c485 | 2009-04-08 23:54:23 +0000 | [diff] [blame] | 2145 | |
Daniel Dunbar | 02633b5 | 2009-03-26 16:23:12 +0000 | [diff] [blame] | 2146 | if (Args.hasArg(options::OPT_fopenmp)) |
| 2147 | // This is more complicated in gcc... |
| 2148 | CmdArgs.push_back("-lgomp"); |
| 2149 | |
Daniel Dunbar | 6b200b2 | 2009-09-18 08:14:36 +0000 | [diff] [blame] | 2150 | getDarwinToolChain().AddLinkSearchPathArgs(Args, CmdArgs); |
Daniel Dunbar | c21c485 | 2009-04-08 23:54:23 +0000 | [diff] [blame] | 2151 | |
Daniel Dunbar | 02633b5 | 2009-03-26 16:23:12 +0000 | [diff] [blame] | 2152 | for (InputInfoList::const_iterator |
| 2153 | it = Inputs.begin(), ie = Inputs.end(); it != ie; ++it) { |
| 2154 | const InputInfo &II = *it; |
| 2155 | if (II.isFilename()) |
| 2156 | CmdArgs.push_back(II.getFilename()); |
Daniel Dunbar | c21c485 | 2009-04-08 23:54:23 +0000 | [diff] [blame] | 2157 | else |
Daniel Dunbar | 02633b5 | 2009-03-26 16:23:12 +0000 | [diff] [blame] | 2158 | II.getInputArg().renderAsInput(Args, CmdArgs); |
| 2159 | } |
| 2160 | |
| 2161 | if (LinkingOutput) { |
| 2162 | CmdArgs.push_back("-arch_multiple"); |
| 2163 | CmdArgs.push_back("-final_output"); |
| 2164 | CmdArgs.push_back(LinkingOutput); |
| 2165 | } |
| 2166 | |
| 2167 | if (Args.hasArg(options::OPT_fprofile_arcs) || |
| 2168 | Args.hasArg(options::OPT_fprofile_generate) || |
| 2169 | Args.hasArg(options::OPT_fcreate_profile) || |
| 2170 | Args.hasArg(options::OPT_coverage)) |
| 2171 | CmdArgs.push_back("-lgcov"); |
Daniel Dunbar | c21c485 | 2009-04-08 23:54:23 +0000 | [diff] [blame] | 2172 | |
Daniel Dunbar | 02633b5 | 2009-03-26 16:23:12 +0000 | [diff] [blame] | 2173 | if (Args.hasArg(options::OPT_fnested_functions)) |
| 2174 | CmdArgs.push_back("-allow_stack_execute"); |
Daniel Dunbar | c21c485 | 2009-04-08 23:54:23 +0000 | [diff] [blame] | 2175 | |
Daniel Dunbar | 02633b5 | 2009-03-26 16:23:12 +0000 | [diff] [blame] | 2176 | if (!Args.hasArg(options::OPT_nostdlib) && |
| 2177 | !Args.hasArg(options::OPT_nodefaultlibs)) { |
Daniel Dunbar | edfa02b | 2009-04-08 06:06:21 +0000 | [diff] [blame] | 2178 | // FIXME: g++ is more complicated here, it tries to put -lstdc++ |
| 2179 | // before -lm, for example. |
| 2180 | if (getToolChain().getHost().getDriver().CCCIsCXX) |
| 2181 | CmdArgs.push_back("-lstdc++"); |
| 2182 | |
Daniel Dunbar | 02633b5 | 2009-03-26 16:23:12 +0000 | [diff] [blame] | 2183 | // link_ssp spec is empty. |
| 2184 | |
Daniel Dunbar | 6cd4154 | 2009-09-18 08:15:03 +0000 | [diff] [blame] | 2185 | // Let the tool chain choose which runtime library to link. |
| 2186 | getDarwinToolChain().AddLinkRuntimeLibArgs(Args, CmdArgs); |
Daniel Dunbar | 02633b5 | 2009-03-26 16:23:12 +0000 | [diff] [blame] | 2187 | } |
| 2188 | |
| 2189 | if (!Args.hasArg(options::OPT_A) && |
| 2190 | !Args.hasArg(options::OPT_nostdlib) && |
| 2191 | !Args.hasArg(options::OPT_nostartfiles)) { |
| 2192 | // endfile_spec is empty. |
| 2193 | } |
| 2194 | |
| 2195 | Args.AddAllArgs(CmdArgs, options::OPT_T_Group); |
| 2196 | Args.AddAllArgs(CmdArgs, options::OPT_F); |
| 2197 | |
Daniel Dunbar | c21c485 | 2009-04-08 23:54:23 +0000 | [diff] [blame] | 2198 | const char *Exec = |
Daniel Dunbar | 5ed34f4 | 2009-09-09 22:33:00 +0000 | [diff] [blame] | 2199 | Args.MakeArgString(getToolChain().GetProgramPath(C, "ld")); |
Daniel Dunbar | daab7b1 | 2009-12-02 03:23:25 +0000 | [diff] [blame] | 2200 | Dest.addCommand(new Command(JA, *this, Exec, CmdArgs)); |
Daniel Dunbar | 02633b5 | 2009-03-26 16:23:12 +0000 | [diff] [blame] | 2201 | |
Daniel Dunbar | 0b46e1b | 2009-04-04 00:55:30 +0000 | [diff] [blame] | 2202 | // Find the first non-empty base input (we want to ignore linker |
| 2203 | // inputs). |
| 2204 | const char *BaseInput = ""; |
| 2205 | for (unsigned i = 0, e = Inputs.size(); i != e; ++i) { |
| 2206 | if (Inputs[i].getBaseInput()[0] != '\0') { |
| 2207 | BaseInput = Inputs[i].getBaseInput(); |
| 2208 | break; |
| 2209 | } |
| 2210 | } |
Daniel Dunbar | c21c485 | 2009-04-08 23:54:23 +0000 | [diff] [blame] | 2211 | |
Daniel Dunbar | 3ed2945 | 2009-04-24 03:03:52 +0000 | [diff] [blame] | 2212 | // Run dsymutil if we are making an executable in a single step. |
| 2213 | // |
| 2214 | // FIXME: Currently we don't want to do this when we are part of a |
| 2215 | // universal build step, as this would end up creating stray temp |
| 2216 | // files. |
| 2217 | if (!LinkingOutput && |
| 2218 | Args.getLastArg(options::OPT_g_Group) && |
Daniel Dunbar | 02633b5 | 2009-03-26 16:23:12 +0000 | [diff] [blame] | 2219 | !Args.getLastArg(options::OPT_gstabs) && |
| 2220 | !Args.getLastArg(options::OPT_g0)) { |
| 2221 | // FIXME: This is gross, but matches gcc. The test only considers |
| 2222 | // the suffix (not the -x type), and then only of the first |
Daniel Dunbar | 0b46e1b | 2009-04-04 00:55:30 +0000 | [diff] [blame] | 2223 | // source input. Awesome. |
| 2224 | const char *Suffix = strrchr(BaseInput, '.'); |
Daniel Dunbar | 02633b5 | 2009-03-26 16:23:12 +0000 | [diff] [blame] | 2225 | if (Suffix && isSourceSuffix(Suffix + 1)) { |
Daniel Dunbar | c21c485 | 2009-04-08 23:54:23 +0000 | [diff] [blame] | 2226 | const char *Exec = |
Daniel Dunbar | 5ed34f4 | 2009-09-09 22:33:00 +0000 | [diff] [blame] | 2227 | Args.MakeArgString(getToolChain().GetProgramPath(C, "dsymutil")); |
Daniel Dunbar | 02633b5 | 2009-03-26 16:23:12 +0000 | [diff] [blame] | 2228 | ArgStringList CmdArgs; |
| 2229 | CmdArgs.push_back(Output.getFilename()); |
Daniel Dunbar | daab7b1 | 2009-12-02 03:23:25 +0000 | [diff] [blame] | 2230 | C.getJobs().addCommand(new Command(JA, *this, Exec, CmdArgs)); |
Daniel Dunbar | 02633b5 | 2009-03-26 16:23:12 +0000 | [diff] [blame] | 2231 | } |
| 2232 | } |
| 2233 | } |
| 2234 | |
Daniel Dunbar | ff7488d | 2009-03-20 00:52:38 +0000 | [diff] [blame] | 2235 | void darwin::Lipo::ConstructJob(Compilation &C, const JobAction &JA, |
Daniel Dunbar | c21c485 | 2009-04-08 23:54:23 +0000 | [diff] [blame] | 2236 | Job &Dest, const InputInfo &Output, |
| 2237 | const InputInfoList &Inputs, |
| 2238 | const ArgList &Args, |
Daniel Dunbar | ff7488d | 2009-03-20 00:52:38 +0000 | [diff] [blame] | 2239 | const char *LinkingOutput) const { |
| 2240 | ArgStringList CmdArgs; |
| 2241 | |
| 2242 | CmdArgs.push_back("-create"); |
| 2243 | assert(Output.isFilename() && "Unexpected lipo output."); |
Daniel Dunbar | a428df8 | 2009-03-24 00:24:37 +0000 | [diff] [blame] | 2244 | |
| 2245 | CmdArgs.push_back("-output"); |
Daniel Dunbar | ff7488d | 2009-03-20 00:52:38 +0000 | [diff] [blame] | 2246 | CmdArgs.push_back(Output.getFilename()); |
Daniel Dunbar | a428df8 | 2009-03-24 00:24:37 +0000 | [diff] [blame] | 2247 | |
Daniel Dunbar | ff7488d | 2009-03-20 00:52:38 +0000 | [diff] [blame] | 2248 | for (InputInfoList::const_iterator |
| 2249 | it = Inputs.begin(), ie = Inputs.end(); it != ie; ++it) { |
| 2250 | const InputInfo &II = *it; |
| 2251 | assert(II.isFilename() && "Unexpected lipo input."); |
| 2252 | CmdArgs.push_back(II.getFilename()); |
| 2253 | } |
Daniel Dunbar | c21c485 | 2009-04-08 23:54:23 +0000 | [diff] [blame] | 2254 | const char *Exec = |
Daniel Dunbar | 5ed34f4 | 2009-09-09 22:33:00 +0000 | [diff] [blame] | 2255 | Args.MakeArgString(getToolChain().GetProgramPath(C, "lipo")); |
Daniel Dunbar | daab7b1 | 2009-12-02 03:23:25 +0000 | [diff] [blame] | 2256 | Dest.addCommand(new Command(JA, *this, Exec, CmdArgs)); |
Daniel Dunbar | ff7488d | 2009-03-20 00:52:38 +0000 | [diff] [blame] | 2257 | } |
Daniel Dunbar | 68a31d4 | 2009-03-31 17:45:15 +0000 | [diff] [blame] | 2258 | |
Edward O'Callaghan | e7925a0 | 2009-08-22 01:06:46 +0000 | [diff] [blame] | 2259 | void auroraux::Assemble::ConstructJob(Compilation &C, const JobAction &JA, |
Daniel Dunbar | 294691e | 2009-11-04 06:24:38 +0000 | [diff] [blame] | 2260 | Job &Dest, const InputInfo &Output, |
| 2261 | const InputInfoList &Inputs, |
| 2262 | const ArgList &Args, |
| 2263 | const char *LinkingOutput) const { |
Edward O'Callaghan | e7925a0 | 2009-08-22 01:06:46 +0000 | [diff] [blame] | 2264 | ArgStringList CmdArgs; |
| 2265 | |
| 2266 | Args.AddAllArgValues(CmdArgs, options::OPT_Wa_COMMA, |
| 2267 | options::OPT_Xassembler); |
| 2268 | |
| 2269 | CmdArgs.push_back("-o"); |
| 2270 | if (Output.isPipe()) |
| 2271 | CmdArgs.push_back("-"); |
| 2272 | else |
| 2273 | CmdArgs.push_back(Output.getFilename()); |
| 2274 | |
| 2275 | for (InputInfoList::const_iterator |
| 2276 | it = Inputs.begin(), ie = Inputs.end(); it != ie; ++it) { |
| 2277 | const InputInfo &II = *it; |
| 2278 | if (II.isPipe()) |
| 2279 | CmdArgs.push_back("-"); |
| 2280 | else |
| 2281 | CmdArgs.push_back(II.getFilename()); |
| 2282 | } |
| 2283 | |
| 2284 | const char *Exec = |
Edward O'Callaghan | ff430e6 | 2009-10-19 07:02:08 +0000 | [diff] [blame] | 2285 | Args.MakeArgString(getToolChain().GetProgramPath(C, "gas")); |
Daniel Dunbar | daab7b1 | 2009-12-02 03:23:25 +0000 | [diff] [blame] | 2286 | Dest.addCommand(new Command(JA, *this, Exec, CmdArgs)); |
Edward O'Callaghan | e7925a0 | 2009-08-22 01:06:46 +0000 | [diff] [blame] | 2287 | } |
| 2288 | |
| 2289 | void auroraux::Link::ConstructJob(Compilation &C, const JobAction &JA, |
Daniel Dunbar | 294691e | 2009-11-04 06:24:38 +0000 | [diff] [blame] | 2290 | Job &Dest, const InputInfo &Output, |
| 2291 | const InputInfoList &Inputs, |
| 2292 | const ArgList &Args, |
| 2293 | const char *LinkingOutput) const { |
Edward O'Callaghan | e7925a0 | 2009-08-22 01:06:46 +0000 | [diff] [blame] | 2294 | const Driver &D = getToolChain().getHost().getDriver(); |
| 2295 | ArgStringList CmdArgs; |
| 2296 | |
| 2297 | if ((!Args.hasArg(options::OPT_nostdlib)) && |
Daniel Dunbar | 294691e | 2009-11-04 06:24:38 +0000 | [diff] [blame] | 2298 | (!Args.hasArg(options::OPT_shared))) { |
Edward O'Callaghan | e7925a0 | 2009-08-22 01:06:46 +0000 | [diff] [blame] | 2299 | CmdArgs.push_back("-e"); |
Edward O'Callaghan | 7adf949 | 2009-10-15 07:44:07 +0000 | [diff] [blame] | 2300 | CmdArgs.push_back("_start"); |
Edward O'Callaghan | e7925a0 | 2009-08-22 01:06:46 +0000 | [diff] [blame] | 2301 | } |
| 2302 | |
| 2303 | if (Args.hasArg(options::OPT_static)) { |
| 2304 | CmdArgs.push_back("-Bstatic"); |
Edward O'Callaghan | 7adf949 | 2009-10-15 07:44:07 +0000 | [diff] [blame] | 2305 | CmdArgs.push_back("-dn"); |
Edward O'Callaghan | e7925a0 | 2009-08-22 01:06:46 +0000 | [diff] [blame] | 2306 | } else { |
Edward O'Callaghan | 7adf949 | 2009-10-15 07:44:07 +0000 | [diff] [blame] | 2307 | // CmdArgs.push_back("--eh-frame-hdr"); |
Edward O'Callaghan | e7925a0 | 2009-08-22 01:06:46 +0000 | [diff] [blame] | 2308 | CmdArgs.push_back("-Bdynamic"); |
| 2309 | if (Args.hasArg(options::OPT_shared)) { |
| 2310 | CmdArgs.push_back("-shared"); |
| 2311 | } else { |
Edward O'Callaghan | 3cecc19 | 2009-10-16 19:44:18 +0000 | [diff] [blame] | 2312 | CmdArgs.push_back("--dynamic-linker"); |
Edward O'Callaghan | e7925a0 | 2009-08-22 01:06:46 +0000 | [diff] [blame] | 2313 | CmdArgs.push_back("/lib/ld.so.1"); // 64Bit Path /lib/amd64/ld.so.1 |
| 2314 | } |
| 2315 | } |
| 2316 | |
| 2317 | if (Output.isPipe()) { |
| 2318 | CmdArgs.push_back("-o"); |
| 2319 | CmdArgs.push_back("-"); |
| 2320 | } else if (Output.isFilename()) { |
| 2321 | CmdArgs.push_back("-o"); |
| 2322 | CmdArgs.push_back(Output.getFilename()); |
| 2323 | } else { |
| 2324 | assert(Output.isNothing() && "Invalid output."); |
| 2325 | } |
| 2326 | |
| 2327 | if (!Args.hasArg(options::OPT_nostdlib) && |
| 2328 | !Args.hasArg(options::OPT_nostartfiles)) { |
| 2329 | if (!Args.hasArg(options::OPT_shared)) { |
Edward O'Callaghan | 7adf949 | 2009-10-15 07:44:07 +0000 | [diff] [blame] | 2330 | CmdArgs.push_back(Args.MakeArgString(getToolChain().GetFilePath(C, "crt1.o"))); |
| 2331 | CmdArgs.push_back(Args.MakeArgString(getToolChain().GetFilePath(C, "crti.o"))); |
Daniel Dunbar | 5ed34f4 | 2009-09-09 22:33:00 +0000 | [diff] [blame] | 2332 | CmdArgs.push_back(Args.MakeArgString(getToolChain().GetFilePath(C, "crtbegin.o"))); |
Edward O'Callaghan | e7925a0 | 2009-08-22 01:06:46 +0000 | [diff] [blame] | 2333 | } else { |
Edward O'Callaghan | 7adf949 | 2009-10-15 07:44:07 +0000 | [diff] [blame] | 2334 | CmdArgs.push_back(Args.MakeArgString(getToolChain().GetFilePath(C, "crti.o"))); |
Edward O'Callaghan | e7925a0 | 2009-08-22 01:06:46 +0000 | [diff] [blame] | 2335 | } |
Edward O'Callaghan | 7adf949 | 2009-10-15 07:44:07 +0000 | [diff] [blame] | 2336 | CmdArgs.push_back(Args.MakeArgString(getToolChain().GetFilePath(C, "crtn.o"))); |
Edward O'Callaghan | e7925a0 | 2009-08-22 01:06:46 +0000 | [diff] [blame] | 2337 | } |
| 2338 | |
Daniel Dunbar | 294691e | 2009-11-04 06:24:38 +0000 | [diff] [blame] | 2339 | CmdArgs.push_back(Args.MakeArgString("-L/opt/gcc4/lib/gcc/" |
| 2340 | + getToolChain().getTripleString() |
Daniel Dunbar | f7fb31f | 2009-10-29 02:24:37 +0000 | [diff] [blame] | 2341 | + "/4.2.4")); |
Edward O'Callaghan | e7925a0 | 2009-08-22 01:06:46 +0000 | [diff] [blame] | 2342 | |
| 2343 | Args.AddAllArgs(CmdArgs, options::OPT_L); |
| 2344 | Args.AddAllArgs(CmdArgs, options::OPT_T_Group); |
| 2345 | Args.AddAllArgs(CmdArgs, options::OPT_e); |
| 2346 | |
| 2347 | for (InputInfoList::const_iterator |
| 2348 | it = Inputs.begin(), ie = Inputs.end(); it != ie; ++it) { |
| 2349 | const InputInfo &II = *it; |
| 2350 | |
| 2351 | // Don't try to pass LLVM inputs to a generic gcc. |
| 2352 | if (II.getType() == types::TY_LLVMBC) |
| 2353 | D.Diag(clang::diag::err_drv_no_linker_llvm_support) |
Daniel Dunbar | 8813764 | 2009-09-09 22:32:48 +0000 | [diff] [blame] | 2354 | << getToolChain().getTripleString(); |
Edward O'Callaghan | e7925a0 | 2009-08-22 01:06:46 +0000 | [diff] [blame] | 2355 | |
| 2356 | if (II.isPipe()) |
| 2357 | CmdArgs.push_back("-"); |
| 2358 | else if (II.isFilename()) |
| 2359 | CmdArgs.push_back(II.getFilename()); |
| 2360 | else |
| 2361 | II.getInputArg().renderAsInput(Args, CmdArgs); |
| 2362 | } |
| 2363 | |
| 2364 | if (!Args.hasArg(options::OPT_nostdlib) && |
| 2365 | !Args.hasArg(options::OPT_nodefaultlibs)) { |
| 2366 | // FIXME: For some reason GCC passes -lgcc before adding |
| 2367 | // the default system libraries. Just mimic this for now. |
| 2368 | CmdArgs.push_back("-lgcc"); |
| 2369 | |
| 2370 | if (Args.hasArg(options::OPT_pthread)) |
| 2371 | CmdArgs.push_back("-pthread"); |
| 2372 | if (!Args.hasArg(options::OPT_shared)) |
| 2373 | CmdArgs.push_back("-lc"); |
| 2374 | CmdArgs.push_back("-lgcc"); |
| 2375 | } |
| 2376 | |
| 2377 | if (!Args.hasArg(options::OPT_nostdlib) && |
| 2378 | !Args.hasArg(options::OPT_nostartfiles)) { |
| 2379 | if (!Args.hasArg(options::OPT_shared)) |
Daniel Dunbar | 5ed34f4 | 2009-09-09 22:33:00 +0000 | [diff] [blame] | 2380 | CmdArgs.push_back(Args.MakeArgString(getToolChain().GetFilePath(C, "crtend.o"))); |
Edward O'Callaghan | 7adf949 | 2009-10-15 07:44:07 +0000 | [diff] [blame] | 2381 | // else |
| 2382 | // CmdArgs.push_back(Args.MakeArgString(getToolChain().GetFilePath(C, "crtendS.o"))); |
Edward O'Callaghan | e7925a0 | 2009-08-22 01:06:46 +0000 | [diff] [blame] | 2383 | } |
| 2384 | |
| 2385 | const char *Exec = |
Daniel Dunbar | 5ed34f4 | 2009-09-09 22:33:00 +0000 | [diff] [blame] | 2386 | Args.MakeArgString(getToolChain().GetProgramPath(C, "ld")); |
Daniel Dunbar | daab7b1 | 2009-12-02 03:23:25 +0000 | [diff] [blame] | 2387 | Dest.addCommand(new Command(JA, *this, Exec, CmdArgs)); |
Edward O'Callaghan | e7925a0 | 2009-08-22 01:06:46 +0000 | [diff] [blame] | 2388 | } |
| 2389 | |
Daniel Dunbar | f7b8eec | 2009-06-29 20:52:51 +0000 | [diff] [blame] | 2390 | void openbsd::Assemble::ConstructJob(Compilation &C, const JobAction &JA, |
| 2391 | Job &Dest, const InputInfo &Output, |
| 2392 | const InputInfoList &Inputs, |
| 2393 | const ArgList &Args, |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 2394 | const char *LinkingOutput) const { |
Daniel Dunbar | f7b8eec | 2009-06-29 20:52:51 +0000 | [diff] [blame] | 2395 | ArgStringList CmdArgs; |
| 2396 | |
| 2397 | Args.AddAllArgValues(CmdArgs, options::OPT_Wa_COMMA, |
| 2398 | options::OPT_Xassembler); |
| 2399 | |
| 2400 | CmdArgs.push_back("-o"); |
| 2401 | if (Output.isPipe()) |
| 2402 | CmdArgs.push_back("-"); |
| 2403 | else |
| 2404 | CmdArgs.push_back(Output.getFilename()); |
| 2405 | |
| 2406 | for (InputInfoList::const_iterator |
| 2407 | it = Inputs.begin(), ie = Inputs.end(); it != ie; ++it) { |
| 2408 | const InputInfo &II = *it; |
| 2409 | if (II.isPipe()) |
| 2410 | CmdArgs.push_back("-"); |
| 2411 | else |
| 2412 | CmdArgs.push_back(II.getFilename()); |
| 2413 | } |
| 2414 | |
| 2415 | const char *Exec = |
Daniel Dunbar | 5ed34f4 | 2009-09-09 22:33:00 +0000 | [diff] [blame] | 2416 | Args.MakeArgString(getToolChain().GetProgramPath(C, "as")); |
Daniel Dunbar | daab7b1 | 2009-12-02 03:23:25 +0000 | [diff] [blame] | 2417 | Dest.addCommand(new Command(JA, *this, Exec, CmdArgs)); |
Daniel Dunbar | f7b8eec | 2009-06-29 20:52:51 +0000 | [diff] [blame] | 2418 | } |
| 2419 | |
| 2420 | void openbsd::Link::ConstructJob(Compilation &C, const JobAction &JA, |
| 2421 | Job &Dest, const InputInfo &Output, |
| 2422 | const InputInfoList &Inputs, |
| 2423 | const ArgList &Args, |
| 2424 | const char *LinkingOutput) const { |
| 2425 | const Driver &D = getToolChain().getHost().getDriver(); |
| 2426 | ArgStringList CmdArgs; |
| 2427 | |
Daniel Dunbar | 2bbcf66 | 2009-08-03 01:28:59 +0000 | [diff] [blame] | 2428 | if ((!Args.hasArg(options::OPT_nostdlib)) && |
Daniel Dunbar | 294691e | 2009-11-04 06:24:38 +0000 | [diff] [blame] | 2429 | (!Args.hasArg(options::OPT_shared))) { |
Daniel Dunbar | 2bbcf66 | 2009-08-03 01:28:59 +0000 | [diff] [blame] | 2430 | CmdArgs.push_back("-e"); |
| 2431 | CmdArgs.push_back("__start"); |
| 2432 | } |
| 2433 | |
Daniel Dunbar | f7b8eec | 2009-06-29 20:52:51 +0000 | [diff] [blame] | 2434 | if (Args.hasArg(options::OPT_static)) { |
| 2435 | CmdArgs.push_back("-Bstatic"); |
| 2436 | } else { |
| 2437 | CmdArgs.push_back("--eh-frame-hdr"); |
Daniel Dunbar | 2bbcf66 | 2009-08-03 01:28:59 +0000 | [diff] [blame] | 2438 | CmdArgs.push_back("-Bdynamic"); |
Daniel Dunbar | f7b8eec | 2009-06-29 20:52:51 +0000 | [diff] [blame] | 2439 | if (Args.hasArg(options::OPT_shared)) { |
Daniel Dunbar | 2bbcf66 | 2009-08-03 01:28:59 +0000 | [diff] [blame] | 2440 | CmdArgs.push_back("-shared"); |
Daniel Dunbar | f7b8eec | 2009-06-29 20:52:51 +0000 | [diff] [blame] | 2441 | } else { |
| 2442 | CmdArgs.push_back("-dynamic-linker"); |
| 2443 | CmdArgs.push_back("/usr/libexec/ld.so"); |
| 2444 | } |
| 2445 | } |
| 2446 | |
| 2447 | if (Output.isPipe()) { |
| 2448 | CmdArgs.push_back("-o"); |
| 2449 | CmdArgs.push_back("-"); |
| 2450 | } else if (Output.isFilename()) { |
| 2451 | CmdArgs.push_back("-o"); |
| 2452 | CmdArgs.push_back(Output.getFilename()); |
| 2453 | } else { |
| 2454 | assert(Output.isNothing() && "Invalid output."); |
| 2455 | } |
| 2456 | |
| 2457 | if (!Args.hasArg(options::OPT_nostdlib) && |
| 2458 | !Args.hasArg(options::OPT_nostartfiles)) { |
| 2459 | if (!Args.hasArg(options::OPT_shared)) { |
Daniel Dunbar | 5ed34f4 | 2009-09-09 22:33:00 +0000 | [diff] [blame] | 2460 | CmdArgs.push_back(Args.MakeArgString(getToolChain().GetFilePath(C, "crt0.o"))); |
| 2461 | CmdArgs.push_back(Args.MakeArgString(getToolChain().GetFilePath(C, "crtbegin.o"))); |
Daniel Dunbar | f7b8eec | 2009-06-29 20:52:51 +0000 | [diff] [blame] | 2462 | } else { |
Daniel Dunbar | 5ed34f4 | 2009-09-09 22:33:00 +0000 | [diff] [blame] | 2463 | CmdArgs.push_back(Args.MakeArgString(getToolChain().GetFilePath(C, "crtbeginS.o"))); |
Daniel Dunbar | f7b8eec | 2009-06-29 20:52:51 +0000 | [diff] [blame] | 2464 | } |
| 2465 | } |
| 2466 | |
Edward O'Callaghan | e7e1820 | 2009-10-28 15:13:08 +0000 | [diff] [blame] | 2467 | std::string Triple = getToolChain().getTripleString(); |
| 2468 | if (Triple.substr(0, 6) == "x86_64") |
Daniel Dunbar | 294691e | 2009-11-04 06:24:38 +0000 | [diff] [blame] | 2469 | Triple.replace(0, 6, "amd64"); |
Daniel Dunbar | f7fb31f | 2009-10-29 02:24:37 +0000 | [diff] [blame] | 2470 | CmdArgs.push_back(Args.MakeArgString("-L/usr/lib/gcc-lib/" + Triple + |
| 2471 | "/3.3.5")); |
Daniel Dunbar | 2bbcf66 | 2009-08-03 01:28:59 +0000 | [diff] [blame] | 2472 | |
Daniel Dunbar | f7b8eec | 2009-06-29 20:52:51 +0000 | [diff] [blame] | 2473 | Args.AddAllArgs(CmdArgs, options::OPT_L); |
| 2474 | Args.AddAllArgs(CmdArgs, options::OPT_T_Group); |
| 2475 | Args.AddAllArgs(CmdArgs, options::OPT_e); |
| 2476 | |
| 2477 | for (InputInfoList::const_iterator |
| 2478 | it = Inputs.begin(), ie = Inputs.end(); it != ie; ++it) { |
| 2479 | const InputInfo &II = *it; |
| 2480 | |
| 2481 | // Don't try to pass LLVM inputs to a generic gcc. |
| 2482 | if (II.getType() == types::TY_LLVMBC) |
| 2483 | D.Diag(clang::diag::err_drv_no_linker_llvm_support) |
Daniel Dunbar | 8813764 | 2009-09-09 22:32:48 +0000 | [diff] [blame] | 2484 | << getToolChain().getTripleString(); |
Daniel Dunbar | f7b8eec | 2009-06-29 20:52:51 +0000 | [diff] [blame] | 2485 | |
| 2486 | if (II.isPipe()) |
| 2487 | CmdArgs.push_back("-"); |
| 2488 | else if (II.isFilename()) |
| 2489 | CmdArgs.push_back(II.getFilename()); |
| 2490 | else |
| 2491 | II.getInputArg().renderAsInput(Args, CmdArgs); |
| 2492 | } |
| 2493 | |
| 2494 | if (!Args.hasArg(options::OPT_nostdlib) && |
| 2495 | !Args.hasArg(options::OPT_nodefaultlibs)) { |
Daniel Dunbar | 2bbcf66 | 2009-08-03 01:28:59 +0000 | [diff] [blame] | 2496 | // FIXME: For some reason GCC passes -lgcc before adding |
| 2497 | // the default system libraries. Just mimic this for now. |
| 2498 | CmdArgs.push_back("-lgcc"); |
Daniel Dunbar | f7b8eec | 2009-06-29 20:52:51 +0000 | [diff] [blame] | 2499 | |
| 2500 | if (Args.hasArg(options::OPT_pthread)) |
| 2501 | CmdArgs.push_back("-pthread"); |
Daniel Dunbar | 2bbcf66 | 2009-08-03 01:28:59 +0000 | [diff] [blame] | 2502 | if (!Args.hasArg(options::OPT_shared)) |
| 2503 | CmdArgs.push_back("-lc"); |
| 2504 | CmdArgs.push_back("-lgcc"); |
Daniel Dunbar | f7b8eec | 2009-06-29 20:52:51 +0000 | [diff] [blame] | 2505 | } |
| 2506 | |
| 2507 | if (!Args.hasArg(options::OPT_nostdlib) && |
| 2508 | !Args.hasArg(options::OPT_nostartfiles)) { |
| 2509 | if (!Args.hasArg(options::OPT_shared)) |
Daniel Dunbar | 5ed34f4 | 2009-09-09 22:33:00 +0000 | [diff] [blame] | 2510 | CmdArgs.push_back(Args.MakeArgString(getToolChain().GetFilePath(C, "crtend.o"))); |
Daniel Dunbar | f7b8eec | 2009-06-29 20:52:51 +0000 | [diff] [blame] | 2511 | else |
Daniel Dunbar | 5ed34f4 | 2009-09-09 22:33:00 +0000 | [diff] [blame] | 2512 | CmdArgs.push_back(Args.MakeArgString(getToolChain().GetFilePath(C, "crtendS.o"))); |
Daniel Dunbar | f7b8eec | 2009-06-29 20:52:51 +0000 | [diff] [blame] | 2513 | } |
| 2514 | |
| 2515 | const char *Exec = |
Daniel Dunbar | 5ed34f4 | 2009-09-09 22:33:00 +0000 | [diff] [blame] | 2516 | Args.MakeArgString(getToolChain().GetProgramPath(C, "ld")); |
Daniel Dunbar | daab7b1 | 2009-12-02 03:23:25 +0000 | [diff] [blame] | 2517 | Dest.addCommand(new Command(JA, *this, Exec, CmdArgs)); |
Daniel Dunbar | f7b8eec | 2009-06-29 20:52:51 +0000 | [diff] [blame] | 2518 | } |
Ed Schouten | c66a5a3 | 2009-04-02 19:13:12 +0000 | [diff] [blame] | 2519 | |
Daniel Dunbar | 68a31d4 | 2009-03-31 17:45:15 +0000 | [diff] [blame] | 2520 | void freebsd::Assemble::ConstructJob(Compilation &C, const JobAction &JA, |
Daniel Dunbar | c21c485 | 2009-04-08 23:54:23 +0000 | [diff] [blame] | 2521 | Job &Dest, const InputInfo &Output, |
| 2522 | const InputInfoList &Inputs, |
| 2523 | const ArgList &Args, |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 2524 | const char *LinkingOutput) const { |
Daniel Dunbar | 68a31d4 | 2009-03-31 17:45:15 +0000 | [diff] [blame] | 2525 | ArgStringList CmdArgs; |
| 2526 | |
Daniel Dunbar | 008f54a | 2009-04-01 19:36:32 +0000 | [diff] [blame] | 2527 | // When building 32-bit code on FreeBSD/amd64, we have to explicitly |
| 2528 | // instruct as in the base system to assemble 32-bit code. |
| 2529 | if (getToolChain().getArchName() == "i386") |
Daniel Dunbar | 68a31d4 | 2009-03-31 17:45:15 +0000 | [diff] [blame] | 2530 | CmdArgs.push_back("--32"); |
| 2531 | |
| 2532 | Args.AddAllArgValues(CmdArgs, options::OPT_Wa_COMMA, |
| 2533 | options::OPT_Xassembler); |
| 2534 | |
| 2535 | CmdArgs.push_back("-o"); |
| 2536 | if (Output.isPipe()) |
| 2537 | CmdArgs.push_back("-"); |
| 2538 | else |
| 2539 | CmdArgs.push_back(Output.getFilename()); |
| 2540 | |
| 2541 | for (InputInfoList::const_iterator |
| 2542 | it = Inputs.begin(), ie = Inputs.end(); it != ie; ++it) { |
| 2543 | const InputInfo &II = *it; |
| 2544 | if (II.isPipe()) |
| 2545 | CmdArgs.push_back("-"); |
| 2546 | else |
| 2547 | CmdArgs.push_back(II.getFilename()); |
| 2548 | } |
| 2549 | |
Daniel Dunbar | c21c485 | 2009-04-08 23:54:23 +0000 | [diff] [blame] | 2550 | const char *Exec = |
Daniel Dunbar | 5ed34f4 | 2009-09-09 22:33:00 +0000 | [diff] [blame] | 2551 | Args.MakeArgString(getToolChain().GetProgramPath(C, "as")); |
Daniel Dunbar | daab7b1 | 2009-12-02 03:23:25 +0000 | [diff] [blame] | 2552 | Dest.addCommand(new Command(JA, *this, Exec, CmdArgs)); |
Daniel Dunbar | 68a31d4 | 2009-03-31 17:45:15 +0000 | [diff] [blame] | 2553 | } |
Daniel Dunbar | 008f54a | 2009-04-01 19:36:32 +0000 | [diff] [blame] | 2554 | |
| 2555 | void freebsd::Link::ConstructJob(Compilation &C, const JobAction &JA, |
Daniel Dunbar | c21c485 | 2009-04-08 23:54:23 +0000 | [diff] [blame] | 2556 | Job &Dest, const InputInfo &Output, |
| 2557 | const InputInfoList &Inputs, |
| 2558 | const ArgList &Args, |
Daniel Dunbar | a8304f6 | 2009-05-02 20:14:53 +0000 | [diff] [blame] | 2559 | const char *LinkingOutput) const { |
| 2560 | const Driver &D = getToolChain().getHost().getDriver(); |
Daniel Dunbar | 008f54a | 2009-04-01 19:36:32 +0000 | [diff] [blame] | 2561 | ArgStringList CmdArgs; |
| 2562 | |
| 2563 | if (Args.hasArg(options::OPT_static)) { |
| 2564 | CmdArgs.push_back("-Bstatic"); |
| 2565 | } else { |
| 2566 | CmdArgs.push_back("--eh-frame-hdr"); |
| 2567 | if (Args.hasArg(options::OPT_shared)) { |
| 2568 | CmdArgs.push_back("-Bshareable"); |
| 2569 | } else { |
| 2570 | CmdArgs.push_back("-dynamic-linker"); |
| 2571 | CmdArgs.push_back("/libexec/ld-elf.so.1"); |
| 2572 | } |
| 2573 | } |
| 2574 | |
| 2575 | // When building 32-bit code on FreeBSD/amd64, we have to explicitly |
| 2576 | // instruct ld in the base system to link 32-bit code. |
| 2577 | if (getToolChain().getArchName() == "i386") { |
| 2578 | CmdArgs.push_back("-m"); |
| 2579 | CmdArgs.push_back("elf_i386_fbsd"); |
| 2580 | } |
| 2581 | |
| 2582 | if (Output.isPipe()) { |
| 2583 | CmdArgs.push_back("-o"); |
| 2584 | CmdArgs.push_back("-"); |
| 2585 | } else if (Output.isFilename()) { |
| 2586 | CmdArgs.push_back("-o"); |
| 2587 | CmdArgs.push_back(Output.getFilename()); |
| 2588 | } else { |
| 2589 | assert(Output.isNothing() && "Invalid output."); |
| 2590 | } |
| 2591 | |
| 2592 | if (!Args.hasArg(options::OPT_nostdlib) && |
| 2593 | !Args.hasArg(options::OPT_nostartfiles)) { |
| 2594 | if (!Args.hasArg(options::OPT_shared)) { |
Daniel Dunbar | 5ed34f4 | 2009-09-09 22:33:00 +0000 | [diff] [blame] | 2595 | CmdArgs.push_back(Args.MakeArgString(getToolChain().GetFilePath(C, "crt1.o"))); |
| 2596 | CmdArgs.push_back(Args.MakeArgString(getToolChain().GetFilePath(C, "crti.o"))); |
| 2597 | CmdArgs.push_back(Args.MakeArgString(getToolChain().GetFilePath(C, "crtbegin.o"))); |
Daniel Dunbar | 008f54a | 2009-04-01 19:36:32 +0000 | [diff] [blame] | 2598 | } else { |
Daniel Dunbar | 5ed34f4 | 2009-09-09 22:33:00 +0000 | [diff] [blame] | 2599 | CmdArgs.push_back(Args.MakeArgString(getToolChain().GetFilePath(C, "crti.o"))); |
| 2600 | CmdArgs.push_back(Args.MakeArgString(getToolChain().GetFilePath(C, "crtbeginS.o"))); |
Daniel Dunbar | 008f54a | 2009-04-01 19:36:32 +0000 | [diff] [blame] | 2601 | } |
| 2602 | } |
| 2603 | |
| 2604 | Args.AddAllArgs(CmdArgs, options::OPT_L); |
| 2605 | Args.AddAllArgs(CmdArgs, options::OPT_T_Group); |
| 2606 | Args.AddAllArgs(CmdArgs, options::OPT_e); |
| 2607 | |
| 2608 | for (InputInfoList::const_iterator |
Daniel Dunbar | c21c485 | 2009-04-08 23:54:23 +0000 | [diff] [blame] | 2609 | it = Inputs.begin(), ie = Inputs.end(); it != ie; ++it) { |
Daniel Dunbar | 008f54a | 2009-04-01 19:36:32 +0000 | [diff] [blame] | 2610 | const InputInfo &II = *it; |
Daniel Dunbar | a8304f6 | 2009-05-02 20:14:53 +0000 | [diff] [blame] | 2611 | |
| 2612 | // Don't try to pass LLVM inputs to a generic gcc. |
| 2613 | if (II.getType() == types::TY_LLVMBC) |
| 2614 | D.Diag(clang::diag::err_drv_no_linker_llvm_support) |
Daniel Dunbar | 8813764 | 2009-09-09 22:32:48 +0000 | [diff] [blame] | 2615 | << getToolChain().getTripleString(); |
Daniel Dunbar | a8304f6 | 2009-05-02 20:14:53 +0000 | [diff] [blame] | 2616 | |
Daniel Dunbar | 008f54a | 2009-04-01 19:36:32 +0000 | [diff] [blame] | 2617 | if (II.isPipe()) |
| 2618 | CmdArgs.push_back("-"); |
| 2619 | else if (II.isFilename()) |
| 2620 | CmdArgs.push_back(II.getFilename()); |
| 2621 | else |
| 2622 | II.getInputArg().renderAsInput(Args, CmdArgs); |
| 2623 | } |
| 2624 | |
| 2625 | if (!Args.hasArg(options::OPT_nostdlib) && |
| 2626 | !Args.hasArg(options::OPT_nodefaultlibs)) { |
| 2627 | // FIXME: For some reason GCC passes -lgcc and -lgcc_s before adding |
| 2628 | // the default system libraries. Just mimic this for now. |
| 2629 | CmdArgs.push_back("-lgcc"); |
Edward O'Callaghan | 69203e1 | 2009-11-18 14:51:31 +0000 | [diff] [blame] | 2630 | if (D.CCCIsCXX) |
| 2631 | CmdArgs.push_back("-lstdc++"); |
Daniel Dunbar | 008f54a | 2009-04-01 19:36:32 +0000 | [diff] [blame] | 2632 | if (Args.hasArg(options::OPT_static)) { |
| 2633 | CmdArgs.push_back("-lgcc_eh"); |
| 2634 | } else { |
| 2635 | CmdArgs.push_back("--as-needed"); |
| 2636 | CmdArgs.push_back("-lgcc_s"); |
| 2637 | CmdArgs.push_back("--no-as-needed"); |
| 2638 | } |
| 2639 | |
| 2640 | if (Args.hasArg(options::OPT_pthread)) |
| 2641 | CmdArgs.push_back("-lpthread"); |
| 2642 | CmdArgs.push_back("-lc"); |
| 2643 | |
| 2644 | CmdArgs.push_back("-lgcc"); |
| 2645 | if (Args.hasArg(options::OPT_static)) { |
| 2646 | CmdArgs.push_back("-lgcc_eh"); |
| 2647 | } else { |
| 2648 | CmdArgs.push_back("--as-needed"); |
| 2649 | CmdArgs.push_back("-lgcc_s"); |
| 2650 | CmdArgs.push_back("--no-as-needed"); |
| 2651 | } |
| 2652 | } |
| 2653 | |
| 2654 | if (!Args.hasArg(options::OPT_nostdlib) && |
| 2655 | !Args.hasArg(options::OPT_nostartfiles)) { |
| 2656 | if (!Args.hasArg(options::OPT_shared)) |
Daniel Dunbar | 5ed34f4 | 2009-09-09 22:33:00 +0000 | [diff] [blame] | 2657 | CmdArgs.push_back(Args.MakeArgString(getToolChain().GetFilePath(C, "crtend.o"))); |
Daniel Dunbar | 008f54a | 2009-04-01 19:36:32 +0000 | [diff] [blame] | 2658 | else |
Daniel Dunbar | 5ed34f4 | 2009-09-09 22:33:00 +0000 | [diff] [blame] | 2659 | CmdArgs.push_back(Args.MakeArgString(getToolChain().GetFilePath(C, "crtendS.o"))); |
| 2660 | CmdArgs.push_back(Args.MakeArgString(getToolChain().GetFilePath(C, "crtn.o"))); |
Daniel Dunbar | 008f54a | 2009-04-01 19:36:32 +0000 | [diff] [blame] | 2661 | } |
| 2662 | |
Daniel Dunbar | c21c485 | 2009-04-08 23:54:23 +0000 | [diff] [blame] | 2663 | const char *Exec = |
Daniel Dunbar | 5ed34f4 | 2009-09-09 22:33:00 +0000 | [diff] [blame] | 2664 | Args.MakeArgString(getToolChain().GetProgramPath(C, "ld")); |
Daniel Dunbar | daab7b1 | 2009-12-02 03:23:25 +0000 | [diff] [blame] | 2665 | Dest.addCommand(new Command(JA, *this, Exec, CmdArgs)); |
Daniel Dunbar | 008f54a | 2009-04-01 19:36:32 +0000 | [diff] [blame] | 2666 | } |
Daniel Dunbar | 11e1b40 | 2009-05-02 18:28:39 +0000 | [diff] [blame] | 2667 | |
| 2668 | /// DragonFly Tools |
| 2669 | |
| 2670 | // For now, DragonFly Assemble does just about the same as for |
| 2671 | // FreeBSD, but this may change soon. |
| 2672 | void dragonfly::Assemble::ConstructJob(Compilation &C, const JobAction &JA, |
Daniel Dunbar | 294691e | 2009-11-04 06:24:38 +0000 | [diff] [blame] | 2673 | Job &Dest, const InputInfo &Output, |
| 2674 | const InputInfoList &Inputs, |
| 2675 | const ArgList &Args, |
| 2676 | const char *LinkingOutput) const { |
Daniel Dunbar | 11e1b40 | 2009-05-02 18:28:39 +0000 | [diff] [blame] | 2677 | ArgStringList CmdArgs; |
| 2678 | |
| 2679 | // When building 32-bit code on DragonFly/pc64, we have to explicitly |
| 2680 | // instruct as in the base system to assemble 32-bit code. |
| 2681 | if (getToolChain().getArchName() == "i386") |
| 2682 | CmdArgs.push_back("--32"); |
| 2683 | |
| 2684 | Args.AddAllArgValues(CmdArgs, options::OPT_Wa_COMMA, |
| 2685 | options::OPT_Xassembler); |
| 2686 | |
| 2687 | CmdArgs.push_back("-o"); |
| 2688 | if (Output.isPipe()) |
| 2689 | CmdArgs.push_back("-"); |
| 2690 | else |
| 2691 | CmdArgs.push_back(Output.getFilename()); |
| 2692 | |
| 2693 | for (InputInfoList::const_iterator |
| 2694 | it = Inputs.begin(), ie = Inputs.end(); it != ie; ++it) { |
| 2695 | const InputInfo &II = *it; |
| 2696 | if (II.isPipe()) |
| 2697 | CmdArgs.push_back("-"); |
| 2698 | else |
| 2699 | CmdArgs.push_back(II.getFilename()); |
| 2700 | } |
| 2701 | |
| 2702 | const char *Exec = |
Daniel Dunbar | 5ed34f4 | 2009-09-09 22:33:00 +0000 | [diff] [blame] | 2703 | Args.MakeArgString(getToolChain().GetProgramPath(C, "as")); |
Daniel Dunbar | daab7b1 | 2009-12-02 03:23:25 +0000 | [diff] [blame] | 2704 | Dest.addCommand(new Command(JA, *this, Exec, CmdArgs)); |
Daniel Dunbar | 11e1b40 | 2009-05-02 18:28:39 +0000 | [diff] [blame] | 2705 | } |
| 2706 | |
| 2707 | void dragonfly::Link::ConstructJob(Compilation &C, const JobAction &JA, |
| 2708 | Job &Dest, const InputInfo &Output, |
| 2709 | const InputInfoList &Inputs, |
| 2710 | const ArgList &Args, |
| 2711 | const char *LinkingOutput) const { |
Daniel Dunbar | a8304f6 | 2009-05-02 20:14:53 +0000 | [diff] [blame] | 2712 | const Driver &D = getToolChain().getHost().getDriver(); |
Daniel Dunbar | 11e1b40 | 2009-05-02 18:28:39 +0000 | [diff] [blame] | 2713 | ArgStringList CmdArgs; |
| 2714 | |
| 2715 | if (Args.hasArg(options::OPT_static)) { |
| 2716 | CmdArgs.push_back("-Bstatic"); |
| 2717 | } else { |
| 2718 | if (Args.hasArg(options::OPT_shared)) |
| 2719 | CmdArgs.push_back("-Bshareable"); |
| 2720 | else { |
| 2721 | CmdArgs.push_back("-dynamic-linker"); |
| 2722 | CmdArgs.push_back("/usr/libexec/ld-elf.so.2"); |
| 2723 | } |
| 2724 | } |
| 2725 | |
| 2726 | // When building 32-bit code on DragonFly/pc64, we have to explicitly |
| 2727 | // instruct ld in the base system to link 32-bit code. |
| 2728 | if (getToolChain().getArchName() == "i386") { |
| 2729 | CmdArgs.push_back("-m"); |
| 2730 | CmdArgs.push_back("elf_i386"); |
| 2731 | } |
| 2732 | |
| 2733 | if (Output.isPipe()) { |
| 2734 | CmdArgs.push_back("-o"); |
| 2735 | CmdArgs.push_back("-"); |
| 2736 | } else if (Output.isFilename()) { |
| 2737 | CmdArgs.push_back("-o"); |
| 2738 | CmdArgs.push_back(Output.getFilename()); |
| 2739 | } else { |
| 2740 | assert(Output.isNothing() && "Invalid output."); |
| 2741 | } |
| 2742 | |
| 2743 | if (!Args.hasArg(options::OPT_nostdlib) && |
| 2744 | !Args.hasArg(options::OPT_nostartfiles)) { |
| 2745 | if (!Args.hasArg(options::OPT_shared)) { |
Daniel Dunbar | 5ed34f4 | 2009-09-09 22:33:00 +0000 | [diff] [blame] | 2746 | CmdArgs.push_back(Args.MakeArgString(getToolChain().GetFilePath(C, "crt1.o"))); |
| 2747 | CmdArgs.push_back(Args.MakeArgString(getToolChain().GetFilePath(C, "crti.o"))); |
| 2748 | CmdArgs.push_back(Args.MakeArgString(getToolChain().GetFilePath(C, "crtbegin.o"))); |
Daniel Dunbar | 11e1b40 | 2009-05-02 18:28:39 +0000 | [diff] [blame] | 2749 | } else { |
Daniel Dunbar | 5ed34f4 | 2009-09-09 22:33:00 +0000 | [diff] [blame] | 2750 | CmdArgs.push_back(Args.MakeArgString(getToolChain().GetFilePath(C, "crti.o"))); |
| 2751 | CmdArgs.push_back(Args.MakeArgString(getToolChain().GetFilePath(C, "crtbeginS.o"))); |
Daniel Dunbar | 11e1b40 | 2009-05-02 18:28:39 +0000 | [diff] [blame] | 2752 | } |
| 2753 | } |
| 2754 | |
| 2755 | Args.AddAllArgs(CmdArgs, options::OPT_L); |
| 2756 | Args.AddAllArgs(CmdArgs, options::OPT_T_Group); |
| 2757 | Args.AddAllArgs(CmdArgs, options::OPT_e); |
| 2758 | |
| 2759 | for (InputInfoList::const_iterator |
| 2760 | it = Inputs.begin(), ie = Inputs.end(); it != ie; ++it) { |
| 2761 | const InputInfo &II = *it; |
Daniel Dunbar | a8304f6 | 2009-05-02 20:14:53 +0000 | [diff] [blame] | 2762 | |
| 2763 | // Don't try to pass LLVM inputs to a generic gcc. |
| 2764 | if (II.getType() == types::TY_LLVMBC) |
| 2765 | D.Diag(clang::diag::err_drv_no_linker_llvm_support) |
Daniel Dunbar | 8813764 | 2009-09-09 22:32:48 +0000 | [diff] [blame] | 2766 | << getToolChain().getTripleString(); |
Daniel Dunbar | a8304f6 | 2009-05-02 20:14:53 +0000 | [diff] [blame] | 2767 | |
Daniel Dunbar | 11e1b40 | 2009-05-02 18:28:39 +0000 | [diff] [blame] | 2768 | if (II.isPipe()) |
| 2769 | CmdArgs.push_back("-"); |
| 2770 | else if (II.isFilename()) |
| 2771 | CmdArgs.push_back(II.getFilename()); |
| 2772 | else |
| 2773 | II.getInputArg().renderAsInput(Args, CmdArgs); |
| 2774 | } |
| 2775 | |
| 2776 | if (!Args.hasArg(options::OPT_nostdlib) && |
| 2777 | !Args.hasArg(options::OPT_nodefaultlibs)) { |
| 2778 | // FIXME: GCC passes on -lgcc, -lgcc_pic and a whole lot of |
| 2779 | // rpaths |
| 2780 | CmdArgs.push_back("-L/usr/lib/gcc41"); |
| 2781 | |
| 2782 | if (!Args.hasArg(options::OPT_static)) { |
| 2783 | CmdArgs.push_back("-rpath"); |
| 2784 | CmdArgs.push_back("/usr/lib/gcc41"); |
| 2785 | |
| 2786 | CmdArgs.push_back("-rpath-link"); |
| 2787 | CmdArgs.push_back("/usr/lib/gcc41"); |
| 2788 | |
| 2789 | CmdArgs.push_back("-rpath"); |
| 2790 | CmdArgs.push_back("/usr/lib"); |
| 2791 | |
| 2792 | CmdArgs.push_back("-rpath-link"); |
| 2793 | CmdArgs.push_back("/usr/lib"); |
| 2794 | } |
| 2795 | |
| 2796 | if (Args.hasArg(options::OPT_shared)) { |
| 2797 | CmdArgs.push_back("-lgcc_pic"); |
| 2798 | } else { |
| 2799 | CmdArgs.push_back("-lgcc"); |
| 2800 | } |
| 2801 | |
| 2802 | |
| 2803 | if (Args.hasArg(options::OPT_pthread)) |
Mike Stump | 4d63f8b | 2009-10-31 20:11:46 +0000 | [diff] [blame] | 2804 | CmdArgs.push_back("-lpthread"); |
Daniel Dunbar | 11e1b40 | 2009-05-02 18:28:39 +0000 | [diff] [blame] | 2805 | |
| 2806 | if (!Args.hasArg(options::OPT_nolibc)) { |
| 2807 | CmdArgs.push_back("-lc"); |
| 2808 | } |
| 2809 | |
| 2810 | if (Args.hasArg(options::OPT_shared)) { |
| 2811 | CmdArgs.push_back("-lgcc_pic"); |
| 2812 | } else { |
| 2813 | CmdArgs.push_back("-lgcc"); |
| 2814 | } |
| 2815 | } |
| 2816 | |
| 2817 | if (!Args.hasArg(options::OPT_nostdlib) && |
| 2818 | !Args.hasArg(options::OPT_nostartfiles)) { |
| 2819 | if (!Args.hasArg(options::OPT_shared)) |
Daniel Dunbar | 5ed34f4 | 2009-09-09 22:33:00 +0000 | [diff] [blame] | 2820 | CmdArgs.push_back(Args.MakeArgString(getToolChain().GetFilePath(C, "crtend.o"))); |
Daniel Dunbar | 11e1b40 | 2009-05-02 18:28:39 +0000 | [diff] [blame] | 2821 | else |
Daniel Dunbar | 5ed34f4 | 2009-09-09 22:33:00 +0000 | [diff] [blame] | 2822 | CmdArgs.push_back(Args.MakeArgString(getToolChain().GetFilePath(C, "crtendS.o"))); |
| 2823 | CmdArgs.push_back(Args.MakeArgString(getToolChain().GetFilePath(C, "crtn.o"))); |
Daniel Dunbar | 11e1b40 | 2009-05-02 18:28:39 +0000 | [diff] [blame] | 2824 | } |
| 2825 | |
| 2826 | const char *Exec = |
Daniel Dunbar | 5ed34f4 | 2009-09-09 22:33:00 +0000 | [diff] [blame] | 2827 | Args.MakeArgString(getToolChain().GetProgramPath(C, "ld")); |
Daniel Dunbar | daab7b1 | 2009-12-02 03:23:25 +0000 | [diff] [blame] | 2828 | Dest.addCommand(new Command(JA, *this, Exec, CmdArgs)); |
Daniel Dunbar | 11e1b40 | 2009-05-02 18:28:39 +0000 | [diff] [blame] | 2829 | } |