Daniel Dunbar | 2ba38ba | 2009-03-16 05:25:36 +0000 | [diff] [blame] | 1 | //===--- ToolChain.h - Collections of tools for one platform ----*- 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 Hines | 176edba | 2014-12-01 14:53:08 -0800 | [diff] [blame] | 10 | #ifndef LLVM_CLANG_DRIVER_TOOLCHAIN_H |
| 11 | #define LLVM_CLANG_DRIVER_TOOLCHAIN_H |
Daniel Dunbar | 2ba38ba | 2009-03-16 05:25:36 +0000 | [diff] [blame] | 12 | |
Rafael Espindola | 5b22205 | 2013-03-18 20:48:54 +0000 | [diff] [blame] | 13 | #include "clang/Driver/Action.h" |
Stephen Hines | 651f13c | 2014-04-23 16:59:28 -0700 | [diff] [blame] | 14 | #include "clang/Driver/Multilib.h" |
Daniel Dunbar | 4180011 | 2010-08-02 05:43:56 +0000 | [diff] [blame] | 15 | #include "clang/Driver/Types.h" |
Chandler Carruth | 30a2e16 | 2012-12-04 09:18:49 +0000 | [diff] [blame] | 16 | #include "clang/Driver/Util.h" |
Daniel Dunbar | 0edefeb | 2009-03-18 20:26:19 +0000 | [diff] [blame] | 17 | #include "llvm/ADT/SmallVector.h" |
Daniel Dunbar | cb8ab23 | 2009-05-22 02:53:45 +0000 | [diff] [blame] | 18 | #include "llvm/ADT/Triple.h" |
Michael J. Spencer | 03013fa | 2010-11-29 18:12:39 +0000 | [diff] [blame] | 19 | #include "llvm/Support/Path.h" |
Stephen Hines | 651f13c | 2014-04-23 16:59:28 -0700 | [diff] [blame] | 20 | #include <memory> |
Daniel Dunbar | 2ba38ba | 2009-03-16 05:25:36 +0000 | [diff] [blame] | 21 | #include <string> |
| 22 | |
Reid Kleckner | b1e25a1 | 2013-06-14 17:17:23 +0000 | [diff] [blame] | 23 | namespace llvm { |
| 24 | namespace opt { |
| 25 | class ArgList; |
| 26 | class DerivedArgList; |
| 27 | class InputArgList; |
| 28 | } |
| 29 | } |
| 30 | |
Daniel Dunbar | 2ba38ba | 2009-03-16 05:25:36 +0000 | [diff] [blame] | 31 | namespace clang { |
John McCall | 260611a | 2012-06-20 06:18:46 +0000 | [diff] [blame] | 32 | class ObjCRuntime; |
| 33 | |
Daniel Dunbar | 2ba38ba | 2009-03-16 05:25:36 +0000 | [diff] [blame] | 34 | namespace driver { |
Daniel Dunbar | 2ba38ba | 2009-03-16 05:25:36 +0000 | [diff] [blame] | 35 | class Compilation; |
Daniel Dunbar | ee788e7 | 2009-12-21 18:54:17 +0000 | [diff] [blame] | 36 | class Driver; |
Daniel Dunbar | 2ba38ba | 2009-03-16 05:25:36 +0000 | [diff] [blame] | 37 | class JobAction; |
Alexey Samsonov | 1b8f12d | 2013-08-19 09:14:21 +0000 | [diff] [blame] | 38 | class SanitizerArgs; |
Daniel Dunbar | 2ba38ba | 2009-03-16 05:25:36 +0000 | [diff] [blame] | 39 | class Tool; |
| 40 | |
| 41 | /// ToolChain - Access to tools for a single platform. |
| 42 | class ToolChain { |
Daniel Dunbar | 0edefeb | 2009-03-18 20:26:19 +0000 | [diff] [blame] | 43 | public: |
Stephen Hines | 176edba | 2014-12-01 14:53:08 -0800 | [diff] [blame] | 44 | typedef SmallVector<std::string, 16> path_list; |
Daniel Dunbar | 0edefeb | 2009-03-18 20:26:19 +0000 | [diff] [blame] | 45 | |
Daniel Dunbar | 641b98b | 2010-09-14 23:12:35 +0000 | [diff] [blame] | 46 | enum CXXStdlibType { |
Daniel Dunbar | 3f16c95 | 2010-09-14 23:12:40 +0000 | [diff] [blame] | 47 | CST_Libcxx, |
Daniel Dunbar | 641b98b | 2010-09-14 23:12:35 +0000 | [diff] [blame] | 48 | CST_Libstdcxx |
| 49 | }; |
| 50 | |
Daniel Dunbar | c24767c | 2011-12-07 23:03:15 +0000 | [diff] [blame] | 51 | enum RuntimeLibType { |
| 52 | RLT_CompilerRT, |
| 53 | RLT_Libgcc |
| 54 | }; |
| 55 | |
Stephen Hines | 0e2c34f | 2015-03-23 12:09:02 -0700 | [diff] [blame] | 56 | enum RTTIMode { |
| 57 | RM_EnabledExplicitly, |
| 58 | RM_EnabledImplicitly, |
| 59 | RM_DisabledExplicitly, |
| 60 | RM_DisabledImplicitly |
| 61 | }; |
| 62 | |
Daniel Dunbar | 0edefeb | 2009-03-18 20:26:19 +0000 | [diff] [blame] | 63 | private: |
Chandler Carruth | 4d7ff6e | 2012-01-25 09:12:06 +0000 | [diff] [blame] | 64 | const Driver &D; |
Daniel Dunbar | cb8ab23 | 2009-05-22 02:53:45 +0000 | [diff] [blame] | 65 | const llvm::Triple Triple; |
Reid Kleckner | dd0b3c4 | 2013-06-17 13:59:19 +0000 | [diff] [blame] | 66 | const llvm::opt::ArgList &Args; |
Stephen Hines | 0e2c34f | 2015-03-23 12:09:02 -0700 | [diff] [blame] | 67 | // We need to initialize CachedRTTIArg before CachedRTTIMode |
| 68 | const llvm::opt::Arg *const CachedRTTIArg; |
| 69 | const RTTIMode CachedRTTIMode; |
Daniel Dunbar | 2ba38ba | 2009-03-16 05:25:36 +0000 | [diff] [blame] | 70 | |
Daniel Dunbar | 0edefeb | 2009-03-18 20:26:19 +0000 | [diff] [blame] | 71 | /// The list of toolchain specific path prefixes to search for |
| 72 | /// files. |
| 73 | path_list FilePaths; |
| 74 | |
| 75 | /// The list of toolchain specific path prefixes to search for |
| 76 | /// programs. |
| 77 | path_list ProgramPaths; |
| 78 | |
Stephen Hines | 651f13c | 2014-04-23 16:59:28 -0700 | [diff] [blame] | 79 | mutable std::unique_ptr<Tool> Clang; |
| 80 | mutable std::unique_ptr<Tool> Assemble; |
| 81 | mutable std::unique_ptr<Tool> Link; |
Rafael Espindola | f48b93c | 2013-03-20 03:05:54 +0000 | [diff] [blame] | 82 | Tool *getClang() const; |
| 83 | Tool *getAssemble() const; |
| 84 | Tool *getLink() const; |
| 85 | Tool *getClangAs() const; |
Rafael Espindola | 5b22205 | 2013-03-18 20:48:54 +0000 | [diff] [blame] | 86 | |
Stephen Hines | 651f13c | 2014-04-23 16:59:28 -0700 | [diff] [blame] | 87 | mutable std::unique_ptr<SanitizerArgs> SanitizerArguments; |
Peter Collingbourne | c6911a2 | 2013-11-01 18:16:25 +0000 | [diff] [blame] | 88 | |
Daniel Dunbar | 2ba38ba | 2009-03-16 05:25:36 +0000 | [diff] [blame] | 89 | protected: |
Stephen Hines | 651f13c | 2014-04-23 16:59:28 -0700 | [diff] [blame] | 90 | MultilibSet Multilibs; |
| 91 | |
Reid Kleckner | dd0b3c4 | 2013-06-17 13:59:19 +0000 | [diff] [blame] | 92 | ToolChain(const Driver &D, const llvm::Triple &T, |
| 93 | const llvm::opt::ArgList &Args); |
Daniel Dunbar | 2ba38ba | 2009-03-16 05:25:36 +0000 | [diff] [blame] | 94 | |
Rafael Espindola | f48b93c | 2013-03-20 03:05:54 +0000 | [diff] [blame] | 95 | virtual Tool *buildAssembler() const; |
| 96 | virtual Tool *buildLinker() const; |
| 97 | virtual Tool *getTool(Action::ActionClass AC) const; |
Rafael Espindola | 5b22205 | 2013-03-18 20:48:54 +0000 | [diff] [blame] | 98 | |
Chandler Carruth | 79cbbdc | 2011-12-17 23:10:01 +0000 | [diff] [blame] | 99 | /// \name Utilities for implementing subclasses. |
| 100 | ///@{ |
Reid Kleckner | dd0b3c4 | 2013-06-17 13:59:19 +0000 | [diff] [blame] | 101 | static void addSystemInclude(const llvm::opt::ArgList &DriverArgs, |
| 102 | llvm::opt::ArgStringList &CC1Args, |
Chandler Carruth | 79cbbdc | 2011-12-17 23:10:01 +0000 | [diff] [blame] | 103 | const Twine &Path); |
Reid Kleckner | dd0b3c4 | 2013-06-17 13:59:19 +0000 | [diff] [blame] | 104 | static void addExternCSystemInclude(const llvm::opt::ArgList &DriverArgs, |
| 105 | llvm::opt::ArgStringList &CC1Args, |
Chandler Carruth | 79cbbdc | 2011-12-17 23:10:01 +0000 | [diff] [blame] | 106 | const Twine &Path); |
Reid Kleckner | dd0b3c4 | 2013-06-17 13:59:19 +0000 | [diff] [blame] | 107 | static void |
| 108 | addExternCSystemIncludeIfExists(const llvm::opt::ArgList &DriverArgs, |
| 109 | llvm::opt::ArgStringList &CC1Args, |
| 110 | const Twine &Path); |
| 111 | static void addSystemIncludes(const llvm::opt::ArgList &DriverArgs, |
| 112 | llvm::opt::ArgStringList &CC1Args, |
Chandler Carruth | 79cbbdc | 2011-12-17 23:10:01 +0000 | [diff] [blame] | 113 | ArrayRef<StringRef> Paths); |
| 114 | ///@} |
| 115 | |
Daniel Dunbar | 2ba38ba | 2009-03-16 05:25:36 +0000 | [diff] [blame] | 116 | public: |
| 117 | virtual ~ToolChain(); |
| 118 | |
| 119 | // Accessors |
| 120 | |
Daniel Dunbar | ee788e7 | 2009-12-21 18:54:17 +0000 | [diff] [blame] | 121 | const Driver &getDriver() const; |
Daniel Dunbar | 12cfe03 | 2009-06-16 23:25:22 +0000 | [diff] [blame] | 122 | const llvm::Triple &getTriple() const { return Triple; } |
| 123 | |
Rafael Espindola | ba30bbe | 2010-08-10 00:25:48 +0000 | [diff] [blame] | 124 | llvm::Triple::ArchType getArch() const { return Triple.getArch(); } |
Chris Lattner | 686775d | 2011-07-20 06:58:45 +0000 | [diff] [blame] | 125 | StringRef getArchName() const { return Triple.getArchName(); } |
| 126 | StringRef getPlatform() const { return Triple.getVendorName(); } |
| 127 | StringRef getOS() const { return Triple.getOSName(); } |
Daniel Dunbar | 2ba38ba | 2009-03-16 05:25:36 +0000 | [diff] [blame] | 128 | |
Daniel Dunbar | d2a527e | 2012-11-08 03:38:26 +0000 | [diff] [blame] | 129 | /// \brief Provide the default architecture name (as expected by -arch) for |
| 130 | /// this toolchain. Note t |
Stephen Hines | 176edba | 2014-12-01 14:53:08 -0800 | [diff] [blame] | 131 | StringRef getDefaultUniversalArchName() const; |
Daniel Dunbar | d2a527e | 2012-11-08 03:38:26 +0000 | [diff] [blame] | 132 | |
Daniel Dunbar | cb8ab23 | 2009-05-22 02:53:45 +0000 | [diff] [blame] | 133 | std::string getTripleString() const { |
| 134 | return Triple.getTriple(); |
Daniel Dunbar | cd8e4c4 | 2009-03-30 06:36:42 +0000 | [diff] [blame] | 135 | } |
| 136 | |
Daniel Dunbar | bbafc5c | 2009-03-20 04:36:45 +0000 | [diff] [blame] | 137 | path_list &getFilePaths() { return FilePaths; } |
| 138 | const path_list &getFilePaths() const { return FilePaths; } |
Daniel Dunbar | 0edefeb | 2009-03-18 20:26:19 +0000 | [diff] [blame] | 139 | |
Daniel Dunbar | bbafc5c | 2009-03-20 04:36:45 +0000 | [diff] [blame] | 140 | path_list &getProgramPaths() { return ProgramPaths; } |
| 141 | const path_list &getProgramPaths() const { return ProgramPaths; } |
Daniel Dunbar | 0edefeb | 2009-03-18 20:26:19 +0000 | [diff] [blame] | 142 | |
Stephen Hines | 651f13c | 2014-04-23 16:59:28 -0700 | [diff] [blame] | 143 | const MultilibSet &getMultilibs() const { return Multilibs; } |
| 144 | |
Alexey Samsonov | 1b8f12d | 2013-08-19 09:14:21 +0000 | [diff] [blame] | 145 | const SanitizerArgs& getSanitizerArgs() const; |
| 146 | |
Stephen Hines | 0e2c34f | 2015-03-23 12:09:02 -0700 | [diff] [blame] | 147 | // Returns the Arg * that explicitly turned on/off rtti, or nullptr. |
| 148 | const llvm::opt::Arg *getRTTIArg() const { return CachedRTTIArg; } |
| 149 | |
| 150 | // Returns the RTTIMode for the toolchain with the current arguments. |
| 151 | RTTIMode getRTTIMode() const { return CachedRTTIMode; } |
| 152 | |
Daniel Dunbar | 2ba38ba | 2009-03-16 05:25:36 +0000 | [diff] [blame] | 153 | // Tool access. |
| 154 | |
Daniel Dunbar | 0dcb9a3 | 2009-09-09 18:36:12 +0000 | [diff] [blame] | 155 | /// TranslateArgs - Create a new derived argument list for any argument |
Daniel Dunbar | 279c1db | 2010-06-11 22:00:26 +0000 | [diff] [blame] | 156 | /// translations this ToolChain may wish to perform, or 0 if no tool chain |
| 157 | /// specific translations are needed. |
Daniel Dunbar | 0dcb9a3 | 2009-09-09 18:36:12 +0000 | [diff] [blame] | 158 | /// |
| 159 | /// \param BoundArch - The bound architecture name, or 0. |
Reid Kleckner | dd0b3c4 | 2013-06-17 13:59:19 +0000 | [diff] [blame] | 160 | virtual llvm::opt::DerivedArgList * |
| 161 | TranslateArgs(const llvm::opt::DerivedArgList &Args, |
| 162 | const char *BoundArch) const { |
Stephen Hines | 6bcf27b | 2014-05-29 04:14:42 -0700 | [diff] [blame] | 163 | return nullptr; |
Daniel Dunbar | 279c1db | 2010-06-11 22:00:26 +0000 | [diff] [blame] | 164 | } |
Daniel Dunbar | 2ba38ba | 2009-03-16 05:25:36 +0000 | [diff] [blame] | 165 | |
Rafael Espindola | 5b22205 | 2013-03-18 20:48:54 +0000 | [diff] [blame] | 166 | /// Choose a tool to use to handle the action \p JA. |
Rafael Espindola | 2951187 | 2013-03-24 15:06:53 +0000 | [diff] [blame] | 167 | Tool *SelectTool(const JobAction &JA) const; |
Daniel Dunbar | 2ba38ba | 2009-03-16 05:25:36 +0000 | [diff] [blame] | 168 | |
| 169 | // Helper methods |
| 170 | |
Daniel Dunbar | 4a7e889 | 2010-07-14 18:46:23 +0000 | [diff] [blame] | 171 | std::string GetFilePath(const char *Name) const; |
Simon Atanasyan | fc44e88 | 2012-10-03 19:52:37 +0000 | [diff] [blame] | 172 | std::string GetProgramPath(const char *Name) const; |
Daniel Dunbar | 2ba38ba | 2009-03-16 05:25:36 +0000 | [diff] [blame] | 173 | |
Stephen Hines | c568f1e | 2014-07-21 00:47:37 -0700 | [diff] [blame] | 174 | /// Returns the linker path, respecting the -fuse-ld= argument to determine |
| 175 | /// the linker suffix or name. |
| 176 | std::string GetLinkerPath() const; |
| 177 | |
Chandler Carruth | 6365ab9 | 2013-07-30 17:57:09 +0000 | [diff] [blame] | 178 | /// \brief Dispatch to the specific toolchain for verbose printing. |
| 179 | /// |
| 180 | /// This is used when handling the verbose option to print detailed, |
| 181 | /// toolchain-specific information useful for understanding the behavior of |
| 182 | /// the driver on a specific platform. |
| 183 | virtual void printVerboseInfo(raw_ostream &OS) const {}; |
| 184 | |
Daniel Dunbar | 2ba38ba | 2009-03-16 05:25:36 +0000 | [diff] [blame] | 185 | // Platform defaults information |
| 186 | |
Stephen Hines | 176edba | 2014-12-01 14:53:08 -0800 | [diff] [blame] | 187 | /// \brief Returns true if the toolchain is targeting a non-native |
| 188 | /// architecture. |
| 189 | virtual bool isCrossCompiling() const; |
| 190 | |
Daniel Dunbar | b993f5d | 2010-09-17 00:24:52 +0000 | [diff] [blame] | 191 | /// HasNativeLTOLinker - Check whether the linker and related tools have |
| 192 | /// native LLVM support. |
| 193 | virtual bool HasNativeLLVMSupport() const; |
| 194 | |
Daniel Dunbar | 4180011 | 2010-08-02 05:43:56 +0000 | [diff] [blame] | 195 | /// LookupTypeForExtension - Return the default language type to use for the |
| 196 | /// given extension. |
| 197 | virtual types::ID LookupTypeForExtension(const char *Ext) const; |
| 198 | |
Daniel Dunbar | 9e5cc6b | 2009-11-17 08:07:36 +0000 | [diff] [blame] | 199 | /// IsBlocksDefault - Does this tool chain enable -fblocks by default. |
| 200 | virtual bool IsBlocksDefault() const { return false; } |
Daniel Dunbar | 398c610 | 2011-02-04 02:20:39 +0000 | [diff] [blame] | 201 | |
Daniel Dunbar | 8767cbc | 2010-02-03 03:07:56 +0000 | [diff] [blame] | 202 | /// IsIntegratedAssemblerDefault - Does this tool chain enable -integrated-as |
| 203 | /// by default. |
| 204 | virtual bool IsIntegratedAssemblerDefault() const { return false; } |
| 205 | |
Rafael Espindola | 7ce8d82 | 2013-03-18 17:58:22 +0000 | [diff] [blame] | 206 | /// \brief Check if the toolchain should use the integrated assembler. |
Rafael Espindola | af370e6 | 2013-03-18 18:10:27 +0000 | [diff] [blame] | 207 | bool useIntegratedAs() const; |
Rafael Espindola | 5470cd2 | 2013-03-18 17:52:57 +0000 | [diff] [blame] | 208 | |
Benjamin Kramer | 769aa2d | 2012-05-02 14:55:48 +0000 | [diff] [blame] | 209 | /// IsMathErrnoDefault - Does this tool chain use -fmath-errno by default. |
| 210 | virtual bool IsMathErrnoDefault() const { return true; } |
| 211 | |
Fariborz Jahanian | 3d145f6 | 2012-11-15 19:02:45 +0000 | [diff] [blame] | 212 | /// IsEncodeExtendedBlockSignatureDefault - Does this tool chain enable |
| 213 | /// -fencode-extended-block-signature by default. |
| 214 | virtual bool IsEncodeExtendedBlockSignatureDefault() const { return false; } |
Ted Kremenek | c32647d | 2010-12-23 21:35:43 +0000 | [diff] [blame] | 215 | |
Daniel Dunbar | 9e5cc6b | 2009-11-17 08:07:36 +0000 | [diff] [blame] | 216 | /// IsObjCNonFragileABIDefault - Does this tool chain set |
| 217 | /// -fobjc-nonfragile-abi by default. |
| 218 | virtual bool IsObjCNonFragileABIDefault() const { return false; } |
| 219 | |
Daniel Dunbar | f643b9b | 2010-04-24 17:56:46 +0000 | [diff] [blame] | 220 | /// UseObjCMixedDispatchDefault - When using non-legacy dispatch, should the |
| 221 | /// mixed dispatch method be used? |
| 222 | virtual bool UseObjCMixedDispatch() const { return false; } |
| 223 | |
Daniel Dunbar | 9e5cc6b | 2009-11-17 08:07:36 +0000 | [diff] [blame] | 224 | /// GetDefaultStackProtectorLevel - Get the default stack protector level for |
Stephen Hines | 651f13c | 2014-04-23 16:59:28 -0700 | [diff] [blame] | 225 | /// this tool chain (0=off, 1=on, 2=strong, 3=all). |
Nico Weber | 2fef111 | 2011-08-23 07:38:27 +0000 | [diff] [blame] | 226 | virtual unsigned GetDefaultStackProtectorLevel(bool KernelOrKext) const { |
| 227 | return 0; |
| 228 | } |
Daniel Dunbar | 9e5cc6b | 2009-11-17 08:07:36 +0000 | [diff] [blame] | 229 | |
Daniel Dunbar | c24767c | 2011-12-07 23:03:15 +0000 | [diff] [blame] | 230 | /// GetDefaultRuntimeLibType - Get the default runtime library variant to use. |
| 231 | virtual RuntimeLibType GetDefaultRuntimeLibType() const { |
| 232 | return ToolChain::RLT_Libgcc; |
| 233 | } |
| 234 | |
Daniel Dunbar | 2ba38ba | 2009-03-16 05:25:36 +0000 | [diff] [blame] | 235 | /// IsUnwindTablesDefault - Does this tool chain use -funwind-tables |
| 236 | /// by default. |
Rafael Espindola | 03a8638 | 2012-09-23 03:05:41 +0000 | [diff] [blame] | 237 | virtual bool IsUnwindTablesDefault() const; |
Daniel Dunbar | 2ba38ba | 2009-03-16 05:25:36 +0000 | [diff] [blame] | 238 | |
Chandler Carruth | 7ce816a | 2012-11-19 03:52:03 +0000 | [diff] [blame] | 239 | /// \brief Test whether this toolchain defaults to PIC. |
| 240 | virtual bool isPICDefault() const = 0; |
Daniel Dunbar | 2ba38ba | 2009-03-16 05:25:36 +0000 | [diff] [blame] | 241 | |
Peter Collingbourne | 52ca70d | 2013-04-09 04:35:11 +0000 | [diff] [blame] | 242 | /// \brief Test whether this toolchain defaults to PIE. |
| 243 | virtual bool isPIEDefault() const = 0; |
| 244 | |
| 245 | /// \brief Tests whether this toolchain forces its default for PIC, PIE or |
| 246 | /// non-PIC. If this returns true, any PIC related flags should be ignored |
| 247 | /// and instead the results of \c isPICDefault() and \c isPIEDefault() are |
| 248 | /// used exclusively. |
Chandler Carruth | 7ce816a | 2012-11-19 03:52:03 +0000 | [diff] [blame] | 249 | virtual bool isPICDefaultForced() const = 0; |
Daniel Dunbar | f2d8b9f | 2009-12-18 02:43:17 +0000 | [diff] [blame] | 250 | |
Daniel Dunbar | bbe8e3e | 2011-03-01 18:49:30 +0000 | [diff] [blame] | 251 | /// SupportsProfiling - Does this tool chain support -pg. |
| 252 | virtual bool SupportsProfiling() const { return true; } |
| 253 | |
Daniel Dunbar | 43a9b32 | 2010-04-10 16:20:23 +0000 | [diff] [blame] | 254 | /// Does this tool chain support Objective-C garbage collection. |
David Chisnall | 74a63bc | 2011-05-22 16:26:21 +0000 | [diff] [blame] | 255 | virtual bool SupportsObjCGC() const { return true; } |
Daniel Dunbar | 43a9b32 | 2010-04-10 16:20:23 +0000 | [diff] [blame] | 256 | |
John McCall | 0a7dd78 | 2012-08-21 02:47:43 +0000 | [diff] [blame] | 257 | /// Complain if this tool chain doesn't support Objective-C ARC. |
| 258 | virtual void CheckObjCARC() const {} |
Argyrios Kyrtzidis | 5840dd9 | 2012-02-29 03:43:52 +0000 | [diff] [blame] | 259 | |
Daniel Dunbar | f2d8b9f | 2009-12-18 02:43:17 +0000 | [diff] [blame] | 260 | /// UseDwarfDebugFlags - Embed the compile options to clang into the Dwarf |
| 261 | /// compile unit information. |
| 262 | virtual bool UseDwarfDebugFlags() const { return false; } |
Daniel Dunbar | b2987d1 | 2010-02-10 18:49:11 +0000 | [diff] [blame] | 263 | |
| 264 | /// UseSjLjExceptions - Does this tool chain use SjLj exceptions. |
Benjamin Kramer | 8aa7994 | 2010-02-11 11:33:47 +0000 | [diff] [blame] | 265 | virtual bool UseSjLjExceptions() const { return false; } |
Daniel Dunbar | 00577ad | 2010-08-23 22:35:37 +0000 | [diff] [blame] | 266 | |
Stephen Hines | 176edba | 2014-12-01 14:53:08 -0800 | [diff] [blame] | 267 | /// getThreadModel() - Which thread model does this target use? |
| 268 | virtual std::string getThreadModel() const { return "posix"; } |
| 269 | |
Stephen Hines | 0e2c34f | 2015-03-23 12:09:02 -0700 | [diff] [blame] | 270 | /// isThreadModelSupported() - Does this target support a thread model? |
Stephen Hines | 176edba | 2014-12-01 14:53:08 -0800 | [diff] [blame] | 271 | virtual bool isThreadModelSupported(const StringRef Model) const; |
| 272 | |
Daniel Dunbar | 00577ad | 2010-08-23 22:35:37 +0000 | [diff] [blame] | 273 | /// ComputeLLVMTriple - Return the LLVM target triple to use, after taking |
| 274 | /// command line arguments into account. |
Reid Kleckner | dd0b3c4 | 2013-06-17 13:59:19 +0000 | [diff] [blame] | 275 | virtual std::string |
| 276 | ComputeLLVMTriple(const llvm::opt::ArgList &Args, |
| 277 | types::ID InputType = types::TY_INVALID) const; |
Daniel Dunbar | 00577ad | 2010-08-23 22:35:37 +0000 | [diff] [blame] | 278 | |
| 279 | /// ComputeEffectiveClangTriple - Return the Clang triple to use for this |
| 280 | /// target, which may take into account the command line arguments. For |
| 281 | /// example, on Darwin the -mmacosx-version-min= command line argument (which |
| 282 | /// sets the deployment target) determines the version in the triple passed to |
| 283 | /// Clang. |
Reid Kleckner | dd0b3c4 | 2013-06-17 13:59:19 +0000 | [diff] [blame] | 284 | virtual std::string ComputeEffectiveClangTriple( |
| 285 | const llvm::opt::ArgList &Args, |
| 286 | types::ID InputType = types::TY_INVALID) const; |
Daniel Dunbar | 641b98b | 2010-09-14 23:12:35 +0000 | [diff] [blame] | 287 | |
John McCall | 260611a | 2012-06-20 06:18:46 +0000 | [diff] [blame] | 288 | /// getDefaultObjCRuntime - Return the default Objective-C runtime |
| 289 | /// for this platform. |
John McCall | 9f084a3 | 2011-07-06 00:26:06 +0000 | [diff] [blame] | 290 | /// |
John McCall | 13db5cf | 2011-09-09 20:41:01 +0000 | [diff] [blame] | 291 | /// FIXME: this really belongs on some sort of DeploymentTarget abstraction |
John McCall | 260611a | 2012-06-20 06:18:46 +0000 | [diff] [blame] | 292 | virtual ObjCRuntime getDefaultObjCRuntime(bool isNonFragile) const; |
John McCall | 9f084a3 | 2011-07-06 00:26:06 +0000 | [diff] [blame] | 293 | |
John McCall | 13db5cf | 2011-09-09 20:41:01 +0000 | [diff] [blame] | 294 | /// hasBlocksRuntime - Given that the user is compiling with |
| 295 | /// -fblocks, does this tool chain guarantee the existence of a |
| 296 | /// blocks runtime? |
| 297 | /// |
| 298 | /// FIXME: this really belongs on some sort of DeploymentTarget abstraction |
| 299 | virtual bool hasBlocksRuntime() const { return true; } |
| 300 | |
Chandler Carruth | 88491fc | 2011-11-04 07:12:53 +0000 | [diff] [blame] | 301 | /// \brief Add the clang cc1 arguments for system include paths. |
| 302 | /// |
| 303 | /// This routine is responsible for adding the necessary cc1 arguments to |
| 304 | /// include headers from standard system header directories. |
Reid Kleckner | dd0b3c4 | 2013-06-17 13:59:19 +0000 | [diff] [blame] | 305 | virtual void |
| 306 | AddClangSystemIncludeArgs(const llvm::opt::ArgList &DriverArgs, |
| 307 | llvm::opt::ArgStringList &CC1Args) const; |
Chandler Carruth | 88491fc | 2011-11-04 07:12:53 +0000 | [diff] [blame] | 308 | |
Chandler Carruth | a6b2581 | 2012-11-21 23:40:23 +0000 | [diff] [blame] | 309 | /// \brief Add options that need to be passed to cc1 for this target. |
Reid Kleckner | dd0b3c4 | 2013-06-17 13:59:19 +0000 | [diff] [blame] | 310 | virtual void addClangTargetOptions(const llvm::opt::ArgList &DriverArgs, |
| 311 | llvm::opt::ArgStringList &CC1Args) const; |
Rafael Espindola | 8af669f | 2012-06-19 01:26:10 +0000 | [diff] [blame] | 312 | |
Stephen Hines | 651f13c | 2014-04-23 16:59:28 -0700 | [diff] [blame] | 313 | /// \brief Add warning options that need to be passed to cc1 for this target. |
| 314 | virtual void addClangWarningOptions(llvm::opt::ArgStringList &CC1Args) const; |
| 315 | |
Daniel Dunbar | c24767c | 2011-12-07 23:03:15 +0000 | [diff] [blame] | 316 | // GetRuntimeLibType - Determine the runtime library type to use with the |
| 317 | // given compilation arguments. |
Reid Kleckner | dd0b3c4 | 2013-06-17 13:59:19 +0000 | [diff] [blame] | 318 | virtual RuntimeLibType |
| 319 | GetRuntimeLibType(const llvm::opt::ArgList &Args) const; |
Daniel Dunbar | c24767c | 2011-12-07 23:03:15 +0000 | [diff] [blame] | 320 | |
Daniel Dunbar | 641b98b | 2010-09-14 23:12:35 +0000 | [diff] [blame] | 321 | // GetCXXStdlibType - Determine the C++ standard library type to use with the |
| 322 | // given compilation arguments. |
Reid Kleckner | dd0b3c4 | 2013-06-17 13:59:19 +0000 | [diff] [blame] | 323 | virtual CXXStdlibType GetCXXStdlibType(const llvm::opt::ArgList &Args) const; |
Daniel Dunbar | 641b98b | 2010-09-14 23:12:35 +0000 | [diff] [blame] | 324 | |
| 325 | /// AddClangCXXStdlibIncludeArgs - Add the clang -cc1 level arguments to set |
| 326 | /// the include paths to use for the given C++ standard library type. |
Reid Kleckner | dd0b3c4 | 2013-06-17 13:59:19 +0000 | [diff] [blame] | 327 | virtual void |
| 328 | AddClangCXXStdlibIncludeArgs(const llvm::opt::ArgList &DriverArgs, |
| 329 | llvm::opt::ArgStringList &CC1Args) const; |
Daniel Dunbar | 641b98b | 2010-09-14 23:12:35 +0000 | [diff] [blame] | 330 | |
Daniel Dunbar | 132e35d | 2010-09-17 01:20:05 +0000 | [diff] [blame] | 331 | /// AddCXXStdlibLibArgs - Add the system specific linker arguments to use |
Daniel Dunbar | 641b98b | 2010-09-14 23:12:35 +0000 | [diff] [blame] | 332 | /// for the given C++ standard library type. |
Reid Kleckner | dd0b3c4 | 2013-06-17 13:59:19 +0000 | [diff] [blame] | 333 | virtual void AddCXXStdlibLibArgs(const llvm::opt::ArgList &Args, |
| 334 | llvm::opt::ArgStringList &CmdArgs) const; |
Shantonu Sen | 7433fed | 2010-09-17 18:39:08 +0000 | [diff] [blame] | 335 | |
| 336 | /// AddCCKextLibArgs - Add the system specific linker arguments to use |
| 337 | /// for kernel extensions (Darwin-specific). |
Reid Kleckner | dd0b3c4 | 2013-06-17 13:59:19 +0000 | [diff] [blame] | 338 | virtual void AddCCKextLibArgs(const llvm::opt::ArgList &Args, |
| 339 | llvm::opt::ArgStringList &CmdArgs) const; |
Benjamin Kramer | e20e508 | 2012-10-04 19:42:20 +0000 | [diff] [blame] | 340 | |
| 341 | /// AddFastMathRuntimeIfAvailable - If a runtime library exists that sets |
| 342 | /// global flags for unsafe floating point math, add it and return true. |
| 343 | /// |
Stephen Hines | 651f13c | 2014-04-23 16:59:28 -0700 | [diff] [blame] | 344 | /// This checks for presence of the -Ofast, -ffast-math or -funsafe-math flags. |
Reid Kleckner | dd0b3c4 | 2013-06-17 13:59:19 +0000 | [diff] [blame] | 345 | virtual bool |
| 346 | AddFastMathRuntimeIfAvailable(const llvm::opt::ArgList &Args, |
| 347 | llvm::opt::ArgStringList &CmdArgs) const; |
Daniel Dunbar | 2ba38ba | 2009-03-16 05:25:36 +0000 | [diff] [blame] | 348 | }; |
| 349 | |
| 350 | } // end namespace driver |
| 351 | } // end namespace clang |
| 352 | |
| 353 | #endif |