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 | |
| 10 | #ifndef CLANG_LIB_DRIVER_TOOLCHAINS_H_ |
| 11 | #define CLANG_LIB_DRIVER_TOOLCHAINS_H_ |
| 12 | |
Daniel Dunbar | 670b7f4 | 2009-03-17 22:07:31 +0000 | [diff] [blame] | 13 | #include "clang/Driver/Action.h" |
Daniel Dunbar | 83b08eb | 2009-03-17 21:38:00 +0000 | [diff] [blame] | 14 | #include "clang/Driver/ToolChain.h" |
| 15 | |
Daniel Dunbar | 670b7f4 | 2009-03-17 22:07:31 +0000 | [diff] [blame] | 16 | #include "llvm/ADT/DenseMap.h" |
Daniel Dunbar | 83b08eb | 2009-03-17 21:38:00 +0000 | [diff] [blame] | 17 | #include "llvm/Support/Compiler.h" |
| 18 | |
Daniel Dunbar | 670b7f4 | 2009-03-17 22:07:31 +0000 | [diff] [blame] | 19 | #include "Tools.h" |
| 20 | |
Daniel Dunbar | 83b08eb | 2009-03-17 21:38:00 +0000 | [diff] [blame] | 21 | namespace clang { |
| 22 | namespace driver { |
Daniel Dunbar | 985b825 | 2009-03-17 22:18:43 +0000 | [diff] [blame] | 23 | namespace toolchains { |
Daniel Dunbar | 83b08eb | 2009-03-17 21:38:00 +0000 | [diff] [blame] | 24 | |
Daniel Dunbar | 670b7f4 | 2009-03-17 22:07:31 +0000 | [diff] [blame] | 25 | /// Generic_GCC - A tool chain using the 'gcc' command to perform |
| 26 | /// all subcommands; this relies on gcc translating the majority of |
| 27 | /// command line options. |
Daniel Dunbar | 985b825 | 2009-03-17 22:18:43 +0000 | [diff] [blame] | 28 | class VISIBILITY_HIDDEN Generic_GCC : public ToolChain { |
Daniel Dunbar | 75358d2 | 2009-03-30 21:06:03 +0000 | [diff] [blame] | 29 | protected: |
Daniel Dunbar | 670b7f4 | 2009-03-17 22:07:31 +0000 | [diff] [blame] | 30 | mutable llvm::DenseMap<unsigned, Tool*> Tools; |
| 31 | |
Daniel Dunbar | 83b08eb | 2009-03-17 21:38:00 +0000 | [diff] [blame] | 32 | public: |
Daniel Dunbar | cb8ab23 | 2009-05-22 02:53:45 +0000 | [diff] [blame] | 33 | Generic_GCC(const HostInfo &Host, const llvm::Triple& Triple); |
Daniel Dunbar | 3917608 | 2009-03-20 00:20:03 +0000 | [diff] [blame] | 34 | ~Generic_GCC(); |
Daniel Dunbar | 83b08eb | 2009-03-17 21:38:00 +0000 | [diff] [blame] | 35 | |
Daniel Dunbar | 0dcb9a3 | 2009-09-09 18:36:12 +0000 | [diff] [blame] | 36 | virtual DerivedArgList *TranslateArgs(InputArgList &Args, |
| 37 | const char *BoundArch) const; |
Daniel Dunbar | 83b08eb | 2009-03-17 21:38:00 +0000 | [diff] [blame] | 38 | |
Daniel Dunbar | 3917608 | 2009-03-20 00:20:03 +0000 | [diff] [blame] | 39 | virtual Tool &SelectTool(const Compilation &C, const JobAction &JA) const; |
Daniel Dunbar | 670b7f4 | 2009-03-17 22:07:31 +0000 | [diff] [blame] | 40 | |
Daniel Dunbar | 3917608 | 2009-03-20 00:20:03 +0000 | [diff] [blame] | 41 | virtual bool IsMathErrnoDefault() const; |
| 42 | virtual bool IsUnwindTablesDefault() const; |
| 43 | virtual const char *GetDefaultRelocationModel() const; |
| 44 | virtual const char *GetForcedPicModel() const; |
Daniel Dunbar | 83b08eb | 2009-03-17 21:38:00 +0000 | [diff] [blame] | 45 | }; |
| 46 | |
Daniel Dunbar | f395528 | 2009-09-04 18:34:51 +0000 | [diff] [blame] | 47 | /// Darwin - Darwin tool chain. |
| 48 | class VISIBILITY_HIDDEN Darwin : public ToolChain { |
Daniel Dunbar | 8eddb3f | 2009-03-20 00:57:52 +0000 | [diff] [blame] | 49 | mutable llvm::DenseMap<unsigned, Tool*> Tools; |
| 50 | |
Daniel Dunbar | c50b00d | 2009-03-23 16:15:50 +0000 | [diff] [blame] | 51 | /// Darwin version of tool chain. |
| 52 | unsigned DarwinVersion[3]; |
| 53 | |
| 54 | /// GCC version to use. |
| 55 | unsigned GCCVersion[3]; |
| 56 | |
Daniel Dunbar | 30392de | 2009-09-04 18:35:21 +0000 | [diff] [blame] | 57 | /// Whether this is this an iPhone toolchain. |
| 58 | bool IsIPhone; |
| 59 | |
Daniel Dunbar | c50b00d | 2009-03-23 16:15:50 +0000 | [diff] [blame] | 60 | /// The directory suffix for this tool chain. |
| 61 | std::string ToolChainDir; |
| 62 | |
Daniel Dunbar | 02633b5 | 2009-03-26 16:23:12 +0000 | [diff] [blame] | 63 | /// The default macosx-version-min of this tool chain; empty until |
| 64 | /// initialized. |
| 65 | mutable std::string MacosxVersionMin; |
| 66 | |
Daniel Dunbar | 30392de | 2009-09-04 18:35:21 +0000 | [diff] [blame] | 67 | /// The default iphoneos-version-min of this tool chain. |
| 68 | std::string IPhoneOSVersionMin; |
| 69 | |
Daniel Dunbar | 02633b5 | 2009-03-26 16:23:12 +0000 | [diff] [blame] | 70 | const char *getMacosxVersionMin() const; |
Daniel Dunbar | ec069ed | 2009-03-25 06:58:31 +0000 | [diff] [blame] | 71 | |
Daniel Dunbar | 8eddb3f | 2009-03-20 00:57:52 +0000 | [diff] [blame] | 72 | public: |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 73 | Darwin(const HostInfo &Host, const llvm::Triple& Triple, |
Daniel Dunbar | 30392de | 2009-09-04 18:35:21 +0000 | [diff] [blame] | 74 | const unsigned (&DarwinVersion)[3], |
| 75 | const unsigned (&GCCVersion)[3], |
| 76 | bool IsIPhone); |
Daniel Dunbar | f395528 | 2009-09-04 18:34:51 +0000 | [diff] [blame] | 77 | ~Darwin(); |
Daniel Dunbar | 8eddb3f | 2009-03-20 00:57:52 +0000 | [diff] [blame] | 78 | |
Daniel Dunbar | 6b200b2 | 2009-09-18 08:14:36 +0000 | [diff] [blame] | 79 | /// @name Darwin Specific Toolchain API |
| 80 | /// { |
| 81 | |
Daniel Dunbar | 02633b5 | 2009-03-26 16:23:12 +0000 | [diff] [blame] | 82 | void getDarwinVersion(unsigned (&Res)[3]) const { |
| 83 | Res[0] = DarwinVersion[0]; |
| 84 | Res[1] = DarwinVersion[1]; |
| 85 | Res[2] = DarwinVersion[2]; |
| 86 | } |
| 87 | |
| 88 | void getMacosxVersion(unsigned (&Res)[3]) const { |
| 89 | Res[0] = 10; |
| 90 | Res[1] = DarwinVersion[0] - 4; |
| 91 | Res[2] = DarwinVersion[1]; |
| 92 | } |
| 93 | |
Daniel Dunbar | 48d5aae | 2009-09-18 08:14:46 +0000 | [diff] [blame^] | 94 | /// getMacosxVersionMin - Get the effective -mmacosx-version-min, which is |
| 95 | /// either the -mmacosx-version-min, or the current version if unspecified. |
| 96 | void getMacosxVersionMin(const ArgList &Args, unsigned (&Res)[3]) const; |
| 97 | |
Daniel Dunbar | 02633b5 | 2009-03-26 16:23:12 +0000 | [diff] [blame] | 98 | const char *getMacosxVersionStr() const { |
| 99 | return MacosxVersionMin.c_str(); |
| 100 | } |
| 101 | |
Daniel Dunbar | 30392de | 2009-09-04 18:35:21 +0000 | [diff] [blame] | 102 | const char *getIPhoneOSVersionStr() const { |
| 103 | return IPhoneOSVersionMin.c_str(); |
| 104 | } |
| 105 | |
Daniel Dunbar | 6b200b2 | 2009-09-18 08:14:36 +0000 | [diff] [blame] | 106 | /// AddLinkSearchPathArgs - Add the linker search paths to \arg CmdArgs. |
| 107 | /// |
| 108 | /// \param Args - The input argument list. |
| 109 | /// \param CmdArgs [out] - The command argument list to append the paths |
| 110 | /// (prefixed by -L) to. |
| 111 | void AddLinkSearchPathArgs(const ArgList &Args, ArgStringList &CmdArgs) const; |
Daniel Dunbar | 02633b5 | 2009-03-26 16:23:12 +0000 | [diff] [blame] | 112 | |
Daniel Dunbar | 30392de | 2009-09-04 18:35:21 +0000 | [diff] [blame] | 113 | bool isIPhone() const { return IsIPhone; } |
| 114 | |
Daniel Dunbar | 6b200b2 | 2009-09-18 08:14:36 +0000 | [diff] [blame] | 115 | /// } |
| 116 | /// @name ToolChain Implementation |
| 117 | /// { |
| 118 | |
Daniel Dunbar | 0dcb9a3 | 2009-09-09 18:36:12 +0000 | [diff] [blame] | 119 | virtual DerivedArgList *TranslateArgs(InputArgList &Args, |
| 120 | const char *BoundArch) const; |
Daniel Dunbar | 8eddb3f | 2009-03-20 00:57:52 +0000 | [diff] [blame] | 121 | |
| 122 | virtual Tool &SelectTool(const Compilation &C, const JobAction &JA) const; |
| 123 | |
| 124 | virtual bool IsMathErrnoDefault() const; |
| 125 | virtual bool IsUnwindTablesDefault() const; |
| 126 | virtual const char *GetDefaultRelocationModel() const; |
| 127 | virtual const char *GetForcedPicModel() const; |
Daniel Dunbar | 6b200b2 | 2009-09-18 08:14:36 +0000 | [diff] [blame] | 128 | |
| 129 | /// } |
Daniel Dunbar | 8eddb3f | 2009-03-20 00:57:52 +0000 | [diff] [blame] | 130 | }; |
| 131 | |
| 132 | /// Darwin_GCC - Generic Darwin tool chain using gcc. |
| 133 | class VISIBILITY_HIDDEN Darwin_GCC : public Generic_GCC { |
| 134 | public: |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 135 | Darwin_GCC(const HostInfo &Host, const llvm::Triple& Triple) |
Daniel Dunbar | cb8ab23 | 2009-05-22 02:53:45 +0000 | [diff] [blame] | 136 | : Generic_GCC(Host, Triple) {} |
Daniel Dunbar | 8eddb3f | 2009-03-20 00:57:52 +0000 | [diff] [blame] | 137 | |
| 138 | virtual const char *GetDefaultRelocationModel() const { return "pic"; } |
| 139 | }; |
| 140 | |
Edward O'Callaghan | e7925a0 | 2009-08-22 01:06:46 +0000 | [diff] [blame] | 141 | class VISIBILITY_HIDDEN AuroraUX : public Generic_GCC { |
| 142 | public: |
| 143 | AuroraUX(const HostInfo &Host, const llvm::Triple& Triple); |
| 144 | |
| 145 | virtual Tool &SelectTool(const Compilation &C, const JobAction &JA) const; |
| 146 | }; |
| 147 | |
Daniel Dunbar | f7b8eec | 2009-06-29 20:52:51 +0000 | [diff] [blame] | 148 | class VISIBILITY_HIDDEN OpenBSD : public Generic_GCC { |
| 149 | public: |
| 150 | OpenBSD(const HostInfo &Host, const llvm::Triple& Triple); |
| 151 | |
| 152 | virtual Tool &SelectTool(const Compilation &C, const JobAction &JA) const; |
| 153 | }; |
| 154 | |
Daniel Dunbar | 75358d2 | 2009-03-30 21:06:03 +0000 | [diff] [blame] | 155 | class VISIBILITY_HIDDEN FreeBSD : public Generic_GCC { |
| 156 | public: |
Daniel Dunbar | cb8ab23 | 2009-05-22 02:53:45 +0000 | [diff] [blame] | 157 | FreeBSD(const HostInfo &Host, const llvm::Triple& Triple, bool Lib32); |
Daniel Dunbar | 75358d2 | 2009-03-30 21:06:03 +0000 | [diff] [blame] | 158 | |
| 159 | virtual Tool &SelectTool(const Compilation &C, const JobAction &JA) const; |
| 160 | }; |
| 161 | |
Daniel Dunbar | 11e1b40 | 2009-05-02 18:28:39 +0000 | [diff] [blame] | 162 | class VISIBILITY_HIDDEN DragonFly : public Generic_GCC { |
| 163 | public: |
Daniel Dunbar | cb8ab23 | 2009-05-22 02:53:45 +0000 | [diff] [blame] | 164 | DragonFly(const HostInfo &Host, const llvm::Triple& Triple); |
Daniel Dunbar | 11e1b40 | 2009-05-02 18:28:39 +0000 | [diff] [blame] | 165 | |
| 166 | virtual Tool &SelectTool(const Compilation &C, const JobAction &JA) const; |
| 167 | }; |
| 168 | |
Eli Friedman | 6b3454a | 2009-05-26 07:52:18 +0000 | [diff] [blame] | 169 | class VISIBILITY_HIDDEN Linux : public Generic_GCC { |
| 170 | public: |
| 171 | Linux(const HostInfo &Host, const llvm::Triple& Triple); |
| 172 | }; |
| 173 | |
| 174 | |
Daniel Dunbar | 83b08eb | 2009-03-17 21:38:00 +0000 | [diff] [blame] | 175 | } // end namespace toolchains |
| 176 | } // end namespace driver |
| 177 | } // end namespace clang |
| 178 | |
| 179 | #endif |