diff options
author | Daniel Dunbar <daniel@zuster.org> | 2009-02-20 01:48:01 +0000 |
---|---|---|
committer | Daniel Dunbar <daniel@zuster.org> | 2009-02-20 01:48:01 +0000 |
commit | a805135a1677f97c1753f9b02113ad1fadb9ddd4 (patch) | |
tree | fe47ffd3b7097c33425a90759d9b4e7bba94ec1e | |
parent | 67762a35dca6202d2272db02d0b8740728e3aa8f (diff) |
ccc: Use toolChain arch name instead of looking for arch command line
argument; the toolchain should always know the arch.
- Fixes: <rdar://problem/6582911> -ccc-clang-archs doesn't work for excluding ppc
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@65104 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | tools/ccc/ccclib/HostInfo.py | 2 | ||||
-rw-r--r-- | tools/ccc/ccclib/ToolChain.py | 18 | ||||
-rw-r--r-- | tools/ccc/ccclib/Tools.py | 44 | ||||
-rw-r--r-- | tools/ccc/test/ccc/universal-hello.c | 5 |
4 files changed, 33 insertions, 36 deletions
diff --git a/tools/ccc/ccclib/HostInfo.py b/tools/ccc/ccclib/HostInfo.py index e95ffa1e44..d1ec28d0b3 100644 --- a/tools/ccc/ccclib/HostInfo.py +++ b/tools/ccc/ccclib/HostInfo.py @@ -47,7 +47,7 @@ class DarwinHostInfo(HostInfo): self.darwinVersion, self.gccVersion) - return ToolChain.Generic_GCC_ToolChain(self.driver, '') + return ToolChain.Generic_GCC_ToolChain(self.driver, arch) class DarwinPPCHostInfo(DarwinHostInfo): def getArchName(self, args): diff --git a/tools/ccc/ccclib/ToolChain.py b/tools/ccc/ccclib/ToolChain.py index 2fe482ecd2..aa1646a5b5 100644 --- a/tools/ccc/ccclib/ToolChain.py +++ b/tools/ccc/ccclib/ToolChain.py @@ -74,6 +74,12 @@ class ToolChain(object): if self.driver.cccNoClangCXX: if action.inputs[0].type in Types.cxxTypesSet: return False + + # Don't use clang if this isn't one of the user specified + # archs to build. + if (self.driver.cccClangArchs and + self.archName not in self.driver.cccClangArchs): + return False return True @@ -131,18 +137,6 @@ class Darwin_X86_ToolChain(ToolChain): major,minor,minorminor = self.darwinVersion return '%d.%d.%d' % (10, major-4, minor) - def shouldUseClangCompiler(self, action): - if not super(Darwin_X86_ToolChain, self).shouldUseClangCompiler(action): - return False - - # Only use clang if user didn't override archs, or this is one - # of the ones they provided. - if (not self.driver.cccClangArchs or - self.archName in self.driver.cccClangArchs): - return True - - return False - def selectTool(self, action): assert isinstance(action, Phases.JobAction) diff --git a/tools/ccc/ccclib/Tools.py b/tools/ccc/ccclib/Tools.py index dc349be50e..c1146a0fb2 100644 --- a/tools/ccc/ccclib/Tools.py +++ b/tools/ccc/ccclib/Tools.py @@ -37,8 +37,13 @@ class GCC_Common_Tool(Tool): cmd_args.extend(arglist.render(arg)) cmd_args.extend(self.getGCCExtraArgs()) - if arch: - cmd_args.extend(arglist.render(arch)) + + # If using a driver driver, force the arch. + if self.toolChain.driver.hostInfo.useDriverDriver(): + # FIXME: Remove this branch once ok. + cmd_args.append('-arch') + cmd_args.append(self.toolChain.archName) + if isinstance(output, Jobs.PipedJob): cmd_args.extend(['-o', '-']) elif isinstance(phase.phase, Phases.SyntaxOnlyPhase): @@ -141,8 +146,9 @@ class Darwin_AssembleTool(Tool): cmd_args.append('--gstabs') # Derived from asm spec. - if arch: - cmd_args.extend(arglist.render(arch)) + cmd_args.append('-arch') + cmd_args.append(self.toolChain.archName) + cmd_args.append('-force_cpusubtype_ALL') if (arglist.getLastArg(arglist.parser.m_kernelOption) or arglist.getLastArg(arglist.parser.staticOption) or @@ -252,13 +258,11 @@ class Clang_CompileTool(Tool): not arglist.getLastArg(arglist.parser.m_dynamicNoPicOption))) # FIXME: This needs to tie into a platform hook. - if arch: - archName = arglist.getValue(arch) - if (archName == 'x86_64' or - picEnabled): - cmd_args.append('--relocation-model=pic') - elif not arglist.getLastArg(arglist.parser.m_dynamicNoPicOption): - cmd_args.append('--relocation-model=static') + if (self.toolChain.archName == 'x86_64' or + picEnabled): + cmd_args.append('--relocation-model=pic') + elif not arglist.getLastArg(arglist.parser.m_dynamicNoPicOption): + cmd_args.append('--relocation-model=static') if arglist.getLastArg(arglist.parser.f_timeReportOption): cmd_args.append('--time-passes') @@ -353,8 +357,10 @@ class Clang_CompileTool(Tool): for arg in arglist.getArgs(arglist.parser.XclangOption): cmd_args.extend(arglist.getValues(arg)) - if arch is not None: - cmd_args.extend(arglist.render(arch)) + # FIXME: We should always pass this once it is always known. + if self.toolChain.archName: + cmd_args.append('-arch') + cmd_args.append(self.toolChain.archName) if isinstance(output, Jobs.PipedJob): cmd_args.extend(['-o', '-']) @@ -583,7 +589,7 @@ class Darwin_X86_CC1Tool(Tool): arglist.addLastArg(cmd_args, arglist.parser.POption) # FIXME: Handle %I properly. - if arglist.getValue(arch) == 'x86_64': + if self.toolChain.archName == 'x86_64': cmd_args.append('-imultilib') cmd_args.append('x86_64') @@ -796,13 +802,7 @@ class Darwin_X86_LinkTool(Tool): def addDarwinArch(self, cmd_args, arch, arglist): # Derived from darwin_arch spec. cmd_args.append('-arch') - # FIXME: The actual spec uses -m64 for this, but we want to - # respect arch. Figure out what exactly gcc is doing. - #if arglist.getLastArg(arglist.parser.m_64Option): - if arglist.getValue(arch) == 'x86_64': - cmd_args.append('x86_64') - else: - cmd_args.append('i386') + cmd_args.append(self.toolChain.archName) def addDarwinSubArch(self, cmd_args, arch, arglist): # Derived from darwin_subarch spec, not sure what the @@ -1109,7 +1109,7 @@ class Darwin_X86_LinkTool(Tool): # FIXME: Derive these correctly. tcDir = self.toolChain.getToolChainDir() - if arglist.getValue(arch) == 'x86_64': + if self.toolChain.archName == 'x86_64': cmd_args.extend(["-L/usr/lib/gcc/%s/x86_64" % tcDir, "-L/usr/lib/gcc/%s/x86_64" % tcDir]) cmd_args.extend(["-L/usr/lib/%s" % tcDir, diff --git a/tools/ccc/test/ccc/universal-hello.c b/tools/ccc/test/ccc/universal-hello.c index 654c43507a..480a330436 100644 --- a/tools/ccc/test/ccc/universal-hello.c +++ b/tools/ccc/test/ccc/universal-hello.c @@ -5,7 +5,10 @@ // RUN: %t | grep "Hello, World" && // Check that multiple archs are handled properly. -// RUN: xcc -ccc-print-phases -### -arch ppc -arch ppc %s | grep linker- | count 1 +// RUN: xcc -ccc-print-phases -### -arch ppc -arch ppc %s | grep linker- | count 1 && + +// Check that -ccc-clang-archs is honored. +// RUN: xcc -ccc-clang-archs i386 -### -arch ppc -arch i386 %s 2>&1 | grep clang | count 1 int main() { printf("Hello, World!\n"); |