Driver: Fix fallback to gcc to -c instead of -S if trying to generate an LLVM bc
file.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@94463 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Driver/Tools.cpp b/lib/Driver/Tools.cpp
index afb22a2..29dd3f5 100644
--- a/lib/Driver/Tools.cpp
+++ b/lib/Driver/Tools.cpp
@@ -1213,7 +1213,7 @@
}
}
- RenderExtraToolArgs(CmdArgs);
+ RenderExtraToolArgs(JA, CmdArgs);
// If using a driver driver, force the arch.
const std::string &Arch = getToolChain().getArchName();
@@ -1291,23 +1291,32 @@
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 {
+ // If -flto, etc. are present then make sure not to force assembly output.
+ if (JA.getType() == types::TY_LLVMBC)
+ CmdArgs.push_back("-c");
+ else
+ 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.
}
diff --git a/lib/Driver/Tools.h b/lib/Driver/Tools.h
index abd8cfc..572c7f4 100644
--- a/lib/Driver/Tools.h
+++ b/lib/Driver/Tools.h
@@ -66,7 +66,8 @@
/// 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 +79,8 @@
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 +91,8 @@
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 +103,8 @@
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 +115,8 @@
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 +127,8 @@
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