self.cccHostBits = self.cccHostMachine = None
self.cccHostSystem = self.cccHostRelease = None
self.cccCXX = False
- self.cccClang = False
self.cccEcho = False
self.cccFallback = False
+ self.cccNoClang = self.cccNoClangCXX = self.cccNoClangPreprocessor = False
+ self.cccClangArchs = None
# Certain options suppress the 'no input files' warning.
self.suppressMissingInputWarning = False
# FIXME: How to handle override of host? ccc specific options?
# Abuse -b?
- if self.getenvBool('CCC_CLANG'):
- self.cccClang = True
- if self.getenvBool('CCC_ECHO'):
- self.cccEcho = True
- if self.getenvBool('CCC_FALLBACK'):
- self.cccFallback = True
+ arg = os.getenv('CCC_ADD_ARGS')
+ if arg:
+ args = filter(None, map(str.strip, arg.split(',')))
+ argv = args + argv
while argv and argv[0].startswith('-ccc-'):
fullOpt,argv = argv[0],argv[1:]
cccPrintPhases = True
elif opt == 'cxx':
self.cccCXX = True
- elif opt == 'clang':
- self.cccClang = True
elif opt == 'echo':
self.cccEcho = True
elif opt == 'fallback':
self.cccFallback = True
+
+ elif opt == 'no-clang':
+ self.cccNoClang = True
+ elif opt == 'no-clang-cxx':
+ self.cccNoClangCXX = True
+ elif opt == 'no-clang-cpp':
+ self.cccNoClangPreprocessor = True
+ elif opt == 'clang-archs':
+ self.cccClangArchs,argv = argv[0].split(','),argv[1:]
+
elif opt == 'host-bits':
self.cccHostBits,argv = argv[0],argv[1:]
elif opt == 'host-machine':
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)
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__]
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__]
cmd_args.append('-emit-llvm-bc')
elif outputType is Types.AsmTypeNoPP:
cmd_args.append('-S')
+ elif (inputs[0].type.preprocess and
+ outputType is inputs[0].type.preprocess):
+ cmd_args.append('-E')
elif outputType is Types.PCHType:
# No special option needed, driven by -x. However, we
# patch the output name to try and not conflict with gcc.
'treelang' : TreelangType,
}
+# Set of C family types.
+cTypesSet = set([CType, CTypeNoPP,
+ ObjCType, ObjCTypeNoPP,
+ CXXType, CXXTypeNoPP,
+ ObjCXXType, ObjCXXTypeNoPP,
+ CHeaderType, CHeaderNoPPType,
+ ObjCHeaderType, ObjCHeaderNoPPType,
+ CXXHeaderType, CXXHeaderNoPPType,
+ ObjCXXHeaderType, ObjCXXHeaderNoPPType])
+
+# Set of C++ family types.
+cxxTypesSet = set([CXXType, CXXTypeNoPP,
+ ObjCXXType, ObjCXXTypeNoPP,
+ CXXHeaderType, CXXHeaderNoPPType,
+ ObjCXXHeaderType, ObjCXXHeaderNoPPType])
+
# Check that the type specifier map at least matches what the types
# believe to be true.
assert not [name for name,type in kTypeSpecifierMap.items()
-// RUN: xcc -### -fsyntax-only -Xarch_i386 -Wall -Xarch_ppc -Wunused -arch i386 -arch ppc %s &> %t &&
+// RUN: xcc -ccc-no-clang -### -fsyntax-only -Xarch_i386 -Wall -Xarch_ppc -Wunused -arch i386 -arch ppc %s &> %t &&
// RUN: grep '"-Xarch"' %t | count 0 &&
// RUN: grep '"-Wall"' %t | count 1 &&
// RUN: grep 'i686-apple' %t | grep -v '"-m64"' | count 1 &&
-// RUN: xcc -### -S --all-warnings %s &> %t &&
+// RUN: xcc -ccc-no-clang -### -S --all-warnings %s &> %t &&
// RUN: grep -- '"-Wall"' %t &&
-// RUN: xcc -### -S --ansi %s &> %t &&
+// RUN: xcc -ccc-no-clang -### -S --ansi %s &> %t &&
// RUN: grep -- '"-ansi"' %t &&
-// RUN: xcc -### -S --assert foo --assert=foo %s &> %t &&
+// RUN: xcc -ccc-no-clang -### -S --assert foo --assert=foo %s &> %t &&
// RUN: grep -- '"-A" "foo" "-A" "foo"' %t &&
-// RUN: xcc -### -S --classpath foo --classpath=foo %s &> %t &&
+// RUN: xcc -ccc-no-clang -### -S --classpath foo --classpath=foo %s &> %t &&
// RUN: grep -- '"-fclasspath=foo" "-fclasspath=foo"' %t &&
// RUN: true
// Check that object files compiled with -mdynamic-no-pic can be
// linked.
//
-// RUN: xcc -ccc-clang -m32 -mdynamic-no-pic %s -c -o %t.o &&
-// RUN: xcc -ccc-clang -m32 %t.o -o %t &&
+// RUN: xcc -m32 -mdynamic-no-pic %s -c -o %t.o &&
+// RUN: xcc -m32 %t.o -o %t &&
// RUN: %t | grep "Hello, World" &&
-// RUN: xcc -ccc-clang -m64 -mdynamic-no-pic %s -c -o %t.o &&
-// RUN: xcc -ccc-clang -m64 %t.o -o %t &&
+// RUN: xcc -m64 -mdynamic-no-pic %s -c -o %t.o &&
+// RUN: xcc -m64 %t.o -o %t &&
// RUN: %t | grep "Hello, World" &&
// RUN: true
-// RUN: xcc -ccc-host-bits 32 -ccc-host-machine i386 -ccc-host-system darwin -ccc-host-release 10.5.0 -### -x objective-c -arch i386 -fmessage-length=0 -Wno-trigraphs -fpascal-strings -fasm-blocks -Os -mdynamic-no-pic -DUSER_DEFINE_0 -fvisibility=hidden -mmacosx-version-min=10.5 -gdwarf-2 -IINCLUDE_PATH_0 -Wall -Wextra -Wno-missing-field-initializers -Wno-unused-parameter -Wno-four-char-constants -Wno-unknown-pragmas -Wno-format-y2k -Wpointer-arith -Wreturn-type -Wwrite-strings -Wswitch -Wcast-align -Wchar-subscripts -Winline -Wnested-externs -Wint-to-pointer-cast -Wpointer-to-int-cast -Wshorten-64-to-32 -FFRAMEWORK_0 -IINCLUDE_PATH_1 -FFRAMEWORK_1 -include USER_INCLUDE_0 -c %s -o %t.out &> %t.opts &&
+// RUN: xcc -ccc-no-clang -ccc-host-bits 32 -ccc-host-machine i386 -ccc-host-system darwin -ccc-host-release 10.5.0 -### -x objective-c -arch i386 -fmessage-length=0 -Wno-trigraphs -fpascal-strings -fasm-blocks -Os -mdynamic-no-pic -DUSER_DEFINE_0 -fvisibility=hidden -mmacosx-version-min=10.5 -gdwarf-2 -IINCLUDE_PATH_0 -Wall -Wextra -Wno-missing-field-initializers -Wno-unused-parameter -Wno-four-char-constants -Wno-unknown-pragmas -Wno-format-y2k -Wpointer-arith -Wreturn-type -Wwrite-strings -Wswitch -Wcast-align -Wchar-subscripts -Winline -Wnested-externs -Wint-to-pointer-cast -Wpointer-to-int-cast -Wshorten-64-to-32 -FFRAMEWORK_0 -IINCLUDE_PATH_1 -FFRAMEWORK_1 -include USER_INCLUDE_0 -c %s -o %t.out &> %t.opts &&
// RUN: grep ' "/usr/libexec/gcc/i686-apple-darwin10/4.2.1/cc1obj" "-quiet" "-IINCLUDE_PATH_0" "-FFRAMEWORK_0" "-IINCLUDE_PATH_1" "-FFRAMEWORK_1" "-D__DYNAMIC__" "-DUSER_DEFINE_0" "-include" "USER_INCLUDE_0" ".*" "-quiet" "-dumpbase" "darwin-x86-cc1.m" "-mpascal-strings" "-mdynamic-no-pic" "-mmacosx-version-min=10.5" "-mtune=core2" "-auxbase-strip" ".*" "-gdwarf-2" "-Os" "-Wno-trigraphs" "-Wall" "-Wextra" "-Wno-missing-field-initializers" "-Wno-unused-parameter" "-Wno-four-char-constants" "-Wno-unknown-pragmas" "-Wno-format-y2k" "-Wpointer-arith" "-Wreturn-type" "-Wwrite-strings" "-Wswitch" "-Wcast-align" "-Wchar-subscripts" "-Winline" "-Wnested-externs" "-Wint-to-pointer-cast" "-Wpointer-to-int-cast" "-Wshorten-64-to-32" "-fmessage-length=0" "-fasm-blocks" "-fvisibility=hidden" "-o"' %t.opts &&
// RUN: grep ' "/usr/libexec/gcc/i686-apple-darwin10/4.2.1/as" "-arch" "i386" "-force_cpusubtype_ALL" "-o"' %t.opts &&
-// RUN: xcc -ccc-host-bits 32 -ccc-host-machine i386 -ccc-host-system darwin -ccc-host-release 10.5.0 -### -v -E -dM -arch i386 -xobjective-c -c %s &> %t.opts &&
+// RUN: xcc -ccc-no-clang -ccc-host-bits 32 -ccc-host-machine i386 -ccc-host-system darwin -ccc-host-release 10.5.0 -### -v -E -dM -arch i386 -xobjective-c -c %s &> %t.opts &&
// RUN: grep ' "/usr/libexec/gcc/i686-apple-darwin10/4.2.1/cc1obj" "-E" "-quiet" "-v" "-D__DYNAMIC__" ".*" "-fPIC" "-mmacosx-version-min=10.6.5" "-mtune=core2" "-dM"' %t.opts &&
-// RUN: xcc -ccc-host-bits 32 -ccc-host-machine i386 -ccc-host-system darwin -ccc-host-release 10.5.0 -### -m32 -S -x cpp-output %s &> %t.opts &&
+// RUN: xcc -ccc-no-clang -ccc-host-bits 32 -ccc-host-machine i386 -ccc-host-system darwin -ccc-host-release 10.5.0 -### -m32 -S -x cpp-output %s &> %t.opts &&
// RUN: grep ' "/usr/libexec/gcc/i686-apple-darwin10/4.2.1/cc1" "-fpreprocessed" ".*darwin-x86-cc1.m" "-fPIC" "-quiet" "-dumpbase" "darwin-x86-cc1.m" "-mmacosx-version-min=10.6.5" "-m32" "-mtune=core2" "-auxbase" "darwin-x86-cc1" "-o" ".*"' %t.opts &&
-// RUN: xcc -ccc-host-bits 32 -ccc-host-machine i386 -ccc-host-system darwin -ccc-host-release 10.5.0 -### -x objective-c-header %s -o /tmp/x.gch &> %t.opts &&
+// RUN: xcc -ccc-no-clang -ccc-host-bits 32 -ccc-host-machine i386 -ccc-host-system darwin -ccc-host-release 10.5.0 -### -x objective-c-header %s -o /tmp/x.gch &> %t.opts &&
// RUN: grep ' "/usr/libexec/gcc/i686-apple-darwin10/4.2.1/cc1obj" "-quiet" "-D__DYNAMIC__" ".*darwin-x86-cc1.m" "-fPIC" "-quiet" "-dumpbase" "darwin-x86-cc1.m" "-mmacosx-version-min=10.6.5" "-mtune=core2" "-auxbase" ".*" "-o" "/dev/null" "--output-pch=" "/tmp/x.gch"' %t.opts &&
// RUN: true
-// RUN: xcc %s -o %t &&
+// RUN: xcc -ccc-no-clang %s -o %t &&
// RUN: %t | grep "Hello, World" &&
-// RUN: xcc %s -o %t -pipe &&
+// RUN: xcc -ccc-no-clang %s -o %t -pipe &&
// RUN: %t | grep "Hello, World" &&
-// RUN: xcc -ccc-clang %s -o %t &&
+// RUN: xcc %s -o %t &&
// RUN: %t | grep "Hello, World"
int main() {
-// RUN: xcc %s -o %t &&
+// RUN: xcc -ccc-no-clang %s -o %t &&
// RUN: %t | grep "Hello, World" &&
-// RUN: xcc -ccc-clang %s -o %t &&
+// RUN: xcc %s -o %t &&
// RUN: %t | grep "Hello, World"
int main() {
-// RUN: xcc -arch ppc -arch i386 -arch x86_64 %s -o %t &&
+// RUN: xcc -ccc-no-clang -arch ppc -arch i386 -arch x86_64 %s -o %t &&
// RUN: %t | grep "Hello, World" &&
-// RUN: xcc -pipe -arch ppc -arch i386 -arch x86_64 %s -o %t &&
+// RUN: xcc -ccc-no-clang -pipe -arch ppc -arch i386 -arch x86_64 %s -o %t &&
// RUN: %t | grep "Hello, World" &&
// Check that multiple archs are handled properly.