ccc: (Darwin) More argument translation for Darwin/Compile tool.

llvm-svn: 62089
This commit is contained in:
Daniel Dunbar 2009-01-12 17:53:19 +00:00
parent 6919ab4d05
commit d0b0eca12a
2 changed files with 99 additions and 19 deletions

View File

@ -452,7 +452,10 @@ class OptionParser:
# FIXME: Weird, gcc claims this here in help but I'm not sure why;
# perhaps interaction with preprocessor? Investigate.
self.addOption(JoinedOption('-std='))
# FIXME: This is broken in Darwin cc1, it wants std* and this
# is std=. May need an option group for this as well.
self.stdOption = self.addOption(JoinedOption('-std='))
self.addOption(JoinedOrSeparateOption('--sysroot'))
# Version control
@ -484,7 +487,7 @@ class OptionParser:
self.MTOption = self.addOption(JoinedOrSeparateOption('-MT'))
self.MQOption = self.addOption(JoinedOrSeparateOption('-MQ'))
self.MachOption = self.addOption(FlagOption('-Mach'))
self.addOption(FlagOption('-undef'))
self.undefOption = self.addOption(FlagOption('-undef'))
self.wOption = self.addOption(FlagOption('-w'))
self.addOption(JoinedOrSeparateOption('-allowable_client'))
@ -535,6 +538,7 @@ class OptionParser:
self.addOption(FlagOption('-R'))
self.POption = self.addOption(FlagOption('-P'))
self.QOption = self.addOption(FlagOption('-Q'))
self.QnOption = self.addOption(FlagOption('-Qn'))
self.addOption(FlagOption('-all_load'))
self.addOption(FlagOption('--constant-cfstrings'))
self.traditionalOption = self.addOption(FlagOption('-traditional'))
@ -597,9 +601,8 @@ class OptionParser:
self.eOption = self.addOption(JoinedOrSeparateOption('-e'))
self.rOption = self.addOption(JoinedOrSeparateOption('-r'))
# Is this actually declared anywhere? I can only find it in a
# spec. :(
self.pgOption = self.addOption(FlagOption('-pg'))
self.pOption = self.addOption(FlagOption('-p'))
doNotReallySupport = 1
if doNotReallySupport:
@ -650,6 +653,10 @@ class OptionParser:
self.g3Option = self.addOption(JoinedOption('-g3'))
self.gOption = self.addOption(JoinedOption('-g'))
self.fastOption = self.addOption(FlagOption('-fast'))
self.fastfOption = self.addOption(FlagOption('-fastf'))
self.fastcpOption = self.addOption(FlagOption('-fastcp'))
self.f_appleKextOption = self.addOption(FlagOption('-fapple-kext'))
self.f_exceptionsOption = self.addOption(FlagOption('-fexceptions'))
self.f_objcOption = self.addOption(FlagOption('-fobjc'))
@ -679,12 +686,16 @@ class OptionParser:
self.mOption = self.addOption(SeparateOption('-m'))
self.addOption(JoinedOption('-m'))
self.ansiOption = self.addOption(FlagOption('-ansi'))
self.trigraphsOption = self.addOption(FlagOption('-trigraphs'))
self.pedanticOption = self.addOption(FlagOption('-pedantic'))
self.addOption(JoinedOption('-i'))
self.addOption(JoinedOption('-O'))
self.addOption(JoinedOption('-W'))
self.OOption = self.addOption(JoinedOption('-O'))
self.WOption = self.addOption(JoinedOption('-W'))
# FIXME: Weird. This option isn't really separate, --param=a=b
# works. An alias somewhere?
self.addOption(SeparateOption('--param'))
# works. There is something else going on which interprets the
# '='.
self._paramOption = self.addOption(SeparateOption('--param'))
# FIXME: What is this? Seems to do something on Linux. I think
# only one is valid, but have a log that uses both.

View File

