]> granicus.if.org Git - clang/commitdiff
ccc: Use toolChain arch name instead of looking for arch command line
authorDaniel Dunbar <daniel@zuster.org>
Fri, 20 Feb 2009 01:48:01 +0000 (01:48 +0000)
committerDaniel Dunbar <daniel@zuster.org>
Fri, 20 Feb 2009 01:48:01 +0000 (01:48 +0000)
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

tools/ccc/ccclib/HostInfo.py
tools/ccc/ccclib/ToolChain.py
tools/ccc/ccclib/Tools.py
tools/ccc/test/ccc/universal-hello.c

index e95ffa1e44143363f24cb3af51a9d97690bbc3b0..d1ec28d0b38628b3803f74258279ed69f94f18e0 100644 (file)
@@ -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):
index 2fe482ecd24f31d104555c2ee45f1f97fb97240f..aa1646a5b5145ba9be34fc9c18e01f47f02d85d6 100644 (file)
@@ -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)
         
index dc349be50e2c7b1e2ca6816ba88b385dc6074b1a..c1146a0fb260078bffd27fdb7548afe1d8746635 100644 (file)
@@ -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,
index 654c43507a1f20477786db40de0384ad8265511b..480a330436710a286422bad8ca7b1c940cf215a0 100644 (file)
@@ -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");