forked from OSchip/llvm-project
ccc/Driver: .s defaults to 'assembler-with-cpp' on Darwin.
- <rdar://problem/6669441> ccc doesn't handle assembler-with-cpp semantics correctly (but clang supports it) - This is sad, because it requires a fairly useless target hook. C'est la vie. llvm-svn: 67418
This commit is contained in:
parent
52a47e9c7b
commit
ea9f032613
|
@ -10,6 +10,7 @@
|
|||
#ifndef CLANG_DRIVER_HOSTINFO_H_
|
||||
#define CLANG_DRIVER_HOSTINFO_H_
|
||||
|
||||
#include "clang/Driver/Types.h"
|
||||
#include <string>
|
||||
|
||||
namespace clang {
|
||||
|
@ -45,6 +46,10 @@ public:
|
|||
/// driver for this host and support -arch, -Xarch, etc.
|
||||
virtual bool useDriverDriver() const = 0;
|
||||
|
||||
/// lookupTypeForExtension - Return the default language type to use
|
||||
/// for the given extension.
|
||||
virtual types::ID lookupTypeForExtension(const char *Ext) const = 0;
|
||||
|
||||
/// getToolChain - Construct the toolchain to use for this host.
|
||||
///
|
||||
/// \param Args - The argument list, which may be used to alter the
|
||||
|
|
|
@ -445,9 +445,11 @@ void Driver::BuildActions(const ArgList &Args, ActionList &Actions) const {
|
|||
Ty = types::TY_C;
|
||||
} else {
|
||||
// Otherwise lookup by extension, and fallback to ObjectType
|
||||
// if not found.
|
||||
// if not found. We use a host hook here because Darwin at
|
||||
// least has its own idea of what .s is.
|
||||
if (const char *Ext = strrchr(Value, '.'))
|
||||
Ty = types::lookupTypeForExtension(Ext + 1);
|
||||
Ty = Host->lookupTypeForExtension(Ext + 1);
|
||||
|
||||
if (Ty == types::TY_INVALID)
|
||||
Ty = types::TY_Object;
|
||||
}
|
||||
|
|
|
@ -57,6 +57,17 @@ public:
|
|||
|
||||
virtual bool useDriverDriver() const;
|
||||
|
||||
virtual types::ID lookupTypeForExtension(const char *Ext) const {
|
||||
types::ID Ty = types::lookupTypeForExtension(Ext);
|
||||
|
||||
// Darwin always preprocesses assembly files (unless -x is used
|
||||
// explicitly).
|
||||
if (Ty == types::TY_PP_Asm)
|
||||
return types::TY_Asm;
|
||||
|
||||
return Ty;
|
||||
}
|
||||
|
||||
virtual ToolChain *getToolChain(const ArgList &Args,
|
||||
const char *ArchName) const;
|
||||
};
|
||||
|
@ -173,6 +184,10 @@ public:
|
|||
|
||||
virtual bool useDriverDriver() const;
|
||||
|
||||
virtual types::ID lookupTypeForExtension(const char *Ext) const {
|
||||
return types::lookupTypeForExtension(Ext);
|
||||
}
|
||||
|
||||
virtual ToolChain *getToolChain(const ArgList &Args,
|
||||
const char *ArchName) const;
|
||||
};
|
||||
|
|
|
@ -66,4 +66,14 @@
|
|||
// RUN: grep -F '1: preprocessor, {0}, c-header-cpp-output' %t &&
|
||||
// RUN: grep -F '2: precompiler, {1}, precompiled-header' %t &&
|
||||
|
||||
// Darwin overrides the handling for .s
|
||||
// RUN: touch %t.s &&
|
||||
// RUN: clang-driver -ccc-host-triple i386-unknown-unknown -ccc-print-phases -c %t.s &> %t &&
|
||||
// RUN: grep '0: input, ".*\.s", assembler' %t &&
|
||||
// RUN: grep -F '1: assembler, {0}, object' %t &&
|
||||
// RUN: clang-driver -ccc-host-triple i386-apple-darwin9 -ccc-print-phases -c %t.s &> %t &&
|
||||
// RUN: grep '0: input, ".*\.s", assembler-with-cpp' %t &&
|
||||
// RUN: grep -F '1: preprocessor, {0}, assembler' %t &&
|
||||
// RUN: grep -F '2: assembler, {1}, object' %t &&
|
||||
|
||||
// RUN: true
|
||||
|
|
|
@ -426,7 +426,7 @@ class Driver(object):
|
|||
else:
|
||||
raise Arguments.InvalidArgumentsError("-E or -x required when input is from standard input")
|
||||
elif ext and ext in Types.kTypeSuffixMap:
|
||||
klass = Types.kTypeSuffixMap[ext]
|
||||
klass = self.hostInfo.lookupTypeForExtension(ext)
|
||||
else:
|
||||
# FIXME: Its not clear why we shouldn't just
|
||||
# revert to unknown. I think this is more likely a
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
import ToolChain
|
||||
import Types
|
||||
|
||||
class HostInfo(object):
|
||||
"""HostInfo - Config information about a particular host which may
|
||||
|
@ -14,6 +15,9 @@ class HostInfo(object):
|
|||
def useDriverDriver(self):
|
||||
abstract
|
||||
|
||||
def lookupTypeForExtension(self, ext):
|
||||
abstract
|
||||
|
||||
def getToolChain(self):
|
||||
abstract
|
||||
|
||||
|
@ -37,6 +41,12 @@ class DarwinHostInfo(HostInfo):
|
|||
def useDriverDriver(self):
|
||||
return True
|
||||
|
||||
def lookupTypeForExtension(self, ext):
|
||||
ty = Types.kTypeSuffixMap.get(ext)
|
||||
if ty is Types.AsmTypeNoPP:
|
||||
return Types.AsmType
|
||||
return ty
|
||||
|
||||
def getToolChain(self):
|
||||
return self.getToolChainForArch(self.getArchName(None))
|
||||
|
||||
|
@ -98,6 +108,9 @@ class UnknownHostInfo(HostInfo):
|
|||
def useDriverDriver(self):
|
||||
return False
|
||||
|
||||
def lookupTypeForExtension(self, ext):
|
||||
return Types.kTypeSuffixMap.get(ext)
|
||||
|
||||
def getToolChain(self):
|
||||
return ToolChain.Generic_GCC_ToolChain(self.driver, '')
|
||||
|
||||
|
|
Loading…
Reference in New Issue