ToolChains.h revision 3404fe7105ecc3baa58b7ea725773de4112259d6
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 251d4612b829500cbe04a2eafca74afac703e34934Daniel Dunbar/// Generic_GCC - A tool chain using the 'gcc' command to perform 261d4612b829500cbe04a2eafca74afac703e34934Daniel Dunbar/// all subcommands; this relies on gcc translating the majority of 271d4612b829500cbe04a2eafca74afac703e34934Daniel Dunbar/// command line options. 2892dd1915842410005c68d32c43bb3b3cf5a4a702Duncan Sandsclass LLVM_LIBRARY_VISIBILITY 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 36ac0659ae4124156915eddf70e78065df224d34c8Daniel Dunbar virtual Tool &SelectTool(const Compilation &C, const JobAction &JA, 37ac0659ae4124156915eddf70e78065df224d34c8Daniel Dunbar const ActionList &Inputs) const; 38670b7f4fe6720e91520ec5a993b33c00058ed77aDaniel Dunbar 393917608370583fa30c466b6c3893448229aea9adDaniel Dunbar virtual bool IsUnwindTablesDefault() const; 403917608370583fa30c466b6c3893448229aea9adDaniel Dunbar virtual const char *GetDefaultRelocationModel() const; 413917608370583fa30c466b6c3893448229aea9adDaniel Dunbar virtual const char *GetForcedPicModel() const; 4283b08eb6d2a7f71328db51baa79c654bb9dcc55dDaniel Dunbar}; 4383b08eb6d2a7f71328db51baa79c654bb9dcc55dDaniel Dunbar 441d4612b829500cbe04a2eafca74afac703e34934Daniel Dunbar/// Darwin - The base Darwin tool chain. 4592dd1915842410005c68d32c43bb3b3cf5a4a702Duncan Sandsclass LLVM_LIBRARY_VISIBILITY Darwin : public ToolChain { 4625b58eb7998ed947bc1c07e70de0b5d8f6aff857Daniel Dunbarpublic: 4725b58eb7998ed947bc1c07e70de0b5d8f6aff857Daniel Dunbar /// The host version. 4825b58eb7998ed947bc1c07e70de0b5d8f6aff857Daniel Dunbar unsigned DarwinVersion[3]; 4925b58eb7998ed947bc1c07e70de0b5d8f6aff857Daniel Dunbar 5025b58eb7998ed947bc1c07e70de0b5d8f6aff857Daniel Dunbarprivate: 518eddb3fb6ff3dd20e3920380e1ce56df105b8a98Daniel Dunbar mutable llvm::DenseMap<unsigned, Tool*> Tools; 528eddb3fb6ff3dd20e3920380e1ce56df105b8a98Daniel Dunbar 532603137cb91e1d143b36fb71a72189884fbde5b5Daniel Dunbar /// Whether the information on the target has been initialized. 542603137cb91e1d143b36fb71a72189884fbde5b5Daniel Dunbar // 552603137cb91e1d143b36fb71a72189884fbde5b5Daniel Dunbar // FIXME: This should be eliminated. What we want to do is make this part of 562603137cb91e1d143b36fb71a72189884fbde5b5Daniel Dunbar // the "default target for arguments" selection process, once we get out of 572603137cb91e1d143b36fb71a72189884fbde5b5Daniel Dunbar // the argument translation business. 582603137cb91e1d143b36fb71a72189884fbde5b5Daniel Dunbar mutable bool TargetInitialized; 592603137cb91e1d143b36fb71a72189884fbde5b5Daniel Dunbar 60f85e193739c953358c865005855253af4f68a497John McCall // FIXME: Remove this once there is a proper way to detect an ARC runtime 61f85e193739c953358c865005855253af4f68a497John McCall // for the simulator. 62f85e193739c953358c865005855253af4f68a497John McCall public: 63f85e193739c953358c865005855253af4f68a497John McCall mutable enum { 64f85e193739c953358c865005855253af4f68a497John McCall ARCSimulator_None, 65f85e193739c953358c865005855253af4f68a497John McCall ARCSimulator_HasARCRuntime, 66f85e193739c953358c865005855253af4f68a497John McCall ARCSimulator_NoARCRuntime 67f85e193739c953358c865005855253af4f68a497John McCall } ARCRuntimeForSimulator; 68f85e193739c953358c865005855253af4f68a497John McCall 69f85e193739c953358c865005855253af4f68a497John McCallprivate: 70fc8f0e14ad142ed811e90fbd9a30e419e301c717Chris Lattner /// Whether we are targeting iPhoneOS target. 712603137cb91e1d143b36fb71a72189884fbde5b5Daniel Dunbar mutable bool TargetIsIPhoneOS; 72eb840bd0e473ee11622e084a0d6ff276ee7aa5c6Daniel Dunbar 735f5c37b1234e6ebb6c17e084bc4e2cce92e31585Daniel Dunbar /// Whether we are targeting the iPhoneOS simulator target. 745f5c37b1234e6ebb6c17e084bc4e2cce92e31585Daniel Dunbar mutable bool TargetIsIPhoneOSSimulator; 755f5c37b1234e6ebb6c17e084bc4e2cce92e31585Daniel Dunbar 76fc8f0e14ad142ed811e90fbd9a30e419e301c717Chris Lattner /// The OS version we are targeting. 772603137cb91e1d143b36fb71a72189884fbde5b5Daniel Dunbar mutable unsigned TargetVersion[3]; 782603137cb91e1d143b36fb71a72189884fbde5b5Daniel Dunbar 7902633b541b04ad5ffc1c70f4c2feeeb13e607057Daniel Dunbar /// The default macosx-version-min of this tool chain; empty until 8002633b541b04ad5ffc1c70f4c2feeeb13e607057Daniel Dunbar /// initialized. 81816bc31ed45002de2547d6679b44f31eb85ec491Daniel Dunbar std::string MacosxVersionMin; 8202633b541b04ad5ffc1c70f4c2feeeb13e607057Daniel Dunbar 83c0e665eb705762f95cd4f722ad7ecbdcde3f4527Daniel Dunbarprivate: 8460baf0f6d54376805168d49fa68628f801f95ef9Daniel Dunbar void AddDeploymentTarget(DerivedArgList &Args) const; 85c0e665eb705762f95cd4f722ad7ecbdcde3f4527Daniel Dunbar 868eddb3fb6ff3dd20e3920380e1ce56df105b8a98Daniel Dunbarpublic: 8725b58eb7998ed947bc1c07e70de0b5d8f6aff857Daniel Dunbar Darwin(const HostInfo &Host, const llvm::Triple& Triple); 88f395528158379e7ea9f6ff4bbb791abadca15aabDaniel Dunbar ~Darwin(); 898eddb3fb6ff3dd20e3920380e1ce56df105b8a98Daniel Dunbar 9000577ada44c889fbe311d61c51a8da89e65c7c9aDaniel Dunbar std::string ComputeEffectiveClangTriple(const ArgList &Args) const; 9100577ada44c889fbe311d61c51a8da89e65c7c9aDaniel Dunbar 926b200b2b698b6ac9e310f2225c69c85d28ae4fb0Daniel Dunbar /// @name Darwin Specific Toolchain API 936b200b2b698b6ac9e310f2225c69c85d28ae4fb0Daniel Dunbar /// { 946b200b2b698b6ac9e310f2225c69c85d28ae4fb0Daniel Dunbar 952603137cb91e1d143b36fb71a72189884fbde5b5Daniel Dunbar // FIXME: Eliminate these ...Target functions and derive separate tool chains 962603137cb91e1d143b36fb71a72189884fbde5b5Daniel Dunbar // for these targets and put version in constructor. 975f5c37b1234e6ebb6c17e084bc4e2cce92e31585Daniel Dunbar void setTarget(bool IsIPhoneOS, unsigned Major, unsigned Minor, 985f5c37b1234e6ebb6c17e084bc4e2cce92e31585Daniel Dunbar unsigned Micro, bool IsIOSSim) const { 995f5c37b1234e6ebb6c17e084bc4e2cce92e31585Daniel Dunbar assert((!IsIOSSim || IsIPhoneOS) && "Unexpected deployment target!"); 1005f5c37b1234e6ebb6c17e084bc4e2cce92e31585Daniel Dunbar 1012603137cb91e1d143b36fb71a72189884fbde5b5Daniel Dunbar // FIXME: For now, allow reinitialization as long as values don't 1022603137cb91e1d143b36fb71a72189884fbde5b5Daniel Dunbar // change. This will go away when we move away from argument translation. 1035f5c37b1234e6ebb6c17e084bc4e2cce92e31585Daniel Dunbar if (TargetInitialized && TargetIsIPhoneOS == IsIPhoneOS && 1045f5c37b1234e6ebb6c17e084bc4e2cce92e31585Daniel Dunbar TargetIsIPhoneOSSimulator == IsIOSSim && 1052603137cb91e1d143b36fb71a72189884fbde5b5Daniel Dunbar TargetVersion[0] == Major && TargetVersion[1] == Minor && 1062603137cb91e1d143b36fb71a72189884fbde5b5Daniel Dunbar TargetVersion[2] == Micro) 1072603137cb91e1d143b36fb71a72189884fbde5b5Daniel Dunbar return; 1082603137cb91e1d143b36fb71a72189884fbde5b5Daniel Dunbar 1092603137cb91e1d143b36fb71a72189884fbde5b5Daniel Dunbar assert(!TargetInitialized && "Target already initialized!"); 1102603137cb91e1d143b36fb71a72189884fbde5b5Daniel Dunbar TargetInitialized = true; 1115f5c37b1234e6ebb6c17e084bc4e2cce92e31585Daniel Dunbar TargetIsIPhoneOS = IsIPhoneOS; 1125f5c37b1234e6ebb6c17e084bc4e2cce92e31585Daniel Dunbar TargetIsIPhoneOSSimulator = IsIOSSim; 1132603137cb91e1d143b36fb71a72189884fbde5b5Daniel Dunbar TargetVersion[0] = Major; 1142603137cb91e1d143b36fb71a72189884fbde5b5Daniel Dunbar TargetVersion[1] = Minor; 1152603137cb91e1d143b36fb71a72189884fbde5b5Daniel Dunbar TargetVersion[2] = Micro; 1162603137cb91e1d143b36fb71a72189884fbde5b5Daniel Dunbar } 1172603137cb91e1d143b36fb71a72189884fbde5b5Daniel Dunbar 1182603137cb91e1d143b36fb71a72189884fbde5b5Daniel Dunbar bool isTargetIPhoneOS() const { 1192603137cb91e1d143b36fb71a72189884fbde5b5Daniel Dunbar assert(TargetInitialized && "Target not initialized!"); 1202603137cb91e1d143b36fb71a72189884fbde5b5Daniel Dunbar return TargetIsIPhoneOS; 1212603137cb91e1d143b36fb71a72189884fbde5b5Daniel Dunbar } 1222603137cb91e1d143b36fb71a72189884fbde5b5Daniel Dunbar 1234035580e3475db9013f335ce2b8a49dd1988a79aDaniel Dunbar bool isTargetIOSSimulator() const { 1245f5c37b1234e6ebb6c17e084bc4e2cce92e31585Daniel Dunbar assert(TargetInitialized && "Target not initialized!"); 1255f5c37b1234e6ebb6c17e084bc4e2cce92e31585Daniel Dunbar return TargetIsIPhoneOSSimulator; 1264035580e3475db9013f335ce2b8a49dd1988a79aDaniel Dunbar } 1274035580e3475db9013f335ce2b8a49dd1988a79aDaniel Dunbar 12803d87ee556f9e11ab83f6d2f80c9ee92e3667301Daniel Dunbar bool isTargetInitialized() const { return TargetInitialized; } 12903d87ee556f9e11ab83f6d2f80c9ee92e3667301Daniel Dunbar 1302603137cb91e1d143b36fb71a72189884fbde5b5Daniel Dunbar void getTargetVersion(unsigned (&Res)[3]) const { 1312603137cb91e1d143b36fb71a72189884fbde5b5Daniel Dunbar assert(TargetInitialized && "Target not initialized!"); 1322603137cb91e1d143b36fb71a72189884fbde5b5Daniel Dunbar Res[0] = TargetVersion[0]; 1332603137cb91e1d143b36fb71a72189884fbde5b5Daniel Dunbar Res[1] = TargetVersion[1]; 1342603137cb91e1d143b36fb71a72189884fbde5b5Daniel Dunbar Res[2] = TargetVersion[2]; 1352603137cb91e1d143b36fb71a72189884fbde5b5Daniel Dunbar } 1362603137cb91e1d143b36fb71a72189884fbde5b5Daniel Dunbar 137eeff406730f50afd973f005a8d501a19af4785e5Daniel Dunbar /// getDarwinArchName - Get the "Darwin" arch name for a particular compiler 138eeff406730f50afd973f005a8d501a19af4785e5Daniel Dunbar /// invocation. For example, Darwin treats different ARM variations as 139eeff406730f50afd973f005a8d501a19af4785e5Daniel Dunbar /// distinct architectures. 140eeff406730f50afd973f005a8d501a19af4785e5Daniel Dunbar llvm::StringRef getDarwinArchName(const ArgList &Args) const; 141eeff406730f50afd973f005a8d501a19af4785e5Daniel Dunbar 142ce3fdf233353b10f20d74dceda3d77a82285de17Daniel Dunbar static bool isVersionLT(unsigned (&A)[3], unsigned (&B)[3]) { 143608d04cb7bee2db28c8689f6626bf9e0b114c473Daniel Dunbar for (unsigned i=0; i < 3; ++i) { 144608d04cb7bee2db28c8689f6626bf9e0b114c473Daniel Dunbar if (A[i] > B[i]) return false; 145608d04cb7bee2db28c8689f6626bf9e0b114c473Daniel Dunbar if (A[i] < B[i]) return true; 146608d04cb7bee2db28c8689f6626bf9e0b114c473Daniel Dunbar } 147608d04cb7bee2db28c8689f6626bf9e0b114c473Daniel Dunbar return false; 148608d04cb7bee2db28c8689f6626bf9e0b114c473Daniel Dunbar } 149608d04cb7bee2db28c8689f6626bf9e0b114c473Daniel Dunbar 150ce3fdf233353b10f20d74dceda3d77a82285de17Daniel Dunbar bool isIPhoneOSVersionLT(unsigned V0, unsigned V1=0, unsigned V2=0) const { 151ce3fdf233353b10f20d74dceda3d77a82285de17Daniel Dunbar assert(isTargetIPhoneOS() && "Unexpected call for OS X target!"); 152608d04cb7bee2db28c8689f6626bf9e0b114c473Daniel Dunbar unsigned B[3] = { V0, V1, V2 }; 153ce3fdf233353b10f20d74dceda3d77a82285de17Daniel Dunbar return isVersionLT(TargetVersion, B); 154608d04cb7bee2db28c8689f6626bf9e0b114c473Daniel Dunbar } 155608d04cb7bee2db28c8689f6626bf9e0b114c473Daniel Dunbar 156ce3fdf233353b10f20d74dceda3d77a82285de17Daniel Dunbar bool isMacosxVersionLT(unsigned V0, unsigned V1=0, unsigned V2=0) const { 157ce3fdf233353b10f20d74dceda3d77a82285de17Daniel Dunbar assert(!isTargetIPhoneOS() && "Unexpected call for iPhoneOS target!"); 158cacb0f007001f7463d44ebd5dde7bfaecf876a71Daniel Dunbar unsigned B[3] = { V0, V1, V2 }; 159ce3fdf233353b10f20d74dceda3d77a82285de17Daniel Dunbar return isVersionLT(TargetVersion, B); 160cacb0f007001f7463d44ebd5dde7bfaecf876a71Daniel Dunbar } 161cacb0f007001f7463d44ebd5dde7bfaecf876a71Daniel Dunbar 1626b200b2b698b6ac9e310f2225c69c85d28ae4fb0Daniel Dunbar /// AddLinkSearchPathArgs - Add the linker search paths to \arg CmdArgs. 1636b200b2b698b6ac9e310f2225c69c85d28ae4fb0Daniel Dunbar /// 1646b200b2b698b6ac9e310f2225c69c85d28ae4fb0Daniel Dunbar /// \param Args - The input argument list. 1656b200b2b698b6ac9e310f2225c69c85d28ae4fb0Daniel Dunbar /// \param CmdArgs [out] - The command argument list to append the paths 1666b200b2b698b6ac9e310f2225c69c85d28ae4fb0Daniel Dunbar /// (prefixed by -L) to. 1671d4612b829500cbe04a2eafca74afac703e34934Daniel Dunbar virtual void AddLinkSearchPathArgs(const ArgList &Args, 1681d4612b829500cbe04a2eafca74afac703e34934Daniel Dunbar ArgStringList &CmdArgs) const = 0; 16902633b541b04ad5ffc1c70f4c2feeeb13e607057Daniel Dunbar 170f85e193739c953358c865005855253af4f68a497John McCall /// AddLinkARCArgs - Add the linker arguments to link the ARC runtime library. 171f85e193739c953358c865005855253af4f68a497John McCall virtual void AddLinkARCArgs(const ArgList &Args, 172f85e193739c953358c865005855253af4f68a497John McCall ArgStringList &CmdArgs) const = 0; 173f85e193739c953358c865005855253af4f68a497John McCall 1746cd4154b9088fa18ae05d11c0f3140fafd76c734Daniel Dunbar /// AddLinkRuntimeLibArgs - Add the linker arguments to link the compiler 1756cd4154b9088fa18ae05d11c0f3140fafd76c734Daniel Dunbar /// runtime library. 1761d4612b829500cbe04a2eafca74afac703e34934Daniel Dunbar virtual void AddLinkRuntimeLibArgs(const ArgList &Args, 1771d4612b829500cbe04a2eafca74afac703e34934Daniel Dunbar ArgStringList &CmdArgs) const = 0; 1783404fe7105ecc3baa58b7ea725773de4112259d6Eric Christopher 1796b200b2b698b6ac9e310f2225c69c85d28ae4fb0Daniel Dunbar /// } 1806b200b2b698b6ac9e310f2225c69c85d28ae4fb0Daniel Dunbar /// @name ToolChain Implementation 1816b200b2b698b6ac9e310f2225c69c85d28ae4fb0Daniel Dunbar /// { 1826b200b2b698b6ac9e310f2225c69c85d28ae4fb0Daniel Dunbar 1834180011fb8cef06adec04d30486b1bf3b99aa8b8Daniel Dunbar virtual types::ID LookupTypeForExtension(const char *Ext) const; 1844180011fb8cef06adec04d30486b1bf3b99aa8b8Daniel Dunbar 185b993f5d93b994b9b0aac6aebae669621744bbed7Daniel Dunbar virtual bool HasNativeLLVMSupport() const; 186b993f5d93b994b9b0aac6aebae669621744bbed7Daniel Dunbar 187f85e193739c953358c865005855253af4f68a497John McCall virtual bool HasARCRuntime() const; 188f85e193739c953358c865005855253af4f68a497John McCall 189279c1dbebf37cd128f3c73c70741a6b8c35ad025Daniel Dunbar virtual DerivedArgList *TranslateArgs(const DerivedArgList &Args, 1900dcb9a3705743ec972af37f48ead81a0939e3958Daniel Dunbar const char *BoundArch) const; 1918eddb3fb6ff3dd20e3920380e1ce56df105b8a98Daniel Dunbar 192ac0659ae4124156915eddf70e78065df224d34c8Daniel Dunbar virtual Tool &SelectTool(const Compilation &C, const JobAction &JA, 193ac0659ae4124156915eddf70e78065df224d34c8Daniel Dunbar const ActionList &Inputs) const; 1948eddb3fb6ff3dd20e3920380e1ce56df105b8a98Daniel Dunbar 1959e5cc6b703b2d0013f13800c2ffbeb3cf85fcfadDaniel Dunbar virtual bool IsBlocksDefault() const { 196ef44a5d65c48b92802aac02126d36c03d818e847Daniel Dunbar // Always allow blocks on Darwin; users interested in versioning are 197ef44a5d65c48b92802aac02126d36c03d818e847Daniel Dunbar // expected to use /usr/include/Blocks.h. 198ef44a5d65c48b92802aac02126d36c03d818e847Daniel Dunbar return true; 1999e5cc6b703b2d0013f13800c2ffbeb3cf85fcfadDaniel Dunbar } 200eb840bd0e473ee11622e084a0d6ff276ee7aa5c6Daniel Dunbar virtual bool IsIntegratedAssemblerDefault() const { 20171a6cbc5a101899f54e0a76aece82c01b48ad089Daniel Dunbar#ifdef DISABLE_DEFAULT_INTEGRATED_ASSEMBLER 20271a6cbc5a101899f54e0a76aece82c01b48ad089Daniel Dunbar return false; 20371a6cbc5a101899f54e0a76aece82c01b48ad089Daniel Dunbar#else 204eb840bd0e473ee11622e084a0d6ff276ee7aa5c6Daniel Dunbar // Default integrated assembler to on for x86. 205eb840bd0e473ee11622e084a0d6ff276ee7aa5c6Daniel Dunbar return (getTriple().getArch() == llvm::Triple::x86 || 206eb840bd0e473ee11622e084a0d6ff276ee7aa5c6Daniel Dunbar getTriple().getArch() == llvm::Triple::x86_64); 20771a6cbc5a101899f54e0a76aece82c01b48ad089Daniel Dunbar#endif 208eb840bd0e473ee11622e084a0d6ff276ee7aa5c6Daniel Dunbar } 209398c610b16728b4398214367dd0effd9d2e61340Daniel Dunbar virtual bool IsStrictAliasingDefault() const { 210398c610b16728b4398214367dd0effd9d2e61340Daniel Dunbar#ifdef DISABLE_DEFAULT_STRICT_ALIASING 211398c610b16728b4398214367dd0effd9d2e61340Daniel Dunbar return false; 212398c610b16728b4398214367dd0effd9d2e61340Daniel Dunbar#else 213398c610b16728b4398214367dd0effd9d2e61340Daniel Dunbar return ToolChain::IsStrictAliasingDefault(); 214398c610b16728b4398214367dd0effd9d2e61340Daniel Dunbar#endif 215398c610b16728b4398214367dd0effd9d2e61340Daniel Dunbar } 216c32647d111e516593b9ba242cad7b8ff4016c155Ted Kremenek 217c32647d111e516593b9ba242cad7b8ff4016c155Ted Kremenek virtual bool IsObjCDefaultSynthPropertiesDefault() const { 2182fb468dcf86d306ba8557b4914a0d09fe946d1faTed Kremenek return false; 219c32647d111e516593b9ba242cad7b8ff4016c155Ted Kremenek } 220c32647d111e516593b9ba242cad7b8ff4016c155Ted Kremenek 2219e5cc6b703b2d0013f13800c2ffbeb3cf85fcfadDaniel Dunbar virtual bool IsObjCNonFragileABIDefault() const { 222f645aaaf274c2f32c9ace457b9e69f041b565c17Daniel Dunbar // Non-fragile ABI is default for everything but i386. 223f645aaaf274c2f32c9ace457b9e69f041b565c17Daniel Dunbar return getTriple().getArch() != llvm::Triple::x86; 2249e5cc6b703b2d0013f13800c2ffbeb3cf85fcfadDaniel Dunbar } 225609508ce95732e7e7010f79c5207613eced7c9cbDaniel Dunbar virtual bool IsObjCLegacyDispatchDefault() const { 226609508ce95732e7e7010f79c5207613eced7c9cbDaniel Dunbar // This is only used with the non-fragile ABI. 227f645aaaf274c2f32c9ace457b9e69f041b565c17Daniel Dunbar 228f645aaaf274c2f32c9ace457b9e69f041b565c17Daniel Dunbar // Legacy dispatch is used everywhere except on x86_64. 229f645aaaf274c2f32c9ace457b9e69f041b565c17Daniel Dunbar return getTriple().getArch() != llvm::Triple::x86_64; 230609508ce95732e7e7010f79c5207613eced7c9cbDaniel Dunbar } 231f643b9b338b797a824447207d7eab5f1187f4f34Daniel Dunbar virtual bool UseObjCMixedDispatch() const { 232f645aaaf274c2f32c9ace457b9e69f041b565c17Daniel Dunbar // This is only used with the non-fragile ABI and non-legacy dispatch. 233f645aaaf274c2f32c9ace457b9e69f041b565c17Daniel Dunbar 234f645aaaf274c2f32c9ace457b9e69f041b565c17Daniel Dunbar // Mixed dispatch is used everywhere except OS X before 10.6. 235f645aaaf274c2f32c9ace457b9e69f041b565c17Daniel Dunbar return !(!isTargetIPhoneOS() && isMacosxVersionLT(10, 6)); 236f643b9b338b797a824447207d7eab5f1187f4f34Daniel Dunbar } 2378eddb3fb6ff3dd20e3920380e1ce56df105b8a98Daniel Dunbar virtual bool IsUnwindTablesDefault() const; 2389e5cc6b703b2d0013f13800c2ffbeb3cf85fcfadDaniel Dunbar virtual unsigned GetDefaultStackProtectorLevel() const { 2395435fc9739e9ac4baede460cf5e7489886948af5Daniel Dunbar // Stack protectors default to on for 10.6 and beyond. 2405435fc9739e9ac4baede460cf5e7489886948af5Daniel Dunbar return !isTargetIPhoneOS() && !isMacosxVersionLT(10, 6); 2419e5cc6b703b2d0013f13800c2ffbeb3cf85fcfadDaniel Dunbar } 2428eddb3fb6ff3dd20e3920380e1ce56df105b8a98Daniel Dunbar virtual const char *GetDefaultRelocationModel() const; 2438eddb3fb6ff3dd20e3920380e1ce56df105b8a98Daniel Dunbar virtual const char *GetForcedPicModel() const; 2446b200b2b698b6ac9e310f2225c69c85d28ae4fb0Daniel Dunbar 245bbe8e3eff56ac1d79f3668d706536e3cebe28c18Daniel Dunbar virtual bool SupportsProfiling() const; 246bbe8e3eff56ac1d79f3668d706536e3cebe28c18Daniel Dunbar 24743a9b3263cb0bcb050cc75c15b3e6a8951e6b97aDaniel Dunbar virtual bool SupportsObjCGC() const; 24843a9b3263cb0bcb050cc75c15b3e6a8951e6b97aDaniel Dunbar 249f2d8b9f967a1ab53ee9fdbcc3ac0a4ee0a83a26eDaniel Dunbar virtual bool UseDwarfDebugFlags() const; 250f2d8b9f967a1ab53ee9fdbcc3ac0a4ee0a83a26eDaniel Dunbar 251b2987d159a88ab0ee2e40c884eb4d77b42ab89b6Daniel Dunbar virtual bool UseSjLjExceptions() const; 252b2987d159a88ab0ee2e40c884eb4d77b42ab89b6Daniel Dunbar 2536b200b2b698b6ac9e310f2225c69c85d28ae4fb0Daniel Dunbar /// } 2548eddb3fb6ff3dd20e3920380e1ce56df105b8a98Daniel Dunbar}; 2558eddb3fb6ff3dd20e3920380e1ce56df105b8a98Daniel Dunbar 2561d4612b829500cbe04a2eafca74afac703e34934Daniel Dunbar/// DarwinClang - The Darwin toolchain used by Clang. 25792dd1915842410005c68d32c43bb3b3cf5a4a702Duncan Sandsclass LLVM_LIBRARY_VISIBILITY DarwinClang : public Darwin { 2581d4612b829500cbe04a2eafca74afac703e34934Daniel Dunbarpublic: 25925b58eb7998ed947bc1c07e70de0b5d8f6aff857Daniel Dunbar DarwinClang(const HostInfo &Host, const llvm::Triple& Triple); 2601d4612b829500cbe04a2eafca74afac703e34934Daniel Dunbar 2611d4612b829500cbe04a2eafca74afac703e34934Daniel Dunbar /// @name Darwin ToolChain Implementation 2621d4612b829500cbe04a2eafca74afac703e34934Daniel Dunbar /// { 2631d4612b829500cbe04a2eafca74afac703e34934Daniel Dunbar 2641d4612b829500cbe04a2eafca74afac703e34934Daniel Dunbar virtual void AddLinkSearchPathArgs(const ArgList &Args, 2651d4612b829500cbe04a2eafca74afac703e34934Daniel Dunbar ArgStringList &CmdArgs) const; 2661d4612b829500cbe04a2eafca74afac703e34934Daniel Dunbar 2671d4612b829500cbe04a2eafca74afac703e34934Daniel Dunbar virtual void AddLinkRuntimeLibArgs(const ArgList &Args, 2681d4612b829500cbe04a2eafca74afac703e34934Daniel Dunbar ArgStringList &CmdArgs) const; 2693404fe7105ecc3baa58b7ea725773de4112259d6Eric Christopher void AddLinkRuntimeLib(const ArgList &Args, ArgStringList &CmdArgs, 2703404fe7105ecc3baa58b7ea725773de4112259d6Eric Christopher const char *DarwinStaticLib) const; 2713404fe7105ecc3baa58b7ea725773de4112259d6Eric Christopher 272132e35d2f87895d20e7ea146c8c00404b80221a1Daniel Dunbar virtual void AddCXXStdlibLibArgs(const ArgList &Args, 273132e35d2f87895d20e7ea146c8c00404b80221a1Daniel Dunbar ArgStringList &CmdArgs) const; 274efe91ea6bb6f45aaf663a43a1960998bc1eb9378Daniel Dunbar 2757433fedce98a58341d0f30c2e12e8d53f3bba575Shantonu Sen virtual void AddCCKextLibArgs(const ArgList &Args, 2767433fedce98a58341d0f30c2e12e8d53f3bba575Shantonu Sen ArgStringList &CmdArgs) const; 2777433fedce98a58341d0f30c2e12e8d53f3bba575Shantonu Sen 278f85e193739c953358c865005855253af4f68a497John McCall virtual void AddLinkARCArgs(const ArgList &Args, 279f85e193739c953358c865005855253af4f68a497John McCall ArgStringList &CmdArgs) const; 2801d4612b829500cbe04a2eafca74afac703e34934Daniel Dunbar /// } 2811d4612b829500cbe04a2eafca74afac703e34934Daniel Dunbar}; 2821d4612b829500cbe04a2eafca74afac703e34934Daniel Dunbar 2831d4612b829500cbe04a2eafca74afac703e34934Daniel Dunbar/// Darwin_Generic_GCC - Generic Darwin tool chain using gcc. 28492dd1915842410005c68d32c43bb3b3cf5a4a702Duncan Sandsclass LLVM_LIBRARY_VISIBILITY Darwin_Generic_GCC : public Generic_GCC { 2858eddb3fb6ff3dd20e3920380e1ce56df105b8a98Daniel Dunbarpublic: 2861d4612b829500cbe04a2eafca74afac703e34934Daniel Dunbar Darwin_Generic_GCC(const HostInfo &Host, const llvm::Triple& Triple) 287cb8ab23f7c800b041aeb6fc38c341d1aa0da86bfDaniel Dunbar : Generic_GCC(Host, Triple) {} 2888eddb3fb6ff3dd20e3920380e1ce56df105b8a98Daniel Dunbar 28900577ada44c889fbe311d61c51a8da89e65c7c9aDaniel Dunbar std::string ComputeEffectiveClangTriple(const ArgList &Args) const; 29000577ada44c889fbe311d61c51a8da89e65c7c9aDaniel Dunbar 2918eddb3fb6ff3dd20e3920380e1ce56df105b8a98Daniel Dunbar virtual const char *GetDefaultRelocationModel() const { return "pic"; } 2928eddb3fb6ff3dd20e3920380e1ce56df105b8a98Daniel Dunbar}; 2938eddb3fb6ff3dd20e3920380e1ce56df105b8a98Daniel Dunbar 294e43cfa1fdbf5b404a76e31f31b1505c7852a1967Rafael Espindolaclass LLVM_LIBRARY_VISIBILITY Generic_ELF : public Generic_GCC { 295e43cfa1fdbf5b404a76e31f31b1505c7852a1967Rafael Espindola public: 296e43cfa1fdbf5b404a76e31f31b1505c7852a1967Rafael Espindola Generic_ELF(const HostInfo &Host, const llvm::Triple& Triple) 297e43cfa1fdbf5b404a76e31f31b1505c7852a1967Rafael Espindola : Generic_GCC(Host, Triple) {} 298e43cfa1fdbf5b404a76e31f31b1505c7852a1967Rafael Espindola 299e43cfa1fdbf5b404a76e31f31b1505c7852a1967Rafael Espindola virtual bool IsIntegratedAssemblerDefault() const { 300e43cfa1fdbf5b404a76e31f31b1505c7852a1967Rafael Espindola // Default integrated assembler to on for x86. 301e43cfa1fdbf5b404a76e31f31b1505c7852a1967Rafael Espindola return (getTriple().getArch() == llvm::Triple::x86 || 302e43cfa1fdbf5b404a76e31f31b1505c7852a1967Rafael Espindola getTriple().getArch() == llvm::Triple::x86_64); 303e43cfa1fdbf5b404a76e31f31b1505c7852a1967Rafael Espindola } 304e43cfa1fdbf5b404a76e31f31b1505c7852a1967Rafael Espindola}; 305e43cfa1fdbf5b404a76e31f31b1505c7852a1967Rafael Espindola 30692dd1915842410005c68d32c43bb3b3cf5a4a702Duncan Sandsclass LLVM_LIBRARY_VISIBILITY AuroraUX : public Generic_GCC { 307e7925a075f110ab21afeae084670a155dea568e3Edward O'Callaghanpublic: 308e7925a075f110ab21afeae084670a155dea568e3Edward O'Callaghan AuroraUX(const HostInfo &Host, const llvm::Triple& Triple); 309e7925a075f110ab21afeae084670a155dea568e3Edward O'Callaghan 310ac0659ae4124156915eddf70e78065df224d34c8Daniel Dunbar virtual Tool &SelectTool(const Compilation &C, const JobAction &JA, 311ac0659ae4124156915eddf70e78065df224d34c8Daniel Dunbar const ActionList &Inputs) const; 312e7925a075f110ab21afeae084670a155dea568e3Edward O'Callaghan}; 313e7925a075f110ab21afeae084670a155dea568e3Edward O'Callaghan 314e43cfa1fdbf5b404a76e31f31b1505c7852a1967Rafael Espindolaclass LLVM_LIBRARY_VISIBILITY OpenBSD : public Generic_ELF { 315f7b8eec37c8c8012fa525c71fb29a58c9f29beefDaniel Dunbarpublic: 316f7b8eec37c8c8012fa525c71fb29a58c9f29beefDaniel Dunbar OpenBSD(const HostInfo &Host, const llvm::Triple& Triple); 317f7b8eec37c8c8012fa525c71fb29a58c9f29beefDaniel Dunbar 318ac0659ae4124156915eddf70e78065df224d34c8Daniel Dunbar virtual Tool &SelectTool(const Compilation &C, const JobAction &JA, 319ac0659ae4124156915eddf70e78065df224d34c8Daniel Dunbar const ActionList &Inputs) const; 320f7b8eec37c8c8012fa525c71fb29a58c9f29beefDaniel Dunbar}; 321f7b8eec37c8c8012fa525c71fb29a58c9f29beefDaniel Dunbar 322e43cfa1fdbf5b404a76e31f31b1505c7852a1967Rafael Espindolaclass LLVM_LIBRARY_VISIBILITY FreeBSD : public Generic_ELF { 32375358d267256022475371416654b056ad8531cb3Daniel Dunbarpublic: 324214afe96b4210ca36d99621dd930225e6bf5b9b3Daniel Dunbar FreeBSD(const HostInfo &Host, const llvm::Triple& Triple); 32575358d267256022475371416654b056ad8531cb3Daniel Dunbar 326ac0659ae4124156915eddf70e78065df224d34c8Daniel Dunbar virtual Tool &SelectTool(const Compilation &C, const JobAction &JA, 327ac0659ae4124156915eddf70e78065df224d34c8Daniel Dunbar const ActionList &Inputs) const; 32875358d267256022475371416654b056ad8531cb3Daniel Dunbar}; 32975358d267256022475371416654b056ad8531cb3Daniel Dunbar 3308e50a96b387dca7525caa8a6add31420dd82a2cdBenjamin Kramerclass LLVM_LIBRARY_VISIBILITY NetBSD : public Generic_ELF { 331182564cd14a2105fff05fd52f5940eff96161d57Joerg Sonnenberger const llvm::Triple ToolTriple; 332182564cd14a2105fff05fd52f5940eff96161d57Joerg Sonnenberger 3338e50a96b387dca7525caa8a6add31420dd82a2cdBenjamin Kramerpublic: 334182564cd14a2105fff05fd52f5940eff96161d57Joerg Sonnenberger NetBSD(const HostInfo &Host, const llvm::Triple& Triple, 335182564cd14a2105fff05fd52f5940eff96161d57Joerg Sonnenberger const llvm::Triple& ToolTriple); 3368e50a96b387dca7525caa8a6add31420dd82a2cdBenjamin Kramer 337ac0659ae4124156915eddf70e78065df224d34c8Daniel Dunbar virtual Tool &SelectTool(const Compilation &C, const JobAction &JA, 338ac0659ae4124156915eddf70e78065df224d34c8Daniel Dunbar const ActionList &Inputs) const; 3398e50a96b387dca7525caa8a6add31420dd82a2cdBenjamin Kramer}; 3408e50a96b387dca7525caa8a6add31420dd82a2cdBenjamin Kramer 34138e317d6dce161b249508686cc67eb7176958762Chris Lattnerclass LLVM_LIBRARY_VISIBILITY Minix : public Generic_GCC { 34238e317d6dce161b249508686cc67eb7176958762Chris Lattnerpublic: 34338e317d6dce161b249508686cc67eb7176958762Chris Lattner Minix(const HostInfo &Host, const llvm::Triple& Triple); 34438e317d6dce161b249508686cc67eb7176958762Chris Lattner 345ac0659ae4124156915eddf70e78065df224d34c8Daniel Dunbar virtual Tool &SelectTool(const Compilation &C, const JobAction &JA, 346ac0659ae4124156915eddf70e78065df224d34c8Daniel Dunbar const ActionList &Inputs) const; 34738e317d6dce161b249508686cc67eb7176958762Chris Lattner}; 34838e317d6dce161b249508686cc67eb7176958762Chris Lattner 349e43cfa1fdbf5b404a76e31f31b1505c7852a1967Rafael Espindolaclass LLVM_LIBRARY_VISIBILITY DragonFly : public Generic_ELF { 35011e1b40d759a643086f590f6ffbd9d68360bad46Daniel Dunbarpublic: 351cb8ab23f7c800b041aeb6fc38c341d1aa0da86bfDaniel Dunbar DragonFly(const HostInfo &Host, const llvm::Triple& Triple); 35211e1b40d759a643086f590f6ffbd9d68360bad46Daniel Dunbar 353ac0659ae4124156915eddf70e78065df224d34c8Daniel Dunbar virtual Tool &SelectTool(const Compilation &C, const JobAction &JA, 354ac0659ae4124156915eddf70e78065df224d34c8Daniel Dunbar const ActionList &Inputs) const; 35511e1b40d759a643086f590f6ffbd9d68360bad46Daniel Dunbar}; 35611e1b40d759a643086f590f6ffbd9d68360bad46Daniel Dunbar 357e43cfa1fdbf5b404a76e31f31b1505c7852a1967Rafael Espindolaclass LLVM_LIBRARY_VISIBILITY Linux : public Generic_ELF { 3586b3454a219cee5ef36c4668961f93a5c32deab61Eli Friedmanpublic: 3596b3454a219cee5ef36c4668961f93a5c32deab61Eli Friedman Linux(const HostInfo &Host, const llvm::Triple& Triple); 360ba30bbe4e36a30a274da809a11a42f9cdc168e92Rafael Espindola 361c1da981bba867681004004b2d54ec2fdf3c08913Rafael Espindola virtual bool HasNativeLLVMSupport() const; 362c1da981bba867681004004b2d54ec2fdf3c08913Rafael Espindola 363ac0659ae4124156915eddf70e78065df224d34c8Daniel Dunbar virtual Tool &SelectTool(const Compilation &C, const JobAction &JA, 364ac0659ae4124156915eddf70e78065df224d34c8Daniel Dunbar const ActionList &Inputs) const; 365c1da981bba867681004004b2d54ec2fdf3c08913Rafael Espindola 366c1da981bba867681004004b2d54ec2fdf3c08913Rafael Espindola std::string Linker; 367c1da981bba867681004004b2d54ec2fdf3c08913Rafael Espindola std::vector<std::string> ExtraOpts; 3686b3454a219cee5ef36c4668961f93a5c32deab61Eli Friedman}; 3696b3454a219cee5ef36c4668961f93a5c32deab61Eli Friedman 3706b3454a219cee5ef36c4668961f93a5c32deab61Eli Friedman 3713a47c4e0a3e8d13ee4fb06cc3a98f9cfa9982400Chris Lattner/// TCEToolChain - A tool chain using the llvm bitcode tools to perform 3723a47c4e0a3e8d13ee4fb06cc3a98f9cfa9982400Chris Lattner/// all subcommands. See http://tce.cs.tut.fi for our peculiar target. 37392dd1915842410005c68d32c43bb3b3cf5a4a702Duncan Sandsclass LLVM_LIBRARY_VISIBILITY TCEToolChain : public ToolChain { 3743a47c4e0a3e8d13ee4fb06cc3a98f9cfa9982400Chris Lattnerpublic: 3753a47c4e0a3e8d13ee4fb06cc3a98f9cfa9982400Chris Lattner TCEToolChain(const HostInfo &Host, const llvm::Triple& Triple); 3763a47c4e0a3e8d13ee4fb06cc3a98f9cfa9982400Chris Lattner ~TCEToolChain(); 3773a47c4e0a3e8d13ee4fb06cc3a98f9cfa9982400Chris Lattner 378ac0659ae4124156915eddf70e78065df224d34c8Daniel Dunbar virtual Tool &SelectTool(const Compilation &C, const JobAction &JA, 379ac0659ae4124156915eddf70e78065df224d34c8Daniel Dunbar const ActionList &Inputs) const; 3803a47c4e0a3e8d13ee4fb06cc3a98f9cfa9982400Chris Lattner bool IsMathErrnoDefault() const; 3813a47c4e0a3e8d13ee4fb06cc3a98f9cfa9982400Chris Lattner bool IsUnwindTablesDefault() const; 3823a47c4e0a3e8d13ee4fb06cc3a98f9cfa9982400Chris Lattner const char* GetDefaultRelocationModel() const; 3833a47c4e0a3e8d13ee4fb06cc3a98f9cfa9982400Chris Lattner const char* GetForcedPicModel() const; 3843a47c4e0a3e8d13ee4fb06cc3a98f9cfa9982400Chris Lattner 3853a47c4e0a3e8d13ee4fb06cc3a98f9cfa9982400Chris Lattnerprivate: 3863a47c4e0a3e8d13ee4fb06cc3a98f9cfa9982400Chris Lattner mutable llvm::DenseMap<unsigned, Tool*> Tools; 3873a47c4e0a3e8d13ee4fb06cc3a98f9cfa9982400Chris Lattner 3883a47c4e0a3e8d13ee4fb06cc3a98f9cfa9982400Chris Lattner}; 3893a47c4e0a3e8d13ee4fb06cc3a98f9cfa9982400Chris Lattner 390ff58e3610f4e12094def69eb2d6dcb4330378d8fMichael J. Spencerclass LLVM_LIBRARY_VISIBILITY Windows : public ToolChain { 391ff58e3610f4e12094def69eb2d6dcb4330378d8fMichael J. Spencer mutable llvm::DenseMap<unsigned, Tool*> Tools; 392ff58e3610f4e12094def69eb2d6dcb4330378d8fMichael J. Spencer 393ff58e3610f4e12094def69eb2d6dcb4330378d8fMichael J. Spencerpublic: 394ff58e3610f4e12094def69eb2d6dcb4330378d8fMichael J. Spencer Windows(const HostInfo &Host, const llvm::Triple& Triple); 395ff58e3610f4e12094def69eb2d6dcb4330378d8fMichael J. Spencer 396ac0659ae4124156915eddf70e78065df224d34c8Daniel Dunbar virtual Tool &SelectTool(const Compilation &C, const JobAction &JA, 397ac0659ae4124156915eddf70e78065df224d34c8Daniel Dunbar const ActionList &Inputs) const; 398ff58e3610f4e12094def69eb2d6dcb4330378d8fMichael J. Spencer 399ff58e3610f4e12094def69eb2d6dcb4330378d8fMichael J. Spencer virtual bool IsIntegratedAssemblerDefault() const; 400ff58e3610f4e12094def69eb2d6dcb4330378d8fMichael J. Spencer virtual bool IsUnwindTablesDefault() const; 401ff58e3610f4e12094def69eb2d6dcb4330378d8fMichael J. Spencer virtual const char *GetDefaultRelocationModel() const; 402ff58e3610f4e12094def69eb2d6dcb4330378d8fMichael J. Spencer virtual const char *GetForcedPicModel() const; 403ff58e3610f4e12094def69eb2d6dcb4330378d8fMichael J. Spencer}; 404ff58e3610f4e12094def69eb2d6dcb4330378d8fMichael J. Spencer 40583b08eb6d2a7f71328db51baa79c654bb9dcc55dDaniel Dunbar} // end namespace toolchains 40683b08eb6d2a7f71328db51baa79c654bb9dcc55dDaniel Dunbar} // end namespace driver 40783b08eb6d2a7f71328db51baa79c654bb9dcc55dDaniel Dunbar} // end namespace clang 40883b08eb6d2a7f71328db51baa79c654bb9dcc55dDaniel Dunbar 40983b08eb6d2a7f71328db51baa79c654bb9dcc55dDaniel Dunbar#endif 410