| 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 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 162 sym_sz_unescaped = pexe_base_unescaped + '.sym.sz.txt' | 162 sym_sz_unescaped = pexe_base_unescaped + '.sym.sz.txt' |
| 163 whitelist_sz = pexe_base + '.wl.sz.txt' | 163 whitelist_sz = pexe_base + '.wl.sz.txt' |
| 164 whitelist_sz_unescaped = pexe_base_unescaped + '.wl.sz.txt' | 164 whitelist_sz_unescaped = pexe_base_unescaped + '.wl.sz.txt' |
| 165 llvm2ice = ( | 165 llvm2ice = ( |
| 166 '{root}/toolchain_build/src/subzero/llvm2ice' | 166 '{root}/toolchain_build/src/subzero/llvm2ice' |
| 167 ).format(root=nacl_root) | 167 ).format(root=nacl_root) |
| 168 llcbin = ( | 168 llcbin = ( |
| 169 '{root}/toolchain/linux_x86/pnacl_newlib/bin/llc' | 169 '{root}/toolchain/linux_x86/pnacl_newlib/bin/llc' |
| 170 ).format(root=nacl_root) | 170 ).format(root=nacl_root) |
| 171 opt_level = args.optlevel | 171 opt_level = args.optlevel |
| 172 | 172 opt_level_map = { 'm1':'0', '-1':'0', '0':'0', '1':'1', '2':'2' } |
| 173 if args.force or NewerThanOrNotThere(pexe, obj_llc) or \ | 173 if args.force or NewerThanOrNotThere(pexe, obj_llc) or \ |
| 174 NewerThanOrNotThere(llcbin, obj_llc): | 174 NewerThanOrNotThere(llcbin, obj_llc): |
| 175 opt_level_map = { 'm1':'0', '-1':'0', '0':'0', '1':'1', '2':'2' } | |
| 176 shellcmd(['pnacl-translate', | 175 shellcmd(['pnacl-translate', |
| 177 '-ffunction-sections', | 176 '-ffunction-sections', |
| 178 '-c', | 177 '-c', |
| 179 '-arch', 'x86-32-linux', | 178 '-arch', 'x86-32-linux', |
| 180 '-O' + opt_level_map[opt_level], | 179 '-O' + opt_level_map[opt_level], |
| 181 '--pnacl-driver-append-LLC_FLAGS_EXTRA=-externalize', | 180 '--pnacl-driver-append-LLC_FLAGS_EXTRA=-externalize', |
| 182 '-o', obj_llc] + | 181 '-o', obj_llc] + |
| 183 args.llc_args + | 182 args.llc_args + |
| 184 [pexe], | 183 [pexe], |
| 185 echo=args.verbose) | 184 echo=args.verbose) |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 245 shellcmd(( | 244 shellcmd(( |
| 246 'ld -r -m elf_i386 -o {partial} {sz} {llc}' | 245 'ld -r -m elf_i386 -o {partial} {sz} {llc}' |
| 247 ).format(partial=obj_partial, sz=obj_sz_weak, llc=obj_llc_weak), | 246 ).format(partial=obj_partial, sz=obj_sz_weak, llc=obj_llc_weak), |
| 248 echo=args.verbose) | 247 echo=args.verbose) |
| 249 shellcmd(( | 248 shellcmd(( |
| 250 'objcopy -w --localize-symbol="*" {partial}' | 249 'objcopy -w --localize-symbol="*" {partial}' |
| 251 ).format(partial=obj_partial), echo=args.verbose) | 250 ).format(partial=obj_partial), echo=args.verbose) |
| 252 shellcmd(( | 251 shellcmd(( |
| 253 'objcopy --globalize-symbol=_user_start {partial}' | 252 'objcopy --globalize-symbol=_user_start {partial}' |
| 254 ).format(partial=obj_partial), echo=args.verbose) | 253 ).format(partial=obj_partial), echo=args.verbose) |
| 254 linker = ( |
| 255 '{root}/../third_party/llvm-build/Release+Asserts/bin/clang' |
| 256 ).format(root=nacl_root) |
| 255 shellcmd(( | 257 shellcmd(( |
| 256 'gcc -m32 {partial} -o {exe} ' + | 258 '{ld} -m32 {partial} -o {exe} -O{opt_level} ' + |
| 257 # Keep the rest of this command line (except szrt.c) in sync | 259 # Keep the rest of this command line (except szrt.c) in sync |
| 258 # with RunHostLD() in pnacl-translate.py. | 260 # with RunHostLD() in pnacl-translate.py. |
| 259 '{root}/toolchain/linux_x86/pnacl_newlib/translator/x86-32-linux/lib/' + | 261 '{root}/toolchain/linux_x86/pnacl_newlib/translator/x86-32-linux/lib/' + |
| 260 '{{unsandboxed_irt,irt_query_list}}.o ' + | 262 '{{unsandboxed_irt,irt_query_list}}.o ' + |
| 261 '{root}/toolchain_build/src/subzero/runtime/szrt.c ' + | 263 '{root}/toolchain_build/src/subzero/runtime/szrt.c ' + |
| 264 '{root}/toolchain_build/src/subzero/runtime/szrt_i686.ll ' + |
| 262 '-lpthread -lrt' | 265 '-lpthread -lrt' |
| 263 ).format(partial=obj_partial, exe=exe, root=nacl_root), | 266 ).format(ld=linker, partial=obj_partial, exe=exe, |
| 267 opt_level=opt_level_map[opt_level], root=nacl_root), |
| 264 echo=args.verbose) | 268 echo=args.verbose) |
| 265 # Put the extra verbose printing at the end. | 269 # Put the extra verbose printing at the end. |
| 266 if args.verbose: | 270 if args.verbose: |
| 267 print 'PATH={path}'.format(path=os.environ['PATH']) | 271 print 'PATH={path}'.format(path=os.environ['PATH']) |
| 268 print 'include={regex}'.format(regex=re_include_str) | 272 print 'include={regex}'.format(regex=re_include_str) |
| 269 print 'exclude={regex}'.format(regex=re_exclude_str) | 273 print 'exclude={regex}'.format(regex=re_exclude_str) |
| 270 print 'default_match={dm}'.format(dm=default_match) | 274 print 'default_match={dm}'.format(dm=default_match) |
| 271 print 'Number of Subzero syms = {num}'.format(num=len(sz_syms)) | 275 print 'Number of Subzero syms = {num}'.format(num=len(sz_syms)) |
| 272 | 276 |
| 273 if __name__ == '__main__': | 277 if __name__ == '__main__': |
| 274 main() | 278 main() |
| OLD | NEW |