From: Daniel Dunbar Date: Tue, 20 Jan 2009 05:51:52 +0000 (+0000) Subject: ccc: Darwin/x86: Teach compile tool how to build .pch files. xcc is X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=4e3d7626e479866182d1a2d1b138813cf2d7adb1;p=clang ccc: Darwin/x86: Teach compile tool how to build .pch files. xcc is now fully independent of the gcc driver when targetting Darwin/x86. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@62570 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/tools/ccc/ccclib/ToolChain.py b/tools/ccc/ccclib/ToolChain.py index c3e585efb0..ac1cc0a0ba 100644 --- a/tools/ccc/ccclib/ToolChain.py +++ b/tools/ccc/ccclib/ToolChain.py @@ -54,7 +54,7 @@ class Darwin_X86_ToolChain(ToolChain): self.toolMap = { Phases.PreprocessPhase : Tools.Darwin_X86_PreprocessTool(self), Phases.CompilePhase : Tools.Darwin_X86_CompileTool(self), - Phases.PrecompilePhase : Tools.GCC_PrecompileTool(), + Phases.PrecompilePhase : Tools.Darwin_X86_CompileTool(self), Phases.AssemblePhase : Tools.Darwin_AssembleTool(self), Phases.LinkPhase : Tools.Darwin_X86_LinkTool(self), Phases.LipoPhase : Tools.LipoTool(), diff --git a/tools/ccc/ccclib/Tools.py b/tools/ccc/ccclib/Tools.py index ab9ad7b5a8..06d1ab1408 100644 --- a/tools/ccc/ccclib/Tools.py +++ b/tools/ccc/ccclib/Tools.py @@ -280,21 +280,21 @@ class Darwin_X86_CC1Tool(Tool): """getCC1Name(type) -> name, use-cpp, is-cxx""" # FIXME: Get bool results from elsewhere. - if type is Types.CType: + if type is Types.CType or type is Types.CHeaderType: return 'cc1',True,False - elif type is Types.CTypeNoPP: + elif type is Types.CTypeNoPP or type is Types.CHeaderNoPPType: return 'cc1',False,False - elif type is Types.ObjCType: + elif type is Types.ObjCType or type is Types.ObjCHeaderType: return 'cc1obj',True,False - elif type is Types.ObjCTypeNoPP: + elif type is Types.ObjCTypeNoPP or type is Types.ObjCHeaderNoPPTypeP: return 'cc1obj',True,False - elif type is Types.CXXType: + elif type is Types.CXXType or type is Types.CXXHeaderType: return 'cc1plus',True,True - elif type is Types.CXXTypeNoPP: + elif type is Types.CXXTypeNoPP or type is Types.CXXHeaderNoPPType: return 'cc1plus',False,True - elif type is Types.ObjCXXType: + elif type is Types.ObjCXXType or type is Types.ObjCXXHeaderType: return 'cc1objplus',True,True - elif type is Types.ObjCXXTypeNoPP: + elif type is Types.ObjCXXTypeNoPP or type is Types.ObjCXXHeaderNoPPType: return 'cc1objplus',False,True else: raise ValueError,"Unexpected type for Darwin compile tool." @@ -622,7 +622,10 @@ class Darwin_X86_CompileTool(Darwin_X86_CC1Tool): arglist.getLastArg(arglist.parser.f_traditionalOption)): raise Arguments.InvalidArgumentsError("-traditional is not supported without -E") - output_args = self.getOutputArgs(arglist, output) + if outputType is Types.PCHType: + output_args = [] + else: + output_args = self.getOutputArgs(arglist, output) # There is no need for this level of compatibility, but it # makes diffing easier. @@ -653,6 +656,17 @@ class Darwin_X86_CompileTool(Darwin_X86_CC1Tool): early_output_args, isCXX) cmd_args.extend(end_output_args) + if outputType is Types.PCHType: + assert output is not None and not isinstance(output, Jobs.PipedJob) + + cmd_args.append('-o') + # NOTE: gcc uses a temp .s file for this, but there + # doesn't seem to be a good reason. + cmd_args.append('/dev/null') + + cmd_args.append('--output-pch=') + cmd_args.append(arglist.getValue(output)) + jobs.addJob(Jobs.Command(self.toolChain.getProgramPath(cc1Name), cmd_args)) diff --git a/tools/ccc/test/ccc/darwin-x86-cc1.m b/tools/ccc/test/ccc/darwin-x86-cc1.m index a0ef89beef..6c097d3a74 100644 --- a/tools/ccc/test/ccc/darwin-x86-cc1.m +++ b/tools/ccc/test/ccc/darwin-x86-cc1.m @@ -8,5 +8,8 @@ // 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: 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: 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