blob: b0cc9cbecdb622ac11bb898c99771e3d134887c7 [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 Dunbarf3cad362009-03-25 04:13:45 +000036 virtual DerivedArgList *TranslateArgs(InputArgList &Args) const;
Daniel Dunbar83b08eb2009-03-17 21:38:00 +000037
Daniel Dunbar39176082009-03-20 00:20:03 +000038 virtual Tool &SelectTool(const Compilation &C, const JobAction &JA) const;
Daniel Dunbar670b7f42009-03-17 22:07:31 +000039
Daniel Dunbar39176082009-03-20 00:20:03 +000040 virtual bool IsMathErrnoDefault() const;
41 virtual bool IsUnwindTablesDefault() const;
42 virtual const char *GetDefaultRelocationModel() const;
43 virtual const char *GetForcedPicModel() const;
Daniel Dunbar83b08eb2009-03-17 21:38:00 +000044};
45
Daniel Dunbarf3955282009-09-04 18:34:51 +000046/// Darwin - Darwin tool chain.
47class VISIBILITY_HIDDEN Darwin : public ToolChain {
Daniel Dunbar8eddb3f2009-03-20 00:57:52 +000048 mutable llvm::DenseMap<unsigned, Tool*> Tools;
49
Daniel Dunbarc50b00d2009-03-23 16:15:50 +000050 /// Darwin version of tool chain.
51 unsigned DarwinVersion[3];
52
53 /// GCC version to use.
54 unsigned GCCVersion[3];
55
Daniel Dunbar30392de2009-09-04 18:35:21 +000056 /// Whether this is this an iPhone toolchain.
57 bool IsIPhone;
58
Daniel Dunbarc50b00d2009-03-23 16:15:50 +000059 /// The directory suffix for this tool chain.
60 std::string ToolChainDir;
61
Daniel Dunbar02633b52009-03-26 16:23:12 +000062 /// The default macosx-version-min of this tool chain; empty until
63 /// initialized.
64 mutable std::string MacosxVersionMin;
65
Daniel Dunbar30392de2009-09-04 18:35:21 +000066 /// The default iphoneos-version-min of this tool chain.
67 std::string IPhoneOSVersionMin;
68
Daniel Dunbar02633b52009-03-26 16:23:12 +000069 const char *getMacosxVersionMin() const;
Daniel Dunbarec069ed2009-03-25 06:58:31 +000070
Daniel Dunbar8eddb3f2009-03-20 00:57:52 +000071public:
Daniel Dunbarf3955282009-09-04 18:34:51 +000072 Darwin(const HostInfo &Host, const llvm::Triple& Triple,
Daniel Dunbar30392de2009-09-04 18:35:21 +000073 const unsigned (&DarwinVersion)[3],
74 const unsigned (&GCCVersion)[3],
75 bool IsIPhone);
Daniel Dunbarf3955282009-09-04 18:34:51 +000076 ~Darwin();
Daniel Dunbar8eddb3f2009-03-20 00:57:52 +000077
Daniel Dunbar02633b52009-03-26 16:23:12 +000078 void getDarwinVersion(unsigned (&Res)[3]) const {
79 Res[0] = DarwinVersion[0];
80 Res[1] = DarwinVersion[1];
81 Res[2] = DarwinVersion[2];
82 }
83
84 void getMacosxVersion(unsigned (&Res)[3]) const {
85 Res[0] = 10;
86 Res[1] = DarwinVersion[0] - 4;
87 Res[2] = DarwinVersion[1];
88 }
89
90 const char *getMacosxVersionStr() const {
91 return MacosxVersionMin.c_str();
92 }
93
Daniel Dunbar30392de2009-09-04 18:35:21 +000094 const char *getIPhoneOSVersionStr() const {
95 return IPhoneOSVersionMin.c_str();
96 }
97
Daniel Dunbar02633b52009-03-26 16:23:12 +000098 const std::string &getToolChainDir() const {
99 return ToolChainDir;
100 }
101
Daniel Dunbar30392de2009-09-04 18:35:21 +0000102 bool isIPhone() const { return IsIPhone; }
103
Daniel Dunbarf3cad362009-03-25 04:13:45 +0000104 virtual DerivedArgList *TranslateArgs(InputArgList &Args) const;
Daniel Dunbar8eddb3f2009-03-20 00:57:52 +0000105
106 virtual Tool &SelectTool(const Compilation &C, const JobAction &JA) const;
107
108 virtual bool IsMathErrnoDefault() const;
109 virtual bool IsUnwindTablesDefault() const;
110 virtual const char *GetDefaultRelocationModel() const;
111 virtual const char *GetForcedPicModel() const;
112};
113
114 /// Darwin_GCC - Generic Darwin tool chain using gcc.
115class VISIBILITY_HIDDEN Darwin_GCC : public Generic_GCC {
116public:
Daniel Dunbarcb8ab232009-05-22 02:53:45 +0000117 Darwin_GCC(const HostInfo &Host, const llvm::Triple& Triple)
118 : Generic_GCC(Host, Triple) {}
Daniel Dunbar8eddb3f2009-03-20 00:57:52 +0000119
120 virtual const char *GetDefaultRelocationModel() const { return "pic"; }
121};
122
Edward O'Callaghane7925a02009-08-22 01:06:46 +0000123class VISIBILITY_HIDDEN AuroraUX : public Generic_GCC {
124public:
125 AuroraUX(const HostInfo &Host, const llvm::Triple& Triple);
126
127 virtual Tool &SelectTool(const Compilation &C, const JobAction &JA) const;
128};
129
Daniel Dunbarf7b8eec2009-06-29 20:52:51 +0000130class VISIBILITY_HIDDEN OpenBSD : public Generic_GCC {
131public:
132 OpenBSD(const HostInfo &Host, const llvm::Triple& Triple);
133
134 virtual Tool &SelectTool(const Compilation &C, const JobAction &JA) const;
135};
136
Daniel Dunbar75358d22009-03-30 21:06:03 +0000137class VISIBILITY_HIDDEN FreeBSD : public Generic_GCC {
138public:
Daniel Dunbarcb8ab232009-05-22 02:53:45 +0000139 FreeBSD(const HostInfo &Host, const llvm::Triple& Triple, bool Lib32);
Daniel Dunbar75358d22009-03-30 21:06:03 +0000140
141 virtual Tool &SelectTool(const Compilation &C, const JobAction &JA) const;
142};
143
Daniel Dunbar11e1b402009-05-02 18:28:39 +0000144class VISIBILITY_HIDDEN DragonFly : public Generic_GCC {
145public:
Daniel Dunbarcb8ab232009-05-22 02:53:45 +0000146 DragonFly(const HostInfo &Host, const llvm::Triple& Triple);
Daniel Dunbar11e1b402009-05-02 18:28:39 +0000147
148 virtual Tool &SelectTool(const Compilation &C, const JobAction &JA) const;
149};
150
Eli Friedman6b3454a2009-05-26 07:52:18 +0000151class VISIBILITY_HIDDEN Linux : public Generic_GCC {
152public:
153 Linux(const HostInfo &Host, const llvm::Triple& Triple);
154};
155
156
Daniel Dunbar83b08eb2009-03-17 21:38:00 +0000157} // end namespace toolchains
158} // end namespace driver
159} // end namespace clang
160
161#endif