blob: 0e5ce348841754f1ef1ba6f10306e7bd29e8e3f6 [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 Dunbar02633b52009-03-26 16:23:12 +000079 void getDarwinVersion(unsigned (&Res)[3]) const {
80 Res[0] = DarwinVersion[0];
81 Res[1] = DarwinVersion[1];
82 Res[2] = DarwinVersion[2];
83 }
84
85 void getMacosxVersion(unsigned (&Res)[3]) const {
86 Res[0] = 10;
87 Res[1] = DarwinVersion[0] - 4;
88 Res[2] = DarwinVersion[1];
89 }
90
91 const char *getMacosxVersionStr() const {
92 return MacosxVersionMin.c_str();
93 }
94
Daniel Dunbar30392de2009-09-04 18:35:21 +000095 const char *getIPhoneOSVersionStr() const {
96 return IPhoneOSVersionMin.c_str();
97 }
98
Mike Stump1eb44332009-09-09 15:08:12 +000099 const std::string &getToolChainDir() const {
Daniel Dunbar02633b52009-03-26 16:23:12 +0000100 return ToolChainDir;
101 }
102
Daniel Dunbar30392de2009-09-04 18:35:21 +0000103 bool isIPhone() const { return IsIPhone; }
104
Daniel Dunbar0dcb9a32009-09-09 18:36:12 +0000105 virtual DerivedArgList *TranslateArgs(InputArgList &Args,
106 const char *BoundArch) const;
Daniel Dunbar8eddb3f2009-03-20 00:57:52 +0000107
108 virtual Tool &SelectTool(const Compilation &C, const JobAction &JA) const;
109
110 virtual bool IsMathErrnoDefault() const;
111 virtual bool IsUnwindTablesDefault() const;
112 virtual const char *GetDefaultRelocationModel() const;
113 virtual const char *GetForcedPicModel() const;
114};
115
116 /// Darwin_GCC - Generic Darwin tool chain using gcc.
117class VISIBILITY_HIDDEN Darwin_GCC : public Generic_GCC {
118public:
Mike Stump1eb44332009-09-09 15:08:12 +0000119 Darwin_GCC(const HostInfo &Host, const llvm::Triple& Triple)
Daniel Dunbarcb8ab232009-05-22 02:53:45 +0000120 : Generic_GCC(Host, Triple) {}
Daniel Dunbar8eddb3f2009-03-20 00:57:52 +0000121
122 virtual const char *GetDefaultRelocationModel() const { return "pic"; }
123};
124
Edward O'Callaghane7925a02009-08-22 01:06:46 +0000125class VISIBILITY_HIDDEN AuroraUX : public Generic_GCC {
126public:
127 AuroraUX(const HostInfo &Host, const llvm::Triple& Triple);
128
129 virtual Tool &SelectTool(const Compilation &C, const JobAction &JA) const;
130};
131
Daniel Dunbarf7b8eec2009-06-29 20:52:51 +0000132class VISIBILITY_HIDDEN OpenBSD : public Generic_GCC {
133public:
134 OpenBSD(const HostInfo &Host, const llvm::Triple& Triple);
135
136 virtual Tool &SelectTool(const Compilation &C, const JobAction &JA) const;
137};
138
Daniel Dunbar75358d22009-03-30 21:06:03 +0000139class VISIBILITY_HIDDEN FreeBSD : public Generic_GCC {
140public:
Daniel Dunbarcb8ab232009-05-22 02:53:45 +0000141 FreeBSD(const HostInfo &Host, const llvm::Triple& Triple, bool Lib32);
Daniel Dunbar75358d22009-03-30 21:06:03 +0000142
143 virtual Tool &SelectTool(const Compilation &C, const JobAction &JA) const;
144};
145
Daniel Dunbar11e1b402009-05-02 18:28:39 +0000146class VISIBILITY_HIDDEN DragonFly : public Generic_GCC {
147public:
Daniel Dunbarcb8ab232009-05-22 02:53:45 +0000148 DragonFly(const HostInfo &Host, const llvm::Triple& Triple);
Daniel Dunbar11e1b402009-05-02 18:28:39 +0000149
150 virtual Tool &SelectTool(const Compilation &C, const JobAction &JA) const;
151};
152
Eli Friedman6b3454a2009-05-26 07:52:18 +0000153class VISIBILITY_HIDDEN Linux : public Generic_GCC {
154public:
155 Linux(const HostInfo &Host, const llvm::Triple& Triple);
156};
157
158
Daniel Dunbar83b08eb2009-03-17 21:38:00 +0000159} // end namespace toolchains
160} // end namespace driver
161} // end namespace clang
162
163#endif