diff options
author | Daniel Dunbar <daniel@zuster.org> | 2009-01-22 01:55:46 +0000 |
---|---|---|
committer | Daniel Dunbar <daniel@zuster.org> | 2009-01-22 01:55:46 +0000 |
commit | 1e1d2c6d68bbf23c1ab3741ccffcb23848caaa02 (patch) | |
tree | 582fb3077f3c1cc2e987e71257ada12667a143cd /tools/ccc/ccclib/Tools.py | |
parent | 05c13a3411782108d65aab3c77b1a231a4963bc0 (diff) |
ccc/clang: Mimic llvm-gcc initialization of LLVM backend based on gcc
options (for example, to set relocation model or enable unwind table generation).
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@62740 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'tools/ccc/ccclib/Tools.py')
-rw-r--r-- | tools/ccc/ccclib/Tools.py | 54 |
1 files changed, 53 insertions, 1 deletions
diff --git a/tools/ccc/ccclib/Tools.py b/tools/ccc/ccclib/Tools.py index fbf17cb3a7..b1087d3983 100644 --- a/tools/ccc/ccclib/Tools.py +++ b/tools/ccc/ccclib/Tools.py @@ -219,6 +219,58 @@ class Clang_CompileTool(Tool): # 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 @@ class Darwin_X86_LinkTool(Tool): # 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) |