blob: baab99bc5ca61efbd9465a4b53052290bab21ea4 [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:
33 Generic_GCC(const HostInfo &Host, const char *Arch, const char *Platform,
Daniel Dunbarc50b00d2009-03-23 16:15:50 +000034 const char *OS);
Daniel Dunbar39176082009-03-20 00:20:03 +000035 ~Generic_GCC();
Daniel Dunbar83b08eb2009-03-17 21:38:00 +000036
Daniel Dunbarf3cad362009-03-25 04:13:45 +000037 virtual DerivedArgList *TranslateArgs(InputArgList &Args) 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 Dunbar8eddb3f2009-03-20 00:57:52 +000047 /// Darwin_X86 - Darwin tool chain for i386 an x86_64.
48class VISIBILITY_HIDDEN Darwin_X86 : public ToolChain {
49 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
57 /// The directory suffix for this tool chain.
58 std::string ToolChainDir;
59
Daniel Dunbar02633b52009-03-26 16:23:12 +000060 /// The default macosx-version-min of this tool chain; empty until
61 /// initialized.
62 mutable std::string MacosxVersionMin;
63
64 const char *getMacosxVersionMin() const;
Daniel Dunbarec069ed2009-03-25 06:58:31 +000065
Daniel Dunbar8eddb3f2009-03-20 00:57:52 +000066public:
67 Darwin_X86(const HostInfo &Host, const char *Arch, const char *Platform,
Daniel Dunbarc50b00d2009-03-23 16:15:50 +000068 const char *OS, const unsigned (&DarwinVersion)[3],
69 const unsigned (&GCCVersion)[3]);
Daniel Dunbar8eddb3f2009-03-20 00:57:52 +000070 ~Darwin_X86();
71
Daniel Dunbar02633b52009-03-26 16:23:12 +000072 void getDarwinVersion(unsigned (&Res)[3]) const {
73 Res[0] = DarwinVersion[0];
74 Res[1] = DarwinVersion[1];
75 Res[2] = DarwinVersion[2];
76 }
77
78 void getMacosxVersion(unsigned (&Res)[3]) const {
79 Res[0] = 10;
80 Res[1] = DarwinVersion[0] - 4;
81 Res[2] = DarwinVersion[1];
82 }
83
84 const char *getMacosxVersionStr() const {
85 return MacosxVersionMin.c_str();
86 }
87
88 const std::string &getToolChainDir() const {
89 return ToolChainDir;
90 }
91
Daniel Dunbarf3cad362009-03-25 04:13:45 +000092 virtual DerivedArgList *TranslateArgs(InputArgList &Args) const;
Daniel Dunbar8eddb3f2009-03-20 00:57:52 +000093
94 virtual Tool &SelectTool(const Compilation &C, const JobAction &JA) const;
95
96 virtual bool IsMathErrnoDefault() const;
97 virtual bool IsUnwindTablesDefault() const;
98 virtual const char *GetDefaultRelocationModel() const;
99 virtual const char *GetForcedPicModel() const;
100};
101
102 /// Darwin_GCC - Generic Darwin tool chain using gcc.
103class VISIBILITY_HIDDEN Darwin_GCC : public Generic_GCC {
104public:
105 Darwin_GCC(const HostInfo &Host, const char *Arch, const char *Platform,
106 const char *OS) : Generic_GCC(Host, Arch, Platform, OS) {}
107
108 virtual const char *GetDefaultRelocationModel() const { return "pic"; }
109};
110
Daniel Dunbar75358d22009-03-30 21:06:03 +0000111class VISIBILITY_HIDDEN FreeBSD : public Generic_GCC {
112public:
113 FreeBSD(const HostInfo &Host, const char *Arch, const char *Platform,
114 const char *OS, bool Lib32);
115
116 virtual Tool &SelectTool(const Compilation &C, const JobAction &JA) const;
117};
118
Daniel Dunbar11e1b402009-05-02 18:28:39 +0000119class VISIBILITY_HIDDEN DragonFly : public Generic_GCC {
120public:
121 DragonFly(const HostInfo &Host, const char *Arch, const char *Platform,
122 const char *OS);
123
124 virtual Tool &SelectTool(const Compilation &C, const JobAction &JA) const;
125};
126
Daniel Dunbar83b08eb2009-03-17 21:38:00 +0000127} // end namespace toolchains
128} // end namespace driver
129} // end namespace clang
130
131#endif