[cfe-commits] r62740 - in /cfe/trunk/tools/ccc/ccclib: Arguments.py Tools.py
Daniel Dunbar
daniel at zuster.org
Wed Jan 21 17:55:48 PST 2009
Author: ddunbar
Date: Wed Jan 21 19:55:46 2009
New Revision: 62740
URL: http://llvm.org/viewvc/llvm-project?rev=62740&view=rev
Log:
ccc/clang: Mimic llvm-gcc initialization of LLVM backend based on gcc
options (for example, to set relocation model or enable unwind table generation).
Modified:
cfe/trunk/tools/ccc/ccclib/Arguments.py
cfe/trunk/tools/ccc/ccclib/Tools.py
Modified: cfe/trunk/tools/ccc/ccclib/Arguments.py
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/ccc/ccclib/Arguments.py?rev=62740&r1=62739&r2=62740&view=diff
==============================================================================
--- cfe/trunk/tools/ccc/ccclib/Arguments.py (original)
+++ cfe/trunk/tools/ccc/ccclib/Arguments.py Wed Jan 21 19:55:46 2009
@@ -713,7 +713,9 @@
# FIXME: What to do about the ambiguity of options like
# -dumpspecs? How is this handled in gcc?
# FIXME: Naming convention.
- self.dOption = self.addOption(FlagOption('-d'))
+ self.dGroup = OptionGroup('-d')
+ self.dAOption = self.addOption(FlagOption('-dA', self.dGroup))
+ self.addOption(FlagOption('-d', self.dGroup))
# Use a group for this in anticipation of adding more -d
# options explicitly. Note that we don't put many -d things in
@@ -744,12 +746,15 @@
self.f_appleKextOption = self.addOption(FlagOption('-fapple-kext', self.fGroup))
self.f_constantCfstringsOption = self.addOption(FlagOption('-fconstant-cfstrings', self.fGroup))
self.f_createProfileOption = self.addOption(FlagOption('-fcreate-profile', self.fGroup))
+ self.f_debugPassArgumentsOption = self.addOption(FlagOption('-fdebug-pass-arguments', self.fGroup))
+ self.f_debugPassStructureOption = self.addOption(FlagOption('-fdebug-pass-structure', self.fGroup))
self.f_eliminateUnusedDebugSymbolsOption = self.addOption(FlagOption('-feliminate-unused-debug-symbols', self.fGroup))
self.f_exceptionsOption = self.addOption(FlagOption('-fexceptions', self.fGroup))
self.f_gnuRuntimeOption = self.addOption(FlagOption('-fgnu-runtime', self.fGroup))
self.f_gnuRuntimeOption = self.addOption(FlagOption('-fgnu-runtime', self.fGroup))
self.f_indirectVirtualCallsOption = self.addOption(FlagOption('-findirect-virtual-calls', self.fGroup))
self.f_laxVectorConversionsOption = self.addOption(FlagOption('-flax-vector-conversions', self.fGroup))
+ self.f_limitedPrecisionOption = self.addOption(JoinedOption('-flimited-precision=', self.fGroup))
self.f_msExtensionsOption = self.addOption(FlagOption('-fms-extensions', self.fGroup))
self.f_mudflapOption = self.addOption(FlagOption('-fmudflap', self.fGroup))
self.f_mudflapthOption = self.addOption(FlagOption('-fmudflapth', self.fGroup))
@@ -764,14 +769,21 @@
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))
+ self.f_omitFramePointerOption = self.addOption(FlagOption('-fomit-frame-pointer', self.fGroup))
self.f_openmpOption = self.addOption(FlagOption('-fopenmp', self.fGroup))
self.f_pascalStringsOption = self.addOption(FlagOption('-fpascal-strings', self.fGroup))
self.f_pieOption = self.addOption(FlagOption('-fpie', self.fGroup))
+ self.f_PIEOption = self.addOption(FlagOption('-fPIE', self.fGroup))
+ self.f_picOption = self.addOption(FlagOption('-fpic', self.fGroup))
+ self.f_PICOption = self.addOption(FlagOption('-fPIC', self.fGroup))
self.f_profileArcsOption = self.addOption(FlagOption('-fprofile-arcs', self.fGroup))
self.f_profileGenerateOption = self.addOption(FlagOption('-fprofile-generate', self.fGroup))
self.f_terminatedVtablesOption = self.addOption(FlagOption('-fterminated-vtables', self.fGroup))
+ self.f_timeReportOption = self.addOption(FlagOption('-ftime-report', self.fGroup))
self.f_traditionalOption = self.addOption(FlagOption('-ftraditional', self.fGroup))
+ self.f_unwindTablesOption = self.addOption(FlagOption('-funwind-tables', self.fGroup))
self.f_writableStringsOption = self.addOption(FlagOption('-fwritable-strings', self.fGroup))
+ self.f_zeroInitializedInBssOption = self.addOption(FlagOption('-fzero-initialized-in-bss', self.fGroup))
self.addOption(JoinedOption('-f', self.fGroup))
self.coverageOption = self.addOption(FlagOption('-coverage'))
Modified: cfe/trunk/tools/ccc/ccclib/Tools.py
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/ccc/ccclib/Tools.py?rev=62740&r1=62739&r2=62740&view=diff
==============================================================================
--- cfe/trunk/tools/ccc/ccclib/Tools.py (original)
+++ cfe/trunk/tools/ccc/ccclib/Tools.py Wed Jan 21 19:55:46 2009
@@ -219,6 +219,58 @@
# Add -WA, arguments when running as analyzer.
for arg in arglist.getArgs(arglist.parser.WAOption):
cmd_args.extend(arglist.renderAsInput(arg))
+ else:
+ # Perform argument translation for LLVM backend. This
+ # performs some care in reconciling with llvm-gcc. The
+ # issue is that llvm-gcc translates these options based on
+ # the values in cc1, whereas we are processing based on
+ # the driver arguments.
+ #
+ # FIXME: This is currently broken for -f flags when -fno
+ # variants are present.
+
+ # This comes from the default translation the driver + cc1
+ # would do to enable flag_pic.
+ #
+ # FIXME: Centralize this code.
+ picEnabled = (arglist.getLastArg(arglist.parser.f_PICOption) or
+ arglist.getLastArg(arglist.parser.f_picOption) or
+ arglist.getLastArg(arglist.parser.f_PIEOption) or
+ arglist.getLastArg(arglist.parser.f_pieOption) or
+ (not arglist.getLastArg(arglist.parser.m_kernelOption) and
+ not arglist.getLastArg(arglist.parser.staticOption) and
+ not arglist.getLastArg(arglist.parser.m_dynamicNoPicOption)))
+
+ archName = arglist.getValue(arch)
+ if (archName == 'x86_64' or
+ picEnabled):
+ cmd_args.append('--relocation-model=pic')
+ else:
+ cmd_args.append('--relocation-model=static')
+
+ if arglist.getLastArg(arglist.parser.f_timeReportOption):
+ cmd_args.append('--time-passes')
+ # FIXME: Set --enable-unsafe-fp-math.
+ if not arglist.getLastArg(arglist.parser.f_omitFramePointerOption):
+ cmd_args.append('--disable-fp-elim')
+ if not arglist.getLastArg(arglist.parser.f_zeroInitializedInBssOption):
+ cmd_args.append('--nozero-initialized-in-bss')
+ if arglist.getLastArg(arglist.parser.dAOption):
+ cmd_args.append('--asm-verbose')
+ if arglist.getLastArg(arglist.parser.f_debugPassStructureOption):
+ cmd_args.append('--debug-pass=Structure')
+ if arglist.getLastArg(arglist.parser.f_debugPassArgumentsOption):
+ cmd_args.append('--debug-pass=Arguments')
+ # FIXME: set --inline-threshhold=50 if (optimize_size || optimize < 3)
+ if arglist.getLastArg(arglist.parser.f_unwindTablesOption):
+ cmd_args.append('--unwind-tables')
+
+ arg = arglist.getLastArg(arglist.parser.f_limitedPrecisionOption)
+ if arg:
+ cmd_args.append('--limit-float-precision')
+ cmd_args.append(arglist.getValue(arg))
+
+ # FIXME: Add --stack-protector-buffer-size=<xxx> on -fstack-protect.
arglist.addAllArgs(cmd_args, arglist.parser.vOption)
arglist.addAllArgs2(cmd_args, arglist.parser.DOption, arglist.parser.UOption)
@@ -937,7 +989,7 @@
# FIXME: gcc has %{x} in here. How could this ever happen?
# Cruft?
- arglist.addLastArg(cmd_args, arglist.parser.dOption)
+ arglist.addLastArg(cmd_args, arglist.parser.dGroup)
arglist.addLastArg(cmd_args, arglist.parser.tOption)
arglist.addLastArg(cmd_args, arglist.parser.ZOption)
arglist.addAllArgs(cmd_args, arglist.parser.uGroup)
More information about the cfe-commits
mailing list