ToolChains.h revision 1eb4433ac451dc16f4133a88af2d002ac26c58ef
183b08eb6d2a7f71328db51baa79c654bb9dcc55dDaniel Dunbar//===--- ToolChains.h - ToolChain Implementations ---------------*- C++ -*-===//
283b08eb6d2a7f71328db51baa79c654bb9dcc55dDaniel Dunbar//
383b08eb6d2a7f71328db51baa79c654bb9dcc55dDaniel Dunbar//                     The LLVM Compiler Infrastructure
483b08eb6d2a7f71328db51baa79c654bb9dcc55dDaniel Dunbar//
583b08eb6d2a7f71328db51baa79c654bb9dcc55dDaniel Dunbar// This file is distributed under the University of Illinois Open Source
683b08eb6d2a7f71328db51baa79c654bb9dcc55dDaniel Dunbar// License. See LICENSE.TXT for details.
783b08eb6d2a7f71328db51baa79c654bb9dcc55dDaniel Dunbar//
883b08eb6d2a7f71328db51baa79c654bb9dcc55dDaniel Dunbar//===----------------------------------------------------------------------===//
983b08eb6d2a7f71328db51baa79c654bb9dcc55dDaniel Dunbar
1083b08eb6d2a7f71328db51baa79c654bb9dcc55dDaniel Dunbar#ifndef CLANG_LIB_DRIVER_TOOLCHAINS_H_
1183b08eb6d2a7f71328db51baa79c654bb9dcc55dDaniel Dunbar#define CLANG_LIB_DRIVER_TOOLCHAINS_H_
1283b08eb6d2a7f71328db51baa79c654bb9dcc55dDaniel Dunbar
13670b7f4fe6720e91520ec5a993b33c00058ed77aDaniel Dunbar#include "clang/Driver/Action.h"
1483b08eb6d2a7f71328db51baa79c654bb9dcc55dDaniel Dunbar#include "clang/Driver/ToolChain.h"
1583b08eb6d2a7f71328db51baa79c654bb9dcc55dDaniel Dunbar
16670b7f4fe6720e91520ec5a993b33c00058ed77aDaniel Dunbar#include "llvm/ADT/DenseMap.h"
1783b08eb6d2a7f71328db51baa79c654bb9dcc55dDaniel Dunbar#include "llvm/Support/Compiler.h"
1883b08eb6d2a7f71328db51baa79c654bb9dcc55dDaniel Dunbar
19670b7f4fe6720e91520ec5a993b33c00058ed77aDaniel Dunbar#include "Tools.h"
20670b7f4fe6720e91520ec5a993b33c00058ed77aDaniel Dunbar
2183b08eb6d2a7f71328db51baa79c654bb9dcc55dDaniel Dunbarnamespace clang {
2283b08eb6d2a7f71328db51baa79c654bb9dcc55dDaniel Dunbarnamespace driver {
23985b825eea7387be10478de0430815ed6a673326Daniel Dunbarnamespace toolchains {
2483b08eb6d2a7f71328db51baa79c654bb9dcc55dDaniel Dunbar
25670b7f4fe6720e91520ec5a993b33c00058ed77aDaniel Dunbar  /// Generic_GCC - A tool chain using the 'gcc' command to perform
26670b7f4fe6720e91520ec5a993b33c00058ed77aDaniel Dunbar  /// all subcommands; this relies on gcc translating the majority of
27670b7f4fe6720e91520ec5a993b33c00058ed77aDaniel Dunbar  /// command line options.
28985b825eea7387be10478de0430815ed6a673326Daniel Dunbarclass VISIBILITY_HIDDEN Generic_GCC : public ToolChain {
2975358d267256022475371416654b056ad8531cb3Daniel Dunbarprotected:
30670b7f4fe6720e91520ec5a993b33c00058ed77aDaniel Dunbar  mutable llvm::DenseMap<unsigned, Tool*> Tools;
31670b7f4fe6720e91520ec5a993b33c00058ed77aDaniel Dunbar
3283b08eb6d2a7f71328db51baa79c654bb9dcc55dDaniel Dunbarpublic:
33cb8ab23f7c800b041aeb6fc38c341d1aa0da86bfDaniel Dunbar  Generic_GCC(const HostInfo &Host, const llvm::Triple& Triple);
343917608370583fa30c466b6c3893448229aea9adDaniel Dunbar  ~Generic_GCC();
3583b08eb6d2a7f71328db51baa79c654bb9dcc55dDaniel Dunbar
36f3cad36e59a41b5767fe662b5ac8911ee174b801Daniel Dunbar  virtual DerivedArgList *TranslateArgs(InputArgList &Args) const;
3783b08eb6d2a7f71328db51baa79c654bb9dcc55dDaniel Dunbar
383917608370583fa30c466b6c3893448229aea9adDaniel Dunbar  virtual Tool &SelectTool(const Compilation &C, const JobAction &JA) const;
39670b7f4fe6720e91520ec5a993b33c00058ed77aDaniel Dunbar
403917608370583fa30c466b6c3893448229aea9adDaniel Dunbar  virtual bool IsMathErrnoDefault() const;
413917608370583fa30c466b6c3893448229aea9adDaniel Dunbar  virtual bool IsUnwindTablesDefault() const;
423917608370583fa30c466b6c3893448229aea9adDaniel Dunbar  virtual const char *GetDefaultRelocationModel() const;
433917608370583fa30c466b6c3893448229aea9adDaniel Dunbar  virtual const char *GetForcedPicModel() const;
4483b08eb6d2a7f71328db51baa79c654bb9dcc55dDaniel Dunbar};
4583b08eb6d2a7f71328db51baa79c654bb9dcc55dDaniel Dunbar
46f395528158379e7ea9f6ff4bbb791abadca15aabDaniel Dunbar/// Darwin - Darwin tool chain.
47f395528158379e7ea9f6ff4bbb791abadca15aabDaniel Dunbarclass VISIBILITY_HIDDEN Darwin : public ToolChain {
488eddb3fb6ff3dd20e3920380e1ce56df105b8a98Daniel Dunbar  mutable llvm::DenseMap<unsigned, Tool*> Tools;
498eddb3fb6ff3dd20e3920380e1ce56df105b8a98Daniel Dunbar
50c50b00dbd843cd929b5f220d4a8699852249f64cDaniel Dunbar  /// Darwin version of tool chain.
51c50b00dbd843cd929b5f220d4a8699852249f64cDaniel Dunbar  unsigned DarwinVersion[3];
52c50b00dbd843cd929b5f220d4a8699852249f64cDaniel Dunbar
53c50b00dbd843cd929b5f220d4a8699852249f64cDaniel Dunbar  /// GCC version to use.
54c50b00dbd843cd929b5f220d4a8699852249f64cDaniel Dunbar  unsigned GCCVersion[3];
55c50b00dbd843cd929b5f220d4a8699852249f64cDaniel Dunbar
5630392de4681602f1aabc61b0184b1de53bc172f0Daniel Dunbar  /// Whether this is this an iPhone toolchain.
5730392de4681602f1aabc61b0184b1de53bc172f0Daniel Dunbar  bool IsIPhone;
5830392de4681602f1aabc61b0184b1de53bc172f0Daniel Dunbar
59c50b00dbd843cd929b5f220d4a8699852249f64cDaniel Dunbar  /// The directory suffix for this tool chain.
60c50b00dbd843cd929b5f220d4a8699852249f64cDaniel Dunbar  std::string ToolChainDir;
61c50b00dbd843cd929b5f220d4a8699852249f64cDaniel Dunbar
6202633b541b04ad5ffc1c70f4c2feeeb13e607057Daniel Dunbar  /// The default macosx-version-min of this tool chain; empty until
6302633b541b04ad5ffc1c70f4c2feeeb13e607057Daniel Dunbar  /// initialized.
6402633b541b04ad5ffc1c70f4c2feeeb13e607057Daniel Dunbar  mutable std::string MacosxVersionMin;
6502633b541b04ad5ffc1c70f4c2feeeb13e607057Daniel Dunbar
6630392de4681602f1aabc61b0184b1de53bc172f0Daniel Dunbar  /// The default iphoneos-version-min of this tool chain.
6730392de4681602f1aabc61b0184b1de53bc172f0Daniel Dunbar  std::string IPhoneOSVersionMin;
6830392de4681602f1aabc61b0184b1de53bc172f0Daniel Dunbar
6902633b541b04ad5ffc1c70f4c2feeeb13e607057Daniel Dunbar  const char *getMacosxVersionMin() const;
70ec069ed8a6647d84cc3a58d46d5b2a3c9f000704Daniel Dunbar
718eddb3fb6ff3dd20e3920380e1ce56df105b8a98Daniel Dunbarpublic:
721eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump  Darwin(const HostInfo &Host, const llvm::Triple& Triple,
7330392de4681602f1aabc61b0184b1de53bc172f0Daniel Dunbar         const unsigned (&DarwinVersion)[3],
7430392de4681602f1aabc61b0184b1de53bc172f0Daniel Dunbar         const unsigned (&GCCVersion)[3],
7530392de4681602f1aabc61b0184b1de53bc172f0Daniel Dunbar         bool IsIPhone);
76f395528158379e7ea9f6ff4bbb791abadca15aabDaniel Dunbar  ~Darwin();
778eddb3fb6ff3dd20e3920380e1ce56df105b8a98Daniel Dunbar
7802633b541b04ad5ffc1c70f4c2feeeb13e607057Daniel Dunbar  void getDarwinVersion(unsigned (&Res)[3]) const {
7902633b541b04ad5ffc1c70f4c2feeeb13e607057Daniel Dunbar    Res[0] = DarwinVersion[0];
8002633b541b04ad5ffc1c70f4c2feeeb13e607057Daniel Dunbar    Res[1] = DarwinVersion[1];
8102633b541b04ad5ffc1c70f4c2feeeb13e607057Daniel Dunbar    Res[2] = DarwinVersion[2];
8202633b541b04ad5ffc1c70f4c2feeeb13e607057Daniel Dunbar  }
8302633b541b04ad5ffc1c70f4c2feeeb13e607057Daniel Dunbar
8402633b541b04ad5ffc1c70f4c2feeeb13e607057Daniel Dunbar  void getMacosxVersion(unsigned (&Res)[3]) const {
8502633b541b04ad5ffc1c70f4c2feeeb13e607057Daniel Dunbar    Res[0] = 10;
8602633b541b04ad5ffc1c70f4c2feeeb13e607057Daniel Dunbar    Res[1] = DarwinVersion[0] - 4;
8702633b541b04ad5ffc1c70f4c2feeeb13e607057Daniel Dunbar    Res[2] = DarwinVersion[1];
8802633b541b04ad5ffc1c70f4c2feeeb13e607057Daniel Dunbar  }
8902633b541b04ad5ffc1c70f4c2feeeb13e607057Daniel Dunbar
9002633b541b04ad5ffc1c70f4c2feeeb13e607057Daniel Dunbar  const char *getMacosxVersionStr() const {
9102633b541b04ad5ffc1c70f4c2feeeb13e607057Daniel Dunbar    return MacosxVersionMin.c_str();
9202633b541b04ad5ffc1c70f4c2feeeb13e607057Daniel Dunbar  }
9302633b541b04ad5ffc1c70f4c2feeeb13e607057Daniel Dunbar
9430392de4681602f1aabc61b0184b1de53bc172f0Daniel Dunbar  const char *getIPhoneOSVersionStr() const {
9530392de4681602f1aabc61b0184b1de53bc172f0Daniel Dunbar    return IPhoneOSVersionMin.c_str();
9630392de4681602f1aabc61b0184b1de53bc172f0Daniel Dunbar  }
9730392de4681602f1aabc61b0184b1de53bc172f0Daniel Dunbar
981eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump  const std::string &getToolChainDir() const {
9902633b541b04ad5ffc1c70f4c2feeeb13e607057Daniel Dunbar    return ToolChainDir;
10002633b541b04ad5ffc1c70f4c2feeeb13e607057Daniel Dunbar  }
10102633b541b04ad5ffc1c70f4c2feeeb13e607057Daniel Dunbar
10230392de4681602f1aabc61b0184b1de53bc172f0Daniel Dunbar  bool isIPhone() const { return IsIPhone; }
10330392de4681602f1aabc61b0184b1de53bc172f0Daniel Dunbar
104f3cad36e59a41b5767fe662b5ac8911ee174b801Daniel Dunbar  virtual DerivedArgList *TranslateArgs(InputArgList &Args) const;
1058eddb3fb6ff3dd20e3920380e1ce56df105b8a98Daniel Dunbar
1068eddb3fb6ff3dd20e3920380e1ce56df105b8a98Daniel Dunbar  virtual Tool &SelectTool(const Compilation &C, const JobAction &JA) const;
1078eddb3fb6ff3dd20e3920380e1ce56df105b8a98Daniel Dunbar
1088eddb3fb6ff3dd20e3920380e1ce56df105b8a98Daniel Dunbar  virtual bool IsMathErrnoDefault() const;
1098eddb3fb6ff3dd20e3920380e1ce56df105b8a98Daniel Dunbar  virtual bool IsUnwindTablesDefault() const;
1108eddb3fb6ff3dd20e3920380e1ce56df105b8a98Daniel Dunbar  virtual const char *GetDefaultRelocationModel() const;
1118eddb3fb6ff3dd20e3920380e1ce56df105b8a98Daniel Dunbar  virtual const char *GetForcedPicModel() const;
1128eddb3fb6ff3dd20e3920380e1ce56df105b8a98Daniel Dunbar};
1138eddb3fb6ff3dd20e3920380e1ce56df105b8a98Daniel Dunbar
1148eddb3fb6ff3dd20e3920380e1ce56df105b8a98Daniel Dunbar  /// Darwin_GCC - Generic Darwin tool chain using gcc.
1158eddb3fb6ff3dd20e3920380e1ce56df105b8a98Daniel Dunbarclass VISIBILITY_HIDDEN Darwin_GCC : public Generic_GCC {
1168eddb3fb6ff3dd20e3920380e1ce56df105b8a98Daniel Dunbarpublic:
1171eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump  Darwin_GCC(const HostInfo &Host, const llvm::Triple& Triple)
118cb8ab23f7c800b041aeb6fc38c341d1aa0da86bfDaniel Dunbar    : Generic_GCC(Host, Triple) {}
1198eddb3fb6ff3dd20e3920380e1ce56df105b8a98Daniel Dunbar
1208eddb3fb6ff3dd20e3920380e1ce56df105b8a98Daniel Dunbar  virtual const char *GetDefaultRelocationModel() const { return "pic"; }
1218eddb3fb6ff3dd20e3920380e1ce56df105b8a98Daniel Dunbar};
1228eddb3fb6ff3dd20e3920380e1ce56df105b8a98Daniel Dunbar
123e7925a075f110ab21afeae084670a155dea568e3Edward O'Callaghanclass VISIBILITY_HIDDEN AuroraUX : public Generic_GCC {
124e7925a075f110ab21afeae084670a155dea568e3Edward O'Callaghanpublic:
125e7925a075f110ab21afeae084670a155dea568e3Edward O'Callaghan  AuroraUX(const HostInfo &Host, const llvm::Triple& Triple);
126e7925a075f110ab21afeae084670a155dea568e3Edward O'Callaghan
127e7925a075f110ab21afeae084670a155dea568e3Edward O'Callaghan  virtual Tool &SelectTool(const Compilation &C, const JobAction &JA) const;
128e7925a075f110ab21afeae084670a155dea568e3Edward O'Callaghan};
129e7925a075f110ab21afeae084670a155dea568e3Edward O'Callaghan
130f7b8eec37c8c8012fa525c71fb29a58c9f29beefDaniel Dunbarclass VISIBILITY_HIDDEN OpenBSD : public Generic_GCC {
131f7b8eec37c8c8012fa525c71fb29a58c9f29beefDaniel Dunbarpublic:
132f7b8eec37c8c8012fa525c71fb29a58c9f29beefDaniel Dunbar  OpenBSD(const HostInfo &Host, const llvm::Triple& Triple);
133f7b8eec37c8c8012fa525c71fb29a58c9f29beefDaniel Dunbar
134f7b8eec37c8c8012fa525c71fb29a58c9f29beefDaniel Dunbar  virtual Tool &SelectTool(const Compilation &C, const JobAction &JA) const;
135f7b8eec37c8c8012fa525c71fb29a58c9f29beefDaniel Dunbar};
136f7b8eec37c8c8012fa525c71fb29a58c9f29beefDaniel Dunbar
13775358d267256022475371416654b056ad8531cb3Daniel Dunbarclass VISIBILITY_HIDDEN FreeBSD : public Generic_GCC {
13875358d267256022475371416654b056ad8531cb3Daniel Dunbarpublic:
139cb8ab23f7c800b041aeb6fc38c341d1aa0da86bfDaniel Dunbar  FreeBSD(const HostInfo &Host, const llvm::Triple& Triple, bool Lib32);
14075358d267256022475371416654b056ad8531cb3Daniel Dunbar
14175358d267256022475371416654b056ad8531cb3Daniel Dunbar  virtual Tool &SelectTool(const Compilation &C, const JobAction &JA) const;
14275358d267256022475371416654b056ad8531cb3Daniel Dunbar};
14375358d267256022475371416654b056ad8531cb3Daniel Dunbar
14411e1b40d759a643086f590f6ffbd9d68360bad46Daniel Dunbarclass VISIBILITY_HIDDEN DragonFly : public Generic_GCC {
14511e1b40d759a643086f590f6ffbd9d68360bad46Daniel Dunbarpublic:
146cb8ab23f7c800b041aeb6fc38c341d1aa0da86bfDaniel Dunbar  DragonFly(const HostInfo &Host, const llvm::Triple& Triple);
14711e1b40d759a643086f590f6ffbd9d68360bad46Daniel Dunbar
14811e1b40d759a643086f590f6ffbd9d68360bad46Daniel Dunbar  virtual Tool &SelectTool(const Compilation &C, const JobAction &JA) const;
14911e1b40d759a643086f590f6ffbd9d68360bad46Daniel Dunbar};
15011e1b40d759a643086f590f6ffbd9d68360bad46Daniel Dunbar
1516b3454a219cee5ef36c4668961f93a5c32deab61Eli Friedmanclass VISIBILITY_HIDDEN Linux : public Generic_GCC {
1526b3454a219cee5ef36c4668961f93a5c32deab61Eli Friedmanpublic:
1536b3454a219cee5ef36c4668961f93a5c32deab61Eli Friedman  Linux(const HostInfo &Host, const llvm::Triple& Triple);
1546b3454a219cee5ef36c4668961f93a5c32deab61Eli Friedman};
1556b3454a219cee5ef36c4668961f93a5c32deab61Eli Friedman
1566b3454a219cee5ef36c4668961f93a5c32deab61Eli Friedman
15783b08eb6d2a7f71328db51baa79c654bb9dcc55dDaniel Dunbar} // end namespace toolchains
15883b08eb6d2a7f71328db51baa79c654bb9dcc55dDaniel Dunbar} // end namespace driver
15983b08eb6d2a7f71328db51baa79c654bb9dcc55dDaniel Dunbar} // end namespace clang
16083b08eb6d2a7f71328db51baa79c654bb9dcc55dDaniel Dunbar
16183b08eb6d2a7f71328db51baa79c654bb9dcc55dDaniel Dunbar#endif
162