1 //===--- ToolChain.h - Collections of tools for one platform ----*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 #ifndef CLANG_DRIVER_TOOLCHAIN_H_
11 #define CLANG_DRIVER_TOOLCHAIN_H_
13 #include "clang/Driver/Util.h"
14 #include "clang/Driver/Types.h"
15 #include "llvm/ADT/SmallVector.h"
16 #include "llvm/ADT/Triple.h"
17 #include "llvm/Support/Path.h"
32 /// ToolChain - Access to tools for a single platform.
35 typedef llvm::SmallVector<std::string, 4> path_list;
44 const llvm::Triple Triple;
46 /// The list of toolchain specific path prefixes to search for
50 /// The list of toolchain specific path prefixes to search for
52 path_list ProgramPaths;
55 ToolChain(const HostInfo &Host, const llvm::Triple &_Triple);
62 const Driver &getDriver() const;
63 const llvm::Triple &getTriple() const { return Triple; }
65 llvm::Triple::ArchType getArch() const { return Triple.getArch(); }
66 llvm::StringRef getArchName() const { return Triple.getArchName(); }
67 llvm::StringRef getPlatform() const { return Triple.getVendorName(); }
68 llvm::StringRef getOS() const { return Triple.getOSName(); }
70 std::string getTripleString() const {
71 return Triple.getTriple();
74 path_list &getFilePaths() { return FilePaths; }
75 const path_list &getFilePaths() const { return FilePaths; }
77 path_list &getProgramPaths() { return ProgramPaths; }
78 const path_list &getProgramPaths() const { return ProgramPaths; }
82 /// TranslateArgs - Create a new derived argument list for any argument
83 /// translations this ToolChain may wish to perform, or 0 if no tool chain
84 /// specific translations are needed.
86 /// \param BoundArch - The bound architecture name, or 0.
87 virtual DerivedArgList *TranslateArgs(const DerivedArgList &Args,
88 const char *BoundArch) const {
92 /// SelectTool - Choose a tool to use to handle the action \arg JA with the
93 /// given \arg Inputs.
94 virtual Tool &SelectTool(const Compilation &C, const JobAction &JA,
95 const ActionList &Inputs) const = 0;
99 std::string GetFilePath(const char *Name) const;
100 std::string GetProgramPath(const char *Name, bool WantFile = false) const;
102 // Platform defaults information
104 /// HasNativeLTOLinker - Check whether the linker and related tools have
105 /// native LLVM support.
106 virtual bool HasNativeLLVMSupport() const;
108 /// LookupTypeForExtension - Return the default language type to use for the
110 virtual types::ID LookupTypeForExtension(const char *Ext) const;
112 /// IsBlocksDefault - Does this tool chain enable -fblocks by default.
113 virtual bool IsBlocksDefault() const { return false; }
115 /// IsIntegratedAssemblerDefault - Does this tool chain enable -integrated-as
117 virtual bool IsIntegratedAssemblerDefault() const { return false; }
119 /// IsStrictAliasingDefault - Does this tool chain use -fstrict-aliasing by
121 virtual bool IsStrictAliasingDefault() const { return true; }
123 /// IsObjCDefaultSynthPropertiesDefault - Does this tool chain enable
124 /// -fobjc-default-synthesize-properties by default.
125 virtual bool IsObjCDefaultSynthPropertiesDefault() const { return false; }
127 /// IsObjCNonFragileABIDefault - Does this tool chain set
128 /// -fobjc-nonfragile-abi by default.
129 virtual bool IsObjCNonFragileABIDefault() const { return false; }
131 /// IsObjCLegacyDispatchDefault - Does this tool chain set
132 /// -fobjc-legacy-dispatch by default (this is only used with the non-fragile
134 virtual bool IsObjCLegacyDispatchDefault() const { return false; }
136 /// UseObjCMixedDispatchDefault - When using non-legacy dispatch, should the
137 /// mixed dispatch method be used?
138 virtual bool UseObjCMixedDispatch() const { return false; }
140 /// GetDefaultStackProtectorLevel - Get the default stack protector level for
141 /// this tool chain (0=off, 1=on, 2=all).
142 virtual unsigned GetDefaultStackProtectorLevel() const { return 0; }
144 /// IsUnwindTablesDefault - Does this tool chain use -funwind-tables
146 virtual bool IsUnwindTablesDefault() const = 0;
148 /// GetDefaultRelocationModel - Return the LLVM name of the default
149 /// relocation model for this tool chain.
150 virtual const char *GetDefaultRelocationModel() const = 0;
152 /// GetForcedPicModel - Return the LLVM name of the forced PIC model
153 /// for this tool chain, or 0 if this tool chain does not force a
154 /// particular PIC mode.
155 virtual const char *GetForcedPicModel() const = 0;
157 /// SupportsProfiling - Does this tool chain support -pg.
158 virtual bool SupportsProfiling() const { return true; }
160 /// Does this tool chain support Objective-C garbage collection.
161 virtual bool SupportsObjCGC() const { return true; }
163 /// UseDwarfDebugFlags - Embed the compile options to clang into the Dwarf
164 /// compile unit information.
165 virtual bool UseDwarfDebugFlags() const { return false; }
167 /// UseSjLjExceptions - Does this tool chain use SjLj exceptions.
168 virtual bool UseSjLjExceptions() const { return false; }
170 /// ComputeLLVMTriple - Return the LLVM target triple to use, after taking
171 /// command line arguments into account.
172 virtual std::string ComputeLLVMTriple(const ArgList &Args) const;
174 /// ComputeEffectiveClangTriple - Return the Clang triple to use for this
175 /// target, which may take into account the command line arguments. For
176 /// example, on Darwin the -mmacosx-version-min= command line argument (which
177 /// sets the deployment target) determines the version in the triple passed to
179 virtual std::string ComputeEffectiveClangTriple(const ArgList &Args) const;
181 /// configureObjCRuntime - Configure the known properties of the
182 /// Objective-C runtime for this platform.
184 /// FIXME: this doesn't really belong here.
185 virtual void configureObjCRuntime(ObjCRuntime &runtime) const;
187 // GetCXXStdlibType - Determine the C++ standard library type to use with the
188 // given compilation arguments.
189 virtual CXXStdlibType GetCXXStdlibType(const ArgList &Args) const;
191 /// AddClangCXXStdlibIncludeArgs - Add the clang -cc1 level arguments to set
192 /// the include paths to use for the given C++ standard library type.
193 virtual void AddClangCXXStdlibIncludeArgs(const ArgList &Args,
194 ArgStringList &CmdArgs,
195 bool ObjCXXAutoRefCount) const;
197 /// AddCXXStdlibLibArgs - Add the system specific linker arguments to use
198 /// for the given C++ standard library type.
199 virtual void AddCXXStdlibLibArgs(const ArgList &Args,
200 ArgStringList &CmdArgs) const;
202 /// AddCCKextLibArgs - Add the system specific linker arguments to use
203 /// for kernel extensions (Darwin-specific).
204 virtual void AddCCKextLibArgs(const ArgList &Args,
205 ArgStringList &CmdArgs) const;
208 } // end namespace driver
209 } // end namespace clang