Driver: Add and use darwin::Assemble tool.
- Based on patch from Pieter de Bie; thanks!
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@67379 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Driver/ToolChains.cpp b/lib/Driver/ToolChains.cpp
index 3941726..3165a8f 100644
--- a/lib/Driver/ToolChains.cpp
+++ b/lib/Driver/ToolChains.cpp
@@ -44,7 +44,7 @@
case Action::CompileJobClass:
T = new tools::gcc::Compile(*this); break;
case Action::AssembleJobClass:
- T = new tools::gcc::Assemble(*this); break;
+ T = new tools::darwin::Assemble(*this); break;
case Action::LinkJobClass:
T = new tools::gcc::Link(*this); break;
case Action::LipoJobClass:
diff --git a/lib/Driver/Tools.cpp b/lib/Driver/Tools.cpp
index 9ac20f9..9a3930c 100644
--- a/lib/Driver/Tools.cpp
+++ b/lib/Driver/Tools.cpp
@@ -438,10 +438,56 @@
// The types are (hopefully) good enough.
}
+void darwin::Assemble::ConstructJob(Compilation &C, const JobAction &JA,
+ Job &Dest, const InputInfo &Output,
+ const InputInfoList &Inputs,
+ const ArgList &Args,
+ const char *LinkingOutput) const {
+ ArgStringList CmdArgs;
+
+ assert(Inputs.size() == 1 && "Unexpected number of inputs.");
+ const InputInfo &Input = Inputs[0];
+
+ // Bit of a hack, this is only used for original inputs.
+ if (Input.isFilename() &&
+ strcmp(Input.getFilename(), Input.getBaseInput()) == 0 &&
+ Args.hasArg(options::OPT_g_Group))
+ CmdArgs.push_back("--gstabs");
+
+ // Derived from asm spec.
+ CmdArgs.push_back("-arch");
+ CmdArgs.push_back(getToolChain().getArchName().c_str());
+
+ CmdArgs.push_back("-force_cpusubtype_ALL");
+ if ((Args.hasArg(options::OPT_mkernel) ||
+ Args.hasArg(options::OPT_static) ||
+ Args.hasArg(options::OPT_fapple_kext)) &&
+ !Args.hasArg(options::OPT_dynamic))
+ CmdArgs.push_back("-static");
+
+ Args.AddAllArgValues(CmdArgs, options::OPT_Wa_COMMA,
+ options::OPT_Xassembler);
+
+ assert(Output.isFilename() && "Unexpected lipo output.");
+ CmdArgs.push_back("-o");
+ CmdArgs.push_back(Output.getFilename());
+
+ if (Input.isPipe()) {
+ CmdArgs.push_back("-");
+ } else {
+ assert(Input.isFilename() && "Invalid input.");
+ CmdArgs.push_back(Input.getFilename());
+ }
+
+ // asm_final spec is empty.
+
+ const char *Exec =
+ Args.MakeArgString(getToolChain().GetProgramPath(C, "as").c_str());
+ Dest.addCommand(new Command(Exec, CmdArgs));
+}
void darwin::Lipo::ConstructJob(Compilation &C, const JobAction &JA,
- Job &Dest,
- const InputInfo &Output,
+ Job &Dest, const InputInfo &Output,
const InputInfoList &Inputs,
const ArgList &Args,
const char *LinkingOutput) const {
diff --git a/lib/Driver/Tools.h b/lib/Driver/Tools.h
index 40aa208..672096e 100644
--- a/lib/Driver/Tools.h
+++ b/lib/Driver/Tools.h
@@ -111,9 +111,25 @@
} // end namespace gcc
namespace darwin {
+ class VISIBILITY_HIDDEN Assemble : public Tool {
+ public:
+ Assemble(const ToolChain &TC) : Tool("darwin::Assemble", TC) {}
+
+ virtual bool acceptsPipedInput() const { return true; }
+ virtual bool canPipeOutput() const { return false; }
+ virtual bool hasIntegratedCPP() const { return false; }
+
+ virtual void ConstructJob(Compilation &C, const JobAction &JA,
+ Job &Dest,
+ const InputInfo &Output,
+ const InputInfoList &Inputs,
+ const ArgList &TCArgs,
+ const char *LinkingOutput) const;
+ };
+
class VISIBILITY_HIDDEN Lipo : public Tool {
public:
- Lipo(const ToolChain &TC) : Tool("gcc::Link", TC) {}
+ Lipo(const ToolChain &TC) : Tool("darwin::Lipo", TC) {}
virtual bool acceptsPipedInput() const { return false; }
virtual bool canPipeOutput() const { return false; }