Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(108)

Side by Side Diff: pydir/szbuild.py

Issue 892803002: Subzero: Add a --elf arg to szbuild.py and crosstest.py. (Closed) Base URL: https://chromium.googlesource.com/native_client/pnacl-subzero.git@master
Patch Set: Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « pydir/crosstest.py ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 #!/usr/bin/env python2 1 #!/usr/bin/env python2
2 2
3 import argparse 3 import argparse
4 import os 4 import os
5 import pipes 5 import pipes
6 import re 6 import re
7 import sys 7 import sys
8 8
9 from utils import shellcmd 9 from utils import shellcmd
10 from utils import FindBaseNaCl 10 from utils import FindBaseNaCl
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
73 help='Subzero symbols to exclude ' + 73 help='Subzero symbols to exclude ' +
74 '(regex or line range)') 74 '(regex or line range)')
75 argparser.add_argument('--output', '-o', default='a.out', dest='output', 75 argparser.add_argument('--output', '-o', default='a.out', dest='output',
76 action='store', 76 action='store',
77 help='Output executable. Default %(default)s.') 77 help='Output executable. Default %(default)s.')
78 argparser.add_argument('-O', default='2', dest='optlevel', 78 argparser.add_argument('-O', default='2', dest='optlevel',
79 choices=['m1', '-1', '0', '1', '2'], 79 choices=['m1', '-1', '0', '1', '2'],
80 help='Optimization level ' + 80 help='Optimization level ' +
81 '(m1 and -1 are equivalent).' + 81 '(m1 and -1 are equivalent).' +
82 ' Default %(default)s.') 82 ' Default %(default)s.')
83 argparser.add_argument('--elf', dest='elf',
84 action='store_true',
85 help='Directly generate ELF output')
83 argparser.add_argument('--verbose', '-v', dest='verbose', 86 argparser.add_argument('--verbose', '-v', dest='verbose',
84 action='store_true', 87 action='store_true',
85 help='Display some extra debugging output') 88 help='Display some extra debugging output')
86 argparser.add_argument('--sz', dest='sz_args', action='append', default=[], 89 argparser.add_argument('--sz', dest='sz_args', action='append', default=[],
87 help='Extra arguments for Subzero') 90 help='Extra arguments for Subzero')
88 argparser.add_argument('--llc', dest='llc_args', action='append', 91 argparser.add_argument('--llc', dest='llc_args', action='append',
89 default=[], help='Extra arguments for llc') 92 default=[], help='Extra arguments for llc')
90 93
91 def main(): 94 def main():
92 """Create a hybrid translation from Subzero and llc. 95 """Create a hybrid translation from Subzero and llc.
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
195 'nm {obj} | sed -n "s/.* [a-zA-Z] //p" > {sym}' 198 'nm {obj} | sed -n "s/.* [a-zA-Z] //p" > {sym}'
196 ).format(obj=obj_llc, sym=sym_llc), echo=args.verbose) 199 ).format(obj=obj_llc, sym=sym_llc), echo=args.verbose)
197 200
198 if (args.force or 201 if (args.force or
199 NewerThanOrNotThere(pexe, obj_sz) or 202 NewerThanOrNotThere(pexe, obj_sz) or
200 NewerThanOrNotThere(llvm2ice, obj_sz)): 203 NewerThanOrNotThere(llvm2ice, obj_sz)):
201 # Run llvm2ice regardless of hybrid mode. 204 # Run llvm2ice regardless of hybrid mode.
202 shellcmd([llvm2ice, 205 shellcmd([llvm2ice,
203 '-O' + opt_level, 206 '-O' + opt_level,
204 '-bitcode-format=pnacl', 207 '-bitcode-format=pnacl',
205 '-o', asm_sz] + 208 '-o', obj_sz if args.elf else asm_sz] +
206 (['-externalize', 209 (['-externalize',
207 '-ffunction-sections', 210 '-ffunction-sections',
208 '-fdata-sections'] if hybrid else []) + 211 '-fdata-sections'] if hybrid else []) +
212 (['-elf-writer'] if args.elf else []) +
209 args.sz_args + 213 args.sz_args +
210 [pexe], 214 [pexe],
211 echo=args.verbose) 215 echo=args.verbose)
212 shellcmd(( 216 if not args.elf:
213 'llvm-mc -arch=x86 -filetype=obj -o {obj} {asm}' 217 shellcmd((
214 ).format(asm=asm_sz, obj=obj_sz), echo=args.verbose) 218 'llvm-mc -arch=x86 -filetype=obj -o {obj} {asm}'
219 ).format(asm=asm_sz, obj=obj_sz), echo=args.verbose)
215 shellcmd(( 220 shellcmd((
216 'objcopy --redefine-sym _start=_user_start {obj}' 221 'objcopy --redefine-sym _start=_user_start {obj}'
217 ).format(obj=obj_sz), echo=args.verbose) 222 ).format(obj=obj_sz), echo=args.verbose)
218 if hybrid: 223 if hybrid:
219 shellcmd(( 224 shellcmd((
220 'nm {obj} | sed -n "s/.* [a-zA-Z] //p" > {sym}' 225 'nm {obj} | sed -n "s/.* [a-zA-Z] //p" > {sym}'
221 ).format(obj=obj_sz, sym=sym_sz), echo=args.verbose) 226 ).format(obj=obj_sz, sym=sym_sz), echo=args.verbose)
222 227
223 if hybrid: 228 if hybrid:
224 with open(sym_sz_unescaped) as f: 229 with open(sym_sz_unescaped) as f:
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
285 if args.verbose: 290 if args.verbose:
286 print 'PATH={path}'.format(path=os.environ['PATH']) 291 print 'PATH={path}'.format(path=os.environ['PATH'])
287 if hybrid: 292 if hybrid:
288 print 'include={regex}'.format(regex=re_include_str) 293 print 'include={regex}'.format(regex=re_include_str)
289 print 'exclude={regex}'.format(regex=re_exclude_str) 294 print 'exclude={regex}'.format(regex=re_exclude_str)
290 print 'default_match={dm}'.format(dm=default_match) 295 print 'default_match={dm}'.format(dm=default_match)
291 print 'Number of Subzero syms = {num}'.format(num=len(sz_syms)) 296 print 'Number of Subzero syms = {num}'.format(num=len(sz_syms))
292 297
293 if __name__ == '__main__': 298 if __name__ == '__main__':
294 main() 299 main()
OLDNEW
« no previous file with comments | « pydir/crosstest.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698