summaryrefslogtreecommitdiffstats
path: root/lib/Driver
diff options
context:
space:
mode:
authorrdivacky <rdivacky@FreeBSD.org>2010-02-16 09:31:36 +0000
committerrdivacky <rdivacky@FreeBSD.org>2010-02-16 09:31:36 +0000
commitfd035e6496665b1f1197868e21cb0a4594e8db6e (patch)
tree53010172e19c77ea447bcd89e117cda052ab52e0 /lib/Driver
parent2fce988e86bc01829142e4362d4eff1af0925147 (diff)
downloadFreeBSD-src-fd035e6496665b1f1197868e21cb0a4594e8db6e.zip
FreeBSD-src-fd035e6496665b1f1197868e21cb0a4594e8db6e.tar.gz
Update clang to r96341.
Diffstat (limited to 'lib/Driver')
-rw-r--r--lib/Driver/Driver.cpp81
-rw-r--r--lib/Driver/HostInfo.cpp11
-rw-r--r--lib/Driver/Makefile1
-rw-r--r--lib/Driver/ToolChains.cpp158
-rw-r--r--lib/Driver/ToolChains.h115
-rw-r--r--lib/Driver/Tools.cpp228
-rw-r--r--lib/Driver/Tools.h19
7 files changed, 373 insertions, 240 deletions
diff --git a/lib/Driver/Driver.cpp b/lib/Driver/Driver.cpp
index 852a018..15df767 100644
--- a/lib/Driver/Driver.cpp
+++ b/lib/Driver/Driver.cpp
@@ -50,8 +50,8 @@ Driver::Driver(llvm::StringRef _Name, llvm::StringRef _Dir,
Name(_Name), Dir(_Dir), DefaultHostTriple(_DefaultHostTriple),
DefaultImageName(_DefaultImageName),
Host(0),
- CCCIsCXX(false), CCCEcho(false), CCCPrintBindings(false),
- CCCGenericGCCName("gcc"), CCCUseClang(true),
+ CCCGenericGCCName("gcc"), CCCIsCXX(false), CCCEcho(false),
+ CCCPrintBindings(false), CheckInputsExist(true), CCCUseClang(true),
CCCUseClangCXX(true), CCCUseClangCPP(true), CCCUsePCH(true),
SuppressMissingInputWarning(false) {
if (IsProduction) {
@@ -158,10 +158,8 @@ Compilation *Driver::BuildCompilation(int argc, const char **argv) {
llvm::Triple::ArchType Arch =
llvm::Triple(Split.first, "", "").getArch();
- if (Arch == llvm::Triple::UnknownArch) {
- Diag(clang::diag::err_drv_invalid_arch_name) << Arch;
- continue;
- }
+ if (Arch == llvm::Triple::UnknownArch)
+ Diag(clang::diag::err_drv_invalid_arch_name) << Split.first;
CCCClangArchs.insert(Arch);
}
@@ -579,10 +577,9 @@ void Driver::BuildActions(const ArgList &Args, ActionList &Actions) const {
Ty = InputType;
}
- // Check that the file exists. It isn't clear this is worth doing, since
- // the tool presumably does this anyway, and this just adds an extra stat
- // to the equation, but this is gcc compatible.
- if (memcmp(Value, "-", 2) != 0 && !llvm::sys::Path(Value).exists())
+ // Check that the file exists, if enabled.
+ if (CheckInputsExist && memcmp(Value, "-", 2) != 0 &&
+ !llvm::sys::Path(Value).exists())
Diag(clang::diag::err_drv_no_such_file) << A->getValue(Args);
else
Inputs.push_back(std::make_pair(Ty, A));
@@ -625,6 +622,7 @@ void Driver::BuildActions(const ArgList &Args, ActionList &Actions) const {
// -{fsyntax-only,-analyze,emit-ast,S} only run up to the compiler.
} else if ((FinalPhaseArg = Args.getLastArg(options::OPT_fsyntax_only)) ||
+ (FinalPhaseArg = Args.getLastArg(options::OPT_rewrite_objc)) ||
(FinalPhaseArg = Args.getLastArg(options::OPT__analyze,
options::OPT__analyze_auto)) ||
(FinalPhaseArg = Args.getLastArg(options::OPT_emit_ast)) ||
@@ -745,6 +743,8 @@ Action *Driver::ConstructPhaseAction(const ArgList &Args, phases::ID Phase,
if (Args.hasArg(options::OPT_fsyntax_only)) {
return new CompileJobAction(Input, types::TY_Nothing);
+ } else if (Args.hasArg(options::OPT_rewrite_objc)) {
+ return new CompileJobAction(Input, types::TY_RewrittenObjC);
} else if (Args.hasArg(options::OPT__analyze, options::OPT__analyze_auto)) {
return new AnalyzeJobAction(Input, types::TY_Plist);
} else if (Args.hasArg(options::OPT_emit_ast)) {
@@ -866,6 +866,44 @@ void Driver::BuildJobs(Compilation &C) const {
}
}
+static const Tool &SelectToolForJob(Compilation &C, const ToolChain *TC,
+ const JobAction *JA,
+ const ActionList *&Inputs) {
+ const Tool *ToolForJob = 0;
+
+ // See if we should look for a compiler with an integrated assembler. We match
+ // bottom up, so what we are actually looking for is an assembler job with a
+ // compiler input.
+ if (C.getArgs().hasArg(options::OPT_integrated_as,
+ options::OPT_no_integrated_as,
+ TC->IsIntegratedAssemblerDefault()) &&
+ !C.getArgs().hasArg(options::OPT_save_temps) &&
+ isa<AssembleJobAction>(JA) &&
+ Inputs->size() == 1 && isa<CompileJobAction>(*Inputs->begin())) {
+ const Tool &Compiler = TC->SelectTool(C,cast<JobAction>(**Inputs->begin()));
+ if (Compiler.hasIntegratedAssembler()) {
+ Inputs = &(*Inputs)[0]->getInputs();
+ ToolForJob = &Compiler;
+ }
+ }
+
+ // Otherwise use the tool for the current job.
+ if (!ToolForJob)
+ ToolForJob = &TC->SelectTool(C, *JA);
+
+ // See if we should use an integrated preprocessor. We do so when we have
+ // exactly one input, since this is the only use case we care about
+ // (irrelevant since we don't support combine yet).
+ if (Inputs->size() == 1 && isa<PreprocessJobAction>(*Inputs->begin()) &&
+ !C.getArgs().hasArg(options::OPT_no_integrated_cpp) &&
+ !C.getArgs().hasArg(options::OPT_traditional_cpp) &&
+ !C.getArgs().hasArg(options::OPT_save_temps) &&
+ ToolForJob->hasIntegratedCPP())
+ Inputs = &(*Inputs)[0]->getInputs();
+
+ return *ToolForJob;
+}
+
void Driver::BuildJobsForAction(Compilation &C,
const Action *A,
const ToolChain *TC,
@@ -906,21 +944,10 @@ void Driver::BuildJobsForAction(Compilation &C,
return;
}
- const JobAction *JA = cast<JobAction>(A);
- const Tool &T = TC->SelectTool(C, *JA);
-
- // See if we should use an integrated preprocessor. We do so when we have
- // exactly one input, since this is the only use case we care about
- // (irrelevant since we don't support combine yet).
const ActionList *Inputs = &A->getInputs();
- if (Inputs->size() == 1 && isa<PreprocessJobAction>(*Inputs->begin())) {
- if (!C.getArgs().hasArg(options::OPT_no_integrated_cpp) &&
- !C.getArgs().hasArg(options::OPT_traditional_cpp) &&
- !C.getArgs().hasArg(options::OPT_save_temps) &&
- T.hasIntegratedCPP()) {
- Inputs = &(*Inputs)[0]->getInputs();
- }
- }
+
+ const JobAction *JA = cast<JobAction>(A);
+ const Tool &T = SelectToolForJob(C, TC, JA, Inputs);
// Only use pipes when there is exactly one input.
bool TryToUsePipeInput = Inputs->size() == 1 && T.acceptsPipedInput();
@@ -1147,8 +1174,10 @@ bool Driver::ShouldUseClangCompiler(const Compilation &C, const JobAction &JA,
return false;
}
- // Always use clang for precompiling and AST generation, regardless of archs.
- if (isa<PrecompileJobAction>(JA) || JA.getType() == types::TY_AST)
+ // Always use clang for precompiling, AST generation, and rewriting,
+ // regardless of archs.
+ if (isa<PrecompileJobAction>(JA) || JA.getType() == types::TY_AST ||
+ JA.getType() == types::TY_RewrittenObjC)
return true;
// Finally, don't use clang if this isn't one of the user specified archs to
diff --git a/lib/Driver/HostInfo.cpp b/lib/Driver/HostInfo.cpp
index ed73b17..18bb786 100644
--- a/lib/Driver/HostInfo.cpp
+++ b/lib/Driver/HostInfo.cpp
@@ -106,7 +106,7 @@ ToolChain *DarwinHostInfo::CreateToolChain(const ArgList &Args,
if (Arg *A = Args.getLastArg(options::OPT_arch)) {
// The gcc driver behavior with multiple -arch flags wasn't consistent for
// things which rely on a default architecture. We just use the last -arch
- // to find the default tool chain (assuming it is valid..
+ // to find the default tool chain (assuming it is valid).
Arch = llvm::Triple::getArchTypeForDarwinArchName(A->getValue(Args));
// If it was invalid just use the host, we will reject this command line
@@ -146,10 +146,10 @@ ToolChain *DarwinHostInfo::CreateToolChain(const ArgList &Args,
// If we recognized the arch, match it to the toolchains we support.
if (Arch == llvm::Triple::x86 || Arch == llvm::Triple::x86_64) {
// We still use the legacy DarwinGCC toolchain on X86.
- TC = new toolchains::DarwinGCC(*this, TCTriple, DarwinVersion, GCCVersion,
- false);
+ TC = new toolchains::DarwinGCC(*this, TCTriple, DarwinVersion,
+ GCCVersion);
} else if (Arch == llvm::Triple::arm || Arch == llvm::Triple::thumb)
- TC = new toolchains::DarwinClang(*this, TCTriple, DarwinVersion, true);
+ TC = new toolchains::DarwinClang(*this, TCTriple, DarwinVersion);
else
TC = new toolchains::Darwin_Generic_GCC(*this, TCTriple);
}
@@ -159,8 +159,7 @@ ToolChain *DarwinHostInfo::CreateToolChain(const ArgList &Args,
// Unknown Host Info
-/// UnknownHostInfo - Generic host information to use for unknown
-/// hosts.
+/// UnknownHostInfo - Generic host information to use for unknown hosts.
class UnknownHostInfo : public HostInfo {
/// Cache of tool chains we have created.
mutable llvm::StringMap<ToolChain*> ToolChains;
diff --git a/lib/Driver/Makefile b/lib/Driver/Makefile
index dbacf8b..371bda7 100644
--- a/lib/Driver/Makefile
+++ b/lib/Driver/Makefile
@@ -10,7 +10,6 @@
LEVEL = ../../../..
LIBRARYNAME := clangDriver
BUILD_ARCHIVE = 1
-CXXFLAGS = -fno-rtti
CPPFLAGS += -I$(PROJ_SRC_DIR)/../../include -I$(PROJ_OBJ_DIR)/../../include
diff --git a/lib/Driver/ToolChains.cpp b/lib/Driver/ToolChains.cpp
index a9c6a68..a7cd711 100644
--- a/lib/Driver/ToolChains.cpp
+++ b/lib/Driver/ToolChains.cpp
@@ -31,20 +31,12 @@ using namespace clang::driver::toolchains;
/// Darwin - Darwin tool chain for i386 and x86_64.
Darwin::Darwin(const HostInfo &Host, const llvm::Triple& Triple,
- const unsigned (&_DarwinVersion)[3], bool _IsIPhoneOS)
- : ToolChain(Host, Triple),
- IsIPhoneOS(_IsIPhoneOS)
+ const unsigned (&_DarwinVersion)[3])
+ : ToolChain(Host, Triple), TargetInitialized(false)
{
- DarwinVersion[0] = _DarwinVersion[0];
- DarwinVersion[1] = _DarwinVersion[1];
- DarwinVersion[2] = _DarwinVersion[2];
-
llvm::raw_string_ostream(MacosxVersionMin)
- << "10." << std::max(0, (int)DarwinVersion[0] - 4) << '.'
- << DarwinVersion[1];
-
- // FIXME: Lift default up.
- IPhoneOSVersionMin = "3.0";
+ << "10." << std::max(0, (int)_DarwinVersion[0] - 4) << '.'
+ << _DarwinVersion[1];
}
// FIXME: Can we tablegen this?
@@ -112,8 +104,8 @@ llvm::StringRef Darwin::getDarwinArchName(const ArgList &Args) const {
DarwinGCC::DarwinGCC(const HostInfo &Host, const llvm::Triple& Triple,
const unsigned (&DarwinVersion)[3],
- const unsigned (&_GCCVersion)[3], bool IsIPhoneOS)
- : Darwin(Host, Triple, DarwinVersion, IsIPhoneOS)
+ const unsigned (&_GCCVersion)[3])
+ : Darwin(Host, Triple, DarwinVersion)
{
GCCVersion[0] = _GCCVersion[0];
GCCVersion[1] = _GCCVersion[1];
@@ -245,8 +237,7 @@ void DarwinGCC::AddLinkSearchPathArgs(const ArgList &Args,
void DarwinGCC::AddLinkRuntimeLibArgs(const ArgList &Args,
ArgStringList &CmdArgs) const {
- unsigned MacosxVersionMin[3];
- getMacosxVersionMin(Args, MacosxVersionMin);
+ // Note that this routine is only used for targetting OS X.
// Derived from libgcc and lib specs but refactored.
if (Args.hasArg(options::OPT_static)) {
@@ -256,7 +247,7 @@ void DarwinGCC::AddLinkRuntimeLibArgs(const ArgList &Args,
CmdArgs.push_back("-lgcc_eh");
} else if (Args.hasArg(options::OPT_miphoneos_version_min_EQ)) {
// Derived from darwin_iphoneos_libgcc spec.
- if (isIPhoneOS()) {
+ if (isTargetIPhoneOS()) {
CmdArgs.push_back("-lgcc_s.1");
} else {
CmdArgs.push_back("-lgcc_s.10.5");
@@ -266,20 +257,20 @@ void DarwinGCC::AddLinkRuntimeLibArgs(const ArgList &Args,
options::OPT_fno_exceptions) ||
Args.hasArg(options::OPT_fgnu_runtime)) {
// FIXME: This is probably broken on 10.3?
- if (isMacosxVersionLT(MacosxVersionMin, 10, 5))
+ if (isMacosxVersionLT(10, 5))
CmdArgs.push_back("-lgcc_s.10.4");
- else if (isMacosxVersionLT(MacosxVersionMin, 10, 6))
+ else if (isMacosxVersionLT(10, 6))
CmdArgs.push_back("-lgcc_s.10.5");
} else {
- if (isMacosxVersionLT(MacosxVersionMin, 10, 3, 9))
+ if (isMacosxVersionLT(10, 3, 9))
; // Do nothing.
- else if (isMacosxVersionLT(MacosxVersionMin, 10, 5))
+ else if (isMacosxVersionLT(10, 5))
CmdArgs.push_back("-lgcc_s.10.4");
- else if (isMacosxVersionLT(MacosxVersionMin, 10, 6))
+ else if (isMacosxVersionLT(10, 6))
CmdArgs.push_back("-lgcc_s.10.5");
}
- if (isIPhoneOS() || isMacosxVersionLT(MacosxVersionMin, 10, 6)) {
+ if (isTargetIPhoneOS() || isMacosxVersionLT(10, 6)) {
CmdArgs.push_back("-lgcc");
CmdArgs.push_back("-lSystem");
} else {
@@ -290,9 +281,8 @@ void DarwinGCC::AddLinkRuntimeLibArgs(const ArgList &Args,
}
DarwinClang::DarwinClang(const HostInfo &Host, const llvm::Triple& Triple,
- const unsigned (&DarwinVersion)[3],
- bool IsIPhoneOS)
- : Darwin(Host, Triple, DarwinVersion, IsIPhoneOS)
+ const unsigned (&DarwinVersion)[3])
+ : Darwin(Host, Triple, DarwinVersion)
{
// We expect 'as', 'ld', etc. to be adjacent to our install dir.
getProgramPaths().push_back(getDriver().Dir);
@@ -325,7 +315,7 @@ void DarwinClang::AddLinkRuntimeLibArgs(const ArgList &Args,
// Select the dynamic runtime library and the target specific static library.
const char *DarwinStaticLib = 0;
- if (isIPhoneOS()) {
+ if (isTargetIPhoneOS()) {
CmdArgs.push_back("-lgcc_s.1");
// We may need some static functions for armv6/thumb which are required to
@@ -333,20 +323,17 @@ void DarwinClang::AddLinkRuntimeLibArgs(const ArgList &Args,
if (getDarwinArchName(Args) == "armv6")
DarwinStaticLib = "libclang_rt.armv6.a";
} else {
- unsigned MacosxVersionMin[3];
- getMacosxVersionMin(Args, MacosxVersionMin);
-
// The dynamic runtime library was merged with libSystem for 10.6 and
// beyond; only 10.4 and 10.5 need an additional runtime library.
- if (isMacosxVersionLT(MacosxVersionMin, 10, 5))
+ if (isMacosxVersionLT(10, 5))
CmdArgs.push_back("-lgcc_s.10.4");
- else if (isMacosxVersionLT(MacosxVersionMin, 10, 6))
+ else if (isMacosxVersionLT(10, 6))
CmdArgs.push_back("-lgcc_s.10.5");
// For OS X, we only need a static runtime library when targetting 10.4, to
// provide versions of the static functions which were omitted from
// 10.4.dylib.
- if (isMacosxVersionLT(MacosxVersionMin, 10, 5))
+ if (isMacosxVersionLT(10, 5))
DarwinStaticLib = "libclang_rt.10.4.a";
}
@@ -367,21 +354,6 @@ void DarwinClang::AddLinkRuntimeLibArgs(const ArgList &Args,
}
}
-void Darwin::getMacosxVersionMin(const ArgList &Args,
- unsigned (&Res)[3]) const {
- if (Arg *A = Args.getLastArg(options::OPT_mmacosx_version_min_EQ)) {
- bool HadExtra;
- if (!Driver::GetReleaseVersion(A->getValue(Args), Res[0], Res[1], Res[2],
- HadExtra) ||
- HadExtra) {
- const Driver &D = getDriver();
- D.Diag(clang::diag::err_drv_invalid_version_number)
- << A->getAsString(Args);
- }
- } else
- return getMacosxVersion(Res);
-}
-
DerivedArgList *Darwin::TranslateArgs(InputArgList &Args,
const char *BoundArch) const {
DerivedArgList *DAL = new DerivedArgList(Args, false);
@@ -394,34 +366,84 @@ DerivedArgList *Darwin::TranslateArgs(InputArgList &Args,
// have something that works, we should reevaluate each translation
// and try to push it down into tool specific logic.
- Arg *OSXVersion =
- Args.getLastArgNoClaim(options::OPT_mmacosx_version_min_EQ);
- Arg *iPhoneVersion =
- Args.getLastArgNoClaim(options::OPT_miphoneos_version_min_EQ);
+ Arg *OSXVersion = Args.getLastArg(options::OPT_mmacosx_version_min_EQ);
+ Arg *iPhoneVersion = Args.getLastArg(options::OPT_miphoneos_version_min_EQ);
if (OSXVersion && iPhoneVersion) {
getDriver().Diag(clang::diag::err_drv_argument_not_allowed_with)
<< OSXVersion->getAsString(Args)
<< iPhoneVersion->getAsString(Args);
+ iPhoneVersion = 0;
} else if (!OSXVersion && !iPhoneVersion) {
- // Chose the default version based on the arch.
+ // If neither OS X nor iPhoneOS targets were specified, check for
+ // environment defines.
+ const char *OSXTarget = ::getenv("MACOSX_DEPLOYMENT_TARGET");
+ const char *iPhoneOSTarget = ::getenv("IPHONEOS_DEPLOYMENT_TARGET");
+
+ // Ignore empty strings.
+ if (OSXTarget && OSXTarget[0] == '\0')
+ OSXTarget = 0;
+ if (iPhoneOSTarget && iPhoneOSTarget[0] == '\0')
+ iPhoneOSTarget = 0;
+
+ // Diagnose conflicting deployment targets, and choose default platform
+ // based on the tool chain.
//
- // FIXME: Are there iPhone overrides for this?
-
- if (!isIPhoneOS()) {
- // Look for MACOSX_DEPLOYMENT_TARGET, otherwise use the version
- // from the host.
- const char *Version = ::getenv("MACOSX_DEPLOYMENT_TARGET");
- if (!Version)
- Version = MacosxVersionMin.c_str();
+ // FIXME: Don't hardcode default here.
+ if (OSXTarget && iPhoneOSTarget) {
+ // FIXME: We should see if we can get away with warning or erroring on
+ // this. Perhaps put under -pedantic?
+ if (getTriple().getArch() == llvm::Triple::arm ||
+ getTriple().getArch() == llvm::Triple::thumb)
+ OSXVersion = 0;
+ else
+ iPhoneVersion = 0;
+ }
+
+ if (OSXTarget) {
const Option *O = Opts.getOption(options::OPT_mmacosx_version_min_EQ);
- DAL->append(DAL->MakeJoinedArg(0, O, Version));
- } else {
- const char *Version = IPhoneOSVersionMin.c_str();
+ OSXVersion = DAL->MakeJoinedArg(0, O, OSXTarget);
+ DAL->append(OSXVersion);
+ } else if (iPhoneOSTarget) {
const Option *O = Opts.getOption(options::OPT_miphoneos_version_min_EQ);
- DAL->append(DAL->MakeJoinedArg(0, O, Version));
+ iPhoneVersion = DAL->MakeJoinedArg(0, O, iPhoneOSTarget);
+ DAL->append(iPhoneVersion);
+ } else {
+ // Otherwise, choose a default platform based on the tool chain.
+ //
+ // FIXME: Don't hardcode default here.
+ if (getTriple().getArch() == llvm::Triple::arm ||
+ getTriple().getArch() == llvm::Triple::thumb) {
+ const Option *O = Opts.getOption(options::OPT_miphoneos_version_min_EQ);
+ iPhoneVersion = DAL->MakeJoinedArg(0, O, "3.0");
+ DAL->append(iPhoneVersion);
+ } else {
+ const Option *O = Opts.getOption(options::OPT_mmacosx_version_min_EQ);
+ OSXVersion = DAL->MakeJoinedArg(0, O, MacosxVersionMin);
+ DAL->append(OSXVersion);
+ }
}
}
+ // Set the tool chain target information.
+ unsigned Major, Minor, Micro;
+ bool HadExtra;
+ if (OSXVersion) {
+ assert(!iPhoneVersion && "Unknown target platform!");
+ if (!Driver::GetReleaseVersion(OSXVersion->getValue(Args), Major, Minor,
+ Micro, HadExtra) || HadExtra ||
+ Major != 10 || Minor >= 10 || Micro >= 10)
+ getDriver().Diag(clang::diag::err_drv_invalid_version_number)
+ << OSXVersion->getAsString(Args);
+ } else {
+ assert(iPhoneVersion && "Unknown target platform!");
+ if (!Driver::GetReleaseVersion(iPhoneVersion->getValue(Args), Major, Minor,
+ Micro, HadExtra) || HadExtra ||
+ Major >= 10 || Minor >= 100 || Micro >= 100)
+ getDriver().Diag(clang::diag::err_drv_invalid_version_number)
+ << iPhoneVersion->getAsString(Args);
+ }
+ setTarget(iPhoneVersion, Major, Minor, Micro);
+
for (ArgList::iterator it = Args.begin(), ie = Args.end(); it != ie; ++it) {
Arg *A = *it;
@@ -618,6 +640,12 @@ bool Darwin::UseDwarfDebugFlags() const {
return false;
}
+bool Darwin::UseSjLjExceptions() const {
+ // Darwin uses SjLj exceptions on ARM.
+ return (getTriple().getArch() == llvm::Triple::arm ||
+ getTriple().getArch() == llvm::Triple::thumb);
+}
+
const char *Darwin::GetDefaultRelocationModel() const {
return "pic";
}
diff --git a/lib/Driver/ToolChains.h b/lib/Driver/ToolChains.h
index 3ca6ad8..fda0875 100644
--- a/lib/Driver/ToolChains.h
+++ b/lib/Driver/ToolChains.h
@@ -47,42 +47,60 @@ public:
class VISIBILITY_HIDDEN Darwin : public ToolChain {
mutable llvm::DenseMap<unsigned, Tool*> Tools;
- /// Darwin version of tool chain.
- unsigned DarwinVersion[3];
-
- /// Whether this is this an iPhoneOS toolchain.
+ /// Whether the information on the target has been initialized.
//
- // FIXME: This should go away, such differences should be completely
- // determined by the target triple.
- bool IsIPhoneOS;
+ // FIXME: This should be eliminated. What we want to do is make this part of
+ // the "default target for arguments" selection process, once we get out of
+ // the argument translation business.
+ mutable bool TargetInitialized;
+
+ /// Whether we are targetting iPhoneOS target.
+ mutable bool TargetIsIPhoneOS;
+
+ /// The OS version we are targetting.
+ mutable unsigned TargetVersion[3];
/// The default macosx-version-min of this tool chain; empty until
/// initialized.
- mutable std::string MacosxVersionMin;
-
- /// The default iphoneos-version-min of this tool chain.
- std::string IPhoneOSVersionMin;
-
- const char *getMacosxVersionMin() const;
+ std::string MacosxVersionMin;
public:
Darwin(const HostInfo &Host, const llvm::Triple& Triple,
- const unsigned (&DarwinVersion)[3], bool IsIPhoneOS);
+ const unsigned (&DarwinVersion)[3]);
~Darwin();
/// @name Darwin Specific Toolchain API
/// {
- void getDarwinVersion(unsigned (&Res)[3]) const {
- Res[0] = DarwinVersion[0];
- Res[1] = DarwinVersion[1];
- Res[2] = DarwinVersion[2];
+ // FIXME: Eliminate these ...Target functions and derive separate tool chains
+ // for these targets and put version in constructor.
+ void setTarget(bool isIPhoneOS, unsigned Major, unsigned Minor,
+ unsigned Micro) const {
+ // FIXME: For now, allow reinitialization as long as values don't
+ // change. This will go away when we move away from argument translation.
+ if (TargetInitialized && TargetIsIPhoneOS == isIPhoneOS &&
+ TargetVersion[0] == Major && TargetVersion[1] == Minor &&
+ TargetVersion[2] == Micro)
+ return;
+
+ assert(!TargetInitialized && "Target already initialized!");
+ TargetInitialized = true;
+ TargetIsIPhoneOS = isIPhoneOS;
+ TargetVersion[0] = Major;
+ TargetVersion[1] = Minor;
+ TargetVersion[2] = Micro;
}
- void getMacosxVersion(unsigned (&Res)[3]) const {
- Res[0] = 10;
- Res[1] = DarwinVersion[0] - 4;
- Res[2] = DarwinVersion[1];
+ bool isTargetIPhoneOS() const {
+ assert(TargetInitialized && "Target not initialized!");
+ return TargetIsIPhoneOS;
+ }
+
+ void getTargetVersion(unsigned (&Res)[3]) const {
+ assert(TargetInitialized && "Target not initialized!");
+ Res[0] = TargetVersion[0];
+ Res[1] = TargetVersion[1];
+ Res[2] = TargetVersion[2];
}
/// getDarwinArchName - Get the "Darwin" arch name for a particular compiler
@@ -90,11 +108,7 @@ public:
/// distinct architectures.
llvm::StringRef getDarwinArchName(const ArgList &Args) const;
- /// getMacosxVersionMin - Get the effective -mmacosx-version-min, which is
- /// either the -mmacosx-version-min, or the current version if unspecified.
- void getMacosxVersionMin(const ArgList &Args, unsigned (&Res)[3]) const;
-
- static bool isMacosxVersionLT(unsigned (&A)[3], unsigned (&B)[3]) {
+ static bool isVersionLT(unsigned (&A)[3], unsigned (&B)[3]) {
for (unsigned i=0; i < 3; ++i) {
if (A[i] > B[i]) return false;
if (A[i] < B[i]) return true;
@@ -102,18 +116,16 @@ public:
return false;
}
- static bool isMacosxVersionLT(unsigned (&A)[3],
- unsigned V0, unsigned V1=0, unsigned V2=0) {
+ bool isIPhoneOSVersionLT(unsigned V0, unsigned V1=0, unsigned V2=0) const {
+ assert(isTargetIPhoneOS() && "Unexpected call for OS X target!");
unsigned B[3] = { V0, V1, V2 };
- return isMacosxVersionLT(A, B);
+ return isVersionLT(TargetVersion, B);
}
- const char *getMacosxVersionStr() const {
- return MacosxVersionMin.c_str();
- }
-
- const char *getIPhoneOSVersionStr() const {
- return IPhoneOSVersionMin.c_str();
+ bool isMacosxVersionLT(unsigned V0, unsigned V1=0, unsigned V2=0) const {
+ assert(!isTargetIPhoneOS() && "Unexpected call for iPhoneOS target!");
+ unsigned B[3] = { V0, V1, V2 };
+ return isVersionLT(TargetVersion, B);
}
/// AddLinkSearchPathArgs - Add the linker search paths to \arg CmdArgs.
@@ -129,8 +141,6 @@ public:
virtual void AddLinkRuntimeLibArgs(const ArgList &Args,
ArgStringList &CmdArgs) const = 0;
- bool isIPhoneOS() const { return IsIPhoneOS; }
-
/// }
/// @name ToolChain Implementation
/// {
@@ -141,24 +151,33 @@ public:
virtual Tool &SelectTool(const Compilation &C, const JobAction &JA) const;
virtual bool IsBlocksDefault() const {
- // Blocks default to on for 10.6 (darwin10) and beyond.
- return (DarwinVersion[0] > 9);
+ // Blocks default to on for OS X 10.6 and iPhoneOS 3.0 and beyond.
+ if (isTargetIPhoneOS())
+ return !isIPhoneOSVersionLT(3);
+ else
+ return !isMacosxVersionLT(10, 6);
}
virtual bool IsObjCNonFragileABIDefault() const {
- // Non-fragile ABI default to on for 10.5 (darwin9) and beyond on x86-64.
- return (DarwinVersion[0] >= 9 &&
- getTriple().getArch() == llvm::Triple::x86_64);
+ // Non-fragile ABI default to on for iPhoneOS and x86-64.
+ return isTargetIPhoneOS() || getTriple().getArch() == llvm::Triple::x86_64;
+ }
+ virtual bool IsObjCLegacyDispatchDefault() const {
+ // This is only used with the non-fragile ABI.
+ return (getTriple().getArch() == llvm::Triple::arm ||
+ getTriple().getArch() == llvm::Triple::thumb);
}
virtual bool IsUnwindTablesDefault() const;
virtual unsigned GetDefaultStackProtectorLevel() const {
- // Stack protectors default to on for 10.6 (darwin10) and beyond.
- return (DarwinVersion[0] > 9) ? 1 : 0;
+ // Stack protectors default to on for 10.6 and beyond.
+ return !isTargetIPhoneOS() && !isMacosxVersionLT(10, 6);
}
virtual const char *GetDefaultRelocationModel() const;
virtual const char *GetForcedPicModel() const;
virtual bool UseDwarfDebugFlags() const;
+ virtual bool UseSjLjExceptions() const;
+
/// }
};
@@ -166,7 +185,7 @@ public:
class VISIBILITY_HIDDEN DarwinClang : public Darwin {
public:
DarwinClang(const HostInfo &Host, const llvm::Triple& Triple,
- const unsigned (&DarwinVersion)[3], bool IsIPhoneOS);
+ const unsigned (&DarwinVersion)[3]);
/// @name Darwin ToolChain Implementation
/// {
@@ -190,8 +209,8 @@ class VISIBILITY_HIDDEN DarwinGCC : public Darwin {
public:
DarwinGCC(const HostInfo &Host, const llvm::Triple& Triple,
- const unsigned (&DarwinVersion)[3], const unsigned (&GCCVersion)[3],
- bool IsIPhoneOS);
+ const unsigned (&DarwinVersion)[3],
+ const unsigned (&GCCVersion)[3]);
/// @name Darwin ToolChain Implementation
/// {
diff --git a/lib/Driver/Tools.cpp b/lib/Driver/Tools.cpp
index afb22a2..aff70bc 100644
--- a/lib/Driver/Tools.cpp
+++ b/lib/Driver/Tools.cpp
@@ -512,7 +512,7 @@ void Clang::AddX86TargetArgs(const ArgList &Args,
// Select the default CPU if none was given (or detection failed).
if (!CPUName) {
// FIXME: Need target hooks.
- if (memcmp(getToolChain().getOS().c_str(), "darwin", 6) == 0) {
+ if (getToolChain().getOS().startswith("darwin")) {
if (getToolChain().getArchName() == "x86_64")
CPUName = "core2";
else if (getToolChain().getArchName() == "i386")
@@ -586,43 +586,35 @@ static std::string getEffectiveClangTriple(const Driver &D,
const ArgList &Args) {
llvm::Triple Triple(getLLVMTriple(TC, Args));
+ // Handle -mmacosx-version-min and -miphoneos-version-min.
if (Triple.getOS() != llvm::Triple::Darwin) {
// Diagnose use of -mmacosx-version-min and -miphoneos-version-min on
// non-Darwin.
if (Arg *A = Args.getLastArg(options::OPT_mmacosx_version_min_EQ,
options::OPT_miphoneos_version_min_EQ))
D.Diag(clang::diag::err_drv_clang_unsupported) << A->getAsString(Args);
- return Triple.getTriple();
- }
-
- // If -mmacosx-version-min=10.3.9 is specified, change the effective triple
- // from being something like powerpc-apple-darwin9 to powerpc-apple-darwin7.
- if (Arg *A = Args.getLastArg(options::OPT_mmacosx_version_min_EQ)) {
- unsigned Major, Minor, Micro;
- bool HadExtra;
- if (!Driver::GetReleaseVersion(A->getValue(Args), Major, Minor, Micro,
- HadExtra) || HadExtra ||
- Major != 10)
- D.Diag(clang::diag::err_drv_invalid_version_number)
- << A->getAsString(Args);
+ } else {
+ const toolchains::Darwin &DarwinTC(
+ reinterpret_cast<const toolchains::Darwin&>(TC));
+ unsigned Version[3];
+ DarwinTC.getTargetVersion(Version);
+
+ // Mangle the target version into the OS triple component. For historical
+ // reasons that make little sense, the version passed here is the "darwin"
+ // version, which drops the 10 and offsets by 4. See inverse code when
+ // setting the OS version preprocessor define.
+ if (!DarwinTC.isTargetIPhoneOS()) {
+ Version[0] = Version[1] + 4;
+ Version[1] = Version[2];
+ Version[2] = 0;
+ } else {
+ // Use the environment to communicate that we are targetting iPhoneOS.
+ Triple.setEnvironmentName("iphoneos");
+ }
- // Mangle the MacOS version min number into the Darwin number: e.g. 10.3.9
- // is darwin7.9.
- llvm::SmallString<16> Str;
- llvm::raw_svector_ostream(Str) << "darwin" << Minor + 4 << "." << Micro;
- Triple.setOSName(Str.str());
- } else if (Arg *A = Args.getLastArg(options::OPT_miphoneos_version_min_EQ)) {
- unsigned Major, Minor, Micro;
- bool HadExtra;
- if (!Driver::GetReleaseVersion(A->getValue(Args), Major, Minor, Micro,
- HadExtra) || HadExtra)
- D.Diag(clang::diag::err_drv_invalid_version_number)
- << A->getAsString(Args);
-
- // Mangle the iPhoneOS version number into the Darwin number: e.g. 2.0 is 2
- // -> 9.2.0.
llvm::SmallString<16> Str;
- llvm::raw_svector_ostream(Str) << "darwin9." << Major << "." << Minor;
+ llvm::raw_svector_ostream(Str) << "darwin" << Version[0]
+ << "." << Version[1] << "." << Version[2];
Triple.setOSName(Str.str());
}
@@ -659,6 +651,8 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA,
CmdArgs.push_back("-Eonly");
else
CmdArgs.push_back("-E");
+ } else if (isa<AssembleJobAction>(JA)) {
+ CmdArgs.push_back("-emit-obj");
} else if (isa<PrecompileJobAction>(JA)) {
// Use PCH if the user requested it, except for C++ (for now).
bool UsePCH = D.CCCUsePCH;
@@ -682,12 +676,22 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA,
CmdArgs.push_back("-S");
} else if (JA.getType() == types::TY_AST) {
CmdArgs.push_back("-emit-pch");
+ } else if (JA.getType() == types::TY_RewrittenObjC) {
+ CmdArgs.push_back("-rewrite-objc");
+ } else {
+ assert(JA.getType() == types::TY_PP_Asm &&
+ "Unexpected output type!");
}
}
// The make clang go fast button.
CmdArgs.push_back("-disable-free");
+ // Disable the verification pass in -asserts builds.
+#ifdef NDEBUG
+ CmdArgs.push_back("-disable-llvm-verifier");
+#endif
+
// Set the main file name, so that debug info works even with
// -save-temps.
CmdArgs.push_back("-main-file-name");
@@ -707,14 +711,14 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA,
// Add default argument set.
if (!Args.hasArg(options::OPT__analyzer_no_default_checks)) {
- CmdArgs.push_back("-warn-dead-stores");
- CmdArgs.push_back("-warn-security-syntactic");
- CmdArgs.push_back("-checker-cfref");
+ CmdArgs.push_back("-analyzer-check-dead-stores");
+ CmdArgs.push_back("-analyzer-check-security-syntactic");
+ CmdArgs.push_back("-analyzer-check-objc-mem");
CmdArgs.push_back("-analyzer-eagerly-assume");
- CmdArgs.push_back("-warn-objc-methodsigs");
+ CmdArgs.push_back("-analyzer-check-objc-methodsigs");
// Do not enable the missing -dealloc check.
- // '-warn-objc-missing-dealloc',
- CmdArgs.push_back("-warn-objc-unused-ivars");
+ // '-analyzer-check-objc-missing-dealloc',
+ CmdArgs.push_back("-analyzer-check-objc-unused-ivars");
}
// Set the output format. The default is plist, for (lame) historical
@@ -909,8 +913,14 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA,
A->render(Args, CmdArgs);
} else {
// Honor -std-default.
- Args.AddAllArgsTranslated(CmdArgs, options::OPT_std_default_EQ,
- "-std=", /*Joined=*/true);
+ //
+ // FIXME: Clang doesn't correctly handle -std= when the input language
+ // doesn't match. For the time being just ignore this for C++ inputs;
+ // eventually we want to do all the standard defaulting here instead of
+ // splitting it between the driver and clang -cc1.
+ if (!types::isCXX(InputType))
+ Args.AddAllArgsTranslated(CmdArgs, options::OPT_std_default_EQ,
+ "-std=", /*Joined=*/true);
Args.AddLastArg(CmdArgs, options::OPT_trigraphs);
}
@@ -1004,6 +1014,9 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA,
if (needsExceptions(Args, InputType, getToolChain().getTriple()))
CmdArgs.push_back("-fexceptions");
+ if (getToolChain().UseSjLjExceptions())
+ CmdArgs.push_back("-fsjlj-exceptions");
+
// -frtti is default.
if (!Args.hasFlag(options::OPT_frtti, options::OPT_fno_rtti))
CmdArgs.push_back("-fno-rtti");
@@ -1013,6 +1026,11 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA,
isSignedCharDefault(getToolChain().getTriple())))
CmdArgs.push_back("-fno-signed-char");
+ // -fthreadsafe-static is default.
+ if (!Args.hasFlag(options::OPT_fthreadsafe_statics,
+ options::OPT_fno_threadsafe_statics))
+ CmdArgs.push_back("-fno-threadsafe-statics");
+
// -fms-extensions=0 is default.
if (Args.hasFlag(options::OPT_fms_extensions, options::OPT_fno_ms_extensions,
getToolChain().getTriple().getOS() == llvm::Triple::Win32))
@@ -1026,10 +1044,22 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA,
// -fobjc-nonfragile-abi=0 is default.
if (types::isObjC(InputType)) {
if (Args.hasArg(options::OPT_fobjc_nonfragile_abi) ||
- getToolChain().IsObjCNonFragileABIDefault())
+ getToolChain().IsObjCNonFragileABIDefault()) {
CmdArgs.push_back("-fobjc-nonfragile-abi");
+
+ // -fobjc-legacy-dispatch is only relevant with the nonfragile-abi, and
+ // defaults to off.
+ if (Args.hasFlag(options::OPT_fobjc_legacy_dispatch,
+ options::OPT_fno_objc_legacy_dispatch,
+ getToolChain().IsObjCLegacyDispatchDefault()))
+ CmdArgs.push_back("-fobjc-legacy-dispatch");
+ }
}
+ if (!Args.hasFlag(options::OPT_fassume_sane_operator_new,
+ options::OPT_fno_assume_sane_operator_new))
+ CmdArgs.push_back("-fno-assume-sane-operator-new");
+
// -fshort-wchar default varies depending on platform; only
// pass if specified.
if (Arg *A = Args.getLastArg(options::OPT_fshort_wchar)) {
@@ -1066,6 +1096,8 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA,
options::OPT_fno_diagnostics_fixit_info))
CmdArgs.push_back("-fno-diagnostics-fixit-info");
+ Args.AddLastArg(CmdArgs, options::OPT_fdiagnostics_binary);
+
// Enable -fdiagnostics-show-option by default.
if (Args.hasFlag(options::OPT_fdiagnostics_show_option,
options::OPT_fno_diagnostics_show_option))
@@ -1213,7 +1245,7 @@ void gcc::Common::ConstructJob(Compilation &C, const JobAction &JA,
}
}
- RenderExtraToolArgs(CmdArgs);
+ RenderExtraToolArgs(JA, CmdArgs);
// If using a driver driver, force the arch.
const std::string &Arch = getToolChain().getArchName();
@@ -1291,23 +1323,39 @@ void gcc::Common::ConstructJob(Compilation &C, const JobAction &JA,
Dest.addCommand(new Command(JA, *this, Exec, CmdArgs));
}
-void gcc::Preprocess::RenderExtraToolArgs(ArgStringList &CmdArgs) const {
+void gcc::Preprocess::RenderExtraToolArgs(const JobAction &JA,
+ ArgStringList &CmdArgs) const {
CmdArgs.push_back("-E");
}
-void gcc::Precompile::RenderExtraToolArgs(ArgStringList &CmdArgs) const {
+void gcc::Precompile::RenderExtraToolArgs(const JobAction &JA,
+ ArgStringList &CmdArgs) const {
// The type is good enough.
}
-void gcc::Compile::RenderExtraToolArgs(ArgStringList &CmdArgs) const {
- CmdArgs.push_back("-S");
+void gcc::Compile::RenderExtraToolArgs(const JobAction &JA,
+ ArgStringList &CmdArgs) const {
+ const Driver &D = getToolChain().getDriver();
+
+ // If -flto, etc. are present then make sure not to force assembly output.
+ if (JA.getType() == types::TY_LLVMBC)
+ CmdArgs.push_back("-c");
+ else {
+ if (JA.getType() != types::TY_PP_Asm)
+ D.Diag(clang::diag::err_drv_invalid_gcc_output_type)
+ << getTypeName(JA.getType());
+
+ CmdArgs.push_back("-S");
+ }
}
-void gcc::Assemble::RenderExtraToolArgs(ArgStringList &CmdArgs) const {
+void gcc::Assemble::RenderExtraToolArgs(const JobAction &JA,
+ ArgStringList &CmdArgs) const {
CmdArgs.push_back("-c");
}
-void gcc::Link::RenderExtraToolArgs(ArgStringList &CmdArgs) const {
+void gcc::Link::RenderExtraToolArgs(const JobAction &JA,
+ ArgStringList &CmdArgs) const {
// The types are (hopefully) good enough.
}
@@ -1703,6 +1751,10 @@ void darwin::Compile::ConstructJob(Compilation &C, const JobAction &JA,
else if (Output.getType() == types::TY_AST)
D.Diag(clang::diag::err_drv_no_ast_support)
<< getToolChain().getTripleString();
+ else if (JA.getType() != types::TY_PP_Asm &&
+ JA.getType() != types::TY_PCH)
+ D.Diag(clang::diag::err_drv_invalid_gcc_output_type)
+ << getTypeName(JA.getType());
ArgStringList OutputArgs;
if (Output.getType() != types::TY_PCH) {
@@ -1798,7 +1850,7 @@ void darwin::Assemble::ConstructJob(Compilation &C, const JobAction &JA,
// Derived from asm spec.
AddDarwinArch(Args, CmdArgs);
- if (!getDarwinToolChain().isIPhoneOS() ||
+ if (!getDarwinToolChain().isTargetIPhoneOS() ||
Args.hasArg(options::OPT_force__cpusubtype__ALL))
CmdArgs.push_back("-force_cpusubtype_ALL");
@@ -1921,7 +1973,7 @@ void darwin::Link::AddLinkArgs(const ArgList &Args,
Args.AddLastArg(CmdArgs, options::OPT_all__load);
Args.AddAllArgs(CmdArgs, options::OPT_allowable__client);
Args.AddLastArg(CmdArgs, options::OPT_bind__at__load);
- if (getDarwinToolChain().isIPhoneOS())
+ if (getDarwinToolChain().isTargetIPhoneOS())
Args.AddLastArg(CmdArgs, options::OPT_arch__errors__fatal);
Args.AddLastArg(CmdArgs, options::OPT_dead__strip);
Args.AddLastArg(CmdArgs, options::OPT_no__dead__strip__inits__and__terms);
@@ -1933,20 +1985,11 @@ void darwin::Link::AddLinkArgs(const ArgList &Args,
Args.AddAllArgs(CmdArgs, options::OPT_image__base);
Args.AddAllArgs(CmdArgs, options::OPT_init);
- if (!Args.hasArg(options::OPT_mmacosx_version_min_EQ) &&
- !Args.hasArg(options::OPT_miphoneos_version_min_EQ)) {
- // Add default version min.
- if (!getDarwinToolChain().isIPhoneOS()) {
- CmdArgs.push_back("-macosx_version_min");
- CmdArgs.push_back(getDarwinToolChain().getMacosxVersionStr());
- } else {
- CmdArgs.push_back("-iphoneos_version_min");
- CmdArgs.push_back(getDarwinToolChain().getIPhoneOSVersionStr());
- }
- }
-
- // Adding all arguments doesn't make sense here but this is what
- // gcc does.
+ // Adding all arguments doesn't make sense here but this is what gcc does. One
+ // of this should always be present thanks to argument translation.
+ assert((Args.hasArg(options::OPT_mmacosx_version_min_EQ) ||
+ Args.hasArg(options::OPT_miphoneos_version_min_EQ)) &&
+ "Missing version argument (lost in translation)?");
Args.AddAllArgsTranslated(CmdArgs, options::OPT_mmacosx_version_min_EQ,
"-macosx_version_min");
Args.AddAllArgsTranslated(CmdArgs, options::OPT_miphoneos_version_min_EQ,
@@ -1978,7 +2021,7 @@ void darwin::Link::AddLinkArgs(const ArgList &Args,
Args.AddAllArgs(CmdArgs, options::OPT_sub__umbrella);
Args.AddAllArgsTranslated(CmdArgs, options::OPT_isysroot, "-syslibroot");
- if (getDarwinToolChain().isIPhoneOS()) {
+ if (getDarwinToolChain().isTargetIPhoneOS()) {
if (!Args.hasArg(options::OPT_isysroot)) {
CmdArgs.push_back("-syslibroot");
CmdArgs.push_back("/Developer/SDKs/Extra");
@@ -2037,26 +2080,32 @@ void darwin::Link::ConstructJob(Compilation &C, const JobAction &JA,
CmdArgs.push_back("-o");
CmdArgs.push_back(Output.getFilename());
-
- unsigned MacosxVersionMin[3];
- getDarwinToolChain().getMacosxVersionMin(Args, MacosxVersionMin);
-
if (!Args.hasArg(options::OPT_A) &&
!Args.hasArg(options::OPT_nostdlib) &&
!Args.hasArg(options::OPT_nostartfiles)) {
// Derived from startfile spec.
if (Args.hasArg(options::OPT_dynamiclib)) {
// Derived from darwin_dylib1 spec.
- if (getDarwinToolChain().isMacosxVersionLT(MacosxVersionMin, 10, 5))
- CmdArgs.push_back("-ldylib1.o");
- else if (getDarwinToolChain().isMacosxVersionLT(MacosxVersionMin, 10, 6))
- CmdArgs.push_back("-ldylib1.10.5.o");
+ if (getDarwinToolChain().isTargetIPhoneOS()) {
+ if (getDarwinToolChain().isIPhoneOSVersionLT(3, 1))
+ CmdArgs.push_back("-ldylib1.o");
+ } else {
+ if (getDarwinToolChain().isMacosxVersionLT(10, 5))
+ CmdArgs.push_back("-ldylib1.o");
+ else if (getDarwinToolChain().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 (getDarwinToolChain().isMacosxVersionLT(MacosxVersionMin, 10, 6))
- CmdArgs.push_back("-lbundle1.o");
+ if (getDarwinToolChain().isTargetIPhoneOS()) {
+ if (getDarwinToolChain().isIPhoneOSVersionLT(3, 1))
+ CmdArgs.push_back("-lbundle1.o");
+ } else {
+ if (getDarwinToolChain().isMacosxVersionLT(10, 6))
+ CmdArgs.push_back("-lbundle1.o");
+ }
}
} else {
if (Args.hasArg(options::OPT_pg)) {
@@ -2076,26 +2125,29 @@ void darwin::Link::ConstructJob(Compilation &C, const JobAction &JA,
CmdArgs.push_back("-lcrt0.o");
} else {
// Derived from darwin_crt1 spec.
- if (getDarwinToolChain().isIPhoneOS()) {
- CmdArgs.push_back("-lcrt1.o");
- } else if (getDarwinToolChain().isMacosxVersionLT(MacosxVersionMin,
- 10, 5))
- CmdArgs.push_back("-lcrt1.o");
- else if (getDarwinToolChain().isMacosxVersionLT(MacosxVersionMin,
- 10, 6))
- CmdArgs.push_back("-lcrt1.10.5.o");
- else
- CmdArgs.push_back("-lcrt1.10.6.o");
-
- // darwin_crt2 spec is empty.
+ if (getDarwinToolChain().isTargetIPhoneOS()) {
+ if (getDarwinToolChain().isIPhoneOSVersionLT(3, 1))
+ CmdArgs.push_back("-lcrt1.o");
+ else
+ CmdArgs.push_back("-lcrt1.3.1.o");
+ } else {
+ if (getDarwinToolChain().isMacosxVersionLT(10, 5))
+ CmdArgs.push_back("-lcrt1.o");
+ else if (getDarwinToolChain().isMacosxVersionLT(10, 6))
+ CmdArgs.push_back("-lcrt1.10.5.o");
+ else
+ CmdArgs.push_back("-lcrt1.10.6.o");
+
+ // darwin_crt2 spec is empty.
+ }
}
}
}
}
- if (Args.hasArg(options::OPT_shared_libgcc) &&
- !Args.hasArg(options::OPT_miphoneos_version_min_EQ) &&
- getDarwinToolChain().isMacosxVersionLT(MacosxVersionMin, 10, 5)) {
+ if (!getDarwinToolChain().isTargetIPhoneOS() &&
+ Args.hasArg(options::OPT_shared_libgcc) &&
+ getDarwinToolChain().isMacosxVersionLT(10, 5)) {
const char *Str =
Args.MakeArgString(getToolChain().GetFilePath(C, "crt3.o"));
CmdArgs.push_back(Str);
diff --git a/lib/Driver/Tools.h b/lib/Driver/Tools.h
index abd8cfc..db59641 100644
--- a/lib/Driver/Tools.h
+++ b/lib/Driver/Tools.h
@@ -41,6 +41,7 @@ namespace tools {
virtual bool acceptsPipedInput() const { return true; }
virtual bool canPipeOutput() const { return true; }
+ virtual bool hasIntegratedAssembler() const { return true; }
virtual bool hasIntegratedCPP() const { return true; }
virtual void ConstructJob(Compilation &C, const JobAction &JA,
@@ -66,7 +67,8 @@ namespace gcc {
/// RenderExtraToolArgs - Render any arguments necessary to force
/// the particular tool mode.
- virtual void RenderExtraToolArgs(ArgStringList &CmdArgs) const = 0;
+ virtual void RenderExtraToolArgs(const JobAction &JA,
+ ArgStringList &CmdArgs) const = 0;
};
@@ -78,7 +80,8 @@ namespace gcc {
virtual bool canPipeOutput() const { return true; }
virtual bool hasIntegratedCPP() const { return false; }
- virtual void RenderExtraToolArgs(ArgStringList &CmdArgs) const;
+ virtual void RenderExtraToolArgs(const JobAction &JA,
+ ArgStringList &CmdArgs) const;
};
class VISIBILITY_HIDDEN Precompile : public Common {
@@ -89,7 +92,8 @@ namespace gcc {
virtual bool canPipeOutput() const { return false; }
virtual bool hasIntegratedCPP() const { return true; }
- virtual void RenderExtraToolArgs(ArgStringList &CmdArgs) const;
+ virtual void RenderExtraToolArgs(const JobAction &JA,
+ ArgStringList &CmdArgs) const;
};
class VISIBILITY_HIDDEN Compile : public Common {
@@ -100,7 +104,8 @@ namespace gcc {
virtual bool canPipeOutput() const { return true; }
virtual bool hasIntegratedCPP() const { return true; }
- virtual void RenderExtraToolArgs(ArgStringList &CmdArgs) const;
+ virtual void RenderExtraToolArgs(const JobAction &JA,
+ ArgStringList &CmdArgs) const;
};
class VISIBILITY_HIDDEN Assemble : public Common {
@@ -111,7 +116,8 @@ namespace gcc {
virtual bool canPipeOutput() const { return false; }
virtual bool hasIntegratedCPP() const { return false; }
- virtual void RenderExtraToolArgs(ArgStringList &CmdArgs) const;
+ virtual void RenderExtraToolArgs(const JobAction &JA,
+ ArgStringList &CmdArgs) const;
};
class VISIBILITY_HIDDEN Link : public Common {
@@ -122,7 +128,8 @@ namespace gcc {
virtual bool canPipeOutput() const { return false; }
virtual bool hasIntegratedCPP() const { return false; }
- virtual void RenderExtraToolArgs(ArgStringList &CmdArgs) const;
+ virtual void RenderExtraToolArgs(const JobAction &JA,
+ ArgStringList &CmdArgs) const;
};
} // end namespace gcc
OpenPOWER on IntegriCloud