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"
|
2012-12-04 17:13:33 +08:00
|
|
|
#include "clang/Basic/ObjCRuntime.h"
|
|
|
|
#include "clang/Basic/Version.h"
|
2014-06-04 11:28:55 +08:00
|
|
|
#include "clang/Config/config.h" // for GCC_INSTALL_PREFIX
|
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"
|
2009-11-19 12:25:22 +08:00
|
|
|
#include "clang/Driver/Options.h"
|
2013-08-19 17:14:21 +08:00
|
|
|
#include "clang/Driver/SanitizerArgs.h"
|
2012-12-04 17:13:33 +08:00
|
|
|
#include "llvm/ADT/STLExtras.h"
|
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"
|
2013-06-15 01:17:23 +08:00
|
|
|
#include "llvm/Option/Arg.h"
|
|
|
|
#include "llvm/Option/ArgList.h"
|
|
|
|
#include "llvm/Option/OptTable.h"
|
|
|
|
#include "llvm/Option/Option.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"
|
2010-11-30 02:12:39 +08:00
|
|
|
#include "llvm/Support/Path.h"
|
2014-01-07 19:51:46 +08:00
|
|
|
#include "llvm/Support/Program.h"
|
2012-12-04 17:13:33 +08:00
|
|
|
#include "llvm/Support/raw_ostream.h"
|
2009-04-11 05:00:07 +08:00
|
|
|
#include <cstdlib> // ::getenv
|
2014-06-13 01:19:42 +08:00
|
|
|
#include <system_error>
|
2009-04-11 05:00:07 +08:00
|
|
|
|
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;
|
2013-06-15 01:17:23 +08:00
|
|
|
using namespace llvm::opt;
|
2009-03-20 08:20:03 +08:00
|
|
|
|
2014-01-16 16:48:16 +08:00
|
|
|
MachO::MachO(const Driver &D, const llvm::Triple &Triple,
|
|
|
|
const ArgList &Args)
|
|
|
|
: ToolChain(D, Triple, Args) {
|
2014-05-22 21:12:14 +08:00
|
|
|
getProgramPaths().push_back(getDriver().getInstalledDir());
|
|
|
|
if (getDriver().getInstalledDir() != getDriver().Dir)
|
|
|
|
getProgramPaths().push_back(getDriver().Dir);
|
|
|
|
|
|
|
|
// We expect 'as', 'ld', etc. to be adjacent to our install dir.
|
|
|
|
getProgramPaths().push_back(getDriver().getInstalledDir());
|
|
|
|
if (getDriver().getInstalledDir() != getDriver().Dir)
|
|
|
|
getProgramPaths().push_back(getDriver().Dir);
|
2014-01-16 16:48:16 +08:00
|
|
|
}
|
2009-03-20 08:57:52 +08:00
|
|
|
|
2014-01-16 16:48:16 +08:00
|
|
|
/// Darwin - Darwin tool chain for i386 and x86_64.
|
|
|
|
Darwin::Darwin(const Driver & D, const llvm::Triple & Triple,
|
|
|
|
const ArgList & Args)
|
|
|
|
: MachO(D, Triple, Args), TargetInitialized(false) {
|
2012-02-01 05:30:03 +08:00
|
|
|
// Compute the initial Darwin version from the triple
|
|
|
|
unsigned Major, Minor, Micro;
|
2012-02-01 06:43:59 +08:00
|
|
|
if (!Triple.getMacOSXVersion(Major, Minor, Micro))
|
|
|
|
getDriver().Diag(diag::err_drv_invalid_darwin_version) <<
|
|
|
|
Triple.getOSName();
|
|
|
|
llvm::raw_string_ostream(MacosxVersionMin)
|
|
|
|
<< Major << '.' << Minor << '.' << Micro;
|
|
|
|
|
2012-02-01 05:30:03 +08:00
|
|
|
// FIXME: DarwinVersion is only used to find GCC's libexec directory.
|
|
|
|
// It should be removed when we stop supporting that.
|
|
|
|
DarwinVersion[0] = Minor + 4;
|
|
|
|
DarwinVersion[1] = Micro;
|
|
|
|
DarwinVersion[2] = 0;
|
2012-05-10 02:46:30 +08:00
|
|
|
|
|
|
|
// Compute the initial iOS version from the triple
|
2012-05-10 02:51:13 +08:00
|
|
|
Triple.getiOSVersion(Major, Minor, Micro);
|
2012-05-10 02:46:30 +08:00
|
|
|
llvm::raw_string_ostream(iOSVersionMin)
|
|
|
|
<< Major << '.' << Minor << '.' << Micro;
|
2009-09-18 16:15:13 +08:00
|
|
|
}
|
|
|
|
|
2014-01-16 16:48:16 +08:00
|
|
|
types::ID MachO::LookupTypeForExtension(const char *Ext) const {
|
2010-08-02 13:43:56 +08:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2014-01-16 16:48:16 +08:00
|
|
|
bool MachO::HasNativeLLVMSupport() const {
|
2010-09-17 08:24:52 +08:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2011-07-06 08:26:06 +08:00
|
|
|
/// Darwin provides an ARC runtime starting in MacOS X 10.7 and iOS 5.0.
|
2012-06-20 14:18:46 +08:00
|
|
|
ObjCRuntime Darwin::getDefaultObjCRuntime(bool isNonFragile) const {
|
2013-12-12 19:55:52 +08:00
|
|
|
if (isTargetIOSBased())
|
2012-06-20 14:18:46 +08:00
|
|
|
return ObjCRuntime(ObjCRuntime::iOS, TargetVersion);
|
2012-11-09 09:59:30 +08:00
|
|
|
if (isNonFragile)
|
|
|
|
return ObjCRuntime(ObjCRuntime::MacOSX, TargetVersion);
|
|
|
|
return ObjCRuntime(ObjCRuntime::FragileMacOSX, TargetVersion);
|
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 {
|
2013-12-12 19:55:52 +08:00
|
|
|
if (isTargetIOSBased())
|
2011-09-10 04:41:01 +08:00
|
|
|
return !isIPhoneOSVersionLT(3, 2);
|
2013-12-12 19:55:52 +08:00
|
|
|
else {
|
2014-01-16 16:48:16 +08:00
|
|
|
assert(isTargetMacOS() && "unexpected darwin target");
|
|
|
|
return !isMacosxVersionLT(10, 6);
|
2013-12-12 19:55:52 +08:00
|
|
|
}
|
2011-09-10 04:41:01 +08:00
|
|
|
}
|
|
|
|
|
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")
|
2013-03-05 06:37:49 +08:00
|
|
|
.Case("armv6m", "armv6m")
|
2011-10-07 08:37:57 +08:00
|
|
|
.Case("armv5tej", "armv5")
|
|
|
|
.Case("xscale", "xscale")
|
|
|
|
.Case("armv4t", "armv4t")
|
|
|
|
.Case("armv7", "armv7")
|
|
|
|
.Cases("armv7a", "armv7-a", "armv7")
|
|
|
|
.Cases("armv7r", "armv7-r", "armv7")
|
2013-03-05 06:37:49 +08:00
|
|
|
.Cases("armv7em", "armv7e-m", "armv7em")
|
2012-09-30 07:52:50 +08:00
|
|
|
.Cases("armv7k", "armv7-k", "armv7k")
|
2013-03-05 06:37:49 +08:00
|
|
|
.Cases("armv7m", "armv7-m", "armv7m")
|
2012-09-30 07:52:50 +08:00
|
|
|
.Cases("armv7s", "armv7-s", "armv7s")
|
2014-05-18 00:56:41 +08:00
|
|
|
.Default(nullptr);
|
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")
|
2013-03-05 06:37:49 +08:00
|
|
|
.Cases("arm1136j-s", "arm1136jf-s", "arm1176jz-s", "arm1176jzf-s", "armv6")
|
2015-02-18 18:34:48 +08:00
|
|
|
.Cases("sc000", "cortex-m0", "cortex-m0plus", "cortex-m1", "armv6m")
|
2014-11-06 22:59:30 +08:00
|
|
|
.Cases("cortex-a5", "cortex-a7", "cortex-a8", "armv7")
|
2014-10-13 18:22:48 +08:00
|
|
|
.Cases("cortex-a9", "cortex-a12", "cortex-a15", "cortex-a17", "krait", "armv7")
|
2015-02-18 18:34:48 +08:00
|
|
|
.Cases("cortex-r4", "cortex-r5", "cortex-r7", "armv7r")
|
|
|
|
.Cases("sc300", "cortex-m3", "armv7m")
|
2014-10-01 17:03:02 +08:00
|
|
|
.Cases("cortex-m4", "cortex-m7", "armv7em")
|
2012-09-30 07:52:50 +08:00
|
|
|
.Case("swift", "armv7s")
|
2014-05-18 00:56:41 +08:00
|
|
|
.Default(nullptr);
|
2010-01-22 10:04:58 +08:00
|
|
|
}
|
|
|
|
|
2013-12-12 19:55:52 +08:00
|
|
|
static bool isSoftFloatABI(const ArgList &Args) {
|
2014-02-12 11:21:20 +08:00
|
|
|
Arg *A = Args.getLastArg(options::OPT_msoft_float, options::OPT_mhard_float,
|
2013-12-12 19:55:52 +08:00
|
|
|
options::OPT_mfloat_abi_EQ);
|
2014-02-12 11:21:20 +08:00
|
|
|
if (!A)
|
|
|
|
return false;
|
2014-09-30 05:50:34 +08:00
|
|
|
|
2013-12-12 19:55:52 +08:00
|
|
|
return A->getOption().matches(options::OPT_msoft_float) ||
|
|
|
|
(A->getOption().matches(options::OPT_mfloat_abi_EQ) &&
|
|
|
|
A->getValue() == StringRef("soft"));
|
|
|
|
}
|
|
|
|
|
2014-01-16 16:48:16 +08:00
|
|
|
StringRef MachO::getMachOArchName(const ArgList &Args) const {
|
2010-01-22 10:04:58 +08:00
|
|
|
switch (getTriple().getArch()) {
|
|
|
|
default:
|
2014-08-29 05:23:05 +08:00
|
|
|
return getDefaultUniversalArchName();
|
2011-06-03 11:49:51 +08:00
|
|
|
|
2014-07-23 20:32:58 +08:00
|
|
|
case llvm::Triple::aarch64:
|
|
|
|
return "arm64";
|
|
|
|
|
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))
|
2012-11-01 12:30:05 +08:00
|
|
|
if (const char *Arch = GetArmArchForMArch(A->getValue()))
|
2010-01-22 10:04:58 +08:00
|
|
|
return Arch;
|
|
|
|
|
|
|
|
if (const Arg *A = Args.getLastArg(options::OPT_mcpu_EQ))
|
2012-11-01 12:30:05 +08:00
|
|
|
if (const char *Arch = GetArmArchForMCpu(A->getValue()))
|
2010-01-22 10:04:58 +08:00
|
|
|
return Arch;
|
|
|
|
|
|
|
|
return "arm";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-09-05 02:34:51 +08:00
|
|
|
Darwin::~Darwin() {
|
2009-03-20 08:57:52 +08:00
|
|
|
}
|
|
|
|
|
2014-01-16 16:48:16 +08:00
|
|
|
MachO::~MachO() {
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
std::string MachO::ComputeEffectiveClangTriple(const ArgList &Args,
|
|
|
|
types::ID InputType) const {
|
|
|
|
llvm::Triple Triple(ComputeLLVMTriple(Args, InputType));
|
|
|
|
|
|
|
|
return Triple.getTriple();
|
|
|
|
}
|
|
|
|
|
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
|
|
|
|
2014-01-16 16:48:16 +08:00
|
|
|
SmallString<16> Str;
|
|
|
|
Str += isTargetIOSBased() ? "ios" : "macosx";
|
|
|
|
Str += getTargetVersion().getAsString();
|
|
|
|
Triple.setOSName(Str);
|
2010-08-24 06:35:37 +08:00
|
|
|
|
|
|
|
return Triple.getTriple();
|
|
|
|
}
|
|
|
|
|
2011-12-20 10:48:34 +08:00
|
|
|
void Generic_ELF::anchor() {}
|
|
|
|
|
2014-01-16 16:48:16 +08:00
|
|
|
Tool *MachO::getTool(Action::ActionClass AC) const {
|
2013-03-19 04:48:54 +08:00
|
|
|
switch (AC) {
|
2013-03-19 02:50:01 +08:00
|
|
|
case Action::LipoJobClass:
|
2013-03-20 11:05:54 +08:00
|
|
|
if (!Lipo)
|
|
|
|
Lipo.reset(new tools::darwin::Lipo(*this));
|
|
|
|
return Lipo.get();
|
2013-03-19 02:50:01 +08:00
|
|
|
case Action::DsymutilJobClass:
|
2013-03-20 11:05:54 +08:00
|
|
|
if (!Dsymutil)
|
|
|
|
Dsymutil.reset(new tools::darwin::Dsymutil(*this));
|
|
|
|
return Dsymutil.get();
|
2014-02-07 02:53:25 +08:00
|
|
|
case Action::VerifyDebugInfoJobClass:
|
2013-03-20 11:05:54 +08:00
|
|
|
if (!VerifyDebug)
|
|
|
|
VerifyDebug.reset(new tools::darwin::VerifyDebug(*this));
|
|
|
|
return VerifyDebug.get();
|
2013-03-19 08:36:57 +08:00
|
|
|
default:
|
2013-03-20 11:05:54 +08:00
|
|
|
return ToolChain::getTool(AC);
|
2009-03-20 08:57:52 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-01-16 16:48:16 +08:00
|
|
|
Tool *MachO::buildLinker() const {
|
2013-03-20 11:05:54 +08:00
|
|
|
return new tools::darwin::Link(*this);
|
|
|
|
}
|
|
|
|
|
2014-01-16 16:48:16 +08:00
|
|
|
Tool *MachO::buildAssembler() const {
|
2013-03-20 11:05:54 +08:00
|
|
|
return new tools::darwin::Assemble(*this);
|
|
|
|
}
|
2009-09-18 16:15:03 +08:00
|
|
|
|
2013-03-19 02:10:27 +08:00
|
|
|
DarwinClang::DarwinClang(const Driver &D, const llvm::Triple& Triple,
|
|
|
|
const ArgList &Args)
|
2014-01-16 16:48:16 +08:00
|
|
|
: Darwin(D, Triple, Args) {
|
2009-09-18 16:15:13 +08:00
|
|
|
}
|
|
|
|
|
2014-03-29 21:16:12 +08:00
|
|
|
void DarwinClang::addClangWarningOptions(ArgStringList &CC1Args) const {
|
|
|
|
// For iOS, 64-bit, promote certain warnings to errors.
|
|
|
|
if (!isTargetMacOS() && getTriple().isArch64Bit()) {
|
|
|
|
// Always enable -Wdeprecated-objc-isa-usage and promote it
|
|
|
|
// to an error.
|
|
|
|
CC1Args.push_back("-Wdeprecated-objc-isa-usage");
|
|
|
|
CC1Args.push_back("-Werror=deprecated-objc-isa-usage");
|
|
|
|
|
|
|
|
// Also error about implicit function declarations, as that
|
|
|
|
// can impact calling conventions.
|
|
|
|
CC1Args.push_back("-Werror=implicit-function-declaration");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-01-16 16:48:16 +08:00
|
|
|
/// \brief Determine whether Objective-C automated reference counting is
|
|
|
|
/// enabled.
|
|
|
|
static bool isObjCAutoRefCount(const ArgList &Args) {
|
|
|
|
return Args.hasFlag(options::OPT_fobjc_arc, options::OPT_fno_objc_arc, false);
|
|
|
|
}
|
|
|
|
|
2011-06-16 07:02:42 +08:00
|
|
|
void DarwinClang::AddLinkARCArgs(const ArgList &Args,
|
|
|
|
ArgStringList &CmdArgs) const {
|
2014-01-16 16:48:16 +08:00
|
|
|
// Avoid linking compatibility stubs on i386 mac.
|
|
|
|
if (isTargetMacOS() && getArch() == llvm::Triple::x86)
|
|
|
|
return;
|
|
|
|
|
|
|
|
ObjCRuntime runtime = getDefaultObjCRuntime(/*nonfragile*/ true);
|
|
|
|
|
|
|
|
if ((runtime.hasNativeARC() || !isObjCAutoRefCount(Args)) &&
|
|
|
|
runtime.hasSubscripting())
|
|
|
|
return;
|
2011-08-24 01:56:55 +08:00
|
|
|
|
|
|
|
CmdArgs.push_back("-force_load");
|
2013-06-26 10:13:00 +08:00
|
|
|
SmallString<128> P(getDriver().ClangExecutable);
|
|
|
|
llvm::sys::path::remove_filename(P); // 'clang'
|
|
|
|
llvm::sys::path::remove_filename(P); // 'bin'
|
2013-06-29 00:25:46 +08:00
|
|
|
llvm::sys::path::append(P, "lib", "arc", "libarclite_");
|
2011-06-16 07:02:42 +08:00
|
|
|
// Mash in the platform.
|
2011-10-19 01:40:15 +08:00
|
|
|
if (isTargetIOSSimulator())
|
2013-06-26 10:13:00 +08:00
|
|
|
P += "iphonesimulator";
|
2011-10-19 01:40:15 +08:00
|
|
|
else if (isTargetIPhoneOS())
|
2013-06-26 10:13:00 +08:00
|
|
|
P += "iphoneos";
|
2011-06-16 07:02:42 +08:00
|
|
|
else
|
2013-06-26 10:13:00 +08:00
|
|
|
P += "macosx";
|
|
|
|
P += ".a";
|
2011-06-16 07:02:42 +08:00
|
|
|
|
2013-06-26 10:13:00 +08:00
|
|
|
CmdArgs.push_back(Args.MakeArgString(P));
|
2011-06-16 07:02:42 +08:00
|
|
|
}
|
|
|
|
|
2014-01-16 16:48:16 +08:00
|
|
|
void MachO::AddLinkRuntimeLib(const ArgList &Args, ArgStringList &CmdArgs,
|
2014-10-31 08:08:57 +08:00
|
|
|
StringRef DarwinLibName, bool AlwaysLink,
|
2014-11-05 01:35:17 +08:00
|
|
|
bool IsEmbedded, bool AddRPath) const {
|
|
|
|
SmallString<128> Dir(getDriver().ResourceDir);
|
|
|
|
llvm::sys::path::append(Dir, "lib", IsEmbedded ? "macho_embedded" : "darwin");
|
|
|
|
|
|
|
|
SmallString<128> P(Dir);
|
|
|
|
llvm::sys::path::append(P, DarwinLibName);
|
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
|
2012-11-21 22:17:42 +08:00
|
|
|
// not have compiler-rt checked out or integrated into their build (unless
|
|
|
|
// we explicitly force linking with this library).
|
2013-06-25 23:14:22 +08:00
|
|
|
if (AlwaysLink || llvm::sys::fs::exists(P.str()))
|
2011-06-23 01:41:40 +08:00
|
|
|
CmdArgs.push_back(Args.MakeArgString(P.str()));
|
2014-11-05 01:35:17 +08:00
|
|
|
|
|
|
|
// Adding the rpaths might negatively interact when other rpaths are involved,
|
|
|
|
// so we should make sure we add the rpaths last, after all user-specified
|
|
|
|
// rpaths. This is currently true from this place, but we need to be
|
|
|
|
// careful if this function is ever called before user's rpaths are emitted.
|
|
|
|
if (AddRPath) {
|
|
|
|
assert(DarwinLibName.endswith(".dylib") && "must be a dynamic library");
|
|
|
|
|
|
|
|
// Add @executable_path to rpath to support having the dylib copied with
|
|
|
|
// the executable.
|
|
|
|
CmdArgs.push_back("-rpath");
|
|
|
|
CmdArgs.push_back("@executable_path");
|
|
|
|
|
|
|
|
// Add the path to the resource dir to rpath to support using the dylib
|
|
|
|
// from the default location without copying.
|
|
|
|
CmdArgs.push_back("-rpath");
|
|
|
|
CmdArgs.push_back(Args.MakeArgString(Dir.str()));
|
|
|
|
}
|
2011-06-23 01:41:40 +08:00
|
|
|
}
|
|
|
|
|
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)
|
2012-11-01 12:30:05 +08:00
|
|
|
<< Args.getLastArg(options::OPT_rtlib_EQ)->getValue() << "darwin";
|
2011-12-08 07:03:15 +08:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2010-01-22 11:38:14 +08:00
|
|
|
// Darwin doesn't support real static executables, don't link any runtime
|
|
|
|
// libraries with -static.
|
2012-10-16 06:23:53 +08:00
|
|
|
if (Args.hasArg(options::OPT_static) ||
|
|
|
|
Args.hasArg(options::OPT_fapple_kext) ||
|
|
|
|
Args.hasArg(options::OPT_mkernel))
|
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.
|
2014-08-07 11:14:34 +08:00
|
|
|
if (Args.hasFlag(options::OPT_fprofile_arcs, options::OPT_fno_profile_arcs,
|
|
|
|
false) ||
|
2011-11-17 08:36:57 +08:00
|
|
|
Args.hasArg(options::OPT_fprofile_generate) ||
|
2014-01-07 06:27:36 +08:00
|
|
|
Args.hasArg(options::OPT_fprofile_instr_generate) ||
|
2011-11-17 08:36:57 +08:00
|
|
|
Args.hasArg(options::OPT_fcreate_profile) ||
|
|
|
|
Args.hasArg(options::OPT_coverage)) {
|
|
|
|
// Select the appropriate runtime library for the target.
|
2014-03-21 02:40:53 +08:00
|
|
|
if (isTargetIOSBased())
|
2011-11-17 08:36:57 +08:00
|
|
|
AddLinkRuntimeLib(Args, CmdArgs, "libclang_rt.profile_ios.a");
|
2014-03-21 02:40:53 +08:00
|
|
|
else
|
2011-11-17 08:36:57 +08:00
|
|
|
AddLinkRuntimeLib(Args, CmdArgs, "libclang_rt.profile_osx.a");
|
|
|
|
}
|
|
|
|
|
2013-11-02 02:16:25 +08:00
|
|
|
const SanitizerArgs &Sanitize = getSanitizerArgs();
|
2012-11-06 23:09:03 +08:00
|
|
|
|
2012-11-16 20:53:14 +08:00
|
|
|
// Add Ubsan runtime library, if required.
|
|
|
|
if (Sanitize.needsUbsanRt()) {
|
2013-11-02 02:16:25 +08:00
|
|
|
// FIXME: Move this check to SanitizerArgs::filterUnsupportedKinds.
|
2013-12-12 19:55:52 +08:00
|
|
|
if (isTargetIOSBased()) {
|
2012-11-16 20:53:14 +08:00
|
|
|
getDriver().Diag(diag::err_drv_clang_unsupported_per_platform)
|
|
|
|
<< "-fsanitize=undefined";
|
|
|
|
} else {
|
2013-12-12 19:55:52 +08:00
|
|
|
assert(isTargetMacOS() && "unexpected non OS X target");
|
2012-11-21 22:17:42 +08:00
|
|
|
AddLinkRuntimeLib(Args, CmdArgs, "libclang_rt.ubsan_osx.a", true);
|
2012-11-16 20:53:14 +08:00
|
|
|
|
|
|
|
// The Ubsan runtime library requires C++.
|
|
|
|
AddCXXStdlibLibArgs(Args, CmdArgs);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
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.
|
2012-11-06 23:09:03 +08:00
|
|
|
if (Sanitize.needsAsanRt()) {
|
2013-11-02 02:16:25 +08:00
|
|
|
// FIXME: Move this check to SanitizerArgs::filterUnsupportedKinds.
|
2013-12-12 19:55:52 +08:00
|
|
|
if (isTargetIPhoneOS()) {
|
2011-12-02 07:40:18 +08:00
|
|
|
getDriver().Diag(diag::err_drv_clang_unsupported_per_platform)
|
2012-11-06 23:09:03 +08:00
|
|
|
<< "-fsanitize=address";
|
2011-12-02 07:40:18 +08:00
|
|
|
} else {
|
2013-09-20 16:09:51 +08:00
|
|
|
if (!Args.hasArg(options::OPT_dynamiclib) &&
|
|
|
|
!Args.hasArg(options::OPT_bundle)) {
|
2013-03-21 18:49:06 +08:00
|
|
|
// The ASAN runtime library requires C++.
|
|
|
|
AddCXXStdlibLibArgs(Args, CmdArgs);
|
|
|
|
}
|
2013-11-16 00:07:44 +08:00
|
|
|
if (isTargetMacOS()) {
|
|
|
|
AddLinkRuntimeLib(Args, CmdArgs,
|
|
|
|
"libclang_rt.asan_osx_dynamic.dylib",
|
2014-11-05 01:35:17 +08:00
|
|
|
/*AlwaysLink*/ true, /*IsEmbedded*/ false,
|
|
|
|
/*AddRPath*/ true);
|
2013-11-16 00:07:44 +08:00
|
|
|
} else {
|
|
|
|
if (isTargetIOSSimulator()) {
|
|
|
|
AddLinkRuntimeLib(Args, CmdArgs,
|
|
|
|
"libclang_rt.asan_iossim_dynamic.dylib",
|
2014-11-05 01:35:17 +08:00
|
|
|
/*AlwaysLink*/ true, /*IsEmbedded*/ false,
|
|
|
|
/*AddRPath*/ true);
|
2013-11-16 00:07:44 +08:00
|
|
|
}
|
|
|
|
}
|
2011-12-02 07:40:18 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
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.
|
2013-12-12 19:55:52 +08:00
|
|
|
if (isTargetIOSBased()) {
|
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+
|
2014-03-29 23:09:45 +08:00
|
|
|
if (isIPhoneOSVersionLT(5, 0) && !isTargetIOSSimulator() &&
|
2014-07-23 20:32:58 +08:00
|
|
|
getTriple().getArch() != llvm::Triple::aarch64)
|
2011-10-08 01:54:41 +08:00
|
|
|
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 {
|
2013-12-12 19:55:52 +08:00
|
|
|
assert(isTargetMacOS() && "unexpected non MacOS platform");
|
2010-01-22 11:38:14 +08:00
|
|
|
// 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
|
|
|
}
|
|
|
|
|
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
|
|
|
|
2012-08-18 02:43:50 +08:00
|
|
|
// Support allowing the SDKROOT environment variable used by xcrun and other
|
|
|
|
// Xcode tools to define the default sysroot, by making it the default for
|
|
|
|
// isysroot.
|
2012-12-20 07:41:50 +08:00
|
|
|
if (const Arg *A = Args.getLastArg(options::OPT_isysroot)) {
|
|
|
|
// Warn if the path does not exist.
|
2013-06-25 23:14:22 +08:00
|
|
|
if (!llvm::sys::fs::exists(A->getValue()))
|
2012-12-20 07:41:50 +08:00
|
|
|
getDriver().Diag(clang::diag::warn_missing_sysroot) << A->getValue();
|
|
|
|
} else {
|
2012-08-18 02:43:50 +08:00
|
|
|
if (char *env = ::getenv("SDKROOT")) {
|
2013-01-16 04:33:56 +08:00
|
|
|
// We only use this value as the default if it is an absolute path,
|
|
|
|
// exists, and it is not the root path.
|
|
|
|
if (llvm::sys::path::is_absolute(env) && llvm::sys::fs::exists(env) &&
|
|
|
|
StringRef(env) != "/") {
|
2012-08-18 02:43:50 +08:00
|
|
|
Args.append(Args.MakeSeparateArg(
|
2014-05-18 00:56:41 +08:00
|
|
|
nullptr, Opts.getOption(options::OPT_isysroot), env));
|
2012-08-18 02:43:50 +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);
|
2012-01-11 10:41:15 +08:00
|
|
|
|
2014-10-11 07:10:10 +08:00
|
|
|
if (OSXVersion && iOSVersion) {
|
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)
|
2014-10-11 07:10:10 +08:00
|
|
|
<< iOSVersion->getAsString(Args);
|
|
|
|
iOSVersion = nullptr;
|
|
|
|
} else if (!OSXVersion && !iOSVersion) {
|
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;
|
|
|
|
if (char *env = ::getenv("MACOSX_DEPLOYMENT_TARGET"))
|
|
|
|
OSXTarget = env;
|
|
|
|
if (char *env = ::getenv("IPHONEOS_DEPLOYMENT_TARGET"))
|
|
|
|
iOSTarget = env;
|
|
|
|
|
2015-01-15 02:22:29 +08:00
|
|
|
// If no '-miphoneos-version-min' specified on the command line and
|
|
|
|
// IPHONEOS_DEPLOYMENT_TARGET is not defined, see if we can set the default
|
|
|
|
// based on -isysroot.
|
|
|
|
if (iOSTarget.empty()) {
|
2011-09-01 04:56:25 +08:00
|
|
|
if (const Arg *A = Args.getLastArg(options::OPT_isysroot)) {
|
2015-01-15 02:22:29 +08:00
|
|
|
StringRef first, second;
|
2012-11-01 12:30:05 +08:00
|
|
|
StringRef isysroot = A->getValue();
|
2015-01-15 02:22:29 +08:00
|
|
|
std::tie(first, second) = isysroot.split(StringRef("SDKs/iPhoneOS"));
|
|
|
|
if (second != "")
|
|
|
|
iOSTarget = second.substr(0,3);
|
2011-09-01 04:56:25 +08:00
|
|
|
}
|
|
|
|
}
|
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.
|
2014-01-16 16:48:16 +08:00
|
|
|
StringRef MachOArchName = getMachOArchName(Args);
|
2012-05-10 02:55:57 +08:00
|
|
|
if (OSXTarget.empty() && iOSTarget.empty() &&
|
2014-03-29 23:09:45 +08:00
|
|
|
(MachOArchName == "armv7" || MachOArchName == "armv7s" ||
|
|
|
|
MachOArchName == "arm64"))
|
2012-05-10 02:09:58 +08:00
|
|
|
iOSTarget = iOSVersionMin;
|
2011-09-28 08:46:32 +08:00
|
|
|
|
2011-04-30 12:15:58 +08:00
|
|
|
// 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 ||
|
2014-05-24 20:52:07 +08:00
|
|
|
getTriple().getArch() == llvm::Triple::aarch64 ||
|
2010-02-03 01:31:12 +08:00
|
|
|
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()) {
|
2012-10-20 06:36:40 +08:00
|
|
|
const Option O = Opts.getOption(options::OPT_mmacosx_version_min_EQ);
|
2014-05-18 00:56:41 +08:00
|
|
|
OSXVersion = Args.MakeJoinedArg(nullptr, O, OSXTarget);
|
2010-07-20 01:11:36 +08:00
|
|
|
Args.append(OSXVersion);
|
2011-09-01 04:56:25 +08:00
|
|
|
} else if (!iOSTarget.empty()) {
|
2012-10-20 06:36:40 +08:00
|
|
|
const Option O = Opts.getOption(options::OPT_miphoneos_version_min_EQ);
|
2014-05-18 00:56:41 +08:00
|
|
|
iOSVersion = Args.MakeJoinedArg(nullptr, O, iOSTarget);
|
2011-04-30 12:15:58 +08:00
|
|
|
Args.append(iOSVersion);
|
2014-01-16 16:48:16 +08:00
|
|
|
} else if (MachOArchName != "armv6m" && MachOArchName != "armv7m" &&
|
|
|
|
MachOArchName != "armv7em") {
|
2010-07-16 00:18:06 +08:00
|
|
|
// Otherwise, assume we are targeting OS X.
|
2012-10-20 06:36:40 +08:00
|
|
|
const Option O = Opts.getOption(options::OPT_mmacosx_version_min_EQ);
|
2014-05-18 00:56:41 +08:00
|
|
|
OSXVersion = Args.MakeJoinedArg(nullptr, O, MacosxVersionMin);
|
2010-07-20 01:11:36 +08:00
|
|
|
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
|
|
|
|
2013-12-12 19:55:52 +08:00
|
|
|
DarwinPlatformKind Platform;
|
|
|
|
if (OSXVersion)
|
|
|
|
Platform = MacOS;
|
|
|
|
else if (iOSVersion)
|
|
|
|
Platform = IPhoneOS;
|
|
|
|
else
|
2014-01-16 16:48:16 +08:00
|
|
|
llvm_unreachable("Unable to infer Darwin variant");
|
2013-12-12 19:55:52 +08:00
|
|
|
|
2010-01-27 08:56:25 +08:00
|
|
|
// Set the tool chain target information.
|
|
|
|
unsigned Major, Minor, Micro;
|
|
|
|
bool HadExtra;
|
2013-12-12 19:55:52 +08:00
|
|
|
if (Platform == MacOS) {
|
2014-10-11 07:10:10 +08:00
|
|
|
assert(!iOSVersion && "Unknown target platform!");
|
2012-11-01 12:30:05 +08:00
|
|
|
if (!Driver::GetReleaseVersion(OSXVersion->getValue(), Major, Minor,
|
2010-01-27 08:56:25 +08:00
|
|
|
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);
|
2014-10-11 07:10:10 +08:00
|
|
|
} else if (Platform == IPhoneOS) {
|
|
|
|
assert(iOSVersion && "Unknown target platform!");
|
|
|
|
if (!Driver::GetReleaseVersion(iOSVersion->getValue(), Major, Minor,
|
2012-01-11 10:41:15 +08:00
|
|
|
Micro, HadExtra) || HadExtra ||
|
|
|
|
Major >= 10 || Minor >= 100 || Micro >= 100)
|
|
|
|
getDriver().Diag(diag::err_drv_invalid_version_number)
|
2014-10-11 07:10:10 +08:00
|
|
|
<< iOSVersion->getAsString(Args);
|
2014-01-16 16:48:16 +08:00
|
|
|
} else
|
|
|
|
llvm_unreachable("unknown kind of Darwin platform");
|
2011-04-30 12:15:58 +08:00
|
|
|
|
2014-10-11 07:10:10 +08:00
|
|
|
// Recognize iOS targets with an x86 architecture as the iOS simulator.
|
2011-04-30 12:18:16 +08:00
|
|
|
if (iOSVersion && (getTriple().getArch() == llvm::Triple::x86 ||
|
|
|
|
getTriple().getArch() == llvm::Triple::x86_64))
|
2013-12-12 19:55:52 +08:00
|
|
|
Platform = IPhoneOSSimulator;
|
2011-04-30 12:18:16 +08:00
|
|
|
|
2013-12-12 19:55:52 +08:00
|
|
|
setTarget(Platform, Major, Minor, Micro);
|
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.
|
|
|
|
if (const Arg *A = Args.getLastArg(options::OPT_isysroot)) {
|
2013-06-26 10:13:00 +08:00
|
|
|
SmallString<128> P(A->getValue());
|
2013-06-29 00:25:46 +08:00
|
|
|
llvm::sys::path::append(P, "usr", "lib", "libstdc++.dylib");
|
2010-09-17 09:16:06 +08:00
|
|
|
|
2013-06-25 23:14:22 +08:00
|
|
|
if (!llvm::sys::fs::exists(P.str())) {
|
2013-06-26 10:13:00 +08:00
|
|
|
llvm::sys::path::remove_filename(P);
|
|
|
|
llvm::sys::path::append(P, "libstdc++.6.dylib");
|
2013-06-25 23:14:22 +08:00
|
|
|
if (llvm::sys::fs::exists(P.str())) {
|
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.
|
2013-06-25 23:14:22 +08:00
|
|
|
if (!llvm::sys::fs::exists("/usr/lib/libstdc++.dylib") &&
|
|
|
|
llvm::sys::fs::exists("/usr/lib/libstdc++.6.dylib")) {
|
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).
|
|
|
|
|
2013-06-26 10:13:00 +08:00
|
|
|
SmallString<128> P(getDriver().ResourceDir);
|
2013-06-29 00:25:46 +08:00
|
|
|
llvm::sys::path::append(P, "lib", "darwin");
|
2012-10-16 06:23:53 +08:00
|
|
|
|
|
|
|
// Use the newer cc_kext for iOS ARM after 6.0.
|
|
|
|
if (!isTargetIPhoneOS() || isTargetIOSSimulator() ||
|
2014-05-24 20:52:07 +08:00
|
|
|
getTriple().getArch() == llvm::Triple::aarch64 ||
|
2012-10-16 06:23:53 +08:00
|
|
|
!isIPhoneOSVersionLT(6, 0)) {
|
2013-06-26 10:13:00 +08:00
|
|
|
llvm::sys::path::append(P, "libclang_rt.cc_kext.a");
|
2012-10-16 06:23:53 +08:00
|
|
|
} else {
|
2013-06-26 10:13:00 +08:00
|
|
|
llvm::sys::path::append(P, "libclang_rt.cc_kext_ios5.a");
|
2012-10-16 06:23:53 +08:00
|
|
|
}
|
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.
|
2013-06-25 23:14:22 +08:00
|
|
|
if (llvm::sys::fs::exists(P.str()))
|
2010-09-18 02:39:08 +08:00
|
|
|
CmdArgs.push_back(Args.MakeArgString(P.str()));
|
|
|
|
}
|
|
|
|
|
2014-01-16 16:48:16 +08:00
|
|
|
DerivedArgList *MachO::TranslateArgs(const DerivedArgList &Args,
|
|
|
|
const char *BoundArch) const {
|
2010-07-20 01:11:33 +08:00
|
|
|
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
|
|
|
|
2014-05-09 03:32:46 +08:00
|
|
|
for (Arg *A : Args) {
|
2009-03-25 14:12:34 +08:00
|
|
|
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.
|
2012-10-07 12:44:33 +08:00
|
|
|
llvm::Triple::ArchType XarchArch =
|
2014-01-16 16:48:16 +08:00
|
|
|
tools::darwin::getArchTypeForMachOArchName(A->getValue(0));
|
2012-10-07 12:44:33 +08:00
|
|
|
if (!(XarchArch == getArch() ||
|
|
|
|
(BoundArch && XarchArch ==
|
2014-01-16 16:48:16 +08:00
|
|
|
tools::darwin::getArchTypeForMachOArchName(BoundArch))))
|
2009-03-25 14:12:34 +08:00
|
|
|
continue;
|
|
|
|
|
2011-02-19 13:33:51 +08:00
|
|
|
Arg *OriginalArg = A;
|
2012-11-01 12:30:05 +08:00
|
|
|
unsigned Index = Args.getBaseArgs().MakeIndex(A->getValue(1));
|
2010-06-15 05:23:08 +08:00
|
|
|
unsigned Prev = Index;
|
2014-05-12 01:27:13 +08:00
|
|
|
std::unique_ptr<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;
|
2012-10-20 06:37:06 +08:00
|
|
|
} else if (XarchArg->getOption().hasFlag(options::DriverOption)) {
|
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);
|
2010-06-15 05:23:08 +08:00
|
|
|
|
2014-05-12 01:27:13 +08:00
|
|
|
A = XarchArg.release();
|
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".
|
2012-10-20 06:37:06 +08:00
|
|
|
if (A->getOption().hasFlag(options::LinkerInput)) {
|
2011-02-19 13:33:51 +08:00
|
|
|
// 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),
|
2012-11-01 12:30:05 +08:00
|
|
|
A->getValue(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),
|
2012-11-01 12:30:05 +08:00
|
|
|
A->getValue());
|
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))
|
2014-05-18 00:56:41 +08:00
|
|
|
DAL->AddJoinedArg(nullptr, 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
|
2012-04-27 22:58:16 +08:00
|
|
|
// how the driver driver works.
|
2009-09-10 06:33:15 +08:00
|
|
|
if (BoundArch) {
|
2011-07-23 18:55:15 +08:00
|
|
|
StringRef Name = BoundArch;
|
2012-10-20 06:36:40 +08:00
|
|
|
const Option MCpu = Opts.getOption(options::OPT_mcpu_EQ);
|
|
|
|
const Option MArch = Opts.getOption(options::OPT_march_EQ);
|
2009-09-10 06:33:15 +08:00
|
|
|
|
|
|
|
// 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")
|
2014-05-18 00:56:41 +08:00
|
|
|
DAL->AddJoinedArg(nullptr, MCpu, "601");
|
2009-09-10 06:33:15 +08:00
|
|
|
else if (Name == "ppc603")
|
2014-05-18 00:56:41 +08:00
|
|
|
DAL->AddJoinedArg(nullptr, MCpu, "603");
|
2009-09-10 06:33:15 +08:00
|
|
|
else if (Name == "ppc604")
|
2014-05-18 00:56:41 +08:00
|
|
|
DAL->AddJoinedArg(nullptr, MCpu, "604");
|
2009-09-10 06:33:15 +08:00
|
|
|
else if (Name == "ppc604e")
|
2014-05-18 00:56:41 +08:00
|
|
|
DAL->AddJoinedArg(nullptr, MCpu, "604e");
|
2009-09-10 06:33:15 +08:00
|
|
|
else if (Name == "ppc750")
|
2014-05-18 00:56:41 +08:00
|
|
|
DAL->AddJoinedArg(nullptr, MCpu, "750");
|
2009-09-10 06:33:15 +08:00
|
|
|
else if (Name == "ppc7400")
|
2014-05-18 00:56:41 +08:00
|
|
|
DAL->AddJoinedArg(nullptr, MCpu, "7400");
|
2009-09-10 06:33:15 +08:00
|
|
|
else if (Name == "ppc7450")
|
2014-05-18 00:56:41 +08:00
|
|
|
DAL->AddJoinedArg(nullptr, MCpu, "7450");
|
2009-09-10 06:33:15 +08:00
|
|
|
else if (Name == "ppc970")
|
2014-05-18 00:56:41 +08:00
|
|
|
DAL->AddJoinedArg(nullptr, MCpu, "970");
|
2009-09-10 06:33:15 +08:00
|
|
|
|
2013-07-26 09:36:11 +08:00
|
|
|
else if (Name == "ppc64" || Name == "ppc64le")
|
2014-05-18 00:56:41 +08:00
|
|
|
DAL->AddFlagArg(nullptr, Opts.getOption(options::OPT_m64));
|
2009-09-10 06:33:15 +08:00
|
|
|
|
|
|
|
else if (Name == "i386")
|
|
|
|
;
|
|
|
|
else if (Name == "i486")
|
2014-05-18 00:56:41 +08:00
|
|
|
DAL->AddJoinedArg(nullptr, MArch, "i486");
|
2009-09-10 06:33:15 +08:00
|
|
|
else if (Name == "i586")
|
2014-05-18 00:56:41 +08:00
|
|
|
DAL->AddJoinedArg(nullptr, MArch, "i586");
|
2009-09-10 06:33:15 +08:00
|
|
|
else if (Name == "i686")
|
2014-05-18 00:56:41 +08:00
|
|
|
DAL->AddJoinedArg(nullptr, MArch, "i686");
|
2009-09-10 06:33:15 +08:00
|
|
|
else if (Name == "pentium")
|
2014-05-18 00:56:41 +08:00
|
|
|
DAL->AddJoinedArg(nullptr, MArch, "pentium");
|
2009-09-10 06:33:15 +08:00
|
|
|
else if (Name == "pentium2")
|
2014-05-18 00:56:41 +08:00
|
|
|
DAL->AddJoinedArg(nullptr, MArch, "pentium2");
|
2009-09-10 06:33:15 +08:00
|
|
|
else if (Name == "pentpro")
|
2014-05-18 00:56:41 +08:00
|
|
|
DAL->AddJoinedArg(nullptr, MArch, "pentiumpro");
|
2009-09-10 06:33:15 +08:00
|
|
|
else if (Name == "pentIIm3")
|
2014-05-18 00:56:41 +08:00
|
|
|
DAL->AddJoinedArg(nullptr, MArch, "pentium2");
|
2009-09-10 06:33:15 +08:00
|
|
|
|
|
|
|
else if (Name == "x86_64")
|
2014-05-18 00:56:41 +08:00
|
|
|
DAL->AddFlagArg(nullptr, Opts.getOption(options::OPT_m64));
|
2013-11-16 08:53:35 +08:00
|
|
|
else if (Name == "x86_64h") {
|
2014-05-18 00:56:41 +08:00
|
|
|
DAL->AddFlagArg(nullptr, Opts.getOption(options::OPT_m64));
|
|
|
|
DAL->AddJoinedArg(nullptr, MArch, "x86_64h");
|
2013-11-16 08:53:35 +08:00
|
|
|
}
|
2009-03-25 14:58:31 +08:00
|
|
|
|
2009-09-10 06:33:15 +08:00
|
|
|
else if (Name == "arm")
|
2014-05-18 00:56:41 +08:00
|
|
|
DAL->AddJoinedArg(nullptr, MArch, "armv4t");
|
2009-09-10 06:33:15 +08:00
|
|
|
else if (Name == "armv4t")
|
2014-05-18 00:56:41 +08:00
|
|
|
DAL->AddJoinedArg(nullptr, MArch, "armv4t");
|
2009-09-10 06:33:15 +08:00
|
|
|
else if (Name == "armv5")
|
2014-05-18 00:56:41 +08:00
|
|
|
DAL->AddJoinedArg(nullptr, MArch, "armv5tej");
|
2009-09-10 06:33:15 +08:00
|
|
|
else if (Name == "xscale")
|
2014-05-18 00:56:41 +08:00
|
|
|
DAL->AddJoinedArg(nullptr, MArch, "xscale");
|
2009-09-10 06:33:15 +08:00
|
|
|
else if (Name == "armv6")
|
2014-05-18 00:56:41 +08:00
|
|
|
DAL->AddJoinedArg(nullptr, MArch, "armv6k");
|
2013-03-05 06:37:49 +08:00
|
|
|
else if (Name == "armv6m")
|
2014-05-18 00:56:41 +08:00
|
|
|
DAL->AddJoinedArg(nullptr, MArch, "armv6m");
|
2009-09-10 06:33:15 +08:00
|
|
|
else if (Name == "armv7")
|
2014-05-18 00:56:41 +08:00
|
|
|
DAL->AddJoinedArg(nullptr, MArch, "armv7a");
|
2013-03-05 06:37:49 +08:00
|
|
|
else if (Name == "armv7em")
|
2014-05-18 00:56:41 +08:00
|
|
|
DAL->AddJoinedArg(nullptr, MArch, "armv7em");
|
2012-09-30 07:52:50 +08:00
|
|
|
else if (Name == "armv7k")
|
2014-05-18 00:56:41 +08:00
|
|
|
DAL->AddJoinedArg(nullptr, MArch, "armv7k");
|
2013-03-05 06:37:49 +08:00
|
|
|
else if (Name == "armv7m")
|
2014-05-18 00:56:41 +08:00
|
|
|
DAL->AddJoinedArg(nullptr, MArch, "armv7m");
|
2012-09-30 07:52:50 +08:00
|
|
|
else if (Name == "armv7s")
|
2014-05-18 00:56:41 +08:00
|
|
|
DAL->AddJoinedArg(nullptr, MArch, "armv7s");
|
2009-09-10 06:33:15 +08:00
|
|
|
}
|
2009-03-25 14:58:31 +08:00
|
|
|
|
2014-01-16 16:48:16 +08:00
|
|
|
return DAL;
|
|
|
|
}
|
|
|
|
|
|
|
|
void MachO::AddLinkRuntimeLibArgs(const llvm::opt::ArgList &Args,
|
|
|
|
llvm::opt::ArgStringList &CmdArgs) const {
|
|
|
|
// Embedded targets are simple at the moment, not supporting sanitizers and
|
|
|
|
// with different libraries for each member of the product { static, PIC } x
|
|
|
|
// { hard-float, soft-float }
|
|
|
|
llvm::SmallString<32> CompilerRT = StringRef("libclang_rt.");
|
|
|
|
CompilerRT +=
|
|
|
|
tools::arm::getARMFloatABI(getDriver(), Args, getTriple()) == "hard"
|
|
|
|
? "hard"
|
|
|
|
: "soft";
|
|
|
|
CompilerRT += Args.hasArg(options::OPT_fPIC) ? "_pic.a" : "_static.a";
|
|
|
|
|
|
|
|
AddLinkRuntimeLib(Args, CmdArgs, CompilerRT, false, true);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
DerivedArgList *Darwin::TranslateArgs(const DerivedArgList &Args,
|
|
|
|
const char *BoundArch) const {
|
|
|
|
// First get the generic Apple args, before moving onto Darwin-specific ones.
|
|
|
|
DerivedArgList *DAL = MachO::TranslateArgs(Args, BoundArch);
|
|
|
|
const OptTable &Opts = getDriver().getOpts();
|
|
|
|
|
2014-02-21 08:20:07 +08:00
|
|
|
// If no architecture is bound, none of the translations here are relevant.
|
|
|
|
if (!BoundArch)
|
|
|
|
return DAL;
|
|
|
|
|
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.
|
2014-02-21 08:20:07 +08:00
|
|
|
AddDeploymentTarget(*DAL);
|
2010-07-20 01:11:36 +08:00
|
|
|
|
2012-10-16 06:23:53 +08:00
|
|
|
// For iOS 6, undo the translation to add -static for -mkernel/-fapple-kext.
|
|
|
|
// FIXME: It would be far better to avoid inserting those -static arguments,
|
|
|
|
// but we can't check the deployment target in the translation code until
|
|
|
|
// it is set here.
|
2014-12-02 08:27:35 +08:00
|
|
|
if (isTargetIOSBased() && !isIPhoneOSVersionLT(6, 0)) {
|
2012-10-16 06:23:53 +08:00
|
|
|
for (ArgList::iterator it = DAL->begin(), ie = DAL->end(); it != ie; ) {
|
|
|
|
Arg *A = *it;
|
|
|
|
++it;
|
|
|
|
if (A->getOption().getID() != options::OPT_mkernel &&
|
|
|
|
A->getOption().getID() != options::OPT_fapple_kext)
|
|
|
|
continue;
|
|
|
|
assert(it != ie && "unexpected argument translation");
|
|
|
|
A = *it;
|
|
|
|
assert(A->getOption().getID() == options::OPT_static &&
|
|
|
|
"missing expected -static argument");
|
|
|
|
it = DAL->getArgs().erase(it);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-11-03 07:19:53 +08:00
|
|
|
// Default to use libc++ on OS X 10.9+ and iOS 7+.
|
|
|
|
if (((isTargetMacOS() && !isMacosxVersionLT(10, 9)) ||
|
2013-12-12 19:55:52 +08:00
|
|
|
(isTargetIOSBased() && !isIPhoneOSVersionLT(7, 0))) &&
|
2013-11-03 07:19:53 +08:00
|
|
|
!Args.getLastArg(options::OPT_stdlib_EQ))
|
2014-05-18 00:56:41 +08:00
|
|
|
DAL->AddJoinedArg(nullptr, Opts.getOption(options::OPT_stdlib_EQ),
|
|
|
|
"libc++");
|
2013-11-03 07:19:53 +08:00
|
|
|
|
2011-10-08 01:54:41 +08:00
|
|
|
// Validate the C++ standard library choice.
|
|
|
|
CXXStdlibType Type = GetCXXStdlibType(*DAL);
|
|
|
|
if (Type == ToolChain::CST_Libcxx) {
|
2012-06-20 14:18:46 +08:00
|
|
|
// Check whether the target provides libc++.
|
|
|
|
StringRef where;
|
|
|
|
|
2013-12-06 00:25:25 +08:00
|
|
|
// Complain about targeting iOS < 5.0 in any way.
|
2013-12-12 19:55:52 +08:00
|
|
|
if (isTargetIOSBased() && isIPhoneOSVersionLT(5, 0))
|
2012-11-09 09:59:30 +08:00
|
|
|
where = "iOS 5.0";
|
2012-06-20 14:18:46 +08:00
|
|
|
|
|
|
|
if (where != StringRef()) {
|
2011-10-08 01:54:41 +08:00
|
|
|
getDriver().Diag(clang::diag::err_drv_invalid_libcxx_deployment)
|
2012-06-20 14:18:46 +08:00
|
|
|
<< where;
|
2011-10-08 01:54:41 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
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
|
|
|
|
2014-01-16 16:48:16 +08:00
|
|
|
bool MachO::IsUnwindTablesDefault() const {
|
2012-10-07 11:23:40 +08:00
|
|
|
return getArch() == llvm::Triple::x86_64;
|
2009-03-20 08:57:52 +08:00
|
|
|
}
|
|
|
|
|
2014-01-16 16:48:16 +08:00
|
|
|
bool MachO::UseDwarfDebugFlags() const {
|
2009-12-18 10:43:17 +08:00
|
|
|
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);
|
|
|
|
}
|
|
|
|
|
2014-01-16 16:48:16 +08:00
|
|
|
bool MachO::isPICDefault() const {
|
Completely re-work how the Clang driver interprets PIC and PIE options.
There were numerous issues here that were all entangled, and so I've
tried to do a general simplification of the logic.
1) The logic was mimicing actual GCC bugs, rather than "features". These
have been fixed in trunk GCC, and this fixes Clang as well. Notably,
the logic was always intended to be last-match-wins like any other
flag.
2) The logic for handling '-mdynamic-no-pic' was preposterously unclear.
It also allowed the use of this flag on non-Darwin platforms where it
has no actual meaning. Now this option is handled directly based on
tests of how llvm-gcc behaves, and it is only supported on Darwin.
3) The APIs for the Driver's ToolChains had the implementation ugliness
of dynamic-no-pic leaking through them. They also had the
implementation details of the LLVM relocation model flag names
leaking through.
4) The actual results of passing these flags was incorrect on Darwin in
many cases. For example, Darwin *always* uses PIC level 2 if it uses
in PIC level, and Darwin *always* uses PIC on 64-bit regardless of
the flags specified, including -fPIE. Darwin never compiles in PIE
mode, but it can *link* in PIE mode.
5) Also, PIC was not always being enabled even when PIE was. This isn't
a supported mode at all and may have caused some fallout in builds
with complex PIC and PIE interactions.
The result is (I hope) cleaner and clearer for readers. I've also left
comments and tests about some of the truly strage behavior that is
observed on Darwin platforms. We have no real testing of Windows
platforms and PIC, but I don't have the tools handy to figure that out.
Hopefully others can beef up our testing here.
Unfortunately, I can't test this for every platform. =/ If folks have
dependencies on these flags that aren't covered by tests, they may
break. I've audited and ensured that all the changes in behavior of the
existing tests are intentional and good. In particular I've tried to
make sure the Darwin behavior (which is more suprising than the Linux
behavior) also matches that of 'gcc' on my mac.
llvm-svn: 168297
2012-11-19 11:52:03 +08:00
|
|
|
return true;
|
2009-03-20 08:57:52 +08:00
|
|
|
}
|
|
|
|
|
2014-01-16 16:48:16 +08:00
|
|
|
bool MachO::isPIEDefault() const {
|
2013-04-09 12:35:11 +08:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2014-01-16 16:48:16 +08:00
|
|
|
bool MachO::isPICDefaultForced() const {
|
2014-03-29 23:09:45 +08:00
|
|
|
return (getArch() == llvm::Triple::x86_64 ||
|
2014-05-24 20:52:07 +08:00
|
|
|
getArch() == llvm::Triple::aarch64);
|
2009-03-20 08:57:52 +08:00
|
|
|
}
|
|
|
|
|
2014-01-16 16:48:16 +08:00
|
|
|
bool MachO::SupportsProfiling() const {
|
2011-03-02 02:49:30 +08:00
|
|
|
// Profiling instrumentation is only supported on x86.
|
2012-10-07 12:44:33 +08:00
|
|
|
return getArch() == llvm::Triple::x86 || getArch() == llvm::Triple::x86_64;
|
2011-03-02 02:49:30 +08:00
|
|
|
}
|
|
|
|
|
2014-01-16 16:48:16 +08:00
|
|
|
void Darwin::addMinVersionArgs(const llvm::opt::ArgList &Args,
|
|
|
|
llvm::opt::ArgStringList &CmdArgs) const {
|
|
|
|
VersionTuple TargetVersion = getTargetVersion();
|
|
|
|
|
2014-10-11 03:38:34 +08:00
|
|
|
if (isTargetIOSSimulator())
|
2014-01-16 16:48:16 +08:00
|
|
|
CmdArgs.push_back("-ios_simulator_version_min");
|
2014-02-02 05:06:21 +08:00
|
|
|
else if (isTargetIOSBased())
|
2014-01-16 16:48:16 +08:00
|
|
|
CmdArgs.push_back("-iphoneos_version_min");
|
|
|
|
else {
|
|
|
|
assert(isTargetMacOS() && "unexpected target");
|
|
|
|
CmdArgs.push_back("-macosx_version_min");
|
|
|
|
}
|
|
|
|
|
|
|
|
CmdArgs.push_back(Args.MakeArgString(TargetVersion.getAsString()));
|
|
|
|
}
|
|
|
|
|
|
|
|
void Darwin::addStartObjectFileArgs(const llvm::opt::ArgList &Args,
|
|
|
|
llvm::opt::ArgStringList &CmdArgs) const {
|
|
|
|
// Derived from startfile spec.
|
|
|
|
if (Args.hasArg(options::OPT_dynamiclib)) {
|
|
|
|
// Derived from darwin_dylib1 spec.
|
|
|
|
if (isTargetIOSSimulator()) {
|
2014-01-21 08:17:10 +08:00
|
|
|
; // iOS simulator does not need dylib1.o.
|
2014-01-16 16:48:16 +08:00
|
|
|
} else if (isTargetIPhoneOS()) {
|
|
|
|
if (isIPhoneOSVersionLT(3, 1))
|
|
|
|
CmdArgs.push_back("-ldylib1.o");
|
|
|
|
} else {
|
|
|
|
if (isMacosxVersionLT(10, 5))
|
|
|
|
CmdArgs.push_back("-ldylib1.o");
|
|
|
|
else if (isMacosxVersionLT(10, 6))
|
|
|
|
CmdArgs.push_back("-ldylib1.10.5.o");
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if (Args.hasArg(options::OPT_bundle)) {
|
|
|
|
if (!Args.hasArg(options::OPT_static)) {
|
|
|
|
// Derived from darwin_bundle1 spec.
|
|
|
|
if (isTargetIOSSimulator()) {
|
2014-01-21 08:17:10 +08:00
|
|
|
; // iOS simulator does not need bundle1.o.
|
2014-01-16 16:48:16 +08:00
|
|
|
} else if (isTargetIPhoneOS()) {
|
|
|
|
if (isIPhoneOSVersionLT(3, 1))
|
|
|
|
CmdArgs.push_back("-lbundle1.o");
|
|
|
|
} else {
|
|
|
|
if (isMacosxVersionLT(10, 6))
|
|
|
|
CmdArgs.push_back("-lbundle1.o");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if (Args.hasArg(options::OPT_pg) && SupportsProfiling()) {
|
|
|
|
if (Args.hasArg(options::OPT_static) ||
|
|
|
|
Args.hasArg(options::OPT_object) ||
|
|
|
|
Args.hasArg(options::OPT_preload)) {
|
|
|
|
CmdArgs.push_back("-lgcrt0.o");
|
|
|
|
} else {
|
|
|
|
CmdArgs.push_back("-lgcrt1.o");
|
|
|
|
|
|
|
|
// darwin_crt2 spec is empty.
|
|
|
|
}
|
|
|
|
// By default on OS X 10.8 and later, we don't link with a crt1.o
|
|
|
|
// file and the linker knows to use _main as the entry point. But,
|
|
|
|
// when compiling with -pg, we need to link with the gcrt1.o file,
|
|
|
|
// so pass the -no_new_main option to tell the linker to use the
|
|
|
|
// "start" symbol as the entry point.
|
|
|
|
if (isTargetMacOS() && !isMacosxVersionLT(10, 8))
|
|
|
|
CmdArgs.push_back("-no_new_main");
|
|
|
|
} else {
|
|
|
|
if (Args.hasArg(options::OPT_static) ||
|
|
|
|
Args.hasArg(options::OPT_object) ||
|
|
|
|
Args.hasArg(options::OPT_preload)) {
|
|
|
|
CmdArgs.push_back("-lcrt0.o");
|
|
|
|
} else {
|
|
|
|
// Derived from darwin_crt1 spec.
|
|
|
|
if (isTargetIOSSimulator()) {
|
2014-01-21 08:17:10 +08:00
|
|
|
; // iOS simulator does not need crt1.o.
|
2014-01-16 16:48:16 +08:00
|
|
|
} else if (isTargetIPhoneOS()) {
|
2014-07-23 20:32:58 +08:00
|
|
|
if (getArch() == llvm::Triple::aarch64)
|
2014-03-29 23:09:45 +08:00
|
|
|
; // iOS does not need any crt1 files for arm64
|
|
|
|
else if (isIPhoneOSVersionLT(3, 1))
|
2014-01-16 16:48:16 +08:00
|
|
|
CmdArgs.push_back("-lcrt1.o");
|
|
|
|
else if (isIPhoneOSVersionLT(6, 0))
|
|
|
|
CmdArgs.push_back("-lcrt1.3.1.o");
|
|
|
|
} else {
|
|
|
|
if (isMacosxVersionLT(10, 5))
|
|
|
|
CmdArgs.push_back("-lcrt1.o");
|
|
|
|
else if (isMacosxVersionLT(10, 6))
|
|
|
|
CmdArgs.push_back("-lcrt1.10.5.o");
|
|
|
|
else if (isMacosxVersionLT(10, 8))
|
|
|
|
CmdArgs.push_back("-lcrt1.10.6.o");
|
|
|
|
|
|
|
|
// darwin_crt2 spec is empty.
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!isTargetIPhoneOS() && Args.hasArg(options::OPT_shared_libgcc) &&
|
|
|
|
isMacosxVersionLT(10, 5)) {
|
|
|
|
const char *Str = Args.MakeArgString(GetFilePath("crt3.o"));
|
|
|
|
CmdArgs.push_back(Str);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-04-11 00:20:23 +08:00
|
|
|
bool Darwin::SupportsObjCGC() const {
|
2013-12-12 19:55:52 +08:00
|
|
|
return isTargetMacOS();
|
2010-04-11 00:20:23 +08:00
|
|
|
}
|
|
|
|
|
2012-08-21 10:47:43 +08:00
|
|
|
void Darwin::CheckObjCARC() const {
|
2013-12-12 19:55:52 +08:00
|
|
|
if (isTargetIOSBased()|| (isTargetMacOS() && !isMacosxVersionLT(10, 6)))
|
2012-08-21 10:47:43 +08:00
|
|
|
return;
|
2012-08-27 09:56:21 +08:00
|
|
|
getDriver().Diag(diag::err_arc_unsupported_on_toolchain);
|
2012-02-29 11:43:52 +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) {
|
2013-08-26 16:59:53 +08:00
|
|
|
const GCCVersion BadVersion = { VersionText.str(), -1, -1, -1, "", "", "" };
|
2011-11-07 07:39:34 +08:00
|
|
|
std::pair<StringRef, StringRef> First = VersionText.split('.');
|
|
|
|
std::pair<StringRef, StringRef> Second = First.second.split('.');
|
|
|
|
|
2013-08-26 16:59:53 +08:00
|
|
|
GCCVersion GoodVersion = { VersionText.str(), -1, -1, -1, "", "", "" };
|
2011-11-07 07:39:34 +08:00
|
|
|
if (First.first.getAsInteger(10, GoodVersion.Major) ||
|
|
|
|
GoodVersion.Major < 0)
|
|
|
|
return BadVersion;
|
2013-08-26 16:59:53 +08:00
|
|
|
GoodVersion.MajorStr = First.first.str();
|
2011-11-07 07:39:34 +08:00
|
|
|
if (Second.first.getAsInteger(10, GoodVersion.Minor) ||
|
|
|
|
GoodVersion.Minor < 0)
|
|
|
|
return BadVersion;
|
2013-08-26 16:59:53 +08:00
|
|
|
GoodVersion.MinorStr = Second.first.str();
|
2011-11-07 07:39:34 +08:00
|
|
|
|
|
|
|
// 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()) {
|
2013-01-11 06:20:02 +08:00
|
|
|
if (size_t EndNumber = PatchText.find_first_not_of("0123456789")) {
|
2011-11-07 07:39:34 +08:00
|
|
|
// Try to parse the number and any suffix.
|
|
|
|
if (PatchText.slice(0, EndNumber).getAsInteger(10, GoodVersion.Patch) ||
|
|
|
|
GoodVersion.Patch < 0)
|
|
|
|
return BadVersion;
|
2013-08-26 16:59:53 +08:00
|
|
|
GoodVersion.PatchSuffix = PatchText.substr(EndNumber);
|
2011-11-07 07:39:34 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return GoodVersion;
|
|
|
|
}
|
|
|
|
|
|
|
|
/// \brief Less-than for GCCVersion, implementing a Strict Weak Ordering.
|
2013-08-10 01:17:48 +08:00
|
|
|
bool Generic_GCC::GCCVersion::isOlderThan(int RHSMajor, int RHSMinor,
|
|
|
|
int RHSPatch,
|
|
|
|
StringRef RHSPatchSuffix) const {
|
|
|
|
if (Major != RHSMajor)
|
|
|
|
return Major < RHSMajor;
|
|
|
|
if (Minor != RHSMinor)
|
|
|
|
return Minor < RHSMinor;
|
|
|
|
if (Patch != RHSPatch) {
|
2012-12-29 20:01:08 +08:00
|
|
|
// Note that versions without a specified patch sort higher than those with
|
|
|
|
// a patch.
|
2013-08-10 01:17:48 +08:00
|
|
|
if (RHSPatch == -1)
|
2012-12-29 20:01:08 +08:00
|
|
|
return true;
|
|
|
|
if (Patch == -1)
|
|
|
|
return false;
|
|
|
|
|
|
|
|
// Otherwise just sort on the patch itself.
|
2013-08-10 01:17:48 +08:00
|
|
|
return Patch < RHSPatch;
|
2012-12-29 20:01:08 +08:00
|
|
|
}
|
2013-08-10 01:17:48 +08:00
|
|
|
if (PatchSuffix != RHSPatchSuffix) {
|
2012-12-29 20:01:08 +08:00
|
|
|
// Sort empty suffixes higher.
|
2013-08-10 01:17:48 +08:00
|
|
|
if (RHSPatchSuffix.empty())
|
2012-12-29 20:01:08 +08:00
|
|
|
return true;
|
|
|
|
if (PatchSuffix.empty())
|
2012-12-29 21:00:47 +08:00
|
|
|
return false;
|
2012-12-29 20:01:08 +08:00
|
|
|
|
|
|
|
// Provide a lexicographic sort to make this a total ordering.
|
2013-08-10 01:17:48 +08:00
|
|
|
return PatchSuffix < RHSPatchSuffix;
|
2012-12-29 20:01:08 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
// The versions are equal.
|
2011-11-07 07:39:34 +08:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2014-02-12 11:21:20 +08:00
|
|
|
static llvm::StringRef getGCCToolchainDir(const ArgList &Args) {
|
2012-02-19 09:38:32 +08:00
|
|
|
const Arg *A = Args.getLastArg(options::OPT_gcc_toolchain);
|
|
|
|
if (A)
|
2012-11-01 12:30:05 +08:00
|
|
|
return A->getValue();
|
2012-02-19 09:38:32 +08:00
|
|
|
return GCC_INSTALL_PREFIX;
|
|
|
|
}
|
|
|
|
|
2013-12-07 02:32:18 +08:00
|
|
|
/// \brief Initialize a GCCInstallationDetector from the driver.
|
2011-11-07 07:39:34 +08:00
|
|
|
///
|
|
|
|
/// This performs all of the autodetection and sets up the various paths.
|
2012-04-17 19:16:26 +08:00
|
|
|
/// Once constructed, a GCCInstallationDetector is essentially 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.
|
2013-12-07 02:32:18 +08:00
|
|
|
void
|
|
|
|
Generic_GCC::GCCInstallationDetector::init(
|
|
|
|
const Driver &D, const llvm::Triple &TargetTriple, const ArgList &Args) {
|
2013-06-22 19:35:51 +08:00
|
|
|
llvm::Triple BiarchVariantTriple =
|
|
|
|
TargetTriple.isArch32Bit() ? TargetTriple.get64BitArchVariant()
|
2012-02-13 10:02:09 +08:00
|
|
|
: TargetTriple.get32BitArchVariant();
|
2011-11-07 07:39:34 +08:00
|
|
|
// The library directories which may contain GCC installations.
|
2013-06-22 19:35:51 +08:00
|
|
|
SmallVector<StringRef, 4> CandidateLibDirs, CandidateBiarchLibDirs;
|
2011-11-07 07:39:34 +08:00
|
|
|
// The compatible GCC triples for this particular architecture.
|
2014-08-12 02:09:28 +08:00
|
|
|
SmallVector<StringRef, 16> CandidateTripleAliases;
|
|
|
|
SmallVector<StringRef, 16> CandidateBiarchTripleAliases;
|
2013-06-22 19:35:51 +08:00
|
|
|
CollectLibDirsAndTriples(TargetTriple, BiarchVariantTriple, CandidateLibDirs,
|
|
|
|
CandidateTripleAliases, CandidateBiarchLibDirs,
|
|
|
|
CandidateBiarchTripleAliases);
|
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());
|
2012-02-03 09:01:20 +08:00
|
|
|
|
2012-02-19 09:38:32 +08:00
|
|
|
StringRef GCCToolchainDir = getGCCToolchainDir(Args);
|
|
|
|
if (GCCToolchainDir != "") {
|
|
|
|
if (GCCToolchainDir.back() == '/')
|
|
|
|
GCCToolchainDir = GCCToolchainDir.drop_back(); // remove the /
|
2012-02-03 09:01:20 +08:00
|
|
|
|
2012-02-19 09:38:32 +08:00
|
|
|
Prefixes.push_back(GCCToolchainDir);
|
2012-02-03 09:01:20 +08:00
|
|
|
} else {
|
2013-08-29 07:17:47 +08:00
|
|
|
// If we have a SysRoot, try that first.
|
|
|
|
if (!D.SysRoot.empty()) {
|
|
|
|
Prefixes.push_back(D.SysRoot);
|
|
|
|
Prefixes.push_back(D.SysRoot + "/usr");
|
|
|
|
}
|
|
|
|
|
|
|
|
// Then look for gcc installed alongside clang.
|
2012-02-03 09:01:20 +08:00
|
|
|
Prefixes.push_back(D.InstalledDir + "/..");
|
2013-08-29 07:17:47 +08:00
|
|
|
|
|
|
|
// And finally in /usr.
|
|
|
|
if (D.SysRoot.empty())
|
|
|
|
Prefixes.push_back("/usr");
|
2012-02-03 09:01:20 +08:00
|
|
|
}
|
2011-11-07 07:39:34 +08:00
|
|
|
|
|
|
|
// 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)
|
2014-02-12 11:21:20 +08:00
|
|
|
ScanLibDirForGCCTriple(TargetTriple, Args, LibDir,
|
2012-10-21 19:44:57 +08:00
|
|
|
CandidateTripleAliases[k]);
|
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
|
|
|
}
|
2013-06-22 19:35:51 +08:00
|
|
|
for (unsigned j = 0, je = CandidateBiarchLibDirs.size(); j < je; ++j) {
|
|
|
|
const std::string LibDir = Prefixes[i] + CandidateBiarchLibDirs[j].str();
|
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 (!llvm::sys::fs::exists(LibDir))
|
|
|
|
continue;
|
2013-06-22 19:35:51 +08:00
|
|
|
for (unsigned k = 0, ke = CandidateBiarchTripleAliases.size(); k < ke;
|
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
|
|
|
++k)
|
2014-02-12 11:21:20 +08:00
|
|
|
ScanLibDirForGCCTriple(TargetTriple, Args, LibDir,
|
2013-06-22 19:35:51 +08:00
|
|
|
CandidateBiarchTripleAliases[k],
|
|
|
|
/*NeedsBiarchSuffix=*/ true);
|
2011-11-07 07:39:34 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-07-31 01:57:09 +08:00
|
|
|
void Generic_GCC::GCCInstallationDetector::print(raw_ostream &OS) const {
|
2014-05-09 03:32:46 +08:00
|
|
|
for (const auto &InstallPath : CandidateGCCInstallPaths)
|
|
|
|
OS << "Found candidate GCC installation: " << InstallPath << "\n";
|
2013-07-31 01:57:09 +08:00
|
|
|
|
2014-02-20 03:06:58 +08:00
|
|
|
if (!GCCInstallPath.empty())
|
|
|
|
OS << "Selected GCC installation: " << GCCInstallPath << "\n";
|
|
|
|
|
2014-05-09 03:32:46 +08:00
|
|
|
for (const auto &Multilib : Multilibs)
|
|
|
|
OS << "Candidate multilib: " << Multilib << "\n";
|
2014-02-20 03:06:58 +08:00
|
|
|
|
|
|
|
if (Multilibs.size() != 0 || !SelectedMultilib.isDefault())
|
|
|
|
OS << "Selected multilib: " << SelectedMultilib << "\n";
|
2014-02-12 11:21:20 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
bool Generic_GCC::GCCInstallationDetector::getBiarchSibling(Multilib &M) const {
|
|
|
|
if (BiarchSibling.hasValue()) {
|
|
|
|
M = BiarchSibling.getValue();
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
2013-07-31 01:57:09 +08:00
|
|
|
}
|
|
|
|
|
2011-11-07 07:39:34 +08:00
|
|
|
/*static*/ void Generic_GCC::GCCInstallationDetector::CollectLibDirsAndTriples(
|
2013-06-22 19:35:51 +08:00
|
|
|
const llvm::Triple &TargetTriple, const llvm::Triple &BiarchTriple,
|
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
|
|
|
SmallVectorImpl<StringRef> &LibDirs,
|
|
|
|
SmallVectorImpl<StringRef> &TripleAliases,
|
2013-06-22 19:35:51 +08:00
|
|
|
SmallVectorImpl<StringRef> &BiarchLibDirs,
|
|
|
|
SmallVectorImpl<StringRef> &BiarchTripleAliases) {
|
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
|
|
|
// 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.
|
2014-05-07 00:58:14 +08:00
|
|
|
static const char *const AArch64LibDirs[] = { "/lib64", "/lib" };
|
2013-06-22 19:35:51 +08:00
|
|
|
static const char *const AArch64Triples[] = { "aarch64-none-linux-gnu",
|
2014-04-23 21:36:23 +08:00
|
|
|
"aarch64-linux-gnu",
|
2014-05-07 00:58:14 +08:00
|
|
|
"aarch64-linux-android",
|
|
|
|
"aarch64-redhat-linux" };
|
2014-03-14 20:15:45 +08:00
|
|
|
static const char *const AArch64beLibDirs[] = { "/lib" };
|
|
|
|
static const char *const AArch64beTriples[] = { "aarch64_be-none-linux-gnu",
|
|
|
|
"aarch64_be-linux-gnu" };
|
2013-01-31 20:13:10 +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
|
|
|
static const char *const ARMLibDirs[] = { "/lib" };
|
2013-06-22 19:35:51 +08:00
|
|
|
static const char *const ARMTriples[] = { "arm-linux-gnueabi",
|
|
|
|
"arm-linux-androideabi" };
|
|
|
|
static const char *const ARMHFTriples[] = { "arm-linux-gnueabihf",
|
|
|
|
"armv7hl-redhat-linux-gnueabi" };
|
2014-03-28 22:40:46 +08:00
|
|
|
static const char *const ARMebLibDirs[] = { "/lib" };
|
|
|
|
static const char *const ARMebTriples[] = { "armeb-linux-gnueabi",
|
|
|
|
"armeb-linux-androideabi" };
|
|
|
|
static const char *const ARMebHFTriples[] = { "armeb-linux-gnueabihf",
|
|
|
|
"armebv7hl-redhat-linux-gnueabi" };
|
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
|
|
|
|
|
|
|
static const char *const X86_64LibDirs[] = { "/lib64", "/lib" };
|
|
|
|
static const char *const X86_64Triples[] = {
|
2013-06-22 19:35:51 +08:00
|
|
|
"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",
|
2014-01-23 17:08:32 +08:00
|
|
|
"x86_64-manbo-linux-gnu", "x86_64-linux-gnu", "x86_64-slackware-linux",
|
2014-07-10 23:27:19 +08:00
|
|
|
"x86_64-linux-android", "x86_64-unknown-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
|
|
|
};
|
2014-07-10 23:27:19 +08:00
|
|
|
static const char *const X32LibDirs[] = { "/libx32" };
|
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
|
|
|
static const char *const X86LibDirs[] = { "/lib32", "/lib" };
|
|
|
|
static const char *const X86Triples[] = {
|
2013-06-22 19:35:51 +08:00
|
|
|
"i686-linux-gnu", "i686-pc-linux-gnu", "i486-linux-gnu", "i386-linux-gnu",
|
|
|
|
"i386-redhat-linux6E", "i686-redhat-linux", "i586-redhat-linux",
|
|
|
|
"i386-redhat-linux", "i586-suse-linux", "i486-slackware-linux",
|
2014-07-19 00:24:57 +08:00
|
|
|
"i686-montavista-linux", "i686-linux-android", "i586-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
|
|
|
};
|
|
|
|
|
|
|
|
static const char *const MIPSLibDirs[] = { "/lib" };
|
2013-10-10 15:57:44 +08:00
|
|
|
static const char *const MIPSTriples[] = { "mips-linux-gnu",
|
2014-07-10 22:40:57 +08:00
|
|
|
"mips-mti-linux-gnu",
|
|
|
|
"mips-img-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
|
|
|
static const char *const MIPSELLibDirs[] = { "/lib" };
|
2013-06-22 19:35:51 +08:00
|
|
|
static const char *const MIPSELTriples[] = { "mipsel-linux-gnu",
|
2014-07-10 22:40:57 +08:00
|
|
|
"mipsel-linux-android",
|
|
|
|
"mips-img-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
|
|
|
|
2012-04-27 03:57:02 +08:00
|
|
|
static const char *const MIPS64LibDirs[] = { "/lib64", "/lib" };
|
2013-10-10 15:57:44 +08:00
|
|
|
static const char *const MIPS64Triples[] = { "mips64-linux-gnu",
|
2014-06-25 03:00:12 +08:00
|
|
|
"mips-mti-linux-gnu",
|
2014-07-10 22:40:57 +08:00
|
|
|
"mips-img-linux-gnu",
|
2014-06-25 03:00:12 +08:00
|
|
|
"mips64-linux-gnuabi64" };
|
2012-04-27 03:57:02 +08:00
|
|
|
static const char *const MIPS64ELLibDirs[] = { "/lib64", "/lib" };
|
2013-10-10 15:57:44 +08:00
|
|
|
static const char *const MIPS64ELTriples[] = { "mips64el-linux-gnu",
|
2014-01-26 00:04:08 +08:00
|
|
|
"mips-mti-linux-gnu",
|
2014-07-10 22:40:57 +08:00
|
|
|
"mips-img-linux-gnu",
|
2014-06-25 03:00:12 +08:00
|
|
|
"mips64el-linux-android",
|
|
|
|
"mips64el-linux-gnuabi64" };
|
2012-04-27 03:57:02 +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
|
|
|
static const char *const PPCLibDirs[] = { "/lib32", "/lib" };
|
|
|
|
static const char *const PPCTriples[] = {
|
2013-06-22 19:35:51 +08:00
|
|
|
"powerpc-linux-gnu", "powerpc-unknown-linux-gnu", "powerpc-linux-gnuspe",
|
|
|
|
"powerpc-suse-linux", "powerpc-montavista-linuxspe"
|
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
|
|
|
};
|
|
|
|
static const char *const PPC64LibDirs[] = { "/lib64", "/lib" };
|
2013-06-22 19:35:51 +08:00
|
|
|
static const char *const PPC64Triples[] = { "powerpc64-linux-gnu",
|
|
|
|
"powerpc64-unknown-linux-gnu",
|
|
|
|
"powerpc64-suse-linux",
|
|
|
|
"ppc64-redhat-linux" };
|
2013-07-26 09:36:11 +08:00
|
|
|
static const char *const PPC64LELibDirs[] = { "/lib64", "/lib" };
|
|
|
|
static const char *const PPC64LETriples[] = { "powerpc64le-linux-gnu",
|
|
|
|
"powerpc64le-unknown-linux-gnu",
|
|
|
|
"powerpc64le-suse-linux",
|
|
|
|
"ppc64le-redhat-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
|
|
|
|
2014-01-10 14:53:02 +08:00
|
|
|
static const char *const SPARCv8LibDirs[] = { "/lib32", "/lib" };
|
|
|
|
static const char *const SPARCv8Triples[] = { "sparc-linux-gnu",
|
|
|
|
"sparcv8-linux-gnu" };
|
|
|
|
static const char *const SPARCv9LibDirs[] = { "/lib64", "/lib" };
|
|
|
|
static const char *const SPARCv9Triples[] = { "sparc64-linux-gnu",
|
|
|
|
"sparcv9-linux-gnu" };
|
|
|
|
|
2013-05-07 00:26:41 +08:00
|
|
|
static const char *const SystemZLibDirs[] = { "/lib64", "/lib" };
|
|
|
|
static const char *const SystemZTriples[] = {
|
2013-06-22 19:35:51 +08:00
|
|
|
"s390x-linux-gnu", "s390x-unknown-linux-gnu", "s390x-ibm-linux-gnu",
|
|
|
|
"s390x-suse-linux", "s390x-redhat-linux"
|
2013-05-07 00:26:41 +08:00
|
|
|
};
|
|
|
|
|
2014-10-18 18:43:51 +08:00
|
|
|
using std::begin;
|
|
|
|
using std::end;
|
|
|
|
|
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
|
|
|
switch (TargetTriple.getArch()) {
|
2013-01-31 20:13:10 +08:00
|
|
|
case llvm::Triple::aarch64:
|
2014-10-18 18:43:51 +08:00
|
|
|
LibDirs.append(begin(AArch64LibDirs), end(AArch64LibDirs));
|
|
|
|
TripleAliases.append(begin(AArch64Triples), end(AArch64Triples));
|
|
|
|
BiarchLibDirs.append(begin(AArch64LibDirs), end(AArch64LibDirs));
|
|
|
|
BiarchTripleAliases.append(begin(AArch64Triples), end(AArch64Triples));
|
2013-01-31 20:13:10 +08:00
|
|
|
break;
|
2014-03-14 20:15:45 +08:00
|
|
|
case llvm::Triple::aarch64_be:
|
2014-10-18 18:43:51 +08:00
|
|
|
LibDirs.append(begin(AArch64beLibDirs), end(AArch64beLibDirs));
|
|
|
|
TripleAliases.append(begin(AArch64beTriples), end(AArch64beTriples));
|
|
|
|
BiarchLibDirs.append(begin(AArch64beLibDirs), end(AArch64beLibDirs));
|
|
|
|
BiarchTripleAliases.append(begin(AArch64beTriples), end(AArch64beTriples));
|
2014-03-14 20:15:45 +08:00
|
|
|
break;
|
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
|
|
|
case llvm::Triple::arm:
|
|
|
|
case llvm::Triple::thumb:
|
2014-10-18 18:43:51 +08:00
|
|
|
LibDirs.append(begin(ARMLibDirs), end(ARMLibDirs));
|
2012-07-31 16:06:29 +08:00
|
|
|
if (TargetTriple.getEnvironment() == llvm::Triple::GNUEABIHF) {
|
2014-10-18 18:43:51 +08:00
|
|
|
TripleAliases.append(begin(ARMHFTriples), end(ARMHFTriples));
|
2012-07-31 16:06:29 +08:00
|
|
|
} else {
|
2014-10-18 18:43:51 +08:00
|
|
|
TripleAliases.append(begin(ARMTriples), end(ARMTriples));
|
2012-07-31 16:06:29 +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
|
|
|
break;
|
2014-03-28 22:40:46 +08:00
|
|
|
case llvm::Triple::armeb:
|
|
|
|
case llvm::Triple::thumbeb:
|
2014-10-18 18:43:51 +08:00
|
|
|
LibDirs.append(begin(ARMebLibDirs), end(ARMebLibDirs));
|
2014-03-28 22:40:46 +08:00
|
|
|
if (TargetTriple.getEnvironment() == llvm::Triple::GNUEABIHF) {
|
2014-10-18 18:43:51 +08:00
|
|
|
TripleAliases.append(begin(ARMebHFTriples), end(ARMebHFTriples));
|
2014-03-28 22:40:46 +08:00
|
|
|
} else {
|
2014-10-18 18:43:51 +08:00
|
|
|
TripleAliases.append(begin(ARMebTriples), end(ARMebTriples));
|
2014-03-28 22:40:46 +08:00
|
|
|
}
|
|
|
|
break;
|
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
|
|
|
case llvm::Triple::x86_64:
|
2014-10-18 18:43:51 +08:00
|
|
|
LibDirs.append(begin(X86_64LibDirs), end(X86_64LibDirs));
|
|
|
|
TripleAliases.append(begin(X86_64Triples), end(X86_64Triples));
|
|
|
|
// x32 is always available when x86_64 is available, so adding it as
|
|
|
|
// secondary arch with x86_64 triples
|
2014-07-10 23:27:19 +08:00
|
|
|
if (TargetTriple.getEnvironment() == llvm::Triple::GNUX32) {
|
2014-10-18 18:43:51 +08:00
|
|
|
BiarchLibDirs.append(begin(X32LibDirs), end(X32LibDirs));
|
|
|
|
BiarchTripleAliases.append(begin(X86_64Triples), end(X86_64Triples));
|
2014-07-10 23:27:19 +08:00
|
|
|
} else {
|
2014-10-18 18:43:51 +08:00
|
|
|
BiarchLibDirs.append(begin(X86LibDirs), end(X86LibDirs));
|
|
|
|
BiarchTripleAliases.append(begin(X86Triples), end(X86Triples));
|
2014-07-10 23:27:19 +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
|
|
|
break;
|
|
|
|
case llvm::Triple::x86:
|
2014-10-18 18:43:51 +08:00
|
|
|
LibDirs.append(begin(X86LibDirs), end(X86LibDirs));
|
|
|
|
TripleAliases.append(begin(X86Triples), end(X86Triples));
|
|
|
|
BiarchLibDirs.append(begin(X86_64LibDirs), end(X86_64LibDirs));
|
|
|
|
BiarchTripleAliases.append(begin(X86_64Triples), end(X86_64Triples));
|
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
|
|
|
break;
|
|
|
|
case llvm::Triple::mips:
|
2014-10-18 18:43:51 +08:00
|
|
|
LibDirs.append(begin(MIPSLibDirs), end(MIPSLibDirs));
|
|
|
|
TripleAliases.append(begin(MIPSTriples), end(MIPSTriples));
|
|
|
|
BiarchLibDirs.append(begin(MIPS64LibDirs), end(MIPS64LibDirs));
|
|
|
|
BiarchTripleAliases.append(begin(MIPS64Triples), end(MIPS64Triples));
|
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
|
|
|
break;
|
|
|
|
case llvm::Triple::mipsel:
|
2014-10-18 18:43:51 +08:00
|
|
|
LibDirs.append(begin(MIPSELLibDirs), end(MIPSELLibDirs));
|
|
|
|
TripleAliases.append(begin(MIPSELTriples), end(MIPSELTriples));
|
|
|
|
TripleAliases.append(begin(MIPSTriples), end(MIPSTriples));
|
|
|
|
BiarchLibDirs.append(begin(MIPS64ELLibDirs), end(MIPS64ELLibDirs));
|
|
|
|
BiarchTripleAliases.append(begin(MIPS64ELTriples), end(MIPS64ELTriples));
|
2012-04-27 03:57:02 +08:00
|
|
|
break;
|
|
|
|
case llvm::Triple::mips64:
|
2014-10-18 18:43:51 +08:00
|
|
|
LibDirs.append(begin(MIPS64LibDirs), end(MIPS64LibDirs));
|
|
|
|
TripleAliases.append(begin(MIPS64Triples), end(MIPS64Triples));
|
|
|
|
BiarchLibDirs.append(begin(MIPSLibDirs), end(MIPSLibDirs));
|
|
|
|
BiarchTripleAliases.append(begin(MIPSTriples), end(MIPSTriples));
|
2012-04-27 03:57:02 +08:00
|
|
|
break;
|
|
|
|
case llvm::Triple::mips64el:
|
2014-10-18 18:43:51 +08:00
|
|
|
LibDirs.append(begin(MIPS64ELLibDirs), end(MIPS64ELLibDirs));
|
|
|
|
TripleAliases.append(begin(MIPS64ELTriples), end(MIPS64ELTriples));
|
|
|
|
BiarchLibDirs.append(begin(MIPSELLibDirs), end(MIPSELLibDirs));
|
|
|
|
BiarchTripleAliases.append(begin(MIPSELTriples), end(MIPSELTriples));
|
|
|
|
BiarchTripleAliases.append(begin(MIPSTriples), end(MIPSTriples));
|
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
|
|
|
break;
|
|
|
|
case llvm::Triple::ppc:
|
2014-10-18 18:43:51 +08:00
|
|
|
LibDirs.append(begin(PPCLibDirs), end(PPCLibDirs));
|
|
|
|
TripleAliases.append(begin(PPCTriples), end(PPCTriples));
|
|
|
|
BiarchLibDirs.append(begin(PPC64LibDirs), end(PPC64LibDirs));
|
|
|
|
BiarchTripleAliases.append(begin(PPC64Triples), end(PPC64Triples));
|
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
|
|
|
break;
|
|
|
|
case llvm::Triple::ppc64:
|
2014-10-18 18:43:51 +08:00
|
|
|
LibDirs.append(begin(PPC64LibDirs), end(PPC64LibDirs));
|
|
|
|
TripleAliases.append(begin(PPC64Triples), end(PPC64Triples));
|
|
|
|
BiarchLibDirs.append(begin(PPCLibDirs), end(PPCLibDirs));
|
|
|
|
BiarchTripleAliases.append(begin(PPCTriples), end(PPCTriples));
|
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
|
|
|
break;
|
2013-07-26 09:36:11 +08:00
|
|
|
case llvm::Triple::ppc64le:
|
2014-10-18 18:43:51 +08:00
|
|
|
LibDirs.append(begin(PPC64LELibDirs), end(PPC64LELibDirs));
|
|
|
|
TripleAliases.append(begin(PPC64LETriples), end(PPC64LETriples));
|
2013-07-26 09:36:11 +08:00
|
|
|
break;
|
2014-01-10 14:53:02 +08:00
|
|
|
case llvm::Triple::sparc:
|
2014-10-18 18:43:51 +08:00
|
|
|
LibDirs.append(begin(SPARCv8LibDirs), end(SPARCv8LibDirs));
|
|
|
|
TripleAliases.append(begin(SPARCv8Triples), end(SPARCv8Triples));
|
|
|
|
BiarchLibDirs.append(begin(SPARCv9LibDirs), end(SPARCv9LibDirs));
|
|
|
|
BiarchTripleAliases.append(begin(SPARCv9Triples), end(SPARCv9Triples));
|
2014-01-10 14:53:02 +08:00
|
|
|
break;
|
|
|
|
case llvm::Triple::sparcv9:
|
2014-10-18 18:43:51 +08:00
|
|
|
LibDirs.append(begin(SPARCv9LibDirs), end(SPARCv9LibDirs));
|
|
|
|
TripleAliases.append(begin(SPARCv9Triples), end(SPARCv9Triples));
|
|
|
|
BiarchLibDirs.append(begin(SPARCv8LibDirs), end(SPARCv8LibDirs));
|
|
|
|
BiarchTripleAliases.append(begin(SPARCv8Triples), end(SPARCv8Triples));
|
2014-01-10 14:53:02 +08:00
|
|
|
break;
|
2013-05-07 00:26:41 +08:00
|
|
|
case llvm::Triple::systemz:
|
2014-10-18 18:43:51 +08:00
|
|
|
LibDirs.append(begin(SystemZLibDirs), end(SystemZLibDirs));
|
|
|
|
TripleAliases.append(begin(SystemZTriples), end(SystemZTriples));
|
2013-05-07 00:26:41 +08:00
|
|
|
break;
|
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
|
|
|
|
|
|
|
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.
|
2013-06-22 19:35:51 +08:00
|
|
|
if (TargetTriple.str() != BiarchTriple.str())
|
|
|
|
BiarchTripleAliases.push_back(BiarchTriple.str());
|
2011-11-07 07:39:34 +08:00
|
|
|
}
|
|
|
|
|
2014-02-12 11:21:20 +08:00
|
|
|
namespace {
|
|
|
|
// Filter to remove Multilibs that don't exist as a suffix to Path
|
2014-02-25 12:21:44 +08:00
|
|
|
class FilterNonExistent : public MultilibSet::FilterCallback {
|
2014-02-12 11:21:20 +08:00
|
|
|
std::string Base;
|
|
|
|
public:
|
2014-02-25 12:21:44 +08:00
|
|
|
FilterNonExistent(std::string Base) : Base(Base) {}
|
2014-03-02 17:32:10 +08:00
|
|
|
bool operator()(const Multilib &M) const override {
|
2014-02-12 11:21:20 +08:00
|
|
|
return !llvm::sys::fs::exists(Base + M.gccSuffix() + "/crtbegin.o");
|
|
|
|
}
|
|
|
|
};
|
|
|
|
} // end anonymous namespace
|
|
|
|
|
|
|
|
static void addMultilibFlag(bool Enabled, const char *const Flag,
|
|
|
|
std::vector<std::string> &Flags) {
|
|
|
|
if (Enabled)
|
|
|
|
Flags.push_back(std::string("+") + Flag);
|
|
|
|
else
|
|
|
|
Flags.push_back(std::string("-") + Flag);
|
|
|
|
}
|
|
|
|
|
2013-04-20 16:15:03 +08:00
|
|
|
static bool isMipsArch(llvm::Triple::ArchType Arch) {
|
2014-02-12 11:21:20 +08:00
|
|
|
return Arch == llvm::Triple::mips || Arch == llvm::Triple::mipsel ||
|
|
|
|
Arch == llvm::Triple::mips64 || Arch == llvm::Triple::mips64el;
|
|
|
|
}
|
|
|
|
|
|
|
|
static bool isMips32(llvm::Triple::ArchType Arch) {
|
|
|
|
return Arch == llvm::Triple::mips || Arch == llvm::Triple::mipsel;
|
|
|
|
}
|
|
|
|
|
|
|
|
static bool isMips64(llvm::Triple::ArchType Arch) {
|
|
|
|
return Arch == llvm::Triple::mips64 || Arch == llvm::Triple::mips64el;
|
|
|
|
}
|
|
|
|
|
|
|
|
static bool isMipsEL(llvm::Triple::ArchType Arch) {
|
|
|
|
return Arch == llvm::Triple::mipsel || Arch == llvm::Triple::mips64el;
|
|
|
|
}
|
|
|
|
|
2013-04-20 16:15:03 +08:00
|
|
|
static bool isMips16(const ArgList &Args) {
|
|
|
|
Arg *A = Args.getLastArg(options::OPT_mips16,
|
|
|
|
options::OPT_mno_mips16);
|
|
|
|
return A && A->getOption().matches(options::OPT_mips16);
|
|
|
|
}
|
|
|
|
|
|
|
|
static bool isMicroMips(const ArgList &Args) {
|
|
|
|
Arg *A = Args.getLastArg(options::OPT_mmicromips,
|
|
|
|
options::OPT_mno_micromips);
|
|
|
|
return A && A->getOption().matches(options::OPT_mmicromips);
|
|
|
|
}
|
|
|
|
|
2014-05-12 15:37:51 +08:00
|
|
|
struct DetectedMultilibs {
|
|
|
|
/// The set of multilibs that the detected installation supports.
|
|
|
|
MultilibSet Multilibs;
|
|
|
|
|
|
|
|
/// The primary multilib appropriate for the given flags.
|
|
|
|
Multilib SelectedMultilib;
|
|
|
|
|
|
|
|
/// On Biarch systems, this corresponds to the default multilib when
|
|
|
|
/// targeting the non-default multilib. Otherwise, it is empty.
|
|
|
|
llvm::Optional<Multilib> BiarchSibling;
|
|
|
|
};
|
|
|
|
|
2014-07-30 17:15:10 +08:00
|
|
|
static Multilib makeMultilib(StringRef commonSuffix) {
|
|
|
|
return Multilib(commonSuffix, commonSuffix, commonSuffix);
|
|
|
|
}
|
|
|
|
|
2014-05-12 15:37:51 +08:00
|
|
|
static bool findMIPSMultilibs(const llvm::Triple &TargetTriple, StringRef Path,
|
|
|
|
const llvm::opt::ArgList &Args,
|
|
|
|
DetectedMultilibs &Result) {
|
2013-10-10 15:57:44 +08:00
|
|
|
// Some MIPS toolchains put libraries and object files compiled
|
|
|
|
// using different options in to the sub-directoris which names
|
|
|
|
// reflects the flags used for compilation. For example sysroot
|
|
|
|
// directory might looks like the following examples:
|
|
|
|
//
|
|
|
|
// /usr
|
|
|
|
// /lib <= crt*.o files compiled with '-mips32'
|
|
|
|
// /mips16
|
|
|
|
// /usr
|
|
|
|
// /lib <= crt*.o files compiled with '-mips16'
|
|
|
|
// /el
|
|
|
|
// /usr
|
|
|
|
// /lib <= crt*.o files compiled with '-mips16 -EL'
|
|
|
|
//
|
|
|
|
// or
|
|
|
|
//
|
|
|
|
// /usr
|
|
|
|
// /lib <= crt*.o files compiled with '-mips32r2'
|
|
|
|
// /mips16
|
|
|
|
// /usr
|
|
|
|
// /lib <= crt*.o files compiled with '-mips32r2 -mips16'
|
|
|
|
// /mips32
|
|
|
|
// /usr
|
|
|
|
// /lib <= crt*.o files compiled with '-mips32'
|
|
|
|
|
2014-02-25 12:21:44 +08:00
|
|
|
FilterNonExistent NonExistent(Path);
|
2014-02-12 11:21:20 +08:00
|
|
|
|
|
|
|
// Check for FSF toolchain multilibs
|
|
|
|
MultilibSet FSFMipsMultilibs;
|
|
|
|
{
|
2014-07-30 17:15:10 +08:00
|
|
|
auto MArchMips32 = makeMultilib("/mips32")
|
2014-07-17 01:34:54 +08:00
|
|
|
.flag("+m32").flag("-m64").flag("-mmicromips").flag("+march=mips32");
|
2014-02-12 11:21:20 +08:00
|
|
|
|
2014-07-30 17:15:10 +08:00
|
|
|
auto MArchMicroMips = makeMultilib("/micromips")
|
2014-02-12 11:21:20 +08:00
|
|
|
.flag("+m32").flag("-m64").flag("+mmicromips");
|
|
|
|
|
2014-07-30 17:15:10 +08:00
|
|
|
auto MArchMips64r2 = makeMultilib("/mips64r2")
|
2014-02-12 11:21:20 +08:00
|
|
|
.flag("-m32").flag("+m64").flag("+march=mips64r2");
|
|
|
|
|
2014-07-30 17:15:10 +08:00
|
|
|
auto MArchMips64 = makeMultilib("/mips64")
|
2014-02-12 11:21:20 +08:00
|
|
|
.flag("-m32").flag("+m64").flag("-march=mips64r2");
|
|
|
|
|
2014-07-30 17:15:10 +08:00
|
|
|
auto MArchDefault = makeMultilib("")
|
2014-07-17 01:34:54 +08:00
|
|
|
.flag("+m32").flag("-m64").flag("-mmicromips").flag("+march=mips32r2");
|
2014-02-12 11:21:20 +08:00
|
|
|
|
2014-07-30 17:15:10 +08:00
|
|
|
auto Mips16 = makeMultilib("/mips16")
|
2014-02-12 11:21:20 +08:00
|
|
|
.flag("+mips16");
|
|
|
|
|
2014-08-13 22:34:14 +08:00
|
|
|
auto UCLibc = makeMultilib("/uclibc")
|
|
|
|
.flag("+muclibc");
|
|
|
|
|
2014-07-30 17:15:10 +08:00
|
|
|
auto MAbi64 = makeMultilib("/64")
|
2014-07-16 20:29:22 +08:00
|
|
|
.flag("+mabi=n64").flag("-mabi=n32").flag("-m32");
|
2014-02-12 11:21:20 +08:00
|
|
|
|
2014-07-30 17:15:10 +08:00
|
|
|
auto BigEndian = makeMultilib("")
|
2014-03-05 02:37:28 +08:00
|
|
|
.flag("+EB").flag("-EL");
|
|
|
|
|
2014-07-30 17:15:10 +08:00
|
|
|
auto LittleEndian = makeMultilib("/el")
|
2014-02-12 11:21:20 +08:00
|
|
|
.flag("+EL").flag("-EB");
|
|
|
|
|
2014-07-30 17:15:10 +08:00
|
|
|
auto SoftFloat = makeMultilib("/sof")
|
2014-02-12 11:21:20 +08:00
|
|
|
.flag("+msoft-float");
|
|
|
|
|
2014-07-30 17:15:10 +08:00
|
|
|
auto Nan2008 = makeMultilib("/nan2008")
|
2014-02-12 11:21:20 +08:00
|
|
|
.flag("+mnan=2008");
|
|
|
|
|
|
|
|
FSFMipsMultilibs = MultilibSet()
|
|
|
|
.Either(MArchMips32, MArchMicroMips,
|
|
|
|
MArchMips64r2, MArchMips64, MArchDefault)
|
2014-08-13 22:34:14 +08:00
|
|
|
.Maybe(UCLibc)
|
2014-02-12 11:21:20 +08:00
|
|
|
.Maybe(Mips16)
|
|
|
|
.FilterOut("/mips64/mips16")
|
|
|
|
.FilterOut("/mips64r2/mips16")
|
|
|
|
.FilterOut("/micromips/mips16")
|
|
|
|
.Maybe(MAbi64)
|
|
|
|
.FilterOut("/micromips/64")
|
|
|
|
.FilterOut("/mips32/64")
|
|
|
|
.FilterOut("^/64")
|
|
|
|
.FilterOut("/mips16/64")
|
2014-03-05 02:37:28 +08:00
|
|
|
.Either(BigEndian, LittleEndian)
|
2014-02-12 11:21:20 +08:00
|
|
|
.Maybe(SoftFloat)
|
|
|
|
.Maybe(Nan2008)
|
|
|
|
.FilterOut(".*sof/nan2008")
|
2014-08-06 13:44:47 +08:00
|
|
|
.FilterOut(NonExistent)
|
|
|
|
.setIncludeDirsCallback([](
|
|
|
|
StringRef InstallDir, StringRef TripleStr, const Multilib &M) {
|
|
|
|
std::vector<std::string> Dirs;
|
|
|
|
Dirs.push_back((InstallDir + "/include").str());
|
2014-08-13 22:34:14 +08:00
|
|
|
std::string SysRootInc = InstallDir.str() + "/../../../../sysroot";
|
|
|
|
if (StringRef(M.includeSuffix()).startswith("/uclibc"))
|
|
|
|
Dirs.push_back(SysRootInc + "/uclibc/usr/include");
|
|
|
|
else
|
|
|
|
Dirs.push_back(SysRootInc + "/usr/include");
|
2014-08-06 13:44:47 +08:00
|
|
|
return Dirs;
|
|
|
|
});
|
2014-02-12 11:21:20 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
// Check for Code Sourcery toolchain multilibs
|
|
|
|
MultilibSet CSMipsMultilibs;
|
|
|
|
{
|
2014-07-30 17:15:10 +08:00
|
|
|
auto MArchMips16 = makeMultilib("/mips16")
|
2014-02-12 11:21:20 +08:00
|
|
|
.flag("+m32").flag("+mips16");
|
|
|
|
|
2014-07-30 17:15:10 +08:00
|
|
|
auto MArchMicroMips = makeMultilib("/micromips")
|
2014-02-12 11:21:20 +08:00
|
|
|
.flag("+m32").flag("+mmicromips");
|
|
|
|
|
2014-07-30 17:15:10 +08:00
|
|
|
auto MArchDefault = makeMultilib("")
|
2014-02-12 11:21:20 +08:00
|
|
|
.flag("-mips16").flag("-mmicromips");
|
|
|
|
|
2014-08-13 22:34:14 +08:00
|
|
|
auto UCLibc = makeMultilib("/uclibc")
|
|
|
|
.flag("+muclibc");
|
|
|
|
|
2014-07-30 17:15:10 +08:00
|
|
|
auto SoftFloat = makeMultilib("/soft-float")
|
2014-02-12 11:21:20 +08:00
|
|
|
.flag("+msoft-float");
|
|
|
|
|
2014-07-30 17:15:10 +08:00
|
|
|
auto Nan2008 = makeMultilib("/nan2008")
|
2014-02-12 11:21:20 +08:00
|
|
|
.flag("+mnan=2008");
|
|
|
|
|
2014-07-30 17:15:10 +08:00
|
|
|
auto DefaultFloat = makeMultilib("")
|
2014-02-12 11:21:20 +08:00
|
|
|
.flag("-msoft-float").flag("-mnan=2008");
|
|
|
|
|
2014-07-30 17:15:10 +08:00
|
|
|
auto BigEndian = makeMultilib("")
|
2014-03-05 02:37:28 +08:00
|
|
|
.flag("+EB").flag("-EL");
|
|
|
|
|
2014-07-30 17:15:10 +08:00
|
|
|
auto LittleEndian = makeMultilib("/el")
|
2014-02-12 11:21:20 +08:00
|
|
|
.flag("+EL").flag("-EB");
|
|
|
|
|
|
|
|
// Note that this one's osSuffix is ""
|
2014-07-30 17:15:10 +08:00
|
|
|
auto MAbi64 = makeMultilib("")
|
2014-02-12 11:21:20 +08:00
|
|
|
.gccSuffix("/64")
|
|
|
|
.includeSuffix("/64")
|
2014-07-16 20:29:22 +08:00
|
|
|
.flag("+mabi=n64").flag("-mabi=n32").flag("-m32");
|
2014-02-12 11:21:20 +08:00
|
|
|
|
|
|
|
CSMipsMultilibs = MultilibSet()
|
|
|
|
.Either(MArchMips16, MArchMicroMips, MArchDefault)
|
2014-08-13 22:34:14 +08:00
|
|
|
.Maybe(UCLibc)
|
2014-02-12 11:21:20 +08:00
|
|
|
.Either(SoftFloat, Nan2008, DefaultFloat)
|
|
|
|
.FilterOut("/micromips/nan2008")
|
|
|
|
.FilterOut("/mips16/nan2008")
|
2014-03-05 02:37:28 +08:00
|
|
|
.Either(BigEndian, LittleEndian)
|
2014-02-12 11:21:20 +08:00
|
|
|
.Maybe(MAbi64)
|
|
|
|
.FilterOut("/mips16.*/64")
|
|
|
|
.FilterOut("/micromips.*/64")
|
2014-08-06 13:44:47 +08:00
|
|
|
.FilterOut(NonExistent)
|
|
|
|
.setIncludeDirsCallback([](
|
|
|
|
StringRef InstallDir, StringRef TripleStr, const Multilib &M) {
|
|
|
|
std::vector<std::string> Dirs;
|
|
|
|
Dirs.push_back((InstallDir + "/include").str());
|
2014-08-13 22:34:14 +08:00
|
|
|
std::string SysRootInc =
|
|
|
|
InstallDir.str() + "/../../../../" + TripleStr.str();
|
|
|
|
if (StringRef(M.includeSuffix()).startswith("/uclibc"))
|
|
|
|
Dirs.push_back(SysRootInc + "/libc/uclibc/usr/include");
|
|
|
|
else
|
|
|
|
Dirs.push_back(SysRootInc + "/libc/usr/include");
|
2014-08-06 13:44:47 +08:00
|
|
|
return Dirs;
|
|
|
|
});
|
2014-02-12 11:21:20 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
MultilibSet AndroidMipsMultilibs = MultilibSet()
|
|
|
|
.Maybe(Multilib("/mips-r2").flag("+march=mips32r2"))
|
2014-02-25 12:21:44 +08:00
|
|
|
.FilterOut(NonExistent);
|
2014-02-12 11:21:20 +08:00
|
|
|
|
|
|
|
MultilibSet DebianMipsMultilibs;
|
|
|
|
{
|
|
|
|
Multilib MAbiN32 = Multilib()
|
|
|
|
.gccSuffix("/n32")
|
|
|
|
.includeSuffix("/n32")
|
|
|
|
.flag("+mabi=n32");
|
|
|
|
|
|
|
|
Multilib M64 = Multilib()
|
|
|
|
.gccSuffix("/64")
|
|
|
|
.includeSuffix("/64")
|
|
|
|
.flag("+m64").flag("-m32").flag("-mabi=n32");
|
|
|
|
|
|
|
|
Multilib M32 = Multilib()
|
|
|
|
.flag("-m64").flag("+m32").flag("-mabi=n32");
|
|
|
|
|
|
|
|
DebianMipsMultilibs = MultilibSet()
|
|
|
|
.Either(M32, M64, MAbiN32)
|
2014-02-25 12:21:44 +08:00
|
|
|
.FilterOut(NonExistent);
|
2014-02-12 11:21:20 +08:00
|
|
|
}
|
|
|
|
|
2014-07-10 22:40:57 +08:00
|
|
|
MultilibSet ImgMultilibs;
|
|
|
|
{
|
2014-07-30 17:15:10 +08:00
|
|
|
auto Mips64r6 = makeMultilib("/mips64r6")
|
2014-07-10 22:40:57 +08:00
|
|
|
.flag("+m64").flag("-m32");
|
|
|
|
|
2014-07-30 17:15:10 +08:00
|
|
|
auto LittleEndian = makeMultilib("/el")
|
2014-07-10 22:40:57 +08:00
|
|
|
.flag("+EL").flag("-EB");
|
|
|
|
|
2014-07-30 17:15:10 +08:00
|
|
|
auto MAbi64 = makeMultilib("/64")
|
2014-07-16 20:29:22 +08:00
|
|
|
.flag("+mabi=n64").flag("-mabi=n32").flag("-m32");
|
2014-07-10 22:40:57 +08:00
|
|
|
|
|
|
|
ImgMultilibs = MultilibSet()
|
|
|
|
.Maybe(Mips64r6)
|
|
|
|
.Maybe(MAbi64)
|
|
|
|
.Maybe(LittleEndian)
|
2014-08-06 13:44:47 +08:00
|
|
|
.FilterOut(NonExistent)
|
|
|
|
.setIncludeDirsCallback([](
|
|
|
|
StringRef InstallDir, StringRef TripleStr, const Multilib &M) {
|
|
|
|
std::vector<std::string> Dirs;
|
|
|
|
Dirs.push_back((InstallDir + "/include").str());
|
|
|
|
Dirs.push_back((InstallDir + "/../../../../sysroot/usr/include").str());
|
|
|
|
return Dirs;
|
|
|
|
});
|
2014-07-10 22:40:57 +08:00
|
|
|
}
|
|
|
|
|
2014-07-16 20:29:22 +08:00
|
|
|
StringRef CPUName;
|
|
|
|
StringRef ABIName;
|
|
|
|
tools::mips::getMipsCPUAndABI(Args, TargetTriple, CPUName, ABIName);
|
|
|
|
|
2014-02-12 11:21:20 +08:00
|
|
|
llvm::Triple::ArchType TargetArch = TargetTriple.getArch();
|
2013-10-10 15:57:44 +08:00
|
|
|
|
2014-02-12 11:21:20 +08:00
|
|
|
Multilib::flags_list Flags;
|
|
|
|
addMultilibFlag(isMips32(TargetArch), "m32", Flags);
|
|
|
|
addMultilibFlag(isMips64(TargetArch), "m64", Flags);
|
|
|
|
addMultilibFlag(isMips16(Args), "mips16", Flags);
|
2014-07-17 01:34:54 +08:00
|
|
|
addMultilibFlag(CPUName == "mips32", "march=mips32", Flags);
|
|
|
|
addMultilibFlag(CPUName == "mips32r2", "march=mips32r2", Flags);
|
|
|
|
addMultilibFlag(CPUName == "mips64", "march=mips64", Flags);
|
|
|
|
addMultilibFlag(CPUName == "mips64r2" || CPUName == "octeon",
|
|
|
|
"march=mips64r2", Flags);
|
2014-02-12 11:21:20 +08:00
|
|
|
addMultilibFlag(isMicroMips(Args), "mmicromips", Flags);
|
2014-08-13 22:34:14 +08:00
|
|
|
addMultilibFlag(tools::mips::isUCLibc(Args), "muclibc", Flags);
|
2014-07-16 20:24:48 +08:00
|
|
|
addMultilibFlag(tools::mips::isNaN2008(Args, TargetTriple), "mnan=2008",
|
|
|
|
Flags);
|
2014-07-16 20:29:22 +08:00
|
|
|
addMultilibFlag(ABIName == "n32", "mabi=n32", Flags);
|
|
|
|
addMultilibFlag(ABIName == "n64", "mabi=n64", Flags);
|
2014-02-12 11:21:20 +08:00
|
|
|
addMultilibFlag(isSoftFloatABI(Args), "msoft-float", Flags);
|
|
|
|
addMultilibFlag(!isSoftFloatABI(Args), "mhard-float", Flags);
|
|
|
|
addMultilibFlag(isMipsEL(TargetArch), "EL", Flags);
|
2014-07-16 20:29:22 +08:00
|
|
|
addMultilibFlag(!isMipsEL(TargetArch), "EB", Flags);
|
2014-02-12 11:21:20 +08:00
|
|
|
|
2014-03-05 02:37:28 +08:00
|
|
|
if (TargetTriple.getEnvironment() == llvm::Triple::Android) {
|
|
|
|
// Select Android toolchain. It's the only choice in that case.
|
2014-05-12 15:37:51 +08:00
|
|
|
if (AndroidMipsMultilibs.select(Flags, Result.SelectedMultilib)) {
|
|
|
|
Result.Multilibs = AndroidMipsMultilibs;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
2014-03-05 02:37:28 +08:00
|
|
|
}
|
|
|
|
|
2014-07-10 22:40:57 +08:00
|
|
|
if (TargetTriple.getVendor() == llvm::Triple::ImaginationTechnologies &&
|
|
|
|
TargetTriple.getOS() == llvm::Triple::Linux &&
|
|
|
|
TargetTriple.getEnvironment() == llvm::Triple::GNU) {
|
|
|
|
// Select mips-img-linux-gnu toolchain.
|
|
|
|
if (ImgMultilibs.select(Flags, Result.SelectedMultilib)) {
|
|
|
|
Result.Multilibs = ImgMultilibs;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2014-03-05 02:37:28 +08:00
|
|
|
// Sort candidates. Toolchain that best meets the directories goes first.
|
|
|
|
// Then select the first toolchains matches command line flags.
|
|
|
|
MultilibSet *candidates[] = { &DebianMipsMultilibs, &FSFMipsMultilibs,
|
|
|
|
&CSMipsMultilibs };
|
|
|
|
std::sort(
|
|
|
|
std::begin(candidates), std::end(candidates),
|
|
|
|
[](MultilibSet *a, MultilibSet *b) { return a->size() > b->size(); });
|
|
|
|
for (const auto &candidate : candidates) {
|
2014-05-12 15:37:51 +08:00
|
|
|
if (candidate->select(Flags, Result.SelectedMultilib)) {
|
2014-03-05 02:37:28 +08:00
|
|
|
if (candidate == &DebianMipsMultilibs)
|
2014-05-12 15:37:51 +08:00
|
|
|
Result.BiarchSibling = Multilib();
|
|
|
|
Result.Multilibs = *candidate;
|
2014-03-05 02:37:28 +08:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-06-25 03:00:12 +08:00
|
|
|
{
|
|
|
|
// Fallback to the regular toolchain-tree structure.
|
|
|
|
Multilib Default;
|
|
|
|
Result.Multilibs.push_back(Default);
|
|
|
|
Result.Multilibs.FilterOut(NonExistent);
|
|
|
|
|
|
|
|
if (Result.Multilibs.select(Flags, Result.SelectedMultilib)) {
|
|
|
|
Result.BiarchSibling = Multilib();
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-03-05 02:37:28 +08:00
|
|
|
return false;
|
2014-02-12 11:21:20 +08:00
|
|
|
}
|
|
|
|
|
2014-05-12 15:37:51 +08:00
|
|
|
static bool findBiarchMultilibs(const llvm::Triple &TargetTriple,
|
|
|
|
StringRef Path, const ArgList &Args,
|
|
|
|
bool NeedsBiarchSuffix,
|
|
|
|
DetectedMultilibs &Result) {
|
2013-10-10 15:57:44 +08:00
|
|
|
|
2014-02-12 11:21:20 +08:00
|
|
|
// Some versions of SUSE and Fedora on ppc64 put 32-bit libs
|
|
|
|
// in what would normally be GCCInstallPath and put the 64-bit
|
|
|
|
// 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 biarch triple alias, we look for
|
|
|
|
// crtbegin.o without the subdirectory.
|
|
|
|
|
|
|
|
Multilib Default;
|
|
|
|
Multilib Alt64 = Multilib()
|
|
|
|
.gccSuffix("/64")
|
|
|
|
.includeSuffix("/64")
|
2014-07-10 23:27:19 +08:00
|
|
|
.flag("-m32").flag("+m64").flag("-mx32");
|
2014-02-12 11:21:20 +08:00
|
|
|
Multilib Alt32 = Multilib()
|
|
|
|
.gccSuffix("/32")
|
|
|
|
.includeSuffix("/32")
|
2014-07-10 23:27:19 +08:00
|
|
|
.flag("+m32").flag("-m64").flag("-mx32");
|
|
|
|
Multilib Altx32 = Multilib()
|
|
|
|
.gccSuffix("/x32")
|
|
|
|
.includeSuffix("/x32")
|
|
|
|
.flag("-m32").flag("-m64").flag("+mx32");
|
2014-02-12 11:21:20 +08:00
|
|
|
|
2014-02-25 12:21:44 +08:00
|
|
|
FilterNonExistent NonExistent(Path);
|
2014-02-12 11:21:20 +08:00
|
|
|
|
2014-07-10 23:27:19 +08:00
|
|
|
// Determine default multilib from: 32, 64, x32
|
|
|
|
// Also handle cases such as 64 on 32, 32 on 64, etc.
|
|
|
|
enum { UNKNOWN, WANT32, WANT64, WANTX32 } Want = UNKNOWN;
|
2014-07-11 02:46:15 +08:00
|
|
|
const bool IsX32 = TargetTriple.getEnvironment() == llvm::Triple::GNUX32;
|
2014-02-25 12:21:44 +08:00
|
|
|
if (TargetTriple.isArch32Bit() && !NonExistent(Alt32))
|
2014-07-10 23:27:19 +08:00
|
|
|
Want = WANT64;
|
2014-07-10 23:42:35 +08:00
|
|
|
else if (TargetTriple.isArch64Bit() && IsX32 && !NonExistent(Altx32))
|
2014-07-10 23:27:19 +08:00
|
|
|
Want = WANT64;
|
2014-07-10 23:42:35 +08:00
|
|
|
else if (TargetTriple.isArch64Bit() && !IsX32 && !NonExistent(Alt64))
|
2014-07-10 23:27:19 +08:00
|
|
|
Want = WANT32;
|
2013-11-26 19:57:14 +08:00
|
|
|
else {
|
2014-07-10 23:27:19 +08:00
|
|
|
if (TargetTriple.isArch32Bit())
|
|
|
|
Want = NeedsBiarchSuffix ? WANT64 : WANT32;
|
2014-07-10 23:42:35 +08:00
|
|
|
else if (IsX32)
|
2014-07-10 23:27:19 +08:00
|
|
|
Want = NeedsBiarchSuffix ? WANT64 : WANTX32;
|
2014-02-12 11:21:20 +08:00
|
|
|
else
|
2014-07-10 23:27:19 +08:00
|
|
|
Want = NeedsBiarchSuffix ? WANT32 : WANT64;
|
2014-02-12 09:36:51 +08:00
|
|
|
}
|
2013-11-20 21:53:20 +08:00
|
|
|
|
2014-07-10 23:27:19 +08:00
|
|
|
if (Want == WANT32)
|
|
|
|
Default.flag("+m32").flag("-m64").flag("-mx32");
|
|
|
|
else if (Want == WANT64)
|
|
|
|
Default.flag("-m32").flag("+m64").flag("-mx32");
|
|
|
|
else if (Want == WANTX32)
|
|
|
|
Default.flag("-m32").flag("-m64").flag("+mx32");
|
2014-02-12 11:21:20 +08:00
|
|
|
else
|
2014-07-10 23:27:19 +08:00
|
|
|
return false;
|
2013-11-26 19:57:14 +08:00
|
|
|
|
2014-05-12 15:37:51 +08:00
|
|
|
Result.Multilibs.push_back(Default);
|
|
|
|
Result.Multilibs.push_back(Alt64);
|
|
|
|
Result.Multilibs.push_back(Alt32);
|
2014-07-10 23:27:19 +08:00
|
|
|
Result.Multilibs.push_back(Altx32);
|
2013-11-26 19:57:14 +08:00
|
|
|
|
2014-05-12 15:37:51 +08:00
|
|
|
Result.Multilibs.FilterOut(NonExistent);
|
2013-11-26 19:57:14 +08:00
|
|
|
|
2014-02-12 11:21:20 +08:00
|
|
|
Multilib::flags_list Flags;
|
2014-07-10 23:42:35 +08:00
|
|
|
addMultilibFlag(TargetTriple.isArch64Bit() && !IsX32, "m64", Flags);
|
2014-02-12 11:21:20 +08:00
|
|
|
addMultilibFlag(TargetTriple.isArch32Bit(), "m32", Flags);
|
2014-07-10 23:42:35 +08:00
|
|
|
addMultilibFlag(TargetTriple.isArch64Bit() && IsX32, "mx32", Flags);
|
2013-04-20 16:15:03 +08:00
|
|
|
|
2014-05-12 15:37:51 +08:00
|
|
|
if (!Result.Multilibs.select(Flags, Result.SelectedMultilib))
|
2014-02-12 11:21:20 +08:00
|
|
|
return false;
|
2014-02-12 09:29:25 +08:00
|
|
|
|
2014-07-10 23:27:19 +08:00
|
|
|
if (Result.SelectedMultilib == Alt64 ||
|
|
|
|
Result.SelectedMultilib == Alt32 ||
|
|
|
|
Result.SelectedMultilib == Altx32)
|
2014-05-12 15:37:51 +08:00
|
|
|
Result.BiarchSibling = Default;
|
2014-02-12 11:21:20 +08:00
|
|
|
|
|
|
|
return true;
|
2013-04-20 16:15:03 +08:00
|
|
|
}
|
|
|
|
|
2011-11-07 07:39:34 +08:00
|
|
|
void Generic_GCC::GCCInstallationDetector::ScanLibDirForGCCTriple(
|
2014-02-12 11:21:20 +08:00
|
|
|
const llvm::Triple &TargetTriple, const ArgList &Args,
|
2013-06-22 19:35:51 +08:00
|
|
|
const std::string &LibDir, StringRef CandidateTriple,
|
|
|
|
bool NeedsBiarchSuffix) {
|
2014-02-12 11:21:20 +08:00
|
|
|
llvm::Triple::ArchType TargetArch = TargetTriple.getArch();
|
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(),
|
2013-07-26 08:53:40 +08:00
|
|
|
// Debian puts cross-compilers in gcc-cross
|
|
|
|
"/gcc-cross/" + CandidateTriple.str(),
|
2011-11-07 07:39:34 +08:00
|
|
|
"/" + CandidateTriple.str() + "/gcc/" + CandidateTriple.str(),
|
|
|
|
|
2012-09-19 06:25:07 +08:00
|
|
|
// The Freescale PPC SDK has the gcc libraries in
|
|
|
|
// <sysroot>/usr/lib/<triple>/x.y.z so have a look there as well.
|
|
|
|
"/" + CandidateTriple.str(),
|
|
|
|
|
2011-11-07 07:39:34 +08:00
|
|
|
// 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
|
|
|
};
|
2013-07-26 08:53:40 +08:00
|
|
|
const std::string InstallSuffixes[] = {
|
|
|
|
"/../../..", // gcc/
|
|
|
|
"/../../..", // gcc-cross/
|
|
|
|
"/../../../..", // <triple>/gcc/
|
|
|
|
"/../..", // <triple>/
|
|
|
|
"/../../../.." // i386-linux-gnu/gcc/<triple>/
|
|
|
|
};
|
2011-11-07 07:39:34 +08:00
|
|
|
// Only look at the final, weird Ubuntu suffix for i386-linux-gnu.
|
2013-06-22 19:35:51 +08:00
|
|
|
const unsigned NumLibSuffixes =
|
|
|
|
(llvm::array_lengthof(LibSuffixes) - (TargetArch != llvm::Triple::x86));
|
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 i = 0; i < NumLibSuffixes; ++i) {
|
|
|
|
StringRef LibSuffix = LibSuffixes[i];
|
2014-06-12 22:02:15 +08:00
|
|
|
std::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);
|
2013-08-15 02:38:51 +08:00
|
|
|
if (CandidateVersion.Major != -1) // Filter obviously bad entries.
|
|
|
|
if (!CandidateGCCInstallPaths.insert(LI->path()).second)
|
|
|
|
continue; // Saw this path before; no need to look at it again.
|
2013-08-10 01:17:48 +08:00
|
|
|
if (CandidateVersion.isOlderThan(4, 1, 1))
|
2011-11-07 07:39:34 +08:00
|
|
|
continue;
|
|
|
|
if (CandidateVersion <= Version)
|
|
|
|
continue;
|
2011-12-08 13:50:03 +08:00
|
|
|
|
2014-05-12 15:37:51 +08:00
|
|
|
DetectedMultilibs Detected;
|
2014-02-12 11:21:20 +08:00
|
|
|
|
|
|
|
// Debian mips multilibs behave more like the rest of the biarch ones,
|
|
|
|
// so handle them there
|
|
|
|
if (isMipsArch(TargetArch)) {
|
2014-05-12 15:37:51 +08:00
|
|
|
if (!findMIPSMultilibs(TargetTriple, LI->path(), Args, Detected))
|
2014-02-12 11:21:20 +08:00
|
|
|
continue;
|
|
|
|
} else if (!findBiarchMultilibs(TargetTriple, LI->path(), Args,
|
2014-05-12 15:37:51 +08:00
|
|
|
NeedsBiarchSuffix, Detected)) {
|
2013-09-28 21:45:11 +08:00
|
|
|
continue;
|
2014-05-12 15:37:51 +08:00
|
|
|
}
|
2011-11-07 07:39:34 +08:00
|
|
|
|
2014-05-12 15:37:51 +08:00
|
|
|
Multilibs = Detected.Multilibs;
|
|
|
|
SelectedMultilib = Detected.SelectedMultilib;
|
|
|
|
BiarchSibling = Detected.BiarchSibling;
|
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-02-19 09:38:32 +08:00
|
|
|
Generic_GCC::Generic_GCC(const Driver &D, const llvm::Triple& Triple,
|
|
|
|
const ArgList &Args)
|
2013-12-07 02:32:18 +08:00
|
|
|
: ToolChain(D, Triple, Args), GCCInstallation() {
|
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() {
|
|
|
|
}
|
|
|
|
|
2013-03-20 11:05:54 +08:00
|
|
|
Tool *Generic_GCC::getTool(Action::ActionClass AC) const {
|
2013-03-19 04:48:54 +08:00
|
|
|
switch (AC) {
|
2013-03-19 02:50:01 +08:00
|
|
|
case Action::PreprocessJobClass:
|
2013-03-20 11:05:54 +08:00
|
|
|
if (!Preprocess)
|
|
|
|
Preprocess.reset(new tools::gcc::Preprocess(*this));
|
|
|
|
return Preprocess.get();
|
2013-03-19 02:50:01 +08:00
|
|
|
case Action::CompileJobClass:
|
2013-03-20 11:05:54 +08:00
|
|
|
if (!Compile)
|
|
|
|
Compile.reset(new tools::gcc::Compile(*this));
|
|
|
|
return Compile.get();
|
2013-03-19 08:36:57 +08:00
|
|
|
default:
|
2013-03-20 11:05:54 +08:00
|
|
|
return ToolChain::getTool(AC);
|
2009-03-20 08:20:03 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-03-20 11:05:54 +08:00
|
|
|
Tool *Generic_GCC::buildAssembler() const {
|
2013-11-24 00:40:57 +08:00
|
|
|
return new tools::gnutools::Assemble(*this);
|
2013-03-20 11:05:54 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
Tool *Generic_GCC::buildLinker() const {
|
2014-06-30 00:00:11 +08:00
|
|
|
return new tools::gcc::Link(*this);
|
2013-03-20 11:05:54 +08:00
|
|
|
}
|
|
|
|
|
2013-07-31 01:57:09 +08:00
|
|
|
void Generic_GCC::printVerboseInfo(raw_ostream &OS) const {
|
|
|
|
// Print the information about how we detected the GCC installation.
|
|
|
|
GCCInstallation.print(OS);
|
|
|
|
}
|
|
|
|
|
2009-03-20 08:20:03 +08:00
|
|
|
bool Generic_GCC::IsUnwindTablesDefault() const {
|
2012-09-22 23:04:11 +08:00
|
|
|
return getArch() == llvm::Triple::x86_64;
|
2009-03-20 08:20:03 +08:00
|
|
|
}
|
|
|
|
|
Completely re-work how the Clang driver interprets PIC and PIE options.
There were numerous issues here that were all entangled, and so I've
tried to do a general simplification of the logic.
1) The logic was mimicing actual GCC bugs, rather than "features". These
have been fixed in trunk GCC, and this fixes Clang as well. Notably,
the logic was always intended to be last-match-wins like any other
flag.
2) The logic for handling '-mdynamic-no-pic' was preposterously unclear.
It also allowed the use of this flag on non-Darwin platforms where it
has no actual meaning. Now this option is handled directly based on
tests of how llvm-gcc behaves, and it is only supported on Darwin.
3) The APIs for the Driver's ToolChains had the implementation ugliness
of dynamic-no-pic leaking through them. They also had the
implementation details of the LLVM relocation model flag names
leaking through.
4) The actual results of passing these flags was incorrect on Darwin in
many cases. For example, Darwin *always* uses PIC level 2 if it uses
in PIC level, and Darwin *always* uses PIC on 64-bit regardless of
the flags specified, including -fPIE. Darwin never compiles in PIE
mode, but it can *link* in PIE mode.
5) Also, PIC was not always being enabled even when PIE was. This isn't
a supported mode at all and may have caused some fallout in builds
with complex PIC and PIE interactions.
The result is (I hope) cleaner and clearer for readers. I've also left
comments and tests about some of the truly strage behavior that is
observed on Darwin platforms. We have no real testing of Windows
platforms and PIC, but I don't have the tools handy to figure that out.
Hopefully others can beef up our testing here.
Unfortunately, I can't test this for every platform. =/ If folks have
dependencies on these flags that aren't covered by tests, they may
break. I've audited and ensured that all the changes in behavior of the
existing tests are intentional and good. In particular I've tried to
make sure the Darwin behavior (which is more suprising than the Linux
behavior) also matches that of 'gcc' on my mac.
llvm-svn: 168297
2012-11-19 11:52:03 +08:00
|
|
|
bool Generic_GCC::isPICDefault() const {
|
|
|
|
return false;
|
2009-03-20 08:20:03 +08:00
|
|
|
}
|
|
|
|
|
2013-04-09 12:35:11 +08:00
|
|
|
bool Generic_GCC::isPIEDefault() const {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
Completely re-work how the Clang driver interprets PIC and PIE options.
There were numerous issues here that were all entangled, and so I've
tried to do a general simplification of the logic.
1) The logic was mimicing actual GCC bugs, rather than "features". These
have been fixed in trunk GCC, and this fixes Clang as well. Notably,
the logic was always intended to be last-match-wins like any other
flag.
2) The logic for handling '-mdynamic-no-pic' was preposterously unclear.
It also allowed the use of this flag on non-Darwin platforms where it
has no actual meaning. Now this option is handled directly based on
tests of how llvm-gcc behaves, and it is only supported on Darwin.
3) The APIs for the Driver's ToolChains had the implementation ugliness
of dynamic-no-pic leaking through them. They also had the
implementation details of the LLVM relocation model flag names
leaking through.
4) The actual results of passing these flags was incorrect on Darwin in
many cases. For example, Darwin *always* uses PIC level 2 if it uses
in PIC level, and Darwin *always* uses PIC on 64-bit regardless of
the flags specified, including -fPIE. Darwin never compiles in PIE
mode, but it can *link* in PIE mode.
5) Also, PIC was not always being enabled even when PIE was. This isn't
a supported mode at all and may have caused some fallout in builds
with complex PIC and PIE interactions.
The result is (I hope) cleaner and clearer for readers. I've also left
comments and tests about some of the truly strage behavior that is
observed on Darwin platforms. We have no real testing of Windows
platforms and PIC, but I don't have the tools handy to figure that out.
Hopefully others can beef up our testing here.
Unfortunately, I can't test this for every platform. =/ If folks have
dependencies on these flags that aren't covered by tests, they may
break. I've audited and ensured that all the changes in behavior of the
existing tests are intentional and good. In particular I've tried to
make sure the Darwin behavior (which is more suprising than the Linux
behavior) also matches that of 'gcc' on my mac.
llvm-svn: 168297
2012-11-19 11:52:03 +08:00
|
|
|
bool Generic_GCC::isPICDefaultForced() const {
|
|
|
|
return false;
|
2009-03-20 08:20:03 +08:00
|
|
|
}
|
Completely re-work how the Clang driver interprets PIC and PIE options.
There were numerous issues here that were all entangled, and so I've
tried to do a general simplification of the logic.
1) The logic was mimicing actual GCC bugs, rather than "features". These
have been fixed in trunk GCC, and this fixes Clang as well. Notably,
the logic was always intended to be last-match-wins like any other
flag.
2) The logic for handling '-mdynamic-no-pic' was preposterously unclear.
It also allowed the use of this flag on non-Darwin platforms where it
has no actual meaning. Now this option is handled directly based on
tests of how llvm-gcc behaves, and it is only supported on Darwin.
3) The APIs for the Driver's ToolChains had the implementation ugliness
of dynamic-no-pic leaking through them. They also had the
implementation details of the LLVM relocation model flag names
leaking through.
4) The actual results of passing these flags was incorrect on Darwin in
many cases. For example, Darwin *always* uses PIC level 2 if it uses
in PIC level, and Darwin *always* uses PIC on 64-bit regardless of
the flags specified, including -fPIE. Darwin never compiles in PIE
mode, but it can *link* in PIE mode.
5) Also, PIC was not always being enabled even when PIE was. This isn't
a supported mode at all and may have caused some fallout in builds
with complex PIC and PIE interactions.
The result is (I hope) cleaner and clearer for readers. I've also left
comments and tests about some of the truly strage behavior that is
observed on Darwin platforms. We have no real testing of Windows
platforms and PIC, but I don't have the tools handy to figure that out.
Hopefully others can beef up our testing here.
Unfortunately, I can't test this for every platform. =/ If folks have
dependencies on these flags that aren't covered by tests, they may
break. I've audited and ensured that all the changes in behavior of the
existing tests are intentional and good. In particular I've tried to
make sure the Darwin behavior (which is more suprising than the Linux
behavior) also matches that of 'gcc' on my mac.
llvm-svn: 168297
2012-11-19 11:52:03 +08:00
|
|
|
|
2013-11-26 02:50:53 +08:00
|
|
|
bool Generic_GCC::IsIntegratedAssemblerDefault() const {
|
|
|
|
return getTriple().getArch() == llvm::Triple::x86 ||
|
2013-12-11 17:35:10 +08:00
|
|
|
getTriple().getArch() == llvm::Triple::x86_64 ||
|
|
|
|
getTriple().getArch() == llvm::Triple::aarch64 ||
|
2014-02-25 21:51:00 +08:00
|
|
|
getTriple().getArch() == llvm::Triple::aarch64_be ||
|
2013-12-11 17:35:10 +08:00
|
|
|
getTriple().getArch() == llvm::Triple::arm ||
|
2014-03-28 22:40:46 +08:00
|
|
|
getTriple().getArch() == llvm::Triple::armeb ||
|
|
|
|
getTriple().getArch() == llvm::Triple::thumb ||
|
2014-10-07 01:33:18 +08:00
|
|
|
getTriple().getArch() == llvm::Triple::thumbeb ||
|
2015-01-14 15:55:36 +08:00
|
|
|
getTriple().getArch() == llvm::Triple::ppc ||
|
2014-10-07 01:33:18 +08:00
|
|
|
getTriple().getArch() == llvm::Triple::ppc64 ||
|
2014-10-10 02:46:38 +08:00
|
|
|
getTriple().getArch() == llvm::Triple::ppc64le ||
|
2015-01-14 15:55:36 +08:00
|
|
|
getTriple().getArch() == llvm::Triple::sparc ||
|
|
|
|
getTriple().getArch() == llvm::Triple::sparcv9 ||
|
2014-10-10 02:46:38 +08:00
|
|
|
getTriple().getArch() == llvm::Triple::systemz;
|
2013-11-26 02:50:53 +08:00
|
|
|
}
|
|
|
|
|
2014-01-10 21:44:34 +08:00
|
|
|
void Generic_ELF::addClangTargetOptions(const ArgList &DriverArgs,
|
|
|
|
ArgStringList &CC1Args) const {
|
|
|
|
const Generic_GCC::GCCVersion &V = GCCInstallation.getVersion();
|
2014-03-29 23:09:45 +08:00
|
|
|
bool UseInitArrayDefault =
|
2014-01-10 21:44:34 +08:00
|
|
|
getTriple().getArch() == llvm::Triple::aarch64 ||
|
2014-02-25 21:51:00 +08:00
|
|
|
getTriple().getArch() == llvm::Triple::aarch64_be ||
|
2014-03-29 23:09:45 +08:00
|
|
|
(getTriple().getOS() == llvm::Triple::Linux &&
|
|
|
|
(!V.isOlderThan(4, 7, 0) ||
|
|
|
|
getTriple().getEnvironment() == llvm::Triple::Android));
|
2014-01-10 21:44:34 +08:00
|
|
|
|
|
|
|
if (DriverArgs.hasFlag(options::OPT_fuse_init_array,
|
|
|
|
options::OPT_fno_use_init_array,
|
|
|
|
UseInitArrayDefault))
|
|
|
|
CC1Args.push_back("-fuse-init-array");
|
|
|
|
}
|
|
|
|
|
2011-12-13 05:14:55 +08:00
|
|
|
/// Hexagon Toolchain
|
|
|
|
|
2014-11-08 01:48:03 +08:00
|
|
|
std::string Hexagon_TC::GetGnuDir(const std::string &InstalledDir,
|
|
|
|
const ArgList &Args) {
|
2012-12-06 20:43:18 +08:00
|
|
|
|
|
|
|
// Locate the rest of the toolchain ...
|
2014-11-08 01:48:03 +08:00
|
|
|
std::string GccToolchain = getGCCToolchainDir(Args);
|
|
|
|
|
|
|
|
if (!GccToolchain.empty())
|
|
|
|
return GccToolchain;
|
2012-12-06 20:43:18 +08:00
|
|
|
|
|
|
|
std::string InstallRelDir = InstalledDir + "/../../gnu";
|
|
|
|
if (llvm::sys::fs::exists(InstallRelDir))
|
|
|
|
return InstallRelDir;
|
|
|
|
|
|
|
|
std::string PrefixRelDir = std::string(LLVM_PREFIX) + "/../gnu";
|
|
|
|
if (llvm::sys::fs::exists(PrefixRelDir))
|
|
|
|
return PrefixRelDir;
|
|
|
|
|
|
|
|
return InstallRelDir;
|
|
|
|
}
|
|
|
|
|
2012-12-06 23:46:07 +08:00
|
|
|
static void GetHexagonLibraryPaths(
|
|
|
|
const ArgList &Args,
|
2014-11-04 16:55:13 +08:00
|
|
|
const std::string &Ver,
|
|
|
|
const std::string &MarchString,
|
2012-12-06 23:46:07 +08:00
|
|
|
const std::string &InstalledDir,
|
|
|
|
ToolChain::path_list *LibPaths)
|
|
|
|
{
|
|
|
|
bool buildingLib = Args.hasArg(options::OPT_shared);
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
// -L Args
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
for (arg_iterator
|
|
|
|
it = Args.filtered_begin(options::OPT_L),
|
|
|
|
ie = Args.filtered_end();
|
|
|
|
it != ie;
|
|
|
|
++it) {
|
|
|
|
for (unsigned i = 0, e = (*it)->getNumValues(); i != e; ++i)
|
|
|
|
LibPaths->push_back((*it)->getValue(i));
|
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
// Other standard paths
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
const std::string MarchSuffix = "/" + MarchString;
|
|
|
|
const std::string G0Suffix = "/G0";
|
|
|
|
const std::string MarchG0Suffix = MarchSuffix + G0Suffix;
|
2014-11-08 01:48:03 +08:00
|
|
|
const std::string RootDir = Hexagon_TC::GetGnuDir(InstalledDir, Args) + "/";
|
2012-12-06 23:46:07 +08:00
|
|
|
|
|
|
|
// lib/gcc/hexagon/...
|
|
|
|
std::string LibGCCHexagonDir = RootDir + "lib/gcc/hexagon/";
|
|
|
|
if (buildingLib) {
|
|
|
|
LibPaths->push_back(LibGCCHexagonDir + Ver + MarchG0Suffix);
|
|
|
|
LibPaths->push_back(LibGCCHexagonDir + Ver + G0Suffix);
|
|
|
|
}
|
|
|
|
LibPaths->push_back(LibGCCHexagonDir + Ver + MarchSuffix);
|
|
|
|
LibPaths->push_back(LibGCCHexagonDir + Ver);
|
|
|
|
|
|
|
|
// lib/gcc/...
|
|
|
|
LibPaths->push_back(RootDir + "lib/gcc");
|
|
|
|
|
|
|
|
// hexagon/lib/...
|
|
|
|
std::string HexagonLibDir = RootDir + "hexagon/lib";
|
|
|
|
if (buildingLib) {
|
|
|
|
LibPaths->push_back(HexagonLibDir + MarchG0Suffix);
|
|
|
|
LibPaths->push_back(HexagonLibDir + G0Suffix);
|
|
|
|
}
|
|
|
|
LibPaths->push_back(HexagonLibDir + MarchSuffix);
|
|
|
|
LibPaths->push_back(HexagonLibDir);
|
|
|
|
}
|
|
|
|
|
2012-12-06 20:43:18 +08:00
|
|
|
Hexagon_TC::Hexagon_TC(const Driver &D, const llvm::Triple &Triple,
|
|
|
|
const ArgList &Args)
|
|
|
|
: Linux(D, Triple, Args) {
|
|
|
|
const std::string InstalledDir(getDriver().getInstalledDir());
|
2014-11-08 01:48:03 +08:00
|
|
|
const std::string GnuDir = Hexagon_TC::GetGnuDir(InstalledDir, Args);
|
2012-12-06 20:43:18 +08:00
|
|
|
|
|
|
|
// Note: Generic_GCC::Generic_GCC adds InstalledDir and getDriver().Dir to
|
|
|
|
// program paths
|
|
|
|
const std::string BinDir(GnuDir + "/bin");
|
|
|
|
if (llvm::sys::fs::exists(BinDir))
|
|
|
|
getProgramPaths().push_back(BinDir);
|
|
|
|
|
|
|
|
// Determine version of GCC libraries and headers to use.
|
|
|
|
const std::string HexagonDir(GnuDir + "/lib/gcc/hexagon");
|
2014-06-12 22:02:15 +08:00
|
|
|
std::error_code ec;
|
2012-12-06 20:43:18 +08:00
|
|
|
GCCVersion MaxVersion= GCCVersion::Parse("0.0.0");
|
|
|
|
for (llvm::sys::fs::directory_iterator di(HexagonDir, ec), de;
|
|
|
|
!ec && di != de; di = di.increment(ec)) {
|
|
|
|
GCCVersion cv = GCCVersion::Parse(llvm::sys::path::filename(di->path()));
|
|
|
|
if (MaxVersion < cv)
|
|
|
|
MaxVersion = cv;
|
|
|
|
}
|
|
|
|
GCCLibAndIncVersion = MaxVersion;
|
2012-12-06 23:46:07 +08:00
|
|
|
|
|
|
|
ToolChain::path_list *LibPaths= &getFilePaths();
|
|
|
|
|
|
|
|
// Remove paths added by Linux toolchain. Currently Hexagon_TC really targets
|
|
|
|
// 'elf' OS type, so the Linux paths are not appropriate. When we actually
|
|
|
|
// support 'linux' we'll need to fix this up
|
|
|
|
LibPaths->clear();
|
|
|
|
|
|
|
|
GetHexagonLibraryPaths(
|
|
|
|
Args,
|
|
|
|
GetGCCLibAndIncVersion(),
|
|
|
|
GetTargetCPU(Args),
|
|
|
|
InstalledDir,
|
|
|
|
LibPaths);
|
2011-12-13 05:14:55 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
Hexagon_TC::~Hexagon_TC() {
|
|
|
|
}
|
|
|
|
|
2013-03-20 11:05:54 +08:00
|
|
|
Tool *Hexagon_TC::buildAssembler() const {
|
|
|
|
return new tools::hexagon::Assemble(*this);
|
|
|
|
}
|
|
|
|
|
|
|
|
Tool *Hexagon_TC::buildLinker() const {
|
|
|
|
return new tools::hexagon::Link(*this);
|
2011-12-13 05:14:55 +08:00
|
|
|
}
|
|
|
|
|
2012-12-06 20:43:18 +08:00
|
|
|
void Hexagon_TC::AddClangSystemIncludeArgs(const ArgList &DriverArgs,
|
|
|
|
ArgStringList &CC1Args) const {
|
|
|
|
const Driver &D = getDriver();
|
|
|
|
|
|
|
|
if (DriverArgs.hasArg(options::OPT_nostdinc) ||
|
|
|
|
DriverArgs.hasArg(options::OPT_nostdlibinc))
|
|
|
|
return;
|
|
|
|
|
|
|
|
std::string Ver(GetGCCLibAndIncVersion());
|
2014-11-08 01:48:03 +08:00
|
|
|
std::string GnuDir = Hexagon_TC::GetGnuDir(D.InstalledDir, DriverArgs);
|
2012-12-06 20:43:18 +08:00
|
|
|
std::string HexagonDir(GnuDir + "/lib/gcc/hexagon/" + Ver);
|
|
|
|
addExternCSystemInclude(DriverArgs, CC1Args, HexagonDir + "/include");
|
|
|
|
addExternCSystemInclude(DriverArgs, CC1Args, HexagonDir + "/include-fixed");
|
|
|
|
addExternCSystemInclude(DriverArgs, CC1Args, GnuDir + "/hexagon/include");
|
2011-12-13 05:14:55 +08:00
|
|
|
}
|
|
|
|
|
2012-12-06 20:43:18 +08:00
|
|
|
void Hexagon_TC::AddClangCXXStdlibIncludeArgs(const ArgList &DriverArgs,
|
|
|
|
ArgStringList &CC1Args) const {
|
|
|
|
|
|
|
|
if (DriverArgs.hasArg(options::OPT_nostdlibinc) ||
|
|
|
|
DriverArgs.hasArg(options::OPT_nostdincxx))
|
|
|
|
return;
|
|
|
|
|
|
|
|
const Driver &D = getDriver();
|
|
|
|
std::string Ver(GetGCCLibAndIncVersion());
|
2014-11-08 01:48:03 +08:00
|
|
|
SmallString<128> IncludeDir(
|
|
|
|
Hexagon_TC::GetGnuDir(D.InstalledDir, DriverArgs));
|
2012-12-06 20:43:18 +08:00
|
|
|
|
2013-06-26 10:13:00 +08:00
|
|
|
llvm::sys::path::append(IncludeDir, "hexagon/include/c++/");
|
|
|
|
llvm::sys::path::append(IncludeDir, Ver);
|
2012-12-06 20:43:18 +08:00
|
|
|
addSystemInclude(DriverArgs, CC1Args, IncludeDir.str());
|
Completely re-work how the Clang driver interprets PIC and PIE options.
There were numerous issues here that were all entangled, and so I've
tried to do a general simplification of the logic.
1) The logic was mimicing actual GCC bugs, rather than "features". These
have been fixed in trunk GCC, and this fixes Clang as well. Notably,
the logic was always intended to be last-match-wins like any other
flag.
2) The logic for handling '-mdynamic-no-pic' was preposterously unclear.
It also allowed the use of this flag on non-Darwin platforms where it
has no actual meaning. Now this option is handled directly based on
tests of how llvm-gcc behaves, and it is only supported on Darwin.
3) The APIs for the Driver's ToolChains had the implementation ugliness
of dynamic-no-pic leaking through them. They also had the
implementation details of the LLVM relocation model flag names
leaking through.
4) The actual results of passing these flags was incorrect on Darwin in
many cases. For example, Darwin *always* uses PIC level 2 if it uses
in PIC level, and Darwin *always* uses PIC on 64-bit regardless of
the flags specified, including -fPIE. Darwin never compiles in PIE
mode, but it can *link* in PIE mode.
5) Also, PIC was not always being enabled even when PIE was. This isn't
a supported mode at all and may have caused some fallout in builds
with complex PIC and PIE interactions.
The result is (I hope) cleaner and clearer for readers. I've also left
comments and tests about some of the truly strage behavior that is
observed on Darwin platforms. We have no real testing of Windows
platforms and PIC, but I don't have the tools handy to figure that out.
Hopefully others can beef up our testing here.
Unfortunately, I can't test this for every platform. =/ If folks have
dependencies on these flags that aren't covered by tests, they may
break. I've audited and ensured that all the changes in behavior of the
existing tests are intentional and good. In particular I've tried to
make sure the Darwin behavior (which is more suprising than the Linux
behavior) also matches that of 'gcc' on my mac.
llvm-svn: 168297
2012-11-19 11:52:03 +08:00
|
|
|
}
|
2012-12-06 22:16:43 +08:00
|
|
|
|
2012-12-06 23:46:07 +08:00
|
|
|
ToolChain::CXXStdlibType
|
|
|
|
Hexagon_TC::GetCXXStdlibType(const ArgList &Args) const {
|
|
|
|
Arg *A = Args.getLastArg(options::OPT_stdlib_EQ);
|
|
|
|
if (!A)
|
|
|
|
return ToolChain::CST_Libstdcxx;
|
|
|
|
|
|
|
|
StringRef Value = A->getValue();
|
|
|
|
if (Value != "libstdc++") {
|
|
|
|
getDriver().Diag(diag::err_drv_invalid_stdlib_name)
|
|
|
|
<< A->getAsString(Args);
|
|
|
|
}
|
|
|
|
|
|
|
|
return ToolChain::CST_Libstdcxx;
|
|
|
|
}
|
|
|
|
|
2013-09-24 21:28:24 +08:00
|
|
|
static int getHexagonVersion(const ArgList &Args) {
|
|
|
|
Arg *A = Args.getLastArg(options::OPT_march_EQ, options::OPT_mcpu_EQ);
|
|
|
|
// Select the default CPU (v4) if none was given.
|
|
|
|
if (!A)
|
|
|
|
return 4;
|
|
|
|
|
|
|
|
// FIXME: produce errors if we cannot parse the version.
|
|
|
|
StringRef WhichHexagon = A->getValue();
|
|
|
|
if (WhichHexagon.startswith("hexagonv")) {
|
|
|
|
int Val;
|
|
|
|
if (!WhichHexagon.substr(sizeof("hexagonv") - 1).getAsInteger(10, Val))
|
|
|
|
return Val;
|
|
|
|
}
|
|
|
|
if (WhichHexagon.startswith("v")) {
|
|
|
|
int Val;
|
|
|
|
if (!WhichHexagon.substr(1).getAsInteger(10, Val))
|
|
|
|
return Val;
|
2012-12-06 22:16:43 +08:00
|
|
|
}
|
2013-09-24 21:28:24 +08:00
|
|
|
|
|
|
|
// FIXME: should probably be an error.
|
|
|
|
return 4;
|
2012-12-06 22:16:43 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
StringRef Hexagon_TC::GetTargetCPU(const ArgList &Args)
|
|
|
|
{
|
2013-09-24 21:28:24 +08:00
|
|
|
int V = getHexagonVersion(Args);
|
|
|
|
// FIXME: We don't support versions < 4. We should error on them.
|
|
|
|
switch (V) {
|
|
|
|
default:
|
|
|
|
llvm_unreachable("Unexpected version");
|
|
|
|
case 5:
|
|
|
|
return "v5";
|
|
|
|
case 4:
|
|
|
|
return "v4";
|
|
|
|
case 3:
|
|
|
|
return "v3";
|
|
|
|
case 2:
|
|
|
|
return "v2";
|
|
|
|
case 1:
|
|
|
|
return "v1";
|
2012-12-06 22:16:43 +08:00
|
|
|
}
|
|
|
|
}
|
2012-12-06 20:43:18 +08:00
|
|
|
// 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.
|
|
|
|
|
2013-03-19 02:10:27 +08:00
|
|
|
TCEToolChain::TCEToolChain(const Driver &D, const llvm::Triple& Triple,
|
|
|
|
const ArgList &Args)
|
|
|
|
: ToolChain(D, Triple, Args) {
|
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() {
|
|
|
|
}
|
|
|
|
|
2011-06-03 11:49:51 +08:00
|
|
|
bool TCEToolChain::IsMathErrnoDefault() const {
|
|
|
|
return true;
|
2010-03-05 05:07:38 +08:00
|
|
|
}
|
|
|
|
|
Completely re-work how the Clang driver interprets PIC and PIE options.
There were numerous issues here that were all entangled, and so I've
tried to do a general simplification of the logic.
1) The logic was mimicing actual GCC bugs, rather than "features". These
have been fixed in trunk GCC, and this fixes Clang as well. Notably,
the logic was always intended to be last-match-wins like any other
flag.
2) The logic for handling '-mdynamic-no-pic' was preposterously unclear.
It also allowed the use of this flag on non-Darwin platforms where it
has no actual meaning. Now this option is handled directly based on
tests of how llvm-gcc behaves, and it is only supported on Darwin.
3) The APIs for the Driver's ToolChains had the implementation ugliness
of dynamic-no-pic leaking through them. They also had the
implementation details of the LLVM relocation model flag names
leaking through.
4) The actual results of passing these flags was incorrect on Darwin in
many cases. For example, Darwin *always* uses PIC level 2 if it uses
in PIC level, and Darwin *always* uses PIC on 64-bit regardless of
the flags specified, including -fPIE. Darwin never compiles in PIE
mode, but it can *link* in PIE mode.
5) Also, PIC was not always being enabled even when PIE was. This isn't
a supported mode at all and may have caused some fallout in builds
with complex PIC and PIE interactions.
The result is (I hope) cleaner and clearer for readers. I've also left
comments and tests about some of the truly strage behavior that is
observed on Darwin platforms. We have no real testing of Windows
platforms and PIC, but I don't have the tools handy to figure that out.
Hopefully others can beef up our testing here.
Unfortunately, I can't test this for every platform. =/ If folks have
dependencies on these flags that aren't covered by tests, they may
break. I've audited and ensured that all the changes in behavior of the
existing tests are intentional and good. In particular I've tried to
make sure the Darwin behavior (which is more suprising than the Linux
behavior) also matches that of 'gcc' on my mac.
llvm-svn: 168297
2012-11-19 11:52:03 +08:00
|
|
|
bool TCEToolChain::isPICDefault() const {
|
|
|
|
return false;
|
2010-03-05 05:07:38 +08:00
|
|
|
}
|
|
|
|
|
2013-04-09 12:35:11 +08:00
|
|
|
bool TCEToolChain::isPIEDefault() const {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
Completely re-work how the Clang driver interprets PIC and PIE options.
There were numerous issues here that were all entangled, and so I've
tried to do a general simplification of the logic.
1) The logic was mimicing actual GCC bugs, rather than "features". These
have been fixed in trunk GCC, and this fixes Clang as well. Notably,
the logic was always intended to be last-match-wins like any other
flag.
2) The logic for handling '-mdynamic-no-pic' was preposterously unclear.
It also allowed the use of this flag on non-Darwin platforms where it
has no actual meaning. Now this option is handled directly based on
tests of how llvm-gcc behaves, and it is only supported on Darwin.
3) The APIs for the Driver's ToolChains had the implementation ugliness
of dynamic-no-pic leaking through them. They also had the
implementation details of the LLVM relocation model flag names
leaking through.
4) The actual results of passing these flags was incorrect on Darwin in
many cases. For example, Darwin *always* uses PIC level 2 if it uses
in PIC level, and Darwin *always* uses PIC on 64-bit regardless of
the flags specified, including -fPIE. Darwin never compiles in PIE
mode, but it can *link* in PIE mode.
5) Also, PIC was not always being enabled even when PIE was. This isn't
a supported mode at all and may have caused some fallout in builds
with complex PIC and PIE interactions.
The result is (I hope) cleaner and clearer for readers. I've also left
comments and tests about some of the truly strage behavior that is
observed on Darwin platforms. We have no real testing of Windows
platforms and PIC, but I don't have the tools handy to figure that out.
Hopefully others can beef up our testing here.
Unfortunately, I can't test this for every platform. =/ If folks have
dependencies on these flags that aren't covered by tests, they may
break. I've audited and ensured that all the changes in behavior of the
existing tests are intentional and good. In particular I've tried to
make sure the Darwin behavior (which is more suprising than the Linux
behavior) also matches that of 'gcc' on my mac.
llvm-svn: 168297
2012-11-19 11:52:03 +08:00
|
|
|
bool TCEToolChain::isPICDefaultForced() const {
|
|
|
|
return false;
|
2010-03-05 05:07:38 +08:00
|
|
|
}
|
|
|
|
|
2009-06-30 04:52:51 +08:00
|
|
|
/// OpenBSD - OpenBSD tool chain which can call as(1) and ld(1) directly.
|
|
|
|
|
2012-02-19 09:38:32 +08:00
|
|
|
OpenBSD::OpenBSD(const Driver &D, const llvm::Triple& Triple, const ArgList &Args)
|
|
|
|
: Generic_ELF(D, Triple, Args) {
|
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");
|
|
|
|
}
|
|
|
|
|
2013-03-20 11:05:54 +08:00
|
|
|
Tool *OpenBSD::buildAssembler() const {
|
|
|
|
return new tools::openbsd::Assemble(*this);
|
|
|
|
}
|
|
|
|
|
|
|
|
Tool *OpenBSD::buildLinker() const {
|
|
|
|
return new tools::openbsd::Link(*this);
|
2009-06-30 04:52:51 +08:00
|
|
|
}
|
|
|
|
|
2012-08-09 07:57:20 +08:00
|
|
|
/// Bitrig - Bitrig tool chain which can call as(1) and ld(1) directly.
|
|
|
|
|
|
|
|
Bitrig::Bitrig(const Driver &D, const llvm::Triple& Triple, const ArgList &Args)
|
|
|
|
: Generic_ELF(D, Triple, Args) {
|
|
|
|
getFilePaths().push_back(getDriver().Dir + "/../lib");
|
|
|
|
getFilePaths().push_back("/usr/lib");
|
|
|
|
}
|
|
|
|
|
2013-03-20 11:05:54 +08:00
|
|
|
Tool *Bitrig::buildAssembler() const {
|
|
|
|
return new tools::bitrig::Assemble(*this);
|
|
|
|
}
|
|
|
|
|
|
|
|
Tool *Bitrig::buildLinker() const {
|
|
|
|
return new tools::bitrig::Link(*this);
|
2012-08-09 07:57:20 +08:00
|
|
|
}
|
|
|
|
|
2014-05-02 07:24:24 +08:00
|
|
|
ToolChain::CXXStdlibType
|
|
|
|
Bitrig::GetCXXStdlibType(const ArgList &Args) const {
|
|
|
|
if (Arg *A = Args.getLastArg(options::OPT_stdlib_EQ)) {
|
|
|
|
StringRef Value = A->getValue();
|
|
|
|
if (Value == "libstdc++")
|
|
|
|
return ToolChain::CST_Libstdcxx;
|
|
|
|
if (Value == "libc++")
|
|
|
|
return ToolChain::CST_Libcxx;
|
|
|
|
|
|
|
|
getDriver().Diag(diag::err_drv_invalid_stdlib_name)
|
|
|
|
<< A->getAsString(Args);
|
|
|
|
}
|
|
|
|
return ToolChain::CST_Libcxx;
|
|
|
|
}
|
|
|
|
|
2012-08-09 07:57:20 +08:00
|
|
|
void Bitrig::AddClangCXXStdlibIncludeArgs(const ArgList &DriverArgs,
|
|
|
|
ArgStringList &CC1Args) const {
|
|
|
|
if (DriverArgs.hasArg(options::OPT_nostdlibinc) ||
|
|
|
|
DriverArgs.hasArg(options::OPT_nostdincxx))
|
|
|
|
return;
|
|
|
|
|
2012-10-09 05:31:38 +08:00
|
|
|
switch (GetCXXStdlibType(DriverArgs)) {
|
|
|
|
case ToolChain::CST_Libcxx:
|
|
|
|
addSystemInclude(DriverArgs, CC1Args,
|
2014-05-02 07:24:24 +08:00
|
|
|
getDriver().SysRoot + "/usr/include/c++/v1");
|
2012-10-09 05:31:38 +08:00
|
|
|
break;
|
|
|
|
case ToolChain::CST_Libstdcxx:
|
|
|
|
addSystemInclude(DriverArgs, CC1Args,
|
|
|
|
getDriver().SysRoot + "/usr/include/c++/stdc++");
|
|
|
|
addSystemInclude(DriverArgs, CC1Args,
|
|
|
|
getDriver().SysRoot + "/usr/include/c++/stdc++/backward");
|
|
|
|
|
|
|
|
StringRef Triple = getTriple().str();
|
|
|
|
if (Triple.startswith("amd64"))
|
|
|
|
addSystemInclude(DriverArgs, CC1Args,
|
|
|
|
getDriver().SysRoot + "/usr/include/c++/stdc++/x86_64" +
|
|
|
|
Triple.substr(5));
|
|
|
|
else
|
|
|
|
addSystemInclude(DriverArgs, CC1Args,
|
|
|
|
getDriver().SysRoot + "/usr/include/c++/stdc++/" +
|
|
|
|
Triple);
|
|
|
|
break;
|
|
|
|
}
|
2012-08-09 07:57:20 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void Bitrig::AddCXXStdlibLibArgs(const ArgList &Args,
|
|
|
|
ArgStringList &CmdArgs) const {
|
2012-10-09 05:31:38 +08:00
|
|
|
switch (GetCXXStdlibType(Args)) {
|
|
|
|
case ToolChain::CST_Libcxx:
|
|
|
|
CmdArgs.push_back("-lc++");
|
2014-05-02 07:24:24 +08:00
|
|
|
CmdArgs.push_back("-lc++abi");
|
|
|
|
CmdArgs.push_back("-lpthread");
|
2012-10-09 05:31:38 +08:00
|
|
|
break;
|
|
|
|
case ToolChain::CST_Libstdcxx:
|
|
|
|
CmdArgs.push_back("-lstdc++");
|
|
|
|
break;
|
|
|
|
}
|
2012-08-09 07:57:20 +08:00
|
|
|
}
|
|
|
|
|
2009-03-31 05:06:03 +08:00
|
|
|
/// FreeBSD - FreeBSD tool chain which can call as(1) and ld(1) directly.
|
|
|
|
|
2012-02-19 09:38:32 +08:00
|
|
|
FreeBSD::FreeBSD(const Driver &D, const llvm::Triple& Triple, const ArgList &Args)
|
|
|
|
: Generic_ELF(D, Triple, Args) {
|
2010-08-02 13:43:59 +08:00
|
|
|
|
2012-01-26 09:35:15 +08:00
|
|
|
// When targeting 32-bit platforms, look for '/usr/lib32/crt1.o' and fall
|
|
|
|
// back to '/usr/lib' if it doesn't exist.
|
2012-01-25 19:24:24 +08:00
|
|
|
if ((Triple.getArch() == llvm::Triple::x86 ||
|
|
|
|
Triple.getArch() == llvm::Triple::ppc) &&
|
2012-01-26 09:35:15 +08:00
|
|
|
llvm::sys::fs::exists(getDriver().SysRoot + "/usr/lib32/crt1.o"))
|
2012-01-25 19:24:24 +08:00
|
|
|
getFilePaths().push_back(getDriver().SysRoot + "/usr/lib32");
|
|
|
|
else
|
|
|
|
getFilePaths().push_back(getDriver().SysRoot + "/usr/lib");
|
2009-03-31 05:06:03 +08:00
|
|
|
}
|
|
|
|
|
2013-11-09 23:10:56 +08:00
|
|
|
ToolChain::CXXStdlibType
|
|
|
|
FreeBSD::GetCXXStdlibType(const ArgList &Args) const {
|
|
|
|
if (Arg *A = Args.getLastArg(options::OPT_stdlib_EQ)) {
|
|
|
|
StringRef Value = A->getValue();
|
|
|
|
if (Value == "libstdc++")
|
|
|
|
return ToolChain::CST_Libstdcxx;
|
|
|
|
if (Value == "libc++")
|
|
|
|
return ToolChain::CST_Libcxx;
|
|
|
|
|
|
|
|
getDriver().Diag(diag::err_drv_invalid_stdlib_name)
|
|
|
|
<< A->getAsString(Args);
|
|
|
|
}
|
|
|
|
if (getTriple().getOSMajorVersion() >= 10)
|
|
|
|
return ToolChain::CST_Libcxx;
|
|
|
|
return ToolChain::CST_Libstdcxx;
|
|
|
|
}
|
|
|
|
|
|
|
|
void FreeBSD::AddClangCXXStdlibIncludeArgs(const ArgList &DriverArgs,
|
|
|
|
ArgStringList &CC1Args) const {
|
|
|
|
if (DriverArgs.hasArg(options::OPT_nostdlibinc) ||
|
|
|
|
DriverArgs.hasArg(options::OPT_nostdincxx))
|
|
|
|
return;
|
|
|
|
|
|
|
|
switch (GetCXXStdlibType(DriverArgs)) {
|
|
|
|
case ToolChain::CST_Libcxx:
|
|
|
|
addSystemInclude(DriverArgs, CC1Args,
|
|
|
|
getDriver().SysRoot + "/usr/include/c++/v1");
|
|
|
|
break;
|
|
|
|
case ToolChain::CST_Libstdcxx:
|
|
|
|
addSystemInclude(DriverArgs, CC1Args,
|
|
|
|
getDriver().SysRoot + "/usr/include/c++/4.2");
|
|
|
|
addSystemInclude(DriverArgs, CC1Args,
|
|
|
|
getDriver().SysRoot + "/usr/include/c++/4.2/backward");
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-03-20 11:05:54 +08:00
|
|
|
Tool *FreeBSD::buildAssembler() const {
|
|
|
|
return new tools::freebsd::Assemble(*this);
|
|
|
|
}
|
|
|
|
|
|
|
|
Tool *FreeBSD::buildLinker() const {
|
|
|
|
return new tools::freebsd::Link(*this);
|
2011-02-03 02:59:27 +08:00
|
|
|
}
|
|
|
|
|
2012-12-13 12:17:14 +08:00
|
|
|
bool FreeBSD::UseSjLjExceptions() const {
|
|
|
|
// FreeBSD uses SjLj exceptions on ARM oabi.
|
|
|
|
switch (getTriple().getEnvironment()) {
|
2014-02-19 18:44:07 +08:00
|
|
|
case llvm::Triple::GNUEABIHF:
|
2012-12-13 12:17:14 +08:00
|
|
|
case llvm::Triple::GNUEABI:
|
|
|
|
case llvm::Triple::EABI:
|
|
|
|
return false;
|
|
|
|
|
|
|
|
default:
|
|
|
|
return (getTriple().getArch() == llvm::Triple::arm ||
|
|
|
|
getTriple().getArch() == llvm::Triple::thumb);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-02-25 21:26:03 +08:00
|
|
|
bool FreeBSD::HasNativeLLVMSupport() const {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool FreeBSD::isPIEDefault() const {
|
2014-11-21 20:19:01 +08:00
|
|
|
return getSanitizerArgs().requiresPIE();
|
2014-02-25 21:26:03 +08:00
|
|
|
}
|
|
|
|
|
2011-02-03 02:59:27 +08:00
|
|
|
/// NetBSD - NetBSD tool chain which can call as(1) and ld(1) directly.
|
|
|
|
|
2012-02-19 09:38:32 +08:00
|
|
|
NetBSD::NetBSD(const Driver &D, const llvm::Triple& Triple, const ArgList &Args)
|
|
|
|
: Generic_ELF(D, Triple, Args) {
|
2011-02-03 02:59:27 +08:00
|
|
|
|
2011-03-21 21:59:26 +08:00
|
|
|
if (getDriver().UseStdLib) {
|
2012-01-25 19:18:20 +08:00
|
|
|
// When targeting a 32-bit platform, try the special directory used on
|
|
|
|
// 64-bit hosts, and only fall back to the main library directory if that
|
|
|
|
// doesn't work.
|
|
|
|
// FIXME: It'd be nicer to test if this directory exists, but I'm not sure
|
|
|
|
// what all logic is needed to emulate the '=' prefix here.
|
2014-02-03 06:47:37 +08:00
|
|
|
switch (Triple.getArch()) {
|
|
|
|
case llvm::Triple::x86:
|
2011-03-21 21:59:26 +08:00
|
|
|
getFilePaths().push_back("=/usr/lib/i386");
|
2014-02-03 06:47:37 +08:00
|
|
|
break;
|
|
|
|
case llvm::Triple::arm:
|
2014-05-07 16:24:23 +08:00
|
|
|
case llvm::Triple::armeb:
|
2014-02-03 06:47:37 +08:00
|
|
|
case llvm::Triple::thumb:
|
2014-05-07 16:24:23 +08:00
|
|
|
case llvm::Triple::thumbeb:
|
2014-02-03 06:47:37 +08:00
|
|
|
switch (Triple.getEnvironment()) {
|
|
|
|
case llvm::Triple::EABI:
|
|
|
|
case llvm::Triple::GNUEABI:
|
|
|
|
getFilePaths().push_back("=/usr/lib/eabi");
|
|
|
|
break;
|
2014-08-10 03:01:52 +08:00
|
|
|
case llvm::Triple::EABIHF:
|
|
|
|
case llvm::Triple::GNUEABIHF:
|
|
|
|
getFilePaths().push_back("=/usr/lib/eabihf");
|
|
|
|
break;
|
2014-02-03 06:47:37 +08:00
|
|
|
default:
|
|
|
|
getFilePaths().push_back("=/usr/lib/oabi");
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
break;
|
2014-02-03 06:59:16 +08:00
|
|
|
case llvm::Triple::mips64:
|
|
|
|
case llvm::Triple::mips64el:
|
2014-02-12 11:21:20 +08:00
|
|
|
if (tools::mips::hasMipsAbiArg(Args, "o32"))
|
2014-02-03 06:59:16 +08:00
|
|
|
getFilePaths().push_back("=/usr/lib/o32");
|
2014-02-12 11:21:20 +08:00
|
|
|
else if (tools::mips::hasMipsAbiArg(Args, "64"))
|
2014-02-03 06:59:16 +08:00
|
|
|
getFilePaths().push_back("=/usr/lib/64");
|
|
|
|
break;
|
2014-08-13 22:17:32 +08:00
|
|
|
case llvm::Triple::ppc:
|
|
|
|
getFilePaths().push_back("=/usr/lib/powerpc");
|
|
|
|
break;
|
2014-04-17 04:44:17 +08:00
|
|
|
case llvm::Triple::sparc:
|
|
|
|
getFilePaths().push_back("=/usr/lib/sparc");
|
|
|
|
break;
|
2014-02-03 06:47:37 +08:00
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
2012-01-25 19:18:20 +08:00
|
|
|
|
|
|
|
getFilePaths().push_back("=/usr/lib");
|
2011-02-03 02:59:27 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-03-20 11:05:54 +08:00
|
|
|
Tool *NetBSD::buildAssembler() const {
|
|
|
|
return new tools::netbsd::Assemble(*this);
|
|
|
|
}
|
|
|
|
|
|
|
|
Tool *NetBSD::buildLinker() const {
|
|
|
|
return new tools::netbsd::Link(*this);
|
2009-03-31 05:06:03 +08:00
|
|
|
}
|
2009-05-03 02:28:39 +08:00
|
|
|
|
2013-04-30 09:21:43 +08:00
|
|
|
ToolChain::CXXStdlibType
|
|
|
|
NetBSD::GetCXXStdlibType(const ArgList &Args) const {
|
|
|
|
if (Arg *A = Args.getLastArg(options::OPT_stdlib_EQ)) {
|
|
|
|
StringRef Value = A->getValue();
|
|
|
|
if (Value == "libstdc++")
|
|
|
|
return ToolChain::CST_Libstdcxx;
|
|
|
|
if (Value == "libc++")
|
|
|
|
return ToolChain::CST_Libcxx;
|
|
|
|
|
|
|
|
getDriver().Diag(diag::err_drv_invalid_stdlib_name)
|
|
|
|
<< A->getAsString(Args);
|
|
|
|
}
|
|
|
|
|
2013-10-15 04:13:05 +08:00
|
|
|
unsigned Major, Minor, Micro;
|
|
|
|
getTriple().getOSVersion(Major, Minor, Micro);
|
2014-07-26 04:57:24 +08:00
|
|
|
if (Major >= 7 || (Major == 6 && Minor == 99 && Micro >= 49) || Major == 0) {
|
2014-01-18 08:50:49 +08:00
|
|
|
switch (getArch()) {
|
2014-08-10 02:28:36 +08:00
|
|
|
case llvm::Triple::aarch64:
|
2014-05-07 16:45:26 +08:00
|
|
|
case llvm::Triple::arm:
|
|
|
|
case llvm::Triple::armeb:
|
|
|
|
case llvm::Triple::thumb:
|
|
|
|
case llvm::Triple::thumbeb:
|
2014-07-26 04:57:24 +08:00
|
|
|
case llvm::Triple::ppc:
|
2014-08-13 22:17:32 +08:00
|
|
|
case llvm::Triple::ppc64:
|
|
|
|
case llvm::Triple::ppc64le:
|
2014-01-18 08:50:49 +08:00
|
|
|
case llvm::Triple::x86:
|
|
|
|
case llvm::Triple::x86_64:
|
2013-10-15 04:13:05 +08:00
|
|
|
return ToolChain::CST_Libcxx;
|
2014-01-18 08:50:49 +08:00
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
2013-10-15 04:13:05 +08:00
|
|
|
}
|
2013-04-30 09:21:43 +08:00
|
|
|
return ToolChain::CST_Libstdcxx;
|
|
|
|
}
|
|
|
|
|
|
|
|
void NetBSD::AddClangCXXStdlibIncludeArgs(const ArgList &DriverArgs,
|
|
|
|
ArgStringList &CC1Args) const {
|
|
|
|
if (DriverArgs.hasArg(options::OPT_nostdlibinc) ||
|
|
|
|
DriverArgs.hasArg(options::OPT_nostdincxx))
|
|
|
|
return;
|
|
|
|
|
|
|
|
switch (GetCXXStdlibType(DriverArgs)) {
|
|
|
|
case ToolChain::CST_Libcxx:
|
|
|
|
addSystemInclude(DriverArgs, CC1Args,
|
|
|
|
getDriver().SysRoot + "/usr/include/c++/");
|
|
|
|
break;
|
|
|
|
case ToolChain::CST_Libstdcxx:
|
|
|
|
addSystemInclude(DriverArgs, CC1Args,
|
|
|
|
getDriver().SysRoot + "/usr/include/g++");
|
|
|
|
addSystemInclude(DriverArgs, CC1Args,
|
|
|
|
getDriver().SysRoot + "/usr/include/g++/backward");
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-07-08 00:01:42 +08:00
|
|
|
/// Minix - Minix tool chain which can call as(1) and ld(1) directly.
|
|
|
|
|
2012-02-19 09:38:32 +08:00
|
|
|
Minix::Minix(const Driver &D, const llvm::Triple& Triple, const ArgList &Args)
|
|
|
|
: Generic_ELF(D, Triple, Args) {
|
2010-07-08 00:01:42 +08:00
|
|
|
getFilePaths().push_back(getDriver().Dir + "/../lib");
|
|
|
|
getFilePaths().push_back("/usr/lib");
|
|
|
|
}
|
|
|
|
|
2013-03-20 11:05:54 +08:00
|
|
|
Tool *Minix::buildAssembler() const {
|
|
|
|
return new tools::minix::Assemble(*this);
|
|
|
|
}
|
|
|
|
|
|
|
|
Tool *Minix::buildLinker() const {
|
|
|
|
return new tools::minix::Link(*this);
|
2010-07-08 00:01:42 +08:00
|
|
|
}
|
|
|
|
|
2012-02-15 21:39:01 +08:00
|
|
|
/// Solaris - Solaris tool chain which can call as(1) and ld(1) directly.
|
|
|
|
|
2012-02-19 09:38:32 +08:00
|
|
|
Solaris::Solaris(const Driver &D, const llvm::Triple& Triple,
|
|
|
|
const ArgList &Args)
|
|
|
|
: Generic_GCC(D, Triple, Args) {
|
2012-02-15 21:39:01 +08:00
|
|
|
|
|
|
|
getProgramPaths().push_back(getDriver().getInstalledDir());
|
|
|
|
if (getDriver().getInstalledDir() != getDriver().Dir)
|
|
|
|
getProgramPaths().push_back(getDriver().Dir);
|
|
|
|
|
|
|
|
getFilePaths().push_back(getDriver().Dir + "/../lib");
|
|
|
|
getFilePaths().push_back("/usr/lib");
|
|
|
|
}
|
|
|
|
|
2013-03-20 11:05:54 +08:00
|
|
|
Tool *Solaris::buildAssembler() const {
|
|
|
|
return new tools::solaris::Assemble(*this);
|
|
|
|
}
|
|
|
|
|
|
|
|
Tool *Solaris::buildLinker() const {
|
|
|
|
return new tools::solaris::Link(*this);
|
2012-02-15 21:39:01 +08:00
|
|
|
}
|
2009-08-22 09:06:46 +08:00
|
|
|
|
2013-03-29 03:02:48 +08:00
|
|
|
/// Distribution (very bare-bones at the moment).
|
2009-05-26 15:52:18 +08:00
|
|
|
|
2013-03-29 03:02:48 +08:00
|
|
|
enum Distro {
|
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,
|
2013-01-06 16:09:29 +08:00
|
|
|
DebianJessie,
|
2010-11-11 10:07:13 +08:00
|
|
|
Exherbo,
|
2011-05-22 13:36:06 +08:00
|
|
|
RHEL4,
|
|
|
|
RHEL5,
|
|
|
|
RHEL6,
|
2013-10-26 02:09:41 +08:00
|
|
|
Fedora,
|
2013-07-03 22:14:00 +08:00
|
|
|
OpenSUSE,
|
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,
|
2012-02-06 22:36:09 +08:00
|
|
|
UbuntuPrecise,
|
2012-12-14 04:26:05 +08:00
|
|
|
UbuntuQuantal,
|
|
|
|
UbuntuRaring,
|
2013-06-13 19:52:27 +08:00
|
|
|
UbuntuSaucy,
|
2013-11-07 17:31:30 +08:00
|
|
|
UbuntuTrusty,
|
2010-11-08 04:14:31 +08:00
|
|
|
UnknownDistro
|
|
|
|
};
|
|
|
|
|
2013-03-29 03:02:48 +08:00
|
|
|
static bool IsRedhat(enum Distro Distro) {
|
2013-10-26 02:09:41 +08:00
|
|
|
return Distro == Fedora || (Distro >= RHEL4 && Distro <= RHEL6);
|
2010-11-08 04:14:31 +08:00
|
|
|
}
|
|
|
|
|
2013-07-03 22:14:00 +08:00
|
|
|
static bool IsOpenSUSE(enum Distro Distro) {
|
|
|
|
return Distro == OpenSUSE;
|
2010-11-08 04:14:31 +08:00
|
|
|
}
|
|
|
|
|
2013-03-29 03:02:48 +08:00
|
|
|
static bool IsDebian(enum Distro Distro) {
|
2013-01-06 16:09:29 +08:00
|
|
|
return Distro >= DebianLenny && Distro <= DebianJessie;
|
2010-11-08 04:14:31 +08:00
|
|
|
}
|
|
|
|
|
2013-03-29 03:02:48 +08:00
|
|
|
static bool IsUbuntu(enum Distro Distro) {
|
2013-11-07 17:31:30 +08:00
|
|
|
return Distro >= UbuntuHardy && Distro <= UbuntuTrusty;
|
2010-11-08 04:14:31 +08:00
|
|
|
}
|
|
|
|
|
2013-10-29 07:14:34 +08:00
|
|
|
static Distro DetectDistro(llvm::Triple::ArchType Arch) {
|
2014-07-07 01:43:24 +08:00
|
|
|
llvm::ErrorOr<std::unique_ptr<llvm::MemoryBuffer>> File =
|
|
|
|
llvm::MemoryBuffer::getFile("/etc/lsb-release");
|
|
|
|
if (File) {
|
2011-07-23 18:55:15 +08:00
|
|
|
StringRef Data = File.get()->getBuffer();
|
2014-08-12 02:09:32 +08:00
|
|
|
SmallVector<StringRef, 16> Lines;
|
2010-11-08 04:14:31 +08:00
|
|
|
Data.split(Lines, "\n");
|
2013-03-29 03:02:48 +08:00
|
|
|
Distro Version = UnknownDistro;
|
2012-02-06 22:36:09 +08:00
|
|
|
for (unsigned i = 0, s = Lines.size(); i != s; ++i)
|
|
|
|
if (Version == UnknownDistro && Lines[i].startswith("DISTRIB_CODENAME="))
|
2013-03-29 03:02:48 +08:00
|
|
|
Version = llvm::StringSwitch<Distro>(Lines[i].substr(17))
|
2012-02-06 22:36:09 +08:00
|
|
|
.Case("hardy", UbuntuHardy)
|
|
|
|
.Case("intrepid", UbuntuIntrepid)
|
|
|
|
.Case("jaunty", UbuntuJaunty)
|
|
|
|
.Case("karmic", UbuntuKarmic)
|
|
|
|
.Case("lucid", UbuntuLucid)
|
|
|
|
.Case("maverick", UbuntuMaverick)
|
|
|
|
.Case("natty", UbuntuNatty)
|
|
|
|
.Case("oneiric", UbuntuOneiric)
|
|
|
|
.Case("precise", UbuntuPrecise)
|
2012-12-14 04:26:05 +08:00
|
|
|
.Case("quantal", UbuntuQuantal)
|
|
|
|
.Case("raring", UbuntuRaring)
|
2013-06-13 19:52:27 +08:00
|
|
|
.Case("saucy", UbuntuSaucy)
|
2013-11-07 17:31:30 +08:00
|
|
|
.Case("trusty", UbuntuTrusty)
|
2012-02-06 22:36:09 +08:00
|
|
|
.Default(UnknownDistro);
|
|
|
|
return Version;
|
2010-11-08 04:14:31 +08:00
|
|
|
}
|
|
|
|
|
2014-07-07 01:43:24 +08:00
|
|
|
File = llvm::MemoryBuffer::getFile("/etc/redhat-release");
|
|
|
|
if (File) {
|
2011-07-23 18:55:15 +08:00
|
|
|
StringRef Data = File.get()->getBuffer();
|
2013-10-26 02:09:41 +08:00
|
|
|
if (Data.startswith("Fedora release"))
|
|
|
|
return Fedora;
|
2014-05-05 20:39:32 +08:00
|
|
|
if (Data.startswith("Red Hat Enterprise Linux") ||
|
|
|
|
Data.startswith("CentOS")) {
|
|
|
|
if (Data.find("release 6") != StringRef::npos)
|
|
|
|
return RHEL6;
|
|
|
|
else if (Data.find("release 5") != StringRef::npos)
|
|
|
|
return RHEL5;
|
|
|
|
else if (Data.find("release 4") != StringRef::npos)
|
|
|
|
return RHEL4;
|
|
|
|
}
|
2010-11-08 04:14:31 +08:00
|
|
|
return UnknownDistro;
|
|
|
|
}
|
|
|
|
|
2014-07-07 01:43:24 +08:00
|
|
|
File = llvm::MemoryBuffer::getFile("/etc/debian_version");
|
|
|
|
if (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;
|
2013-01-06 16:09:29 +08:00
|
|
|
else if (Data.startswith("jessie/sid") || Data[0] == '8')
|
|
|
|
return DebianJessie;
|
2010-11-08 04:14:31 +08:00
|
|
|
return UnknownDistro;
|
|
|
|
}
|
|
|
|
|
2013-10-29 07:14:34 +08:00
|
|
|
if (llvm::sys::fs::exists("/etc/SuSE-release"))
|
2013-07-03 22:14:00 +08:00
|
|
|
return OpenSUSE;
|
2010-11-08 04:14:31 +08:00
|
|
|
|
2013-10-29 07:14:34 +08:00
|
|
|
if (llvm::sys::fs::exists("/etc/exherbo-release"))
|
2010-11-11 10:07:13 +08:00
|
|
|
return Exherbo;
|
|
|
|
|
2013-10-29 07:14:34 +08:00
|
|
|
if (llvm::sys::fs::exists("/etc/arch-release"))
|
2011-02-25 14:39:53 +08:00
|
|
|
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.
|
2014-03-05 03:31:42 +08:00
|
|
|
static std::string getMultiarchTriple(const llvm::Triple &TargetTriple,
|
2011-10-31 16:42:24 +08:00
|
|
|
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.
|
2012-07-12 03:08:21 +08:00
|
|
|
case llvm::Triple::arm:
|
|
|
|
case llvm::Triple::thumb:
|
2012-07-31 16:06:29 +08:00
|
|
|
if (TargetTriple.getEnvironment() == llvm::Triple::GNUEABIHF) {
|
|
|
|
if (llvm::sys::fs::exists(SysRoot + "/lib/arm-linux-gnueabihf"))
|
|
|
|
return "arm-linux-gnueabihf";
|
|
|
|
} else {
|
|
|
|
if (llvm::sys::fs::exists(SysRoot + "/lib/arm-linux-gnueabi"))
|
|
|
|
return "arm-linux-gnueabi";
|
|
|
|
}
|
2012-07-12 03:08:21 +08:00
|
|
|
return TargetTriple.str();
|
2014-03-28 22:40:46 +08:00
|
|
|
case llvm::Triple::armeb:
|
|
|
|
case llvm::Triple::thumbeb:
|
|
|
|
if (TargetTriple.getEnvironment() == llvm::Triple::GNUEABIHF) {
|
|
|
|
if (llvm::sys::fs::exists(SysRoot + "/lib/armeb-linux-gnueabihf"))
|
|
|
|
return "armeb-linux-gnueabihf";
|
|
|
|
} else {
|
|
|
|
if (llvm::sys::fs::exists(SysRoot + "/lib/armeb-linux-gnueabi"))
|
|
|
|
return "armeb-linux-gnueabi";
|
|
|
|
}
|
|
|
|
return TargetTriple.str();
|
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:
|
2014-07-10 23:27:19 +08:00
|
|
|
// We don't want this for x32, otherwise it will match x86_64 libs
|
|
|
|
if (TargetTriple.getEnvironment() != llvm::Triple::GNUX32 &&
|
|
|
|
llvm::sys::fs::exists(SysRoot + "/lib/x86_64-linux-gnu"))
|
2011-10-31 16:42:24 +08:00
|
|
|
return "x86_64-linux-gnu";
|
|
|
|
return TargetTriple.str();
|
2013-01-31 20:13:10 +08:00
|
|
|
case llvm::Triple::aarch64:
|
|
|
|
if (llvm::sys::fs::exists(SysRoot + "/lib/aarch64-linux-gnu"))
|
|
|
|
return "aarch64-linux-gnu";
|
2013-06-14 06:54:55 +08:00
|
|
|
return TargetTriple.str();
|
2014-03-14 20:15:45 +08:00
|
|
|
case llvm::Triple::aarch64_be:
|
|
|
|
if (llvm::sys::fs::exists(SysRoot + "/lib/aarch64_be-linux-gnu"))
|
|
|
|
return "aarch64_be-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();
|
2014-06-25 03:00:12 +08:00
|
|
|
case llvm::Triple::mips64:
|
|
|
|
if (llvm::sys::fs::exists(SysRoot + "/lib/mips64-linux-gnu"))
|
|
|
|
return "mips64-linux-gnu";
|
|
|
|
if (llvm::sys::fs::exists(SysRoot + "/lib/mips64-linux-gnuabi64"))
|
|
|
|
return "mips64-linux-gnuabi64";
|
|
|
|
return TargetTriple.str();
|
|
|
|
case llvm::Triple::mips64el:
|
|
|
|
if (llvm::sys::fs::exists(SysRoot + "/lib/mips64el-linux-gnu"))
|
|
|
|
return "mips64el-linux-gnu";
|
|
|
|
if (llvm::sys::fs::exists(SysRoot + "/lib/mips64el-linux-gnuabi64"))
|
|
|
|
return "mips64el-linux-gnuabi64";
|
|
|
|
return TargetTriple.str();
|
2012-02-26 17:03:21 +08:00
|
|
|
case llvm::Triple::ppc:
|
2013-03-16 00:22:43 +08:00
|
|
|
if (llvm::sys::fs::exists(SysRoot + "/lib/powerpc-linux-gnuspe"))
|
|
|
|
return "powerpc-linux-gnuspe";
|
2012-02-26 17:03:21 +08:00
|
|
|
if (llvm::sys::fs::exists(SysRoot + "/lib/powerpc-linux-gnu"))
|
|
|
|
return "powerpc-linux-gnu";
|
|
|
|
return TargetTriple.str();
|
|
|
|
case llvm::Triple::ppc64:
|
|
|
|
if (llvm::sys::fs::exists(SysRoot + "/lib/powerpc64-linux-gnu"))
|
|
|
|
return "powerpc64-linux-gnu";
|
2013-07-26 09:36:11 +08:00
|
|
|
case llvm::Triple::ppc64le:
|
|
|
|
if (llvm::sys::fs::exists(SysRoot + "/lib/powerpc64le-linux-gnu"))
|
|
|
|
return "powerpc64le-linux-gnu";
|
2012-02-26 17:03:21 +08:00
|
|
|
return TargetTriple.str();
|
2011-10-31 16:42:24 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-01-25 19:24:24 +08:00
|
|
|
static void addPathIfExists(Twine Path, ToolChain::path_list &Paths) {
|
|
|
|
if (llvm::sys::fs::exists(Path)) Paths.push_back(Path.str());
|
|
|
|
}
|
|
|
|
|
2014-02-12 11:21:20 +08:00
|
|
|
static StringRef getOSLibDir(const llvm::Triple &Triple, const ArgList &Args) {
|
2013-10-29 18:27:30 +08:00
|
|
|
if (isMipsArch(Triple.getArch())) {
|
|
|
|
// lib32 directory has a special meaning on MIPS targets.
|
|
|
|
// It contains N32 ABI binaries. Use this folder if produce
|
|
|
|
// code for N32 ABI only.
|
2014-02-12 11:21:20 +08:00
|
|
|
if (tools::mips::hasMipsAbiArg(Args, "n32"))
|
2013-10-29 18:27:30 +08:00
|
|
|
return "lib32";
|
|
|
|
return Triple.isArch32Bit() ? "lib" : "lib64";
|
|
|
|
}
|
2012-09-14 19:27:24 +08:00
|
|
|
|
2014-02-12 11:21:20 +08:00
|
|
|
// It happens that only x86 and PPC use the 'lib32' variant of oslibdir, and
|
2013-10-29 18:27:30 +08:00
|
|
|
// using that variant while targeting other architectures causes problems
|
|
|
|
// because the libraries are laid out in shared system roots that can't cope
|
2014-02-12 11:21:20 +08:00
|
|
|
// with a 'lib32' library search path being considered. So we only enable
|
2013-10-29 18:27:30 +08:00
|
|
|
// them when we know we may need it.
|
|
|
|
//
|
|
|
|
// FIXME: This is a bit of a hack. We should really unify this code for
|
2014-02-12 11:21:20 +08:00
|
|
|
// reasoning about oslibdir spellings with the lib dir spellings in the
|
2013-10-29 18:27:30 +08:00
|
|
|
// GCCInstallationDetector, but that is a more significant refactoring.
|
|
|
|
if (Triple.getArch() == llvm::Triple::x86 ||
|
|
|
|
Triple.getArch() == llvm::Triple::ppc)
|
2012-09-14 19:27:24 +08:00
|
|
|
return "lib32";
|
|
|
|
|
2014-07-10 23:27:19 +08:00
|
|
|
if (Triple.getArch() == llvm::Triple::x86_64 &&
|
|
|
|
Triple.getEnvironment() == llvm::Triple::GNUX32)
|
|
|
|
return "libx32";
|
|
|
|
|
2012-09-14 19:27:24 +08:00
|
|
|
return Triple.isArch32Bit() ? "lib" : "lib64";
|
|
|
|
}
|
|
|
|
|
2012-02-19 09:38:32 +08:00
|
|
|
Linux::Linux(const Driver &D, const llvm::Triple &Triple, const ArgList &Args)
|
|
|
|
: Generic_ELF(D, Triple, Args) {
|
2013-12-07 02:32:18 +08:00
|
|
|
GCCInstallation.init(D, Triple, Args);
|
2014-02-12 11:21:20 +08:00
|
|
|
Multilibs = GCCInstallation.getMultilibs();
|
2012-01-25 04:08:17 +08:00
|
|
|
llvm::Triple::ArchType Arch = Triple.getArch();
|
2013-10-05 22:37:55 +08:00
|
|
|
std::string SysRoot = computeSysRoot();
|
2010-11-08 04:14:31 +08:00
|
|
|
|
2013-07-03 22:14:00 +08:00
|
|
|
// Cross-compiling binutils and GCC installations (vanilla and openSUSE at
|
2013-06-21 07:37:54 +08:00
|
|
|
// least) put various tools in a triple-prefixed directory off of the parent
|
|
|
|
// of the GCC installation. We use the GCC triple here to ensure that we end
|
|
|
|
// up with tools that support the same amount of cross compiling as the
|
|
|
|
// detected GCC installation. For example, if we find a GCC installation
|
|
|
|
// targeting x86_64, but it is a bi-arch GCC installation, it can also be
|
|
|
|
// used to target i386.
|
|
|
|
// FIXME: This seems unlikely to be Linux-specific.
|
2011-09-02 00:25:49 +08:00
|
|
|
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
|
|
|
|
2014-06-26 22:23:45 +08:00
|
|
|
Linker = GetLinkerPath();
|
2010-11-08 04:14:31 +08:00
|
|
|
|
2013-10-29 07:14:34 +08:00
|
|
|
Distro Distro = DetectDistro(Arch);
|
2010-11-08 04:14:31 +08:00
|
|
|
|
2013-07-03 22:14:00 +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");
|
|
|
|
|
2012-09-02 17:30:11 +08:00
|
|
|
const bool IsAndroid = Triple.getEnvironment() == llvm::Triple::Android;
|
2013-04-20 16:15:03 +08:00
|
|
|
const bool IsMips = isMipsArch(Arch);
|
|
|
|
|
|
|
|
if (IsMips && !SysRoot.empty())
|
|
|
|
ExtraOpts.push_back("--sysroot=" + SysRoot);
|
2012-01-13 17:30:38 +08:00
|
|
|
|
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.
|
2013-04-20 16:15:03 +08:00
|
|
|
if (!IsMips && !IsAndroid) {
|
2013-07-03 22:14:00 +08:00
|
|
|
if (IsRedhat(Distro) || IsOpenSUSE(Distro) ||
|
2012-02-06 22:36:09 +08:00
|
|
|
(IsUbuntu(Distro) && Distro >= UbuntuMaverick))
|
2011-12-09 12:45:18 +08:00
|
|
|
ExtraOpts.push_back("--hash-style=gnu");
|
|
|
|
|
2013-07-03 22:14:00 +08:00
|
|
|
if (IsDebian(Distro) || IsOpenSUSE(Distro) || Distro == UbuntuLucid ||
|
2011-12-09 12:45:18 +08:00
|
|
|
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 ||
|
2013-07-03 22:14:00 +08:00
|
|
|
Distro == DebianJessie || IsOpenSUSE(Distro) ||
|
2011-06-03 23:23:24 +08:00
|
|
|
(IsRedhat(Distro) && Distro != RHEL4 && Distro != RHEL5) ||
|
2012-02-06 22:36:09 +08:00
|
|
|
(IsUbuntu(Distro) && Distro >= UbuntuKarmic))
|
2010-11-08 04:14:31 +08:00
|
|
|
ExtraOpts.push_back("--build-id");
|
|
|
|
|
2013-07-03 22:14:00 +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
|
|
|
|
2014-02-12 11:21:20 +08:00
|
|
|
const std::string OSLibDir = getOSLibDir(Triple, Args);
|
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();
|
2014-02-12 11:21:20 +08:00
|
|
|
const Multilib &Multilib = GCCInstallation.getMultilib();
|
2012-10-04 01:46:38 +08:00
|
|
|
|
2013-07-31 08:37:07 +08:00
|
|
|
// Sourcery CodeBench MIPS toolchain holds some libraries under
|
2013-10-29 10:27:56 +08:00
|
|
|
// a biarch-like suffix of the GCC installation.
|
2014-02-12 11:21:20 +08:00
|
|
|
addPathIfExists((GCCInstallation.getInstallPath() +
|
|
|
|
Multilib.gccSuffix()),
|
|
|
|
Paths);
|
2013-07-31 08:37:07 +08:00
|
|
|
|
|
|
|
// GCC cross compiling toolchains will install target libraries which ship
|
|
|
|
// as part of the toolchain under <prefix>/<triple>/<libdir> rather than as
|
|
|
|
// any part of the GCC installation in
|
|
|
|
// <prefix>/<libdir>/gcc/<triple>/<version>. This decision is somewhat
|
|
|
|
// debatable, but is the reality today. We need to search this tree even
|
|
|
|
// when we have a sysroot somewhere else. It is the responsibility of
|
2013-12-06 00:25:25 +08:00
|
|
|
// whomever is doing the cross build targeting a sysroot using a GCC
|
2013-07-31 08:37:07 +08:00
|
|
|
// installation that is *not* within the system root to ensure two things:
|
|
|
|
//
|
|
|
|
// 1) Any DSOs that are linked in from this tree or from the install path
|
2014-09-01 20:35:57 +08:00
|
|
|
// above must be present on the system root and found via an
|
2013-07-31 08:37:07 +08:00
|
|
|
// appropriate rpath.
|
|
|
|
// 2) There must not be libraries installed into
|
|
|
|
// <prefix>/<triple>/<libdir> unless they should be preferred over
|
|
|
|
// those within the system root.
|
|
|
|
//
|
|
|
|
// Note that this matches the GCC behavior. See the below comment for where
|
|
|
|
// Clang diverges from GCC's behavior.
|
2014-02-12 11:21:20 +08:00
|
|
|
addPathIfExists(LibPath + "/../" + GCCTriple.str() + "/lib/../" + OSLibDir +
|
|
|
|
Multilib.osSuffix(),
|
2013-07-31 08:37:07 +08:00
|
|
|
Paths);
|
|
|
|
|
Fix using Clang as a cross compiler installed on a host machine and not
inside of a sysroot targeting a system+sysroot which is "similar" or
"compatible" with the host system. This shows up when trying to build
system images on largely compatible hardware as-if fully cross compiled.
The problem is that previously we *perfectly* mimiced GCC here, and it
turns out GCC has a bug that no one has really stumbled across. GCC will
try to look in thy system prefix ('/usr/local' f.ex.) into which it is
instaled to find libraries installed along side GCC that should be
preferred to the base system libraries ('/usr' f.ex.). This seems not
unreasonable, but it has a very unfortunate consequence when combined
with a '--sysroot' which does *not* contain the GCC installation we're
using to complete the toolchain. That results in some of the host
system's library directories being searched during the link.
Now, it so happens that most folks doing stuff like this use
'--with-sysroot' and '--disable-multilib' when configuring GCC. Even
better, they're usually not cross-compiling to a target that is similar
to the host. As a result, searching the host for libraries doesn't
really matter -- most of the time weird directories get appended that
don't exist (no arm triple lib directory, etc). Even if you're
cross-compiling from 32-bit to 64-bit x86 or vice-versa, disabling
multilib makes it less likely that you'll actually find viable libraries
on the host. But that's just luck. We shouldn't rely on this, and this
patch disables looking in the system prefix containing the GCC
installation if that system prefix is *outside* of the sysroot. For
empty sysroots, this has no effect. Similarly, when using the GCC
*inside* of the sysroot, we still track wherever it is installed within
the sysroot and look there for libraries. But now we can use a cross
compiler GCC installation outside the system root, and only look for the
crtbegin.o in the GCC installation, and look for all the other libraries
inside the system root.
This should fix PR12478, allowing Clang to be used when building
a ChromiumOS image without polluting the image with libraries from the
host system.
llvm-svn: 154176
2012-04-07 00:32:06 +08:00
|
|
|
// If the GCC installation we found is inside of the sysroot, we want to
|
|
|
|
// prefer libraries installed in the parent prefix of the GCC installation.
|
|
|
|
// It is important to *not* use these paths when the GCC installation is
|
2012-04-18 18:59:08 +08:00
|
|
|
// outside of the system root as that can pick up unintended libraries.
|
Fix using Clang as a cross compiler installed on a host machine and not
inside of a sysroot targeting a system+sysroot which is "similar" or
"compatible" with the host system. This shows up when trying to build
system images on largely compatible hardware as-if fully cross compiled.
The problem is that previously we *perfectly* mimiced GCC here, and it
turns out GCC has a bug that no one has really stumbled across. GCC will
try to look in thy system prefix ('/usr/local' f.ex.) into which it is
instaled to find libraries installed along side GCC that should be
preferred to the base system libraries ('/usr' f.ex.). This seems not
unreasonable, but it has a very unfortunate consequence when combined
with a '--sysroot' which does *not* contain the GCC installation we're
using to complete the toolchain. That results in some of the host
system's library directories being searched during the link.
Now, it so happens that most folks doing stuff like this use
'--with-sysroot' and '--disable-multilib' when configuring GCC. Even
better, they're usually not cross-compiling to a target that is similar
to the host. As a result, searching the host for libraries doesn't
really matter -- most of the time weird directories get appended that
don't exist (no arm triple lib directory, etc). Even if you're
cross-compiling from 32-bit to 64-bit x86 or vice-versa, disabling
multilib makes it less likely that you'll actually find viable libraries
on the host. But that's just luck. We shouldn't rely on this, and this
patch disables looking in the system prefix containing the GCC
installation if that system prefix is *outside* of the sysroot. For
empty sysroots, this has no effect. Similarly, when using the GCC
*inside* of the sysroot, we still track wherever it is installed within
the sysroot and look there for libraries. But now we can use a cross
compiler GCC installation outside the system root, and only look for the
crtbegin.o in the GCC installation, and look for all the other libraries
inside the system root.
This should fix PR12478, allowing Clang to be used when building
a ChromiumOS image without polluting the image with libraries from the
host system.
llvm-svn: 154176
2012-04-07 00:32:06 +08:00
|
|
|
// This usually happens when there is an external cross compiler on the
|
|
|
|
// host system, and a more minimal sysroot available that is the target of
|
2013-07-31 08:37:07 +08:00
|
|
|
// the cross. Note that GCC does include some of these directories in some
|
|
|
|
// configurations but this seems somewhere between questionable and simply
|
|
|
|
// a bug.
|
Fix using Clang as a cross compiler installed on a host machine and not
inside of a sysroot targeting a system+sysroot which is "similar" or
"compatible" with the host system. This shows up when trying to build
system images on largely compatible hardware as-if fully cross compiled.
The problem is that previously we *perfectly* mimiced GCC here, and it
turns out GCC has a bug that no one has really stumbled across. GCC will
try to look in thy system prefix ('/usr/local' f.ex.) into which it is
instaled to find libraries installed along side GCC that should be
preferred to the base system libraries ('/usr' f.ex.). This seems not
unreasonable, but it has a very unfortunate consequence when combined
with a '--sysroot' which does *not* contain the GCC installation we're
using to complete the toolchain. That results in some of the host
system's library directories being searched during the link.
Now, it so happens that most folks doing stuff like this use
'--with-sysroot' and '--disable-multilib' when configuring GCC. Even
better, they're usually not cross-compiling to a target that is similar
to the host. As a result, searching the host for libraries doesn't
really matter -- most of the time weird directories get appended that
don't exist (no arm triple lib directory, etc). Even if you're
cross-compiling from 32-bit to 64-bit x86 or vice-versa, disabling
multilib makes it less likely that you'll actually find viable libraries
on the host. But that's just luck. We shouldn't rely on this, and this
patch disables looking in the system prefix containing the GCC
installation if that system prefix is *outside* of the sysroot. For
empty sysroots, this has no effect. Similarly, when using the GCC
*inside* of the sysroot, we still track wherever it is installed within
the sysroot and look there for libraries. But now we can use a cross
compiler GCC installation outside the system root, and only look for the
crtbegin.o in the GCC installation, and look for all the other libraries
inside the system root.
This should fix PR12478, allowing Clang to be used when building
a ChromiumOS image without polluting the image with libraries from the
host system.
llvm-svn: 154176
2012-04-07 00:32:06 +08:00
|
|
|
if (StringRef(LibPath).startswith(SysRoot)) {
|
|
|
|
addPathIfExists(LibPath + "/" + MultiarchTriple, Paths);
|
2014-02-12 11:21:20 +08:00
|
|
|
addPathIfExists(LibPath + "/../" + OSLibDir, Paths);
|
Fix using Clang as a cross compiler installed on a host machine and not
inside of a sysroot targeting a system+sysroot which is "similar" or
"compatible" with the host system. This shows up when trying to build
system images on largely compatible hardware as-if fully cross compiled.
The problem is that previously we *perfectly* mimiced GCC here, and it
turns out GCC has a bug that no one has really stumbled across. GCC will
try to look in thy system prefix ('/usr/local' f.ex.) into which it is
instaled to find libraries installed along side GCC that should be
preferred to the base system libraries ('/usr' f.ex.). This seems not
unreasonable, but it has a very unfortunate consequence when combined
with a '--sysroot' which does *not* contain the GCC installation we're
using to complete the toolchain. That results in some of the host
system's library directories being searched during the link.
Now, it so happens that most folks doing stuff like this use
'--with-sysroot' and '--disable-multilib' when configuring GCC. Even
better, they're usually not cross-compiling to a target that is similar
to the host. As a result, searching the host for libraries doesn't
really matter -- most of the time weird directories get appended that
don't exist (no arm triple lib directory, etc). Even if you're
cross-compiling from 32-bit to 64-bit x86 or vice-versa, disabling
multilib makes it less likely that you'll actually find viable libraries
on the host. But that's just luck. We shouldn't rely on this, and this
patch disables looking in the system prefix containing the GCC
installation if that system prefix is *outside* of the sysroot. For
empty sysroots, this has no effect. Similarly, when using the GCC
*inside* of the sysroot, we still track wherever it is installed within
the sysroot and look there for libraries. But now we can use a cross
compiler GCC installation outside the system root, and only look for the
crtbegin.o in the GCC installation, and look for all the other libraries
inside the system root.
This should fix PR12478, allowing Clang to be used when building
a ChromiumOS image without polluting the image with libraries from the
host system.
llvm-svn: 154176
2012-04-07 00:32:06 +08:00
|
|
|
}
|
2010-11-08 04:14:31 +08:00
|
|
|
}
|
2014-01-22 06:49:05 +08:00
|
|
|
|
|
|
|
// Similar to the logic for GCC above, if we currently running Clang inside
|
2014-02-12 11:21:20 +08:00
|
|
|
// of the requested system root, add its parent library paths to
|
2014-01-22 06:49:05 +08:00
|
|
|
// those searched.
|
|
|
|
// FIXME: It's not clear whether we should use the driver's installed
|
|
|
|
// directory ('Dir' below) or the ResourceDir.
|
|
|
|
if (StringRef(D.Dir).startswith(SysRoot)) {
|
|
|
|
addPathIfExists(D.Dir + "/../lib/" + MultiarchTriple, Paths);
|
2014-02-12 11:21:20 +08:00
|
|
|
addPathIfExists(D.Dir + "/../" + OSLibDir, Paths);
|
2014-01-22 06:49:05 +08:00
|
|
|
}
|
|
|
|
|
2011-11-07 07:09:05 +08:00
|
|
|
addPathIfExists(SysRoot + "/lib/" + MultiarchTriple, Paths);
|
2014-02-12 11:21:20 +08:00
|
|
|
addPathIfExists(SysRoot + "/lib/../" + OSLibDir, Paths);
|
2011-11-07 07:09:05 +08:00
|
|
|
addPathIfExists(SysRoot + "/usr/lib/" + MultiarchTriple, Paths);
|
2014-02-12 11:21:20 +08:00
|
|
|
addPathIfExists(SysRoot + "/usr/lib/../" + OSLibDir, Paths);
|
2011-11-07 07:09:05 +08:00
|
|
|
|
2013-06-22 19:35:51 +08:00
|
|
|
// Try walking via the GCC triple path in case of biarch or multiarch GCC
|
2011-11-07 07:09:05 +08:00
|
|
|
// installations with strange symlinks.
|
2013-10-26 01:06:04 +08:00
|
|
|
if (GCCInstallation.isValid()) {
|
2012-01-25 03:28:29 +08:00
|
|
|
addPathIfExists(SysRoot + "/usr/lib/" + GCCInstallation.getTriple().str() +
|
2014-02-12 11:21:20 +08:00
|
|
|
"/../../" + OSLibDir, Paths);
|
2011-06-03 23:39:42 +08:00
|
|
|
|
2014-02-12 11:21:20 +08:00
|
|
|
// Add the 'other' biarch variant path
|
|
|
|
Multilib BiarchSibling;
|
|
|
|
if (GCCInstallation.getBiarchSibling(BiarchSibling)) {
|
2013-10-10 15:57:44 +08:00
|
|
|
addPathIfExists(GCCInstallation.getInstallPath() +
|
2014-02-12 11:21:20 +08:00
|
|
|
BiarchSibling.gccSuffix(), Paths);
|
|
|
|
}
|
Fix using Clang as a cross compiler installed on a host machine and not
inside of a sysroot targeting a system+sysroot which is "similar" or
"compatible" with the host system. This shows up when trying to build
system images on largely compatible hardware as-if fully cross compiled.
The problem is that previously we *perfectly* mimiced GCC here, and it
turns out GCC has a bug that no one has really stumbled across. GCC will
try to look in thy system prefix ('/usr/local' f.ex.) into which it is
instaled to find libraries installed along side GCC that should be
preferred to the base system libraries ('/usr' f.ex.). This seems not
unreasonable, but it has a very unfortunate consequence when combined
with a '--sysroot' which does *not* contain the GCC installation we're
using to complete the toolchain. That results in some of the host
system's library directories being searched during the link.
Now, it so happens that most folks doing stuff like this use
'--with-sysroot' and '--disable-multilib' when configuring GCC. Even
better, they're usually not cross-compiling to a target that is similar
to the host. As a result, searching the host for libraries doesn't
really matter -- most of the time weird directories get appended that
don't exist (no arm triple lib directory, etc). Even if you're
cross-compiling from 32-bit to 64-bit x86 or vice-versa, disabling
multilib makes it less likely that you'll actually find viable libraries
on the host. But that's just luck. We shouldn't rely on this, and this
patch disables looking in the system prefix containing the GCC
installation if that system prefix is *outside* of the sysroot. For
empty sysroots, this has no effect. Similarly, when using the GCC
*inside* of the sysroot, we still track wherever it is installed within
the sysroot and look there for libraries. But now we can use a cross
compiler GCC installation outside the system root, and only look for the
crtbegin.o in the GCC installation, and look for all the other libraries
inside the system root.
This should fix PR12478, allowing Clang to be used when building
a ChromiumOS image without polluting the image with libraries from the
host system.
llvm-svn: 154176
2012-04-07 00:32:06 +08:00
|
|
|
|
2013-07-31 08:37:07 +08:00
|
|
|
// See comments above on the multilib variant for details of why this is
|
|
|
|
// included even from outside the sysroot.
|
2014-02-12 11:21:20 +08:00
|
|
|
const std::string &LibPath = GCCInstallation.getParentLibPath();
|
|
|
|
const llvm::Triple &GCCTriple = GCCInstallation.getTriple();
|
|
|
|
const Multilib &Multilib = GCCInstallation.getMultilib();
|
2013-10-10 15:57:44 +08:00
|
|
|
addPathIfExists(LibPath + "/../" + GCCTriple.str() +
|
2014-02-12 11:21:20 +08:00
|
|
|
"/lib" + Multilib.osSuffix(), Paths);
|
2013-07-31 08:37:07 +08:00
|
|
|
|
|
|
|
// See comments above on the multilib variant for details of why this is
|
|
|
|
// only included from within the sysroot.
|
|
|
|
if (StringRef(LibPath).startswith(SysRoot))
|
Fix using Clang as a cross compiler installed on a host machine and not
inside of a sysroot targeting a system+sysroot which is "similar" or
"compatible" with the host system. This shows up when trying to build
system images on largely compatible hardware as-if fully cross compiled.
The problem is that previously we *perfectly* mimiced GCC here, and it
turns out GCC has a bug that no one has really stumbled across. GCC will
try to look in thy system prefix ('/usr/local' f.ex.) into which it is
instaled to find libraries installed along side GCC that should be
preferred to the base system libraries ('/usr' f.ex.). This seems not
unreasonable, but it has a very unfortunate consequence when combined
with a '--sysroot' which does *not* contain the GCC installation we're
using to complete the toolchain. That results in some of the host
system's library directories being searched during the link.
Now, it so happens that most folks doing stuff like this use
'--with-sysroot' and '--disable-multilib' when configuring GCC. Even
better, they're usually not cross-compiling to a target that is similar
to the host. As a result, searching the host for libraries doesn't
really matter -- most of the time weird directories get appended that
don't exist (no arm triple lib directory, etc). Even if you're
cross-compiling from 32-bit to 64-bit x86 or vice-versa, disabling
multilib makes it less likely that you'll actually find viable libraries
on the host. But that's just luck. We shouldn't rely on this, and this
patch disables looking in the system prefix containing the GCC
installation if that system prefix is *outside* of the sysroot. For
empty sysroots, this has no effect. Similarly, when using the GCC
*inside* of the sysroot, we still track wherever it is installed within
the sysroot and look there for libraries. But now we can use a cross
compiler GCC installation outside the system root, and only look for the
crtbegin.o in the GCC installation, and look for all the other libraries
inside the system root.
This should fix PR12478, allowing Clang to be used when building
a ChromiumOS image without polluting the image with libraries from the
host system.
llvm-svn: 154176
2012-04-07 00:32:06 +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
|
|
|
}
|
2014-01-22 06:49:05 +08:00
|
|
|
|
|
|
|
// Similar to the logic for GCC above, if we are currently running Clang
|
|
|
|
// inside of the requested system root, add its parent library path to those
|
|
|
|
// searched.
|
|
|
|
// FIXME: It's not clear whether we should use the driver's installed
|
|
|
|
// directory ('Dir' below) or the ResourceDir.
|
|
|
|
if (StringRef(D.Dir).startswith(SysRoot))
|
|
|
|
addPathIfExists(D.Dir + "/../lib", Paths);
|
|
|
|
|
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
|
|
|
}
|
|
|
|
|
2013-03-20 11:05:54 +08:00
|
|
|
Tool *Linux::buildLinker() const {
|
2013-03-29 03:04:25 +08:00
|
|
|
return new tools::gnutools::Link(*this);
|
2013-03-20 11:05:54 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
Tool *Linux::buildAssembler() const {
|
2013-03-29 03:04:25 +08:00
|
|
|
return new tools::gnutools::Assemble(*this);
|
2010-08-10 08:25:48 +08:00
|
|
|
}
|
|
|
|
|
2013-10-05 22:37:55 +08:00
|
|
|
std::string Linux::computeSysRoot() const {
|
2013-04-20 16:15:03 +08:00
|
|
|
if (!getDriver().SysRoot.empty())
|
|
|
|
return getDriver().SysRoot;
|
|
|
|
|
|
|
|
if (!GCCInstallation.isValid() || !isMipsArch(getTriple().getArch()))
|
|
|
|
return std::string();
|
|
|
|
|
2013-10-10 15:57:44 +08:00
|
|
|
// Standalone MIPS toolchains use different names for sysroot folder
|
|
|
|
// and put it into different places. Here we try to check some known
|
|
|
|
// variants.
|
|
|
|
|
|
|
|
const StringRef InstallDir = GCCInstallation.getInstallPath();
|
|
|
|
const StringRef TripleStr = GCCInstallation.getTriple().str();
|
2014-02-12 11:21:20 +08:00
|
|
|
const Multilib &Multilib = GCCInstallation.getMultilib();
|
2013-10-10 15:57:44 +08:00
|
|
|
|
2013-10-29 16:53:03 +08:00
|
|
|
std::string Path = (InstallDir + "/../../../../" + TripleStr + "/libc" +
|
2014-02-12 11:21:20 +08:00
|
|
|
Multilib.osSuffix()).str();
|
2013-04-20 16:15:03 +08:00
|
|
|
|
2013-10-10 15:57:44 +08:00
|
|
|
if (llvm::sys::fs::exists(Path))
|
|
|
|
return Path;
|
|
|
|
|
2014-02-12 11:21:20 +08:00
|
|
|
Path = (InstallDir + "/../../../../sysroot" + Multilib.osSuffix()).str();
|
2013-10-10 15:57:44 +08:00
|
|
|
|
|
|
|
if (llvm::sys::fs::exists(Path))
|
|
|
|
return Path;
|
|
|
|
|
|
|
|
return std::string();
|
2013-04-20 16:15:03 +08:00
|
|
|
}
|
|
|
|
|
2011-11-06 04:17:13 +08:00
|
|
|
void Linux::AddClangSystemIncludeArgs(const ArgList &DriverArgs,
|
|
|
|
ArgStringList &CC1Args) const {
|
|
|
|
const Driver &D = getDriver();
|
2013-10-05 22:37:55 +08:00
|
|
|
std::string SysRoot = computeSysRoot();
|
2011-11-06 04:17:13 +08:00
|
|
|
|
|
|
|
if (DriverArgs.hasArg(options::OPT_nostdinc))
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (!DriverArgs.hasArg(options::OPT_nostdlibinc))
|
2013-04-20 16:15:03 +08:00
|
|
|
addSystemInclude(DriverArgs, CC1Args, SysRoot + "/usr/local/include");
|
2011-11-06 04:17:13 +08:00
|
|
|
|
|
|
|
if (!DriverArgs.hasArg(options::OPT_nobuiltininc)) {
|
2013-06-26 10:13:00 +08:00
|
|
|
SmallString<128> P(D.ResourceDir);
|
|
|
|
llvm::sys::path::append(P, "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, ":");
|
2014-05-09 03:32:46 +08:00
|
|
|
for (StringRef dir : dirs) {
|
2015-02-19 02:45:54 +08:00
|
|
|
StringRef Prefix =
|
|
|
|
llvm::sys::path::is_absolute(dir) ? StringRef(SysRoot) : "";
|
2014-05-09 03:32:46 +08:00
|
|
|
addExternCSystemInclude(DriverArgs, CC1Args, Prefix + dir);
|
2011-11-06 04:17:13 +08:00
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Lacking those, try to detect the correct set of system includes for the
|
|
|
|
// target triple.
|
|
|
|
|
2014-08-06 13:44:47 +08:00
|
|
|
// Add include directories specific to the selected multilib set and multilib.
|
|
|
|
if (GCCInstallation.isValid()) {
|
|
|
|
auto Callback = Multilibs.includeDirsCallback();
|
|
|
|
if (Callback) {
|
|
|
|
const auto IncludePaths = Callback(GCCInstallation.getInstallPath(),
|
|
|
|
GCCInstallation.getTriple().str(),
|
|
|
|
GCCInstallation.getMultilib());
|
|
|
|
for (const auto &Path : IncludePaths)
|
|
|
|
addExternCSystemIncludeIfExists(DriverArgs, CC1Args, Path);
|
|
|
|
}
|
2013-04-20 16:15:03 +08:00
|
|
|
}
|
|
|
|
|
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.
|
2013-06-22 19:35:51 +08:00
|
|
|
"/usr/include/i686-linux-gnu/64", "/usr/include/i486-linux-gnu/64"
|
2011-11-06 16:21:07 +08:00
|
|
|
};
|
|
|
|
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.
|
2013-06-22 19:35:51 +08:00
|
|
|
"/usr/include/x86_64-linux-gnu/32", "/usr/include/i686-linux-gnu",
|
2011-11-06 16:21:07 +08:00
|
|
|
"/usr/include/i486-linux-gnu"
|
|
|
|
};
|
2013-01-31 20:13:10 +08:00
|
|
|
const StringRef AArch64MultiarchIncludeDirs[] = {
|
|
|
|
"/usr/include/aarch64-linux-gnu"
|
|
|
|
};
|
2011-11-06 16:21:07 +08:00
|
|
|
const StringRef ARMMultiarchIncludeDirs[] = {
|
|
|
|
"/usr/include/arm-linux-gnueabi"
|
|
|
|
};
|
2012-07-31 16:06:29 +08:00
|
|
|
const StringRef ARMHFMultiarchIncludeDirs[] = {
|
|
|
|
"/usr/include/arm-linux-gnueabihf"
|
|
|
|
};
|
2011-11-11 11:05:19 +08:00
|
|
|
const StringRef MIPSMultiarchIncludeDirs[] = {
|
|
|
|
"/usr/include/mips-linux-gnu"
|
|
|
|
};
|
|
|
|
const StringRef MIPSELMultiarchIncludeDirs[] = {
|
|
|
|
"/usr/include/mipsel-linux-gnu"
|
|
|
|
};
|
2014-06-25 03:00:12 +08:00
|
|
|
const StringRef MIPS64MultiarchIncludeDirs[] = {
|
|
|
|
"/usr/include/mips64-linux-gnu",
|
|
|
|
"/usr/include/mips64-linux-gnuabi64"
|
|
|
|
};
|
|
|
|
const StringRef MIPS64ELMultiarchIncludeDirs[] = {
|
|
|
|
"/usr/include/mips64el-linux-gnu",
|
|
|
|
"/usr/include/mips64el-linux-gnuabi64"
|
|
|
|
};
|
2012-02-26 17:21:43 +08:00
|
|
|
const StringRef PPCMultiarchIncludeDirs[] = {
|
|
|
|
"/usr/include/powerpc-linux-gnu"
|
|
|
|
};
|
|
|
|
const StringRef PPC64MultiarchIncludeDirs[] = {
|
|
|
|
"/usr/include/powerpc64-linux-gnu"
|
|
|
|
};
|
2014-06-20 21:41:24 +08:00
|
|
|
const StringRef PPC64LEMultiarchIncludeDirs[] = {
|
|
|
|
"/usr/include/powerpc64le-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;
|
2014-03-29 23:09:45 +08:00
|
|
|
} else if (getTriple().getArch() == llvm::Triple::aarch64 ||
|
2014-07-23 20:32:58 +08:00
|
|
|
getTriple().getArch() == llvm::Triple::aarch64_be) {
|
2013-01-31 20:13:10 +08:00
|
|
|
MultiarchIncludeDirs = AArch64MultiarchIncludeDirs;
|
2011-11-06 04:17:13 +08:00
|
|
|
} else if (getTriple().getArch() == llvm::Triple::arm) {
|
2012-07-31 16:06:29 +08:00
|
|
|
if (getTriple().getEnvironment() == llvm::Triple::GNUEABIHF)
|
|
|
|
MultiarchIncludeDirs = ARMHFMultiarchIncludeDirs;
|
|
|
|
else
|
|
|
|
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;
|
2014-06-25 03:00:12 +08:00
|
|
|
} else if (getTriple().getArch() == llvm::Triple::mips64) {
|
|
|
|
MultiarchIncludeDirs = MIPS64MultiarchIncludeDirs;
|
|
|
|
} else if (getTriple().getArch() == llvm::Triple::mips64el) {
|
|
|
|
MultiarchIncludeDirs = MIPS64ELMultiarchIncludeDirs;
|
2012-02-26 17:21:43 +08:00
|
|
|
} else if (getTriple().getArch() == llvm::Triple::ppc) {
|
|
|
|
MultiarchIncludeDirs = PPCMultiarchIncludeDirs;
|
|
|
|
} else if (getTriple().getArch() == llvm::Triple::ppc64) {
|
|
|
|
MultiarchIncludeDirs = PPC64MultiarchIncludeDirs;
|
2014-06-20 21:41:24 +08:00
|
|
|
} else if (getTriple().getArch() == llvm::Triple::ppc64le) {
|
|
|
|
MultiarchIncludeDirs = PPC64LEMultiarchIncludeDirs;
|
2011-11-06 16:21:07 +08:00
|
|
|
}
|
2014-05-09 03:32:46 +08:00
|
|
|
for (StringRef Dir : MultiarchIncludeDirs) {
|
|
|
|
if (llvm::sys::fs::exists(SysRoot + Dir)) {
|
|
|
|
addExternCSystemInclude(DriverArgs, CC1Args, SysRoot + Dir);
|
2011-11-06 16:21:07 +08:00
|
|
|
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.
|
2013-04-20 16:15:03 +08:00
|
|
|
addExternCSystemInclude(DriverArgs, CC1Args, SysRoot + "/include");
|
2011-11-09 01:19:47 +08:00
|
|
|
|
2013-04-20 16:15:03 +08:00
|
|
|
addExternCSystemInclude(DriverArgs, CC1Args, SysRoot + "/usr/include");
|
2011-11-06 04:17:13 +08:00
|
|
|
}
|
|
|
|
|
2014-08-27 16:41:41 +08:00
|
|
|
/// \brief Helper to add the variant paths of a libstdc++ installation.
|
2013-03-07 01:14:05 +08:00
|
|
|
/*static*/ bool Linux::addLibStdCXXIncludePaths(Twine Base, Twine Suffix,
|
2014-08-27 16:41:41 +08:00
|
|
|
StringRef GCCTriple,
|
|
|
|
StringRef GCCMultiarchTriple,
|
|
|
|
StringRef TargetMultiarchTriple,
|
2014-02-12 11:21:20 +08:00
|
|
|
Twine IncludeSuffix,
|
2013-03-07 01:14:05 +08:00
|
|
|
const ArgList &DriverArgs,
|
|
|
|
ArgStringList &CC1Args) {
|
2014-08-28 02:21:27 +08:00
|
|
|
if (!llvm::sys::fs::exists(Base + Suffix))
|
2013-03-07 01:14:05 +08:00
|
|
|
return false;
|
|
|
|
|
2014-08-27 16:41:41 +08:00
|
|
|
addSystemInclude(DriverArgs, CC1Args, Base + Suffix);
|
|
|
|
|
|
|
|
// The vanilla GCC layout of libstdc++ headers uses a triple subdirectory. If
|
|
|
|
// that path exists or we have neither a GCC nor target multiarch triple, use
|
|
|
|
// this vanilla search path.
|
|
|
|
if ((GCCMultiarchTriple.empty() && TargetMultiarchTriple.empty()) ||
|
|
|
|
llvm::sys::fs::exists(Base + Suffix + "/" + GCCTriple + IncludeSuffix)) {
|
|
|
|
addSystemInclude(DriverArgs, CC1Args,
|
|
|
|
Base + Suffix + "/" + GCCTriple + IncludeSuffix);
|
|
|
|
} else {
|
|
|
|
// Otherwise try to use multiarch naming schemes which have normalized the
|
|
|
|
// triples and put the triple before the suffix.
|
|
|
|
//
|
|
|
|
// GCC surprisingly uses *both* the GCC triple with a multilib suffix and
|
|
|
|
// the target triple, so we support that here.
|
|
|
|
addSystemInclude(DriverArgs, CC1Args,
|
|
|
|
Base + "/" + GCCMultiarchTriple + Suffix + IncludeSuffix);
|
|
|
|
addSystemInclude(DriverArgs, CC1Args,
|
|
|
|
Base + "/" + TargetMultiarchTriple + Suffix);
|
|
|
|
}
|
|
|
|
|
|
|
|
addSystemInclude(DriverArgs, CC1Args, Base + Suffix + "/backward");
|
2013-03-07 01:14:05 +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) {
|
2014-01-20 17:42:24 +08:00
|
|
|
const std::string LibCXXIncludePathCandidates[] = {
|
|
|
|
// The primary location is within the Clang installation.
|
|
|
|
// FIXME: We shouldn't hard code 'v1' here to make Clang future proof to
|
|
|
|
// newer ABI versions.
|
|
|
|
getDriver().Dir + "/../include/c++/v1",
|
|
|
|
|
|
|
|
// We also check the system as for a long time this is the only place Clang looked.
|
|
|
|
// FIXME: We should really remove this. It doesn't make any sense.
|
|
|
|
getDriver().SysRoot + "/usr/include/c++/v1"
|
|
|
|
};
|
2014-05-09 03:32:46 +08:00
|
|
|
for (const auto &IncludePath : LibCXXIncludePathCandidates) {
|
|
|
|
if (!llvm::sys::fs::exists(IncludePath))
|
2014-01-20 17:42:24 +08:00
|
|
|
continue;
|
|
|
|
// Add the first candidate that exists.
|
2014-05-09 03:32:46 +08:00
|
|
|
addSystemInclude(DriverArgs, CC1Args, IncludePath);
|
2014-01-20 17:42:24 +08:00
|
|
|
break;
|
|
|
|
}
|
2011-11-07 17:01:17 +08:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
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();
|
2012-09-03 17:05:50 +08:00
|
|
|
StringRef TripleStr = GCCInstallation.getTriple().str();
|
2014-02-12 11:21:20 +08:00
|
|
|
const Multilib &Multilib = GCCInstallation.getMultilib();
|
2014-08-27 16:41:41 +08:00
|
|
|
const std::string GCCMultiarchTriple =
|
|
|
|
getMultiarchTriple(GCCInstallation.getTriple(), getDriver().SysRoot);
|
|
|
|
const std::string TargetMultiarchTriple =
|
|
|
|
getMultiarchTriple(getTriple(), getDriver().SysRoot);
|
2013-08-26 16:59:53 +08:00
|
|
|
const GCCVersion &Version = GCCInstallation.getVersion();
|
2012-09-03 17:05:50 +08:00
|
|
|
|
2014-08-27 16:41:41 +08:00
|
|
|
// The primary search for libstdc++ supports multiarch variants.
|
2013-10-29 16:53:03 +08:00
|
|
|
if (addLibStdCXXIncludePaths(LibDir.str() + "/../include",
|
2014-08-27 16:41:41 +08:00
|
|
|
"/c++/" + Version.Text, TripleStr, GCCMultiarchTriple,
|
|
|
|
TargetMultiarchTriple,
|
2014-02-12 11:21:20 +08:00
|
|
|
Multilib.includeSuffix(), DriverArgs, CC1Args))
|
2013-03-07 01:14:05 +08:00
|
|
|
return;
|
|
|
|
|
2014-08-27 16:41:41 +08:00
|
|
|
// Otherwise, fall back on a bunch of options which don't use multiarch
|
|
|
|
// layouts for simplicity.
|
2014-01-20 17:42:24 +08:00
|
|
|
const std::string LibStdCXXIncludePathCandidates[] = {
|
2011-11-06 18:31:01 +08:00
|
|
|
// Gentoo is weird and places its headers inside the GCC install, so if the
|
2013-08-26 16:59:53 +08:00
|
|
|
// first attempt to find the headers fails, try these patterns.
|
|
|
|
InstallDir.str() + "/include/g++-v" + Version.MajorStr + "." +
|
|
|
|
Version.MinorStr,
|
|
|
|
InstallDir.str() + "/include/g++-v" + Version.MajorStr,
|
2012-09-03 17:05:50 +08:00
|
|
|
// Android standalone toolchain has C++ headers in yet another place.
|
2013-08-26 16:59:53 +08:00
|
|
|
LibDir.str() + "/../" + TripleStr.str() + "/include/c++/" + Version.Text,
|
2012-09-19 06:25:07 +08:00
|
|
|
// Freescale SDK C++ headers are directly in <sysroot>/usr/include/c++,
|
|
|
|
// without a subdirectory corresponding to the gcc version.
|
|
|
|
LibDir.str() + "/../include/c++",
|
2012-09-03 17:05:50 +08:00
|
|
|
};
|
|
|
|
|
2014-05-09 03:32:46 +08:00
|
|
|
for (const auto &IncludePath : LibStdCXXIncludePathCandidates) {
|
2014-08-27 16:41:41 +08:00
|
|
|
if (addLibStdCXXIncludePaths(IncludePath, /*Suffix*/ "", TripleStr,
|
|
|
|
/*GCCMultiarchTriple*/ "",
|
|
|
|
/*TargetMultiarchTriple*/ "",
|
|
|
|
Multilib.includeSuffix(), DriverArgs, CC1Args))
|
2012-09-03 17:05:50 +08:00
|
|
|
break;
|
2011-11-06 18:31:01 +08:00
|
|
|
}
|
2011-11-06 04:17:13 +08:00
|
|
|
}
|
|
|
|
|
2013-04-09 12:35:11 +08:00
|
|
|
bool Linux::isPIEDefault() const {
|
2014-11-21 20:19:01 +08:00
|
|
|
return getSanitizerArgs().requiresPIE();
|
2013-04-09 12:35:11 +08:00
|
|
|
}
|
|
|
|
|
2009-05-03 02:28:39 +08:00
|
|
|
/// DragonFly - DragonFly tool chain which can call as(1) and ld(1) directly.
|
|
|
|
|
2012-02-19 09:38:32 +08:00
|
|
|
DragonFly::DragonFly(const Driver &D, const llvm::Triple& Triple, const ArgList &Args)
|
|
|
|
: Generic_ELF(D, Triple, Args) {
|
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");
|
2013-04-12 06:55:55 +08:00
|
|
|
if (llvm::sys::fs::exists("/usr/lib/gcc47"))
|
|
|
|
getFilePaths().push_back("/usr/lib/gcc47");
|
|
|
|
else
|
|
|
|
getFilePaths().push_back("/usr/lib/gcc44");
|
2009-05-03 02:28:39 +08:00
|
|
|
}
|
|
|
|
|
2013-03-20 11:05:54 +08:00
|
|
|
Tool *DragonFly::buildAssembler() const {
|
|
|
|
return new tools::dragonfly::Assemble(*this);
|
|
|
|
}
|
|
|
|
|
|
|
|
Tool *DragonFly::buildLinker() const {
|
|
|
|
return new tools::dragonfly::Link(*this);
|
2009-05-03 02:28:39 +08:00
|
|
|
}
|
2013-10-11 18:29:40 +08:00
|
|
|
|
|
|
|
|
|
|
|
/// XCore tool chain
|
|
|
|
XCore::XCore(const Driver &D, const llvm::Triple &Triple,
|
|
|
|
const ArgList &Args) : ToolChain(D, Triple, Args) {
|
|
|
|
// ProgramPaths are found via 'PATH' environment variable.
|
|
|
|
}
|
|
|
|
|
|
|
|
Tool *XCore::buildAssembler() const {
|
|
|
|
return new tools::XCore::Assemble(*this);
|
|
|
|
}
|
|
|
|
|
|
|
|
Tool *XCore::buildLinker() const {
|
|
|
|
return new tools::XCore::Link(*this);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool XCore::isPICDefault() const {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool XCore::isPIEDefault() const {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool XCore::isPICDefaultForced() const {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool XCore::SupportsProfiling() const {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool XCore::hasBlocksRuntime() const {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
void XCore::AddClangSystemIncludeArgs(const ArgList &DriverArgs,
|
|
|
|
ArgStringList &CC1Args) const {
|
|
|
|
if (DriverArgs.hasArg(options::OPT_nostdinc) ||
|
|
|
|
DriverArgs.hasArg(options::OPT_nostdlibinc))
|
|
|
|
return;
|
|
|
|
if (const char *cl_include_dir = getenv("XCC_C_INCLUDE_PATH")) {
|
|
|
|
SmallVector<StringRef, 4> Dirs;
|
|
|
|
const char EnvPathSeparatorStr[] = {llvm::sys::EnvPathSeparator,'\0'};
|
|
|
|
StringRef(cl_include_dir).split(Dirs, StringRef(EnvPathSeparatorStr));
|
|
|
|
ArrayRef<StringRef> DirVec(Dirs);
|
|
|
|
addSystemIncludes(DriverArgs, CC1Args, DirVec);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void XCore::addClangTargetOptions(const llvm::opt::ArgList &DriverArgs,
|
|
|
|
llvm::opt::ArgStringList &CC1Args) const {
|
|
|
|
CC1Args.push_back("-nostdsysteminc");
|
|
|
|
}
|
|
|
|
|
|
|
|
void XCore::AddClangCXXStdlibIncludeArgs(const ArgList &DriverArgs,
|
|
|
|
ArgStringList &CC1Args) const {
|
|
|
|
if (DriverArgs.hasArg(options::OPT_nostdinc) ||
|
2014-08-01 21:11:46 +08:00
|
|
|
DriverArgs.hasArg(options::OPT_nostdlibinc) ||
|
|
|
|
DriverArgs.hasArg(options::OPT_nostdincxx))
|
2013-10-11 18:29:40 +08:00
|
|
|
return;
|
|
|
|
if (const char *cl_include_dir = getenv("XCC_CPLUS_INCLUDE_PATH")) {
|
|
|
|
SmallVector<StringRef, 4> Dirs;
|
|
|
|
const char EnvPathSeparatorStr[] = {llvm::sys::EnvPathSeparator,'\0'};
|
|
|
|
StringRef(cl_include_dir).split(Dirs, StringRef(EnvPathSeparatorStr));
|
|
|
|
ArrayRef<StringRef> DirVec(Dirs);
|
|
|
|
addSystemIncludes(DriverArgs, CC1Args, DirVec);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void XCore::AddCXXStdlibLibArgs(const ArgList &Args,
|
|
|
|
ArgStringList &CmdArgs) const {
|
|
|
|
// We don't output any lib args. This is handled by xcc.
|
|
|
|
}
|