diff options
Diffstat (limited to 'lib/Driver')
-rw-r--r-- | lib/Driver/Driver.cpp | 33 | ||||
-rw-r--r-- | lib/Driver/Tools.cpp | 42 |
2 files changed, 30 insertions, 45 deletions
diff --git a/lib/Driver/Driver.cpp b/lib/Driver/Driver.cpp index da83803dd7..cae2243b2e 100644 --- a/lib/Driver/Driver.cpp +++ b/lib/Driver/Driver.cpp @@ -504,7 +504,8 @@ void Driver::BuildUniversalActions(const ArgList &Args, ActionList SingleActions; BuildActions(Args, SingleActions); - // Add in arch binding and lipo (if necessary) for every top level action. + // Add in arch bindings for every top level action, as well as lipo and + // dsymutil steps if needed. for (unsigned i = 0, e = SingleActions.size(); i != e; ++i) { Action *Act = SingleActions[i]; @@ -531,6 +532,19 @@ void Driver::BuildUniversalActions(const ArgList &Args, Actions.append(Inputs.begin(), Inputs.end()); else Actions.push_back(new LipoJobAction(Inputs, Act->getType())); + + // Add a 'dsymutil' step if necessary. + if (Act->getType() == types::TY_Image) { + Arg *A = Args.getLastArg(options::OPT_g_Group); + if (A && !A->getOption().matches(options::OPT_g0) && + !A->getOption().matches(options::OPT_gstabs)) { + ActionList Inputs; + Inputs.push_back(Actions.back()); + Actions.pop_back(); + + Actions.push_back(new DsymutilJobAction(Inputs, types::TY_dSYM)); + } + } } } @@ -992,9 +1006,17 @@ void Driver::BuildJobsForAction(Compilation &C, InputInfoList InputInfos; for (ActionList::const_iterator it = Inputs->begin(), ie = Inputs->end(); it != ie; ++it) { + // Treat dsymutil sub-jobs as being at the top-level too, they shouldn't get + // temporary output names. + // + // FIXME: Clean this up. + bool SubJobAtTopLevel = false; + if (AtTopLevel && isa<DsymutilJobAction>(A)) + SubJobAtTopLevel = true; + InputInfo II; BuildJobsForAction(C, *it, TC, BoundArch, TryToUsePipeInput, - /*AtTopLevel*/false, LinkingOutput, II); + SubJobAtTopLevel, LinkingOutput, II); InputInfos.push_back(II); } @@ -1023,6 +1045,11 @@ void Driver::BuildJobsForAction(Compilation &C, // Always use the first input as the base input. const char *BaseInput = InputInfos[0].getBaseInput(); + // ... except dsymutil actions, which use their actual input as the base + // input. + if (JA->getType() == types::TY_dSYM) + BaseInput = InputInfos[0].getFilename(); + // Determine the place to write output to (nothing, pipe, or filename) and // where to put the new job. if (JA->getType() == types::TY_Nothing) { @@ -1065,7 +1092,7 @@ const char *Driver::GetNamedOutputPath(Compilation &C, bool AtTopLevel) const { llvm::PrettyStackTraceString CrashInfo("Computing output path"); // Output to a user requested destination? - if (AtTopLevel) { + if (AtTopLevel && !isa<DsymutilJobAction>(JA)) { if (Arg *FinalOutput = C.getArgs().getLastArg(options::OPT_o)) return C.addResultFile(FinalOutput->getValue(C.getArgs())); } diff --git a/lib/Driver/Tools.cpp b/lib/Driver/Tools.cpp index 518debce93..78f2d70073 100644 --- a/lib/Driver/Tools.cpp +++ b/lib/Driver/Tools.cpp @@ -2215,26 +2215,6 @@ void darwin::Assemble::ConstructJob(Compilation &C, const JobAction &JA, Dest.addCommand(new Command(JA, *this, Exec, CmdArgs)); } -/// Helper routine for seeing if we should use dsymutil; this is a -/// gcc compatible hack, we should remove it and use the input -/// type information. -static bool isSourceSuffix(const char *Str) { - // match: 'C', 'CPP', 'c', 'cc', 'cp', 'c++', 'cpp', 'cxx', 'm', - // 'mm'. - return llvm::StringSwitch<bool>(Str) - .Case("C", true) - .Case("c", true) - .Case("m", true) - .Case("cc", true) - .Case("cp", true) - .Case("mm", true) - .Case("CPP", true) - .Case("c++", true) - .Case("cpp", true) - .Case("cxx", true) - .Default(false); -} - void darwin::DarwinTool::AddDarwinArch(const ArgList &Args, ArgStringList &CmdArgs) const { llvm::StringRef ArchName = getDarwinToolChain().getDarwinArchName(Args); @@ -2555,28 +2535,6 @@ void darwin::Link::ConstructJob(Compilation &C, const JobAction &JA, break; } } - - // Run dsymutil if we are making an executable in a single step. - // - // FIXME: Currently we don't want to do this when we are part of a - // universal build step, as this would end up creating stray temp - // files. - if (!LinkingOutput && - Args.getLastArg(options::OPT_g_Group) && - !Args.getLastArg(options::OPT_gstabs) && - !Args.getLastArg(options::OPT_g0)) { - // FIXME: This is gross, but matches gcc. The test only considers - // the suffix (not the -x type), and then only of the first - // source input. Awesome. - const char *Suffix = strrchr(BaseInput, '.'); - if (Suffix && isSourceSuffix(Suffix + 1)) { - const char *Exec = - Args.MakeArgString(getToolChain().GetProgramPath(C, "dsymutil")); - ArgStringList CmdArgs; - CmdArgs.push_back(Output.getFilename()); - C.getJobs().addCommand(new Command(JA, *this, Exec, CmdArgs)); - } - } } void darwin::Lipo::ConstructJob(Compilation &C, const JobAction &JA, |