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

Side by Side Diff: pydir/szbuild.py

Issue 582593002: Subzero: Allow extra args to be passed to llc and Subzero. (Closed) Base URL: https://chromium.googlesource.com/native_client/pnacl-subzero.git@master
Patch Set: Created 6 years, 3 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 | « no previous file | 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 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
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('--verbose', '-v', dest='verbose', 83 argparser.add_argument('--verbose', '-v', dest='verbose',
84 action='store_true', 84 action='store_true',
85 help='Display some extra debugging output') 85 help='Display some extra debugging output')
86 argparser.add_argument('--stats', dest='stats', action='store_true', 86 argparser.add_argument('--sz', dest='sz_args', action='append', default=[],
87 help='Enable Subzero stats output') 87 help='Extra arguments for Subzero')
88 argparser.add_argument('--llc', dest='llc_args', action='append',
89 default=[], help='Extra arguments for llc')
88 90
89 def main(): 91 def main():
90 """Create a hybrid translation from Subzero and llc. 92 """Create a hybrid translation from Subzero and llc.
91 93
92 Takes a finalized pexe and builds a native executable as a 94 Takes a finalized pexe and builds a native executable as a
93 hybrid of Subzero and llc translated bitcode. Linker tricks are 95 hybrid of Subzero and llc translated bitcode. Linker tricks are
94 used to determine whether Subzero or llc generated symbols are 96 used to determine whether Subzero or llc generated symbols are
95 used, on a per-symbol basis. 97 used, on a per-symbol basis.
96 98
97 By default, for every symbol, its llc version is used. Subzero 99 By default, for every symbol, its llc version is used. Subzero
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
165 '{root}/toolchain_build/src/subzero/llvm2ice' 167 '{root}/toolchain_build/src/subzero/llvm2ice'
166 ).format(root=nacl_root) 168 ).format(root=nacl_root)
167 llcbin = ( 169 llcbin = (
168 '{root}/toolchain/linux_x86/pnacl_newlib/host_x86_32/bin/llc' 170 '{root}/toolchain/linux_x86/pnacl_newlib/host_x86_32/bin/llc'
169 ).format(root=nacl_root) 171 ).format(root=nacl_root)
170 opt_level = args.optlevel 172 opt_level = args.optlevel
171 173
172 if args.force or NewerThanOrNotThere(pexe, obj_llc) or \ 174 if args.force or NewerThanOrNotThere(pexe, obj_llc) or \
173 NewerThanOrNotThere(llcbin, obj_llc): 175 NewerThanOrNotThere(llcbin, obj_llc):
174 opt_level_map = { 'm1':'0', '-1':'0', '0':'0', '1':'1', '2':'2' } 176 opt_level_map = { 'm1':'0', '-1':'0', '0':'0', '1':'1', '2':'2' }
175 shellcmd(( 177 shellcmd(['pnacl-translate',
176 'pnacl-translate -ffunction-sections -c -arch x86-32-linux ' + 178 '-ffunction-sections',
177 '-O{level} --pnacl-driver-append-LLC_FLAGS_EXTRA=-externalize ' + 179 '-c',
178 '-o {obj} {pexe}' 180 '-arch', 'x86-32-linux',
179 ).format(level=opt_level_map[opt_level], obj=obj_llc, pexe=pexe), 181 '-O' + opt_level_map[opt_level],
182 '--pnacl-driver-append-LLC_FLAGS_EXTRA=-externalize',
183 '-o', obj_llc] +
184 args.llc_args +
185 [pexe],
180 echo=args.verbose) 186 echo=args.verbose)
181 shellcmd(( 187 shellcmd((
182 'objcopy --redefine-sym _start=_user_start {obj}' 188 'objcopy --redefine-sym _start=_user_start {obj}'
183 ).format(obj=obj_llc), echo=args.verbose) 189 ).format(obj=obj_llc), echo=args.verbose)
184 shellcmd(( 190 shellcmd((
185 'nm {obj} | sed -n "s/.* [a-zA-Z] //p" > {sym}' 191 'nm {obj} | sed -n "s/.* [a-zA-Z] //p" > {sym}'
186 ).format(obj=obj_llc, sym=sym_llc), echo=args.verbose) 192 ).format(obj=obj_llc, sym=sym_llc), echo=args.verbose)
187 if args.force or NewerThanOrNotThere(pexe, obj_sz) or \ 193 if args.force or NewerThanOrNotThere(pexe, obj_sz) or \
188 NewerThanOrNotThere(llvm2ice, obj_sz): 194 NewerThanOrNotThere(llvm2ice, obj_sz):
189 shellcmd(( 195 shellcmd([llvm2ice,
190 '{l2i} -O{level} -bitcode-format=pnacl -disable-globals ' + 196 '-O' + opt_level,
191 '-externalize -ffunction-sections {pexe} -o {asm}' + 197 '-bitcode-format=pnacl',
192 (' --stats' if args.stats else '') 198 '-disable-globals',
193 ).format(l2i=llvm2ice, level=opt_level, pexe=pexe, asm=asm_sz), 199 '-externalize',
200 '-ffunction-sections',
201 '-o', asm_sz] +
202 args.sz_args +
203 [pexe],
194 echo=args.verbose) 204 echo=args.verbose)
195 shellcmd(( 205 shellcmd((
196 'llvm-mc -arch=x86 -x86-asm-syntax=intel -filetype=obj -o {obj} ' + 206 'llvm-mc -arch=x86 -x86-asm-syntax=intel -filetype=obj -o {obj} ' +
197 '{asm}' 207 '{asm}'
198 ).format(asm=asm_sz, obj=obj_sz), echo=args.verbose) 208 ).format(asm=asm_sz, obj=obj_sz), echo=args.verbose)
199 shellcmd(( 209 shellcmd((
200 'objcopy --redefine-sym _start=_user_start {obj}' 210 'objcopy --redefine-sym _start=_user_start {obj}'
201 ).format(obj=obj_sz), echo=args.verbose) 211 ).format(obj=obj_sz), echo=args.verbose)
202 shellcmd(( 212 shellcmd((
203 'nm {obj} | sed -n "s/.* [a-zA-Z] //p" > {sym}' 213 'nm {obj} | sed -n "s/.* [a-zA-Z] //p" > {sym}'
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
256 # Put the extra verbose printing at the end. 266 # Put the extra verbose printing at the end.
257 if args.verbose: 267 if args.verbose:
258 print 'PATH={path}'.format(path=os.environ['PATH']) 268 print 'PATH={path}'.format(path=os.environ['PATH'])
259 print 'include={regex}'.format(regex=re_include_str) 269 print 'include={regex}'.format(regex=re_include_str)
260 print 'exclude={regex}'.format(regex=re_exclude_str) 270 print 'exclude={regex}'.format(regex=re_exclude_str)
261 print 'default_match={dm}'.format(dm=default_match) 271 print 'default_match={dm}'.format(dm=default_match)
262 print 'Number of Subzero syms = {num}'.format(num=len(sz_syms)) 272 print 'Number of Subzero syms = {num}'.format(num=len(sz_syms))
263 273
264 if __name__ == '__main__': 274 if __name__ == '__main__':
265 main() 275 main()
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698