OLD | NEW |
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 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
114 Each --include and --exclude argument can be a regular expression or a range | 114 Each --include and --exclude argument can be a regular expression or a range |
115 of lines in the symbol file. Each regular expression is wrapped inside | 115 of lines in the symbol file. Each regular expression is wrapped inside |
116 '^$', so if you want a substring match on 'foo', use '.*foo.*' instead. | 116 '^$', so if you want a substring match on 'foo', use '.*foo.*' instead. |
117 Ranges use python-style 'first:last' notation, so e.g. use '0:10' or ':10' | 117 Ranges use python-style 'first:last' notation, so e.g. use '0:10' or ':10' |
118 for the first 10 lines of the file, or '1' for the second line of the file. | 118 for the first 10 lines of the file, or '1' for the second line of the file. |
119 | 119 |
120 If no --include or --exclude arguments are given, the executable is produced | 120 If no --include or --exclude arguments are given, the executable is produced |
121 entirely using Subzero, without using llc or linker tricks. | 121 entirely using Subzero, without using llc or linker tricks. |
122 | 122 |
123 This script uses file modification timestamps to determine whether llc and | 123 This script uses file modification timestamps to determine whether llc and |
124 Subzero re-translation are needed. It checks timestamps of llc, llvm2ice, | 124 Subzero re-translation are needed. It checks timestamps of llc, pnacl-sz, |
125 and the pexe against the translated object files to determine the minimal | 125 and the pexe against the translated object files to determine the minimal |
126 work necessary. The --force option suppresses those checks and | 126 work necessary. The --force option suppresses those checks and |
127 re-translates everything. | 127 re-translates everything. |
128 | 128 |
129 This script augments PATH so that various PNaCl and LLVM tools can be run. | 129 This script augments PATH so that various PNaCl and LLVM tools can be run. |
130 These extra paths are within the native_client tree. When changes are made | 130 These extra paths are within the native_client tree. When changes are made |
131 to these tools, copy them this way: | 131 to these tools, copy them this way: |
132 cd native_client | 132 cd native_client |
133 toolchain_build/toolchain_build_pnacl.py llvm_x86_64_linux \\ | 133 toolchain_build/toolchain_build_pnacl.py llvm_x86_64_linux \\ |
134 --install=toolchain/linux_x86/pnacl_newlib | 134 --install=toolchain/linux_x86/pnacl_newlib |
(...skipping 27 matching lines...) Expand all Loading... |
162 obj_sz = pexe_base + '.sz.o' | 162 obj_sz = pexe_base + '.sz.o' |
163 asm_sz = pexe_base + '.sz.s' | 163 asm_sz = pexe_base + '.sz.s' |
164 obj_llc_weak = pexe_base + '.weak.llc.o' | 164 obj_llc_weak = pexe_base + '.weak.llc.o' |
165 obj_sz_weak = pexe_base + '.weak.sz.o' | 165 obj_sz_weak = pexe_base + '.weak.sz.o' |
166 obj_partial = obj_sz # overridden for hybrid mode | 166 obj_partial = obj_sz # overridden for hybrid mode |
167 sym_llc = pexe_base + '.sym.llc.txt' | 167 sym_llc = pexe_base + '.sym.llc.txt' |
168 sym_sz = pexe_base + '.sym.sz.txt' | 168 sym_sz = pexe_base + '.sym.sz.txt' |
169 sym_sz_unescaped = pexe_base_unescaped + '.sym.sz.txt' | 169 sym_sz_unescaped = pexe_base_unescaped + '.sym.sz.txt' |
170 whitelist_sz = pexe_base + '.wl.sz.txt' | 170 whitelist_sz = pexe_base + '.wl.sz.txt' |
171 whitelist_sz_unescaped = pexe_base_unescaped + '.wl.sz.txt' | 171 whitelist_sz_unescaped = pexe_base_unescaped + '.wl.sz.txt' |
172 llvm2ice = ( | 172 pnacl_sz = ( |
173 '{root}/toolchain_build/src/subzero/llvm2ice' | 173 '{root}/toolchain_build/src/subzero/pnacl-sz' |
174 ).format(root=nacl_root) | 174 ).format(root=nacl_root) |
175 llcbin = 'llc' | 175 llcbin = 'llc' |
176 gold = 'le32-nacl-ld.gold' | 176 gold = 'le32-nacl-ld.gold' |
177 opt_level = args.optlevel | 177 opt_level = args.optlevel |
178 opt_level_map = { 'm1':'0', '-1':'0', '0':'0', '1':'1', '2':'2' } | 178 opt_level_map = { 'm1':'0', '-1':'0', '0':'0', '1':'1', '2':'2' } |
179 hybrid = args.include or args.exclude | 179 hybrid = args.include or args.exclude |
180 | 180 |
181 if hybrid and (args.force or | 181 if hybrid and (args.force or |
182 NewerThanOrNotThere(pexe, obj_llc) or | 182 NewerThanOrNotThere(pexe, obj_llc) or |
183 NewerThanOrNotThere(llcbin, obj_llc)): | 183 NewerThanOrNotThere(llcbin, obj_llc)): |
(...skipping 15 matching lines...) Expand all Loading... |
199 shellcmd(( | 199 shellcmd(( |
200 'objcopy --redefine-sym _start=_user_start {obj}' | 200 'objcopy --redefine-sym _start=_user_start {obj}' |
201 ).format(obj=obj_llc), echo=args.verbose) | 201 ).format(obj=obj_llc), echo=args.verbose) |
202 # Generate llc syms file for consistency, even though it's not used. | 202 # Generate llc syms file for consistency, even though it's not used. |
203 shellcmd(( | 203 shellcmd(( |
204 'nm {obj} | sed -n "s/.* [a-zA-Z] //p" > {sym}' | 204 'nm {obj} | sed -n "s/.* [a-zA-Z] //p" > {sym}' |
205 ).format(obj=obj_llc, sym=sym_llc), echo=args.verbose) | 205 ).format(obj=obj_llc, sym=sym_llc), echo=args.verbose) |
206 | 206 |
207 if (args.force or | 207 if (args.force or |
208 NewerThanOrNotThere(pexe, obj_sz) or | 208 NewerThanOrNotThere(pexe, obj_sz) or |
209 NewerThanOrNotThere(llvm2ice, obj_sz)): | 209 NewerThanOrNotThere(pnacl_sz, obj_sz)): |
210 # Run llvm2ice regardless of hybrid mode. | 210 # Run pnacl-sz regardless of hybrid mode. |
211 shellcmd([llvm2ice, | 211 shellcmd([pnacl_sz, |
212 '-O' + opt_level, | 212 '-O' + opt_level, |
213 '-bitcode-format=pnacl', | 213 '-bitcode-format=pnacl', |
214 '-filetype=' + args.filetype, | 214 '-filetype=' + args.filetype, |
215 '-o', obj_sz if args.filetype == 'obj' else asm_sz] + | 215 '-o', obj_sz if args.filetype == 'obj' else asm_sz] + |
216 (['-externalize', | 216 (['-externalize', |
217 '-ffunction-sections', | 217 '-ffunction-sections', |
218 '-fdata-sections'] if hybrid else []) + | 218 '-fdata-sections'] if hybrid else []) + |
219 (['-sandbox'] if args.sandbox else []) + | 219 (['-sandbox'] if args.sandbox else []) + |
220 args.sz_args + | 220 args.sz_args + |
221 [pexe], | 221 [pexe], |
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
317 if args.verbose: | 317 if args.verbose: |
318 print 'PATH: {path}'.format(path=path_addition) | 318 print 'PATH: {path}'.format(path=path_addition) |
319 if hybrid: | 319 if hybrid: |
320 print 'include={regex}'.format(regex=re_include_str) | 320 print 'include={regex}'.format(regex=re_include_str) |
321 print 'exclude={regex}'.format(regex=re_exclude_str) | 321 print 'exclude={regex}'.format(regex=re_exclude_str) |
322 print 'default_match={dm}'.format(dm=default_match) | 322 print 'default_match={dm}'.format(dm=default_match) |
323 print 'Number of Subzero syms = {num}'.format(num=len(sz_syms)) | 323 print 'Number of Subzero syms = {num}'.format(num=len(sz_syms)) |
324 | 324 |
325 if __name__ == '__main__': | 325 if __name__ == '__main__': |
326 main() | 326 main() |
OLD | NEW |