2011-01-01 01:31:54 +08:00
|
|
|
//===--- ToolChains.cpp - ToolChain Implementations -----------------------===//
|
2009-03-20 08:20:03 +08:00
|
|
|
//
|
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
|
|
|
// This file is distributed under the University of Illinois Open Source
|
|
|
|
// License. See LICENSE.TXT for details.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
#include "ToolChains.h"
|
|
|
|
|
2011-06-03 06:18:46 +08:00
|
|
|
#ifdef HAVE_CLANG_CONFIG_H
|
|
|
|
# include "clang/Config/config.h"
|
|
|
|
#endif
|
|
|
|
|
2009-03-25 12:13:45 +08:00
|
|
|
#include "clang/Driver/Arg.h"
|
|
|
|
#include "clang/Driver/ArgList.h"
|
2010-05-21 05:48:38 +08:00
|
|
|
#include "clang/Driver/Compilation.h"
|
2009-03-24 00:15:50 +08:00
|
|
|
#include "clang/Driver/Driver.h"
|
2009-03-25 14:12:34 +08:00
|
|
|
#include "clang/Driver/DriverDiagnostic.h"
|
2011-07-06 08:26:06 +08:00
|
|
|
#include "clang/Driver/ObjCRuntime.h"
|
2009-11-19 08:15:11 +08:00
|
|
|
#include "clang/Driver/OptTable.h"
|
2009-03-25 14:12:34 +08:00
|
|
|
#include "clang/Driver/Option.h"
|
2009-11-19 12:25:22 +08:00
|
|
|
#include "clang/Driver/Options.h"
|
2010-09-04 01:16:03 +08:00
|
|
|
#include "clang/Basic/Version.h"
|
2009-03-24 00:15:50 +08:00
|
|
|
|
2010-08-24 06:35:37 +08:00
|
|
|
#include "llvm/ADT/SmallString.h"
|
2009-03-24 00:15:50 +08:00
|
|
|
#include "llvm/ADT/StringExtras.h"
|
2011-10-07 08:37:57 +08:00
|
|
|
#include "llvm/ADT/StringSwitch.h"
|
2011-06-16 07:02:42 +08:00
|
|
|
#include "llvm/ADT/STLExtras.h"
|
2009-09-10 06:33:15 +08:00
|
|
|
#include "llvm/Support/ErrorHandling.h"
|
2011-01-10 10:34:13 +08:00
|
|
|
#include "llvm/Support/FileSystem.h"
|
2010-11-08 04:14:31 +08:00
|
|
|
#include "llvm/Support/MemoryBuffer.h"
|
2009-03-25 14:58:31 +08:00
|
|
|
#include "llvm/Support/raw_ostream.h"
|
2010-11-30 02:12:39 +08:00
|
|
|
#include "llvm/Support/Path.h"
|
2010-12-10 01:36:38 +08:00
|
|
|
#include "llvm/Support/system_error.h"
|
2009-03-24 00:15:50 +08:00
|
|
|
|
2009-04-11 05:00:07 +08:00
|
|
|
#include <cstdlib> // ::getenv
|
|
|
|
|
2011-06-23 21:50:47 +08:00
|
|
|
#include "llvm/Config/config.h" // for CXX_INCLUDE_ROOT
|
|
|
|
|
2009-03-20 08:20:03 +08:00
|
|
|
using namespace clang::driver;
|
|
|
|
using namespace clang::driver::toolchains;
|
2011-07-23 18:55:15 +08:00
|
|
|
using namespace clang;
|
2009-03-20 08:20:03 +08:00
|
|
|
|
2009-09-05 02:34:51 +08:00
|
|
|
/// Darwin - Darwin tool chain for i386 and x86_64.
|
2009-03-20 08:57:52 +08:00
|
|
|
|
2012-01-25 17:12:06 +08:00
|
|
|
Darwin::Darwin(const Driver &D, const llvm::Triple& Triple)
|
|
|
|
: ToolChain(D, Triple), TargetInitialized(false),
|
2011-10-08 01:54:41 +08:00
|
|
|
ARCRuntimeForSimulator(ARCSimulator_None),
|
|
|
|
LibCXXForSimulator(LibCXXSimulator_None)
|
2009-09-18 16:15:13 +08:00
|
|
|
{
|
2010-08-02 13:44:07 +08:00
|
|
|
// Compute the initial Darwin version based on the host.
|
|
|
|
bool HadExtra;
|
|
|
|
std::string OSName = Triple.getOSName();
|
2011-02-26 05:20:15 +08:00
|
|
|
if (!Driver::GetReleaseVersion(&OSName.c_str()[6],
|
2010-08-02 13:44:07 +08:00
|
|
|
DarwinVersion[0], DarwinVersion[1],
|
|
|
|
DarwinVersion[2], HadExtra))
|
2011-07-23 18:55:15 +08:00
|
|
|
getDriver().Diag(diag::err_drv_invalid_darwin_version) << OSName;
|
2010-08-02 13:44:07 +08:00
|
|
|
|
2009-03-27 00:23:12 +08:00
|
|
|
llvm::raw_string_ostream(MacosxVersionMin)
|
2010-08-02 13:44:07 +08:00
|
|
|
<< "10." << std::max(0, (int)DarwinVersion[0] - 4) << '.'
|
|
|
|
<< DarwinVersion[1];
|
2009-09-18 16:15:13 +08:00
|
|
|
}
|
|
|
|
|
2010-08-02 13:43:56 +08:00
|
|
|
types::ID Darwin::LookupTypeForExtension(const char *Ext) const {
|
|
|
|
types::ID Ty = types::lookupTypeForExtension(Ext);
|
|
|
|
|
|
|
|
// Darwin always preprocesses assembly files (unless -x is used explicitly).
|
|
|
|
if (Ty == types::TY_PP_Asm)
|
|
|
|
return types::TY_Asm;
|
|
|
|
|
|
|
|
return Ty;
|
|
|
|
}
|
|
|
|
|
2010-09-17 08:24:52 +08:00
|
|
|
bool Darwin::HasNativeLLVMSupport() const {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2011-07-06 08:26:06 +08:00
|
|
|
bool Darwin::hasARCRuntime() const {
|
2011-06-16 07:02:42 +08:00
|
|
|
// FIXME: Remove this once there is a proper way to detect an ARC runtime
|
|
|
|
// for the simulator.
|
|
|
|
switch (ARCRuntimeForSimulator) {
|
|
|
|
case ARCSimulator_None:
|
|
|
|
break;
|
|
|
|
case ARCSimulator_HasARCRuntime:
|
|
|
|
return true;
|
|
|
|
case ARCSimulator_NoARCRuntime:
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (isTargetIPhoneOS())
|
|
|
|
return !isIPhoneOSVersionLT(5);
|
|
|
|
else
|
|
|
|
return !isMacosxVersionLT(10, 7);
|
|
|
|
}
|
|
|
|
|
2011-07-06 08:26:06 +08:00
|
|
|
/// Darwin provides an ARC runtime starting in MacOS X 10.7 and iOS 5.0.
|
|
|
|
void Darwin::configureObjCRuntime(ObjCRuntime &runtime) const {
|
|
|
|
if (runtime.getKind() != ObjCRuntime::NeXT)
|
|
|
|
return ToolChain::configureObjCRuntime(runtime);
|
|
|
|
|
|
|
|
runtime.HasARC = runtime.HasWeak = hasARCRuntime();
|
2011-07-06 09:22:26 +08:00
|
|
|
|
|
|
|
// So far, objc_terminate is only available in iOS 5.
|
|
|
|
// FIXME: do the simulator logic properly.
|
|
|
|
if (!ARCRuntimeForSimulator && isTargetIPhoneOS())
|
|
|
|
runtime.HasTerminate = !isIPhoneOSVersionLT(5);
|
|
|
|
else
|
|
|
|
runtime.HasTerminate = false;
|
2011-07-06 08:26:06 +08:00
|
|
|
}
|
|
|
|
|
2011-09-10 04:41:01 +08:00
|
|
|
/// Darwin provides a blocks runtime starting in MacOS X 10.6 and iOS 3.2.
|
|
|
|
bool Darwin::hasBlocksRuntime() const {
|
|
|
|
if (isTargetIPhoneOS())
|
|
|
|
return !isIPhoneOSVersionLT(3, 2);
|
|
|
|
else
|
|
|
|
return !isMacosxVersionLT(10, 6);
|
|
|
|
}
|
|
|
|
|
2011-07-23 18:55:15 +08:00
|
|
|
static const char *GetArmArchForMArch(StringRef Value) {
|
2011-10-07 08:37:57 +08:00
|
|
|
return llvm::StringSwitch<const char*>(Value)
|
|
|
|
.Case("armv6k", "armv6")
|
|
|
|
.Case("armv5tej", "armv5")
|
|
|
|
.Case("xscale", "xscale")
|
|
|
|
.Case("armv4t", "armv4t")
|
|
|
|
.Case("armv7", "armv7")
|
|
|
|
.Cases("armv7a", "armv7-a", "armv7")
|
|
|
|
.Cases("armv7r", "armv7-r", "armv7")
|
|
|
|
.Cases("armv7m", "armv7-m", "armv7")
|
|
|
|
.Default(0);
|
2010-01-22 10:04:58 +08:00
|
|
|
}
|
|
|
|
|
2011-07-23 18:55:15 +08:00
|
|
|
static const char *GetArmArchForMCpu(StringRef Value) {
|
2011-10-07 08:37:57 +08:00
|
|
|
return llvm::StringSwitch<const char *>(Value)
|
|
|
|
.Cases("arm9e", "arm946e-s", "arm966e-s", "arm968e-s", "arm926ej-s","armv5")
|
|
|
|
.Cases("arm10e", "arm10tdmi", "armv5")
|
|
|
|
.Cases("arm1020t", "arm1020e", "arm1022e", "arm1026ej-s", "armv5")
|
|
|
|
.Case("xscale", "xscale")
|
|
|
|
.Cases("arm1136j-s", "arm1136jf-s", "arm1176jz-s",
|
|
|
|
"arm1176jzf-s", "cortex-m0", "armv6")
|
|
|
|
.Cases("cortex-a8", "cortex-r4", "cortex-m3", "cortex-a9", "armv7")
|
|
|
|
.Default(0);
|
2010-01-22 10:04:58 +08:00
|
|
|
}
|
|
|
|
|
2011-07-23 18:55:15 +08:00
|
|
|
StringRef Darwin::getDarwinArchName(const ArgList &Args) const {
|
2010-01-22 10:04:58 +08:00
|
|
|
switch (getTriple().getArch()) {
|
|
|
|
default:
|
|
|
|
return getArchName();
|
2011-06-03 11:49:51 +08:00
|
|
|
|
2011-03-07 03:11:49 +08:00
|
|
|
case llvm::Triple::thumb:
|
2010-01-22 10:04:58 +08:00
|
|
|
case llvm::Triple::arm: {
|
|
|
|
if (const Arg *A = Args.getLastArg(options::OPT_march_EQ))
|
|
|
|
if (const char *Arch = GetArmArchForMArch(A->getValue(Args)))
|
|
|
|
return Arch;
|
|
|
|
|
|
|
|
if (const Arg *A = Args.getLastArg(options::OPT_mcpu_EQ))
|
|
|
|
if (const char *Arch = GetArmArchForMCpu(A->getValue(Args)))
|
|
|
|
return Arch;
|
|
|
|
|
|
|
|
return "arm";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-09-05 02:34:51 +08:00
|
|
|
Darwin::~Darwin() {
|
2009-03-20 08:57:52 +08:00
|
|
|
// Free tool implementations.
|
|
|
|
for (llvm::DenseMap<unsigned, Tool*>::iterator
|
|
|
|
it = Tools.begin(), ie = Tools.end(); it != ie; ++it)
|
|
|
|
delete it->second;
|
|
|
|
}
|
|
|
|
|
2011-09-21 04:44:06 +08:00
|
|
|
std::string Darwin::ComputeEffectiveClangTriple(const ArgList &Args,
|
|
|
|
types::ID InputType) const {
|
|
|
|
llvm::Triple Triple(ComputeLLVMTriple(Args, InputType));
|
2010-08-24 06:35:37 +08:00
|
|
|
|
|
|
|
// If the target isn't initialized (e.g., an unknown Darwin platform, return
|
|
|
|
// the default triple).
|
|
|
|
if (!isTargetInitialized())
|
|
|
|
return Triple.getTriple();
|
2011-06-03 11:49:51 +08:00
|
|
|
|
2010-08-24 06:35:37 +08:00
|
|
|
unsigned Version[3];
|
|
|
|
getTargetVersion(Version);
|
2011-06-03 11:49:51 +08:00
|
|
|
|
2010-08-24 06:35:37 +08:00
|
|
|
llvm::SmallString<16> Str;
|
2011-04-20 05:45:47 +08:00
|
|
|
llvm::raw_svector_ostream(Str)
|
2011-04-20 07:34:17 +08:00
|
|
|
<< (isTargetIPhoneOS() ? "ios" : "macosx")
|
2011-04-20 05:45:47 +08:00
|
|
|
<< Version[0] << "." << Version[1] << "." << Version[2];
|
2010-08-24 06:35:37 +08:00
|
|
|
Triple.setOSName(Str.str());
|
|
|
|
|
|
|
|
return Triple.getTriple();
|
|
|
|
}
|
|
|
|
|
2011-12-20 10:48:34 +08:00
|
|
|
void Generic_ELF::anchor() {}
|
|
|
|
|
2011-03-19 04:14:00 +08:00
|
|
|
Tool &Darwin::SelectTool(const Compilation &C, const JobAction &JA,
|
|
|
|
const ActionList &Inputs) const {
|
2009-03-20 08:57:52 +08:00
|
|
|
Action::ActionClass Key;
|
2011-03-19 04:14:03 +08:00
|
|
|
|
|
|
|
if (getDriver().ShouldUseClangCompiler(C, JA, getTriple())) {
|
|
|
|
// Fallback to llvm-gcc for i386 kext compiles, we don't support that ABI.
|
|
|
|
if (Inputs.size() == 1 &&
|
|
|
|
types::isCXX(Inputs[0]->getType()) &&
|
2011-10-14 13:03:44 +08:00
|
|
|
getTriple().isOSDarwin() &&
|
2011-03-19 04:14:03 +08:00
|
|
|
getTriple().getArch() == llvm::Triple::x86 &&
|
2011-08-14 07:48:55 +08:00
|
|
|
(C.getArgs().getLastArg(options::OPT_fapple_kext) ||
|
|
|
|
C.getArgs().getLastArg(options::OPT_mkernel)))
|
2011-03-19 04:14:03 +08:00
|
|
|
Key = JA.getKind();
|
|
|
|
else
|
|
|
|
Key = Action::AnalyzeJobClass;
|
|
|
|
} else
|
2009-03-20 08:57:52 +08:00
|
|
|
Key = JA.getKind();
|
|
|
|
|
2010-05-21 05:48:38 +08:00
|
|
|
bool UseIntegratedAs = C.getArgs().hasFlag(options::OPT_integrated_as,
|
|
|
|
options::OPT_no_integrated_as,
|
2011-10-30 08:20:28 +08:00
|
|
|
IsIntegratedAssemblerDefault());
|
2010-05-21 05:48:38 +08:00
|
|
|
|
2009-03-20 08:57:52 +08:00
|
|
|
Tool *&T = Tools[Key];
|
|
|
|
if (!T) {
|
|
|
|
switch (Key) {
|
|
|
|
case Action::InputClass:
|
|
|
|
case Action::BindArchClass:
|
2011-09-23 13:06:16 +08:00
|
|
|
llvm_unreachable("Invalid tool kind.");
|
2009-03-20 08:57:52 +08:00
|
|
|
case Action::PreprocessJobClass:
|
2009-03-30 06:27:40 +08:00
|
|
|
T = new tools::darwin::Preprocess(*this); break;
|
2009-03-20 08:57:52 +08:00
|
|
|
case Action::AnalyzeJobClass:
|
|
|
|
T = new tools::Clang(*this); break;
|
2009-03-30 06:27:40 +08:00
|
|
|
case Action::PrecompileJobClass:
|
2009-03-20 08:57:52 +08:00
|
|
|
case Action::CompileJobClass:
|
2009-03-30 06:27:40 +08:00
|
|
|
T = new tools::darwin::Compile(*this); break;
|
2010-05-21 05:48:38 +08:00
|
|
|
case Action::AssembleJobClass: {
|
|
|
|
if (UseIntegratedAs)
|
|
|
|
T = new tools::ClangAs(*this);
|
|
|
|
else
|
|
|
|
T = new tools::darwin::Assemble(*this);
|
|
|
|
break;
|
|
|
|
}
|
2009-03-20 08:57:52 +08:00
|
|
|
case Action::LinkJobClass:
|
2009-09-05 01:39:02 +08:00
|
|
|
T = new tools::darwin::Link(*this); break;
|
2009-03-20 08:57:52 +08:00
|
|
|
case Action::LipoJobClass:
|
|
|
|
T = new tools::darwin::Lipo(*this); break;
|
2010-06-05 02:28:36 +08:00
|
|
|
case Action::DsymutilJobClass:
|
|
|
|
T = new tools::darwin::Dsymutil(*this); break;
|
2011-08-24 01:56:55 +08:00
|
|
|
case Action::VerifyJobClass:
|
|
|
|
T = new tools::darwin::VerifyDebug(*this); break;
|
2009-03-20 08:57:52 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return *T;
|
|
|
|
}
|
|
|
|
|
2009-09-18 16:15:03 +08:00
|
|
|
|
2012-01-25 17:12:06 +08:00
|
|
|
DarwinClang::DarwinClang(const Driver &D, const llvm::Triple& Triple)
|
|
|
|
: Darwin(D, Triple)
|
2009-09-18 16:15:13 +08:00
|
|
|
{
|
2010-09-17 16:22:12 +08:00
|
|
|
getProgramPaths().push_back(getDriver().getInstalledDir());
|
|
|
|
if (getDriver().getInstalledDir() != getDriver().Dir)
|
|
|
|
getProgramPaths().push_back(getDriver().Dir);
|
|
|
|
|
2009-09-18 16:15:13 +08:00
|
|
|
// We expect 'as', 'ld', etc. to be adjacent to our install dir.
|
2010-08-02 06:29:51 +08:00
|
|
|
getProgramPaths().push_back(getDriver().getInstalledDir());
|
|
|
|
if (getDriver().getInstalledDir() != getDriver().Dir)
|
|
|
|
getProgramPaths().push_back(getDriver().Dir);
|
2010-09-17 16:22:12 +08:00
|
|
|
|
|
|
|
// For fallback, we need to know how to find the GCC cc1 executables, so we
|
2011-03-19 03:25:15 +08:00
|
|
|
// also add the GCC libexec paths. This is legacy code that can be removed
|
|
|
|
// once fallback is no longer useful.
|
2011-09-21 06:00:38 +08:00
|
|
|
AddGCCLibexecPath(DarwinVersion[0]);
|
|
|
|
AddGCCLibexecPath(DarwinVersion[0] - 2);
|
|
|
|
AddGCCLibexecPath(DarwinVersion[0] - 1);
|
|
|
|
AddGCCLibexecPath(DarwinVersion[0] + 1);
|
|
|
|
AddGCCLibexecPath(DarwinVersion[0] + 2);
|
|
|
|
}
|
|
|
|
|
|
|
|
void DarwinClang::AddGCCLibexecPath(unsigned darwinVersion) {
|
2010-09-17 16:22:12 +08:00
|
|
|
std::string ToolChainDir = "i686-apple-darwin";
|
2011-09-21 06:00:38 +08:00
|
|
|
ToolChainDir += llvm::utostr(darwinVersion);
|
2010-09-17 16:22:12 +08:00
|
|
|
ToolChainDir += "/4.2.1";
|
|
|
|
|
|
|
|
std::string Path = getDriver().Dir;
|
2011-09-21 06:00:38 +08:00
|
|
|
Path += "/../llvm-gcc-4.2/libexec/gcc/";
|
2010-09-17 16:22:12 +08:00
|
|
|
Path += ToolChainDir;
|
|
|
|
getProgramPaths().push_back(Path);
|
|
|
|
|
2011-09-21 06:00:38 +08:00
|
|
|
Path = "/usr/llvm-gcc-4.2/libexec/gcc/";
|
2010-09-17 16:22:12 +08:00
|
|
|
Path += ToolChainDir;
|
|
|
|
getProgramPaths().push_back(Path);
|
2009-09-18 16:15:13 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void DarwinClang::AddLinkSearchPathArgs(const ArgList &Args,
|
|
|
|
ArgStringList &CmdArgs) const {
|
|
|
|
// The Clang toolchain uses explicit paths for internal libraries.
|
2010-07-01 07:56:13 +08:00
|
|
|
|
|
|
|
// Unfortunately, we still might depend on a few of the libraries that are
|
|
|
|
// only available in the gcc library directory (in particular
|
|
|
|
// libstdc++.dylib). For now, hardcode the path to the known install location.
|
2011-11-11 15:47:04 +08:00
|
|
|
// FIXME: This should get ripped out someday. However, when building on
|
|
|
|
// 10.6 (darwin10), we're still relying on this to find libstdc++.dylib.
|
2010-07-01 07:56:13 +08:00
|
|
|
llvm::sys::Path P(getDriver().Dir);
|
|
|
|
P.eraseComponent(); // .../usr/bin -> ../usr
|
2011-11-11 15:47:04 +08:00
|
|
|
P.appendComponent("llvm-gcc-4.2");
|
2010-07-01 07:56:13 +08:00
|
|
|
P.appendComponent("lib");
|
|
|
|
P.appendComponent("gcc");
|
|
|
|
switch (getTriple().getArch()) {
|
|
|
|
default:
|
2011-09-23 13:06:16 +08:00
|
|
|
llvm_unreachable("Invalid Darwin arch!");
|
2010-07-01 07:56:13 +08:00
|
|
|
case llvm::Triple::x86:
|
|
|
|
case llvm::Triple::x86_64:
|
|
|
|
P.appendComponent("i686-apple-darwin10");
|
|
|
|
break;
|
|
|
|
case llvm::Triple::arm:
|
|
|
|
case llvm::Triple::thumb:
|
|
|
|
P.appendComponent("arm-apple-darwin10");
|
|
|
|
break;
|
|
|
|
case llvm::Triple::ppc:
|
|
|
|
case llvm::Triple::ppc64:
|
|
|
|
P.appendComponent("powerpc-apple-darwin10");
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
P.appendComponent("4.2.1");
|
2010-08-24 04:58:52 +08:00
|
|
|
|
|
|
|
// Determine the arch specific GCC subdirectory.
|
|
|
|
const char *ArchSpecificDir = 0;
|
|
|
|
switch (getTriple().getArch()) {
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
case llvm::Triple::arm:
|
2010-08-26 08:55:52 +08:00
|
|
|
case llvm::Triple::thumb: {
|
|
|
|
std::string Triple = ComputeLLVMTriple(Args);
|
2011-07-23 18:55:15 +08:00
|
|
|
StringRef TripleStr = Triple;
|
2010-08-26 08:55:52 +08:00
|
|
|
if (TripleStr.startswith("armv5") || TripleStr.startswith("thumbv5"))
|
|
|
|
ArchSpecificDir = "v5";
|
|
|
|
else if (TripleStr.startswith("armv6") || TripleStr.startswith("thumbv6"))
|
|
|
|
ArchSpecificDir = "v6";
|
|
|
|
else if (TripleStr.startswith("armv7") || TripleStr.startswith("thumbv7"))
|
|
|
|
ArchSpecificDir = "v7";
|
2010-08-24 04:58:52 +08:00
|
|
|
break;
|
2010-08-26 08:55:52 +08:00
|
|
|
}
|
2010-08-24 04:58:52 +08:00
|
|
|
case llvm::Triple::ppc64:
|
|
|
|
ArchSpecificDir = "ppc64";
|
|
|
|
break;
|
|
|
|
case llvm::Triple::x86_64:
|
|
|
|
ArchSpecificDir = "x86_64";
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (ArchSpecificDir) {
|
|
|
|
P.appendComponent(ArchSpecificDir);
|
2011-01-10 10:34:13 +08:00
|
|
|
bool Exists;
|
|
|
|
if (!llvm::sys::fs::exists(P.str(), Exists) && Exists)
|
2010-08-24 04:58:52 +08:00
|
|
|
CmdArgs.push_back(Args.MakeArgString("-L" + P.str()));
|
|
|
|
P.eraseComponent();
|
|
|
|
}
|
|
|
|
|
2011-01-10 10:34:13 +08:00
|
|
|
bool Exists;
|
|
|
|
if (!llvm::sys::fs::exists(P.str(), Exists) && Exists)
|
2010-07-01 07:56:13 +08:00
|
|
|
CmdArgs.push_back(Args.MakeArgString("-L" + P.str()));
|
2009-09-18 16:15:13 +08:00
|
|
|
}
|
|
|
|
|
2011-06-16 07:02:42 +08:00
|
|
|
void DarwinClang::AddLinkARCArgs(const ArgList &Args,
|
|
|
|
ArgStringList &CmdArgs) const {
|
2011-08-24 01:56:55 +08:00
|
|
|
|
|
|
|
CmdArgs.push_back("-force_load");
|
2011-06-16 07:02:42 +08:00
|
|
|
llvm::sys::Path P(getDriver().ClangExecutable);
|
|
|
|
P.eraseComponent(); // 'clang'
|
|
|
|
P.eraseComponent(); // 'bin'
|
|
|
|
P.appendComponent("lib");
|
|
|
|
P.appendComponent("arc");
|
|
|
|
P.appendComponent("libarclite_");
|
|
|
|
std::string s = P.str();
|
|
|
|
// Mash in the platform.
|
2011-10-19 01:40:15 +08:00
|
|
|
if (isTargetIOSSimulator())
|
|
|
|
s += "iphonesimulator";
|
|
|
|
else if (isTargetIPhoneOS())
|
2011-06-16 07:02:42 +08:00
|
|
|
s += "iphoneos";
|
2011-10-19 01:40:15 +08:00
|
|
|
// FIXME: Remove this once we depend fully on -mios-simulator-version-min.
|
2011-06-16 07:02:42 +08:00
|
|
|
else if (ARCRuntimeForSimulator != ARCSimulator_None)
|
|
|
|
s += "iphonesimulator";
|
|
|
|
else
|
|
|
|
s += "macosx";
|
|
|
|
s += ".a";
|
|
|
|
|
|
|
|
CmdArgs.push_back(Args.MakeArgString(s));
|
|
|
|
}
|
|
|
|
|
2011-06-23 01:41:40 +08:00
|
|
|
void DarwinClang::AddLinkRuntimeLib(const ArgList &Args,
|
2011-08-24 01:56:55 +08:00
|
|
|
ArgStringList &CmdArgs,
|
2011-06-23 01:41:40 +08:00
|
|
|
const char *DarwinStaticLib) const {
|
|
|
|
llvm::sys::Path P(getDriver().ResourceDir);
|
|
|
|
P.appendComponent("lib");
|
|
|
|
P.appendComponent("darwin");
|
|
|
|
P.appendComponent(DarwinStaticLib);
|
2011-08-24 01:56:55 +08:00
|
|
|
|
2011-06-23 01:41:40 +08:00
|
|
|
// For now, allow missing resource libraries to support developers who may
|
|
|
|
// not have compiler-rt checked out or integrated into their build.
|
|
|
|
bool Exists;
|
|
|
|
if (!llvm::sys::fs::exists(P.str(), Exists) && Exists)
|
|
|
|
CmdArgs.push_back(Args.MakeArgString(P.str()));
|
|
|
|
}
|
|
|
|
|
2009-09-18 16:15:13 +08:00
|
|
|
void DarwinClang::AddLinkRuntimeLibArgs(const ArgList &Args,
|
|
|
|
ArgStringList &CmdArgs) const {
|
2011-12-08 07:03:15 +08:00
|
|
|
// Darwin only supports the compiler-rt based runtime libraries.
|
|
|
|
switch (GetRuntimeLibType(Args)) {
|
|
|
|
case ToolChain::RLT_CompilerRT:
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
getDriver().Diag(diag::err_drv_unsupported_rtlib_for_platform)
|
|
|
|
<< Args.getLastArg(options::OPT_rtlib_EQ)->getValue(Args) << "darwin";
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2010-01-22 11:38:14 +08:00
|
|
|
// Darwin doesn't support real static executables, don't link any runtime
|
|
|
|
// libraries with -static.
|
|
|
|
if (Args.hasArg(options::OPT_static))
|
2009-09-18 16:15:13 +08:00
|
|
|
return;
|
|
|
|
|
|
|
|
// Reject -static-libgcc for now, we can deal with this when and if someone
|
|
|
|
// cares. This is useful in situations where someone wants to statically link
|
|
|
|
// something like libstdc++, and needs its runtime support routines.
|
|
|
|
if (const Arg *A = Args.getLastArg(options::OPT_static_libgcc)) {
|
2011-07-23 18:55:15 +08:00
|
|
|
getDriver().Diag(diag::err_drv_unsupported_opt)
|
2009-09-18 16:15:13 +08:00
|
|
|
<< A->getAsString(Args);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2011-11-17 08:36:57 +08:00
|
|
|
// If we are building profile support, link that library in.
|
|
|
|
if (Args.hasArg(options::OPT_fprofile_arcs) ||
|
|
|
|
Args.hasArg(options::OPT_fprofile_generate) ||
|
|
|
|
Args.hasArg(options::OPT_fcreate_profile) ||
|
|
|
|
Args.hasArg(options::OPT_coverage)) {
|
|
|
|
// Select the appropriate runtime library for the target.
|
|
|
|
if (isTargetIPhoneOS()) {
|
|
|
|
AddLinkRuntimeLib(Args, CmdArgs, "libclang_rt.profile_ios.a");
|
|
|
|
} else {
|
|
|
|
AddLinkRuntimeLib(Args, CmdArgs, "libclang_rt.profile_osx.a");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-12-07 03:18:44 +08:00
|
|
|
// Add ASAN runtime library, if required. Dynamic libraries and bundles
|
|
|
|
// should not be linked with the runtime library.
|
2011-12-02 07:40:18 +08:00
|
|
|
if (Args.hasFlag(options::OPT_faddress_sanitizer,
|
|
|
|
options::OPT_fno_address_sanitizer, false)) {
|
2011-12-07 03:18:44 +08:00
|
|
|
if (Args.hasArg(options::OPT_dynamiclib) ||
|
|
|
|
Args.hasArg(options::OPT_bundle)) return;
|
2011-12-02 07:40:18 +08:00
|
|
|
if (isTargetIPhoneOS()) {
|
|
|
|
getDriver().Diag(diag::err_drv_clang_unsupported_per_platform)
|
|
|
|
<< "-faddress-sanitizer";
|
|
|
|
} else {
|
|
|
|
AddLinkRuntimeLib(Args, CmdArgs, "libclang_rt.asan_osx.a");
|
|
|
|
|
|
|
|
// The ASAN runtime library requires C++ and CoreFoundation.
|
|
|
|
AddCXXStdlibLibArgs(Args, CmdArgs);
|
|
|
|
CmdArgs.push_back("-framework");
|
|
|
|
CmdArgs.push_back("CoreFoundation");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-01-22 11:38:14 +08:00
|
|
|
// Otherwise link libSystem, then the dynamic runtime library, and finally any
|
|
|
|
// target specific static runtime library.
|
2009-09-18 16:15:13 +08:00
|
|
|
CmdArgs.push_back("-lSystem");
|
2010-01-22 11:38:14 +08:00
|
|
|
|
|
|
|
// Select the dynamic runtime library and the target specific static library.
|
2010-01-27 08:56:37 +08:00
|
|
|
if (isTargetIPhoneOS()) {
|
2011-04-30 12:25:16 +08:00
|
|
|
// If we are compiling as iOS / simulator, don't attempt to link libgcc_s.1,
|
|
|
|
// it never went into the SDK.
|
2011-10-08 01:54:41 +08:00
|
|
|
// Linking against libgcc_s.1 isn't needed for iOS 5.0+
|
|
|
|
if (isIPhoneOSVersionLT(5, 0) && !isTargetIOSSimulator())
|
|
|
|
CmdArgs.push_back("-lgcc_s.1");
|
2010-01-22 11:38:14 +08:00
|
|
|
|
2011-04-19 07:48:36 +08:00
|
|
|
// We currently always need a static runtime library for iOS.
|
2011-06-23 01:41:40 +08:00
|
|
|
AddLinkRuntimeLib(Args, CmdArgs, "libclang_rt.ios.a");
|
2010-01-22 11:38:14 +08:00
|
|
|
} else {
|
|
|
|
// The dynamic runtime library was merged with libSystem for 10.6 and
|
|
|
|
// beyond; only 10.4 and 10.5 need an additional runtime library.
|
2010-01-27 08:57:03 +08:00
|
|
|
if (isMacosxVersionLT(10, 5))
|
2010-01-22 11:38:14 +08:00
|
|
|
CmdArgs.push_back("-lgcc_s.10.4");
|
2010-01-27 08:57:03 +08:00
|
|
|
else if (isMacosxVersionLT(10, 6))
|
2010-01-22 11:38:14 +08:00
|
|
|
CmdArgs.push_back("-lgcc_s.10.5");
|
|
|
|
|
2010-09-22 08:03:52 +08:00
|
|
|
// For OS X, we thought we would only need a static runtime library when
|
2011-04-15 13:22:18 +08:00
|
|
|
// targeting 10.4, to provide versions of the static functions which were
|
2010-09-22 08:03:52 +08:00
|
|
|
// omitted from 10.4.dylib.
|
|
|
|
//
|
|
|
|
// Unfortunately, that turned out to not be true, because Darwin system
|
|
|
|
// headers can still use eprintf on i386, and it is not exported from
|
|
|
|
// libSystem. Therefore, we still must provide a runtime library just for
|
|
|
|
// the tiny tiny handful of projects that *might* use that symbol.
|
|
|
|
if (isMacosxVersionLT(10, 5)) {
|
2011-06-23 01:41:40 +08:00
|
|
|
AddLinkRuntimeLib(Args, CmdArgs, "libclang_rt.10.4.a");
|
2010-09-22 08:03:52 +08:00
|
|
|
} else {
|
|
|
|
if (getTriple().getArch() == llvm::Triple::x86)
|
2011-06-23 01:41:40 +08:00
|
|
|
AddLinkRuntimeLib(Args, CmdArgs, "libclang_rt.eprintf.a");
|
|
|
|
AddLinkRuntimeLib(Args, CmdArgs, "libclang_rt.osx.a");
|
2010-09-22 08:03:52 +08:00
|
|
|
}
|
2010-01-22 11:38:14 +08:00
|
|
|
}
|
2009-09-18 16:15:13 +08:00
|
|
|
}
|
|
|
|
|
2011-10-18 08:22:49 +08:00
|
|
|
static inline StringRef SimulatorVersionDefineName() {
|
|
|
|
return "__IPHONE_OS_VERSION_MIN_REQUIRED";
|
|
|
|
}
|
|
|
|
|
|
|
|
/// \brief Parse the simulator version define:
|
|
|
|
/// __IPHONE_OS_VERSION_MIN_REQUIRED=([0-9])([0-9][0-9])([0-9][0-9])
|
|
|
|
// and return the grouped values as integers, e.g:
|
|
|
|
// __IPHONE_OS_VERSION_MIN_REQUIRED=40201
|
|
|
|
// will return Major=4, Minor=2, Micro=1.
|
|
|
|
static bool GetVersionFromSimulatorDefine(StringRef define,
|
|
|
|
unsigned &Major, unsigned &Minor,
|
|
|
|
unsigned &Micro) {
|
|
|
|
assert(define.startswith(SimulatorVersionDefineName()));
|
|
|
|
StringRef name, version;
|
|
|
|
llvm::tie(name, version) = define.split('=');
|
|
|
|
if (version.empty())
|
|
|
|
return false;
|
|
|
|
std::string verstr = version.str();
|
|
|
|
char *end;
|
|
|
|
unsigned num = (unsigned) strtol(verstr.c_str(), &end, 10);
|
|
|
|
if (*end != '\0')
|
|
|
|
return false;
|
|
|
|
Major = num / 10000;
|
|
|
|
num = num % 10000;
|
|
|
|
Minor = num / 100;
|
|
|
|
Micro = num % 100;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2010-07-20 01:11:36 +08:00
|
|
|
void Darwin::AddDeploymentTarget(DerivedArgList &Args) const {
|
2009-12-22 02:54:17 +08:00
|
|
|
const OptTable &Opts = getDriver().getOpts();
|
2009-03-25 14:58:31 +08:00
|
|
|
|
2010-01-27 08:56:25 +08:00
|
|
|
Arg *OSXVersion = Args.getLastArg(options::OPT_mmacosx_version_min_EQ);
|
2011-04-30 12:15:58 +08:00
|
|
|
Arg *iOSVersion = Args.getLastArg(options::OPT_miphoneos_version_min_EQ);
|
|
|
|
Arg *iOSSimVersion = Args.getLastArg(
|
|
|
|
options::OPT_mios_simulator_version_min_EQ);
|
2012-01-11 10:41:15 +08:00
|
|
|
|
2011-04-30 12:15:58 +08:00
|
|
|
if (OSXVersion && (iOSVersion || iOSSimVersion)) {
|
2011-07-23 18:55:15 +08:00
|
|
|
getDriver().Diag(diag::err_drv_argument_not_allowed_with)
|
2009-04-11 04:11:50 +08:00
|
|
|
<< OSXVersion->getAsString(Args)
|
2011-04-30 12:15:58 +08:00
|
|
|
<< (iOSVersion ? iOSVersion : iOSSimVersion)->getAsString(Args);
|
|
|
|
iOSVersion = iOSSimVersion = 0;
|
|
|
|
} else if (iOSVersion && iOSSimVersion) {
|
2011-07-23 18:55:15 +08:00
|
|
|
getDriver().Diag(diag::err_drv_argument_not_allowed_with)
|
2011-04-30 12:15:58 +08:00
|
|
|
<< iOSVersion->getAsString(Args)
|
|
|
|
<< iOSSimVersion->getAsString(Args);
|
|
|
|
iOSSimVersion = 0;
|
|
|
|
} else if (!OSXVersion && !iOSVersion && !iOSSimVersion) {
|
2011-09-01 04:56:25 +08:00
|
|
|
// If no deployment target was specified on the command line, check for
|
2010-01-26 09:45:19 +08:00
|
|
|
// environment defines.
|
2011-09-01 04:56:25 +08:00
|
|
|
StringRef OSXTarget;
|
|
|
|
StringRef iOSTarget;
|
|
|
|
StringRef iOSSimTarget;
|
|
|
|
if (char *env = ::getenv("MACOSX_DEPLOYMENT_TARGET"))
|
|
|
|
OSXTarget = env;
|
|
|
|
if (char *env = ::getenv("IPHONEOS_DEPLOYMENT_TARGET"))
|
|
|
|
iOSTarget = env;
|
|
|
|
if (char *env = ::getenv("IOS_SIMULATOR_DEPLOYMENT_TARGET"))
|
|
|
|
iOSSimTarget = env;
|
|
|
|
|
2011-10-08 19:31:46 +08:00
|
|
|
// If no '-miphoneos-version-min' specified on the command line and
|
2011-09-01 04:56:25 +08:00
|
|
|
// IPHONEOS_DEPLOYMENT_TARGET is not defined, see if we can set the default
|
|
|
|
// based on isysroot.
|
|
|
|
if (iOSTarget.empty()) {
|
|
|
|
if (const Arg *A = Args.getLastArg(options::OPT_isysroot)) {
|
|
|
|
StringRef first, second;
|
|
|
|
StringRef isysroot = A->getValue(Args);
|
|
|
|
llvm::tie(first, second) = isysroot.split(StringRef("SDKs/iPhoneOS"));
|
|
|
|
if (second != "")
|
|
|
|
iOSTarget = second.substr(0,3);
|
|
|
|
}
|
|
|
|
}
|
2010-01-26 09:45:19 +08:00
|
|
|
|
2011-09-28 08:46:32 +08:00
|
|
|
// If no OSX or iOS target has been specified and we're compiling for armv7,
|
|
|
|
// go ahead as assume we're targeting iOS.
|
|
|
|
if (OSXTarget.empty() && iOSTarget.empty())
|
|
|
|
if (getDarwinArchName(Args) == "armv7")
|
|
|
|
iOSTarget = "0.0";
|
|
|
|
|
2011-04-30 12:15:58 +08:00
|
|
|
// Handle conflicting deployment targets
|
2010-02-03 01:31:12 +08:00
|
|
|
//
|
|
|
|
// FIXME: Don't hardcode default here.
|
2011-04-30 12:15:58 +08:00
|
|
|
|
|
|
|
// Do not allow conflicts with the iOS simulator target.
|
2011-09-01 04:56:25 +08:00
|
|
|
if (!iOSSimTarget.empty() && (!OSXTarget.empty() || !iOSTarget.empty())) {
|
2011-07-23 18:55:15 +08:00
|
|
|
getDriver().Diag(diag::err_drv_conflicting_deployment_targets)
|
2011-04-30 12:15:58 +08:00
|
|
|
<< "IOS_SIMULATOR_DEPLOYMENT_TARGET"
|
2011-09-01 04:56:25 +08:00
|
|
|
<< (!OSXTarget.empty() ? "MACOSX_DEPLOYMENT_TARGET" :
|
2011-04-30 12:15:58 +08:00
|
|
|
"IPHONEOS_DEPLOYMENT_TARGET");
|
|
|
|
}
|
|
|
|
|
|
|
|
// Allow conflicts among OSX and iOS for historical reasons, but choose the
|
|
|
|
// default platform.
|
2011-09-01 04:56:25 +08:00
|
|
|
if (!OSXTarget.empty() && !iOSTarget.empty()) {
|
2010-02-03 01:31:12 +08:00
|
|
|
if (getTriple().getArch() == llvm::Triple::arm ||
|
|
|
|
getTriple().getArch() == llvm::Triple::thumb)
|
2011-09-01 04:56:25 +08:00
|
|
|
OSXTarget = "";
|
2010-02-03 01:31:12 +08:00
|
|
|
else
|
2011-09-01 04:56:25 +08:00
|
|
|
iOSTarget = "";
|
2010-02-03 01:31:12 +08:00
|
|
|
}
|
2010-01-30 01:02:25 +08:00
|
|
|
|
2011-09-01 04:56:25 +08:00
|
|
|
if (!OSXTarget.empty()) {
|
2009-09-05 02:35:21 +08:00
|
|
|
const Option *O = Opts.getOption(options::OPT_mmacosx_version_min_EQ);
|
2010-07-20 01:11:36 +08:00
|
|
|
OSXVersion = Args.MakeJoinedArg(0, O, OSXTarget);
|
|
|
|
Args.append(OSXVersion);
|
2011-09-01 04:56:25 +08:00
|
|
|
} else if (!iOSTarget.empty()) {
|
2009-09-05 02:35:21 +08:00
|
|
|
const Option *O = Opts.getOption(options::OPT_miphoneos_version_min_EQ);
|
2011-04-30 12:15:58 +08:00
|
|
|
iOSVersion = Args.MakeJoinedArg(0, O, iOSTarget);
|
|
|
|
Args.append(iOSVersion);
|
2011-09-01 04:56:25 +08:00
|
|
|
} else if (!iOSSimTarget.empty()) {
|
2011-04-30 12:15:58 +08:00
|
|
|
const Option *O = Opts.getOption(
|
|
|
|
options::OPT_mios_simulator_version_min_EQ);
|
|
|
|
iOSSimVersion = Args.MakeJoinedArg(0, O, iOSSimTarget);
|
|
|
|
Args.append(iOSSimVersion);
|
2010-01-26 09:45:19 +08:00
|
|
|
} else {
|
2010-07-16 00:18:06 +08:00
|
|
|
// Otherwise, assume we are targeting OS X.
|
|
|
|
const Option *O = Opts.getOption(options::OPT_mmacosx_version_min_EQ);
|
2010-07-20 01:11:36 +08:00
|
|
|
OSXVersion = Args.MakeJoinedArg(0, O, MacosxVersionMin);
|
|
|
|
Args.append(OSXVersion);
|
2009-09-05 02:35:21 +08:00
|
|
|
}
|
2009-03-25 14:58:31 +08:00
|
|
|
}
|
2009-09-09 23:08:12 +08:00
|
|
|
|
2012-01-17 02:50:54 +08:00
|
|
|
// FIXME: HACK! When compiling for the simulator we can't depend
|
|
|
|
// on getting '-mios-simulator-version-min'; try to parse a
|
|
|
|
// __IPHONE_OS_VERSION_MIN_REQUIRED define passed in command-line.
|
|
|
|
if (OSXVersion) {
|
|
|
|
for (arg_iterator it = Args.filtered_begin(options::OPT_D),
|
|
|
|
ie = Args.filtered_end(); it != ie; ++it) {
|
|
|
|
StringRef define = (*it)->getValue(Args);
|
|
|
|
if (define.startswith(SimulatorVersionDefineName())) {
|
|
|
|
unsigned Major = 0, Minor = 0, Micro = 0;
|
|
|
|
if (GetVersionFromSimulatorDefine(define, Major, Minor, Micro) &&
|
|
|
|
Major < 10 && Minor < 100 && Micro < 100) {
|
|
|
|
std::string iOSSimTarget;
|
|
|
|
llvm::raw_string_ostream(iOSSimTarget)
|
|
|
|
<< Major << '.' << Minor << '.' << Micro;
|
|
|
|
const Option *O = Opts.getOption(
|
|
|
|
options::OPT_mios_simulator_version_min_EQ);
|
|
|
|
iOSSimVersion = Args.MakeJoinedArg(0, O, iOSSimTarget);
|
|
|
|
Args.append(iOSSimVersion);
|
|
|
|
OSXVersion = 0;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-04-30 12:20:40 +08:00
|
|
|
// Reject invalid architecture combinations.
|
|
|
|
if (iOSSimVersion && (getTriple().getArch() != llvm::Triple::x86 &&
|
|
|
|
getTriple().getArch() != llvm::Triple::x86_64)) {
|
2011-07-23 18:55:15 +08:00
|
|
|
getDriver().Diag(diag::err_drv_invalid_arch_for_deployment_target)
|
2011-04-30 12:20:40 +08:00
|
|
|
<< getTriple().getArchName() << iOSSimVersion->getAsString(Args);
|
|
|
|
}
|
|
|
|
|
2010-01-27 08:56:25 +08:00
|
|
|
// Set the tool chain target information.
|
|
|
|
unsigned Major, Minor, Micro;
|
|
|
|
bool HadExtra;
|
|
|
|
if (OSXVersion) {
|
2011-04-30 12:15:58 +08:00
|
|
|
assert((!iOSVersion && !iOSSimVersion) && "Unknown target platform!");
|
2010-01-27 08:56:25 +08:00
|
|
|
if (!Driver::GetReleaseVersion(OSXVersion->getValue(Args), Major, Minor,
|
|
|
|
Micro, HadExtra) || HadExtra ||
|
2011-04-22 05:27:33 +08:00
|
|
|
Major != 10 || Minor >= 100 || Micro >= 100)
|
2011-07-23 18:55:15 +08:00
|
|
|
getDriver().Diag(diag::err_drv_invalid_version_number)
|
2010-01-27 08:56:25 +08:00
|
|
|
<< OSXVersion->getAsString(Args);
|
|
|
|
} else {
|
2011-04-30 12:15:58 +08:00
|
|
|
const Arg *Version = iOSVersion ? iOSVersion : iOSSimVersion;
|
|
|
|
assert(Version && "Unknown target platform!");
|
2012-01-11 10:41:15 +08:00
|
|
|
if (!Driver::GetReleaseVersion(Version->getValue(Args), Major, Minor,
|
|
|
|
Micro, HadExtra) || HadExtra ||
|
|
|
|
Major >= 10 || Minor >= 100 || Micro >= 100)
|
|
|
|
getDriver().Diag(diag::err_drv_invalid_version_number)
|
|
|
|
<< Version->getAsString(Args);
|
2010-01-27 08:56:25 +08:00
|
|
|
}
|
2011-04-30 12:15:58 +08:00
|
|
|
|
2011-04-30 12:18:16 +08:00
|
|
|
bool IsIOSSim = bool(iOSSimVersion);
|
|
|
|
|
|
|
|
// In GCC, the simulator historically was treated as being OS X in some
|
|
|
|
// contexts, like determining the link logic, despite generally being called
|
|
|
|
// with an iOS deployment target. For compatibility, we detect the
|
|
|
|
// simulator as iOS + x86, and treat it differently in a few contexts.
|
|
|
|
if (iOSVersion && (getTriple().getArch() == llvm::Triple::x86 ||
|
|
|
|
getTriple().getArch() == llvm::Triple::x86_64))
|
|
|
|
IsIOSSim = true;
|
|
|
|
|
|
|
|
setTarget(/*IsIPhoneOS=*/ !OSXVersion, Major, Minor, Micro, IsIOSSim);
|
2010-07-20 01:11:33 +08:00
|
|
|
}
|
|
|
|
|
2010-09-17 09:20:05 +08:00
|
|
|
void DarwinClang::AddCXXStdlibLibArgs(const ArgList &Args,
|
2010-09-17 09:16:06 +08:00
|
|
|
ArgStringList &CmdArgs) const {
|
|
|
|
CXXStdlibType Type = GetCXXStdlibType(Args);
|
|
|
|
|
|
|
|
switch (Type) {
|
|
|
|
case ToolChain::CST_Libcxx:
|
|
|
|
CmdArgs.push_back("-lc++");
|
|
|
|
break;
|
|
|
|
|
|
|
|
case ToolChain::CST_Libstdcxx: {
|
|
|
|
// Unfortunately, -lstdc++ doesn't always exist in the standard search path;
|
|
|
|
// it was previously found in the gcc lib dir. However, for all the Darwin
|
|
|
|
// platforms we care about it was -lstdc++.6, so we search for that
|
|
|
|
// explicitly if we can't see an obvious -lstdc++ candidate.
|
|
|
|
|
|
|
|
// Check in the sysroot first.
|
2011-01-10 10:34:13 +08:00
|
|
|
bool Exists;
|
2010-09-17 09:16:06 +08:00
|
|
|
if (const Arg *A = Args.getLastArg(options::OPT_isysroot)) {
|
|
|
|
llvm::sys::Path P(A->getValue(Args));
|
|
|
|
P.appendComponent("usr");
|
|
|
|
P.appendComponent("lib");
|
|
|
|
P.appendComponent("libstdc++.dylib");
|
|
|
|
|
2011-01-10 10:34:13 +08:00
|
|
|
if (llvm::sys::fs::exists(P.str(), Exists) || !Exists) {
|
2010-09-17 09:16:06 +08:00
|
|
|
P.eraseComponent();
|
|
|
|
P.appendComponent("libstdc++.6.dylib");
|
2011-01-10 10:34:13 +08:00
|
|
|
if (!llvm::sys::fs::exists(P.str(), Exists) && Exists) {
|
2010-09-17 09:16:06 +08:00
|
|
|
CmdArgs.push_back(Args.MakeArgString(P.str()));
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Otherwise, look in the root.
|
2011-11-11 15:47:04 +08:00
|
|
|
// FIXME: This should be removed someday when we don't have to care about
|
|
|
|
// 10.6 and earlier, where /usr/lib/libstdc++.dylib does not exist.
|
2011-01-10 10:34:13 +08:00
|
|
|
if ((llvm::sys::fs::exists("/usr/lib/libstdc++.dylib", Exists) || !Exists)&&
|
|
|
|
(!llvm::sys::fs::exists("/usr/lib/libstdc++.6.dylib", Exists) && Exists)){
|
2010-09-17 09:16:06 +08:00
|
|
|
CmdArgs.push_back("/usr/lib/libstdc++.6.dylib");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Otherwise, let the linker search.
|
|
|
|
CmdArgs.push_back("-lstdc++");
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-09-18 02:39:08 +08:00
|
|
|
void DarwinClang::AddCCKextLibArgs(const ArgList &Args,
|
|
|
|
ArgStringList &CmdArgs) const {
|
|
|
|
|
|
|
|
// For Darwin platforms, use the compiler-rt-based support library
|
|
|
|
// instead of the gcc-provided one (which is also incidentally
|
|
|
|
// only present in the gcc lib dir, which makes it hard to find).
|
|
|
|
|
|
|
|
llvm::sys::Path P(getDriver().ResourceDir);
|
|
|
|
P.appendComponent("lib");
|
|
|
|
P.appendComponent("darwin");
|
|
|
|
P.appendComponent("libclang_rt.cc_kext.a");
|
2011-06-03 11:49:51 +08:00
|
|
|
|
2010-09-18 02:39:08 +08:00
|
|
|
// For now, allow missing resource libraries to support developers who may
|
|
|
|
// not have compiler-rt checked out or integrated into their build.
|
2011-01-10 10:34:13 +08:00
|
|
|
bool Exists;
|
|
|
|
if (!llvm::sys::fs::exists(P.str(), Exists) && Exists)
|
2010-09-18 02:39:08 +08:00
|
|
|
CmdArgs.push_back(Args.MakeArgString(P.str()));
|
|
|
|
}
|
|
|
|
|
2010-07-20 01:11:33 +08:00
|
|
|
DerivedArgList *Darwin::TranslateArgs(const DerivedArgList &Args,
|
|
|
|
const char *BoundArch) const {
|
|
|
|
DerivedArgList *DAL = new DerivedArgList(Args.getBaseArgs());
|
|
|
|
const OptTable &Opts = getDriver().getOpts();
|
|
|
|
|
|
|
|
// FIXME: We really want to get out of the tool chain level argument
|
|
|
|
// translation business, as it makes the driver functionality much
|
|
|
|
// more opaque. For now, we follow gcc closely solely for the
|
|
|
|
// purpose of easily achieving feature parity & testability. Once we
|
|
|
|
// have something that works, we should reevaluate each translation
|
|
|
|
// and try to push it down into tool specific logic.
|
2010-01-27 08:56:25 +08:00
|
|
|
|
2010-06-12 06:00:26 +08:00
|
|
|
for (ArgList::const_iterator it = Args.begin(),
|
|
|
|
ie = Args.end(); it != ie; ++it) {
|
2009-03-25 14:12:34 +08:00
|
|
|
Arg *A = *it;
|
|
|
|
|
|
|
|
if (A->getOption().matches(options::OPT_Xarch__)) {
|
2011-06-21 08:20:17 +08:00
|
|
|
// Skip this argument unless the architecture matches either the toolchain
|
|
|
|
// triple arch, or the arch being bound.
|
|
|
|
//
|
2009-03-25 14:12:34 +08:00
|
|
|
// FIXME: Canonicalize name.
|
2011-07-23 18:55:15 +08:00
|
|
|
StringRef XarchArch = A->getValue(Args, 0);
|
2011-06-21 08:20:17 +08:00
|
|
|
if (!(XarchArch == getArchName() ||
|
|
|
|
(BoundArch && XarchArch == BoundArch)))
|
2009-03-25 14:12:34 +08:00
|
|
|
continue;
|
|
|
|
|
2011-02-19 13:33:51 +08:00
|
|
|
Arg *OriginalArg = A;
|
2010-06-15 05:23:08 +08:00
|
|
|
unsigned Index = Args.getBaseArgs().MakeIndex(A->getValue(Args, 1));
|
|
|
|
unsigned Prev = Index;
|
2009-03-25 14:58:31 +08:00
|
|
|
Arg *XarchArg = Opts.ParseOneArg(Args, Index);
|
2009-09-09 23:08:12 +08:00
|
|
|
|
2009-03-25 14:12:34 +08:00
|
|
|
// If the argument parsing failed or more than one argument was
|
|
|
|
// consumed, the -Xarch_ argument's parameter tried to consume
|
|
|
|
// extra arguments. Emit an error and ignore.
|
|
|
|
//
|
|
|
|
// We also want to disallow any options which would alter the
|
|
|
|
// driver behavior; that isn't going to work in our model. We
|
|
|
|
// use isDriverOption() as an approximation, although things
|
|
|
|
// like -O4 are going to slip through.
|
2011-04-22 01:41:34 +08:00
|
|
|
if (!XarchArg || Index > Prev + 1) {
|
2011-07-23 18:55:15 +08:00
|
|
|
getDriver().Diag(diag::err_drv_invalid_Xarch_argument_with_args)
|
2011-04-22 01:32:21 +08:00
|
|
|
<< A->getAsString(Args);
|
|
|
|
continue;
|
|
|
|
} else if (XarchArg->getOption().isDriverOption()) {
|
2011-07-23 18:55:15 +08:00
|
|
|
getDriver().Diag(diag::err_drv_invalid_Xarch_argument_isdriver)
|
2009-03-25 14:12:34 +08:00
|
|
|
<< A->getAsString(Args);
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2009-03-30 06:29:05 +08:00
|
|
|
XarchArg->setBaseArg(A);
|
2009-03-25 14:12:34 +08:00
|
|
|
A = XarchArg;
|
2010-06-15 05:23:08 +08:00
|
|
|
|
|
|
|
DAL->AddSynthesizedArg(A);
|
2011-02-19 13:33:51 +08:00
|
|
|
|
|
|
|
// Linker input arguments require custom handling. The problem is that we
|
|
|
|
// have already constructed the phase actions, so we can not treat them as
|
|
|
|
// "input arguments".
|
|
|
|
if (A->getOption().isLinkerInput()) {
|
|
|
|
// Convert the argument into individual Zlinker_input_args.
|
|
|
|
for (unsigned i = 0, e = A->getNumValues(); i != e; ++i) {
|
|
|
|
DAL->AddSeparateArg(OriginalArg,
|
|
|
|
Opts.getOption(options::OPT_Zlinker_input),
|
|
|
|
A->getValue(Args, i));
|
2011-06-03 11:49:51 +08:00
|
|
|
|
2011-02-19 13:33:51 +08:00
|
|
|
}
|
|
|
|
continue;
|
|
|
|
}
|
2009-09-09 23:08:12 +08:00
|
|
|
}
|
2009-03-25 14:12:34 +08:00
|
|
|
|
2009-03-25 14:58:31 +08:00
|
|
|
// Sob. These is strictly gcc compatible for the time being. Apple
|
|
|
|
// gcc translates options twice, which means that self-expanding
|
|
|
|
// options add duplicates.
|
2009-11-19 12:14:53 +08:00
|
|
|
switch ((options::ID) A->getOption().getID()) {
|
2009-03-25 14:58:31 +08:00
|
|
|
default:
|
|
|
|
DAL->append(A);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case options::OPT_mkernel:
|
|
|
|
case options::OPT_fapple_kext:
|
|
|
|
DAL->append(A);
|
2010-06-15 04:20:41 +08:00
|
|
|
DAL->AddFlagArg(A, Opts.getOption(options::OPT_static));
|
2009-03-25 14:58:31 +08:00
|
|
|
break;
|
2009-09-09 23:08:12 +08:00
|
|
|
|
2009-03-25 14:58:31 +08:00
|
|
|
case options::OPT_dependency_file:
|
2010-06-15 04:20:41 +08:00
|
|
|
DAL->AddSeparateArg(A, Opts.getOption(options::OPT_MF),
|
|
|
|
A->getValue(Args));
|
2009-03-25 14:58:31 +08:00
|
|
|
break;
|
|
|
|
|
|
|
|
case options::OPT_gfull:
|
2010-06-15 04:20:41 +08:00
|
|
|
DAL->AddFlagArg(A, Opts.getOption(options::OPT_g_Flag));
|
|
|
|
DAL->AddFlagArg(A,
|
|
|
|
Opts.getOption(options::OPT_fno_eliminate_unused_debug_symbols));
|
2009-03-25 14:58:31 +08:00
|
|
|
break;
|
|
|
|
|
|
|
|
case options::OPT_gused:
|
2010-06-15 04:20:41 +08:00
|
|
|
DAL->AddFlagArg(A, Opts.getOption(options::OPT_g_Flag));
|
|
|
|
DAL->AddFlagArg(A,
|
|
|
|
Opts.getOption(options::OPT_feliminate_unused_debug_symbols));
|
2009-03-25 14:58:31 +08:00
|
|
|
break;
|
|
|
|
|
|
|
|
case options::OPT_shared:
|
2010-06-15 04:20:41 +08:00
|
|
|
DAL->AddFlagArg(A, Opts.getOption(options::OPT_dynamiclib));
|
2009-03-25 14:58:31 +08:00
|
|
|
break;
|
|
|
|
|
|
|
|
case options::OPT_fconstant_cfstrings:
|
2010-06-15 04:20:41 +08:00
|
|
|
DAL->AddFlagArg(A, Opts.getOption(options::OPT_mconstant_cfstrings));
|
2009-03-25 14:58:31 +08:00
|
|
|
break;
|
|
|
|
|
|
|
|
case options::OPT_fno_constant_cfstrings:
|
2010-06-15 04:20:41 +08:00
|
|
|
DAL->AddFlagArg(A, Opts.getOption(options::OPT_mno_constant_cfstrings));
|
2009-03-25 14:58:31 +08:00
|
|
|
break;
|
|
|
|
|
|
|
|
case options::OPT_Wnonportable_cfstrings:
|
2010-06-15 04:20:41 +08:00
|
|
|
DAL->AddFlagArg(A,
|
|
|
|
Opts.getOption(options::OPT_mwarn_nonportable_cfstrings));
|
2009-03-25 14:58:31 +08:00
|
|
|
break;
|
|
|
|
|
|
|
|
case options::OPT_Wno_nonportable_cfstrings:
|
2010-06-15 04:20:41 +08:00
|
|
|
DAL->AddFlagArg(A,
|
|
|
|
Opts.getOption(options::OPT_mno_warn_nonportable_cfstrings));
|
2009-03-25 14:58:31 +08:00
|
|
|
break;
|
|
|
|
|
|
|
|
case options::OPT_fpascal_strings:
|
2010-06-15 04:20:41 +08:00
|
|
|
DAL->AddFlagArg(A, Opts.getOption(options::OPT_mpascal_strings));
|
2009-03-25 14:58:31 +08:00
|
|
|
break;
|
|
|
|
|
|
|
|
case options::OPT_fno_pascal_strings:
|
2010-06-15 04:20:41 +08:00
|
|
|
DAL->AddFlagArg(A, Opts.getOption(options::OPT_mno_pascal_strings));
|
2009-03-25 14:58:31 +08:00
|
|
|
break;
|
|
|
|
}
|
2009-03-25 14:12:34 +08:00
|
|
|
}
|
|
|
|
|
2009-09-10 06:33:15 +08:00
|
|
|
if (getTriple().getArch() == llvm::Triple::x86 ||
|
|
|
|
getTriple().getArch() == llvm::Triple::x86_64)
|
2009-11-19 12:00:53 +08:00
|
|
|
if (!Args.hasArgNoClaim(options::OPT_mtune_EQ))
|
2010-06-15 04:20:41 +08:00
|
|
|
DAL->AddJoinedArg(0, Opts.getOption(options::OPT_mtune_EQ), "core2");
|
2009-09-10 06:33:15 +08:00
|
|
|
|
|
|
|
// Add the arch options based on the particular spelling of -arch, to match
|
|
|
|
// how the driver driver works.
|
|
|
|
if (BoundArch) {
|
2011-07-23 18:55:15 +08:00
|
|
|
StringRef Name = BoundArch;
|
2009-09-10 06:33:15 +08:00
|
|
|
const Option *MCpu = Opts.getOption(options::OPT_mcpu_EQ);
|
|
|
|
const Option *MArch = Opts.getOption(options::OPT_march_EQ);
|
|
|
|
|
|
|
|
// This code must be kept in sync with LLVM's getArchTypeForDarwinArch,
|
|
|
|
// which defines the list of which architectures we accept.
|
|
|
|
if (Name == "ppc")
|
|
|
|
;
|
|
|
|
else if (Name == "ppc601")
|
2010-06-15 04:20:41 +08:00
|
|
|
DAL->AddJoinedArg(0, MCpu, "601");
|
2009-09-10 06:33:15 +08:00
|
|
|
else if (Name == "ppc603")
|
2010-06-15 04:20:41 +08:00
|
|
|
DAL->AddJoinedArg(0, MCpu, "603");
|
2009-09-10 06:33:15 +08:00
|
|
|
else if (Name == "ppc604")
|
2010-06-15 04:20:41 +08:00
|
|
|
DAL->AddJoinedArg(0, MCpu, "604");
|
2009-09-10 06:33:15 +08:00
|
|
|
else if (Name == "ppc604e")
|
2010-06-15 04:20:41 +08:00
|
|
|
DAL->AddJoinedArg(0, MCpu, "604e");
|
2009-09-10 06:33:15 +08:00
|
|
|
else if (Name == "ppc750")
|
2010-06-15 04:20:41 +08:00
|
|
|
DAL->AddJoinedArg(0, MCpu, "750");
|
2009-09-10 06:33:15 +08:00
|
|
|
else if (Name == "ppc7400")
|
2010-06-15 04:20:41 +08:00
|
|
|
DAL->AddJoinedArg(0, MCpu, "7400");
|
2009-09-10 06:33:15 +08:00
|
|
|
else if (Name == "ppc7450")
|
2010-06-15 04:20:41 +08:00
|
|
|
DAL->AddJoinedArg(0, MCpu, "7450");
|
2009-09-10 06:33:15 +08:00
|
|
|
else if (Name == "ppc970")
|
2010-06-15 04:20:41 +08:00
|
|
|
DAL->AddJoinedArg(0, MCpu, "970");
|
2009-09-10 06:33:15 +08:00
|
|
|
|
|
|
|
else if (Name == "ppc64")
|
2010-06-15 04:20:41 +08:00
|
|
|
DAL->AddFlagArg(0, Opts.getOption(options::OPT_m64));
|
2009-09-10 06:33:15 +08:00
|
|
|
|
|
|
|
else if (Name == "i386")
|
|
|
|
;
|
|
|
|
else if (Name == "i486")
|
2010-06-15 04:20:41 +08:00
|
|
|
DAL->AddJoinedArg(0, MArch, "i486");
|
2009-09-10 06:33:15 +08:00
|
|
|
else if (Name == "i586")
|
2010-06-15 04:20:41 +08:00
|
|
|
DAL->AddJoinedArg(0, MArch, "i586");
|
2009-09-10 06:33:15 +08:00
|
|
|
else if (Name == "i686")
|
2010-06-15 04:20:41 +08:00
|
|
|
DAL->AddJoinedArg(0, MArch, "i686");
|
2009-09-10 06:33:15 +08:00
|
|
|
else if (Name == "pentium")
|
2010-06-15 04:20:41 +08:00
|
|
|
DAL->AddJoinedArg(0, MArch, "pentium");
|
2009-09-10 06:33:15 +08:00
|
|
|
else if (Name == "pentium2")
|
2010-06-15 04:20:41 +08:00
|
|
|
DAL->AddJoinedArg(0, MArch, "pentium2");
|
2009-09-10 06:33:15 +08:00
|
|
|
else if (Name == "pentpro")
|
2010-06-15 04:20:41 +08:00
|
|
|
DAL->AddJoinedArg(0, MArch, "pentiumpro");
|
2009-09-10 06:33:15 +08:00
|
|
|
else if (Name == "pentIIm3")
|
2010-06-15 04:20:41 +08:00
|
|
|
DAL->AddJoinedArg(0, MArch, "pentium2");
|
2009-09-10 06:33:15 +08:00
|
|
|
|
|
|
|
else if (Name == "x86_64")
|
2010-06-15 04:20:41 +08:00
|
|
|
DAL->AddFlagArg(0, Opts.getOption(options::OPT_m64));
|
2009-03-25 14:58:31 +08:00
|
|
|
|
2009-09-10 06:33:15 +08:00
|
|
|
else if (Name == "arm")
|
2010-06-15 04:20:41 +08:00
|
|
|
DAL->AddJoinedArg(0, MArch, "armv4t");
|
2009-09-10 06:33:15 +08:00
|
|
|
else if (Name == "armv4t")
|
2010-06-15 04:20:41 +08:00
|
|
|
DAL->AddJoinedArg(0, MArch, "armv4t");
|
2009-09-10 06:33:15 +08:00
|
|
|
else if (Name == "armv5")
|
2010-06-15 04:20:41 +08:00
|
|
|
DAL->AddJoinedArg(0, MArch, "armv5tej");
|
2009-09-10 06:33:15 +08:00
|
|
|
else if (Name == "xscale")
|
2010-06-15 04:20:41 +08:00
|
|
|
DAL->AddJoinedArg(0, MArch, "xscale");
|
2009-09-10 06:33:15 +08:00
|
|
|
else if (Name == "armv6")
|
2010-06-15 04:20:41 +08:00
|
|
|
DAL->AddJoinedArg(0, MArch, "armv6k");
|
2009-09-10 06:33:15 +08:00
|
|
|
else if (Name == "armv7")
|
2010-06-15 04:20:41 +08:00
|
|
|
DAL->AddJoinedArg(0, MArch, "armv7a");
|
2009-09-10 06:33:15 +08:00
|
|
|
|
|
|
|
else
|
2009-12-12 13:05:38 +08:00
|
|
|
llvm_unreachable("invalid Darwin arch");
|
2009-09-10 06:33:15 +08:00
|
|
|
}
|
2009-03-25 14:58:31 +08:00
|
|
|
|
2010-07-20 01:11:36 +08:00
|
|
|
// Add an explicit version min argument for the deployment target. We do this
|
|
|
|
// after argument translation because -Xarch_ arguments may add a version min
|
|
|
|
// argument.
|
|
|
|
AddDeploymentTarget(*DAL);
|
|
|
|
|
2011-10-08 01:54:41 +08:00
|
|
|
// Validate the C++ standard library choice.
|
|
|
|
CXXStdlibType Type = GetCXXStdlibType(*DAL);
|
|
|
|
if (Type == ToolChain::CST_Libcxx) {
|
|
|
|
switch (LibCXXForSimulator) {
|
|
|
|
case LibCXXSimulator_None:
|
|
|
|
// Handle non-simulator cases.
|
|
|
|
if (isTargetIPhoneOS()) {
|
|
|
|
if (isIPhoneOSVersionLT(5, 0)) {
|
|
|
|
getDriver().Diag(clang::diag::err_drv_invalid_libcxx_deployment)
|
|
|
|
<< "iOS 5.0";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case LibCXXSimulator_NotAvailable:
|
|
|
|
getDriver().Diag(clang::diag::err_drv_invalid_libcxx_deployment)
|
|
|
|
<< "iOS 5.0";
|
|
|
|
break;
|
|
|
|
case LibCXXSimulator_Available:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-03-25 14:12:34 +08:00
|
|
|
return DAL;
|
2009-09-09 23:08:12 +08:00
|
|
|
}
|
2009-03-20 08:57:52 +08:00
|
|
|
|
2009-09-05 02:34:51 +08:00
|
|
|
bool Darwin::IsUnwindTablesDefault() const {
|
2009-03-20 08:57:52 +08:00
|
|
|
// FIXME: Gross; we should probably have some separate target
|
|
|
|
// definition, possibly even reusing the one in clang.
|
|
|
|
return getArchName() == "x86_64";
|
|
|
|
}
|
|
|
|
|
2009-12-18 10:43:17 +08:00
|
|
|
bool Darwin::UseDwarfDebugFlags() const {
|
|
|
|
if (const char *S = ::getenv("RC_DEBUG_OPTIONS"))
|
|
|
|
return S[0] != '\0';
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2010-02-11 02:49:11 +08:00
|
|
|
bool Darwin::UseSjLjExceptions() const {
|
|
|
|
// Darwin uses SjLj exceptions on ARM.
|
|
|
|
return (getTriple().getArch() == llvm::Triple::arm ||
|
|
|
|
getTriple().getArch() == llvm::Triple::thumb);
|
|
|
|
}
|
|
|
|
|
2009-09-05 02:34:51 +08:00
|
|
|
const char *Darwin::GetDefaultRelocationModel() const {
|
2009-03-20 08:57:52 +08:00
|
|
|
return "pic";
|
|
|
|
}
|
|
|
|
|
2009-09-05 02:34:51 +08:00
|
|
|
const char *Darwin::GetForcedPicModel() const {
|
2009-03-20 08:57:52 +08:00
|
|
|
if (getArchName() == "x86_64")
|
|
|
|
return "pic";
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2011-03-02 02:49:30 +08:00
|
|
|
bool Darwin::SupportsProfiling() const {
|
|
|
|
// Profiling instrumentation is only supported on x86.
|
|
|
|
return getArchName() == "i386" || getArchName() == "x86_64";
|
|
|
|
}
|
|
|
|
|
2010-04-11 00:20:23 +08:00
|
|
|
bool Darwin::SupportsObjCGC() const {
|
|
|
|
// Garbage collection is supported everywhere except on iPhone OS.
|
|
|
|
return !isTargetIPhoneOS();
|
|
|
|
}
|
|
|
|
|
2010-08-24 06:35:37 +08:00
|
|
|
std::string
|
2011-09-21 04:44:06 +08:00
|
|
|
Darwin_Generic_GCC::ComputeEffectiveClangTriple(const ArgList &Args,
|
|
|
|
types::ID InputType) const {
|
|
|
|
return ComputeLLVMTriple(Args, InputType);
|
2010-08-24 06:35:37 +08:00
|
|
|
}
|
|
|
|
|
2009-03-20 08:20:03 +08:00
|
|
|
/// Generic_GCC - A tool chain using the 'gcc' command to perform
|
|
|
|
/// all subcommands; this relies on gcc translating the majority of
|
|
|
|
/// command line options.
|
|
|
|
|
2011-11-07 07:39:34 +08:00
|
|
|
/// \brief Parse a GCCVersion object out of a string of text.
|
|
|
|
///
|
|
|
|
/// This is the primary means of forming GCCVersion objects.
|
|
|
|
/*static*/
|
|
|
|
Generic_GCC::GCCVersion Linux::GCCVersion::Parse(StringRef VersionText) {
|
|
|
|
const GCCVersion BadVersion = { VersionText.str(), -1, -1, -1, "" };
|
|
|
|
std::pair<StringRef, StringRef> First = VersionText.split('.');
|
|
|
|
std::pair<StringRef, StringRef> Second = First.second.split('.');
|
|
|
|
|
|
|
|
GCCVersion GoodVersion = { VersionText.str(), -1, -1, -1, "" };
|
|
|
|
if (First.first.getAsInteger(10, GoodVersion.Major) ||
|
|
|
|
GoodVersion.Major < 0)
|
|
|
|
return BadVersion;
|
|
|
|
if (Second.first.getAsInteger(10, GoodVersion.Minor) ||
|
|
|
|
GoodVersion.Minor < 0)
|
|
|
|
return BadVersion;
|
|
|
|
|
|
|
|
// First look for a number prefix and parse that if present. Otherwise just
|
|
|
|
// stash the entire patch string in the suffix, and leave the number
|
|
|
|
// unspecified. This covers versions strings such as:
|
|
|
|
// 4.4
|
|
|
|
// 4.4.0
|
|
|
|
// 4.4.x
|
|
|
|
// 4.4.2-rc4
|
|
|
|
// 4.4.x-patched
|
|
|
|
// And retains any patch number it finds.
|
|
|
|
StringRef PatchText = GoodVersion.PatchSuffix = Second.second.str();
|
|
|
|
if (!PatchText.empty()) {
|
|
|
|
if (unsigned EndNumber = PatchText.find_first_not_of("0123456789")) {
|
|
|
|
// Try to parse the number and any suffix.
|
|
|
|
if (PatchText.slice(0, EndNumber).getAsInteger(10, GoodVersion.Patch) ||
|
|
|
|
GoodVersion.Patch < 0)
|
|
|
|
return BadVersion;
|
|
|
|
GoodVersion.PatchSuffix = PatchText.substr(EndNumber).str();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return GoodVersion;
|
|
|
|
}
|
|
|
|
|
|
|
|
/// \brief Less-than for GCCVersion, implementing a Strict Weak Ordering.
|
|
|
|
bool Generic_GCC::GCCVersion::operator<(const GCCVersion &RHS) const {
|
|
|
|
if (Major < RHS.Major) return true; if (Major > RHS.Major) return false;
|
|
|
|
if (Minor < RHS.Minor) return true; if (Minor > RHS.Minor) return false;
|
|
|
|
|
|
|
|
// Note that we rank versions with *no* patch specified is better than ones
|
|
|
|
// hard-coding a patch version. Thus if the RHS has no patch, it always
|
|
|
|
// wins, and the LHS only wins if it has no patch and the RHS does have
|
|
|
|
// a patch.
|
|
|
|
if (RHS.Patch == -1) return true; if (Patch == -1) return false;
|
|
|
|
if (Patch < RHS.Patch) return true; if (Patch > RHS.Patch) return false;
|
|
|
|
|
|
|
|
// Finally, between completely tied version numbers, the version with the
|
|
|
|
// suffix loses as we prefer full releases.
|
|
|
|
if (RHS.PatchSuffix.empty()) return true;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
Make a major refactoring to how the GCC installation detection works.
The fundamental shift here is to stop making *any* assumptions about the
*host* triple. Where these assumptions you ask? Why, they were in one of
the two target triples referenced of course. This was the single biggest
place where the previously named "host triple" was actually used as
such. ;] The reason we were reasoning about the host is in order to
detect the use of '-m32' or '-m64' flags to change the target. These
flags shift the default target only slightly, which typically means
a slight deviation from the host. When using these flags, the GCC
installation is under a different triple from the one actually targeted
in the compilation, and we used the host triple to find it.
Too bad that wasn't even correct. Consider an x86 Linux host which has
a PPC64 cross-compiling GCC toolchain installed. This toolchain is also
configured for multiarch compiling and can target PPC32 with eth '-m32'
flag. When targeting 'powerpc-linux-gnu' or some other PPC32 triple, we
have to look for the PPC64 variant of the triple to find the GCC
install, and that triple is neither the host nor target.
The new logic computes the multiarch's alternate triple from the target
triple, and looks under both sides. It also looks more aggressively for
the correct subdirectory of the GCC installation, and exposes the
subdirectory in a nice programmatic way. This '/32' or '/64' suffix is
something we can reuse in many other parts of the toolchain.
An important note -- while this likely fixes a large category of
cross-compile use cases, that's not my primary goal, and I've not done
testing (or added test cases) for scenarios that may now work. If
someone else wants to try more interesting PPC cross compiles, I'd love
to have reports. But my focus is on factoring away the references to the
"host" triple. The refactoring is my goal, and so I'm mostly relying on
the existing (pretty good) test coverage we have here.
Future patches will leverage this new functionality to factor out more
and more of the toolchain's triple manipulation.
llvm-svn: 148935
2012-01-25 15:21:38 +08:00
|
|
|
// FIXME: Factor this helper into llvm::Triple itself.
|
|
|
|
static llvm::Triple getMultiarchAlternateTriple(llvm::Triple Triple) {
|
|
|
|
switch (Triple.getArch()) {
|
|
|
|
default: break;
|
|
|
|
case llvm::Triple::x86: Triple.setArchName("x86_64"); break;
|
|
|
|
case llvm::Triple::x86_64: Triple.setArchName("i386"); break;
|
|
|
|
case llvm::Triple::ppc: Triple.setArchName("powerpc64"); break;
|
|
|
|
case llvm::Triple::ppc64: Triple.setArchName("powerpc"); break;
|
|
|
|
}
|
|
|
|
return Triple;
|
|
|
|
}
|
|
|
|
|
2011-11-07 07:39:34 +08:00
|
|
|
/// \brief Construct a GCCInstallationDetector from the driver.
|
|
|
|
///
|
|
|
|
/// This performs all of the autodetection and sets up the various paths.
|
|
|
|
/// Once constructed, a GCCInstallation is esentially immutable.
|
Make a major refactoring to how the GCC installation detection works.
The fundamental shift here is to stop making *any* assumptions about the
*host* triple. Where these assumptions you ask? Why, they were in one of
the two target triples referenced of course. This was the single biggest
place where the previously named "host triple" was actually used as
such. ;] The reason we were reasoning about the host is in order to
detect the use of '-m32' or '-m64' flags to change the target. These
flags shift the default target only slightly, which typically means
a slight deviation from the host. When using these flags, the GCC
installation is under a different triple from the one actually targeted
in the compilation, and we used the host triple to find it.
Too bad that wasn't even correct. Consider an x86 Linux host which has
a PPC64 cross-compiling GCC toolchain installed. This toolchain is also
configured for multiarch compiling and can target PPC32 with eth '-m32'
flag. When targeting 'powerpc-linux-gnu' or some other PPC32 triple, we
have to look for the PPC64 variant of the triple to find the GCC
install, and that triple is neither the host nor target.
The new logic computes the multiarch's alternate triple from the target
triple, and looks under both sides. It also looks more aggressively for
the correct subdirectory of the GCC installation, and exposes the
subdirectory in a nice programmatic way. This '/32' or '/64' suffix is
something we can reuse in many other parts of the toolchain.
An important note -- while this likely fixes a large category of
cross-compile use cases, that's not my primary goal, and I've not done
testing (or added test cases) for scenarios that may now work. If
someone else wants to try more interesting PPC cross compiles, I'd love
to have reports. But my focus is on factoring away the references to the
"host" triple. The refactoring is my goal, and so I'm mostly relying on
the existing (pretty good) test coverage we have here.
Future patches will leverage this new functionality to factor out more
and more of the toolchain's triple manipulation.
llvm-svn: 148935
2012-01-25 15:21:38 +08:00
|
|
|
///
|
|
|
|
/// FIXME: We shouldn't need an explicit TargetTriple parameter here, and
|
|
|
|
/// should instead pull the target out of the driver. This is currently
|
|
|
|
/// necessary because the driver doesn't store the final version of the target
|
|
|
|
/// triple.
|
|
|
|
Generic_GCC::GCCInstallationDetector::GCCInstallationDetector(
|
|
|
|
const Driver &D,
|
|
|
|
const llvm::Triple &TargetTriple)
|
|
|
|
: IsValid(false) {
|
2011-11-07 07:39:34 +08:00
|
|
|
// FIXME: Using CXX_INCLUDE_ROOT is here is a bit of a hack, but
|
|
|
|
// avoids adding yet another option to configure/cmake.
|
|
|
|
// It would probably be cleaner to break it in two variables
|
|
|
|
// CXX_GCC_ROOT with just /foo/bar
|
|
|
|
// CXX_GCC_VER with 4.5.2
|
|
|
|
// Then we would have
|
|
|
|
// CXX_INCLUDE_ROOT = CXX_GCC_ROOT/include/c++/CXX_GCC_VER
|
|
|
|
// and this function would return
|
|
|
|
// CXX_GCC_ROOT/lib/gcc/CXX_INCLUDE_ARCH/CXX_GCC_VER
|
|
|
|
llvm::SmallString<128> CxxIncludeRoot(CXX_INCLUDE_ROOT);
|
|
|
|
if (CxxIncludeRoot != "") {
|
|
|
|
// This is of the form /foo/bar/include/c++/4.5.2/
|
|
|
|
if (CxxIncludeRoot.back() == '/')
|
|
|
|
llvm::sys::path::remove_filename(CxxIncludeRoot); // remove the /
|
|
|
|
StringRef Version = llvm::sys::path::filename(CxxIncludeRoot);
|
|
|
|
llvm::sys::path::remove_filename(CxxIncludeRoot); // remove the version
|
|
|
|
llvm::sys::path::remove_filename(CxxIncludeRoot); // remove the c++
|
|
|
|
llvm::sys::path::remove_filename(CxxIncludeRoot); // remove the include
|
2012-01-25 03:21:42 +08:00
|
|
|
GCCInstallPath = CxxIncludeRoot.str();
|
|
|
|
GCCInstallPath.append("/lib/gcc/");
|
|
|
|
GCCInstallPath.append(CXX_INCLUDE_ARCH);
|
|
|
|
GCCInstallPath.append("/");
|
|
|
|
GCCInstallPath.append(Version);
|
|
|
|
GCCParentLibPath = GCCInstallPath + "/../../..";
|
2011-11-07 07:39:34 +08:00
|
|
|
IsValid = true;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
Make a major refactoring to how the GCC installation detection works.
The fundamental shift here is to stop making *any* assumptions about the
*host* triple. Where these assumptions you ask? Why, they were in one of
the two target triples referenced of course. This was the single biggest
place where the previously named "host triple" was actually used as
such. ;] The reason we were reasoning about the host is in order to
detect the use of '-m32' or '-m64' flags to change the target. These
flags shift the default target only slightly, which typically means
a slight deviation from the host. When using these flags, the GCC
installation is under a different triple from the one actually targeted
in the compilation, and we used the host triple to find it.
Too bad that wasn't even correct. Consider an x86 Linux host which has
a PPC64 cross-compiling GCC toolchain installed. This toolchain is also
configured for multiarch compiling and can target PPC32 with eth '-m32'
flag. When targeting 'powerpc-linux-gnu' or some other PPC32 triple, we
have to look for the PPC64 variant of the triple to find the GCC
install, and that triple is neither the host nor target.
The new logic computes the multiarch's alternate triple from the target
triple, and looks under both sides. It also looks more aggressively for
the correct subdirectory of the GCC installation, and exposes the
subdirectory in a nice programmatic way. This '/32' or '/64' suffix is
something we can reuse in many other parts of the toolchain.
An important note -- while this likely fixes a large category of
cross-compile use cases, that's not my primary goal, and I've not done
testing (or added test cases) for scenarios that may now work. If
someone else wants to try more interesting PPC cross compiles, I'd love
to have reports. But my focus is on factoring away the references to the
"host" triple. The refactoring is my goal, and so I'm mostly relying on
the existing (pretty good) test coverage we have here.
Future patches will leverage this new functionality to factor out more
and more of the toolchain's triple manipulation.
llvm-svn: 148935
2012-01-25 15:21:38 +08:00
|
|
|
llvm::Triple MultiarchTriple = getMultiarchAlternateTriple(TargetTriple);
|
|
|
|
llvm::Triple::ArchType TargetArch = TargetTriple.getArch();
|
2011-11-07 07:39:34 +08:00
|
|
|
// The library directories which may contain GCC installations.
|
Make a major refactoring to how the GCC installation detection works.
The fundamental shift here is to stop making *any* assumptions about the
*host* triple. Where these assumptions you ask? Why, they were in one of
the two target triples referenced of course. This was the single biggest
place where the previously named "host triple" was actually used as
such. ;] The reason we were reasoning about the host is in order to
detect the use of '-m32' or '-m64' flags to change the target. These
flags shift the default target only slightly, which typically means
a slight deviation from the host. When using these flags, the GCC
installation is under a different triple from the one actually targeted
in the compilation, and we used the host triple to find it.
Too bad that wasn't even correct. Consider an x86 Linux host which has
a PPC64 cross-compiling GCC toolchain installed. This toolchain is also
configured for multiarch compiling and can target PPC32 with eth '-m32'
flag. When targeting 'powerpc-linux-gnu' or some other PPC32 triple, we
have to look for the PPC64 variant of the triple to find the GCC
install, and that triple is neither the host nor target.
The new logic computes the multiarch's alternate triple from the target
triple, and looks under both sides. It also looks more aggressively for
the correct subdirectory of the GCC installation, and exposes the
subdirectory in a nice programmatic way. This '/32' or '/64' suffix is
something we can reuse in many other parts of the toolchain.
An important note -- while this likely fixes a large category of
cross-compile use cases, that's not my primary goal, and I've not done
testing (or added test cases) for scenarios that may now work. If
someone else wants to try more interesting PPC cross compiles, I'd love
to have reports. But my focus is on factoring away the references to the
"host" triple. The refactoring is my goal, and so I'm mostly relying on
the existing (pretty good) test coverage we have here.
Future patches will leverage this new functionality to factor out more
and more of the toolchain's triple manipulation.
llvm-svn: 148935
2012-01-25 15:21:38 +08:00
|
|
|
SmallVector<StringRef, 4> CandidateLibDirs, CandidateMultiarchLibDirs;
|
2011-11-07 07:39:34 +08:00
|
|
|
// The compatible GCC triples for this particular architecture.
|
Make a major refactoring to how the GCC installation detection works.
The fundamental shift here is to stop making *any* assumptions about the
*host* triple. Where these assumptions you ask? Why, they were in one of
the two target triples referenced of course. This was the single biggest
place where the previously named "host triple" was actually used as
such. ;] The reason we were reasoning about the host is in order to
detect the use of '-m32' or '-m64' flags to change the target. These
flags shift the default target only slightly, which typically means
a slight deviation from the host. When using these flags, the GCC
installation is under a different triple from the one actually targeted
in the compilation, and we used the host triple to find it.
Too bad that wasn't even correct. Consider an x86 Linux host which has
a PPC64 cross-compiling GCC toolchain installed. This toolchain is also
configured for multiarch compiling and can target PPC32 with eth '-m32'
flag. When targeting 'powerpc-linux-gnu' or some other PPC32 triple, we
have to look for the PPC64 variant of the triple to find the GCC
install, and that triple is neither the host nor target.
The new logic computes the multiarch's alternate triple from the target
triple, and looks under both sides. It also looks more aggressively for
the correct subdirectory of the GCC installation, and exposes the
subdirectory in a nice programmatic way. This '/32' or '/64' suffix is
something we can reuse in many other parts of the toolchain.
An important note -- while this likely fixes a large category of
cross-compile use cases, that's not my primary goal, and I've not done
testing (or added test cases) for scenarios that may now work. If
someone else wants to try more interesting PPC cross compiles, I'd love
to have reports. But my focus is on factoring away the references to the
"host" triple. The refactoring is my goal, and so I'm mostly relying on
the existing (pretty good) test coverage we have here.
Future patches will leverage this new functionality to factor out more
and more of the toolchain's triple manipulation.
llvm-svn: 148935
2012-01-25 15:21:38 +08:00
|
|
|
SmallVector<StringRef, 10> CandidateTripleAliases;
|
|
|
|
SmallVector<StringRef, 10> CandidateMultiarchTripleAliases;
|
|
|
|
CollectLibDirsAndTriples(TargetTriple, MultiarchTriple, CandidateLibDirs,
|
|
|
|
CandidateTripleAliases,
|
|
|
|
CandidateMultiarchLibDirs,
|
|
|
|
CandidateMultiarchTripleAliases);
|
2011-11-07 07:39:34 +08:00
|
|
|
|
|
|
|
// Compute the set of prefixes for our search.
|
|
|
|
SmallVector<std::string, 8> Prefixes(D.PrefixDirs.begin(),
|
|
|
|
D.PrefixDirs.end());
|
|
|
|
Prefixes.push_back(D.SysRoot);
|
|
|
|
Prefixes.push_back(D.SysRoot + "/usr");
|
|
|
|
Prefixes.push_back(D.InstalledDir + "/..");
|
|
|
|
|
|
|
|
// Loop over the various components which exist and select the best GCC
|
|
|
|
// installation available. GCC installs are ranked by version number.
|
|
|
|
Version = GCCVersion::Parse("0.0.0");
|
|
|
|
for (unsigned i = 0, ie = Prefixes.size(); i < ie; ++i) {
|
|
|
|
if (!llvm::sys::fs::exists(Prefixes[i]))
|
|
|
|
continue;
|
|
|
|
for (unsigned j = 0, je = CandidateLibDirs.size(); j < je; ++j) {
|
|
|
|
const std::string LibDir = Prefixes[i] + CandidateLibDirs[j].str();
|
|
|
|
if (!llvm::sys::fs::exists(LibDir))
|
|
|
|
continue;
|
Make a major refactoring to how the GCC installation detection works.
The fundamental shift here is to stop making *any* assumptions about the
*host* triple. Where these assumptions you ask? Why, they were in one of
the two target triples referenced of course. This was the single biggest
place where the previously named "host triple" was actually used as
such. ;] The reason we were reasoning about the host is in order to
detect the use of '-m32' or '-m64' flags to change the target. These
flags shift the default target only slightly, which typically means
a slight deviation from the host. When using these flags, the GCC
installation is under a different triple from the one actually targeted
in the compilation, and we used the host triple to find it.
Too bad that wasn't even correct. Consider an x86 Linux host which has
a PPC64 cross-compiling GCC toolchain installed. This toolchain is also
configured for multiarch compiling and can target PPC32 with eth '-m32'
flag. When targeting 'powerpc-linux-gnu' or some other PPC32 triple, we
have to look for the PPC64 variant of the triple to find the GCC
install, and that triple is neither the host nor target.
The new logic computes the multiarch's alternate triple from the target
triple, and looks under both sides. It also looks more aggressively for
the correct subdirectory of the GCC installation, and exposes the
subdirectory in a nice programmatic way. This '/32' or '/64' suffix is
something we can reuse in many other parts of the toolchain.
An important note -- while this likely fixes a large category of
cross-compile use cases, that's not my primary goal, and I've not done
testing (or added test cases) for scenarios that may now work. If
someone else wants to try more interesting PPC cross compiles, I'd love
to have reports. But my focus is on factoring away the references to the
"host" triple. The refactoring is my goal, and so I'm mostly relying on
the existing (pretty good) test coverage we have here.
Future patches will leverage this new functionality to factor out more
and more of the toolchain's triple manipulation.
llvm-svn: 148935
2012-01-25 15:21:38 +08:00
|
|
|
for (unsigned k = 0, ke = CandidateTripleAliases.size(); k < ke; ++k)
|
|
|
|
ScanLibDirForGCCTriple(TargetArch, LibDir, CandidateTripleAliases[k]);
|
|
|
|
}
|
|
|
|
for (unsigned j = 0, je = CandidateMultiarchLibDirs.size(); j < je; ++j) {
|
|
|
|
const std::string LibDir
|
|
|
|
= Prefixes[i] + CandidateMultiarchLibDirs[j].str();
|
|
|
|
if (!llvm::sys::fs::exists(LibDir))
|
|
|
|
continue;
|
|
|
|
for (unsigned k = 0, ke = CandidateMultiarchTripleAliases.size(); k < ke;
|
|
|
|
++k)
|
|
|
|
ScanLibDirForGCCTriple(TargetArch, LibDir,
|
|
|
|
CandidateMultiarchTripleAliases[k],
|
|
|
|
/*NeedsMultiarchSuffix=*/true);
|
2011-11-07 07:39:34 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*static*/ void Generic_GCC::GCCInstallationDetector::CollectLibDirsAndTriples(
|
Make a major refactoring to how the GCC installation detection works.
The fundamental shift here is to stop making *any* assumptions about the
*host* triple. Where these assumptions you ask? Why, they were in one of
the two target triples referenced of course. This was the single biggest
place where the previously named "host triple" was actually used as
such. ;] The reason we were reasoning about the host is in order to
detect the use of '-m32' or '-m64' flags to change the target. These
flags shift the default target only slightly, which typically means
a slight deviation from the host. When using these flags, the GCC
installation is under a different triple from the one actually targeted
in the compilation, and we used the host triple to find it.
Too bad that wasn't even correct. Consider an x86 Linux host which has
a PPC64 cross-compiling GCC toolchain installed. This toolchain is also
configured for multiarch compiling and can target PPC32 with eth '-m32'
flag. When targeting 'powerpc-linux-gnu' or some other PPC32 triple, we
have to look for the PPC64 variant of the triple to find the GCC
install, and that triple is neither the host nor target.
The new logic computes the multiarch's alternate triple from the target
triple, and looks under both sides. It also looks more aggressively for
the correct subdirectory of the GCC installation, and exposes the
subdirectory in a nice programmatic way. This '/32' or '/64' suffix is
something we can reuse in many other parts of the toolchain.
An important note -- while this likely fixes a large category of
cross-compile use cases, that's not my primary goal, and I've not done
testing (or added test cases) for scenarios that may now work. If
someone else wants to try more interesting PPC cross compiles, I'd love
to have reports. But my focus is on factoring away the references to the
"host" triple. The refactoring is my goal, and so I'm mostly relying on
the existing (pretty good) test coverage we have here.
Future patches will leverage this new functionality to factor out more
and more of the toolchain's triple manipulation.
llvm-svn: 148935
2012-01-25 15:21:38 +08:00
|
|
|
const llvm::Triple &TargetTriple,
|
|
|
|
const llvm::Triple &MultiarchTriple,
|
|
|
|
SmallVectorImpl<StringRef> &LibDirs,
|
|
|
|
SmallVectorImpl<StringRef> &TripleAliases,
|
|
|
|
SmallVectorImpl<StringRef> &MultiarchLibDirs,
|
|
|
|
SmallVectorImpl<StringRef> &MultiarchTripleAliases) {
|
|
|
|
// Declare a bunch of static data sets that we'll select between below. These
|
|
|
|
// are specifically designed to always refer to string literals to avoid any
|
|
|
|
// lifetime or initialization issues.
|
|
|
|
static const char *const ARMLibDirs[] = { "/lib" };
|
|
|
|
static const char *const ARMTriples[] = {
|
|
|
|
"arm-linux-gnueabi",
|
|
|
|
"arm-linux-androideabi"
|
|
|
|
};
|
|
|
|
|
|
|
|
static const char *const X86_64LibDirs[] = { "/lib64", "/lib" };
|
|
|
|
static const char *const X86_64Triples[] = {
|
|
|
|
"x86_64-linux-gnu",
|
|
|
|
"x86_64-unknown-linux-gnu",
|
|
|
|
"x86_64-pc-linux-gnu",
|
|
|
|
"x86_64-redhat-linux6E",
|
|
|
|
"x86_64-redhat-linux",
|
|
|
|
"x86_64-suse-linux",
|
|
|
|
"x86_64-manbo-linux-gnu",
|
|
|
|
"x86_64-linux-gnu",
|
|
|
|
"x86_64-slackware-linux"
|
|
|
|
};
|
|
|
|
static const char *const X86LibDirs[] = { "/lib32", "/lib" };
|
|
|
|
static const char *const X86Triples[] = {
|
|
|
|
"i686-linux-gnu",
|
|
|
|
"i686-pc-linux-gnu",
|
|
|
|
"i486-linux-gnu",
|
|
|
|
"i386-linux-gnu",
|
|
|
|
"i686-redhat-linux",
|
|
|
|
"i586-redhat-linux",
|
|
|
|
"i386-redhat-linux",
|
|
|
|
"i586-suse-linux",
|
|
|
|
"i486-slackware-linux"
|
|
|
|
};
|
|
|
|
|
|
|
|
static const char *const MIPSLibDirs[] = { "/lib" };
|
|
|
|
static const char *const MIPSTriples[] = { "mips-linux-gnu" };
|
|
|
|
static const char *const MIPSELLibDirs[] = { "/lib" };
|
|
|
|
static const char *const MIPSELTriples[] = { "mipsel-linux-gnu" };
|
|
|
|
|
|
|
|
static const char *const PPCLibDirs[] = { "/lib32", "/lib" };
|
|
|
|
static const char *const PPCTriples[] = {
|
|
|
|
"powerpc-linux-gnu",
|
|
|
|
"powerpc-unknown-linux-gnu",
|
|
|
|
"powerpc-suse-linux"
|
|
|
|
};
|
|
|
|
static const char *const PPC64LibDirs[] = { "/lib64", "/lib" };
|
|
|
|
static const char *const PPC64Triples[] = {
|
|
|
|
"powerpc64-unknown-linux-gnu",
|
|
|
|
"powerpc64-suse-linux",
|
|
|
|
"ppc64-redhat-linux"
|
|
|
|
};
|
|
|
|
|
|
|
|
switch (TargetTriple.getArch()) {
|
|
|
|
case llvm::Triple::arm:
|
|
|
|
case llvm::Triple::thumb:
|
2011-11-07 07:39:34 +08:00
|
|
|
LibDirs.append(ARMLibDirs, ARMLibDirs + llvm::array_lengthof(ARMLibDirs));
|
Make a major refactoring to how the GCC installation detection works.
The fundamental shift here is to stop making *any* assumptions about the
*host* triple. Where these assumptions you ask? Why, they were in one of
the two target triples referenced of course. This was the single biggest
place where the previously named "host triple" was actually used as
such. ;] The reason we were reasoning about the host is in order to
detect the use of '-m32' or '-m64' flags to change the target. These
flags shift the default target only slightly, which typically means
a slight deviation from the host. When using these flags, the GCC
installation is under a different triple from the one actually targeted
in the compilation, and we used the host triple to find it.
Too bad that wasn't even correct. Consider an x86 Linux host which has
a PPC64 cross-compiling GCC toolchain installed. This toolchain is also
configured for multiarch compiling and can target PPC32 with eth '-m32'
flag. When targeting 'powerpc-linux-gnu' or some other PPC32 triple, we
have to look for the PPC64 variant of the triple to find the GCC
install, and that triple is neither the host nor target.
The new logic computes the multiarch's alternate triple from the target
triple, and looks under both sides. It also looks more aggressively for
the correct subdirectory of the GCC installation, and exposes the
subdirectory in a nice programmatic way. This '/32' or '/64' suffix is
something we can reuse in many other parts of the toolchain.
An important note -- while this likely fixes a large category of
cross-compile use cases, that's not my primary goal, and I've not done
testing (or added test cases) for scenarios that may now work. If
someone else wants to try more interesting PPC cross compiles, I'd love
to have reports. But my focus is on factoring away the references to the
"host" triple. The refactoring is my goal, and so I'm mostly relying on
the existing (pretty good) test coverage we have here.
Future patches will leverage this new functionality to factor out more
and more of the toolchain's triple manipulation.
llvm-svn: 148935
2012-01-25 15:21:38 +08:00
|
|
|
TripleAliases.append(
|
|
|
|
ARMTriples, ARMTriples + llvm::array_lengthof(ARMTriples));
|
|
|
|
break;
|
|
|
|
case llvm::Triple::x86_64:
|
|
|
|
LibDirs.append(
|
|
|
|
X86_64LibDirs, X86_64LibDirs + llvm::array_lengthof(X86_64LibDirs));
|
|
|
|
TripleAliases.append(
|
|
|
|
X86_64Triples, X86_64Triples + llvm::array_lengthof(X86_64Triples));
|
|
|
|
MultiarchLibDirs.append(
|
|
|
|
X86LibDirs, X86LibDirs + llvm::array_lengthof(X86LibDirs));
|
|
|
|
MultiarchTripleAliases.append(
|
|
|
|
X86Triples, X86Triples + llvm::array_lengthof(X86Triples));
|
|
|
|
break;
|
|
|
|
case llvm::Triple::x86:
|
2011-11-07 07:39:34 +08:00
|
|
|
LibDirs.append(X86LibDirs, X86LibDirs + llvm::array_lengthof(X86LibDirs));
|
Make a major refactoring to how the GCC installation detection works.
The fundamental shift here is to stop making *any* assumptions about the
*host* triple. Where these assumptions you ask? Why, they were in one of
the two target triples referenced of course. This was the single biggest
place where the previously named "host triple" was actually used as
such. ;] The reason we were reasoning about the host is in order to
detect the use of '-m32' or '-m64' flags to change the target. These
flags shift the default target only slightly, which typically means
a slight deviation from the host. When using these flags, the GCC
installation is under a different triple from the one actually targeted
in the compilation, and we used the host triple to find it.
Too bad that wasn't even correct. Consider an x86 Linux host which has
a PPC64 cross-compiling GCC toolchain installed. This toolchain is also
configured for multiarch compiling and can target PPC32 with eth '-m32'
flag. When targeting 'powerpc-linux-gnu' or some other PPC32 triple, we
have to look for the PPC64 variant of the triple to find the GCC
install, and that triple is neither the host nor target.
The new logic computes the multiarch's alternate triple from the target
triple, and looks under both sides. It also looks more aggressively for
the correct subdirectory of the GCC installation, and exposes the
subdirectory in a nice programmatic way. This '/32' or '/64' suffix is
something we can reuse in many other parts of the toolchain.
An important note -- while this likely fixes a large category of
cross-compile use cases, that's not my primary goal, and I've not done
testing (or added test cases) for scenarios that may now work. If
someone else wants to try more interesting PPC cross compiles, I'd love
to have reports. But my focus is on factoring away the references to the
"host" triple. The refactoring is my goal, and so I'm mostly relying on
the existing (pretty good) test coverage we have here.
Future patches will leverage this new functionality to factor out more
and more of the toolchain's triple manipulation.
llvm-svn: 148935
2012-01-25 15:21:38 +08:00
|
|
|
TripleAliases.append(
|
|
|
|
X86Triples, X86Triples + llvm::array_lengthof(X86Triples));
|
|
|
|
MultiarchLibDirs.append(
|
|
|
|
X86_64LibDirs, X86_64LibDirs + llvm::array_lengthof(X86_64LibDirs));
|
|
|
|
MultiarchTripleAliases.append(
|
|
|
|
X86_64Triples, X86_64Triples + llvm::array_lengthof(X86_64Triples));
|
|
|
|
break;
|
|
|
|
case llvm::Triple::mips:
|
|
|
|
LibDirs.append(
|
|
|
|
MIPSLibDirs, MIPSLibDirs + llvm::array_lengthof(MIPSLibDirs));
|
|
|
|
TripleAliases.append(
|
|
|
|
MIPSTriples, MIPSTriples + llvm::array_lengthof(MIPSTriples));
|
|
|
|
break;
|
|
|
|
case llvm::Triple::mipsel:
|
|
|
|
LibDirs.append(
|
|
|
|
MIPSELLibDirs, MIPSELLibDirs + llvm::array_lengthof(MIPSELLibDirs));
|
|
|
|
TripleAliases.append(
|
|
|
|
MIPSELTriples, MIPSELTriples + llvm::array_lengthof(MIPSELTriples));
|
|
|
|
break;
|
|
|
|
case llvm::Triple::ppc:
|
2011-11-07 07:39:34 +08:00
|
|
|
LibDirs.append(PPCLibDirs, PPCLibDirs + llvm::array_lengthof(PPCLibDirs));
|
Make a major refactoring to how the GCC installation detection works.
The fundamental shift here is to stop making *any* assumptions about the
*host* triple. Where these assumptions you ask? Why, they were in one of
the two target triples referenced of course. This was the single biggest
place where the previously named "host triple" was actually used as
such. ;] The reason we were reasoning about the host is in order to
detect the use of '-m32' or '-m64' flags to change the target. These
flags shift the default target only slightly, which typically means
a slight deviation from the host. When using these flags, the GCC
installation is under a different triple from the one actually targeted
in the compilation, and we used the host triple to find it.
Too bad that wasn't even correct. Consider an x86 Linux host which has
a PPC64 cross-compiling GCC toolchain installed. This toolchain is also
configured for multiarch compiling and can target PPC32 with eth '-m32'
flag. When targeting 'powerpc-linux-gnu' or some other PPC32 triple, we
have to look for the PPC64 variant of the triple to find the GCC
install, and that triple is neither the host nor target.
The new logic computes the multiarch's alternate triple from the target
triple, and looks under both sides. It also looks more aggressively for
the correct subdirectory of the GCC installation, and exposes the
subdirectory in a nice programmatic way. This '/32' or '/64' suffix is
something we can reuse in many other parts of the toolchain.
An important note -- while this likely fixes a large category of
cross-compile use cases, that's not my primary goal, and I've not done
testing (or added test cases) for scenarios that may now work. If
someone else wants to try more interesting PPC cross compiles, I'd love
to have reports. But my focus is on factoring away the references to the
"host" triple. The refactoring is my goal, and so I'm mostly relying on
the existing (pretty good) test coverage we have here.
Future patches will leverage this new functionality to factor out more
and more of the toolchain's triple manipulation.
llvm-svn: 148935
2012-01-25 15:21:38 +08:00
|
|
|
TripleAliases.append(
|
|
|
|
PPCTriples, PPCTriples + llvm::array_lengthof(PPCTriples));
|
|
|
|
MultiarchLibDirs.append(
|
|
|
|
PPC64LibDirs, PPC64LibDirs + llvm::array_lengthof(PPC64LibDirs));
|
|
|
|
MultiarchTripleAliases.append(
|
|
|
|
PPC64Triples, PPC64Triples + llvm::array_lengthof(PPC64Triples));
|
|
|
|
break;
|
|
|
|
case llvm::Triple::ppc64:
|
|
|
|
LibDirs.append(
|
|
|
|
PPC64LibDirs, PPC64LibDirs + llvm::array_lengthof(PPC64LibDirs));
|
|
|
|
TripleAliases.append(
|
|
|
|
PPC64Triples, PPC64Triples + llvm::array_lengthof(PPC64Triples));
|
|
|
|
MultiarchLibDirs.append(
|
|
|
|
PPCLibDirs, PPCLibDirs + llvm::array_lengthof(PPCLibDirs));
|
|
|
|
MultiarchTripleAliases.append(
|
|
|
|
PPCTriples, PPCTriples + llvm::array_lengthof(PPCTriples));
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
// By default, just rely on the standard lib directories and the original
|
|
|
|
// triple.
|
|
|
|
break;
|
2011-11-07 07:39:34 +08:00
|
|
|
}
|
Make a major refactoring to how the GCC installation detection works.
The fundamental shift here is to stop making *any* assumptions about the
*host* triple. Where these assumptions you ask? Why, they were in one of
the two target triples referenced of course. This was the single biggest
place where the previously named "host triple" was actually used as
such. ;] The reason we were reasoning about the host is in order to
detect the use of '-m32' or '-m64' flags to change the target. These
flags shift the default target only slightly, which typically means
a slight deviation from the host. When using these flags, the GCC
installation is under a different triple from the one actually targeted
in the compilation, and we used the host triple to find it.
Too bad that wasn't even correct. Consider an x86 Linux host which has
a PPC64 cross-compiling GCC toolchain installed. This toolchain is also
configured for multiarch compiling and can target PPC32 with eth '-m32'
flag. When targeting 'powerpc-linux-gnu' or some other PPC32 triple, we
have to look for the PPC64 variant of the triple to find the GCC
install, and that triple is neither the host nor target.
The new logic computes the multiarch's alternate triple from the target
triple, and looks under both sides. It also looks more aggressively for
the correct subdirectory of the GCC installation, and exposes the
subdirectory in a nice programmatic way. This '/32' or '/64' suffix is
something we can reuse in many other parts of the toolchain.
An important note -- while this likely fixes a large category of
cross-compile use cases, that's not my primary goal, and I've not done
testing (or added test cases) for scenarios that may now work. If
someone else wants to try more interesting PPC cross compiles, I'd love
to have reports. But my focus is on factoring away the references to the
"host" triple. The refactoring is my goal, and so I'm mostly relying on
the existing (pretty good) test coverage we have here.
Future patches will leverage this new functionality to factor out more
and more of the toolchain's triple manipulation.
llvm-svn: 148935
2012-01-25 15:21:38 +08:00
|
|
|
|
|
|
|
// Always append the drivers target triple to the end, in case it doesn't
|
|
|
|
// match any of our aliases.
|
|
|
|
TripleAliases.push_back(TargetTriple.str());
|
|
|
|
|
|
|
|
// Also include the multiarch variant if it's different.
|
|
|
|
if (TargetTriple.str() != MultiarchTriple.str())
|
|
|
|
MultiarchTripleAliases.push_back(MultiarchTriple.str());
|
2011-11-07 07:39:34 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void Generic_GCC::GCCInstallationDetector::ScanLibDirForGCCTriple(
|
Make a major refactoring to how the GCC installation detection works.
The fundamental shift here is to stop making *any* assumptions about the
*host* triple. Where these assumptions you ask? Why, they were in one of
the two target triples referenced of course. This was the single biggest
place where the previously named "host triple" was actually used as
such. ;] The reason we were reasoning about the host is in order to
detect the use of '-m32' or '-m64' flags to change the target. These
flags shift the default target only slightly, which typically means
a slight deviation from the host. When using these flags, the GCC
installation is under a different triple from the one actually targeted
in the compilation, and we used the host triple to find it.
Too bad that wasn't even correct. Consider an x86 Linux host which has
a PPC64 cross-compiling GCC toolchain installed. This toolchain is also
configured for multiarch compiling and can target PPC32 with eth '-m32'
flag. When targeting 'powerpc-linux-gnu' or some other PPC32 triple, we
have to look for the PPC64 variant of the triple to find the GCC
install, and that triple is neither the host nor target.
The new logic computes the multiarch's alternate triple from the target
triple, and looks under both sides. It also looks more aggressively for
the correct subdirectory of the GCC installation, and exposes the
subdirectory in a nice programmatic way. This '/32' or '/64' suffix is
something we can reuse in many other parts of the toolchain.
An important note -- while this likely fixes a large category of
cross-compile use cases, that's not my primary goal, and I've not done
testing (or added test cases) for scenarios that may now work. If
someone else wants to try more interesting PPC cross compiles, I'd love
to have reports. But my focus is on factoring away the references to the
"host" triple. The refactoring is my goal, and so I'm mostly relying on
the existing (pretty good) test coverage we have here.
Future patches will leverage this new functionality to factor out more
and more of the toolchain's triple manipulation.
llvm-svn: 148935
2012-01-25 15:21:38 +08:00
|
|
|
llvm::Triple::ArchType TargetArch, const std::string &LibDir,
|
|
|
|
StringRef CandidateTriple, bool NeedsMultiarchSuffix) {
|
2011-11-07 07:39:34 +08:00
|
|
|
// There are various different suffixes involving the triple we
|
|
|
|
// check for. We also record what is necessary to walk from each back
|
|
|
|
// up to the lib directory.
|
Make a major refactoring to how the GCC installation detection works.
The fundamental shift here is to stop making *any* assumptions about the
*host* triple. Where these assumptions you ask? Why, they were in one of
the two target triples referenced of course. This was the single biggest
place where the previously named "host triple" was actually used as
such. ;] The reason we were reasoning about the host is in order to
detect the use of '-m32' or '-m64' flags to change the target. These
flags shift the default target only slightly, which typically means
a slight deviation from the host. When using these flags, the GCC
installation is under a different triple from the one actually targeted
in the compilation, and we used the host triple to find it.
Too bad that wasn't even correct. Consider an x86 Linux host which has
a PPC64 cross-compiling GCC toolchain installed. This toolchain is also
configured for multiarch compiling and can target PPC32 with eth '-m32'
flag. When targeting 'powerpc-linux-gnu' or some other PPC32 triple, we
have to look for the PPC64 variant of the triple to find the GCC
install, and that triple is neither the host nor target.
The new logic computes the multiarch's alternate triple from the target
triple, and looks under both sides. It also looks more aggressively for
the correct subdirectory of the GCC installation, and exposes the
subdirectory in a nice programmatic way. This '/32' or '/64' suffix is
something we can reuse in many other parts of the toolchain.
An important note -- while this likely fixes a large category of
cross-compile use cases, that's not my primary goal, and I've not done
testing (or added test cases) for scenarios that may now work. If
someone else wants to try more interesting PPC cross compiles, I'd love
to have reports. But my focus is on factoring away the references to the
"host" triple. The refactoring is my goal, and so I'm mostly relying on
the existing (pretty good) test coverage we have here.
Future patches will leverage this new functionality to factor out more
and more of the toolchain's triple manipulation.
llvm-svn: 148935
2012-01-25 15:21:38 +08:00
|
|
|
const std::string LibSuffixes[] = {
|
2011-11-07 07:39:34 +08:00
|
|
|
"/gcc/" + CandidateTriple.str(),
|
|
|
|
"/" + CandidateTriple.str() + "/gcc/" + CandidateTriple.str(),
|
|
|
|
|
|
|
|
// Ubuntu has a strange mis-matched pair of triples that this happens to
|
|
|
|
// match.
|
|
|
|
// FIXME: It may be worthwhile to generalize this and look for a second
|
|
|
|
// triple.
|
2011-11-09 11:46:20 +08:00
|
|
|
"/i386-linux-gnu/gcc/" + CandidateTriple.str()
|
2011-11-07 07:39:34 +08:00
|
|
|
};
|
|
|
|
const std::string InstallSuffixes[] = {
|
|
|
|
"/../../..",
|
|
|
|
"/../../../..",
|
|
|
|
"/../../../.."
|
|
|
|
};
|
|
|
|
// Only look at the final, weird Ubuntu suffix for i386-linux-gnu.
|
Make a major refactoring to how the GCC installation detection works.
The fundamental shift here is to stop making *any* assumptions about the
*host* triple. Where these assumptions you ask? Why, they were in one of
the two target triples referenced of course. This was the single biggest
place where the previously named "host triple" was actually used as
such. ;] The reason we were reasoning about the host is in order to
detect the use of '-m32' or '-m64' flags to change the target. These
flags shift the default target only slightly, which typically means
a slight deviation from the host. When using these flags, the GCC
installation is under a different triple from the one actually targeted
in the compilation, and we used the host triple to find it.
Too bad that wasn't even correct. Consider an x86 Linux host which has
a PPC64 cross-compiling GCC toolchain installed. This toolchain is also
configured for multiarch compiling and can target PPC32 with eth '-m32'
flag. When targeting 'powerpc-linux-gnu' or some other PPC32 triple, we
have to look for the PPC64 variant of the triple to find the GCC
install, and that triple is neither the host nor target.
The new logic computes the multiarch's alternate triple from the target
triple, and looks under both sides. It also looks more aggressively for
the correct subdirectory of the GCC installation, and exposes the
subdirectory in a nice programmatic way. This '/32' or '/64' suffix is
something we can reuse in many other parts of the toolchain.
An important note -- while this likely fixes a large category of
cross-compile use cases, that's not my primary goal, and I've not done
testing (or added test cases) for scenarios that may now work. If
someone else wants to try more interesting PPC cross compiles, I'd love
to have reports. But my focus is on factoring away the references to the
"host" triple. The refactoring is my goal, and so I'm mostly relying on
the existing (pretty good) test coverage we have here.
Future patches will leverage this new functionality to factor out more
and more of the toolchain's triple manipulation.
llvm-svn: 148935
2012-01-25 15:21:38 +08:00
|
|
|
const unsigned NumLibSuffixes = (llvm::array_lengthof(LibSuffixes) -
|
|
|
|
(TargetArch != llvm::Triple::x86));
|
|
|
|
for (unsigned i = 0; i < NumLibSuffixes; ++i) {
|
|
|
|
StringRef LibSuffix = LibSuffixes[i];
|
2011-11-07 07:39:34 +08:00
|
|
|
llvm::error_code EC;
|
Make a major refactoring to how the GCC installation detection works.
The fundamental shift here is to stop making *any* assumptions about the
*host* triple. Where these assumptions you ask? Why, they were in one of
the two target triples referenced of course. This was the single biggest
place where the previously named "host triple" was actually used as
such. ;] The reason we were reasoning about the host is in order to
detect the use of '-m32' or '-m64' flags to change the target. These
flags shift the default target only slightly, which typically means
a slight deviation from the host. When using these flags, the GCC
installation is under a different triple from the one actually targeted
in the compilation, and we used the host triple to find it.
Too bad that wasn't even correct. Consider an x86 Linux host which has
a PPC64 cross-compiling GCC toolchain installed. This toolchain is also
configured for multiarch compiling and can target PPC32 with eth '-m32'
flag. When targeting 'powerpc-linux-gnu' or some other PPC32 triple, we
have to look for the PPC64 variant of the triple to find the GCC
install, and that triple is neither the host nor target.
The new logic computes the multiarch's alternate triple from the target
triple, and looks under both sides. It also looks more aggressively for
the correct subdirectory of the GCC installation, and exposes the
subdirectory in a nice programmatic way. This '/32' or '/64' suffix is
something we can reuse in many other parts of the toolchain.
An important note -- while this likely fixes a large category of
cross-compile use cases, that's not my primary goal, and I've not done
testing (or added test cases) for scenarios that may now work. If
someone else wants to try more interesting PPC cross compiles, I'd love
to have reports. But my focus is on factoring away the references to the
"host" triple. The refactoring is my goal, and so I'm mostly relying on
the existing (pretty good) test coverage we have here.
Future patches will leverage this new functionality to factor out more
and more of the toolchain's triple manipulation.
llvm-svn: 148935
2012-01-25 15:21:38 +08:00
|
|
|
for (llvm::sys::fs::directory_iterator LI(LibDir + LibSuffix, EC), LE;
|
2011-11-07 07:39:34 +08:00
|
|
|
!EC && LI != LE; LI = LI.increment(EC)) {
|
|
|
|
StringRef VersionText = llvm::sys::path::filename(LI->path());
|
|
|
|
GCCVersion CandidateVersion = GCCVersion::Parse(VersionText);
|
|
|
|
static const GCCVersion MinVersion = { "4.1.1", 4, 1, 1, "" };
|
|
|
|
if (CandidateVersion < MinVersion)
|
|
|
|
continue;
|
|
|
|
if (CandidateVersion <= Version)
|
|
|
|
continue;
|
2011-12-08 13:50:03 +08:00
|
|
|
|
|
|
|
// Some versions of SUSE and Fedora on ppc64 put 32-bit libs
|
2012-01-25 03:21:42 +08:00
|
|
|
// in what would normally be GCCInstallPath and put the 64-bit
|
Make a major refactoring to how the GCC installation detection works.
The fundamental shift here is to stop making *any* assumptions about the
*host* triple. Where these assumptions you ask? Why, they were in one of
the two target triples referenced of course. This was the single biggest
place where the previously named "host triple" was actually used as
such. ;] The reason we were reasoning about the host is in order to
detect the use of '-m32' or '-m64' flags to change the target. These
flags shift the default target only slightly, which typically means
a slight deviation from the host. When using these flags, the GCC
installation is under a different triple from the one actually targeted
in the compilation, and we used the host triple to find it.
Too bad that wasn't even correct. Consider an x86 Linux host which has
a PPC64 cross-compiling GCC toolchain installed. This toolchain is also
configured for multiarch compiling and can target PPC32 with eth '-m32'
flag. When targeting 'powerpc-linux-gnu' or some other PPC32 triple, we
have to look for the PPC64 variant of the triple to find the GCC
install, and that triple is neither the host nor target.
The new logic computes the multiarch's alternate triple from the target
triple, and looks under both sides. It also looks more aggressively for
the correct subdirectory of the GCC installation, and exposes the
subdirectory in a nice programmatic way. This '/32' or '/64' suffix is
something we can reuse in many other parts of the toolchain.
An important note -- while this likely fixes a large category of
cross-compile use cases, that's not my primary goal, and I've not done
testing (or added test cases) for scenarios that may now work. If
someone else wants to try more interesting PPC cross compiles, I'd love
to have reports. But my focus is on factoring away the references to the
"host" triple. The refactoring is my goal, and so I'm mostly relying on
the existing (pretty good) test coverage we have here.
Future patches will leverage this new functionality to factor out more
and more of the toolchain's triple manipulation.
llvm-svn: 148935
2012-01-25 15:21:38 +08:00
|
|
|
// libs in a subdirectory named 64. The simple logic we follow is that
|
|
|
|
// *if* there is a subdirectory of the right name with crtbegin.o in it,
|
|
|
|
// we use that. If not, and if not a multiarch triple, we look for
|
|
|
|
// crtbegin.o without the subdirectory.
|
|
|
|
StringRef MultiarchSuffix
|
|
|
|
= (TargetArch == llvm::Triple::x86_64 ||
|
|
|
|
TargetArch == llvm::Triple::ppc64) ? "/64" : "/32";
|
|
|
|
if (llvm::sys::fs::exists(LI->path() + MultiarchSuffix + "/crtbegin.o")) {
|
|
|
|
GCCMultiarchSuffix = MultiarchSuffix.str();
|
|
|
|
} else {
|
|
|
|
if (NeedsMultiarchSuffix ||
|
|
|
|
!llvm::sys::fs::exists(LI->path() + "/crtbegin.o"))
|
|
|
|
continue;
|
|
|
|
GCCMultiarchSuffix.clear();
|
|
|
|
}
|
2011-11-07 07:39:34 +08:00
|
|
|
|
|
|
|
Version = CandidateVersion;
|
2012-01-25 03:28:29 +08:00
|
|
|
GCCTriple.setTriple(CandidateTriple);
|
2011-11-07 07:39:34 +08:00
|
|
|
// FIXME: We hack together the directory name here instead of
|
|
|
|
// using LI to ensure stable path separators across Windows and
|
|
|
|
// Linux.
|
Make a major refactoring to how the GCC installation detection works.
The fundamental shift here is to stop making *any* assumptions about the
*host* triple. Where these assumptions you ask? Why, they were in one of
the two target triples referenced of course. This was the single biggest
place where the previously named "host triple" was actually used as
such. ;] The reason we were reasoning about the host is in order to
detect the use of '-m32' or '-m64' flags to change the target. These
flags shift the default target only slightly, which typically means
a slight deviation from the host. When using these flags, the GCC
installation is under a different triple from the one actually targeted
in the compilation, and we used the host triple to find it.
Too bad that wasn't even correct. Consider an x86 Linux host which has
a PPC64 cross-compiling GCC toolchain installed. This toolchain is also
configured for multiarch compiling and can target PPC32 with eth '-m32'
flag. When targeting 'powerpc-linux-gnu' or some other PPC32 triple, we
have to look for the PPC64 variant of the triple to find the GCC
install, and that triple is neither the host nor target.
The new logic computes the multiarch's alternate triple from the target
triple, and looks under both sides. It also looks more aggressively for
the correct subdirectory of the GCC installation, and exposes the
subdirectory in a nice programmatic way. This '/32' or '/64' suffix is
something we can reuse in many other parts of the toolchain.
An important note -- while this likely fixes a large category of
cross-compile use cases, that's not my primary goal, and I've not done
testing (or added test cases) for scenarios that may now work. If
someone else wants to try more interesting PPC cross compiles, I'd love
to have reports. But my focus is on factoring away the references to the
"host" triple. The refactoring is my goal, and so I'm mostly relying on
the existing (pretty good) test coverage we have here.
Future patches will leverage this new functionality to factor out more
and more of the toolchain's triple manipulation.
llvm-svn: 148935
2012-01-25 15:21:38 +08:00
|
|
|
GCCInstallPath = LibDir + LibSuffixes[i] + "/" + VersionText.str();
|
2012-01-25 03:21:42 +08:00
|
|
|
GCCParentLibPath = GCCInstallPath + InstallSuffixes[i];
|
2011-11-07 07:39:34 +08:00
|
|
|
IsValid = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-01-25 17:12:06 +08:00
|
|
|
Generic_GCC::Generic_GCC(const Driver &D, const llvm::Triple& Triple)
|
|
|
|
: ToolChain(D, Triple), GCCInstallation(getDriver(), Triple) {
|
2010-08-02 06:29:51 +08:00
|
|
|
getProgramPaths().push_back(getDriver().getInstalledDir());
|
2011-03-02 06:50:47 +08:00
|
|
|
if (getDriver().getInstalledDir() != getDriver().Dir)
|
2010-08-02 06:29:51 +08:00
|
|
|
getProgramPaths().push_back(getDriver().Dir);
|
2009-03-24 00:15:50 +08:00
|
|
|
}
|
|
|
|
|
2009-03-20 08:20:03 +08:00
|
|
|
Generic_GCC::~Generic_GCC() {
|
|
|
|
// Free tool implementations.
|
|
|
|
for (llvm::DenseMap<unsigned, Tool*>::iterator
|
|
|
|
it = Tools.begin(), ie = Tools.end(); it != ie; ++it)
|
|
|
|
delete it->second;
|
|
|
|
}
|
|
|
|
|
2009-09-09 23:08:12 +08:00
|
|
|
Tool &Generic_GCC::SelectTool(const Compilation &C,
|
2011-03-19 04:14:00 +08:00
|
|
|
const JobAction &JA,
|
|
|
|
const ActionList &Inputs) const {
|
2009-03-20 08:20:03 +08:00
|
|
|
Action::ActionClass Key;
|
2009-12-22 02:54:17 +08:00
|
|
|
if (getDriver().ShouldUseClangCompiler(C, JA, getTriple()))
|
2009-03-20 08:20:03 +08:00
|
|
|
Key = Action::AnalyzeJobClass;
|
|
|
|
else
|
|
|
|
Key = JA.getKind();
|
|
|
|
|
|
|
|
Tool *&T = Tools[Key];
|
|
|
|
if (!T) {
|
|
|
|
switch (Key) {
|
2009-03-20 08:57:52 +08:00
|
|
|
case Action::InputClass:
|
|
|
|
case Action::BindArchClass:
|
2011-09-23 13:06:16 +08:00
|
|
|
llvm_unreachable("Invalid tool kind.");
|
2009-03-20 08:20:03 +08:00
|
|
|
case Action::PreprocessJobClass:
|
|
|
|
T = new tools::gcc::Preprocess(*this); break;
|
|
|
|
case Action::PrecompileJobClass:
|
|
|
|
T = new tools::gcc::Precompile(*this); break;
|
|
|
|
case Action::AnalyzeJobClass:
|
|
|
|
T = new tools::Clang(*this); break;
|
|
|
|
case Action::CompileJobClass:
|
|
|
|
T = new tools::gcc::Compile(*this); break;
|
|
|
|
case Action::AssembleJobClass:
|
|
|
|
T = new tools::gcc::Assemble(*this); break;
|
|
|
|
case Action::LinkJobClass:
|
|
|
|
T = new tools::gcc::Link(*this); break;
|
2009-09-09 23:08:12 +08:00
|
|
|
|
2009-03-20 08:57:52 +08:00
|
|
|
// This is a bit ungeneric, but the only platform using a driver
|
|
|
|
// driver is Darwin.
|
|
|
|
case Action::LipoJobClass:
|
|
|
|
T = new tools::darwin::Lipo(*this); break;
|
2010-06-05 02:28:36 +08:00
|
|
|
case Action::DsymutilJobClass:
|
|
|
|
T = new tools::darwin::Dsymutil(*this); break;
|
2011-08-24 01:56:55 +08:00
|
|
|
case Action::VerifyJobClass:
|
|
|
|
T = new tools::darwin::VerifyDebug(*this); break;
|
2009-03-20 08:20:03 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return *T;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool Generic_GCC::IsUnwindTablesDefault() const {
|
2009-03-20 08:57:52 +08:00
|
|
|
// FIXME: Gross; we should probably have some separate target
|
|
|
|
// definition, possibly even reusing the one in clang.
|
2009-03-20 08:20:03 +08:00
|
|
|
return getArchName() == "x86_64";
|
|
|
|
}
|
|
|
|
|
|
|
|
const char *Generic_GCC::GetDefaultRelocationModel() const {
|
|
|
|
return "static";
|
|
|
|
}
|
|
|
|
|
|
|
|
const char *Generic_GCC::GetForcedPicModel() const {
|
|
|
|
return 0;
|
|
|
|
}
|
2011-12-13 05:14:55 +08:00
|
|
|
/// Hexagon Toolchain
|
|
|
|
|
2012-01-25 17:12:06 +08:00
|
|
|
Hexagon_TC::Hexagon_TC(const Driver &D, const llvm::Triple& Triple)
|
|
|
|
: ToolChain(D, Triple) {
|
2011-12-13 05:14:55 +08:00
|
|
|
getProgramPaths().push_back(getDriver().getInstalledDir());
|
|
|
|
if (getDriver().getInstalledDir() != getDriver().Dir.c_str())
|
|
|
|
getProgramPaths().push_back(getDriver().Dir);
|
|
|
|
}
|
|
|
|
|
|
|
|
Hexagon_TC::~Hexagon_TC() {
|
|
|
|
// Free tool implementations.
|
|
|
|
for (llvm::DenseMap<unsigned, Tool*>::iterator
|
|
|
|
it = Tools.begin(), ie = Tools.end(); it != ie; ++it)
|
|
|
|
delete it->second;
|
|
|
|
}
|
|
|
|
|
|
|
|
Tool &Hexagon_TC::SelectTool(const Compilation &C,
|
|
|
|
const JobAction &JA,
|
|
|
|
const ActionList &Inputs) const {
|
|
|
|
Action::ActionClass Key;
|
|
|
|
// if (JA.getKind () == Action::CompileJobClass)
|
|
|
|
// Key = JA.getKind ();
|
|
|
|
// else
|
|
|
|
|
|
|
|
if (getDriver().ShouldUseClangCompiler(C, JA, getTriple()))
|
|
|
|
Key = Action::AnalyzeJobClass;
|
|
|
|
else
|
|
|
|
Key = JA.getKind();
|
|
|
|
// if ((JA.getKind () == Action::CompileJobClass)
|
|
|
|
// && (JA.getType () != types::TY_LTO_BC)) {
|
|
|
|
// Key = JA.getKind ();
|
|
|
|
// }
|
|
|
|
|
|
|
|
Tool *&T = Tools[Key];
|
|
|
|
if (!T) {
|
|
|
|
switch (Key) {
|
|
|
|
case Action::InputClass:
|
|
|
|
case Action::BindArchClass:
|
|
|
|
assert(0 && "Invalid tool kind.");
|
|
|
|
case Action::AnalyzeJobClass:
|
|
|
|
T = new tools::Clang(*this); break;
|
|
|
|
case Action::AssembleJobClass:
|
|
|
|
T = new tools::hexagon::Assemble(*this); break;
|
|
|
|
case Action::LinkJobClass:
|
|
|
|
T = new tools::hexagon::Link(*this); break;
|
|
|
|
default:
|
|
|
|
assert(false && "Unsupported action for Hexagon target.");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return *T;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool Hexagon_TC::IsUnwindTablesDefault() const {
|
|
|
|
// FIXME: Gross; we should probably have some separate target
|
|
|
|
// definition, possibly even reusing the one in clang.
|
|
|
|
return getArchName() == "x86_64";
|
|
|
|
}
|
|
|
|
|
|
|
|
const char *Hexagon_TC::GetDefaultRelocationModel() const {
|
|
|
|
return "static";
|
|
|
|
}
|
|
|
|
|
|
|
|
const char *Hexagon_TC::GetForcedPicModel() const {
|
|
|
|
return 0;
|
|
|
|
} // End Hexagon
|
|
|
|
|
2009-03-25 12:13:45 +08:00
|
|
|
|
2010-03-05 05:07:38 +08:00
|
|
|
/// TCEToolChain - A tool chain using the llvm bitcode tools to perform
|
|
|
|
/// all subcommands. See http://tce.cs.tut.fi for our peculiar target.
|
|
|
|
/// Currently does not support anything else but compilation.
|
|
|
|
|
2012-01-25 17:12:06 +08:00
|
|
|
TCEToolChain::TCEToolChain(const Driver &D, const llvm::Triple& Triple)
|
|
|
|
: ToolChain(D, Triple) {
|
2010-03-05 05:07:38 +08:00
|
|
|
// Path mangling to find libexec
|
|
|
|
std::string Path(getDriver().Dir);
|
|
|
|
|
|
|
|
Path += "/../libexec";
|
|
|
|
getProgramPaths().push_back(Path);
|
|
|
|
}
|
|
|
|
|
|
|
|
TCEToolChain::~TCEToolChain() {
|
|
|
|
for (llvm::DenseMap<unsigned, Tool*>::iterator
|
|
|
|
it = Tools.begin(), ie = Tools.end(); it != ie; ++it)
|
|
|
|
delete it->second;
|
|
|
|
}
|
|
|
|
|
2011-06-03 11:49:51 +08:00
|
|
|
bool TCEToolChain::IsMathErrnoDefault() const {
|
|
|
|
return true;
|
2010-03-05 05:07:38 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
bool TCEToolChain::IsUnwindTablesDefault() const {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
const char *TCEToolChain::GetDefaultRelocationModel() const {
|
|
|
|
return "static";
|
|
|
|
}
|
|
|
|
|
|
|
|
const char *TCEToolChain::GetForcedPicModel() const {
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2011-06-03 11:49:51 +08:00
|
|
|
Tool &TCEToolChain::SelectTool(const Compilation &C,
|
2011-03-19 04:14:00 +08:00
|
|
|
const JobAction &JA,
|
|
|
|
const ActionList &Inputs) const {
|
2010-03-05 05:07:38 +08:00
|
|
|
Action::ActionClass Key;
|
|
|
|
Key = Action::AnalyzeJobClass;
|
|
|
|
|
|
|
|
Tool *&T = Tools[Key];
|
|
|
|
if (!T) {
|
|
|
|
switch (Key) {
|
|
|
|
case Action::PreprocessJobClass:
|
|
|
|
T = new tools::gcc::Preprocess(*this); break;
|
|
|
|
case Action::AnalyzeJobClass:
|
|
|
|
T = new tools::Clang(*this); break;
|
|
|
|
default:
|
2011-09-23 13:06:16 +08:00
|
|
|
llvm_unreachable("Unsupported action for TCE target.");
|
2010-03-05 05:07:38 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return *T;
|
|
|
|
}
|
|
|
|
|
2009-06-30 04:52:51 +08:00
|
|
|
/// OpenBSD - OpenBSD tool chain which can call as(1) and ld(1) directly.
|
|
|
|
|
2012-01-25 17:12:06 +08:00
|
|
|
OpenBSD::OpenBSD(const Driver &D, const llvm::Triple& Triple)
|
|
|
|
: Generic_ELF(D, Triple) {
|
2009-12-22 02:54:17 +08:00
|
|
|
getFilePaths().push_back(getDriver().Dir + "/../lib");
|
2009-06-30 04:52:51 +08:00
|
|
|
getFilePaths().push_back("/usr/lib");
|
|
|
|
}
|
|
|
|
|
2011-03-19 04:14:00 +08:00
|
|
|
Tool &OpenBSD::SelectTool(const Compilation &C, const JobAction &JA,
|
|
|
|
const ActionList &Inputs) const {
|
2009-06-30 04:52:51 +08:00
|
|
|
Action::ActionClass Key;
|
2009-12-22 02:54:17 +08:00
|
|
|
if (getDriver().ShouldUseClangCompiler(C, JA, getTriple()))
|
2009-06-30 04:52:51 +08:00
|
|
|
Key = Action::AnalyzeJobClass;
|
|
|
|
else
|
|
|
|
Key = JA.getKind();
|
|
|
|
|
2010-11-08 07:13:01 +08:00
|
|
|
bool UseIntegratedAs = C.getArgs().hasFlag(options::OPT_integrated_as,
|
|
|
|
options::OPT_no_integrated_as,
|
|
|
|
IsIntegratedAssemblerDefault());
|
|
|
|
|
2009-06-30 04:52:51 +08:00
|
|
|
Tool *&T = Tools[Key];
|
|
|
|
if (!T) {
|
|
|
|
switch (Key) {
|
2010-11-08 07:13:01 +08:00
|
|
|
case Action::AssembleJobClass: {
|
|
|
|
if (UseIntegratedAs)
|
|
|
|
T = new tools::ClangAs(*this);
|
|
|
|
else
|
|
|
|
T = new tools::openbsd::Assemble(*this);
|
|
|
|
break;
|
|
|
|
}
|
2009-06-30 04:52:51 +08:00
|
|
|
case Action::LinkJobClass:
|
|
|
|
T = new tools::openbsd::Link(*this); break;
|
|
|
|
default:
|
2011-03-19 04:14:00 +08:00
|
|
|
T = &Generic_GCC::SelectTool(C, JA, Inputs);
|
2009-06-30 04:52:51 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return *T;
|
|
|
|
}
|
|
|
|
|
2012-01-25 16:10:33 +08:00
|
|
|
static void addPathIfExists(Twine Path, ToolChain::path_list &Paths) {
|
|
|
|
if (llvm::sys::fs::exists(Path)) Paths.push_back(Path.str());
|
|
|
|
}
|
|
|
|
|
2009-03-31 05:06:03 +08:00
|
|
|
/// FreeBSD - FreeBSD tool chain which can call as(1) and ld(1) directly.
|
|
|
|
|
2012-01-25 17:12:06 +08:00
|
|
|
FreeBSD::FreeBSD(const Driver &D, const llvm::Triple& Triple)
|
|
|
|
: Generic_ELF(D, Triple) {
|
2010-08-02 13:43:59 +08:00
|
|
|
|
2012-01-25 16:04:15 +08:00
|
|
|
// When targeting 32-bit platforms, look for libraries in '/usr/lib32' first;
|
|
|
|
// for 64-bit hosts that's where they will live. We fall back to '/usr/lib'
|
|
|
|
// for the remaining cases.
|
|
|
|
if (Triple.getArch() == llvm::Triple::x86 ||
|
|
|
|
Triple.getArch() == llvm::Triple::ppc)
|
2012-01-25 16:10:33 +08:00
|
|
|
addPathIfExists(getDriver().SysRoot + "/usr/lib32", getFilePaths());
|
2012-01-25 16:04:15 +08:00
|
|
|
|
2012-01-25 16:10:33 +08:00
|
|
|
addPathIfExists(getDriver().SysRoot + "/usr/lib", getFilePaths());
|
2009-03-31 05:06:03 +08:00
|
|
|
}
|
|
|
|
|
2011-03-19 04:14:00 +08:00
|
|
|
Tool &FreeBSD::SelectTool(const Compilation &C, const JobAction &JA,
|
|
|
|
const ActionList &Inputs) const {
|
2009-03-31 05:06:03 +08:00
|
|
|
Action::ActionClass Key;
|
2009-12-22 02:54:17 +08:00
|
|
|
if (getDriver().ShouldUseClangCompiler(C, JA, getTriple()))
|
2009-03-31 05:06:03 +08:00
|
|
|
Key = Action::AnalyzeJobClass;
|
|
|
|
else
|
|
|
|
Key = JA.getKind();
|
|
|
|
|
2010-11-09 01:46:39 +08:00
|
|
|
bool UseIntegratedAs = C.getArgs().hasFlag(options::OPT_integrated_as,
|
|
|
|
options::OPT_no_integrated_as,
|
|
|
|
IsIntegratedAssemblerDefault());
|
|
|
|
|
2009-03-31 05:06:03 +08:00
|
|
|
Tool *&T = Tools[Key];
|
|
|
|
if (!T) {
|
|
|
|
switch (Key) {
|
2009-04-01 01:45:15 +08:00
|
|
|
case Action::AssembleJobClass:
|
2010-11-09 01:46:39 +08:00
|
|
|
if (UseIntegratedAs)
|
|
|
|
T = new tools::ClangAs(*this);
|
|
|
|
else
|
|
|
|
T = new tools::freebsd::Assemble(*this);
|
2010-11-09 03:39:10 +08:00
|
|
|
break;
|
2009-04-02 03:36:32 +08:00
|
|
|
case Action::LinkJobClass:
|
|
|
|
T = new tools::freebsd::Link(*this); break;
|
2009-03-31 05:06:03 +08:00
|
|
|
default:
|
2011-03-19 04:14:00 +08:00
|
|
|
T = &Generic_GCC::SelectTool(C, JA, Inputs);
|
2011-02-03 02:59:27 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return *T;
|
|
|
|
}
|
|
|
|
|
|
|
|
/// NetBSD - NetBSD tool chain which can call as(1) and ld(1) directly.
|
|
|
|
|
2012-01-25 17:12:06 +08:00
|
|
|
NetBSD::NetBSD(const Driver &D, const llvm::Triple& Triple,
|
2011-05-16 21:35:02 +08:00
|
|
|
const llvm::Triple& ToolTriple)
|
2012-01-25 17:12:06 +08:00
|
|
|
: Generic_ELF(D, Triple), ToolTriple(ToolTriple) {
|
2011-02-03 02:59:27 +08:00
|
|
|
|
|
|
|
// Determine if we are compiling 32-bit code on an x86_64 platform.
|
|
|
|
bool Lib32 = false;
|
2011-05-16 21:35:02 +08:00
|
|
|
if (ToolTriple.getArch() == llvm::Triple::x86_64 &&
|
|
|
|
Triple.getArch() == llvm::Triple::x86)
|
2011-02-03 02:59:27 +08:00
|
|
|
Lib32 = true;
|
|
|
|
|
2011-03-21 21:59:26 +08:00
|
|
|
if (getDriver().UseStdLib) {
|
|
|
|
if (Lib32)
|
|
|
|
getFilePaths().push_back("=/usr/lib/i386");
|
|
|
|
else
|
|
|
|
getFilePaths().push_back("=/usr/lib");
|
2011-02-03 02:59:27 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-03-19 04:14:00 +08:00
|
|
|
Tool &NetBSD::SelectTool(const Compilation &C, const JobAction &JA,
|
|
|
|
const ActionList &Inputs) const {
|
2011-02-03 02:59:27 +08:00
|
|
|
Action::ActionClass Key;
|
|
|
|
if (getDriver().ShouldUseClangCompiler(C, JA, getTriple()))
|
|
|
|
Key = Action::AnalyzeJobClass;
|
|
|
|
else
|
|
|
|
Key = JA.getKind();
|
|
|
|
|
|
|
|
bool UseIntegratedAs = C.getArgs().hasFlag(options::OPT_integrated_as,
|
|
|
|
options::OPT_no_integrated_as,
|
|
|
|
IsIntegratedAssemblerDefault());
|
|
|
|
|
|
|
|
Tool *&T = Tools[Key];
|
|
|
|
if (!T) {
|
|
|
|
switch (Key) {
|
|
|
|
case Action::AssembleJobClass:
|
|
|
|
if (UseIntegratedAs)
|
|
|
|
T = new tools::ClangAs(*this);
|
|
|
|
else
|
2011-05-16 21:35:02 +08:00
|
|
|
T = new tools::netbsd::Assemble(*this, ToolTriple);
|
2011-02-03 02:59:27 +08:00
|
|
|
break;
|
|
|
|
case Action::LinkJobClass:
|
2011-05-16 21:35:02 +08:00
|
|
|
T = new tools::netbsd::Link(*this, ToolTriple);
|
|
|
|
break;
|
2011-02-03 02:59:27 +08:00
|
|
|
default:
|
2011-03-19 04:14:00 +08:00
|
|
|
T = &Generic_GCC::SelectTool(C, JA, Inputs);
|
2009-03-31 05:06:03 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return *T;
|
|
|
|
}
|
2009-05-03 02:28:39 +08:00
|
|
|
|
2010-07-08 00:01:42 +08:00
|
|
|
/// Minix - Minix tool chain which can call as(1) and ld(1) directly.
|
|
|
|
|
2012-01-25 17:12:06 +08:00
|
|
|
Minix::Minix(const Driver &D, const llvm::Triple& Triple)
|
|
|
|
: Generic_ELF(D, Triple) {
|
2010-07-08 00:01:42 +08:00
|
|
|
getFilePaths().push_back(getDriver().Dir + "/../lib");
|
|
|
|
getFilePaths().push_back("/usr/lib");
|
|
|
|
}
|
|
|
|
|
2011-03-19 04:14:00 +08:00
|
|
|
Tool &Minix::SelectTool(const Compilation &C, const JobAction &JA,
|
|
|
|
const ActionList &Inputs) const {
|
2010-07-08 00:01:42 +08:00
|
|
|
Action::ActionClass Key;
|
|
|
|
if (getDriver().ShouldUseClangCompiler(C, JA, getTriple()))
|
|
|
|
Key = Action::AnalyzeJobClass;
|
|
|
|
else
|
|
|
|
Key = JA.getKind();
|
|
|
|
|
|
|
|
Tool *&T = Tools[Key];
|
|
|
|
if (!T) {
|
|
|
|
switch (Key) {
|
|
|
|
case Action::AssembleJobClass:
|
|
|
|
T = new tools::minix::Assemble(*this); break;
|
|
|
|
case Action::LinkJobClass:
|
|
|
|
T = new tools::minix::Link(*this); break;
|
|
|
|
default:
|
2011-03-19 04:14:00 +08:00
|
|
|
T = &Generic_GCC::SelectTool(C, JA, Inputs);
|
2010-07-08 00:01:42 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return *T;
|
|
|
|
}
|
|
|
|
|
2009-08-22 09:06:46 +08:00
|
|
|
/// AuroraUX - AuroraUX tool chain which can call as(1) and ld(1) directly.
|
|
|
|
|
2012-01-25 17:12:06 +08:00
|
|
|
AuroraUX::AuroraUX(const Driver &D, const llvm::Triple& Triple)
|
|
|
|
: Generic_GCC(D, Triple) {
|
2009-08-22 09:06:46 +08:00
|
|
|
|
2010-08-02 06:29:51 +08:00
|
|
|
getProgramPaths().push_back(getDriver().getInstalledDir());
|
2011-03-02 06:50:47 +08:00
|
|
|
if (getDriver().getInstalledDir() != getDriver().Dir)
|
2010-08-02 06:29:51 +08:00
|
|
|
getProgramPaths().push_back(getDriver().Dir);
|
2009-08-22 09:06:46 +08:00
|
|
|
|
2009-12-22 02:54:17 +08:00
|
|
|
getFilePaths().push_back(getDriver().Dir + "/../lib");
|
2009-08-22 09:06:46 +08:00
|
|
|
getFilePaths().push_back("/usr/lib");
|
|
|
|
getFilePaths().push_back("/usr/sfw/lib");
|
|
|
|
getFilePaths().push_back("/opt/gcc4/lib");
|
2009-10-15 15:44:07 +08:00
|
|
|
getFilePaths().push_back("/opt/gcc4/lib/gcc/i386-pc-solaris2.11/4.2.4");
|
2009-08-22 09:06:46 +08:00
|
|
|
|
|
|
|
}
|
|
|
|
|
2011-03-19 04:14:00 +08:00
|
|
|
Tool &AuroraUX::SelectTool(const Compilation &C, const JobAction &JA,
|
|
|
|
const ActionList &Inputs) const {
|
2009-08-22 09:06:46 +08:00
|
|
|
Action::ActionClass Key;
|
2009-12-22 02:54:17 +08:00
|
|
|
if (getDriver().ShouldUseClangCompiler(C, JA, getTriple()))
|
2009-08-22 09:06:46 +08:00
|
|
|
Key = Action::AnalyzeJobClass;
|
|
|
|
else
|
|
|
|
Key = JA.getKind();
|
|
|
|
|
|
|
|
Tool *&T = Tools[Key];
|
|
|
|
if (!T) {
|
|
|
|
switch (Key) {
|
|
|
|
case Action::AssembleJobClass:
|
|
|
|
T = new tools::auroraux::Assemble(*this); break;
|
|
|
|
case Action::LinkJobClass:
|
|
|
|
T = new tools::auroraux::Link(*this); break;
|
|
|
|
default:
|
2011-03-19 04:14:00 +08:00
|
|
|
T = &Generic_GCC::SelectTool(C, JA, Inputs);
|
2009-08-22 09:06:46 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return *T;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-05-26 15:52:18 +08:00
|
|
|
/// Linux toolchain (very bare-bones at the moment).
|
|
|
|
|
2010-11-08 04:14:31 +08:00
|
|
|
enum LinuxDistro {
|
2011-02-25 14:39:53 +08:00
|
|
|
ArchLinux,
|
2010-11-08 04:14:31 +08:00
|
|
|
DebianLenny,
|
|
|
|
DebianSqueeze,
|
2011-06-03 05:36:53 +08:00
|
|
|
DebianWheezy,
|
2010-11-11 10:07:13 +08:00
|
|
|
Exherbo,
|
2011-05-22 13:36:06 +08:00
|
|
|
RHEL4,
|
|
|
|
RHEL5,
|
|
|
|
RHEL6,
|
2010-11-08 04:14:31 +08:00
|
|
|
Fedora13,
|
|
|
|
Fedora14,
|
2011-04-07 02:22:53 +08:00
|
|
|
Fedora15,
|
|
|
|
FedoraRawhide,
|
2010-11-08 04:14:31 +08:00
|
|
|
OpenSuse11_3,
|
2011-05-19 21:26:33 +08:00
|
|
|
OpenSuse11_4,
|
|
|
|
OpenSuse12_1,
|
2011-03-14 23:39:50 +08:00
|
|
|
UbuntuHardy,
|
|
|
|
UbuntuIntrepid,
|
2010-11-10 13:00:22 +08:00
|
|
|
UbuntuJaunty,
|
2010-11-15 17:01:52 +08:00
|
|
|
UbuntuKarmic,
|
2010-11-08 04:14:31 +08:00
|
|
|
UbuntuLucid,
|
|
|
|
UbuntuMaverick,
|
2011-04-06 06:04:27 +08:00
|
|
|
UbuntuNatty,
|
2011-06-06 00:08:59 +08:00
|
|
|
UbuntuOneiric,
|
2010-11-08 04:14:31 +08:00
|
|
|
UnknownDistro
|
|
|
|
};
|
|
|
|
|
2011-05-22 13:36:06 +08:00
|
|
|
static bool IsRedhat(enum LinuxDistro Distro) {
|
2011-04-07 02:22:53 +08:00
|
|
|
return Distro == Fedora13 || Distro == Fedora14 ||
|
2011-06-03 23:23:24 +08:00
|
|
|
Distro == Fedora15 || Distro == FedoraRawhide ||
|
|
|
|
Distro == RHEL4 || Distro == RHEL5 || Distro == RHEL6;
|
2010-11-08 04:14:31 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static bool IsOpenSuse(enum LinuxDistro Distro) {
|
2011-05-19 21:26:33 +08:00
|
|
|
return Distro == OpenSuse11_3 || Distro == OpenSuse11_4 ||
|
|
|
|
Distro == OpenSuse12_1;
|
2010-11-08 04:14:31 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static bool IsDebian(enum LinuxDistro Distro) {
|
2011-06-03 05:36:53 +08:00
|
|
|
return Distro == DebianLenny || Distro == DebianSqueeze ||
|
|
|
|
Distro == DebianWheezy;
|
2010-11-08 04:14:31 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static bool IsUbuntu(enum LinuxDistro Distro) {
|
2011-03-14 23:39:50 +08:00
|
|
|
return Distro == UbuntuHardy || Distro == UbuntuIntrepid ||
|
2011-06-03 11:49:51 +08:00
|
|
|
Distro == UbuntuLucid || Distro == UbuntuMaverick ||
|
2011-04-06 06:04:27 +08:00
|
|
|
Distro == UbuntuJaunty || Distro == UbuntuKarmic ||
|
2011-06-06 00:08:59 +08:00
|
|
|
Distro == UbuntuNatty || Distro == UbuntuOneiric;
|
2010-11-08 04:14:31 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static LinuxDistro DetectLinuxDistro(llvm::Triple::ArchType Arch) {
|
2010-12-16 11:28:14 +08:00
|
|
|
llvm::OwningPtr<llvm::MemoryBuffer> File;
|
|
|
|
if (!llvm::MemoryBuffer::getFile("/etc/lsb-release", File)) {
|
2011-07-23 18:55:15 +08:00
|
|
|
StringRef Data = File.get()->getBuffer();
|
|
|
|
SmallVector<StringRef, 8> Lines;
|
2010-11-08 04:14:31 +08:00
|
|
|
Data.split(Lines, "\n");
|
|
|
|
for (unsigned int i = 0, s = Lines.size(); i < s; ++ i) {
|
2011-03-14 23:39:50 +08:00
|
|
|
if (Lines[i] == "DISTRIB_CODENAME=hardy")
|
|
|
|
return UbuntuHardy;
|
2011-04-06 06:04:27 +08:00
|
|
|
else if (Lines[i] == "DISTRIB_CODENAME=intrepid")
|
|
|
|
return UbuntuIntrepid;
|
2010-11-10 13:00:22 +08:00
|
|
|
else if (Lines[i] == "DISTRIB_CODENAME=jaunty")
|
2010-12-16 11:28:14 +08:00
|
|
|
return UbuntuJaunty;
|
2010-11-15 17:01:52 +08:00
|
|
|
else if (Lines[i] == "DISTRIB_CODENAME=karmic")
|
|
|
|
return UbuntuKarmic;
|
2011-04-06 06:04:27 +08:00
|
|
|
else if (Lines[i] == "DISTRIB_CODENAME=lucid")
|
|
|
|
return UbuntuLucid;
|
|
|
|
else if (Lines[i] == "DISTRIB_CODENAME=maverick")
|
|
|
|
return UbuntuMaverick;
|
|
|
|
else if (Lines[i] == "DISTRIB_CODENAME=natty")
|
|
|
|
return UbuntuNatty;
|
2011-06-06 00:08:59 +08:00
|
|
|
else if (Lines[i] == "DISTRIB_CODENAME=oneiric")
|
|
|
|
return UbuntuOneiric;
|
2010-11-08 04:14:31 +08:00
|
|
|
}
|
|
|
|
return UnknownDistro;
|
|
|
|
}
|
|
|
|
|
2010-12-16 11:28:14 +08:00
|
|
|
if (!llvm::MemoryBuffer::getFile("/etc/redhat-release", File)) {
|
2011-07-23 18:55:15 +08:00
|
|
|
StringRef Data = File.get()->getBuffer();
|
2011-04-07 02:22:53 +08:00
|
|
|
if (Data.startswith("Fedora release 15"))
|
|
|
|
return Fedora15;
|
|
|
|
else if (Data.startswith("Fedora release 14"))
|
2010-11-08 04:14:31 +08:00
|
|
|
return Fedora14;
|
2011-04-07 02:22:53 +08:00
|
|
|
else if (Data.startswith("Fedora release 13"))
|
2010-11-08 04:14:31 +08:00
|
|
|
return Fedora13;
|
2011-04-07 02:22:53 +08:00
|
|
|
else if (Data.startswith("Fedora release") &&
|
2011-07-23 18:55:15 +08:00
|
|
|
Data.find("Rawhide") != StringRef::npos)
|
2011-04-07 02:22:53 +08:00
|
|
|
return FedoraRawhide;
|
2011-05-22 13:36:06 +08:00
|
|
|
else if (Data.startswith("Red Hat Enterprise Linux") &&
|
2011-07-23 18:55:15 +08:00
|
|
|
Data.find("release 6") != StringRef::npos)
|
2011-05-22 13:36:06 +08:00
|
|
|
return RHEL6;
|
2011-06-03 23:23:24 +08:00
|
|
|
else if ((Data.startswith("Red Hat Enterprise Linux") ||
|
|
|
|
Data.startswith("CentOS")) &&
|
2011-07-23 18:55:15 +08:00
|
|
|
Data.find("release 5") != StringRef::npos)
|
2011-05-22 13:36:06 +08:00
|
|
|
return RHEL5;
|
2011-06-03 23:23:24 +08:00
|
|
|
else if ((Data.startswith("Red Hat Enterprise Linux") ||
|
|
|
|
Data.startswith("CentOS")) &&
|
2011-07-23 18:55:15 +08:00
|
|
|
Data.find("release 4") != StringRef::npos)
|
2011-05-22 13:36:06 +08:00
|
|
|
return RHEL4;
|
2010-11-08 04:14:31 +08:00
|
|
|
return UnknownDistro;
|
|
|
|
}
|
|
|
|
|
2010-12-16 11:28:14 +08:00
|
|
|
if (!llvm::MemoryBuffer::getFile("/etc/debian_version", File)) {
|
2011-07-23 18:55:15 +08:00
|
|
|
StringRef Data = File.get()->getBuffer();
|
2010-11-08 04:14:31 +08:00
|
|
|
if (Data[0] == '5')
|
|
|
|
return DebianLenny;
|
2011-12-29 02:17:14 +08:00
|
|
|
else if (Data.startswith("squeeze/sid") || Data[0] == '6')
|
2010-11-08 04:14:31 +08:00
|
|
|
return DebianSqueeze;
|
2011-12-29 02:17:14 +08:00
|
|
|
else if (Data.startswith("wheezy/sid") || Data[0] == '7')
|
2011-06-03 05:36:53 +08:00
|
|
|
return DebianWheezy;
|
2010-11-08 04:14:31 +08:00
|
|
|
return UnknownDistro;
|
|
|
|
}
|
|
|
|
|
2010-12-16 11:28:14 +08:00
|
|
|
if (!llvm::MemoryBuffer::getFile("/etc/SuSE-release", File)) {
|
2011-07-23 18:55:15 +08:00
|
|
|
StringRef Data = File.get()->getBuffer();
|
2010-11-08 04:14:31 +08:00
|
|
|
if (Data.startswith("openSUSE 11.3"))
|
|
|
|
return OpenSuse11_3;
|
2011-05-19 21:26:33 +08:00
|
|
|
else if (Data.startswith("openSUSE 11.4"))
|
|
|
|
return OpenSuse11_4;
|
|
|
|
else if (Data.startswith("openSUSE 12.1"))
|
|
|
|
return OpenSuse12_1;
|
2010-11-08 04:14:31 +08:00
|
|
|
return UnknownDistro;
|
|
|
|
}
|
|
|
|
|
2011-01-10 10:34:13 +08:00
|
|
|
bool Exists;
|
|
|
|
if (!llvm::sys::fs::exists("/etc/exherbo-release", Exists) && Exists)
|
2010-11-11 10:07:13 +08:00
|
|
|
return Exherbo;
|
|
|
|
|
2011-02-25 14:39:53 +08:00
|
|
|
if (!llvm::sys::fs::exists("/etc/arch-release", Exists) && Exists)
|
|
|
|
return ArchLinux;
|
|
|
|
|
2010-11-08 04:14:31 +08:00
|
|
|
return UnknownDistro;
|
|
|
|
}
|
|
|
|
|
2011-10-31 16:42:24 +08:00
|
|
|
/// \brief Get our best guess at the multiarch triple for a target.
|
|
|
|
///
|
|
|
|
/// Debian-based systems are starting to use a multiarch setup where they use
|
|
|
|
/// a target-triple directory in the library and header search paths.
|
|
|
|
/// Unfortunately, this triple does not align with the vanilla target triple,
|
|
|
|
/// so we provide a rough mapping here.
|
|
|
|
static std::string getMultiarchTriple(const llvm::Triple TargetTriple,
|
|
|
|
StringRef SysRoot) {
|
|
|
|
// For most architectures, just use whatever we have rather than trying to be
|
|
|
|
// clever.
|
|
|
|
switch (TargetTriple.getArch()) {
|
|
|
|
default:
|
|
|
|
return TargetTriple.str();
|
|
|
|
|
|
|
|
// We use the existence of '/lib/<triple>' as a directory to detect some
|
|
|
|
// common linux triples that don't quite match the Clang triple for both
|
2011-10-31 17:06:40 +08:00
|
|
|
// 32-bit and 64-bit targets. Multiarch fixes its install triples to these
|
|
|
|
// regardless of what the actual target triple is.
|
2011-10-31 16:42:24 +08:00
|
|
|
case llvm::Triple::x86:
|
|
|
|
if (llvm::sys::fs::exists(SysRoot + "/lib/i386-linux-gnu"))
|
|
|
|
return "i386-linux-gnu";
|
|
|
|
return TargetTriple.str();
|
|
|
|
case llvm::Triple::x86_64:
|
|
|
|
if (llvm::sys::fs::exists(SysRoot + "/lib/x86_64-linux-gnu"))
|
|
|
|
return "x86_64-linux-gnu";
|
|
|
|
return TargetTriple.str();
|
2011-11-09 03:43:37 +08:00
|
|
|
case llvm::Triple::mips:
|
|
|
|
if (llvm::sys::fs::exists(SysRoot + "/lib/mips-linux-gnu"))
|
|
|
|
return "mips-linux-gnu";
|
|
|
|
return TargetTriple.str();
|
|
|
|
case llvm::Triple::mipsel:
|
|
|
|
if (llvm::sys::fs::exists(SysRoot + "/lib/mipsel-linux-gnu"))
|
|
|
|
return "mipsel-linux-gnu";
|
|
|
|
return TargetTriple.str();
|
2011-10-31 16:42:24 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-01-25 17:12:06 +08:00
|
|
|
Linux::Linux(const Driver &D, const llvm::Triple &Triple)
|
|
|
|
: Generic_ELF(D, Triple) {
|
2012-01-25 04:08:17 +08:00
|
|
|
llvm::Triple::ArchType Arch = Triple.getArch();
|
2011-10-03 14:41:08 +08:00
|
|
|
const std::string &SysRoot = getDriver().SysRoot;
|
2010-11-08 04:14:31 +08:00
|
|
|
|
2011-09-02 00:25:49 +08:00
|
|
|
// OpenSuse stores the linker with the compiler, add that to the search
|
|
|
|
// path.
|
|
|
|
ToolChain::path_list &PPaths = getProgramPaths();
|
2011-11-06 17:21:54 +08:00
|
|
|
PPaths.push_back(Twine(GCCInstallation.getParentLibPath() + "/../" +
|
2012-01-25 03:28:29 +08:00
|
|
|
GCCInstallation.getTriple().str() + "/bin").str());
|
2011-09-02 00:25:49 +08:00
|
|
|
|
|
|
|
Linker = GetProgramPath("ld");
|
2010-11-08 04:14:31 +08:00
|
|
|
|
|
|
|
LinuxDistro Distro = DetectLinuxDistro(Arch);
|
|
|
|
|
2011-05-23 00:45:07 +08:00
|
|
|
if (IsOpenSuse(Distro) || IsUbuntu(Distro)) {
|
2010-11-08 22:48:47 +08:00
|
|
|
ExtraOpts.push_back("-z");
|
|
|
|
ExtraOpts.push_back("relro");
|
|
|
|
}
|
2010-11-08 04:14:31 +08:00
|
|
|
|
2011-03-07 03:11:49 +08:00
|
|
|
if (Arch == llvm::Triple::arm || Arch == llvm::Triple::thumb)
|
2010-11-08 04:14:31 +08:00
|
|
|
ExtraOpts.push_back("-X");
|
|
|
|
|
2011-12-09 12:45:18 +08:00
|
|
|
const bool IsMips = Arch == llvm::Triple::mips ||
|
|
|
|
Arch == llvm::Triple::mipsel ||
|
|
|
|
Arch == llvm::Triple::mips64 ||
|
|
|
|
Arch == llvm::Triple::mips64el;
|
|
|
|
|
2012-01-13 17:30:38 +08:00
|
|
|
const bool IsAndroid = Triple.getEnvironment() == llvm::Triple::ANDROIDEABI;
|
|
|
|
|
2011-12-09 12:45:18 +08:00
|
|
|
// Do not use 'gnu' hash style for Mips targets because .gnu.hash
|
|
|
|
// and the MIPS ABI require .dynsym to be sorted in different ways.
|
|
|
|
// .gnu.hash needs symbols to be grouped by hash code whereas the MIPS
|
|
|
|
// ABI requires a mapping between the GOT and the symbol table.
|
2012-01-13 17:30:38 +08:00
|
|
|
// Android loader does not support .gnu.hash.
|
|
|
|
if (!IsMips && !IsAndroid) {
|
2011-12-09 12:45:18 +08:00
|
|
|
if (IsRedhat(Distro) || IsOpenSuse(Distro) || Distro == UbuntuMaverick ||
|
|
|
|
Distro == UbuntuNatty || Distro == UbuntuOneiric)
|
|
|
|
ExtraOpts.push_back("--hash-style=gnu");
|
|
|
|
|
|
|
|
if (IsDebian(Distro) || IsOpenSuse(Distro) || Distro == UbuntuLucid ||
|
|
|
|
Distro == UbuntuJaunty || Distro == UbuntuKarmic)
|
|
|
|
ExtraOpts.push_back("--hash-style=both");
|
|
|
|
}
|
2010-11-08 04:14:31 +08:00
|
|
|
|
2011-05-22 13:36:06 +08:00
|
|
|
if (IsRedhat(Distro))
|
2010-11-08 04:14:31 +08:00
|
|
|
ExtraOpts.push_back("--no-add-needed");
|
|
|
|
|
2011-06-03 05:36:53 +08:00
|
|
|
if (Distro == DebianSqueeze || Distro == DebianWheezy ||
|
2011-06-03 23:23:24 +08:00
|
|
|
IsOpenSuse(Distro) ||
|
|
|
|
(IsRedhat(Distro) && Distro != RHEL4 && Distro != RHEL5) ||
|
|
|
|
Distro == UbuntuLucid ||
|
2011-06-03 05:36:53 +08:00
|
|
|
Distro == UbuntuMaverick || Distro == UbuntuKarmic ||
|
2011-06-06 00:08:59 +08:00
|
|
|
Distro == UbuntuNatty || Distro == UbuntuOneiric)
|
2010-11-08 04:14:31 +08:00
|
|
|
ExtraOpts.push_back("--build-id");
|
|
|
|
|
2011-05-23 00:45:07 +08:00
|
|
|
if (IsOpenSuse(Distro))
|
2011-05-24 15:51:17 +08:00
|
|
|
ExtraOpts.push_back("--enable-new-dtags");
|
2011-05-23 00:45:07 +08:00
|
|
|
|
Rework the selection of builtin library search paths on Linux to
precisely match the pattern and logic used by the GCC driver on Linux as
of a recent SVN checkout.
This happens to follow a *much* more principled approach. There is
a strict hierarchy of paths examined, first with multilib-suffixing,
second without such suffixing. Any and all of these directories which
exist will be added to the library search path when using GCC.
There were many places where Clang followed different paths, omitted
critical entries, and worst of all (in terms of challenges to debugging)
got the entries in a subtly wrong order.
If this breaks Clang on a distro you use, please let me know, and I'll
work with you to figure out what is needed to work on that distro. I've
checked the behavior of the latest release of Ubuntu, OpenSUSE, Fedora,
and Gentoo. I'll be testing it on those as well as Debian stable and
unstable and ArchLinux. I may even dig out a Slackware install.
No real regression tests yet, those will follow once I add enough
support for sysroot to simulate various distro layouts in the testsuite.
llvm-svn: 140981
2011-10-03 13:28:29 +08:00
|
|
|
// The selection of paths to try here is designed to match the patterns which
|
|
|
|
// the GCC driver itself uses, as this is part of the GCC-compatible driver.
|
|
|
|
// This was determined by running GCC in a fake filesystem, creating all
|
|
|
|
// possible permutations of these directories, and seeing which ones it added
|
|
|
|
// to the link paths.
|
|
|
|
path_list &Paths = getFilePaths();
|
2012-01-25 04:08:17 +08:00
|
|
|
|
|
|
|
const bool Is32Bits = (Arch == llvm::Triple::x86 ||
|
|
|
|
Arch == llvm::Triple::mips ||
|
|
|
|
Arch == llvm::Triple::mipsel ||
|
|
|
|
Arch == llvm::Triple::ppc);
|
|
|
|
|
Rework the selection of builtin library search paths on Linux to
precisely match the pattern and logic used by the GCC driver on Linux as
of a recent SVN checkout.
This happens to follow a *much* more principled approach. There is
a strict hierarchy of paths examined, first with multilib-suffixing,
second without such suffixing. Any and all of these directories which
exist will be added to the library search path when using GCC.
There were many places where Clang followed different paths, omitted
critical entries, and worst of all (in terms of challenges to debugging)
got the entries in a subtly wrong order.
If this breaks Clang on a distro you use, please let me know, and I'll
work with you to figure out what is needed to work on that distro. I've
checked the behavior of the latest release of Ubuntu, OpenSUSE, Fedora,
and Gentoo. I'll be testing it on those as well as Debian stable and
unstable and ArchLinux. I may even dig out a Slackware install.
No real regression tests yet, those will follow once I add enough
support for sysroot to simulate various distro layouts in the testsuite.
llvm-svn: 140981
2011-10-03 13:28:29 +08:00
|
|
|
const std::string Multilib = Is32Bits ? "lib32" : "lib64";
|
2011-10-31 16:42:24 +08:00
|
|
|
const std::string MultiarchTriple = getMultiarchTriple(Triple, SysRoot);
|
2011-02-25 14:39:53 +08:00
|
|
|
|
2011-11-07 07:09:05 +08:00
|
|
|
// Add the multilib suffixed paths where they are available.
|
|
|
|
if (GCCInstallation.isValid()) {
|
2012-01-25 03:28:29 +08:00
|
|
|
const llvm::Triple &GCCTriple = GCCInstallation.getTriple();
|
2012-01-25 04:08:17 +08:00
|
|
|
const std::string &LibPath = GCCInstallation.getParentLibPath();
|
Make a major refactoring to how the GCC installation detection works.
The fundamental shift here is to stop making *any* assumptions about the
*host* triple. Where these assumptions you ask? Why, they were in one of
the two target triples referenced of course. This was the single biggest
place where the previously named "host triple" was actually used as
such. ;] The reason we were reasoning about the host is in order to
detect the use of '-m32' or '-m64' flags to change the target. These
flags shift the default target only slightly, which typically means
a slight deviation from the host. When using these flags, the GCC
installation is under a different triple from the one actually targeted
in the compilation, and we used the host triple to find it.
Too bad that wasn't even correct. Consider an x86 Linux host which has
a PPC64 cross-compiling GCC toolchain installed. This toolchain is also
configured for multiarch compiling and can target PPC32 with eth '-m32'
flag. When targeting 'powerpc-linux-gnu' or some other PPC32 triple, we
have to look for the PPC64 variant of the triple to find the GCC
install, and that triple is neither the host nor target.
The new logic computes the multiarch's alternate triple from the target
triple, and looks under both sides. It also looks more aggressively for
the correct subdirectory of the GCC installation, and exposes the
subdirectory in a nice programmatic way. This '/32' or '/64' suffix is
something we can reuse in many other parts of the toolchain.
An important note -- while this likely fixes a large category of
cross-compile use cases, that's not my primary goal, and I've not done
testing (or added test cases) for scenarios that may now work. If
someone else wants to try more interesting PPC cross compiles, I'd love
to have reports. But my focus is on factoring away the references to the
"host" triple. The refactoring is my goal, and so I'm mostly relying on
the existing (pretty good) test coverage we have here.
Future patches will leverage this new functionality to factor out more
and more of the toolchain's triple manipulation.
llvm-svn: 148935
2012-01-25 15:21:38 +08:00
|
|
|
addPathIfExists((GCCInstallation.getInstallPath() +
|
|
|
|
GCCInstallation.getMultiarchSuffix()),
|
|
|
|
Paths);
|
2012-01-25 03:28:29 +08:00
|
|
|
addPathIfExists(LibPath + "/../" + GCCTriple.str() + "/lib/../" + Multilib,
|
2011-11-07 07:09:05 +08:00
|
|
|
Paths);
|
|
|
|
addPathIfExists(LibPath + "/" + MultiarchTriple, Paths);
|
|
|
|
addPathIfExists(LibPath + "/../" + Multilib, Paths);
|
2010-11-08 04:14:31 +08:00
|
|
|
}
|
2011-11-07 07:09:05 +08:00
|
|
|
addPathIfExists(SysRoot + "/lib/" + MultiarchTriple, Paths);
|
|
|
|
addPathIfExists(SysRoot + "/lib/../" + Multilib, Paths);
|
|
|
|
addPathIfExists(SysRoot + "/usr/lib/" + MultiarchTriple, Paths);
|
|
|
|
addPathIfExists(SysRoot + "/usr/lib/../" + Multilib, Paths);
|
|
|
|
|
|
|
|
// Try walking via the GCC triple path in case of multiarch GCC
|
|
|
|
// installations with strange symlinks.
|
|
|
|
if (GCCInstallation.isValid())
|
2012-01-25 03:28:29 +08:00
|
|
|
addPathIfExists(SysRoot + "/usr/lib/" + GCCInstallation.getTriple().str() +
|
2011-11-07 07:09:05 +08:00
|
|
|
"/../../" + Multilib, Paths);
|
2011-06-03 23:39:42 +08:00
|
|
|
|
2011-10-16 18:54:30 +08:00
|
|
|
// Add the non-multilib suffixed paths (if potentially different).
|
2011-10-04 02:16:54 +08:00
|
|
|
if (GCCInstallation.isValid()) {
|
|
|
|
const std::string &LibPath = GCCInstallation.getParentLibPath();
|
2012-01-25 03:28:29 +08:00
|
|
|
const llvm::Triple &GCCTriple = GCCInstallation.getTriple();
|
Make a major refactoring to how the GCC installation detection works.
The fundamental shift here is to stop making *any* assumptions about the
*host* triple. Where these assumptions you ask? Why, they were in one of
the two target triples referenced of course. This was the single biggest
place where the previously named "host triple" was actually used as
such. ;] The reason we were reasoning about the host is in order to
detect the use of '-m32' or '-m64' flags to change the target. These
flags shift the default target only slightly, which typically means
a slight deviation from the host. When using these flags, the GCC
installation is under a different triple from the one actually targeted
in the compilation, and we used the host triple to find it.
Too bad that wasn't even correct. Consider an x86 Linux host which has
a PPC64 cross-compiling GCC toolchain installed. This toolchain is also
configured for multiarch compiling and can target PPC32 with eth '-m32'
flag. When targeting 'powerpc-linux-gnu' or some other PPC32 triple, we
have to look for the PPC64 variant of the triple to find the GCC
install, and that triple is neither the host nor target.
The new logic computes the multiarch's alternate triple from the target
triple, and looks under both sides. It also looks more aggressively for
the correct subdirectory of the GCC installation, and exposes the
subdirectory in a nice programmatic way. This '/32' or '/64' suffix is
something we can reuse in many other parts of the toolchain.
An important note -- while this likely fixes a large category of
cross-compile use cases, that's not my primary goal, and I've not done
testing (or added test cases) for scenarios that may now work. If
someone else wants to try more interesting PPC cross compiles, I'd love
to have reports. But my focus is on factoring away the references to the
"host" triple. The refactoring is my goal, and so I'm mostly relying on
the existing (pretty good) test coverage we have here.
Future patches will leverage this new functionality to factor out more
and more of the toolchain's triple manipulation.
llvm-svn: 148935
2012-01-25 15:21:38 +08:00
|
|
|
if (!GCCInstallation.getMultiarchSuffix().empty())
|
2011-10-04 02:16:54 +08:00
|
|
|
addPathIfExists(GCCInstallation.getInstallPath(), Paths);
|
2012-01-25 03:28:29 +08:00
|
|
|
addPathIfExists(LibPath + "/../" + GCCTriple.str() + "/lib", Paths);
|
2011-10-04 02:16:54 +08:00
|
|
|
addPathIfExists(LibPath, Paths);
|
Rework the selection of builtin library search paths on Linux to
precisely match the pattern and logic used by the GCC driver on Linux as
of a recent SVN checkout.
This happens to follow a *much* more principled approach. There is
a strict hierarchy of paths examined, first with multilib-suffixing,
second without such suffixing. Any and all of these directories which
exist will be added to the library search path when using GCC.
There were many places where Clang followed different paths, omitted
critical entries, and worst of all (in terms of challenges to debugging)
got the entries in a subtly wrong order.
If this breaks Clang on a distro you use, please let me know, and I'll
work with you to figure out what is needed to work on that distro. I've
checked the behavior of the latest release of Ubuntu, OpenSUSE, Fedora,
and Gentoo. I'll be testing it on those as well as Debian stable and
unstable and ArchLinux. I may even dig out a Slackware install.
No real regression tests yet, those will follow once I add enough
support for sysroot to simulate various distro layouts in the testsuite.
llvm-svn: 140981
2011-10-03 13:28:29 +08:00
|
|
|
}
|
2011-10-03 14:41:08 +08:00
|
|
|
addPathIfExists(SysRoot + "/lib", Paths);
|
|
|
|
addPathIfExists(SysRoot + "/usr/lib", Paths);
|
2010-11-08 04:14:31 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
bool Linux::HasNativeLLVMSupport() const {
|
|
|
|
return true;
|
2009-05-26 15:52:18 +08:00
|
|
|
}
|
|
|
|
|
2011-03-19 04:14:00 +08:00
|
|
|
Tool &Linux::SelectTool(const Compilation &C, const JobAction &JA,
|
|
|
|
const ActionList &Inputs) const {
|
2010-08-10 08:25:48 +08:00
|
|
|
Action::ActionClass Key;
|
|
|
|
if (getDriver().ShouldUseClangCompiler(C, JA, getTriple()))
|
|
|
|
Key = Action::AnalyzeJobClass;
|
|
|
|
else
|
|
|
|
Key = JA.getKind();
|
|
|
|
|
2010-11-08 07:13:01 +08:00
|
|
|
bool UseIntegratedAs = C.getArgs().hasFlag(options::OPT_integrated_as,
|
|
|
|
options::OPT_no_integrated_as,
|
|
|
|
IsIntegratedAssemblerDefault());
|
|
|
|
|
2010-08-10 08:25:48 +08:00
|
|
|
Tool *&T = Tools[Key];
|
|
|
|
if (!T) {
|
|
|
|
switch (Key) {
|
|
|
|
case Action::AssembleJobClass:
|
2010-11-08 07:13:01 +08:00
|
|
|
if (UseIntegratedAs)
|
|
|
|
T = new tools::ClangAs(*this);
|
|
|
|
else
|
|
|
|
T = new tools::linuxtools::Assemble(*this);
|
|
|
|
break;
|
2010-11-08 04:14:31 +08:00
|
|
|
case Action::LinkJobClass:
|
|
|
|
T = new tools::linuxtools::Link(*this); break;
|
2010-08-10 08:25:48 +08:00
|
|
|
default:
|
2011-03-19 04:14:00 +08:00
|
|
|
T = &Generic_GCC::SelectTool(C, JA, Inputs);
|
2010-08-10 08:25:48 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return *T;
|
|
|
|
}
|
|
|
|
|
2011-11-06 04:17:13 +08:00
|
|
|
void Linux::AddClangSystemIncludeArgs(const ArgList &DriverArgs,
|
|
|
|
ArgStringList &CC1Args) const {
|
|
|
|
const Driver &D = getDriver();
|
|
|
|
|
|
|
|
if (DriverArgs.hasArg(options::OPT_nostdinc))
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (!DriverArgs.hasArg(options::OPT_nostdlibinc))
|
|
|
|
addSystemInclude(DriverArgs, CC1Args, D.SysRoot + "/usr/local/include");
|
|
|
|
|
|
|
|
if (!DriverArgs.hasArg(options::OPT_nobuiltininc)) {
|
|
|
|
llvm::sys::Path P(D.ResourceDir);
|
|
|
|
P.appendComponent("include");
|
2011-11-07 17:17:31 +08:00
|
|
|
addSystemInclude(DriverArgs, CC1Args, P.str());
|
2011-11-06 04:17:13 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
if (DriverArgs.hasArg(options::OPT_nostdlibinc))
|
|
|
|
return;
|
|
|
|
|
|
|
|
// Check for configure-time C include directories.
|
|
|
|
StringRef CIncludeDirs(C_INCLUDE_DIRS);
|
|
|
|
if (CIncludeDirs != "") {
|
|
|
|
SmallVector<StringRef, 5> dirs;
|
|
|
|
CIncludeDirs.split(dirs, ":");
|
|
|
|
for (SmallVectorImpl<StringRef>::iterator I = dirs.begin(), E = dirs.end();
|
|
|
|
I != E; ++I) {
|
|
|
|
StringRef Prefix = llvm::sys::path::is_absolute(*I) ? D.SysRoot : "";
|
|
|
|
addExternCSystemInclude(DriverArgs, CC1Args, Prefix + *I);
|
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Lacking those, try to detect the correct set of system includes for the
|
|
|
|
// target triple.
|
|
|
|
|
2011-11-06 16:21:07 +08:00
|
|
|
// Implement generic Debian multiarch support.
|
|
|
|
const StringRef X86_64MultiarchIncludeDirs[] = {
|
|
|
|
"/usr/include/x86_64-linux-gnu",
|
|
|
|
|
|
|
|
// FIXME: These are older forms of multiarch. It's not clear that they're
|
|
|
|
// in use in any released version of Debian, so we should consider
|
|
|
|
// removing them.
|
|
|
|
"/usr/include/i686-linux-gnu/64",
|
|
|
|
"/usr/include/i486-linux-gnu/64"
|
|
|
|
};
|
|
|
|
const StringRef X86MultiarchIncludeDirs[] = {
|
|
|
|
"/usr/include/i386-linux-gnu",
|
|
|
|
|
|
|
|
// FIXME: These are older forms of multiarch. It's not clear that they're
|
|
|
|
// in use in any released version of Debian, so we should consider
|
|
|
|
// removing them.
|
|
|
|
"/usr/include/x86_64-linux-gnu/32",
|
|
|
|
"/usr/include/i686-linux-gnu",
|
|
|
|
"/usr/include/i486-linux-gnu"
|
|
|
|
};
|
|
|
|
const StringRef ARMMultiarchIncludeDirs[] = {
|
|
|
|
"/usr/include/arm-linux-gnueabi"
|
|
|
|
};
|
2011-11-11 11:05:19 +08:00
|
|
|
const StringRef MIPSMultiarchIncludeDirs[] = {
|
|
|
|
"/usr/include/mips-linux-gnu"
|
|
|
|
};
|
|
|
|
const StringRef MIPSELMultiarchIncludeDirs[] = {
|
|
|
|
"/usr/include/mipsel-linux-gnu"
|
|
|
|
};
|
2011-11-06 16:21:07 +08:00
|
|
|
ArrayRef<StringRef> MultiarchIncludeDirs;
|
2011-11-06 04:17:13 +08:00
|
|
|
if (getTriple().getArch() == llvm::Triple::x86_64) {
|
2011-11-06 16:21:07 +08:00
|
|
|
MultiarchIncludeDirs = X86_64MultiarchIncludeDirs;
|
2011-11-06 04:17:13 +08:00
|
|
|
} else if (getTriple().getArch() == llvm::Triple::x86) {
|
2011-11-06 16:21:07 +08:00
|
|
|
MultiarchIncludeDirs = X86MultiarchIncludeDirs;
|
2011-11-06 04:17:13 +08:00
|
|
|
} else if (getTriple().getArch() == llvm::Triple::arm) {
|
2011-11-06 16:21:07 +08:00
|
|
|
MultiarchIncludeDirs = ARMMultiarchIncludeDirs;
|
2011-11-11 11:05:19 +08:00
|
|
|
} else if (getTriple().getArch() == llvm::Triple::mips) {
|
|
|
|
MultiarchIncludeDirs = MIPSMultiarchIncludeDirs;
|
|
|
|
} else if (getTriple().getArch() == llvm::Triple::mipsel) {
|
|
|
|
MultiarchIncludeDirs = MIPSELMultiarchIncludeDirs;
|
2011-11-06 16:21:07 +08:00
|
|
|
}
|
|
|
|
for (ArrayRef<StringRef>::iterator I = MultiarchIncludeDirs.begin(),
|
|
|
|
E = MultiarchIncludeDirs.end();
|
|
|
|
I != E; ++I) {
|
2011-11-09 11:46:20 +08:00
|
|
|
if (llvm::sys::fs::exists(D.SysRoot + *I)) {
|
2011-11-06 16:21:07 +08:00
|
|
|
addExternCSystemInclude(DriverArgs, CC1Args, D.SysRoot + *I);
|
|
|
|
break;
|
|
|
|
}
|
2011-11-06 04:17:13 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
if (getTriple().getOS() == llvm::Triple::RTEMS)
|
|
|
|
return;
|
|
|
|
|
2011-11-09 01:19:47 +08:00
|
|
|
// Add an include of '/include' directly. This isn't provided by default by
|
|
|
|
// system GCCs, but is often used with cross-compiling GCCs, and harmless to
|
|
|
|
// add even when Clang is acting as-if it were a system compiler.
|
|
|
|
addExternCSystemInclude(DriverArgs, CC1Args, D.SysRoot + "/include");
|
|
|
|
|
2011-11-06 04:17:13 +08:00
|
|
|
addExternCSystemInclude(DriverArgs, CC1Args, D.SysRoot + "/usr/include");
|
|
|
|
}
|
|
|
|
|
2011-12-18 07:10:01 +08:00
|
|
|
/// \brief Helper to add the thre variant paths for a libstdc++ installation.
|
|
|
|
/*static*/ bool Linux::addLibStdCXXIncludePaths(Twine Base, Twine TargetArchDir,
|
|
|
|
const ArgList &DriverArgs,
|
|
|
|
ArgStringList &CC1Args) {
|
2011-11-06 18:31:01 +08:00
|
|
|
if (!llvm::sys::fs::exists(Base))
|
|
|
|
return false;
|
2011-11-06 04:17:13 +08:00
|
|
|
addSystemInclude(DriverArgs, CC1Args, Base);
|
2011-11-06 18:31:01 +08:00
|
|
|
addSystemInclude(DriverArgs, CC1Args, Base + "/" + TargetArchDir);
|
2011-11-06 04:17:13 +08:00
|
|
|
addSystemInclude(DriverArgs, CC1Args, Base + "/backward");
|
2011-11-06 18:31:01 +08:00
|
|
|
return true;
|
2011-11-06 04:17:13 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void Linux::AddClangCXXStdlibIncludeArgs(const ArgList &DriverArgs,
|
|
|
|
ArgStringList &CC1Args) const {
|
|
|
|
if (DriverArgs.hasArg(options::OPT_nostdlibinc) ||
|
|
|
|
DriverArgs.hasArg(options::OPT_nostdincxx))
|
|
|
|
return;
|
|
|
|
|
2011-11-07 17:01:17 +08:00
|
|
|
// Check if libc++ has been enabled and provide its include paths if so.
|
|
|
|
if (GetCXXStdlibType(DriverArgs) == ToolChain::CST_Libcxx) {
|
|
|
|
// libc++ is always installed at a fixed path on Linux currently.
|
|
|
|
addSystemInclude(DriverArgs, CC1Args,
|
|
|
|
getDriver().SysRoot + "/usr/include/c++/v1");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2011-11-06 18:31:01 +08:00
|
|
|
const llvm::Triple &TargetTriple = getTriple();
|
|
|
|
|
2011-11-06 04:17:13 +08:00
|
|
|
StringRef CxxIncludeRoot(CXX_INCLUDE_ROOT);
|
2011-11-06 18:31:01 +08:00
|
|
|
if (!CxxIncludeRoot.empty()) {
|
2011-11-06 04:17:13 +08:00
|
|
|
StringRef CxxIncludeArch(CXX_INCLUDE_ARCH);
|
2011-11-06 18:31:01 +08:00
|
|
|
if (CxxIncludeArch.empty())
|
|
|
|
CxxIncludeArch = TargetTriple.str();
|
|
|
|
|
|
|
|
addLibStdCXXIncludePaths(
|
|
|
|
CxxIncludeRoot,
|
2011-11-07 07:39:37 +08:00
|
|
|
CxxIncludeArch + (isTarget64Bit() ? CXX_INCLUDE_64BIT_DIR
|
|
|
|
: CXX_INCLUDE_32BIT_DIR),
|
2011-11-06 18:31:01 +08:00
|
|
|
DriverArgs, CC1Args);
|
2011-11-06 04:17:13 +08:00
|
|
|
return;
|
|
|
|
}
|
2011-11-06 18:31:01 +08:00
|
|
|
|
2012-01-25 16:04:13 +08:00
|
|
|
// We need a detected GCC installation on Linux to provide libstdc++'s
|
|
|
|
// headers. We handled the libc++ case above.
|
|
|
|
if (!GCCInstallation.isValid())
|
|
|
|
return;
|
2011-11-06 18:31:01 +08:00
|
|
|
|
|
|
|
// By default, look for the C++ headers in an include directory adjacent to
|
|
|
|
// the lib directory of the GCC installation. Note that this is expect to be
|
|
|
|
// equivalent to '/usr/include/c++/X.Y' in almost all cases.
|
|
|
|
StringRef LibDir = GCCInstallation.getParentLibPath();
|
|
|
|
StringRef InstallDir = GCCInstallation.getInstallPath();
|
|
|
|
StringRef Version = GCCInstallation.getVersion();
|
|
|
|
if (!addLibStdCXXIncludePaths(LibDir + "/../include/c++/" + Version,
|
2012-01-25 16:04:13 +08:00
|
|
|
(GCCInstallation.getTriple().str() +
|
|
|
|
GCCInstallation.getMultiarchSuffix()),
|
2011-11-06 18:31:01 +08:00
|
|
|
DriverArgs, CC1Args)) {
|
|
|
|
// Gentoo is weird and places its headers inside the GCC install, so if the
|
|
|
|
// first attempt to find the headers fails, try this pattern.
|
|
|
|
addLibStdCXXIncludePaths(InstallDir + "/include/g++-v4",
|
2012-01-25 16:04:13 +08:00
|
|
|
(GCCInstallation.getTriple().str() +
|
|
|
|
GCCInstallation.getMultiarchSuffix()),
|
2011-11-06 18:31:01 +08:00
|
|
|
DriverArgs, CC1Args);
|
|
|
|
}
|
2011-11-06 04:17:13 +08:00
|
|
|
}
|
|
|
|
|
2009-05-03 02:28:39 +08:00
|
|
|
/// DragonFly - DragonFly tool chain which can call as(1) and ld(1) directly.
|
|
|
|
|
2012-01-25 17:12:06 +08:00
|
|
|
DragonFly::DragonFly(const Driver &D, const llvm::Triple& Triple)
|
|
|
|
: Generic_ELF(D, Triple) {
|
2009-05-03 02:28:39 +08:00
|
|
|
|
|
|
|
// Path mangling to find libexec
|
2010-08-02 06:29:51 +08:00
|
|
|
getProgramPaths().push_back(getDriver().getInstalledDir());
|
2011-03-02 06:50:47 +08:00
|
|
|
if (getDriver().getInstalledDir() != getDriver().Dir)
|
2010-08-02 06:29:51 +08:00
|
|
|
getProgramPaths().push_back(getDriver().Dir);
|
2009-05-03 02:28:39 +08:00
|
|
|
|
2009-12-22 02:54:17 +08:00
|
|
|
getFilePaths().push_back(getDriver().Dir + "/../lib");
|
2009-05-03 02:28:39 +08:00
|
|
|
getFilePaths().push_back("/usr/lib");
|
|
|
|
getFilePaths().push_back("/usr/lib/gcc41");
|
|
|
|
}
|
|
|
|
|
2011-03-19 04:14:00 +08:00
|
|
|
Tool &DragonFly::SelectTool(const Compilation &C, const JobAction &JA,
|
|
|
|
const ActionList &Inputs) const {
|
2009-05-03 02:28:39 +08:00
|
|
|
Action::ActionClass Key;
|
2009-12-22 02:54:17 +08:00
|
|
|
if (getDriver().ShouldUseClangCompiler(C, JA, getTriple()))
|
2009-05-03 02:28:39 +08:00
|
|
|
Key = Action::AnalyzeJobClass;
|
|
|
|
else
|
|
|
|
Key = JA.getKind();
|
|
|
|
|
|
|
|
Tool *&T = Tools[Key];
|
|
|
|
if (!T) {
|
|
|
|
switch (Key) {
|
|
|
|
case Action::AssembleJobClass:
|
|
|
|
T = new tools::dragonfly::Assemble(*this); break;
|
|
|
|
case Action::LinkJobClass:
|
|
|
|
T = new tools::dragonfly::Link(*this); break;
|
|
|
|
default:
|
2011-03-19 04:14:00 +08:00
|
|
|
T = &Generic_GCC::SelectTool(C, JA, Inputs);
|
2009-05-03 02:28:39 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return *T;
|
|
|
|
}
|