Reject -no-integrated-as on windows.

llvm-svn: 177840
This commit is contained in:
Rafael Espindola 2013-03-24 15:06:53 +00:00
parent fb36ede52e
commit 7976446c2c
7 changed files with 27 additions and 21 deletions

View File

@ -35,6 +35,8 @@ def err_drv_use_of_Z_option : Error<
"unsupported use of internal gcc -Z option '%0'">; "unsupported use of internal gcc -Z option '%0'">;
def err_drv_output_argument_with_multiple_files : Error< def err_drv_output_argument_with_multiple_files : Error<
"cannot specify -o when generating multiple output files">; "cannot specify -o when generating multiple output files">;
def err_no_external_windows_assembler : Error<
"there is no external assembler we can use on windows">;
def err_drv_unable_to_remove_file : Error< def err_drv_unable_to_remove_file : Error<
"unable to remove file: %0">; "unable to remove file: %0">;
def err_drv_command_failure : Error< def err_drv_command_failure : Error<

View File

@ -127,7 +127,7 @@ public:
} }
/// Choose a tool to use to handle the action \p JA. /// Choose a tool to use to handle the action \p JA.
Tool &SelectTool(const JobAction &JA) const; Tool *SelectTool(const JobAction &JA) const;
// Helper methods // Helper methods

View File

