blob: 90893c305c8d1697e900571906e07598d7abbe05 [file] [log] [blame]
Daniel Dunbar83b08eb2009-03-17 21:38:00 +00001//===--- ToolChains.h - ToolChain Implementations ---------------*- C++ -*-===//
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
Stephen Hines176edba2014-12-01 14:53:08 -080010#ifndef LLVM_CLANG_LIB_DRIVER_TOOLCHAINS_H
11#define LLVM_CLANG_LIB_DRIVER_TOOLCHAINS_H
Daniel Dunbar83b08eb2009-03-17 21:38:00 +000012
Chandler Carruth55fc8732012-12-04 09:13:33 +000013#include "Tools.h"
14#include "clang/Basic/VersionTuple.h"
Daniel Dunbar670b7f42009-03-17 22:07:31 +000015#include "clang/Driver/Action.h"
Stephen Hines651f13c2014-04-23 16:59:28 -070016#include "clang/Driver/Multilib.h"
Daniel Dunbar83b08eb2009-03-17 21:38:00 +000017#include "clang/Driver/ToolChain.h"
Daniel Dunbar670b7f42009-03-17 22:07:31 +000018#include "llvm/ADT/DenseMap.h"
Stephen Hines651f13c2014-04-23 16:59:28 -070019#include "llvm/ADT/Optional.h"
Daniel Dunbar83b08eb2009-03-17 21:38:00 +000020#include "llvm/Support/Compiler.h"
Benjamin Kramerf15b26c2013-08-14 18:38:51 +000021#include <set>
Stephen Hines651f13c2014-04-23 16:59:28 -070022#include <vector>
Rafael Espindolaa2654612013-06-11 20:06:05 +000023
Daniel Dunbar83b08eb2009-03-17 21:38:00 +000024namespace clang {
25namespace driver {
Daniel Dunbar985b8252009-03-17 22:18:43 +000026namespace toolchains {
Daniel Dunbar83b08eb2009-03-17 21:38:00 +000027
Daniel Dunbar1d4612b2009-09-18 08:15:13 +000028/// Generic_GCC - A tool chain using the 'gcc' command to perform
29/// all subcommands; this relies on gcc translating the majority of
30/// command line options.
Duncan Sands92dd1912010-05-11 20:16:05 +000031class LLVM_LIBRARY_VISIBILITY Generic_GCC : public ToolChain {
Daniel Dunbar75358d22009-03-30 21:06:03 +000032protected:
Chandler Carruth19347ed2011-11-06 23:39:34 +000033 /// \brief Struct to store and manipulate GCC versions.
34 ///
35 /// We rely on assumptions about the form and structure of GCC version
36 /// numbers: they consist of at most three '.'-separated components, and each
37 /// component is a non-negative integer except for the last component. For
38 /// the last component we are very flexible in order to tolerate release
39 /// candidates or 'x' wildcards.
40 ///
41 /// Note that the ordering established among GCCVersions is based on the
42 /// preferred version string to use. For example we prefer versions without
43 /// a hard-coded patch number to those with a hard coded patch number.
44 ///
45 /// Currently this doesn't provide any logic for textual suffixes to patches
46 /// in the way that (for example) Debian's version format does. If that ever
47 /// becomes necessary, it can be added.
48 struct GCCVersion {
49 /// \brief The unparsed text of the version.
50 std::string Text;
51
52 /// \brief The parsed major, minor, and patch numbers.
53 int Major, Minor, Patch;
54
Chandler Carruth0affc672013-08-26 08:59:53 +000055 /// \brief The text of the parsed major, and major+minor versions.
56 std::string MajorStr, MinorStr;
57
Chandler Carruth19347ed2011-11-06 23:39:34 +000058 /// \brief Any textual suffix on the patch number.
59 std::string PatchSuffix;
60
61 static GCCVersion Parse(StringRef VersionText);
Benjamin Kramered5f28f2013-08-09 17:17:48 +000062 bool isOlderThan(int RHSMajor, int RHSMinor, int RHSPatch,
63 StringRef RHSPatchSuffix = StringRef()) const;
64 bool operator<(const GCCVersion &RHS) const {
65 return isOlderThan(RHS.Major, RHS.Minor, RHS.Patch, RHS.PatchSuffix);
66 }
Chandler Carruth19347ed2011-11-06 23:39:34 +000067 bool operator>(const GCCVersion &RHS) const { return RHS < *this; }
68 bool operator<=(const GCCVersion &RHS) const { return !(*this > RHS); }
69 bool operator>=(const GCCVersion &RHS) const { return !(*this < RHS); }
70 };
71
Chandler Carruth19347ed2011-11-06 23:39:34 +000072 /// \brief This is a class to find a viable GCC installation for Clang to
73 /// use.
74 ///
75 /// This class tries to find a GCC installation on the system, and report
76 /// information about it. It starts from the host information provided to the
77 /// Driver, and has logic for fuzzing that where appropriate.
78 class GCCInstallationDetector {
Chandler Carruth19347ed2011-11-06 23:39:34 +000079 bool IsValid;
Chandler Carruthfa5be912012-01-24 19:28:29 +000080 llvm::Triple GCCTriple;
Chandler Carruth19347ed2011-11-06 23:39:34 +000081
82 // FIXME: These might be better as path objects.
Chandler Carruth5d84bb42012-01-24 19:21:42 +000083 std::string GCCInstallPath;
84 std::string GCCParentLibPath;
Stephen Hines651f13c2014-04-23 16:59:28 -070085
86 /// The primary multilib appropriate for the given flags.
87 Multilib SelectedMultilib;
88 /// On Biarch systems, this corresponds to the default multilib when
89 /// targeting the non-default multilib. Otherwise, it is empty.
90 llvm::Optional<Multilib> BiarchSibling;
Chandler Carruth19347ed2011-11-06 23:39:34 +000091
92 GCCVersion Version;
93
Chandler Carruth6365ab92013-07-30 17:57:09 +000094 // We retain the list of install paths that were considered and rejected in
95 // order to print out detailed information in verbose mode.
Benjamin Kramerf15b26c2013-08-14 18:38:51 +000096 std::set<std::string> CandidateGCCInstallPaths;
Chandler Carruth6365ab92013-07-30 17:57:09 +000097
Stephen Hines651f13c2014-04-23 16:59:28 -070098 /// The set of multilibs that the detected installation supports.
99 MultilibSet Multilibs;
100
Chandler Carruth19347ed2011-11-06 23:39:34 +0000101 public:
Stephen Hines651f13c2014-04-23 16:59:28 -0700102 GCCInstallationDetector() : IsValid(false) {}
103 void init(const Driver &D, const llvm::Triple &TargetTriple,
Reid Klecknerdd0b3c42013-06-17 13:59:19 +0000104 const llvm::opt::ArgList &Args);
Chandler Carruth19347ed2011-11-06 23:39:34 +0000105
106 /// \brief Check whether we detected a valid GCC install.
107 bool isValid() const { return IsValid; }
108
109 /// \brief Get the GCC triple for the detected install.
Chandler Carruthfa5be912012-01-24 19:28:29 +0000110 const llvm::Triple &getTriple() const { return GCCTriple; }
Chandler Carruth19347ed2011-11-06 23:39:34 +0000111
112 /// \brief Get the detected GCC installation path.
Chandler Carruth5d84bb42012-01-24 19:21:42 +0000113 StringRef getInstallPath() const { return GCCInstallPath; }
Chandler Carruth19347ed2011-11-06 23:39:34 +0000114
115 /// \brief Get the detected GCC parent lib path.
Chandler Carruth5d84bb42012-01-24 19:21:42 +0000116 StringRef getParentLibPath() const { return GCCParentLibPath; }
Chandler Carruth19347ed2011-11-06 23:39:34 +0000117
Stephen Hines651f13c2014-04-23 16:59:28 -0700118 /// \brief Get the detected Multilib
119 const Multilib &getMultilib() const { return SelectedMultilib; }
120
121 /// \brief Get the whole MultilibSet
122 const MultilibSet &getMultilibs() const { return Multilibs; }
123
124 /// Get the biarch sibling multilib (if it exists).
125 /// \return true iff such a sibling exists
126 bool getBiarchSibling(Multilib &M) const;
Simon Atanasyan5c805e92013-09-28 13:45:11 +0000127
Chandler Carruth19347ed2011-11-06 23:39:34 +0000128 /// \brief Get the detected GCC version string.
Rafael Espindola8af669f2012-06-19 01:26:10 +0000129 const GCCVersion &getVersion() const { return Version; }
Chandler Carruth19347ed2011-11-06 23:39:34 +0000130
Chandler Carruth6365ab92013-07-30 17:57:09 +0000131 /// \brief Print information about the detected GCC installation.
132 void print(raw_ostream &OS) const;
133
Chandler Carruth19347ed2011-11-06 23:39:34 +0000134 private:
Chandler Carruthd79486a2013-06-22 11:35:51 +0000135 static void
136 CollectLibDirsAndTriples(const llvm::Triple &TargetTriple,
137 const llvm::Triple &BiarchTriple,
138 SmallVectorImpl<StringRef> &LibDirs,
139 SmallVectorImpl<StringRef> &TripleAliases,
140 SmallVectorImpl<StringRef> &BiarchLibDirs,
141 SmallVectorImpl<StringRef> &BiarchTripleAliases);
Chandler Carruth19347ed2011-11-06 23:39:34 +0000142
Stephen Hines651f13c2014-04-23 16:59:28 -0700143 void ScanLibDirForGCCTriple(const llvm::Triple &TargetArch,
Reid Klecknerdd0b3c42013-06-17 13:59:19 +0000144 const llvm::opt::ArgList &Args,
Chandler Carruthd936d9d2011-11-09 03:46:20 +0000145 const std::string &LibDir,
Chandler Carruth1c6f04a2012-01-25 07:21:38 +0000146 StringRef CandidateTriple,
Chandler Carruthd79486a2013-06-22 11:35:51 +0000147 bool NeedsBiarchSuffix = false);
Chandler Carruth19347ed2011-11-06 23:39:34 +0000148 };
149
150 GCCInstallationDetector GCCInstallation;
151
Daniel Dunbar83b08eb2009-03-17 21:38:00 +0000152public:
Reid Klecknerdd0b3c42013-06-17 13:59:19 +0000153 Generic_GCC(const Driver &D, const llvm::Triple &Triple,
154 const llvm::opt::ArgList &Args);
Daniel Dunbar39176082009-03-20 00:20:03 +0000155 ~Generic_GCC();
Daniel Dunbar83b08eb2009-03-17 21:38:00 +0000156
Stephen Hines651f13c2014-04-23 16:59:28 -0700157 void printVerboseInfo(raw_ostream &OS) const override;
Chandler Carruth6365ab92013-07-30 17:57:09 +0000158
Stephen Hines651f13c2014-04-23 16:59:28 -0700159 bool IsUnwindTablesDefault() const override;
160 bool isPICDefault() const override;
161 bool isPIEDefault() const override;
162 bool isPICDefaultForced() const override;
163 bool IsIntegratedAssemblerDefault() const override;
Chandler Carruthb37fe612011-11-06 23:39:37 +0000164
165protected:
Stephen Hines651f13c2014-04-23 16:59:28 -0700166 Tool *getTool(Action::ActionClass AC) const override;
167 Tool *buildAssembler() const override;
168 Tool *buildLinker() const override;
Rafael Espindolaf48b93c2013-03-20 03:05:54 +0000169
Chandler Carruthb37fe612011-11-06 23:39:37 +0000170 /// \name ToolChain Implementation Helper Functions
171 /// @{
172
173 /// \brief Check whether the target triple's architecture is 64-bits.
Chandler Carruthd747efa2012-02-11 03:31:12 +0000174 bool isTarget64Bit() const { return getTriple().isArch64Bit(); }
175
Chandler Carruthb37fe612011-11-06 23:39:37 +0000176 /// \brief Check whether the target triple's architecture is 32-bits.
Chandler Carruthd747efa2012-02-11 03:31:12 +0000177 bool isTarget32Bit() const { return getTriple().isArch32Bit(); }
Chandler Carruthb37fe612011-11-06 23:39:37 +0000178
179 /// @}
Rafael Espindolaf48b93c2013-03-20 03:05:54 +0000180
181private:
Stephen Hines651f13c2014-04-23 16:59:28 -0700182 mutable std::unique_ptr<tools::gcc::Preprocess> Preprocess;
183 mutable std::unique_ptr<tools::gcc::Compile> Compile;
184};
185
186class LLVM_LIBRARY_VISIBILITY MachO : public ToolChain {
187protected:
188 Tool *buildAssembler() const override;
189 Tool *buildLinker() const override;
190 Tool *getTool(Action::ActionClass AC) const override;
191private:
192 mutable std::unique_ptr<tools::darwin::Lipo> Lipo;
193 mutable std::unique_ptr<tools::darwin::Dsymutil> Dsymutil;
194 mutable std::unique_ptr<tools::darwin::VerifyDebug> VerifyDebug;
195
196public:
197 MachO(const Driver &D, const llvm::Triple &Triple,
198 const llvm::opt::ArgList &Args);
199 ~MachO();
200
201 /// @name MachO specific toolchain API
202 /// {
203
204 /// Get the "MachO" arch name for a particular compiler invocation. For
205 /// example, Apple treats different ARM variations as distinct architectures.
206 StringRef getMachOArchName(const llvm::opt::ArgList &Args) const;
207
208
209 /// Add the linker arguments to link the ARC runtime library.
210 virtual void AddLinkARCArgs(const llvm::opt::ArgList &Args,
211 llvm::opt::ArgStringList &CmdArgs) const {}
212
213 /// Add the linker arguments to link the compiler runtime library.
214 virtual void AddLinkRuntimeLibArgs(const llvm::opt::ArgList &Args,
215 llvm::opt::ArgStringList &CmdArgs) const;
216
217 virtual void
218 addStartObjectFileArgs(const llvm::opt::ArgList &Args,
219 llvm::opt::ArgStringList &CmdArgs) const {}
220
221 virtual void addMinVersionArgs(const llvm::opt::ArgList &Args,
222 llvm::opt::ArgStringList &CmdArgs) const {}
223
224 /// On some iOS platforms, kernel and kernel modules were built statically. Is
225 /// this such a target?
226 virtual bool isKernelStatic() const {
227 return false;
228 }
229
230 /// Is the target either iOS or an iOS simulator?
231 bool isTargetIOSBased() const {
232 return false;
233 }
234
235 void AddLinkRuntimeLib(const llvm::opt::ArgList &Args,
236 llvm::opt::ArgStringList &CmdArgs,
Stephen Hines176edba2014-12-01 14:53:08 -0800237 StringRef DarwinLibName,
Stephen Hines651f13c2014-04-23 16:59:28 -0700238 bool AlwaysLink = false,
Stephen Hines176edba2014-12-01 14:53:08 -0800239 bool IsEmbedded = false,
240 bool AddRPath = false) const;
Stephen Hines651f13c2014-04-23 16:59:28 -0700241
242 /// }
243 /// @name ToolChain Implementation
244 /// {
245
246 std::string ComputeEffectiveClangTriple(const llvm::opt::ArgList &Args,
247 types::ID InputType) const override;
248
249 types::ID LookupTypeForExtension(const char *Ext) const override;
250
251 bool HasNativeLLVMSupport() const override;
252
253 llvm::opt::DerivedArgList *
254 TranslateArgs(const llvm::opt::DerivedArgList &Args,
255 const char *BoundArch) const override;
256
257 bool IsBlocksDefault() const override {
258 // Always allow blocks on Apple; users interested in versioning are
Stephen Hines0e2c34f2015-03-23 12:09:02 -0700259 // expected to use /usr/include/Block.h.
Stephen Hines651f13c2014-04-23 16:59:28 -0700260 return true;
261 }
262 bool IsIntegratedAssemblerDefault() const override {
263 // Default integrated assembler to on for Apple's MachO targets.
264 return true;
265 }
266
267 bool IsMathErrnoDefault() const override {
268 return false;
269 }
270
271 bool IsEncodeExtendedBlockSignatureDefault() const override {
272 return true;
273 }
274
275 bool IsObjCNonFragileABIDefault() const override {
276 // Non-fragile ABI is default for everything but i386.
277 return getTriple().getArch() != llvm::Triple::x86;
278 }
279
280 bool UseObjCMixedDispatch() const override {
281 return true;
282 }
283
284 bool IsUnwindTablesDefault() const override;
285
286 RuntimeLibType GetDefaultRuntimeLibType() const override {
287 return ToolChain::RLT_CompilerRT;
288 }
289
290 bool isPICDefault() const override;
291 bool isPIEDefault() const override;
292 bool isPICDefaultForced() const override;
293
294 bool SupportsProfiling() const override;
295
296 bool SupportsObjCGC() const override {
297 return false;
298 }
299
300 bool UseDwarfDebugFlags() const override;
301
302 bool UseSjLjExceptions() const override {
303 return false;
304 }
305
306 /// }
Daniel Dunbar83b08eb2009-03-17 21:38:00 +0000307};
308
Tony Linthicum96319392011-12-12 21:14:55 +0000309 /// Darwin - The base Darwin tool chain.
Stephen Hines651f13c2014-04-23 16:59:28 -0700310class LLVM_LIBRARY_VISIBILITY Darwin : public MachO {
Daniel Dunbar25b58eb2010-08-02 05:44:07 +0000311public:
312 /// The host version.
313 unsigned DarwinVersion[3];
314
Daniel Dunbar26031372010-01-27 00:56:25 +0000315 /// Whether the information on the target has been initialized.
316 //
317 // FIXME: This should be eliminated. What we want to do is make this part of
318 // the "default target for arguments" selection process, once we get out of
319 // the argument translation business.
320 mutable bool TargetInitialized;
321
Stephen Hines651f13c2014-04-23 16:59:28 -0700322 enum DarwinPlatformKind {
323 MacOS,
324 IPhoneOS,
325 IPhoneOSSimulator
326 };
Daniel Dunbareb840bd2010-05-14 02:03:00 +0000327
Stephen Hines651f13c2014-04-23 16:59:28 -0700328 mutable DarwinPlatformKind TargetPlatform;
Daniel Dunbar5f5c37b2011-04-30 04:18:16 +0000329
Chris Lattnerfc8f0e12011-04-15 05:22:18 +0000330 /// The OS version we are targeting.
Benjamin Kramer09c9a562012-03-10 20:55:36 +0000331 mutable VersionTuple TargetVersion;
Daniel Dunbar26031372010-01-27 00:56:25 +0000332
John McCall260611a2012-06-20 06:18:46 +0000333private:
Daniel Dunbar02633b52009-03-26 16:23:12 +0000334 /// The default macosx-version-min of this tool chain; empty until
335 /// initialized.
Daniel Dunbar816bc312010-01-26 01:45:19 +0000336 std::string MacosxVersionMin;
Daniel Dunbar02633b52009-03-26 16:23:12 +0000337
Chad Rosier4ec26782012-05-09 18:37:26 +0000338 /// The default ios-version-min of this tool chain; empty until
339 /// initialized.
340 std::string iOSVersionMin;
341
Daniel Dunbarc0e665e2010-07-19 17:11:33 +0000342private:
Reid Klecknerdd0b3c42013-06-17 13:59:19 +0000343 void AddDeploymentTarget(llvm::opt::DerivedArgList &Args) const;
Daniel Dunbarc0e665e2010-07-19 17:11:33 +0000344
Daniel Dunbar8eddb3f2009-03-20 00:57:52 +0000345public:
Reid Klecknerdd0b3c42013-06-17 13:59:19 +0000346 Darwin(const Driver &D, const llvm::Triple &Triple,
347 const llvm::opt::ArgList &Args);
Daniel Dunbarf3955282009-09-04 18:34:51 +0000348 ~Darwin();
Daniel Dunbar8eddb3f2009-03-20 00:57:52 +0000349
Reid Klecknerdd0b3c42013-06-17 13:59:19 +0000350 std::string ComputeEffectiveClangTriple(const llvm::opt::ArgList &Args,
Stephen Hines651f13c2014-04-23 16:59:28 -0700351 types::ID InputType) const override;
Daniel Dunbar00577ad2010-08-23 22:35:37 +0000352
Stephen Hines651f13c2014-04-23 16:59:28 -0700353 /// @name Apple Specific Toolchain Implementation
354 /// {
355
356 void
357 addMinVersionArgs(const llvm::opt::ArgList &Args,
358 llvm::opt::ArgStringList &CmdArgs) const override;
359
360 void
361 addStartObjectFileArgs(const llvm::opt::ArgList &Args,
362 llvm::opt::ArgStringList &CmdArgs) const override;
363
364 bool isKernelStatic() const override {
Stephen Hines0e2c34f2015-03-23 12:09:02 -0700365 return !isTargetIPhoneOS() || isIPhoneOSVersionLT(6, 0);
Stephen Hines651f13c2014-04-23 16:59:28 -0700366 }
367
368protected:
369 /// }
370 /// @name Darwin specific Toolchain functions
Daniel Dunbar6b200b22009-09-18 08:14:36 +0000371 /// {
372
Daniel Dunbar26031372010-01-27 00:56:25 +0000373 // FIXME: Eliminate these ...Target functions and derive separate tool chains
374 // for these targets and put version in constructor.
Stephen Hines651f13c2014-04-23 16:59:28 -0700375 void setTarget(DarwinPlatformKind Platform, unsigned Major, unsigned Minor,
376 unsigned Micro) const {
Daniel Dunbar26031372010-01-27 00:56:25 +0000377 // FIXME: For now, allow reinitialization as long as values don't
378 // change. This will go away when we move away from argument translation.
Stephen Hines651f13c2014-04-23 16:59:28 -0700379 if (TargetInitialized && TargetPlatform == Platform &&
Benjamin Kramer09c9a562012-03-10 20:55:36 +0000380 TargetVersion == VersionTuple(Major, Minor, Micro))
Daniel Dunbar26031372010-01-27 00:56:25 +0000381 return;
382
383 assert(!TargetInitialized && "Target already initialized!");
384 TargetInitialized = true;
Stephen Hines651f13c2014-04-23 16:59:28 -0700385 TargetPlatform = Platform;
Benjamin Kramer09c9a562012-03-10 20:55:36 +0000386 TargetVersion = VersionTuple(Major, Minor, Micro);
Daniel Dunbar26031372010-01-27 00:56:25 +0000387 }
388
389 bool isTargetIPhoneOS() const {
390 assert(TargetInitialized && "Target not initialized!");
Stephen Hines651f13c2014-04-23 16:59:28 -0700391 return TargetPlatform == IPhoneOS;
Daniel Dunbar26031372010-01-27 00:56:25 +0000392 }
393
Daniel Dunbar40355802011-03-31 17:12:33 +0000394 bool isTargetIOSSimulator() const {
Daniel Dunbar5f5c37b2011-04-30 04:18:16 +0000395 assert(TargetInitialized && "Target not initialized!");
Stephen Hines651f13c2014-04-23 16:59:28 -0700396 return TargetPlatform == IPhoneOSSimulator;
397 }
398
399 bool isTargetIOSBased() const {
400 assert(TargetInitialized && "Target not initialized!");
401 return isTargetIPhoneOS() || isTargetIOSSimulator();
Daniel Dunbar40355802011-03-31 17:12:33 +0000402 }
403
Ted Kremenekebcb57a2012-03-06 20:05:56 +0000404 bool isTargetMacOS() const {
Stephen Hines651f13c2014-04-23 16:59:28 -0700405 return TargetPlatform == MacOS;
Ted Kremenekebcb57a2012-03-06 20:05:56 +0000406 }
407
Daniel Dunbar03d87ee2010-03-20 00:50:21 +0000408 bool isTargetInitialized() const { return TargetInitialized; }
409
Benjamin Kramer09c9a562012-03-10 20:55:36 +0000410 VersionTuple getTargetVersion() const {
Daniel Dunbar26031372010-01-27 00:56:25 +0000411 assert(TargetInitialized && "Target not initialized!");
Benjamin Kramer09c9a562012-03-10 20:55:36 +0000412 return TargetVersion;
Daniel Dunbar26031372010-01-27 00:56:25 +0000413 }
414
Daniel Dunbarcacb0f02010-01-27 00:56:56 +0000415 bool isIPhoneOSVersionLT(unsigned V0, unsigned V1=0, unsigned V2=0) const {
Stephen Hines651f13c2014-04-23 16:59:28 -0700416 assert(isTargetIOSBased() && "Unexpected call for non iOS target!");
Benjamin Kramer09c9a562012-03-10 20:55:36 +0000417 return TargetVersion < VersionTuple(V0, V1, V2);
Daniel Dunbarce3fdf22010-01-27 00:57:03 +0000418 }
419
420 bool isMacosxVersionLT(unsigned V0, unsigned V1=0, unsigned V2=0) const {
Stephen Hines651f13c2014-04-23 16:59:28 -0700421 assert(isTargetMacOS() && "Unexpected call for non OS X target!");
Benjamin Kramer09c9a562012-03-10 20:55:36 +0000422 return TargetVersion < VersionTuple(V0, V1, V2);
Daniel Dunbarcacb0f02010-01-27 00:56:56 +0000423 }
424
Stephen Hines651f13c2014-04-23 16:59:28 -0700425public:
Daniel Dunbar6b200b22009-09-18 08:14:36 +0000426 /// }
427 /// @name ToolChain Implementation
428 /// {
429
Stephen Hines176edba2014-12-01 14:53:08 -0800430 // Darwin tools support multiple architecture (e.g., i386 and x86_64) and
431 // most development is done against SDKs, so compiling for a different
432 // architecture should not get any special treatment.
433 bool isCrossCompiling() const override { return false; }
434
Stephen Hines651f13c2014-04-23 16:59:28 -0700435 llvm::opt::DerivedArgList *
Reid Klecknerdd0b3c42013-06-17 13:59:19 +0000436 TranslateArgs(const llvm::opt::DerivedArgList &Args,
Stephen Hines651f13c2014-04-23 16:59:28 -0700437 const char *BoundArch) const override;
Daniel Dunbar8eddb3f2009-03-20 00:57:52 +0000438
Stephen Hines651f13c2014-04-23 16:59:28 -0700439 ObjCRuntime getDefaultObjCRuntime(bool isNonFragile) const override;
440 bool hasBlocksRuntime() const override;
Benjamin Kramer769aa2d2012-05-02 14:55:48 +0000441
Stephen Hines651f13c2014-04-23 16:59:28 -0700442 bool UseObjCMixedDispatch() const override {
Daniel Dunbarf645aaa2010-04-24 18:37:41 +0000443 // This is only used with the non-fragile ABI and non-legacy dispatch.
444
445 // Mixed dispatch is used everywhere except OS X before 10.6.
Stephen Hines651f13c2014-04-23 16:59:28 -0700446 return !(isTargetMacOS() && isMacosxVersionLT(10, 6));
Daniel Dunbarf643b9b2010-04-24 17:56:46 +0000447 }
Stephen Hines651f13c2014-04-23 16:59:28 -0700448
449 unsigned GetDefaultStackProtectorLevel(bool KernelOrKext) const override {
Nico Weber2fef1112011-08-23 07:38:27 +0000450 // Stack protectors default to on for user code on 10.5,
451 // and for everything in 10.6 and beyond
Stephen Hines651f13c2014-04-23 16:59:28 -0700452 if (isTargetIOSBased())
453 return 1;
454 else if (isTargetMacOS() && !isMacosxVersionLT(10, 6))
455 return 1;
456 else if (isTargetMacOS() && !isMacosxVersionLT(10, 5) && !KernelOrKext)
457 return 1;
458
459 return 0;
Daniel Dunbar9e5cc6b2009-11-17 08:07:36 +0000460 }
Daniel Dunbar6b200b22009-09-18 08:14:36 +0000461
Stephen Hines651f13c2014-04-23 16:59:28 -0700462 bool SupportsObjCGC() const override;
Daniel Dunbarbbe8e3e2011-03-01 18:49:30 +0000463
Stephen Hines651f13c2014-04-23 16:59:28 -0700464 void CheckObjCARC() const override;
Daniel Dunbar43a9b322010-04-10 16:20:23 +0000465
Stephen Hines651f13c2014-04-23 16:59:28 -0700466 bool UseSjLjExceptions() const override;
Daniel Dunbar8eddb3f2009-03-20 00:57:52 +0000467};
468
Daniel Dunbar1d4612b2009-09-18 08:15:13 +0000469/// DarwinClang - The Darwin toolchain used by Clang.
Duncan Sands92dd1912010-05-11 20:16:05 +0000470class LLVM_LIBRARY_VISIBILITY DarwinClang : public Darwin {
Daniel Dunbar8eddb3f2009-03-20 00:57:52 +0000471public:
Reid Klecknerdd0b3c42013-06-17 13:59:19 +0000472 DarwinClang(const Driver &D, const llvm::Triple &Triple,
473 const llvm::opt::ArgList &Args);
Daniel Dunbar1d4612b2009-09-18 08:15:13 +0000474
Stephen Hines651f13c2014-04-23 16:59:28 -0700475 /// @name Apple ToolChain Implementation
Daniel Dunbar1d4612b2009-09-18 08:15:13 +0000476 /// {
477
Stephen Hines651f13c2014-04-23 16:59:28 -0700478 void
479 AddLinkRuntimeLibArgs(const llvm::opt::ArgList &Args,
480 llvm::opt::ArgStringList &CmdArgs) const override;
Alexey Samsonov69b77d72012-11-21 14:17:42 +0000481
Stephen Hines651f13c2014-04-23 16:59:28 -0700482 void
483 AddCXXStdlibLibArgs(const llvm::opt::ArgList &Args,
484 llvm::opt::ArgStringList &CmdArgs) const override;
Daniel Dunbarefe91ea2010-09-17 01:16:06 +0000485
Stephen Hines651f13c2014-04-23 16:59:28 -0700486 void
487 AddCCKextLibArgs(const llvm::opt::ArgList &Args,
488 llvm::opt::ArgStringList &CmdArgs) const override;
Shantonu Sen7433fed2010-09-17 18:39:08 +0000489
Stephen Hines176edba2014-12-01 14:53:08 -0800490 virtual void addClangWarningOptions(llvm::opt::ArgStringList &CC1Args)
491 const override;
Stephen Hines651f13c2014-04-23 16:59:28 -0700492
493 void
494 AddLinkARCArgs(const llvm::opt::ArgList &Args,
495 llvm::opt::ArgStringList &CmdArgs) const override;
Daniel Dunbar1d4612b2009-09-18 08:15:13 +0000496 /// }
497};
498
Rafael Espindolae43cfa12010-10-29 20:14:02 +0000499class LLVM_LIBRARY_VISIBILITY Generic_ELF : public Generic_GCC {
David Blaikie99ba9e32011-12-20 02:48:34 +0000500 virtual void anchor();
501public:
Reid Klecknerdd0b3c42013-06-17 13:59:19 +0000502 Generic_ELF(const Driver &D, const llvm::Triple &Triple,
503 const llvm::opt::ArgList &Args)
504 : Generic_GCC(D, Triple, Args) {}
Rafael Espindolae43cfa12010-10-29 20:14:02 +0000505
Stephen Hines651f13c2014-04-23 16:59:28 -0700506 void addClangTargetOptions(const llvm::opt::ArgList &DriverArgs,
507 llvm::opt::ArgStringList &CC1Args) const override;
Rafael Espindolae43cfa12010-10-29 20:14:02 +0000508};
509
David Chisnall31c46902012-02-15 13:39:01 +0000510class LLVM_LIBRARY_VISIBILITY Solaris : public Generic_GCC {
511public:
Reid Klecknerdd0b3c42013-06-17 13:59:19 +0000512 Solaris(const Driver &D, const llvm::Triple &Triple,
513 const llvm::opt::ArgList &Args);
David Chisnall31c46902012-02-15 13:39:01 +0000514
Stephen Hines651f13c2014-04-23 16:59:28 -0700515 bool IsIntegratedAssemblerDefault() const override { return true; }
Rafael Espindolaf48b93c2013-03-20 03:05:54 +0000516protected:
Stephen Hines651f13c2014-04-23 16:59:28 -0700517 Tool *buildAssembler() const override;
518 Tool *buildLinker() const override;
Rafael Espindolaf48b93c2013-03-20 03:05:54 +0000519
David Chisnall31c46902012-02-15 13:39:01 +0000520};
521
522
Rafael Espindolae43cfa12010-10-29 20:14:02 +0000523class LLVM_LIBRARY_VISIBILITY OpenBSD : public Generic_ELF {
Daniel Dunbarf7b8eec2009-06-29 20:52:51 +0000524public:
Reid Klecknerdd0b3c42013-06-17 13:59:19 +0000525 OpenBSD(const Driver &D, const llvm::Triple &Triple,
526 const llvm::opt::ArgList &Args);
Daniel Dunbarf7b8eec2009-06-29 20:52:51 +0000527
Stephen Hines651f13c2014-04-23 16:59:28 -0700528 bool IsMathErrnoDefault() const override { return false; }
529 bool IsObjCNonFragileABIDefault() const override { return true; }
530 bool isPIEDefault() const override { return true; }
Rafael Espindola9adba392013-06-05 04:28:55 +0000531
Stephen Hines651f13c2014-04-23 16:59:28 -0700532 unsigned GetDefaultStackProtectorLevel(bool KernelOrKext) const override {
Stephen Hines6bcf27b2014-05-29 04:14:42 -0700533 return 2;
Rafael Espindola9adba392013-06-05 04:28:55 +0000534 }
David Chisnallc3cb0722012-04-09 12:33:41 +0000535
Rafael Espindolaf48b93c2013-03-20 03:05:54 +0000536protected:
Stephen Hines651f13c2014-04-23 16:59:28 -0700537 Tool *buildAssembler() const override;
538 Tool *buildLinker() const override;
Daniel Dunbarf7b8eec2009-06-29 20:52:51 +0000539};
540
Eli Friedman42f74f22012-08-08 23:57:20 +0000541class LLVM_LIBRARY_VISIBILITY Bitrig : public Generic_ELF {
542public:
Reid Klecknerdd0b3c42013-06-17 13:59:19 +0000543 Bitrig(const Driver &D, const llvm::Triple &Triple,
544 const llvm::opt::ArgList &Args);
Eli Friedman42f74f22012-08-08 23:57:20 +0000545
Stephen Hines651f13c2014-04-23 16:59:28 -0700546 bool IsMathErrnoDefault() const override { return false; }
547 bool IsObjCNonFragileABIDefault() const override { return true; }
Eli Friedman42f74f22012-08-08 23:57:20 +0000548
Stephen Hines6bcf27b2014-05-29 04:14:42 -0700549 CXXStdlibType GetCXXStdlibType(const llvm::opt::ArgList &Args) const override;
Stephen Hines651f13c2014-04-23 16:59:28 -0700550 void
Reid Klecknerdd0b3c42013-06-17 13:59:19 +0000551 AddClangCXXStdlibIncludeArgs(const llvm::opt::ArgList &DriverArgs,
Stephen Hines651f13c2014-04-23 16:59:28 -0700552 llvm::opt::ArgStringList &CC1Args) const override;
553 void AddCXXStdlibLibArgs(const llvm::opt::ArgList &Args,
554 llvm::opt::ArgStringList &CmdArgs) const override;
555 unsigned GetDefaultStackProtectorLevel(bool KernelOrKext) const override {
Eli Friedman42f74f22012-08-08 23:57:20 +0000556 return 1;
557 }
Rafael Espindolaf48b93c2013-03-20 03:05:54 +0000558
559protected:
Stephen Hines651f13c2014-04-23 16:59:28 -0700560 Tool *buildAssembler() const override;
561 Tool *buildLinker() const override;
Eli Friedman42f74f22012-08-08 23:57:20 +0000562};
563
Rafael Espindolae43cfa12010-10-29 20:14:02 +0000564class LLVM_LIBRARY_VISIBILITY FreeBSD : public Generic_ELF {
Daniel Dunbar75358d22009-03-30 21:06:03 +0000565public:
Reid Klecknerdd0b3c42013-06-17 13:59:19 +0000566 FreeBSD(const Driver &D, const llvm::Triple &Triple,
567 const llvm::opt::ArgList &Args);
Stephen Hines651f13c2014-04-23 16:59:28 -0700568 bool HasNativeLLVMSupport() const override;
Daniel Dunbar75358d22009-03-30 21:06:03 +0000569
Stephen Hines651f13c2014-04-23 16:59:28 -0700570 bool IsMathErrnoDefault() const override { return false; }
571 bool IsObjCNonFragileABIDefault() const override { return true; }
David Chisnallc3cb0722012-04-09 12:33:41 +0000572
Stephen Hines651f13c2014-04-23 16:59:28 -0700573 CXXStdlibType GetCXXStdlibType(const llvm::opt::ArgList &Args) const override;
574 void
David Chisnall1cc766f2013-11-09 15:10:56 +0000575 AddClangCXXStdlibIncludeArgs(const llvm::opt::ArgList &DriverArgs,
Stephen Hines651f13c2014-04-23 16:59:28 -0700576 llvm::opt::ArgStringList &CC1Args) const override;
David Chisnall1cc766f2013-11-09 15:10:56 +0000577
Stephen Hines651f13c2014-04-23 16:59:28 -0700578 bool UseSjLjExceptions() const override;
579 bool isPIEDefault() const override;
Rafael Espindolaf48b93c2013-03-20 03:05:54 +0000580protected:
Stephen Hines651f13c2014-04-23 16:59:28 -0700581 Tool *buildAssembler() const override;
582 Tool *buildLinker() const override;
Daniel Dunbar75358d22009-03-30 21:06:03 +0000583};
584
Benjamin Kramer8e50a962011-02-02 18:59:27 +0000585class LLVM_LIBRARY_VISIBILITY NetBSD : public Generic_ELF {
586public:
Reid Klecknerdd0b3c42013-06-17 13:59:19 +0000587 NetBSD(const Driver &D, const llvm::Triple &Triple,
588 const llvm::opt::ArgList &Args);
Benjamin Kramer8e50a962011-02-02 18:59:27 +0000589
Stephen Hines651f13c2014-04-23 16:59:28 -0700590 bool IsMathErrnoDefault() const override { return false; }
591 bool IsObjCNonFragileABIDefault() const override { return true; }
David Chisnallc3cb0722012-04-09 12:33:41 +0000592
Stephen Hines651f13c2014-04-23 16:59:28 -0700593 CXXStdlibType GetCXXStdlibType(const llvm::opt::ArgList &Args) const override;
Joerg Sonnenbergera7efaf92013-04-30 01:21:43 +0000594
Stephen Hines651f13c2014-04-23 16:59:28 -0700595 void
Reid Klecknerdd0b3c42013-06-17 13:59:19 +0000596 AddClangCXXStdlibIncludeArgs(const llvm::opt::ArgList &DriverArgs,
Stephen Hines651f13c2014-04-23 16:59:28 -0700597 llvm::opt::ArgStringList &CC1Args) const override;
598 bool IsUnwindTablesDefault() const override {
Joerg Sonnenbergerba7fd422013-08-15 15:08:33 +0000599 return true;
600 }
Joerg Sonnenbergera7efaf92013-04-30 01:21:43 +0000601
Rafael Espindolaf48b93c2013-03-20 03:05:54 +0000602protected:
Stephen Hines651f13c2014-04-23 16:59:28 -0700603 Tool *buildAssembler() const override;
604 Tool *buildLinker() const override;
Benjamin Kramer8e50a962011-02-02 18:59:27 +0000605};
606
Eli Friedman6d402dc2011-12-08 23:54:21 +0000607class LLVM_LIBRARY_VISIBILITY Minix : public Generic_ELF {
Chris Lattner38e317d2010-07-07 16:01:42 +0000608public:
Reid Klecknerdd0b3c42013-06-17 13:59:19 +0000609 Minix(const Driver &D, const llvm::Triple &Triple,
610 const llvm::opt::ArgList &Args);
Chris Lattner38e317d2010-07-07 16:01:42 +0000611
Rafael Espindolaf48b93c2013-03-20 03:05:54 +0000612protected:
Stephen Hines651f13c2014-04-23 16:59:28 -0700613 Tool *buildAssembler() const override;
614 Tool *buildLinker() const override;
Chris Lattner38e317d2010-07-07 16:01:42 +0000615};
616
Rafael Espindolae43cfa12010-10-29 20:14:02 +0000617class LLVM_LIBRARY_VISIBILITY DragonFly : public Generic_ELF {
Daniel Dunbar11e1b402009-05-02 18:28:39 +0000618public:
Reid Klecknerdd0b3c42013-06-17 13:59:19 +0000619 DragonFly(const Driver &D, const llvm::Triple &Triple,
620 const llvm::opt::ArgList &Args);
Daniel Dunbar11e1b402009-05-02 18:28:39 +0000621
Stephen Hines651f13c2014-04-23 16:59:28 -0700622 bool IsMathErrnoDefault() const override { return false; }
Benjamin Kramer769aa2d2012-05-02 14:55:48 +0000623
Rafael Espindolaf48b93c2013-03-20 03:05:54 +0000624protected:
Stephen Hines651f13c2014-04-23 16:59:28 -0700625 Tool *buildAssembler() const override;
626 Tool *buildLinker() const override;
Daniel Dunbar11e1b402009-05-02 18:28:39 +0000627};
628
Rafael Espindolae43cfa12010-10-29 20:14:02 +0000629class LLVM_LIBRARY_VISIBILITY Linux : public Generic_ELF {
Eli Friedman6b3454a2009-05-26 07:52:18 +0000630public:
Reid Klecknerdd0b3c42013-06-17 13:59:19 +0000631 Linux(const Driver &D, const llvm::Triple &Triple,
632 const llvm::opt::ArgList &Args);
Rafael Espindolaba30bbe2010-08-10 00:25:48 +0000633
Stephen Hines651f13c2014-04-23 16:59:28 -0700634 bool HasNativeLLVMSupport() const override;
Rafael Espindolac1da9812010-11-07 20:14:31 +0000635
Stephen Hines651f13c2014-04-23 16:59:28 -0700636 void
Reid Klecknerdd0b3c42013-06-17 13:59:19 +0000637 AddClangSystemIncludeArgs(const llvm::opt::ArgList &DriverArgs,
Stephen Hines651f13c2014-04-23 16:59:28 -0700638 llvm::opt::ArgStringList &CC1Args) const override;
639 void
Reid Klecknerdd0b3c42013-06-17 13:59:19 +0000640 AddClangCXXStdlibIncludeArgs(const llvm::opt::ArgList &DriverArgs,
Stephen Hines651f13c2014-04-23 16:59:28 -0700641 llvm::opt::ArgStringList &CC1Args) const override;
642 bool isPIEDefault() const override;
Chandler Carruth7d7e9f92011-11-05 20:17:13 +0000643
Rafael Espindolac1da9812010-11-07 20:14:31 +0000644 std::string Linker;
645 std::vector<std::string> ExtraOpts;
Chandler Carruth79cbbdc2011-12-17 23:10:01 +0000646
Rafael Espindolaf48b93c2013-03-20 03:05:54 +0000647protected:
Stephen Hines651f13c2014-04-23 16:59:28 -0700648 Tool *buildAssembler() const override;
649 Tool *buildLinker() const override;
Rafael Espindolaf48b93c2013-03-20 03:05:54 +0000650
Chandler Carruth79cbbdc2011-12-17 23:10:01 +0000651private:
Dmitri Gribenkof2e7c352013-03-06 17:14:05 +0000652 static bool addLibStdCXXIncludePaths(Twine Base, Twine Suffix,
Stephen Hines176edba2014-12-01 14:53:08 -0800653 StringRef GCCTriple,
654 StringRef GCCMultiarchTriple,
655 StringRef TargetMultiarchTriple,
656 Twine IncludeSuffix,
Reid Klecknerdd0b3c42013-06-17 13:59:19 +0000657 const llvm::opt::ArgList &DriverArgs,
658 llvm::opt::ArgStringList &CC1Args);
Simon Atanasyan8e8e95c2013-04-20 08:15:03 +0000659
Simon Atanasyanab5df752013-10-05 14:37:55 +0000660 std::string computeSysRoot() const;
Eli Friedman6b3454a2009-05-26 07:52:18 +0000661};
662
Matthew Curtisb3489a02012-12-06 12:43:18 +0000663class LLVM_LIBRARY_VISIBILITY Hexagon_TC : public Linux {
664protected:
Matthew Curtisb3489a02012-12-06 12:43:18 +0000665 GCCVersion GCCLibAndIncVersion;
Stephen Hines651f13c2014-04-23 16:59:28 -0700666 Tool *buildAssembler() const override;
667 Tool *buildLinker() const override;
Matthew Curtisb3489a02012-12-06 12:43:18 +0000668
669public:
670 Hexagon_TC(const Driver &D, const llvm::Triple &Triple,
Reid Klecknerdd0b3c42013-06-17 13:59:19 +0000671 const llvm::opt::ArgList &Args);
Matthew Curtisb3489a02012-12-06 12:43:18 +0000672 ~Hexagon_TC();
673
Stephen Hines651f13c2014-04-23 16:59:28 -0700674 void
Reid Klecknerdd0b3c42013-06-17 13:59:19 +0000675 AddClangSystemIncludeArgs(const llvm::opt::ArgList &DriverArgs,
Stephen Hines651f13c2014-04-23 16:59:28 -0700676 llvm::opt::ArgStringList &CC1Args) const override;
677 void
Reid Klecknerdd0b3c42013-06-17 13:59:19 +0000678 AddClangCXXStdlibIncludeArgs(const llvm::opt::ArgList &DriverArgs,
Stephen Hines651f13c2014-04-23 16:59:28 -0700679 llvm::opt::ArgStringList &CC1Args) const override;
680 CXXStdlibType GetCXXStdlibType(const llvm::opt::ArgList &Args) const override;
Matthew Curtisb3489a02012-12-06 12:43:18 +0000681
682 StringRef GetGCCLibAndIncVersion() const { return GCCLibAndIncVersion.Text; }
683
Stephen Hines176edba2014-12-01 14:53:08 -0800684 static std::string GetGnuDir(const std::string &InstalledDir,
685 const llvm::opt::ArgList &Args);
Matthew Curtis67814152012-12-06 14:16:43 +0000686
Reid Klecknerdd0b3c42013-06-17 13:59:19 +0000687 static StringRef GetTargetCPU(const llvm::opt::ArgList &Args);
Matthew Curtisb3489a02012-12-06 12:43:18 +0000688};
Eli Friedman6b3454a2009-05-26 07:52:18 +0000689
Chris Lattner3a47c4e2010-03-04 21:07:38 +0000690/// TCEToolChain - A tool chain using the llvm bitcode tools to perform
691/// all subcommands. See http://tce.cs.tut.fi for our peculiar target.
Duncan Sands92dd1912010-05-11 20:16:05 +0000692class LLVM_LIBRARY_VISIBILITY TCEToolChain : public ToolChain {
Chris Lattner3a47c4e2010-03-04 21:07:38 +0000693public:
Reid Klecknerdd0b3c42013-06-17 13:59:19 +0000694 TCEToolChain(const Driver &D, const llvm::Triple &Triple,
695 const llvm::opt::ArgList &Args);
Chris Lattner3a47c4e2010-03-04 21:07:38 +0000696 ~TCEToolChain();
697
Stephen Hines651f13c2014-04-23 16:59:28 -0700698 bool IsMathErrnoDefault() const override;
699 bool isPICDefault() const override;
700 bool isPIEDefault() const override;
701 bool isPICDefaultForced() const override;
Chris Lattner3a47c4e2010-03-04 21:07:38 +0000702};
703
Stephen Hines176edba2014-12-01 14:53:08 -0800704class LLVM_LIBRARY_VISIBILITY MSVCToolChain : public ToolChain {
Michael J. Spencerff58e362010-08-21 21:55:07 +0000705public:
Stephen Hines176edba2014-12-01 14:53:08 -0800706 MSVCToolChain(const Driver &D, const llvm::Triple &Triple,
707 const llvm::opt::ArgList &Args);
Michael J. Spencerff58e362010-08-21 21:55:07 +0000708
Stephen Hines651f13c2014-04-23 16:59:28 -0700709 bool IsIntegratedAssemblerDefault() const override;
710 bool IsUnwindTablesDefault() const override;
711 bool isPICDefault() const override;
712 bool isPIEDefault() const override;
713 bool isPICDefaultForced() const override;
Chandler Carruthca234192011-11-04 23:49:05 +0000714
Stephen Hines651f13c2014-04-23 16:59:28 -0700715 void
Reid Klecknerdd0b3c42013-06-17 13:59:19 +0000716 AddClangSystemIncludeArgs(const llvm::opt::ArgList &DriverArgs,
Stephen Hines651f13c2014-04-23 16:59:28 -0700717 llvm::opt::ArgStringList &CC1Args) const override;
718 void
Reid Klecknerdd0b3c42013-06-17 13:59:19 +0000719 AddClangCXXStdlibIncludeArgs(const llvm::opt::ArgList &DriverArgs,
Stephen Hines651f13c2014-04-23 16:59:28 -0700720 llvm::opt::ArgStringList &CC1Args) const override;
Reid Klecknerdd0b3c42013-06-17 13:59:19 +0000721
Stephen Hines176edba2014-12-01 14:53:08 -0800722 bool getWindowsSDKDir(std::string &path, int &major, int &minor) const;
723 bool getWindowsSDKLibraryPath(std::string &path) const;
724 bool getVisualStudioInstallDir(std::string &path) const;
725 bool getVisualStudioBinariesFolder(const char *clangProgramPath,
726 std::string &path) const;
727
Rafael Espindolaf48b93c2013-03-20 03:05:54 +0000728protected:
Stephen Hines176edba2014-12-01 14:53:08 -0800729 void AddSystemIncludeWithSubfolder(const llvm::opt::ArgList &DriverArgs,
730 llvm::opt::ArgStringList &CC1Args,
731 const std::string &folder,
732 const char *subfolder) const;
733
Stephen Hines651f13c2014-04-23 16:59:28 -0700734 Tool *buildLinker() const override;
735 Tool *buildAssembler() const override;
Michael J. Spencerff58e362010-08-21 21:55:07 +0000736};
737
Stephen Hines176edba2014-12-01 14:53:08 -0800738class LLVM_LIBRARY_VISIBILITY CrossWindowsToolChain : public Generic_GCC {
739public:
740 CrossWindowsToolChain(const Driver &D, const llvm::Triple &T,
741 const llvm::opt::ArgList &Args);
742
743 bool IsIntegratedAssemblerDefault() const override { return true; }
744 bool IsUnwindTablesDefault() const override;
745 bool isPICDefault() const override;
746 bool isPIEDefault() const override;
747 bool isPICDefaultForced() const override;
748
749 unsigned int GetDefaultStackProtectorLevel(bool KernelOrKext) const override {
750 return 0;
751 }
752
753 void AddClangSystemIncludeArgs(const llvm::opt::ArgList &DriverArgs,
754 llvm::opt::ArgStringList &CC1Args)
755 const override;
756 void AddClangCXXStdlibIncludeArgs(const llvm::opt::ArgList &DriverArgs,
757 llvm::opt::ArgStringList &CC1Args)
758 const override;
759 void AddCXXStdlibLibArgs(const llvm::opt::ArgList &Args,
760 llvm::opt::ArgStringList &CmdArgs) const override;
761
762protected:
763 Tool *buildLinker() const override;
764 Tool *buildAssembler() const override;
765};
Robert Lytton4e490e22013-10-11 10:29:40 +0000766
767class LLVM_LIBRARY_VISIBILITY XCore : public ToolChain {
768public:
769 XCore(const Driver &D, const llvm::Triple &Triple,
770 const llvm::opt::ArgList &Args);
771protected:
Stephen Hines651f13c2014-04-23 16:59:28 -0700772 Tool *buildAssembler() const override;
773 Tool *buildLinker() const override;
Robert Lytton4e490e22013-10-11 10:29:40 +0000774public:
Stephen Hines651f13c2014-04-23 16:59:28 -0700775 bool isPICDefault() const override;
776 bool isPIEDefault() const override;
777 bool isPICDefaultForced() const override;
778 bool SupportsProfiling() const override;
779 bool hasBlocksRuntime() const override;
780 void AddClangSystemIncludeArgs(const llvm::opt::ArgList &DriverArgs,
781 llvm::opt::ArgStringList &CC1Args) const override;
782 void addClangTargetOptions(const llvm::opt::ArgList &DriverArgs,
783 llvm::opt::ArgStringList &CC1Args) const override;
784 void AddClangCXXStdlibIncludeArgs(const llvm::opt::ArgList &DriverArgs,
785 llvm::opt::ArgStringList &CC1Args) const override;
786 void AddCXXStdlibLibArgs(const llvm::opt::ArgList &Args,
787 llvm::opt::ArgStringList &CmdArgs) const override;
Robert Lytton4e490e22013-10-11 10:29:40 +0000788};
789
Daniel Dunbar83b08eb2009-03-17 21:38:00 +0000790} // end namespace toolchains
791} // end namespace driver
792} // end namespace clang
793
794#endif