diff options
| author | Daniel Dunbar <daniel@zuster.org> | 2009-01-20 00:47:24 +0000 | 
|---|---|---|
| committer | Daniel Dunbar <daniel@zuster.org> | 2009-01-20 00:47:24 +0000 | 
| commit | 0c8d6c9d275184bbe64907d993b1fac1a74b437c (patch) | |
| tree | 75ada888b7a1e04f03d7e39f74f1663e867872d8 /clang/tools/ccc | |
| parent | 8f79775a668cf96b1d0542bdc455b90d1a00420b (diff) | |
| download | bcm5719-llvm-0c8d6c9d275184bbe64907d993b1fac1a74b437c.tar.gz bcm5719-llvm-0c8d6c9d275184bbe64907d993b1fac1a74b437c.zip | |
ccc: Darwin/x86: Add direct cpp support.
 - Add Darwin_X86_CC1Tool which is shared by Darwin/x86/Compile and
   Darwin/x86/Preprocess tools.
 - Minor bug fixes (CmpDriver exit code, -x cpp-output handling, some
   linker argument translation).
llvm-svn: 62551
Diffstat (limited to 'clang/tools/ccc')
| -rw-r--r-- | clang/tools/ccc/ccclib/Arguments.py | 12 | ||||
| -rw-r--r-- | clang/tools/ccc/ccclib/Driver.py | 1 | ||||
| -rw-r--r-- | clang/tools/ccc/ccclib/ToolChain.py | 2 | ||||
| -rw-r--r-- | clang/tools/ccc/ccclib/Tools.py | 455 | ||||
| -rw-r--r-- | clang/tools/ccc/test/ccc/darwin-x86-cc1.m | 10 | 
5 files changed, 281 insertions, 199 deletions
| diff --git a/clang/tools/ccc/ccclib/Arguments.py b/clang/tools/ccc/ccclib/Arguments.py index ebdd3fd0c7c..ba48417dc6d 100644 --- a/clang/tools/ccc/ccclib/Arguments.py +++ b/clang/tools/ccc/ccclib/Arguments.py @@ -549,7 +549,8 @@ class OptionParser:          self.MTOption = self.addOption(JoinedOrSeparateOption('-MT'))          self.MQOption = self.addOption(JoinedOrSeparateOption('-MQ'))          self.MachOption = self.addOption(FlagOption('-Mach')) -        self.undefOption = self.addOption(FlagOption('-undef')) +        self.uGroup = OptionGroup('-u') +        self.undefOption = self.addOption(FlagOption('-undef', self.uGroup))          self.wOption = self.addOption(FlagOption('-w'))          self.bundle_loaderOption = self.addOption(SeparateOption('-bundle_loader')) @@ -575,8 +576,8 @@ class OptionParser:          self.segprotOption = self.addOption(JoinedOrSeparateOption('-segprot'))          self.sub_libraryOption = self.addOption(JoinedOrSeparateOption('-sub_library'))          self.sub_umbrellaOption = self.addOption(JoinedOrSeparateOption('-sub_umbrella')) -        self.umbrellaOption = self.addOption(SeparateOption('-umbrella')) -        self.undefinedOption = self.addOption(JoinedOrSeparateOption('-undefined')) +        self.umbrellaOption = self.addOption(SeparateOption('-umbrella', self.uGroup)) +        self.undefinedOption = self.addOption(JoinedOrSeparateOption('-undefined', self.uGroup))          self.headerpad_max_install_namesOption = self.addOption(JoinedOption('-headerpad_max_install_names'))          self.twolevel_namespaceOption = self.addOption(FlagOption('-twolevel_namespace'))          self.twolevel_namespace_hintsOption = self.addOption(FlagOption('-twolevel_namespace_hints')) @@ -647,7 +648,7 @@ class OptionParser:          # FIXME: This probably isn't necessary.          self.segs_read_Option = self.addOption(JoinedOption('-segs_read_'))          self.single_moduleOption = self.addOption(FlagOption('-single_module')) -        self.unexported_symbols_listOption = self.addOption(SeparateOption('-unexported_symbols_list')) +        self.unexported_symbols_listOption = self.addOption(SeparateOption('-unexported_symbols_list', self.uGroup))          self.weak_reference_mismatchesOption = self.addOption(SeparateOption('-weak_reference_mismatches'))          self.addOption(SeparateOption('-filelist', isLinkerInput=True)) @@ -685,7 +686,7 @@ class OptionParser:          self.ZOption = self.addOption(JoinedOrSeparateOption('-Z'))          self.addOption(JoinedOrSeparateOption('-l', isLinkerInput=True)) -        self.uOption = self.addOption(JoinedOrSeparateOption('-u')) +        self.uOption = self.addOption(JoinedOrSeparateOption('-u', self.uGroup))          self.tOption = self.addOption(JoinedOrSeparateOption('-t'))          self.yOption = self.addOption(JoinedOption('-y')) @@ -751,6 +752,7 @@ class OptionParser:          self.f_noEliminateUnusedDebugSymbolsOption = self.addOption(FlagOption('-fno-eliminate-unused-debug-symbols', self.fGroup))          self.f_noPascalStringsOption = self.addOption(FlagOption('-fno-pascal-strings', self.fGroup))          self.f_noShowColumnOption = self.addOption(FlagOption('-fno-show-column', self.fGroup)) +        self.f_noWorkingDirectoryOption = self.addOption(FlagOption('-fno-working-directory', self.fGroup))          self.f_objcGcOnlyOption = self.addOption(FlagOption('-fobjc-gc-only', self.fGroup))          self.f_objcGcOption = self.addOption(FlagOption('-fobjc-gc', self.fGroup))          self.f_objcOption = self.addOption(FlagOption('-fobjc', self.fGroup)) diff --git a/clang/tools/ccc/ccclib/Driver.py b/clang/tools/ccc/ccclib/Driver.py index e8d2d3d0279..e52640e2525 100644 --- a/clang/tools/ccc/ccclib/Driver.py +++ b/clang/tools/ccc/ccclib/Driver.py @@ -662,6 +662,7 @@ class Driver(object):                  not hasSaveTemps and                  tool.hasIntegratedCPP()):                  if (len(phase.inputs) == 1 and  +                    isinstance(phase.inputs[0], Phases.JobAction) and                      isinstance(phase.inputs[0].phase, Phases.PreprocessPhase)):                      useIntegratedCPP = True                      inputList = phase.inputs[0].inputs diff --git a/clang/tools/ccc/ccclib/ToolChain.py b/clang/tools/ccc/ccclib/ToolChain.py index 7ca1257f496..c3e585efb04 100644 --- a/clang/tools/ccc/ccclib/ToolChain.py +++ b/clang/tools/ccc/ccclib/ToolChain.py @@ -52,7 +52,7 @@ class Darwin_X86_ToolChain(ToolChain):          self.archName = archName          self.toolMap = { -            Phases.PreprocessPhase : Tools.GCC_PreprocessTool(), +            Phases.PreprocessPhase : Tools.Darwin_X86_PreprocessTool(self),              Phases.CompilePhase : Tools.Darwin_X86_CompileTool(self),              Phases.PrecompilePhase : Tools.GCC_PrecompileTool(),              Phases.AssemblePhase : Tools.Darwin_AssembleTool(self), diff --git a/clang/tools/ccc/ccclib/Tools.py b/clang/tools/ccc/ccclib/Tools.py index 5cb18082ad0..94f2b60bfdf 100644 --- a/clang/tools/ccc/ccclib/Tools.py +++ b/clang/tools/ccc/ccclib/Tools.py @@ -275,29 +275,29 @@ class Clang_CompileTool(Tool):          jobs.addJob(Jobs.Command('clang', cmd_args)) - -class Darwin_X86_CompileTool(Tool): -    def __init__(self, toolChain): -        super(Darwin_X86_CompileTool, self).__init__('cc1', -                                                     (Tool.eFlagsPipedInput | -                                                      Tool.eFlagsPipedOutput | -                                                      Tool.eFlagsIntegratedCPP)) -        self.toolChain = toolChain - -    def addCPPArgs(self, cmd_args, arch, arglist): -        # Derived from cpp spec. - -        if arglist.getLastArg(arglist.parser.staticOption): -            # The gcc spec is broken here, it refers to dynamic but -            # that has been translated. Start by being bug compatible. -             -            # if not arglist.getLastArg(arglist.parser.dynamicOption): -            cmd_args.append('-D__STATIC__') -        else: -            cmd_args.append('-D__DYNAMIC__') +class Darwin_X86_CC1Tool(Tool): +    def getCC1Name(self, type): +        """getCC1Name(type) -> name, use-cpp, is-cxx""" -        if arglist.getLastArg(arglist.parser.pthreadOption): -            cmd_args.append('-D_REENTRANT') +        # FIXME: Get bool results from elsewhere. +        if type is Types.CType: +            return 'cc1',True,False +        elif type is Types.CTypeNoPP: +            return 'cc1',False,False +        elif type is Types.ObjCType: +            return 'cc1obj',True,False +        elif type is Types.ObjCTypeNoPP: +            return 'cc1obj',True,False +        elif type is Types.CXXType: +            return 'cc1plus',True,True +        elif type is Types.CXXTypeNoPP: +            return 'cc1plus',False,True +        elif type is Types.ObjCXXType: +            return 'cc1objplus',True,True +        elif type is Types.ObjCXXTypeNoPP: +            return 'cc1objplus',False,True +        else: +            raise ValueError,"Unexpected type for Darwin compile tool."      def addCC1Args(self, cmd_args, arch, arglist):          # Derived from cc1 spec. @@ -330,159 +330,7 @@ class Darwin_X86_CompileTool(Tool):              not arglist.getLastArg(arglist.parser.f_noEliminateUnusedDebugSymbolsOption)):              cmd_args.append('-feliminate-unused-debug-symbols') -    def getBaseInputName(self, inputs, arglist): -        # FIXME: gcc uses a temporary name here when the base -        # input is stdin, but only in auxbase. Investigate. -        baseInputValue = arglist.getValue(inputs[0].baseInput) -        return os.path.basename(baseInputValue) -     -    def getBaseInputStem(self, inputs, arglist): -        return os.path.splitext(self.getBaseInputName(inputs, arglist))[0] - -    def constructJob(self, phase, arch, jobs, inputs,  -                     output, outputType, arglist): -        inputType = inputs[0].type -        assert not [i for i in inputs if i.type != inputType] - -        usePP = False -        isCXX = False -        if inputType is Types.CType: -            cc1Name = 'cc1' -            usePP = True -        elif inputType is Types.CTypeNoPP: -            cc1Name = 'cc1' -            usePP = False -        elif inputType is Types.ObjCType: -            cc1Name = 'cc1obj' -            usePP = True -        elif inputType is Types.ObjCTypeNoPP: -            cc1Name = 'cc1obj' -            usePP = False -        elif inputType is Types.CXXType: -            cc1Name = 'cc1plus' -            usePP = True -            isCXX = True -        elif inputType is Types.CXXTypeNoPP: -            cc1Name = 'cc1plus' -            usePP = False -            isCXX = True -        elif inputType is Types.ObjCXXType: -            cc1Name = 'cc1objplus' -            usePP = True -            isCXX = True -        elif inputType is Types.ObjCXXTypeNoPP: -            cc1Name = 'cc1objplus' -            usePP = False -            isCXX = True -        else: -            raise ValueError,"Unexpected input type for Darwin compile tool." - -        cmd_args = [] -        if (arglist.getLastArg(arglist.parser.traditionalOption) or -            arglist.getLastArg(arglist.parser.f_traditionalOption)): -            raise Arguments.InvalidArgumentsError("-traditional is not supported without -E") - -        if usePP: -            # Derived from cpp_options. - -            # Derived from cpp_unique_options. - -            if (arglist.getLastArg(arglist.parser.COption) or -                arglist.getLastArg(arglist.parser.CCOption)): -                if not arglist.getLastArg(arglist.parser.EOption): -                    raise Arguments.InvalidArgumentsError("-C or -CC is not supported without -E") -            if not arglist.getLastArg(arglist.parser.QOption): -                cmd_args.append('-quiet') -            arglist.addAllArgs(cmd_args, arglist.parser.nostdincOption) -            arglist.addLastArg(cmd_args, arglist.parser.vOption) -            arglist.addAllArgs2(cmd_args, arglist.parser.IOption, arglist.parser.FOption) -            arglist.addLastArg(cmd_args, arglist.parser.POption) - -            # FIXME: Handle %I properly. -            if arglist.getValue(arch) == 'x86_64': -                cmd_args.append('-imultilib') -                cmd_args.append('x86_64') - -            if arglist.getLastArg(arglist.parser.MDOption): -                cmd_args.append('-MD') -                # FIXME: Think about this more. -                outputOpt = arglist.getLastArg(arglist.parser.oOption) -                if outputOpt: -                    base,ext = os.path.splitext(arglist.getValue(outputOpt)) -                    cmd_args.append(base+'.d') -                else: -                    cmd_args.append(self.getBaseInputStem(inputs, arglist)+'.d') -            if arglist.getLastArg(arglist.parser.MMDOption): -                cmd_args.append('-MMD') -                # FIXME: Think about this more. -                outputOpt = arglist.getLastArg(arglist.parser.oOption) -                if outputOpt: -                    base,ext = os.path.splitext(arglist.getValue(outputOpt)) -                    cmd_args.append(base+'.d') -                else: -                    cmd_args.append(self.getBaseInputStem(inputs, arglist)+'.d') -            arglist.addLastArg(cmd_args, arglist.parser.MOption) -            arglist.addLastArg(cmd_args, arglist.parser.MMOption) -            arglist.addAllArgs(cmd_args, arglist.parser.MFOption) -            arglist.addLastArg(cmd_args, arglist.parser.MGOption) -            arglist.addLastArg(cmd_args, arglist.parser.MPOption) -            arglist.addAllArgs(cmd_args, arglist.parser.MQOption) -            arglist.addAllArgs(cmd_args, arglist.parser.MTOption) -            if (not arglist.getLastArg(arglist.parser.MOption) and -                not arglist.getLastArg(arglist.parser.MMOption) and -                (arglist.getLastArg(arglist.parser.MDOption) or -                 arglist.getLastArg(arglist.parser.MMDOption))): -                outputOpt = arglist.getLastArg(arglist.parser.oOption) -                if outputOpt: -                    cmd_args.append('-MQ') -                    cmd_args.append(arglist.getValue(outputOpt)) - -            arglist.addLastArg(cmd_args, arglist.parser.remapOption) -            if arglist.getLastArg(arglist.parser.g3Option): -                cmd_args.append('-dD') -            arglist.addLastArg(cmd_args, arglist.parser.HOption) - -            self.addCPPArgs(cmd_args, arch, arglist) - -            arglist.addAllArgs3(cmd_args,  -                                arglist.parser.DOption, -                                arglist.parser.UOption, -                                arglist.parser.AOption) - -            arglist.addAllArgs(cmd_args, arglist.parser.iGroup) - -            for input in inputs: -                if isinstance(input.source, Jobs.PipedJob): -                    cmd_args.append('-') -                else: -                    cmd_args.extend(arglist.renderAsInput(input.source)) - -            for arg in arglist.getArgs2(arglist.parser.WpOption, -                                        arglist.parser.XpreprocessorOption): -                cmd_args.extend(arglist.getValues(arg)) - -            if arglist.getLastArg(arglist.parser.f_mudflapOption): -                cmd_args.append('-D_MUDFLAP') -                cmd_args.append('-include') -                cmd_args.append('mf-runtime.h') - -            if arglist.getLastArg(arglist.parser.f_mudflapthOption): -                cmd_args.append('-D_MUDFLAP') -                cmd_args.append('-D_MUDFLAPTH') -                cmd_args.append('-include') -                cmd_args.append('mf-runtime.h') -             -        else: -            cmd_args.append('-fpreprocessed') -            # FIXME: There is a spec command to remove -            # -fpredictive-compilation args here. Investigate. - -            for input in inputs: -                if isinstance(input.source, Jobs.PipedJob): -                    cmd_args.append('-') -                else: -                    cmd_args.extend(arglist.renderAsInput(input.source)) - +    def addCC1OptionsArgs(self, cmd_args, arch, arglist, inputs, output_args, isCXX):          # Derived from cc1_options spec.          if (arglist.getLastArg(arglist.parser.fastOption) or              arglist.getLastArg(arglist.parser.fastfOption) or @@ -539,7 +387,7 @@ class Darwin_X86_CompileTool(Tool):          arglist.addAllArgs2(cmd_args, arglist.parser.fGroup,                               arglist.parser.syntaxOnlyOption) -        arglist.addLastArg(cmd_args, arglist.parser.undefOption) +        arglist.addAllArgs(cmd_args, arglist.parser.undefOption)          if arglist.getLastArg(arglist.parser.QnOption):              cmd_args.append('-fno-ident') @@ -547,18 +395,7 @@ class Darwin_X86_CompileTool(Tool):          #arglist.addLastArg(cmd_args, arglist.parser._helpOption)          #arglist.addLastArg(cmd_args, arglist.parser._targetHelpOption) -        # There is no need for this level of compatibility, but it -        # makes diffing easier. -        outputAtEnd = (not arglist.getLastArg(arglist.parser.syntaxOnlyOption) and -                       not arglist.getLastArg(arglist.parser.SOption)) -        if isinstance(output, Jobs.PipedJob): -            output_args = ['-o', '-'] -        elif output is None: -            output_args = ['-o', '/dev/null'] -        else: -            output_args = arglist.render(output) - -        if not outputAtEnd: +        if output_args:              cmd_args.extend(output_args)          # FIXME: Still don't get what is happening here. Investigate. @@ -576,13 +413,247 @@ class Darwin_X86_CompileTool(Tool):          if isCXX:              cmd_args.append('-D__private_extern__=extern') -        if outputAtEnd: -            cmd_args.extend(output_args) +    def getBaseInputName(self, inputs, arglist): +        # FIXME: gcc uses a temporary name here when the base +        # input is stdin, but only in auxbase. Investigate. +        baseInputValue = arglist.getValue(inputs[0].baseInput) +        return os.path.basename(baseInputValue) +     +    def getBaseInputStem(self, inputs, arglist): +        return os.path.splitext(self.getBaseInputName(inputs, arglist))[0] + +    def getOutputArgs(self, arglist, output, isCPP=False): +        if isinstance(output, Jobs.PipedJob): +            if isCPP: +                output_args = [] +            else: +                output_args = ['-o', '-'] +        elif output is None: +            output_args = ['-o', '/dev/null'] +        else: +            output_args = arglist.render(output) + +        # There is no need for this level of compatibility, but it +        # makes diffing easier. +        if (not arglist.getLastArg(arglist.parser.syntaxOnlyOption) and +            not arglist.getLastArg(arglist.parser.SOption)): +            return [], output_args +        else: +            return output_args, [] + +    def addCPPOptionsArgs(self, cmd_args, arch, arglist, inputs, +                          output_args, isCXX): +        # Derived from cpp_options. +        self.addCPPUniqueOptionsArgs(cmd_args, arch, arglist, inputs) +         +        self.addCC1Args(cmd_args, arch, arglist) + +        # NOTE: The code below has some commonality with cpp_options, +        # but in classic gcc style ends up sending things in different +        # orders. This may be a good merge candidate once we drop +        # pedantic compatibility. + +        arglist.addAllArgs(cmd_args, arglist.parser.mGroup) +        arglist.addAllArgs3(cmd_args, arglist.parser.stdOption,  +                            arglist.parser.ansiOption,  +                            arglist.parser.trigraphsOption) +        arglist.addAllArgs2(cmd_args, arglist.parser.WGroup,  +                            arglist.parser.pedanticGroup) +        arglist.addLastArg(cmd_args, arglist.parser.wOption) + +        # ccc treats -fsyntax-only specially. +        arglist.addAllArgs2(cmd_args, arglist.parser.fGroup,  +                            arglist.parser.syntaxOnlyOption) + +        if (arglist.getLastArg(arglist.parser.gGroup) and +            not arglist.getLastArg(arglist.parser.g0Option) and +            not arglist.getLastArg(arglist.parser.f_noWorkingDirectoryOption)): +            cmd_args.append('-fworking-directory') + +        arglist.addAllArgs(cmd_args, arglist.parser.OOption) +        arglist.addAllArgs(cmd_args, arglist.parser.undefOption) +        if arglist.getLastArg(arglist.parser.saveTempsOption): +            cmd_args.append('-fpch-preprocess') + +    def addCPPUniqueOptionsArgs(self, cmd_args, arch, arglist, inputs): +        # Derived from cpp_unique_options. + +        if (arglist.getLastArg(arglist.parser.COption) or +            arglist.getLastArg(arglist.parser.CCOption)): +            if not arglist.getLastArg(arglist.parser.EOption): +                raise Arguments.InvalidArgumentsError("-C or -CC is not supported without -E") +        if not arglist.getLastArg(arglist.parser.QOption): +            cmd_args.append('-quiet') +        arglist.addAllArgs(cmd_args, arglist.parser.nostdincOption) +        arglist.addLastArg(cmd_args, arglist.parser.vOption) +        arglist.addAllArgs2(cmd_args, arglist.parser.IOption, arglist.parser.FOption) +        arglist.addLastArg(cmd_args, arglist.parser.POption) + +        # FIXME: Handle %I properly. +        if arglist.getValue(arch) == 'x86_64': +            cmd_args.append('-imultilib') +            cmd_args.append('x86_64') + +        if arglist.getLastArg(arglist.parser.MDOption): +            cmd_args.append('-MD') +            # FIXME: Think about this more. +            outputOpt = arglist.getLastArg(arglist.parser.oOption) +            if outputOpt: +                base,ext = os.path.splitext(arglist.getValue(outputOpt)) +                cmd_args.append(base+'.d') +            else: +                cmd_args.append(self.getBaseInputStem(inputs, arglist)+'.d') +        if arglist.getLastArg(arglist.parser.MMDOption): +            cmd_args.append('-MMD') +            # FIXME: Think about this more. +            outputOpt = arglist.getLastArg(arglist.parser.oOption) +            if outputOpt: +                base,ext = os.path.splitext(arglist.getValue(outputOpt)) +                cmd_args.append(base+'.d') +            else: +                cmd_args.append(self.getBaseInputStem(inputs, arglist)+'.d') +        arglist.addLastArg(cmd_args, arglist.parser.MOption) +        arglist.addLastArg(cmd_args, arglist.parser.MMOption) +        arglist.addAllArgs(cmd_args, arglist.parser.MFOption) +        arglist.addLastArg(cmd_args, arglist.parser.MGOption) +        arglist.addLastArg(cmd_args, arglist.parser.MPOption) +        arglist.addAllArgs(cmd_args, arglist.parser.MQOption) +        arglist.addAllArgs(cmd_args, arglist.parser.MTOption) +        if (not arglist.getLastArg(arglist.parser.MOption) and +            not arglist.getLastArg(arglist.parser.MMOption) and +            (arglist.getLastArg(arglist.parser.MDOption) or +             arglist.getLastArg(arglist.parser.MMDOption))): +            outputOpt = arglist.getLastArg(arglist.parser.oOption) +            if outputOpt: +                cmd_args.append('-MQ') +                cmd_args.append(arglist.getValue(outputOpt)) + +        arglist.addLastArg(cmd_args, arglist.parser.remapOption) +        if arglist.getLastArg(arglist.parser.g3Option): +            cmd_args.append('-dD') +        arglist.addLastArg(cmd_args, arglist.parser.HOption) + +        self.addCPPArgs(cmd_args, arch, arglist) + +        arglist.addAllArgs3(cmd_args,  +                            arglist.parser.DOption, +                            arglist.parser.UOption, +                            arglist.parser.AOption) + +        arglist.addAllArgs(cmd_args, arglist.parser.iGroup) + +        for input in inputs: +            if isinstance(input.source, Jobs.PipedJob): +                cmd_args.append('-') +            else: +                cmd_args.extend(arglist.renderAsInput(input.source)) + +        for arg in arglist.getArgs2(arglist.parser.WpOption, +                                    arglist.parser.XpreprocessorOption): +            cmd_args.extend(arglist.getValues(arg)) + +        if arglist.getLastArg(arglist.parser.f_mudflapOption): +            cmd_args.append('-D_MUDFLAP') +            cmd_args.append('-include') +            cmd_args.append('mf-runtime.h') + +        if arglist.getLastArg(arglist.parser.f_mudflapthOption): +            cmd_args.append('-D_MUDFLAP') +            cmd_args.append('-D_MUDFLAPTH') +            cmd_args.append('-include') +            cmd_args.append('mf-runtime.h') + +    def addCPPArgs(self, cmd_args, arch, arglist): +        # Derived from cpp spec. + +        if arglist.getLastArg(arglist.parser.staticOption): +            # The gcc spec is broken here, it refers to dynamic but +            # that has been translated. Start by being bug compatible. +             +            # if not arglist.getLastArg(arglist.parser.dynamicOption): +            cmd_args.append('-D__STATIC__') +        else: +            cmd_args.append('-D__DYNAMIC__') +         +        if arglist.getLastArg(arglist.parser.pthreadOption): +            cmd_args.append('-D_REENTRANT') +         +class Darwin_X86_PreprocessTool(Darwin_X86_CC1Tool): +    def __init__(self, toolChain): +        super(Darwin_X86_PreprocessTool, self).__init__('cpp', +                                                        (Tool.eFlagsPipedInput | +                                                         Tool.eFlagsPipedOutput)) +        self.toolChain = toolChain +     +    def constructJob(self, phase, arch, jobs, inputs,  +                     output, outputType, arglist): +        inputType = inputs[0].type +        assert not [i for i in inputs if i.type != inputType] + +        cc1Name,usePP,isCXX = self.getCC1Name(inputType) + +        cmd_args = ['-E'] +        if (arglist.getLastArg(arglist.parser.traditionalOption) or +            arglist.getLastArg(arglist.parser.f_traditionalOption) or +            arglist.getLastArg(arglist.parser.traditionalCPPOption)): +            cmd_args.append('-traditional-cpp') + +        early_output_args, end_output_args = self.getOutputArgs(arglist, output, +                                                                isCPP=True) +        self.addCPPOptionsArgs(cmd_args, arch, arglist, inputs,  +                               early_output_args, isCXX) +        cmd_args.extend(end_output_args) + +        arglist.addAllArgs(cmd_args, arglist.parser.dGroup) + +        jobs.addJob(Jobs.Command(self.toolChain.getProgramPath(cc1Name),  +                                 cmd_args)) +     +class Darwin_X86_CompileTool(Darwin_X86_CC1Tool): +    def __init__(self, toolChain): +        super(Darwin_X86_CompileTool, self).__init__('cc1', +                                                     (Tool.eFlagsPipedInput | +                                                      Tool.eFlagsPipedOutput | +                                                      Tool.eFlagsIntegratedCPP)) +        self.toolChain = toolChain + +    def constructJob(self, phase, arch, jobs, inputs,  +                     output, outputType, arglist): +        inputType = inputs[0].type +        assert not [i for i in inputs if i.type != inputType] + +        cc1Name,usePP,isCXX = self.getCC1Name(inputType) + +        cmd_args = [] +        if (arglist.getLastArg(arglist.parser.traditionalOption) or +            arglist.getLastArg(arglist.parser.f_traditionalOption)): +            raise Arguments.InvalidArgumentsError("-traditional is not supported without -E") + +        early_output_args, end_output_args = self.getOutputArgs(arglist, output) +        if usePP: +            self.addCPPUniqueOptionsArgs(cmd_args, arch, arglist, inputs) +            self.addCC1OptionsArgs(cmd_args, arch, arglist, inputs, +                                   early_output_args, isCXX) +            cmd_args.extend(end_output_args) +        else: +            cmd_args.append('-fpreprocessed') +             +            # FIXME: There is a spec command to remove +            # -fpredictive-compilation args here. Investigate. + +            for input in inputs: +                if isinstance(input.source, Jobs.PipedJob): +                    cmd_args.append('-') +                else: +                    cmd_args.extend(arglist.renderAsInput(input.source)) + +            self.addCC1OptionsArgs(cmd_args, arch, arglist, inputs,  +                                   early_output_args, isCXX) +            cmd_args.extend(end_output_args)          jobs.addJob(Jobs.Command(self.toolChain.getProgramPath(cc1Name),                                    cmd_args)) -          class Darwin_X86_LinkTool(Tool):      def __init__(self, toolChain):          super(Darwin_X86_LinkTool, self).__init__('collect2') @@ -840,7 +911,7 @@ class Darwin_X86_LinkTool(Tool):          arglist.addLastArg(cmd_args, arglist.parser.dOption)          arglist.addLastArg(cmd_args, arglist.parser.tOption)          arglist.addLastArg(cmd_args, arglist.parser.ZOption) -        arglist.addLastArg(cmd_args, arglist.parser.uOption) +        arglist.addAllArgs(cmd_args, arglist.parser.uGroup)          arglist.addLastArg(cmd_args, arglist.parser.AOption)          arglist.addLastArg(cmd_args, arglist.parser.eOption)          arglist.addLastArg(cmd_args, arglist.parser.mOption) diff --git a/clang/tools/ccc/test/ccc/darwin-x86-cc1.m b/clang/tools/ccc/test/ccc/darwin-x86-cc1.m index f5d05260505..a0ef89beefe 100644 --- a/clang/tools/ccc/test/ccc/darwin-x86-cc1.m +++ b/clang/tools/ccc/test/ccc/darwin-x86-cc1.m @@ -1,4 +1,12 @@  // 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: 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: 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: 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: 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: true | 

