blob: fc320198039669d4609743c5a0d2498cad12e73f [file] [log] [blame]
Daniel Dunbar83b08eb2009-03-17 21:38:00 +00001//===--- ToolChains.h - ToolChain Implementations ---------------*- C++ -*-===//
2//
3// The LLVM Compiler Infrastructure
4//
5// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
7//
8//===----------------------------------------------------------------------===//
9
10#ifndef CLANG_LIB_DRIVER_TOOLCHAINS_H_
11#define CLANG_LIB_DRIVER_TOOLCHAINS_H_
12
Daniel Dunbar670b7f42009-03-17 22:07:31 +000013#include "clang/Driver/Action.h"
Daniel Dunbar83b08eb2009-03-17 21:38:00 +000014#include "clang/Driver/ToolChain.h"
15
Daniel Dunbar670b7f42009-03-17 22:07:31 +000016#include "llvm/ADT/DenseMap.h"
Daniel Dunbar83b08eb2009-03-17 21:38:00 +000017#include "llvm/Support/Compiler.h"
18
Daniel Dunbar670b7f42009-03-17 22:07:31 +000019#include "Tools.h"
20
Daniel Dunbar83b08eb2009-03-17 21:38:00 +000021namespace clang {
22namespace driver {
Daniel Dunbar985b8252009-03-17 22:18:43 +000023namespace toolchains {
Daniel Dunbar83b08eb2009-03-17 21:38:00 +000024
Daniel Dunbar670b7f42009-03-17 22:07:31 +000025 /// 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 Dunbar985b8252009-03-17 22:18:43 +000028class VISIBILITY_HIDDEN Generic_GCC : public ToolChain {
Daniel Dunbar75358d22009-03-30 21:06:03 +000029protected:
Daniel Dunbar670b7f42009-03-17 22:07:31 +000030 mutable llvm::DenseMap<unsigned, Tool*> Tools;
31
Daniel Dunbar83b08eb2009-03-17 21:38:00 +000032public:
Daniel Dunbarcb8ab232009-05-22 02:53:45 +000033 Generic_GCC(const HostInfo &Host, const llvm::Triple& Triple);
Daniel Dunbar39176082009-03-20 00:20:03 +000034 ~Generic_GCC();
Daniel Dunbar83b08eb2009-03-17 21:38:00 +000035
Daniel Dunbar0dcb9a32009-09-09 18:36:12 +000036 virtual DerivedArgList *TranslateArgs(InputArgList &Args,
37 const char *BoundArch) const;
Daniel Dunbar83b08eb2009-03-17 21:38:00 +000038
Daniel Dunbar39176082009-03-20 00:20:03 +000039 virtual Tool &SelectTool(const Compilation &C, const JobAction &JA) const;
Daniel Dunbar670b7f42009-03-17 22:07:31 +000040
Daniel Dunbar39176082009-03-20 00:20:03 +000041 virtual bool IsMathErrnoDefault() const;
42 virtual bool IsUnwindTablesDefault() const;
43 virtual const char *GetDefaultRelocationModel() const;
44 virtual const char *GetForcedPicModel() const;
Daniel Dunbar83b08eb2009-03-17 21:38:00 +000045};
46
Daniel Dunbarf3955282009-09-04 18:34:51 +000047/// Darwin - Darwin tool chain.
48class VISIBILITY_HIDDEN Darwin : public ToolChain {
Daniel Dunbar8eddb3f2009-03-20 00:57:52 +000049 mutable llvm::DenseMap<unsigned, Tool*> Tools;
50
Daniel Dunbarc50b00d2009-03-23 16:15:50 +000051 /// Darwin version of tool chain.
52 unsigned DarwinVersion[3];
53
54 /// GCC version to use.
55 unsigned GCCVersion[3];
56
Daniel Dunbar30392de2009-09-04 18:35:21 +000057 /// Whether this is this an iPhone toolchain.
58 bool IsIPhone;
59
Daniel Dunbarc50b00d2009-03-23 16:15:50 +000060 /// The directory suffix for this tool chain.
61 std::string ToolChainDir;
62
Daniel Dunbar02633b52009-03-26 16:23:12 +000063 /// The default macosx-version-min of this tool chain; empty until
64 /// initialized.
65 mutable std::string MacosxVersionMin;
66
Daniel Dunbar30392de2009-09-04 18:35:21 +000067 /// The default iphoneos-version-min of this tool chain.
68 std::string IPhoneOSVersionMin;
69
Daniel Dunbar02633b52009-03-26 16:23:12 +000070 const char *getMacosxVersionMin() const;
Daniel Dunbarec069ed2009-03-25 06:58:31 +000071
Daniel Dunbar8eddb3f2009-03-20 00:57:52 +000072public:
Mike Stump1eb44332009-09-09 15:08:12 +000073 Darwin(const HostInfo &Host, const llvm::Triple& Triple,
Daniel Dunbar30392de2009-09-04 18:35:21 +000074 const unsigned (&DarwinVersion)[3],
75 const unsigned (&GCCVersion)[3],
76 bool IsIPhone);
Daniel Dunbarf3955282009-09-04 18:34:51 +000077 ~Darwin();
Daniel Dunbar8eddb3f2009-03-20 00:57:52 +000078
Daniel Dunbar6b200b22009-09-18 08:14:36 +000079 /// @name Darwin Specific Toolchain API
80 /// {
81
Daniel Dunbar02633b52009-03-26 16:23:12 +000082 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
94 const char *getMacosxVersionStr() const {
95 return MacosxVersionMin.c_str();
96 }
97
Daniel Dunbar30392de2009-09-04 18:35:21 +000098 const char *getIPhoneOSVersionStr() const {
99 return IPhoneOSVersionMin.c_str();
100 }
101
Daniel Dunbar6b200b22009-09-18 08:14:36 +0000102 /// AddLinkSearchPathArgs - Add the linker search paths to \arg CmdArgs.
103 ///
104 /// \param Args - The input argument list.
105 /// \param CmdArgs [out] - The command argument list to append the paths
106 /// (prefixed by -L) to.
107 void AddLinkSearchPathArgs(const ArgList &Args, ArgStringList &CmdArgs) const;
Daniel Dunbar02633b52009-03-26 16:23:12 +0000108
Daniel Dunbar30392de2009-09-04 18:35:21 +0000109 bool isIPhone() const { return IsIPhone; }
110
Daniel Dunbar6b200b22009-09-18 08:14:36 +0000111 /// }
112 /// @name ToolChain Implementation
113 /// {
114
Daniel Dunbar0dcb9a32009-09-09 18:36:12 +0000115 virtual DerivedArgList *TranslateArgs(InputArgList &Args,
116 const char *BoundArch) const;
Daniel Dunbar8eddb3f2009-03-20 00:57:52 +0000117
118 virtual Tool &SelectTool(const Compilation &C, const JobAction &JA) const;
119
120 virtual bool IsMathErrnoDefault() const;
121 virtual bool IsUnwindTablesDefault() const;
122 virtual const char *GetDefaultRelocationModel() const;
123 virtual const char *GetForcedPicModel() const;
Daniel Dunbar6b200b22009-09-18 08:14:36 +0000124
125 /// }
Daniel Dunbar8eddb3f2009-03-20 00:57:52 +0000126};
127
128 /// Darwin_GCC - Generic Darwin tool chain using gcc.
129class VISIBILITY_HIDDEN Darwin_GCC : public Generic_GCC {
130public:
Mike Stump1eb44332009-09-09 15:08:12 +0000131 Darwin_GCC(const HostInfo &Host, const llvm::Triple& Triple)
Daniel Dunbarcb8ab232009-05-22 02:53:45 +0000132 : Generic_GCC(Host, Triple) {}
Daniel Dunbar8eddb3f2009-03-20 00:57:52 +0000133
134 virtual const char *GetDefaultRelocationModel() const { return "pic"; }
135};
136
Edward O'Callaghane7925a02009-08-22 01:06:46 +0000137class VISIBILITY_HIDDEN AuroraUX : public Generic_GCC {
138public:
139 AuroraUX(const HostInfo &Host, const llvm::Triple& Triple);
140
141 virtual Tool &SelectTool(const Compilation &C, const JobAction &JA) const;
142};
143
Daniel Dunbarf7b8eec2009-06-29 20:52:51 +0000144class VISIBILITY_HIDDEN OpenBSD : public Generic_GCC {
145public:
146 OpenBSD(const HostInfo &Host, const llvm::Triple& Triple);
147
148 virtual Tool &SelectTool(const Compilation &C, const JobAction &JA) const;
149};
150
Daniel Dunbar75358d22009-03-30 21:06:03 +0000151class VISIBILITY_HIDDEN FreeBSD : public Generic_GCC {
152public:
Daniel Dunbarcb8ab232009-05-22 02:53:45 +0000153 FreeBSD(const HostInfo &Host, const llvm::Triple& Triple, bool Lib32);
Daniel Dunbar75358d22009-03-30 21:06:03 +0000154
155 virtual Tool &SelectTool(const Compilation &C, const JobAction &JA) const;
156};
157
Daniel Dunbar11e1b402009-05-02 18:28:39 +0000158class VISIBILITY_HIDDEN DragonFly : public Generic_GCC {
159public:
Daniel Dunbarcb8ab232009-05-22 02:53:45 +0000160 DragonFly(const HostInfo &Host, const llvm::Triple& Triple);
Daniel Dunbar11e1b402009-05-02 18:28:39 +0000161
162 virtual Tool &SelectTool(const Compilation &C, const JobAction &JA) const;
163};
164
Eli Friedman6b3454a2009-05-26 07:52:18 +0000165class VISIBILITY_HIDDEN Linux : public Generic_GCC {
166public:
167 Linux(const HostInfo &Host, const llvm::Triple& Triple);
168};
169
170
Daniel Dunbar83b08eb2009-03-17 21:38:00 +0000171} // end namespace toolchains
172} // end namespace driver
173} // end namespace clang
174
175#endif