Driver: Call 'as' directly on FreeBSD.
- Patch by Ed Schouten!
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@68121 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Driver/ToolChains.cpp b/lib/Driver/ToolChains.cpp
index 6d51273..3401dce 100644
--- a/lib/Driver/ToolChains.cpp
+++ b/lib/Driver/ToolChains.cpp
@@ -389,6 +389,8 @@
Tool *&T = Tools[Key];
if (!T) {
switch (Key) {
+ case Action::AssembleJobClass:
+ T = new tools::freebsd::Assemble(*this); break;
default:
T = &Generic_GCC::SelectTool(C, JA);
}
diff --git a/lib/Driver/Tools.cpp b/lib/Driver/Tools.cpp
index cae0766..2f8bc2f 100644
--- a/lib/Driver/Tools.cpp
+++ b/lib/Driver/Tools.cpp
@@ -1451,3 +1451,39 @@
Args.MakeArgString(getToolChain().GetProgramPath(C, "lipo").c_str());
Dest.addCommand(new Command(Exec, CmdArgs));
}
+
+void freebsd::Assemble::ConstructJob(Compilation &C, const JobAction &JA,
+ Job &Dest, const InputInfo &Output,
+ const InputInfoList &Inputs,
+ const ArgList &Args,
+ const char *LinkingOutput) const
+{
+ ArgStringList CmdArgs;
+
+ // Conceptually, i386 on x86_64 is a separate tool chain, but for
+ // now we just detect this situation by looking for -m32.
+ if (Args.hasArg(options::OPT_m32))
+ CmdArgs.push_back("--32");
+
+ Args.AddAllArgValues(CmdArgs, options::OPT_Wa_COMMA,
+ options::OPT_Xassembler);
+
+ CmdArgs.push_back("-o");
+ if (Output.isPipe())
+ CmdArgs.push_back("-");
+ else
+ CmdArgs.push_back(Output.getFilename());
+
+ for (InputInfoList::const_iterator
+ it = Inputs.begin(), ie = Inputs.end(); it != ie; ++it) {
+ const InputInfo &II = *it;
+ if (II.isPipe())
+ CmdArgs.push_back("-");
+ else
+ CmdArgs.push_back(II.getFilename());
+ }
+
+ const char *Exec =
+ Args.MakeArgString(getToolChain().GetProgramPath(C, "as").c_str());
+ Dest.addCommand(new Command(Exec, CmdArgs));
+}
diff --git a/lib/Driver/Tools.h b/lib/Driver/Tools.h
index 7ad60ed..d9716ba 100644
--- a/lib/Driver/Tools.h
+++ b/lib/Driver/Tools.h
@@ -233,6 +233,25 @@
};
}
+ /// freebsd -- Directly call GNU Binutils assembler and linker
+namespace freebsd {
+ class VISIBILITY_HIDDEN Assemble : public Tool {
+ public:
+ Assemble(const ToolChain &TC) : Tool("freebsd::Assemble", TC) {}
+
+ virtual bool acceptsPipedInput() const { return true; }
+ virtual bool canPipeOutput() const { return true; }
+ 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;
+ };
+}
+
} // end namespace toolchains
} // end namespace driver
} // end namespace clang