Daniel Dunbar | 83b08eb | 2009-03-17 21:38:00 +0000 | [diff] [blame] | 1 | //===--- 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 Hines | 176edba | 2014-12-01 14:53:08 -0800 | [diff] [blame] | 10 | #ifndef LLVM_CLANG_LIB_DRIVER_TOOLCHAINS_H |
| 11 | #define LLVM_CLANG_LIB_DRIVER_TOOLCHAINS_H |
Daniel Dunbar | 83b08eb | 2009-03-17 21:38:00 +0000 | [diff] [blame] | 12 | |
Chandler Carruth | 55fc873 | 2012-12-04 09:13:33 +0000 | [diff] [blame] | 13 | #include "Tools.h" |
| 14 | #include "clang/Basic/VersionTuple.h" |
Daniel Dunbar | 670b7f4 | 2009-03-17 22:07:31 +0000 | [diff] [blame] | 15 | #include "clang/Driver/Action.h" |
Stephen Hines | 651f13c | 2014-04-23 16:59:28 -0700 | [diff] [blame] | 16 | #include "clang/Driver/Multilib.h" |
Daniel Dunbar | 83b08eb | 2009-03-17 21:38:00 +0000 | [diff] [blame] | 17 | #include "clang/Driver/ToolChain.h" |
Daniel Dunbar | 670b7f4 | 2009-03-17 22:07:31 +0000 | [diff] [blame] | 18 | #include "llvm/ADT/DenseMap.h" |
Stephen Hines | 651f13c | 2014-04-23 16:59:28 -0700 | [diff] [blame] | 19 | #include "llvm/ADT/Optional.h" |
Daniel Dunbar | 83b08eb | 2009-03-17 21:38:00 +0000 | [diff] [blame] | 20 | #include "llvm/Support/Compiler.h" |
Benjamin Kramer | f15b26c | 2013-08-14 18:38:51 +0000 | [diff] [blame] | 21 | #include <set> |
Stephen Hines | 651f13c | 2014-04-23 16:59:28 -0700 | [diff] [blame] | 22 | #include <vector> |
Rafael Espindola | a265461 | 2013-06-11 20:06:05 +0000 | [diff] [blame] | 23 | |
Daniel Dunbar | 83b08eb | 2009-03-17 21:38:00 +0000 | [diff] [blame] | 24 | namespace clang { |
| 25 | namespace driver { |
Daniel Dunbar | 985b825 | 2009-03-17 22:18:43 +0000 | [diff] [blame] | 26 | namespace toolchains { |
Daniel Dunbar | 83b08eb | 2009-03-17 21:38:00 +0000 | [diff] [blame] | 27 | |
Daniel Dunbar | 1d4612b | 2009-09-18 08:15:13 +0000 | [diff] [blame] | 28 | /// 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 Sands | 92dd191 | 2010-05-11 20:16:05 +0000 | [diff] [blame] | 31 | class LLVM_LIBRARY_VISIBILITY Generic_GCC : public ToolChain { |
Daniel Dunbar | 75358d2 | 2009-03-30 21:06:03 +0000 | [diff] [blame] | 32 | protected: |
Chandler Carruth | 19347ed | 2011-11-06 23:39:34 +0000 | [diff] [blame] | 33 | /// \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 Carruth | 0affc67 | 2013-08-26 08:59:53 +0000 | [diff] [blame] | 55 | /// \brief The text of the parsed major, and major+minor versions. |
| 56 | std::string MajorStr, MinorStr; |
| 57 | |
Chandler Carruth | 19347ed | 2011-11-06 23:39:34 +0000 | [diff] [blame] | 58 | /// \brief Any textual suffix on the patch number. |
| 59 | std::string PatchSuffix; |
| 60 | |
| 61 | static GCCVersion Parse(StringRef VersionText); |
Benjamin Kramer | ed5f28f | 2013-08-09 17:17:48 +0000 | [diff] [blame] | 62 | 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 Carruth | 19347ed | 2011-11-06 23:39:34 +0000 | [diff] [blame] | 67 | 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 Carruth | 19347ed | 2011-11-06 23:39:34 +0000 | [diff] [blame] | 72 | /// \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 Carruth | 19347ed | 2011-11-06 23:39:34 +0000 | [diff] [blame] | 79 | bool IsValid; |
Chandler Carruth | fa5be91 | 2012-01-24 19:28:29 +0000 | [diff] [blame] | 80 | llvm::Triple GCCTriple; |
Chandler Carruth | 19347ed | 2011-11-06 23:39:34 +0000 | [diff] [blame] | 81 | |
| 82 | // FIXME: These might be better as path objects. |
Chandler Carruth | 5d84bb4 | 2012-01-24 19:21:42 +0000 | [diff] [blame] | 83 | std::string GCCInstallPath; |
| 84 | std::string GCCParentLibPath; |
Stephen Hines | 651f13c | 2014-04-23 16:59:28 -0700 | [diff] [blame] | 85 | |
| 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 Carruth | 19347ed | 2011-11-06 23:39:34 +0000 | [diff] [blame] | 91 | |
| 92 | GCCVersion Version; |
| 93 | |
Chandler Carruth | 6365ab9 | 2013-07-30 17:57:09 +0000 | [diff] [blame] | 94 | // We retain the list of install paths that were considered and rejected in |
| 95 | // order to print out detailed information in verbose mode. |
Benjamin Kramer | f15b26c | 2013-08-14 18:38:51 +0000 | [diff] [blame] | 96 | std::set<std::string> CandidateGCCInstallPaths; |
Chandler Carruth | 6365ab9 | 2013-07-30 17:57:09 +0000 | [diff] [blame] | 97 | |
Stephen Hines | 651f13c | 2014-04-23 16:59:28 -0700 | [diff] [blame] | 98 | /// The set of multilibs that the detected installation supports. |
| 99 | MultilibSet Multilibs; |
| 100 | |
Chandler Carruth | 19347ed | 2011-11-06 23:39:34 +0000 | [diff] [blame] | 101 | public: |
Stephen Hines | 651f13c | 2014-04-23 16:59:28 -0700 | [diff] [blame] | 102 | GCCInstallationDetector() : IsValid(false) {} |
| 103 | void init(const Driver &D, const llvm::Triple &TargetTriple, |
Reid Kleckner | dd0b3c4 | 2013-06-17 13:59:19 +0000 | [diff] [blame] | 104 | const llvm::opt::ArgList &Args); |
Chandler Carruth | 19347ed | 2011-11-06 23:39:34 +0000 | [diff] [blame] | 105 | |
| 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 Carruth | fa5be91 | 2012-01-24 19:28:29 +0000 | [diff] [blame] | 110 | const llvm::Triple &getTriple() const { return GCCTriple; } |
Chandler Carruth | 19347ed | 2011-11-06 23:39:34 +0000 | [diff] [blame] | 111 | |
| 112 | /// \brief Get the detected GCC installation path. |
Chandler Carruth | 5d84bb4 | 2012-01-24 19:21:42 +0000 | [diff] [blame] | 113 | StringRef getInstallPath() const { return GCCInstallPath; } |
Chandler Carruth | 19347ed | 2011-11-06 23:39:34 +0000 | [diff] [blame] | 114 | |
| 115 | /// \brief Get the detected GCC parent lib path. |
Chandler Carruth | 5d84bb4 | 2012-01-24 19:21:42 +0000 | [diff] [blame] | 116 | StringRef getParentLibPath() const { return GCCParentLibPath; } |
Chandler Carruth | 19347ed | 2011-11-06 23:39:34 +0000 | [diff] [blame] | 117 | |
Stephen Hines | 651f13c | 2014-04-23 16:59:28 -0700 | [diff] [blame] | 118 | /// \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 Atanasyan | 5c805e9 | 2013-09-28 13:45:11 +0000 | [diff] [blame] | 127 | |
Chandler Carruth | 19347ed | 2011-11-06 23:39:34 +0000 | [diff] [blame] | 128 | /// \brief Get the detected GCC version string. |
Rafael Espindola | 8af669f | 2012-06-19 01:26:10 +0000 | [diff] [blame] | 129 | const GCCVersion &getVersion() const { return Version; } |
Chandler Carruth | 19347ed | 2011-11-06 23:39:34 +0000 | [diff] [blame] | 130 | |
Chandler Carruth | 6365ab9 | 2013-07-30 17:57:09 +0000 | [diff] [blame] | 131 | /// \brief Print information about the detected GCC installation. |
| 132 | void print(raw_ostream &OS) const; |
| 133 | |
Chandler Carruth | 19347ed | 2011-11-06 23:39:34 +0000 | [diff] [blame] | 134 | private: |
Chandler Carruth | d79486a | 2013-06-22 11:35:51 +0000 | [diff] [blame] | 135 | 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 Carruth | 19347ed | 2011-11-06 23:39:34 +0000 | [diff] [blame] | 142 | |
Stephen Hines | 651f13c | 2014-04-23 16:59:28 -0700 | [diff] [blame] | 143 | void ScanLibDirForGCCTriple(const llvm::Triple &TargetArch, |
Reid Kleckner | dd0b3c4 | 2013-06-17 13:59:19 +0000 | [diff] [blame] | 144 | const llvm::opt::ArgList &Args, |
Chandler Carruth | d936d9d | 2011-11-09 03:46:20 +0000 | [diff] [blame] | 145 | const std::string &LibDir, |
Chandler Carruth | 1c6f04a | 2012-01-25 07:21:38 +0000 | [diff] [blame] | 146 | StringRef CandidateTriple, |
Chandler Carruth | d79486a | 2013-06-22 11:35:51 +0000 | [diff] [blame] | 147 | bool NeedsBiarchSuffix = false); |
Chandler Carruth | 19347ed | 2011-11-06 23:39:34 +0000 | [diff] [blame] | 148 | }; |
| 149 | |
| 150 | GCCInstallationDetector GCCInstallation; |
| 151 | |
Daniel Dunbar | 83b08eb | 2009-03-17 21:38:00 +0000 | [diff] [blame] | 152 | public: |
Reid Kleckner | dd0b3c4 | 2013-06-17 13:59:19 +0000 | [diff] [blame] | 153 | Generic_GCC(const Driver &D, const llvm::Triple &Triple, |
| 154 | const llvm::opt::ArgList &Args); |
Daniel Dunbar | 3917608 | 2009-03-20 00:20:03 +0000 | [diff] [blame] | 155 | ~Generic_GCC(); |
Daniel Dunbar | 83b08eb | 2009-03-17 21:38:00 +0000 | [diff] [blame] | 156 | |
Stephen Hines | 651f13c | 2014-04-23 16:59:28 -0700 | [diff] [blame] | 157 | void printVerboseInfo(raw_ostream &OS) const override; |
Chandler Carruth | 6365ab9 | 2013-07-30 17:57:09 +0000 | [diff] [blame] | 158 | |
Stephen Hines | 651f13c | 2014-04-23 16:59:28 -0700 | [diff] [blame] | 159 | 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 Carruth | b37fe61 | 2011-11-06 23:39:37 +0000 | [diff] [blame] | 164 | |
| 165 | protected: |
Stephen Hines | 651f13c | 2014-04-23 16:59:28 -0700 | [diff] [blame] | 166 | Tool *getTool(Action::ActionClass AC) const override; |
| 167 | Tool *buildAssembler() const override; |
| 168 | Tool *buildLinker() const override; |
Rafael Espindola | f48b93c | 2013-03-20 03:05:54 +0000 | [diff] [blame] | 169 | |
Chandler Carruth | b37fe61 | 2011-11-06 23:39:37 +0000 | [diff] [blame] | 170 | /// \name ToolChain Implementation Helper Functions |
| 171 | /// @{ |
| 172 | |
| 173 | /// \brief Check whether the target triple's architecture is 64-bits. |
Chandler Carruth | d747efa | 2012-02-11 03:31:12 +0000 | [diff] [blame] | 174 | bool isTarget64Bit() const { return getTriple().isArch64Bit(); } |
| 175 | |
Chandler Carruth | b37fe61 | 2011-11-06 23:39:37 +0000 | [diff] [blame] | 176 | /// \brief Check whether the target triple's architecture is 32-bits. |
Chandler Carruth | d747efa | 2012-02-11 03:31:12 +0000 | [diff] [blame] | 177 | bool isTarget32Bit() const { return getTriple().isArch32Bit(); } |
Chandler Carruth | b37fe61 | 2011-11-06 23:39:37 +0000 | [diff] [blame] | 178 | |
| 179 | /// @} |
Rafael Espindola | f48b93c | 2013-03-20 03:05:54 +0000 | [diff] [blame] | 180 | |
| 181 | private: |
Stephen Hines | 651f13c | 2014-04-23 16:59:28 -0700 | [diff] [blame] | 182 | mutable std::unique_ptr<tools::gcc::Preprocess> Preprocess; |
| 183 | mutable std::unique_ptr<tools::gcc::Compile> Compile; |
| 184 | }; |
| 185 | |
| 186 | class LLVM_LIBRARY_VISIBILITY MachO : public ToolChain { |
| 187 | protected: |
| 188 | Tool *buildAssembler() const override; |
| 189 | Tool *buildLinker() const override; |
| 190 | Tool *getTool(Action::ActionClass AC) const override; |
| 191 | private: |
| 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 | |
| 196 | public: |
| 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 Hines | 176edba | 2014-12-01 14:53:08 -0800 | [diff] [blame] | 237 | StringRef DarwinLibName, |
Stephen Hines | 651f13c | 2014-04-23 16:59:28 -0700 | [diff] [blame] | 238 | bool AlwaysLink = false, |
Stephen Hines | 176edba | 2014-12-01 14:53:08 -0800 | [diff] [blame] | 239 | bool IsEmbedded = false, |
| 240 | bool AddRPath = false) const; |
Stephen Hines | 651f13c | 2014-04-23 16:59:28 -0700 | [diff] [blame] | 241 | |
| 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 Hines | 0e2c34f | 2015-03-23 12:09:02 -0700 | [diff] [blame] | 259 | // expected to use /usr/include/Block.h. |
Stephen Hines | 651f13c | 2014-04-23 16:59:28 -0700 | [diff] [blame] | 260 | 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 Dunbar | 83b08eb | 2009-03-17 21:38:00 +0000 | [diff] [blame] | 307 | }; |
| 308 | |
Tony Linthicum | 9631939 | 2011-12-12 21:14:55 +0000 | [diff] [blame] | 309 | /// Darwin - The base Darwin tool chain. |
Stephen Hines | 651f13c | 2014-04-23 16:59:28 -0700 | [diff] [blame] | 310 | class LLVM_LIBRARY_VISIBILITY Darwin : public MachO { |
Daniel Dunbar | 25b58eb | 2010-08-02 05:44:07 +0000 | [diff] [blame] | 311 | public: |
| 312 | /// The host version. |
| 313 | unsigned DarwinVersion[3]; |
| 314 | |
Daniel Dunbar | 2603137 | 2010-01-27 00:56:25 +0000 | [diff] [blame] | 315 | /// 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 Hines | 651f13c | 2014-04-23 16:59:28 -0700 | [diff] [blame] | 322 | enum DarwinPlatformKind { |
| 323 | MacOS, |
| 324 | IPhoneOS, |
| 325 | IPhoneOSSimulator |
| 326 | }; |
Daniel Dunbar | eb840bd | 2010-05-14 02:03:00 +0000 | [diff] [blame] | 327 | |
Stephen Hines | 651f13c | 2014-04-23 16:59:28 -0700 | [diff] [blame] | 328 | mutable DarwinPlatformKind TargetPlatform; |
Daniel Dunbar | 5f5c37b | 2011-04-30 04:18:16 +0000 | [diff] [blame] | 329 | |
Chris Lattner | fc8f0e1 | 2011-04-15 05:22:18 +0000 | [diff] [blame] | 330 | /// The OS version we are targeting. |
Benjamin Kramer | 09c9a56 | 2012-03-10 20:55:36 +0000 | [diff] [blame] | 331 | mutable VersionTuple TargetVersion; |
Daniel Dunbar | 2603137 | 2010-01-27 00:56:25 +0000 | [diff] [blame] | 332 | |
John McCall | 260611a | 2012-06-20 06:18:46 +0000 | [diff] [blame] | 333 | private: |
Daniel Dunbar | 02633b5 | 2009-03-26 16:23:12 +0000 | [diff] [blame] | 334 | /// The default macosx-version-min of this tool chain; empty until |
| 335 | /// initialized. |
Daniel Dunbar | 816bc31 | 2010-01-26 01:45:19 +0000 | [diff] [blame] | 336 | std::string MacosxVersionMin; |
Daniel Dunbar | 02633b5 | 2009-03-26 16:23:12 +0000 | [diff] [blame] | 337 | |
Chad Rosier | 4ec2678 | 2012-05-09 18:37:26 +0000 | [diff] [blame] | 338 | /// The default ios-version-min of this tool chain; empty until |
| 339 | /// initialized. |
| 340 | std::string iOSVersionMin; |
| 341 | |
Daniel Dunbar | c0e665e | 2010-07-19 17:11:33 +0000 | [diff] [blame] | 342 | private: |
Reid Kleckner | dd0b3c4 | 2013-06-17 13:59:19 +0000 | [diff] [blame] | 343 | void AddDeploymentTarget(llvm::opt::DerivedArgList &Args) const; |
Daniel Dunbar | c0e665e | 2010-07-19 17:11:33 +0000 | [diff] [blame] | 344 | |
Daniel Dunbar | 8eddb3f | 2009-03-20 00:57:52 +0000 | [diff] [blame] | 345 | public: |
Reid Kleckner | dd0b3c4 | 2013-06-17 13:59:19 +0000 | [diff] [blame] | 346 | Darwin(const Driver &D, const llvm::Triple &Triple, |
| 347 | const llvm::opt::ArgList &Args); |
Daniel Dunbar | f395528 | 2009-09-04 18:34:51 +0000 | [diff] [blame] | 348 | ~Darwin(); |
Daniel Dunbar | 8eddb3f | 2009-03-20 00:57:52 +0000 | [diff] [blame] | 349 | |
Reid Kleckner | dd0b3c4 | 2013-06-17 13:59:19 +0000 | [diff] [blame] | 350 | std::string ComputeEffectiveClangTriple(const llvm::opt::ArgList &Args, |
Stephen Hines | 651f13c | 2014-04-23 16:59:28 -0700 | [diff] [blame] | 351 | types::ID InputType) const override; |
Daniel Dunbar | 00577ad | 2010-08-23 22:35:37 +0000 | [diff] [blame] | 352 | |
Stephen Hines | 651f13c | 2014-04-23 16:59:28 -0700 | [diff] [blame] | 353 | /// @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 Hines | 0e2c34f | 2015-03-23 12:09:02 -0700 | [diff] [blame] | 365 | return !isTargetIPhoneOS() || isIPhoneOSVersionLT(6, 0); |
Stephen Hines | 651f13c | 2014-04-23 16:59:28 -0700 | [diff] [blame] | 366 | } |
| 367 | |
| 368 | protected: |
| 369 | /// } |
| 370 | /// @name Darwin specific Toolchain functions |
Daniel Dunbar | 6b200b2 | 2009-09-18 08:14:36 +0000 | [diff] [blame] | 371 | /// { |
| 372 | |
Daniel Dunbar | 2603137 | 2010-01-27 00:56:25 +0000 | [diff] [blame] | 373 | // FIXME: Eliminate these ...Target functions and derive separate tool chains |
| 374 | // for these targets and put version in constructor. |
Stephen Hines | 651f13c | 2014-04-23 16:59:28 -0700 | [diff] [blame] | 375 | void setTarget(DarwinPlatformKind Platform, unsigned Major, unsigned Minor, |
| 376 | unsigned Micro) const { |
Daniel Dunbar | 2603137 | 2010-01-27 00:56:25 +0000 | [diff] [blame] | 377 | // 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 Hines | 651f13c | 2014-04-23 16:59:28 -0700 | [diff] [blame] | 379 | if (TargetInitialized && TargetPlatform == Platform && |
Benjamin Kramer | 09c9a56 | 2012-03-10 20:55:36 +0000 | [diff] [blame] | 380 | TargetVersion == VersionTuple(Major, Minor, Micro)) |
Daniel Dunbar | 2603137 | 2010-01-27 00:56:25 +0000 | [diff] [blame] | 381 | return; |
| 382 | |
| 383 | assert(!TargetInitialized && "Target already initialized!"); |
| 384 | TargetInitialized = true; |
Stephen Hines | 651f13c | 2014-04-23 16:59:28 -0700 | [diff] [blame] | 385 | TargetPlatform = Platform; |
Benjamin Kramer | 09c9a56 | 2012-03-10 20:55:36 +0000 | [diff] [blame] | 386 | TargetVersion = VersionTuple(Major, Minor, Micro); |
Daniel Dunbar | 2603137 | 2010-01-27 00:56:25 +0000 | [diff] [blame] | 387 | } |
| 388 | |
| 389 | bool isTargetIPhoneOS() const { |
| 390 | assert(TargetInitialized && "Target not initialized!"); |
Stephen Hines | 651f13c | 2014-04-23 16:59:28 -0700 | [diff] [blame] | 391 | return TargetPlatform == IPhoneOS; |
Daniel Dunbar | 2603137 | 2010-01-27 00:56:25 +0000 | [diff] [blame] | 392 | } |
| 393 | |
Daniel Dunbar | 4035580 | 2011-03-31 17:12:33 +0000 | [diff] [blame] | 394 | bool isTargetIOSSimulator() const { |
Daniel Dunbar | 5f5c37b | 2011-04-30 04:18:16 +0000 | [diff] [blame] | 395 | assert(TargetInitialized && "Target not initialized!"); |
Stephen Hines | 651f13c | 2014-04-23 16:59:28 -0700 | [diff] [blame] | 396 | return TargetPlatform == IPhoneOSSimulator; |
| 397 | } |
| 398 | |
| 399 | bool isTargetIOSBased() const { |
| 400 | assert(TargetInitialized && "Target not initialized!"); |
| 401 | return isTargetIPhoneOS() || isTargetIOSSimulator(); |
Daniel Dunbar | 4035580 | 2011-03-31 17:12:33 +0000 | [diff] [blame] | 402 | } |
| 403 | |
Ted Kremenek | ebcb57a | 2012-03-06 20:05:56 +0000 | [diff] [blame] | 404 | bool isTargetMacOS() const { |
Stephen Hines | 651f13c | 2014-04-23 16:59:28 -0700 | [diff] [blame] | 405 | return TargetPlatform == MacOS; |
Ted Kremenek | ebcb57a | 2012-03-06 20:05:56 +0000 | [diff] [blame] | 406 | } |
| 407 | |
Daniel Dunbar | 03d87ee | 2010-03-20 00:50:21 +0000 | [diff] [blame] | 408 | bool isTargetInitialized() const { return TargetInitialized; } |
| 409 | |
Benjamin Kramer | 09c9a56 | 2012-03-10 20:55:36 +0000 | [diff] [blame] | 410 | VersionTuple getTargetVersion() const { |
Daniel Dunbar | 2603137 | 2010-01-27 00:56:25 +0000 | [diff] [blame] | 411 | assert(TargetInitialized && "Target not initialized!"); |
Benjamin Kramer | 09c9a56 | 2012-03-10 20:55:36 +0000 | [diff] [blame] | 412 | return TargetVersion; |
Daniel Dunbar | 2603137 | 2010-01-27 00:56:25 +0000 | [diff] [blame] | 413 | } |
| 414 | |
Daniel Dunbar | cacb0f0 | 2010-01-27 00:56:56 +0000 | [diff] [blame] | 415 | bool isIPhoneOSVersionLT(unsigned V0, unsigned V1=0, unsigned V2=0) const { |
Stephen Hines | 651f13c | 2014-04-23 16:59:28 -0700 | [diff] [blame] | 416 | assert(isTargetIOSBased() && "Unexpected call for non iOS target!"); |
Benjamin Kramer | 09c9a56 | 2012-03-10 20:55:36 +0000 | [diff] [blame] | 417 | return TargetVersion < VersionTuple(V0, V1, V2); |
Daniel Dunbar | ce3fdf2 | 2010-01-27 00:57:03 +0000 | [diff] [blame] | 418 | } |
| 419 | |
| 420 | bool isMacosxVersionLT(unsigned V0, unsigned V1=0, unsigned V2=0) const { |
Stephen Hines | 651f13c | 2014-04-23 16:59:28 -0700 | [diff] [blame] | 421 | assert(isTargetMacOS() && "Unexpected call for non OS X target!"); |
Benjamin Kramer | 09c9a56 | 2012-03-10 20:55:36 +0000 | [diff] [blame] | 422 | return TargetVersion < VersionTuple(V0, V1, V2); |
Daniel Dunbar | cacb0f0 | 2010-01-27 00:56:56 +0000 | [diff] [blame] | 423 | } |
| 424 | |
Stephen Hines | 651f13c | 2014-04-23 16:59:28 -0700 | [diff] [blame] | 425 | public: |
Daniel Dunbar | 6b200b2 | 2009-09-18 08:14:36 +0000 | [diff] [blame] | 426 | /// } |
| 427 | /// @name ToolChain Implementation |
| 428 | /// { |
| 429 | |
Stephen Hines | 176edba | 2014-12-01 14:53:08 -0800 | [diff] [blame] | 430 | // 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 Hines | 651f13c | 2014-04-23 16:59:28 -0700 | [diff] [blame] | 435 | llvm::opt::DerivedArgList * |
Reid Kleckner | dd0b3c4 | 2013-06-17 13:59:19 +0000 | [diff] [blame] | 436 | TranslateArgs(const llvm::opt::DerivedArgList &Args, |
Stephen Hines | 651f13c | 2014-04-23 16:59:28 -0700 | [diff] [blame] | 437 | const char *BoundArch) const override; |
Daniel Dunbar | 8eddb3f | 2009-03-20 00:57:52 +0000 | [diff] [blame] | 438 | |
Stephen Hines | 651f13c | 2014-04-23 16:59:28 -0700 | [diff] [blame] | 439 | ObjCRuntime getDefaultObjCRuntime(bool isNonFragile) const override; |
| 440 | bool hasBlocksRuntime() const override; |
Benjamin Kramer | 769aa2d | 2012-05-02 14:55:48 +0000 | [diff] [blame] | 441 | |
Stephen Hines | 651f13c | 2014-04-23 16:59:28 -0700 | [diff] [blame] | 442 | bool UseObjCMixedDispatch() const override { |
Daniel Dunbar | f645aaa | 2010-04-24 18:37:41 +0000 | [diff] [blame] | 443 | // 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 Hines | 651f13c | 2014-04-23 16:59:28 -0700 | [diff] [blame] | 446 | return !(isTargetMacOS() && isMacosxVersionLT(10, 6)); |
Daniel Dunbar | f643b9b | 2010-04-24 17:56:46 +0000 | [diff] [blame] | 447 | } |
Stephen Hines | 651f13c | 2014-04-23 16:59:28 -0700 | [diff] [blame] | 448 | |
| 449 | unsigned GetDefaultStackProtectorLevel(bool KernelOrKext) const override { |
Nico Weber | 2fef111 | 2011-08-23 07:38:27 +0000 | [diff] [blame] | 450 | // Stack protectors default to on for user code on 10.5, |
| 451 | // and for everything in 10.6 and beyond |
Stephen Hines | 651f13c | 2014-04-23 16:59:28 -0700 | [diff] [blame] | 452 | 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 Dunbar | 9e5cc6b | 2009-11-17 08:07:36 +0000 | [diff] [blame] | 460 | } |
Daniel Dunbar | 6b200b2 | 2009-09-18 08:14:36 +0000 | [diff] [blame] | 461 | |
Stephen Hines | 651f13c | 2014-04-23 16:59:28 -0700 | [diff] [blame] | 462 | bool SupportsObjCGC() const override; |
Daniel Dunbar | bbe8e3e | 2011-03-01 18:49:30 +0000 | [diff] [blame] | 463 | |
Stephen Hines | 651f13c | 2014-04-23 16:59:28 -0700 | [diff] [blame] | 464 | void CheckObjCARC() const override; |
Daniel Dunbar | 43a9b32 | 2010-04-10 16:20:23 +0000 | [diff] [blame] | 465 | |
Stephen Hines | 651f13c | 2014-04-23 16:59:28 -0700 | [diff] [blame] | 466 | bool UseSjLjExceptions() const override; |
Daniel Dunbar | 8eddb3f | 2009-03-20 00:57:52 +0000 | [diff] [blame] | 467 | }; |
| 468 | |
Daniel Dunbar | 1d4612b | 2009-09-18 08:15:13 +0000 | [diff] [blame] | 469 | /// DarwinClang - The Darwin toolchain used by Clang. |
Duncan Sands | 92dd191 | 2010-05-11 20:16:05 +0000 | [diff] [blame] | 470 | class LLVM_LIBRARY_VISIBILITY DarwinClang : public Darwin { |
Daniel Dunbar | 8eddb3f | 2009-03-20 00:57:52 +0000 | [diff] [blame] | 471 | public: |
Reid Kleckner | dd0b3c4 | 2013-06-17 13:59:19 +0000 | [diff] [blame] | 472 | DarwinClang(const Driver &D, const llvm::Triple &Triple, |
| 473 | const llvm::opt::ArgList &Args); |
Daniel Dunbar | 1d4612b | 2009-09-18 08:15:13 +0000 | [diff] [blame] | 474 | |
Stephen Hines | 651f13c | 2014-04-23 16:59:28 -0700 | [diff] [blame] | 475 | /// @name Apple ToolChain Implementation |
Daniel Dunbar | 1d4612b | 2009-09-18 08:15:13 +0000 | [diff] [blame] | 476 | /// { |
| 477 | |
Stephen Hines | 651f13c | 2014-04-23 16:59:28 -0700 | [diff] [blame] | 478 | void |
| 479 | AddLinkRuntimeLibArgs(const llvm::opt::ArgList &Args, |
| 480 | llvm::opt::ArgStringList &CmdArgs) const override; |
Alexey Samsonov | 69b77d7 | 2012-11-21 14:17:42 +0000 | [diff] [blame] | 481 | |
Stephen Hines | 651f13c | 2014-04-23 16:59:28 -0700 | [diff] [blame] | 482 | void |
| 483 | AddCXXStdlibLibArgs(const llvm::opt::ArgList &Args, |
| 484 | llvm::opt::ArgStringList &CmdArgs) const override; |
Daniel Dunbar | efe91ea | 2010-09-17 01:16:06 +0000 | [diff] [blame] | 485 | |
Stephen Hines | 651f13c | 2014-04-23 16:59:28 -0700 | [diff] [blame] | 486 | void |
| 487 | AddCCKextLibArgs(const llvm::opt::ArgList &Args, |
| 488 | llvm::opt::ArgStringList &CmdArgs) const override; |
Shantonu Sen | 7433fed | 2010-09-17 18:39:08 +0000 | [diff] [blame] | 489 | |
Stephen Hines | 176edba | 2014-12-01 14:53:08 -0800 | [diff] [blame] | 490 | virtual void addClangWarningOptions(llvm::opt::ArgStringList &CC1Args) |
| 491 | const override; |
Stephen Hines | 651f13c | 2014-04-23 16:59:28 -0700 | [diff] [blame] | 492 | |
| 493 | void |
| 494 | AddLinkARCArgs(const llvm::opt::ArgList &Args, |
| 495 | llvm::opt::ArgStringList &CmdArgs) const override; |
Daniel Dunbar | 1d4612b | 2009-09-18 08:15:13 +0000 | [diff] [blame] | 496 | /// } |
| 497 | }; |
| 498 | |
Rafael Espindola | e43cfa1 | 2010-10-29 20:14:02 +0000 | [diff] [blame] | 499 | class LLVM_LIBRARY_VISIBILITY Generic_ELF : public Generic_GCC { |
David Blaikie | 99ba9e3 | 2011-12-20 02:48:34 +0000 | [diff] [blame] | 500 | virtual void anchor(); |
| 501 | public: |
Reid Kleckner | dd0b3c4 | 2013-06-17 13:59:19 +0000 | [diff] [blame] | 502 | Generic_ELF(const Driver &D, const llvm::Triple &Triple, |
| 503 | const llvm::opt::ArgList &Args) |
| 504 | : Generic_GCC(D, Triple, Args) {} |
Rafael Espindola | e43cfa1 | 2010-10-29 20:14:02 +0000 | [diff] [blame] | 505 | |
Stephen Hines | 651f13c | 2014-04-23 16:59:28 -0700 | [diff] [blame] | 506 | void addClangTargetOptions(const llvm::opt::ArgList &DriverArgs, |
| 507 | llvm::opt::ArgStringList &CC1Args) const override; |
Rafael Espindola | e43cfa1 | 2010-10-29 20:14:02 +0000 | [diff] [blame] | 508 | }; |
| 509 | |
David Chisnall | 31c4690 | 2012-02-15 13:39:01 +0000 | [diff] [blame] | 510 | class LLVM_LIBRARY_VISIBILITY Solaris : public Generic_GCC { |
| 511 | public: |
Reid Kleckner | dd0b3c4 | 2013-06-17 13:59:19 +0000 | [diff] [blame] | 512 | Solaris(const Driver &D, const llvm::Triple &Triple, |
| 513 | const llvm::opt::ArgList &Args); |
David Chisnall | 31c4690 | 2012-02-15 13:39:01 +0000 | [diff] [blame] | 514 | |
Stephen Hines | 651f13c | 2014-04-23 16:59:28 -0700 | [diff] [blame] | 515 | bool IsIntegratedAssemblerDefault() const override { return true; } |
Rafael Espindola | f48b93c | 2013-03-20 03:05:54 +0000 | [diff] [blame] | 516 | protected: |
Stephen Hines | 651f13c | 2014-04-23 16:59:28 -0700 | [diff] [blame] | 517 | Tool *buildAssembler() const override; |
| 518 | Tool *buildLinker() const override; |
Rafael Espindola | f48b93c | 2013-03-20 03:05:54 +0000 | [diff] [blame] | 519 | |
David Chisnall | 31c4690 | 2012-02-15 13:39:01 +0000 | [diff] [blame] | 520 | }; |
| 521 | |
| 522 | |
Rafael Espindola | e43cfa1 | 2010-10-29 20:14:02 +0000 | [diff] [blame] | 523 | class LLVM_LIBRARY_VISIBILITY OpenBSD : public Generic_ELF { |
Daniel Dunbar | f7b8eec | 2009-06-29 20:52:51 +0000 | [diff] [blame] | 524 | public: |
Reid Kleckner | dd0b3c4 | 2013-06-17 13:59:19 +0000 | [diff] [blame] | 525 | OpenBSD(const Driver &D, const llvm::Triple &Triple, |
| 526 | const llvm::opt::ArgList &Args); |
Daniel Dunbar | f7b8eec | 2009-06-29 20:52:51 +0000 | [diff] [blame] | 527 | |
Stephen Hines | 651f13c | 2014-04-23 16:59:28 -0700 | [diff] [blame] | 528 | bool IsMathErrnoDefault() const override { return false; } |
| 529 | bool IsObjCNonFragileABIDefault() const override { return true; } |
| 530 | bool isPIEDefault() const override { return true; } |
Rafael Espindola | 9adba39 | 2013-06-05 04:28:55 +0000 | [diff] [blame] | 531 | |
Stephen Hines | 651f13c | 2014-04-23 16:59:28 -0700 | [diff] [blame] | 532 | unsigned GetDefaultStackProtectorLevel(bool KernelOrKext) const override { |
Stephen Hines | 6bcf27b | 2014-05-29 04:14:42 -0700 | [diff] [blame] | 533 | return 2; |
Rafael Espindola | 9adba39 | 2013-06-05 04:28:55 +0000 | [diff] [blame] | 534 | } |
David Chisnall | c3cb072 | 2012-04-09 12:33:41 +0000 | [diff] [blame] | 535 | |
Rafael Espindola | f48b93c | 2013-03-20 03:05:54 +0000 | [diff] [blame] | 536 | protected: |
Stephen Hines | 651f13c | 2014-04-23 16:59:28 -0700 | [diff] [blame] | 537 | Tool *buildAssembler() const override; |
| 538 | Tool *buildLinker() const override; |
Daniel Dunbar | f7b8eec | 2009-06-29 20:52:51 +0000 | [diff] [blame] | 539 | }; |
| 540 | |
Eli Friedman | 42f74f2 | 2012-08-08 23:57:20 +0000 | [diff] [blame] | 541 | class LLVM_LIBRARY_VISIBILITY Bitrig : public Generic_ELF { |
| 542 | public: |
Reid Kleckner | dd0b3c4 | 2013-06-17 13:59:19 +0000 | [diff] [blame] | 543 | Bitrig(const Driver &D, const llvm::Triple &Triple, |
| 544 | const llvm::opt::ArgList &Args); |
Eli Friedman | 42f74f2 | 2012-08-08 23:57:20 +0000 | [diff] [blame] | 545 | |
Stephen Hines | 651f13c | 2014-04-23 16:59:28 -0700 | [diff] [blame] | 546 | bool IsMathErrnoDefault() const override { return false; } |
| 547 | bool IsObjCNonFragileABIDefault() const override { return true; } |
Eli Friedman | 42f74f2 | 2012-08-08 23:57:20 +0000 | [diff] [blame] | 548 | |
Stephen Hines | 6bcf27b | 2014-05-29 04:14:42 -0700 | [diff] [blame] | 549 | CXXStdlibType GetCXXStdlibType(const llvm::opt::ArgList &Args) const override; |
Stephen Hines | 651f13c | 2014-04-23 16:59:28 -0700 | [diff] [blame] | 550 | void |
Reid Kleckner | dd0b3c4 | 2013-06-17 13:59:19 +0000 | [diff] [blame] | 551 | AddClangCXXStdlibIncludeArgs(const llvm::opt::ArgList &DriverArgs, |
Stephen Hines | 651f13c | 2014-04-23 16:59:28 -0700 | [diff] [blame] | 552 | 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 Friedman | 42f74f2 | 2012-08-08 23:57:20 +0000 | [diff] [blame] | 556 | return 1; |
| 557 | } |
Rafael Espindola | f48b93c | 2013-03-20 03:05:54 +0000 | [diff] [blame] | 558 | |
| 559 | protected: |
Stephen Hines | 651f13c | 2014-04-23 16:59:28 -0700 | [diff] [blame] | 560 | Tool *buildAssembler() const override; |
| 561 | Tool *buildLinker() const override; |
Eli Friedman | 42f74f2 | 2012-08-08 23:57:20 +0000 | [diff] [blame] | 562 | }; |
| 563 | |
Rafael Espindola | e43cfa1 | 2010-10-29 20:14:02 +0000 | [diff] [blame] | 564 | class LLVM_LIBRARY_VISIBILITY FreeBSD : public Generic_ELF { |
Daniel Dunbar | 75358d2 | 2009-03-30 21:06:03 +0000 | [diff] [blame] | 565 | public: |
Reid Kleckner | dd0b3c4 | 2013-06-17 13:59:19 +0000 | [diff] [blame] | 566 | FreeBSD(const Driver &D, const llvm::Triple &Triple, |
| 567 | const llvm::opt::ArgList &Args); |
Stephen Hines | 651f13c | 2014-04-23 16:59:28 -0700 | [diff] [blame] | 568 | bool HasNativeLLVMSupport() const override; |
Daniel Dunbar | 75358d2 | 2009-03-30 21:06:03 +0000 | [diff] [blame] | 569 | |
Stephen Hines | 651f13c | 2014-04-23 16:59:28 -0700 | [diff] [blame] | 570 | bool IsMathErrnoDefault() const override { return false; } |
| 571 | bool IsObjCNonFragileABIDefault() const override { return true; } |
David Chisnall | c3cb072 | 2012-04-09 12:33:41 +0000 | [diff] [blame] | 572 | |
Stephen Hines | 651f13c | 2014-04-23 16:59:28 -0700 | [diff] [blame] | 573 | CXXStdlibType GetCXXStdlibType(const llvm::opt::ArgList &Args) const override; |
| 574 | void |
David Chisnall | 1cc766f | 2013-11-09 15:10:56 +0000 | [diff] [blame] | 575 | AddClangCXXStdlibIncludeArgs(const llvm::opt::ArgList &DriverArgs, |
Stephen Hines | 651f13c | 2014-04-23 16:59:28 -0700 | [diff] [blame] | 576 | llvm::opt::ArgStringList &CC1Args) const override; |
David Chisnall | 1cc766f | 2013-11-09 15:10:56 +0000 | [diff] [blame] | 577 | |
Stephen Hines | 651f13c | 2014-04-23 16:59:28 -0700 | [diff] [blame] | 578 | bool UseSjLjExceptions() const override; |
| 579 | bool isPIEDefault() const override; |
Rafael Espindola | f48b93c | 2013-03-20 03:05:54 +0000 | [diff] [blame] | 580 | protected: |
Stephen Hines | 651f13c | 2014-04-23 16:59:28 -0700 | [diff] [blame] | 581 | Tool *buildAssembler() const override; |
| 582 | Tool *buildLinker() const override; |
Daniel Dunbar | 75358d2 | 2009-03-30 21:06:03 +0000 | [diff] [blame] | 583 | }; |
| 584 | |
Benjamin Kramer | 8e50a96 | 2011-02-02 18:59:27 +0000 | [diff] [blame] | 585 | class LLVM_LIBRARY_VISIBILITY NetBSD : public Generic_ELF { |
| 586 | public: |
Reid Kleckner | dd0b3c4 | 2013-06-17 13:59:19 +0000 | [diff] [blame] | 587 | NetBSD(const Driver &D, const llvm::Triple &Triple, |
| 588 | const llvm::opt::ArgList &Args); |
Benjamin Kramer | 8e50a96 | 2011-02-02 18:59:27 +0000 | [diff] [blame] | 589 | |
Stephen Hines | 651f13c | 2014-04-23 16:59:28 -0700 | [diff] [blame] | 590 | bool IsMathErrnoDefault() const override { return false; } |
| 591 | bool IsObjCNonFragileABIDefault() const override { return true; } |
David Chisnall | c3cb072 | 2012-04-09 12:33:41 +0000 | [diff] [blame] | 592 | |
Stephen Hines | 651f13c | 2014-04-23 16:59:28 -0700 | [diff] [blame] | 593 | CXXStdlibType GetCXXStdlibType(const llvm::opt::ArgList &Args) const override; |
Joerg Sonnenberger | a7efaf9 | 2013-04-30 01:21:43 +0000 | [diff] [blame] | 594 | |
Stephen Hines | 651f13c | 2014-04-23 16:59:28 -0700 | [diff] [blame] | 595 | void |
Reid Kleckner | dd0b3c4 | 2013-06-17 13:59:19 +0000 | [diff] [blame] | 596 | AddClangCXXStdlibIncludeArgs(const llvm::opt::ArgList &DriverArgs, |
Stephen Hines | 651f13c | 2014-04-23 16:59:28 -0700 | [diff] [blame] | 597 | llvm::opt::ArgStringList &CC1Args) const override; |
| 598 | bool IsUnwindTablesDefault() const override { |
Joerg Sonnenberger | ba7fd42 | 2013-08-15 15:08:33 +0000 | [diff] [blame] | 599 | return true; |
| 600 | } |
Joerg Sonnenberger | a7efaf9 | 2013-04-30 01:21:43 +0000 | [diff] [blame] | 601 | |
Rafael Espindola | f48b93c | 2013-03-20 03:05:54 +0000 | [diff] [blame] | 602 | protected: |
Stephen Hines | 651f13c | 2014-04-23 16:59:28 -0700 | [diff] [blame] | 603 | Tool *buildAssembler() const override; |
| 604 | Tool *buildLinker() const override; |
Benjamin Kramer | 8e50a96 | 2011-02-02 18:59:27 +0000 | [diff] [blame] | 605 | }; |
| 606 | |
Eli Friedman | 6d402dc | 2011-12-08 23:54:21 +0000 | [diff] [blame] | 607 | class LLVM_LIBRARY_VISIBILITY Minix : public Generic_ELF { |
Chris Lattner | 38e317d | 2010-07-07 16:01:42 +0000 | [diff] [blame] | 608 | public: |
Reid Kleckner | dd0b3c4 | 2013-06-17 13:59:19 +0000 | [diff] [blame] | 609 | Minix(const Driver &D, const llvm::Triple &Triple, |
| 610 | const llvm::opt::ArgList &Args); |
Chris Lattner | 38e317d | 2010-07-07 16:01:42 +0000 | [diff] [blame] | 611 | |
Rafael Espindola | f48b93c | 2013-03-20 03:05:54 +0000 | [diff] [blame] | 612 | protected: |
Stephen Hines | 651f13c | 2014-04-23 16:59:28 -0700 | [diff] [blame] | 613 | Tool *buildAssembler() const override; |
| 614 | Tool *buildLinker() const override; |
Chris Lattner | 38e317d | 2010-07-07 16:01:42 +0000 | [diff] [blame] | 615 | }; |
| 616 | |
Rafael Espindola | e43cfa1 | 2010-10-29 20:14:02 +0000 | [diff] [blame] | 617 | class LLVM_LIBRARY_VISIBILITY DragonFly : public Generic_ELF { |
Daniel Dunbar | 11e1b40 | 2009-05-02 18:28:39 +0000 | [diff] [blame] | 618 | public: |
Reid Kleckner | dd0b3c4 | 2013-06-17 13:59:19 +0000 | [diff] [blame] | 619 | DragonFly(const Driver &D, const llvm::Triple &Triple, |
| 620 | const llvm::opt::ArgList &Args); |
Daniel Dunbar | 11e1b40 | 2009-05-02 18:28:39 +0000 | [diff] [blame] | 621 | |
Stephen Hines | 651f13c | 2014-04-23 16:59:28 -0700 | [diff] [blame] | 622 | bool IsMathErrnoDefault() const override { return false; } |
Benjamin Kramer | 769aa2d | 2012-05-02 14:55:48 +0000 | [diff] [blame] | 623 | |
Rafael Espindola | f48b93c | 2013-03-20 03:05:54 +0000 | [diff] [blame] | 624 | protected: |
Stephen Hines | 651f13c | 2014-04-23 16:59:28 -0700 | [diff] [blame] | 625 | Tool *buildAssembler() const override; |
| 626 | Tool *buildLinker() const override; |
Daniel Dunbar | 11e1b40 | 2009-05-02 18:28:39 +0000 | [diff] [blame] | 627 | }; |
| 628 | |
Rafael Espindola | e43cfa1 | 2010-10-29 20:14:02 +0000 | [diff] [blame] | 629 | class LLVM_LIBRARY_VISIBILITY Linux : public Generic_ELF { |
Eli Friedman | 6b3454a | 2009-05-26 07:52:18 +0000 | [diff] [blame] | 630 | public: |
Reid Kleckner | dd0b3c4 | 2013-06-17 13:59:19 +0000 | [diff] [blame] | 631 | Linux(const Driver &D, const llvm::Triple &Triple, |
| 632 | const llvm::opt::ArgList &Args); |
Rafael Espindola | ba30bbe | 2010-08-10 00:25:48 +0000 | [diff] [blame] | 633 | |
Stephen Hines | 651f13c | 2014-04-23 16:59:28 -0700 | [diff] [blame] | 634 | bool HasNativeLLVMSupport() const override; |
Rafael Espindola | c1da981 | 2010-11-07 20:14:31 +0000 | [diff] [blame] | 635 | |
Stephen Hines | 651f13c | 2014-04-23 16:59:28 -0700 | [diff] [blame] | 636 | void |
Reid Kleckner | dd0b3c4 | 2013-06-17 13:59:19 +0000 | [diff] [blame] | 637 | AddClangSystemIncludeArgs(const llvm::opt::ArgList &DriverArgs, |
Stephen Hines | 651f13c | 2014-04-23 16:59:28 -0700 | [diff] [blame] | 638 | llvm::opt::ArgStringList &CC1Args) const override; |
| 639 | void |
Reid Kleckner | dd0b3c4 | 2013-06-17 13:59:19 +0000 | [diff] [blame] | 640 | AddClangCXXStdlibIncludeArgs(const llvm::opt::ArgList &DriverArgs, |
Stephen Hines | 651f13c | 2014-04-23 16:59:28 -0700 | [diff] [blame] | 641 | llvm::opt::ArgStringList &CC1Args) const override; |
| 642 | bool isPIEDefault() const override; |
Chandler Carruth | 7d7e9f9 | 2011-11-05 20:17:13 +0000 | [diff] [blame] | 643 | |
Rafael Espindola | c1da981 | 2010-11-07 20:14:31 +0000 | [diff] [blame] | 644 | std::string Linker; |
| 645 | std::vector<std::string> ExtraOpts; |
Chandler Carruth | 79cbbdc | 2011-12-17 23:10:01 +0000 | [diff] [blame] | 646 | |
Rafael Espindola | f48b93c | 2013-03-20 03:05:54 +0000 | [diff] [blame] | 647 | protected: |
Stephen Hines | 651f13c | 2014-04-23 16:59:28 -0700 | [diff] [blame] | 648 | Tool *buildAssembler() const override; |
| 649 | Tool *buildLinker() const override; |
Rafael Espindola | f48b93c | 2013-03-20 03:05:54 +0000 | [diff] [blame] | 650 | |
Chandler Carruth | 79cbbdc | 2011-12-17 23:10:01 +0000 | [diff] [blame] | 651 | private: |
Dmitri Gribenko | f2e7c35 | 2013-03-06 17:14:05 +0000 | [diff] [blame] | 652 | static bool addLibStdCXXIncludePaths(Twine Base, Twine Suffix, |
Stephen Hines | 176edba | 2014-12-01 14:53:08 -0800 | [diff] [blame] | 653 | StringRef GCCTriple, |
| 654 | StringRef GCCMultiarchTriple, |
| 655 | StringRef TargetMultiarchTriple, |
| 656 | Twine IncludeSuffix, |
Reid Kleckner | dd0b3c4 | 2013-06-17 13:59:19 +0000 | [diff] [blame] | 657 | const llvm::opt::ArgList &DriverArgs, |
| 658 | llvm::opt::ArgStringList &CC1Args); |
Simon Atanasyan | 8e8e95c | 2013-04-20 08:15:03 +0000 | [diff] [blame] | 659 | |
Simon Atanasyan | ab5df75 | 2013-10-05 14:37:55 +0000 | [diff] [blame] | 660 | std::string computeSysRoot() const; |
Eli Friedman | 6b3454a | 2009-05-26 07:52:18 +0000 | [diff] [blame] | 661 | }; |
| 662 | |
Matthew Curtis | b3489a0 | 2012-12-06 12:43:18 +0000 | [diff] [blame] | 663 | class LLVM_LIBRARY_VISIBILITY Hexagon_TC : public Linux { |
| 664 | protected: |
Matthew Curtis | b3489a0 | 2012-12-06 12:43:18 +0000 | [diff] [blame] | 665 | GCCVersion GCCLibAndIncVersion; |
Stephen Hines | 651f13c | 2014-04-23 16:59:28 -0700 | [diff] [blame] | 666 | Tool *buildAssembler() const override; |
| 667 | Tool *buildLinker() const override; |
Matthew Curtis | b3489a0 | 2012-12-06 12:43:18 +0000 | [diff] [blame] | 668 | |
| 669 | public: |
| 670 | Hexagon_TC(const Driver &D, const llvm::Triple &Triple, |
Reid Kleckner | dd0b3c4 | 2013-06-17 13:59:19 +0000 | [diff] [blame] | 671 | const llvm::opt::ArgList &Args); |
Matthew Curtis | b3489a0 | 2012-12-06 12:43:18 +0000 | [diff] [blame] | 672 | ~Hexagon_TC(); |
| 673 | |
Stephen Hines | 651f13c | 2014-04-23 16:59:28 -0700 | [diff] [blame] | 674 | void |
Reid Kleckner | dd0b3c4 | 2013-06-17 13:59:19 +0000 | [diff] [blame] | 675 | AddClangSystemIncludeArgs(const llvm::opt::ArgList &DriverArgs, |
Stephen Hines | 651f13c | 2014-04-23 16:59:28 -0700 | [diff] [blame] | 676 | llvm::opt::ArgStringList &CC1Args) const override; |
| 677 | void |
Reid Kleckner | dd0b3c4 | 2013-06-17 13:59:19 +0000 | [diff] [blame] | 678 | AddClangCXXStdlibIncludeArgs(const llvm::opt::ArgList &DriverArgs, |
Stephen Hines | 651f13c | 2014-04-23 16:59:28 -0700 | [diff] [blame] | 679 | llvm::opt::ArgStringList &CC1Args) const override; |
| 680 | CXXStdlibType GetCXXStdlibType(const llvm::opt::ArgList &Args) const override; |
Matthew Curtis | b3489a0 | 2012-12-06 12:43:18 +0000 | [diff] [blame] | 681 | |
| 682 | StringRef GetGCCLibAndIncVersion() const { return GCCLibAndIncVersion.Text; } |
| 683 | |
Stephen Hines | 176edba | 2014-12-01 14:53:08 -0800 | [diff] [blame] | 684 | static std::string GetGnuDir(const std::string &InstalledDir, |
| 685 | const llvm::opt::ArgList &Args); |
Matthew Curtis | 6781415 | 2012-12-06 14:16:43 +0000 | [diff] [blame] | 686 | |
Reid Kleckner | dd0b3c4 | 2013-06-17 13:59:19 +0000 | [diff] [blame] | 687 | static StringRef GetTargetCPU(const llvm::opt::ArgList &Args); |
Matthew Curtis | b3489a0 | 2012-12-06 12:43:18 +0000 | [diff] [blame] | 688 | }; |
Eli Friedman | 6b3454a | 2009-05-26 07:52:18 +0000 | [diff] [blame] | 689 | |
Chris Lattner | 3a47c4e | 2010-03-04 21:07:38 +0000 | [diff] [blame] | 690 | /// 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 Sands | 92dd191 | 2010-05-11 20:16:05 +0000 | [diff] [blame] | 692 | class LLVM_LIBRARY_VISIBILITY TCEToolChain : public ToolChain { |
Chris Lattner | 3a47c4e | 2010-03-04 21:07:38 +0000 | [diff] [blame] | 693 | public: |
Reid Kleckner | dd0b3c4 | 2013-06-17 13:59:19 +0000 | [diff] [blame] | 694 | TCEToolChain(const Driver &D, const llvm::Triple &Triple, |
| 695 | const llvm::opt::ArgList &Args); |
Chris Lattner | 3a47c4e | 2010-03-04 21:07:38 +0000 | [diff] [blame] | 696 | ~TCEToolChain(); |
| 697 | |
Stephen Hines | 651f13c | 2014-04-23 16:59:28 -0700 | [diff] [blame] | 698 | bool IsMathErrnoDefault() const override; |
| 699 | bool isPICDefault() const override; |
| 700 | bool isPIEDefault() const override; |
| 701 | bool isPICDefaultForced() const override; |
Chris Lattner | 3a47c4e | 2010-03-04 21:07:38 +0000 | [diff] [blame] | 702 | }; |
| 703 | |
Stephen Hines | 176edba | 2014-12-01 14:53:08 -0800 | [diff] [blame] | 704 | class LLVM_LIBRARY_VISIBILITY MSVCToolChain : public ToolChain { |
Michael J. Spencer | ff58e36 | 2010-08-21 21:55:07 +0000 | [diff] [blame] | 705 | public: |
Stephen Hines | 176edba | 2014-12-01 14:53:08 -0800 | [diff] [blame] | 706 | MSVCToolChain(const Driver &D, const llvm::Triple &Triple, |
| 707 | const llvm::opt::ArgList &Args); |
Michael J. Spencer | ff58e36 | 2010-08-21 21:55:07 +0000 | [diff] [blame] | 708 | |
Stephen Hines | 651f13c | 2014-04-23 16:59:28 -0700 | [diff] [blame] | 709 | 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 Carruth | ca23419 | 2011-11-04 23:49:05 +0000 | [diff] [blame] | 714 | |
Stephen Hines | 651f13c | 2014-04-23 16:59:28 -0700 | [diff] [blame] | 715 | void |
Reid Kleckner | dd0b3c4 | 2013-06-17 13:59:19 +0000 | [diff] [blame] | 716 | AddClangSystemIncludeArgs(const llvm::opt::ArgList &DriverArgs, |
Stephen Hines | 651f13c | 2014-04-23 16:59:28 -0700 | [diff] [blame] | 717 | llvm::opt::ArgStringList &CC1Args) const override; |
| 718 | void |
Reid Kleckner | dd0b3c4 | 2013-06-17 13:59:19 +0000 | [diff] [blame] | 719 | AddClangCXXStdlibIncludeArgs(const llvm::opt::ArgList &DriverArgs, |
Stephen Hines | 651f13c | 2014-04-23 16:59:28 -0700 | [diff] [blame] | 720 | llvm::opt::ArgStringList &CC1Args) const override; |
Reid Kleckner | dd0b3c4 | 2013-06-17 13:59:19 +0000 | [diff] [blame] | 721 | |
Stephen Hines | 176edba | 2014-12-01 14:53:08 -0800 | [diff] [blame] | 722 | 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 Espindola | f48b93c | 2013-03-20 03:05:54 +0000 | [diff] [blame] | 728 | protected: |
Stephen Hines | 176edba | 2014-12-01 14:53:08 -0800 | [diff] [blame] | 729 | void AddSystemIncludeWithSubfolder(const llvm::opt::ArgList &DriverArgs, |
| 730 | llvm::opt::ArgStringList &CC1Args, |
| 731 | const std::string &folder, |
| 732 | const char *subfolder) const; |
| 733 | |
Stephen Hines | 651f13c | 2014-04-23 16:59:28 -0700 | [diff] [blame] | 734 | Tool *buildLinker() const override; |
| 735 | Tool *buildAssembler() const override; |
Michael J. Spencer | ff58e36 | 2010-08-21 21:55:07 +0000 | [diff] [blame] | 736 | }; |
| 737 | |
Stephen Hines | 176edba | 2014-12-01 14:53:08 -0800 | [diff] [blame] | 738 | class LLVM_LIBRARY_VISIBILITY CrossWindowsToolChain : public Generic_GCC { |
| 739 | public: |
| 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 | |
| 762 | protected: |
| 763 | Tool *buildLinker() const override; |
| 764 | Tool *buildAssembler() const override; |
| 765 | }; |
Robert Lytton | 4e490e2 | 2013-10-11 10:29:40 +0000 | [diff] [blame] | 766 | |
| 767 | class LLVM_LIBRARY_VISIBILITY XCore : public ToolChain { |
| 768 | public: |
| 769 | XCore(const Driver &D, const llvm::Triple &Triple, |
| 770 | const llvm::opt::ArgList &Args); |
| 771 | protected: |
Stephen Hines | 651f13c | 2014-04-23 16:59:28 -0700 | [diff] [blame] | 772 | Tool *buildAssembler() const override; |
| 773 | Tool *buildLinker() const override; |
Robert Lytton | 4e490e2 | 2013-10-11 10:29:40 +0000 | [diff] [blame] | 774 | public: |
Stephen Hines | 651f13c | 2014-04-23 16:59:28 -0700 | [diff] [blame] | 775 | 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 Lytton | 4e490e2 | 2013-10-11 10:29:40 +0000 | [diff] [blame] | 788 | }; |
| 789 | |
Daniel Dunbar | 83b08eb | 2009-03-17 21:38:00 +0000 | [diff] [blame] | 790 | } // end namespace toolchains |
| 791 | } // end namespace driver |
| 792 | } // end namespace clang |
| 793 | |
| 794 | #endif |