Nick Lewycky | 3fdcc6f | 2010-12-31 17:31:54 +0000 | [diff] [blame] | 1 | //===--- ToolChain.cpp - Collections of tools for one platform ------------===// |
Daniel Dunbar | 2ba38ba | 2009-03-16 05:25:36 +0000 | [diff] [blame] | 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 "clang/Driver/ToolChain.h" |
Chandler Carruth | 55fc873 | 2012-12-04 09:13:33 +0000 | [diff] [blame] | 11 | #include "clang/Basic/ObjCRuntime.h" |
Daniel Dunbar | 2ba38ba | 2009-03-16 05:25:36 +0000 | [diff] [blame] | 12 | #include "clang/Driver/Action.h" |
Daniel Dunbar | 00577ad | 2010-08-23 22:35:37 +0000 | [diff] [blame] | 13 | #include "clang/Driver/Arg.h" |
| 14 | #include "clang/Driver/ArgList.h" |
Daniel Dunbar | 2ba38ba | 2009-03-16 05:25:36 +0000 | [diff] [blame] | 15 | #include "clang/Driver/Driver.h" |
Daniel Dunbar | 00577ad | 2010-08-23 22:35:37 +0000 | [diff] [blame] | 16 | #include "clang/Driver/DriverDiagnostic.h" |
Benjamin Kramer | e20e508 | 2012-10-04 19:42:20 +0000 | [diff] [blame] | 17 | #include "clang/Driver/Option.h" |
Daniel Dunbar | 00577ad | 2010-08-23 22:35:37 +0000 | [diff] [blame] | 18 | #include "clang/Driver/Options.h" |
Bob Wilson | 57f6d19 | 2012-03-21 17:19:12 +0000 | [diff] [blame] | 19 | #include "llvm/ADT/StringSwitch.h" |
John McCall | 9f084a3 | 2011-07-06 00:26:06 +0000 | [diff] [blame] | 20 | #include "llvm/Support/ErrorHandling.h" |
Daniel Dunbar | 2ba38ba | 2009-03-16 05:25:36 +0000 | [diff] [blame] | 21 | using namespace clang::driver; |
Chris Lattner | 5f9e272 | 2011-07-23 10:55:15 +0000 | [diff] [blame] | 22 | using namespace clang; |
Daniel Dunbar | 2ba38ba | 2009-03-16 05:25:36 +0000 | [diff] [blame] | 23 | |
Chandler Carruth | 1d16f0f | 2012-01-31 02:21:20 +0000 | [diff] [blame] | 24 | ToolChain::ToolChain(const Driver &D, const llvm::Triple &T) |
| 25 | : D(D), Triple(T) { |
Daniel Dunbar | 2ba38ba | 2009-03-16 05:25:36 +0000 | [diff] [blame] | 26 | } |
| 27 | |
| 28 | ToolChain::~ToolChain() { |
| 29 | } |
| 30 | |
Daniel Dunbar | ee788e7 | 2009-12-21 18:54:17 +0000 | [diff] [blame] | 31 | const Driver &ToolChain::getDriver() const { |
Chandler Carruth | 4d7ff6e | 2012-01-25 09:12:06 +0000 | [diff] [blame] | 32 | return D; |
Daniel Dunbar | ee788e7 | 2009-12-21 18:54:17 +0000 | [diff] [blame] | 33 | } |
| 34 | |
Daniel Dunbar | d2a527e | 2012-11-08 03:38:26 +0000 | [diff] [blame] | 35 | std::string ToolChain::getDefaultUniversalArchName() const { |
| 36 | // In universal driver terms, the arch name accepted by -arch isn't exactly |
| 37 | // the same as the ones that appear in the triple. Roughly speaking, this is |
| 38 | // an inverse of the darwin::getArchTypeForDarwinArchName() function, but the |
| 39 | // only interesting special case is powerpc. |
| 40 | switch (Triple.getArch()) { |
| 41 | case llvm::Triple::ppc: |
| 42 | return "ppc"; |
| 43 | case llvm::Triple::ppc64: |
| 44 | return "ppc64"; |
| 45 | default: |
| 46 | return Triple.getArchName(); |
| 47 | } |
| 48 | } |
| 49 | |
Rafael Espindola | 03a8638 | 2012-09-23 03:05:41 +0000 | [diff] [blame] | 50 | bool ToolChain::IsUnwindTablesDefault() const { |
| 51 | return false; |
| 52 | } |
| 53 | |
Daniel Dunbar | 4a7e889 | 2010-07-14 18:46:23 +0000 | [diff] [blame] | 54 | std::string ToolChain::GetFilePath(const char *Name) const { |
Chandler Carruth | 4d7ff6e | 2012-01-25 09:12:06 +0000 | [diff] [blame] | 55 | return D.GetFilePath(Name, *this); |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 56 | |
Daniel Dunbar | 2ba38ba | 2009-03-16 05:25:36 +0000 | [diff] [blame] | 57 | } |
| 58 | |
Simon Atanasyan | fc44e88 | 2012-10-03 19:52:37 +0000 | [diff] [blame] | 59 | std::string ToolChain::GetProgramPath(const char *Name) const { |
| 60 | return D.GetProgramPath(Name, *this); |
Daniel Dunbar | 2ba38ba | 2009-03-16 05:25:36 +0000 | [diff] [blame] | 61 | } |
Daniel Dunbar | 4180011 | 2010-08-02 05:43:56 +0000 | [diff] [blame] | 62 | |
| 63 | types::ID ToolChain::LookupTypeForExtension(const char *Ext) const { |
| 64 | return types::lookupTypeForExtension(Ext); |
| 65 | } |
Daniel Dunbar | 00577ad | 2010-08-23 22:35:37 +0000 | [diff] [blame] | 66 | |
Daniel Dunbar | b993f5d | 2010-09-17 00:24:52 +0000 | [diff] [blame] | 67 | bool ToolChain::HasNativeLLVMSupport() const { |
| 68 | return false; |
| 69 | } |
| 70 | |
John McCall | 260611a | 2012-06-20 06:18:46 +0000 | [diff] [blame] | 71 | ObjCRuntime ToolChain::getDefaultObjCRuntime(bool isNonFragile) const { |
David Chisnall | 11d3f4c | 2012-07-03 20:49:52 +0000 | [diff] [blame] | 72 | return ObjCRuntime(isNonFragile ? ObjCRuntime::GNUstep : ObjCRuntime::GCC, |
John McCall | 260611a | 2012-06-20 06:18:46 +0000 | [diff] [blame] | 73 | VersionTuple()); |
John McCall | 9f084a3 | 2011-07-06 00:26:06 +0000 | [diff] [blame] | 74 | } |
| 75 | |
Chris Lattner | fc8f0e1 | 2011-04-15 05:22:18 +0000 | [diff] [blame] | 76 | /// getARMTargetCPU - Get the (LLVM) name of the ARM cpu we are targeting. |
Daniel Dunbar | 00577ad | 2010-08-23 22:35:37 +0000 | [diff] [blame] | 77 | // |
| 78 | // FIXME: tblgen this. |
| 79 | static const char *getARMTargetCPU(const ArgList &Args, |
| 80 | const llvm::Triple &Triple) { |
Bob Wilson | 677a35b | 2012-03-21 16:31:37 +0000 | [diff] [blame] | 81 | // For Darwin targets, the -arch option (which is translated to a |
| 82 | // corresponding -march option) should determine the architecture |
| 83 | // (and the Mach-O slice) regardless of any -mcpu options. |
| 84 | if (!Triple.isOSDarwin()) { |
| 85 | // FIXME: Warn on inconsistent use of -mcpu and -march. |
| 86 | // If we have -mcpu=, use that. |
| 87 | if (Arg *A = Args.getLastArg(options::OPT_mcpu_EQ)) |
Richard Smith | 1d489cf | 2012-11-01 04:30:05 +0000 | [diff] [blame] | 88 | return A->getValue(); |
Bob Wilson | 677a35b | 2012-03-21 16:31:37 +0000 | [diff] [blame] | 89 | } |
Daniel Dunbar | 00577ad | 2010-08-23 22:35:37 +0000 | [diff] [blame] | 90 | |
Chris Lattner | 5f9e272 | 2011-07-23 10:55:15 +0000 | [diff] [blame] | 91 | StringRef MArch; |
Daniel Dunbar | 00577ad | 2010-08-23 22:35:37 +0000 | [diff] [blame] | 92 | if (Arg *A = Args.getLastArg(options::OPT_march_EQ)) { |
| 93 | // Otherwise, if we have -march= choose the base CPU for that arch. |
Richard Smith | 1d489cf | 2012-11-01 04:30:05 +0000 | [diff] [blame] | 94 | MArch = A->getValue(); |
Daniel Dunbar | 00577ad | 2010-08-23 22:35:37 +0000 | [diff] [blame] | 95 | } else { |
| 96 | // Otherwise, use the Arch from the triple. |
| 97 | MArch = Triple.getArchName(); |
| 98 | } |
| 99 | |
Bob Wilson | 57f6d19 | 2012-03-21 17:19:12 +0000 | [diff] [blame] | 100 | return llvm::StringSwitch<const char *>(MArch) |
| 101 | .Cases("armv2", "armv2a","arm2") |
| 102 | .Case("armv3", "arm6") |
| 103 | .Case("armv3m", "arm7m") |
| 104 | .Cases("armv4", "armv4t", "arm7tdmi") |
| 105 | .Cases("armv5", "armv5t", "arm10tdmi") |
| 106 | .Cases("armv5e", "armv5te", "arm1026ejs") |
| 107 | .Case("armv5tej", "arm926ej-s") |
| 108 | .Cases("armv6", "armv6k", "arm1136jf-s") |
| 109 | .Case("armv6j", "arm1136j-s") |
| 110 | .Cases("armv6z", "armv6zk", "arm1176jzf-s") |
| 111 | .Case("armv6t2", "arm1156t2-s") |
| 112 | .Cases("armv7", "armv7a", "armv7-a", "cortex-a8") |
Bob Wilson | 336bfa3 | 2012-09-29 23:52:50 +0000 | [diff] [blame] | 113 | .Cases("armv7f", "armv7-f", "cortex-a9-mp") |
| 114 | .Cases("armv7s", "armv7-s", "swift") |
Quentin Colombet | ab13751 | 2012-12-21 17:57:47 +0000 | [diff] [blame^] | 115 | .Cases("armv7r", "armv7-r", "cortex-r4", "cortex-r5") |
Bob Wilson | 57f6d19 | 2012-03-21 17:19:12 +0000 | [diff] [blame] | 116 | .Cases("armv7m", "armv7-m", "cortex-m3") |
| 117 | .Case("ep9312", "ep9312") |
| 118 | .Case("iwmmxt", "iwmmxt") |
| 119 | .Case("xscale", "xscale") |
| 120 | .Cases("armv6m", "armv6-m", "cortex-m0") |
| 121 | // If all else failed, return the most base CPU LLVM supports. |
| 122 | .Default("arm7tdmi"); |
Daniel Dunbar | 00577ad | 2010-08-23 22:35:37 +0000 | [diff] [blame] | 123 | } |
| 124 | |
| 125 | /// getLLVMArchSuffixForARM - Get the LLVM arch name to use for a particular |
| 126 | /// CPU. |
| 127 | // |
| 128 | // FIXME: This is redundant with -mcpu, why does LLVM use this. |
| 129 | // FIXME: tblgen this, or kill it! |
Chris Lattner | 5f9e272 | 2011-07-23 10:55:15 +0000 | [diff] [blame] | 130 | static const char *getLLVMArchSuffixForARM(StringRef CPU) { |
Bob Wilson | 57f6d19 | 2012-03-21 17:19:12 +0000 | [diff] [blame] | 131 | return llvm::StringSwitch<const char *>(CPU) |
| 132 | .Cases("arm7tdmi", "arm7tdmi-s", "arm710t", "v4t") |
| 133 | .Cases("arm720t", "arm9", "arm9tdmi", "v4t") |
| 134 | .Cases("arm920", "arm920t", "arm922t", "v4t") |
| 135 | .Cases("arm940t", "ep9312","v4t") |
| 136 | .Cases("arm10tdmi", "arm1020t", "v5") |
| 137 | .Cases("arm9e", "arm926ej-s", "arm946e-s", "v5e") |
| 138 | .Cases("arm966e-s", "arm968e-s", "arm10e", "v5e") |
| 139 | .Cases("arm1020e", "arm1022e", "xscale", "iwmmxt", "v5e") |
| 140 | .Cases("arm1136j-s", "arm1136jf-s", "arm1176jz-s", "v6") |
| 141 | .Cases("arm1176jzf-s", "mpcorenovfp", "mpcore", "v6") |
| 142 | .Cases("arm1156t2-s", "arm1156t2f-s", "v6t2") |
Silviu Baranga | 2df67ea | 2012-09-13 15:06:00 +0000 | [diff] [blame] | 143 | .Cases("cortex-a8", "cortex-a9", "cortex-a15", "v7") |
Bob Wilson | 57f6d19 | 2012-03-21 17:19:12 +0000 | [diff] [blame] | 144 | .Case("cortex-m3", "v7m") |
Jim Grosbach | 6903313 | 2012-03-29 19:53:34 +0000 | [diff] [blame] | 145 | .Case("cortex-m4", "v7m") |
Bob Wilson | 57f6d19 | 2012-03-21 17:19:12 +0000 | [diff] [blame] | 146 | .Case("cortex-m0", "v6m") |
Bob Wilson | 336bfa3 | 2012-09-29 23:52:50 +0000 | [diff] [blame] | 147 | .Case("cortex-a9-mp", "v7f") |
| 148 | .Case("swift", "v7s") |
Bob Wilson | 57f6d19 | 2012-03-21 17:19:12 +0000 | [diff] [blame] | 149 | .Default(""); |
Daniel Dunbar | 00577ad | 2010-08-23 22:35:37 +0000 | [diff] [blame] | 150 | } |
| 151 | |
Chad Rosier | 61ab80a | 2011-09-20 20:44:06 +0000 | [diff] [blame] | 152 | std::string ToolChain::ComputeLLVMTriple(const ArgList &Args, |
| 153 | types::ID InputType) const { |
Daniel Dunbar | 00577ad | 2010-08-23 22:35:37 +0000 | [diff] [blame] | 154 | switch (getTriple().getArch()) { |
| 155 | default: |
| 156 | return getTripleString(); |
| 157 | |
| 158 | case llvm::Triple::arm: |
| 159 | case llvm::Triple::thumb: { |
| 160 | // FIXME: Factor into subclasses. |
| 161 | llvm::Triple Triple = getTriple(); |
| 162 | |
| 163 | // Thumb2 is the default for V7 on Darwin. |
| 164 | // |
| 165 | // FIXME: Thumb should just be another -target-feaure, not in the triple. |
Chris Lattner | 5f9e272 | 2011-07-23 10:55:15 +0000 | [diff] [blame] | 166 | StringRef Suffix = |
Daniel Dunbar | 00577ad | 2010-08-23 22:35:37 +0000 | [diff] [blame] | 167 | getLLVMArchSuffixForARM(getARMTargetCPU(Args, Triple)); |
Bob Wilson | 336bfa3 | 2012-09-29 23:52:50 +0000 | [diff] [blame] | 168 | bool ThumbDefault = (Suffix.startswith("v7") && getTriple().isOSDarwin()); |
Daniel Dunbar | 00577ad | 2010-08-23 22:35:37 +0000 | [diff] [blame] | 169 | std::string ArchName = "arm"; |
Chad Rosier | 61ab80a | 2011-09-20 20:44:06 +0000 | [diff] [blame] | 170 | |
| 171 | // Assembly files should start in ARM mode. |
| 172 | if (InputType != types::TY_PP_Asm && |
| 173 | Args.hasFlag(options::OPT_mthumb, options::OPT_mno_thumb, ThumbDefault)) |
Daniel Dunbar | 00577ad | 2010-08-23 22:35:37 +0000 | [diff] [blame] | 174 | ArchName = "thumb"; |
| 175 | Triple.setArchName(ArchName + Suffix.str()); |
| 176 | |
| 177 | return Triple.getTriple(); |
| 178 | } |
| 179 | } |
| 180 | } |
| 181 | |
Chad Rosier | 61ab80a | 2011-09-20 20:44:06 +0000 | [diff] [blame] | 182 | std::string ToolChain::ComputeEffectiveClangTriple(const ArgList &Args, |
| 183 | types::ID InputType) const { |
Daniel Dunbar | 9d609f2 | 2011-04-30 04:15:58 +0000 | [diff] [blame] | 184 | // Diagnose use of Darwin OS deployment target arguments on non-Darwin. |
Daniel Dunbar | 00577ad | 2010-08-23 22:35:37 +0000 | [diff] [blame] | 185 | if (Arg *A = Args.getLastArg(options::OPT_mmacosx_version_min_EQ, |
Daniel Dunbar | 9d609f2 | 2011-04-30 04:15:58 +0000 | [diff] [blame] | 186 | options::OPT_miphoneos_version_min_EQ, |
| 187 | options::OPT_mios_simulator_version_min_EQ)) |
Chris Lattner | 5f9e272 | 2011-07-23 10:55:15 +0000 | [diff] [blame] | 188 | getDriver().Diag(diag::err_drv_clang_unsupported) |
Daniel Dunbar | 00577ad | 2010-08-23 22:35:37 +0000 | [diff] [blame] | 189 | << A->getAsString(Args); |
| 190 | |
Chad Rosier | 61ab80a | 2011-09-20 20:44:06 +0000 | [diff] [blame] | 191 | return ComputeLLVMTriple(Args, InputType); |
Daniel Dunbar | 00577ad | 2010-08-23 22:35:37 +0000 | [diff] [blame] | 192 | } |
| 193 | |
Chandler Carruth | 88491fc | 2011-11-04 07:12:53 +0000 | [diff] [blame] | 194 | void ToolChain::AddClangSystemIncludeArgs(const ArgList &DriverArgs, |
| 195 | ArgStringList &CC1Args) const { |
| 196 | // Each toolchain should provide the appropriate include flags. |
| 197 | } |
| 198 | |
Chandler Carruth | a6b2581 | 2012-11-21 23:40:23 +0000 | [diff] [blame] | 199 | void ToolChain::addClangTargetOptions(const ArgList &DriverArgs, |
| 200 | ArgStringList &CC1Args) const { |
Rafael Espindola | 8af669f | 2012-06-19 01:26:10 +0000 | [diff] [blame] | 201 | } |
| 202 | |
Daniel Dunbar | c24767c | 2011-12-07 23:03:15 +0000 | [diff] [blame] | 203 | ToolChain::RuntimeLibType ToolChain::GetRuntimeLibType( |
| 204 | const ArgList &Args) const |
| 205 | { |
| 206 | if (Arg *A = Args.getLastArg(options::OPT_rtlib_EQ)) { |
Richard Smith | 1d489cf | 2012-11-01 04:30:05 +0000 | [diff] [blame] | 207 | StringRef Value = A->getValue(); |
Daniel Dunbar | c24767c | 2011-12-07 23:03:15 +0000 | [diff] [blame] | 208 | if (Value == "compiler-rt") |
| 209 | return ToolChain::RLT_CompilerRT; |
| 210 | if (Value == "libgcc") |
| 211 | return ToolChain::RLT_Libgcc; |
| 212 | getDriver().Diag(diag::err_drv_invalid_rtlib_name) |
| 213 | << A->getAsString(Args); |
| 214 | } |
| 215 | |
| 216 | return GetDefaultRuntimeLibType(); |
| 217 | } |
| 218 | |
Daniel Dunbar | 641b98b | 2010-09-14 23:12:35 +0000 | [diff] [blame] | 219 | ToolChain::CXXStdlibType ToolChain::GetCXXStdlibType(const ArgList &Args) const{ |
Daniel Dunbar | 3f16c95 | 2010-09-14 23:12:40 +0000 | [diff] [blame] | 220 | if (Arg *A = Args.getLastArg(options::OPT_stdlib_EQ)) { |
Richard Smith | 1d489cf | 2012-11-01 04:30:05 +0000 | [diff] [blame] | 221 | StringRef Value = A->getValue(); |
Daniel Dunbar | 3f16c95 | 2010-09-14 23:12:40 +0000 | [diff] [blame] | 222 | if (Value == "libc++") |
| 223 | return ToolChain::CST_Libcxx; |
| 224 | if (Value == "libstdc++") |
| 225 | return ToolChain::CST_Libstdcxx; |
Chris Lattner | 5f9e272 | 2011-07-23 10:55:15 +0000 | [diff] [blame] | 226 | getDriver().Diag(diag::err_drv_invalid_stdlib_name) |
Daniel Dunbar | 3f16c95 | 2010-09-14 23:12:40 +0000 | [diff] [blame] | 227 | << A->getAsString(Args); |
| 228 | } |
| 229 | |
Daniel Dunbar | 641b98b | 2010-09-14 23:12:35 +0000 | [diff] [blame] | 230 | return ToolChain::CST_Libstdcxx; |
| 231 | } |
| 232 | |
Chandler Carruth | 79cbbdc | 2011-12-17 23:10:01 +0000 | [diff] [blame] | 233 | /// \brief Utility function to add a system include directory to CC1 arguments. |
| 234 | /*static*/ void ToolChain::addSystemInclude(const ArgList &DriverArgs, |
| 235 | ArgStringList &CC1Args, |
| 236 | const Twine &Path) { |
| 237 | CC1Args.push_back("-internal-isystem"); |
| 238 | CC1Args.push_back(DriverArgs.MakeArgString(Path)); |
| 239 | } |
| 240 | |
| 241 | /// \brief Utility function to add a system include directory with extern "C" |
| 242 | /// semantics to CC1 arguments. |
| 243 | /// |
| 244 | /// Note that this should be used rarely, and only for directories that |
| 245 | /// historically and for legacy reasons are treated as having implicit extern |
| 246 | /// "C" semantics. These semantics are *ignored* by and large today, but its |
| 247 | /// important to preserve the preprocessor changes resulting from the |
| 248 | /// classification. |
| 249 | /*static*/ void ToolChain::addExternCSystemInclude(const ArgList &DriverArgs, |
| 250 | ArgStringList &CC1Args, |
| 251 | const Twine &Path) { |
| 252 | CC1Args.push_back("-internal-externc-isystem"); |
| 253 | CC1Args.push_back(DriverArgs.MakeArgString(Path)); |
| 254 | } |
| 255 | |
| 256 | /// \brief Utility function to add a list of system include directories to CC1. |
| 257 | /*static*/ void ToolChain::addSystemIncludes(const ArgList &DriverArgs, |
| 258 | ArgStringList &CC1Args, |
| 259 | ArrayRef<StringRef> Paths) { |
| 260 | for (ArrayRef<StringRef>::iterator I = Paths.begin(), E = Paths.end(); |
| 261 | I != E; ++I) { |
| 262 | CC1Args.push_back("-internal-isystem"); |
| 263 | CC1Args.push_back(DriverArgs.MakeArgString(*I)); |
| 264 | } |
| 265 | } |
| 266 | |
Chandler Carruth | ab9fcd0 | 2011-11-04 23:49:01 +0000 | [diff] [blame] | 267 | void ToolChain::AddClangCXXStdlibIncludeArgs(const ArgList &DriverArgs, |
| 268 | ArgStringList &CC1Args) const { |
Chandler Carruth | a461442 | 2011-11-04 07:43:33 +0000 | [diff] [blame] | 269 | // Header search paths should be handled by each of the subclasses. |
| 270 | // Historically, they have not been, and instead have been handled inside of |
| 271 | // the CC1-layer frontend. As the logic is hoisted out, this generic function |
| 272 | // will slowly stop being called. |
| 273 | // |
| 274 | // While it is being called, replicate a bit of a hack to propagate the |
| 275 | // '-stdlib=' flag down to CC1 so that it can in turn customize the C++ |
| 276 | // header search paths with it. Once all systems are overriding this |
| 277 | // function, the CC1 flag and this line can be removed. |
Chandler Carruth | ab9fcd0 | 2011-11-04 23:49:01 +0000 | [diff] [blame] | 278 | DriverArgs.AddAllArgs(CC1Args, options::OPT_stdlib_EQ); |
Daniel Dunbar | 641b98b | 2010-09-14 23:12:35 +0000 | [diff] [blame] | 279 | } |
| 280 | |
Daniel Dunbar | 132e35d | 2010-09-17 01:20:05 +0000 | [diff] [blame] | 281 | void ToolChain::AddCXXStdlibLibArgs(const ArgList &Args, |
| 282 | ArgStringList &CmdArgs) const { |
Daniel Dunbar | 641b98b | 2010-09-14 23:12:35 +0000 | [diff] [blame] | 283 | CXXStdlibType Type = GetCXXStdlibType(Args); |
| 284 | |
| 285 | switch (Type) { |
Daniel Dunbar | 3f16c95 | 2010-09-14 23:12:40 +0000 | [diff] [blame] | 286 | case ToolChain::CST_Libcxx: |
| 287 | CmdArgs.push_back("-lc++"); |
| 288 | break; |
| 289 | |
Daniel Dunbar | 641b98b | 2010-09-14 23:12:35 +0000 | [diff] [blame] | 290 | case ToolChain::CST_Libstdcxx: |
| 291 | CmdArgs.push_back("-lstdc++"); |
| 292 | break; |
| 293 | } |
| 294 | } |
Shantonu Sen | 7433fed | 2010-09-17 18:39:08 +0000 | [diff] [blame] | 295 | |
| 296 | void ToolChain::AddCCKextLibArgs(const ArgList &Args, |
| 297 | ArgStringList &CmdArgs) const { |
| 298 | CmdArgs.push_back("-lcc_kext"); |
| 299 | } |
Benjamin Kramer | e20e508 | 2012-10-04 19:42:20 +0000 | [diff] [blame] | 300 | |
| 301 | bool ToolChain::AddFastMathRuntimeIfAvailable(const ArgList &Args, |
| 302 | ArgStringList &CmdArgs) const { |
| 303 | // Check if -ffast-math or -funsafe-math is enabled. |
| 304 | Arg *A = Args.getLastArg(options::OPT_ffast_math, |
| 305 | options::OPT_fno_fast_math, |
| 306 | options::OPT_funsafe_math_optimizations, |
| 307 | options::OPT_fno_unsafe_math_optimizations); |
| 308 | |
| 309 | if (!A || A->getOption().getID() == options::OPT_fno_fast_math || |
| 310 | A->getOption().getID() == options::OPT_fno_unsafe_math_optimizations) |
| 311 | return false; |
| 312 | |
| 313 | // If crtfastmath.o exists add it to the arguments. |
| 314 | std::string Path = GetFilePath("crtfastmath.o"); |
| 315 | if (Path == "crtfastmath.o") // Not found. |
| 316 | return false; |
| 317 | |
| 318 | CmdArgs.push_back(Args.MakeArgString(Path)); |
| 319 | return true; |
| 320 | } |