@ -1288,7 +1288,7 @@ void Driver::BuildJobs(Compilation &C) const {
} }
} }
static const Tool &SelectToolForJob(Compilation &C, const ToolChain *TC, static const Tool *SelectToolForJob(Compilation &C, const ToolChain *TC,
const JobAction *JA, const JobAction *JA,
const ActionList *&Inputs) { const ActionList *&Inputs) {
const Tool *ToolForJob = 0; const Tool *ToolForJob = 0;
@ -1301,17 +1301,19 @@ static const Tool &SelectToolForJob(Compilation &C, const ToolChain *TC,
!C.getArgs().hasArg(options::OPT_save_temps) && !C.getArgs().hasArg(options::OPT_save_temps) &&
isa<AssembleJobAction>(JA) && isa<AssembleJobAction>(JA) &&
Inputs->size() == 1 && isa<CompileJobAction>(*Inputs->begin())) { Inputs->size() == 1 && isa<CompileJobAction>(*Inputs->begin())) {
const Tool &Compiler = const Tool *Compiler =
TC->SelectTool(cast<JobAction>(**Inputs->begin())); TC->SelectTool(cast<JobAction>(**Inputs->begin()));
if (Compiler.hasIntegratedAssembler()) { if (!Compiler)
return NULL;
if (Compiler->hasIntegratedAssembler()) {
Inputs = &(*Inputs)[0]->getInputs(); Inputs = &(*Inputs)[0]->getInputs();
ToolForJob = &Compiler; ToolForJob = Compiler;
} }
} }
// Otherwise use the tool for the current job. // Otherwise use the tool for the current job.
if (!ToolForJob) if (!ToolForJob)
ToolForJob = &TC->SelectTool(*JA); ToolForJob = TC->SelectTool(*JA);
// See if we should use an integrated preprocessor. We do so when we have // 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 // exactly one input, since this is the only use case we care about
@ -1324,7 +1326,7 @@ static const Tool &SelectToolForJob(Compilation &C, const ToolChain *TC,
ToolForJob->hasIntegratedCPP()) ToolForJob->hasIntegratedCPP())
Inputs = &(*Inputs)[0]->getInputs(); Inputs = &(*Inputs)[0]->getInputs();
return *ToolForJob; return ToolForJob;
} }
void Driver::BuildJobsForAction(Compilation &C, void Driver::BuildJobsForAction(Compilation &C,
@ -1366,7 +1368,9 @@ void Driver::BuildJobsForAction(Compilation &C,
const ActionList *Inputs = &A->getInputs(); const ActionList *Inputs = &A->getInputs();
const JobAction *JA = cast<JobAction>(A); const JobAction *JA = cast<JobAction>(A);
const Tool &T = SelectToolForJob(C, TC, JA, Inputs); const Tool *T = SelectToolForJob(C, TC, JA, Inputs);
if (!T)
return;
// Only use pipes when there is exactly one input. // Only use pipes when there is exactly one input.
InputInfoList InputInfos; InputInfoList InputInfos;
@ -1401,8 +1405,8 @@ void Driver::BuildJobsForAction(Compilation &C,
A->getType(), BaseInput); A->getType(), BaseInput);
if (CCCPrintBindings && !CCGenDiagnostics) { if (CCCPrintBindings && !CCGenDiagnostics) {
llvm::errs() << "# \"" << T.getToolChain().getTripleString() << '"' llvm::errs() << "# \"" << T->getToolChain().getTripleString() << '"'
<< " - \"" << T.getName() << "\", inputs: ["; << " - \"" << T->getName() << "\", inputs: [";
for (unsigned i = 0, e = InputInfos.size(); i != e; ++i) { for (unsigned i = 0, e = InputInfos.size(); i != e; ++i) {
llvm::errs() << InputInfos[i].getAsString(); llvm::errs() << InputInfos[i].getAsString();
if (i + 1 != e) if (i + 1 != e)
@ -1410,8 +1414,8 @@ void Driver::BuildJobsForAction(Compilation &C,
} }
llvm::errs() << "], output: " << Result.getAsString() << "\n"; llvm::errs() << "], output: " << Result.getAsString() << "\n";
} else { } else {
T.ConstructJob(C, *JA, Result, InputInfos, T->ConstructJob(C, *JA, Result, InputInfos,
C.getArgsForToolChain(TC, BoundArch), LinkingOutput); C.getArgsForToolChain(TC, BoundArch), LinkingOutput);
} }
} }

View File

@ -117,13 +117,13 @@ Tool *ToolChain::getTool(Action::ActionClass AC) const {
llvm_unreachable("Invalid tool kind."); llvm_unreachable("Invalid tool kind.");
} }
Tool &ToolChain::SelectTool(const JobAction &JA) const { Tool *ToolChain::SelectTool(const JobAction &JA) const {
if (getDriver().ShouldUseClangCompiler(JA)) if (getDriver().ShouldUseClangCompiler(JA))
return *getClang(); return getClang();
Action::ActionClass AC = JA.getKind(); Action::ActionClass AC = JA.getKind();
if (AC == Action::AssembleJobClass && useIntegratedAs()) if (AC == Action::AssembleJobClass && useIntegratedAs())
return *getClangAs(); return getClangAs();
return *getTool(AC); return getTool(AC);
} }
std::string ToolChain::GetFilePath(const char *Name) const { std::string ToolChain::GetFilePath(const char *Name) const {

View File

@ -14,6 +14,7 @@
#include "clang/Driver/ArgList.h" #include "clang/Driver/ArgList.h"
#include "clang/Driver/Compilation.h" #include "clang/Driver/Compilation.h"
#include "clang/Driver/Driver.h" #include "clang/Driver/Driver.h"
#include "clang/Driver/DriverDiagnostic.h"
#include "clang/Driver/Options.h" #include "clang/Driver/Options.h"
#include "llvm/Support/ErrorHandling.h" #include "llvm/Support/ErrorHandling.h"
#include "llvm/Support/Path.h" #include "llvm/Support/Path.h"
@ -43,10 +44,8 @@ Tool *Windows::buildLinker() const {
Tool *Windows::buildAssembler() const { Tool *Windows::buildAssembler() const {
if (getTriple().getEnvironment() == llvm::Triple::MachO) if (getTriple().getEnvironment() == llvm::Triple::MachO)
return new tools::darwin::Assemble(*this); return new tools::darwin::Assemble(*this);
else getDriver().Diag(clang::diag::err_no_external_windows_assembler);
// There no assembler we can use on windows other than the integrated return NULL;
// assembler, so we ignore -no-integrated-as.
return ToolChain::buildAssembler();
} }
bool Windows::IsIntegratedAssemblerDefault() const { bool Windows::IsIntegratedAssemblerDefault() const {

View File

@ -2,4 +2,5 @@
// CHECK: error: unknown type name 'invalid' // CHECK: error: unknown type name 'invalid'
// CHECK-NOT: clang: error: assembler command failed // CHECK-NOT: clang: error: assembler command failed
// CHECK-NOT: clang: error: linker command failed // CHECK-NOT: clang: error: linker command failed
// XFAIL: win32
invalid C code! invalid C code!

View File

@ -1,3 +1,3 @@
// RUN: %clang -target x86_64-pc-win32 -### -no-integrated-as %s -c 2>&1 | FileCheck %s // RUN: %clang -target x86_64-pc-win32 -### -no-integrated-as %s -c 2>&1 | FileCheck %s
// CHECK: cc1as" "-triple" "x86_64-pc-win32" // CHECK: there is no external assembler we can use on windows