@ -298,23 +298,92 @@ class Darwin_X86_CompileTool(Tool):
# FIXME: There is a spec command to remove
# -fpredictive-compilation args here. Investigate.
# FIXME: cc1_options
if arch:
cmd_args.extend(arglist.render(arch))
if isinstance(output, Jobs.PipedJob):
cmd_args.extend(['-o', '-'])
elif output is None:
cmd_args.append('-fsyntax-only')
else:
cmd_args.extend(arglist.render(output))
# FIXME: This is from previously & not part of the spec,
# integrate properly.
for input in inputs:
if isinstance(input.source, Jobs.PipedJob):
cmd_args.append('-')
else:
cmd_args.extend(arglist.renderAsInput(input.source))
# Derived from cc1_options spec.
if (arglist.getLastArg(arglist.parser.fastOption) or
arglist.getLastArg(arglist.parser.fastfOption) or
arglist.getLastArg(arglist.parser.fastcpOption)):
cmd_args.append('-O3')
if (arglist.getLastArg(arglist.parser.pgOption) and
arglist.getLastArg(arglist.parser.f_omitFramePointerOption)):
raise ValueError,"-pg and -fomit-frame-pointer are incompatible"
# FIXME: cc1 spec
if not arglist.getLastArg(arglist.parser.QOption):
cmd_args.append('-quiet')
cmd_args.append('-dumpbase')
# FIXME: Get correct basename.
cmd_args.append('FIXME')
# FIXME: d*
# FIXME: m*
# FIXME: a*
# FIXME: This is wrong, what is supposed to happen is we
# should be using the immediate output if we have a "named
# output" from the user, and otherwise derive one from the
# input name.
outputOpt = arglist.getLastArg(arglist.parser.oOption)
if outputOpt:
cmd_args.append('-auxbase-strip')
cmd_args.append(arglist.getValue(outputOpt))
else:
cmd_args.append('-auxbase')
# FIXME: Add proper basename.
cmd_args.append('FIXME')
# FIXME: g*
arglist.addAllArgs(cmd_args, arglist.parser.OOption)
# FIXME: -Wall is getting some special treatment. Investigate.
arglist.addAllArgs2(cmd_args, arglist.parser.WOption, arglist.parser.pedanticOption)
arglist.addLastArg(cmd_args, arglist.parser.wOption)
arglist.addAllArgs3(cmd_args, arglist.parser.stdOption, arglist.parser.ansiOption, arglist.parser.trigraphsOption)
if arglist.getLastArg(arglist.parser.vOption):
cmd_args.append('-version')
if arglist.getLastArg(arglist.parser.pgOption):
cmd_args.append('-p')
arglist.addLastArg(cmd_args, arglist.parser.pOption)
# FIXME: f*
arglist.addLastArg(cmd_args, arglist.parser.undefOption)
if arglist.getLastArg(arglist.parser.QnOption):
cmd_args.append('-fno-ident')
# FIXME: This isn't correct.
#arglist.addLastArg(cmd_args, arglist.parser._helpOption)
#arglist.addLastArg(cmd_args, arglist.parser._targetHelpOption)
if isinstance(output, Jobs.PipedJob):
cmd_args.extend(['-o', '-'])
elif output is None:
cmd_args.extend(['-o', '/dev/null'])
else:
cmd_args.extend(arglist.render(output))
# FIXME: Still don't get what is happening here. Investigate.
arglist.addAllArgs(cmd_args, arglist.parser._paramOption)
if (arglist.getLastArg(arglist.parser.f_mudflapOption) or
arglist.getLastArg(arglist.parser.f_mudflapthOption)):
cmd_args.append('-fno-builtin')
cmd_args.append('-fno-merge-constants')
if arglist.getLastArg(arglist.parser.coverageOption):
cmd_args.append('-fprofile-arcs')
cmd_args.append('-ftest-coverage')
jobs.addJob(Jobs.Command(self.toolChain.getProgramPath(cc1Name),
cmd_args))