summaryrefslogtreecommitdiffstats
path: root/clang/tools/ccc/ccclib/ToolChain.py
diff options
context:
space:
mode:
authorDaniel Dunbar <daniel@zuster.org>2009-01-29 23:54:06 +0000
committerDaniel Dunbar <daniel@zuster.org>2009-01-29 23:54:06 +0000
commit711e882c1bc0a59893e491f114e8917607242ea5 (patch)
treeae4fed71b52782cb34eb3dfac6e7e982cf6e93c9 /clang/tools/ccc/ccclib/ToolChain.py
parent38b9c05f1c39aac215e9a41afd1e8f645f2474d3 (diff)
downloadbcm5719-llvm-711e882c1bc0a59893e491f114e8917607242ea5.tar.gz
bcm5719-llvm-711e882c1bc0a59893e491f114e8917607242ea5.zip
ccc: Embrace destiny as a clang compiler driver.
This redoes the default mode that ccc runs in w.r.t. using clang. Now ccc defaults to always using clang for any task clang can handle. However, the following options exist to tweak this behavior: -ccc-no-clang: Don't use clang at all for compilation (still used for static analysis). -ccc-no-clang-cxx: Don't use clang for C++ and Objective-C++ inputs. -ccc-no-clang-cpp: Don't use clang as a preprocessor. -ccc-clang-archs <archs>: If present, only use clang for the given comma separated list of architectures. This only works on Darwin for now. Note that all -ccc options must be first on the command line. llvm-svn: 63346
Diffstat (limited to 'clang/tools/ccc/ccclib/ToolChain.py')
-rw-r--r--clang/tools/ccc/ccclib/ToolChain.py61
1 files changed, 38 insertions, 23 deletions
diff --git a/clang/tools/ccc/ccclib/ToolChain.py b/clang/tools/ccc/ccclib/ToolChain.py
index 73b0127e144..6ce6ebc341f 100644
--- a/clang/tools/ccc/ccclib/ToolChain.py
+++ b/clang/tools/ccc/ccclib/ToolChain.py
@@ -54,6 +54,28 @@ class ToolChain(object):
else:
return args
+ def shouldUseClangCompiler(self, action):
+ # If user requested no clang, or this isn't a "compile" phase,
+ # or this isn't a C family option, then don't use clang.
+ if (self.driver.cccNoClang or
+ not isinstance(action.phase, (Phases.PreprocessPhase,
+ Phases.CompilePhase,
+ Phases.SyntaxOnlyPhase,
+ Phases.EmitLLVMPhase,
+ Phases.PrecompilePhase)) or
+ action.inputs[0].type not in Types.cTypesSet):
+ return False
+
+ if self.driver.cccNoClangPreprocessor:
+ if isinstance(action.phase, Phases.PreprocessPhase):
+ return False
+
+ if self.driver.cccNoClangCXX:
+ if action.inputs[0].type in Types.cxxTypesSet:
+ return False
+
+ return True
+
class Darwin_X86_ToolChain(ToolChain):
def __init__(self, driver, darwinVersion, gccVersion, archName):
super(Darwin_X86_ToolChain, self).__init__(driver)
@@ -106,20 +128,23 @@ 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)
- if self.driver.cccClang and self.archName == 'i386':
- if (action.inputs[0].type in (Types.CType, Types.CTypeNoPP,
- Types.ObjCType, Types.ObjCTypeNoPP) and
- (isinstance(action.phase, Phases.CompilePhase) or
- isinstance(action.phase, Phases.SyntaxOnlyPhase) or
- isinstance(action.phase, Phases.EmitLLVMPhase))):
- return self.clangTool
- elif (action.inputs[0].type in (Types.CHeaderType, Types.CHeaderNoPPType,
- Types.ObjCHeaderType, Types.ObjCHeaderNoPPType) and
- isinstance(action.phase, Phases.PrecompilePhase)):
- return self.clangTool
+ if self.shouldUseClangCompiler(action):
+ return self.clangTool
return self.toolMap[action.phase.__class__]
@@ -220,17 +245,7 @@ class Generic_GCC_ToolChain(ToolChain):
def selectTool(self, action):
assert isinstance(action, Phases.JobAction)
- if self.driver.cccClang:
- if (action.inputs[0].type in (Types.CType, Types.CTypeNoPP,
- Types.ObjCType, Types.ObjCTypeNoPP) and
- (isinstance(action.phase, Phases.PreprocessPhase) or
- isinstance(action.phase, Phases.CompilePhase) or
- isinstance(action.phase, Phases.SyntaxOnlyPhase) or
- isinstance(action.phase, Phases.EmitLLVMPhase))):
- return self.clangTool
- elif (action.inputs[0].type in (Types.CHeaderType, Types.CHeaderNoPPType,
- Types.ObjCHeaderType, Types.ObjCHeaderNoPPType) and
- isinstance(action.phase, Phases.PrecompilePhase)):
- return self.clangTool
+ if self.shouldUseClangCompiler(action):
+ return self.clangTool
return self.toolMap[action.phase.__class__]
OpenPOWER on IntegriCloud