Chromium Code Reviews| 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 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 182 '-o', obj_llc] + | 182 '-o', obj_llc] + |
| 183 args.llc_args + | 183 args.llc_args + |
| 184 [pexe], | 184 [pexe], |
| 185 echo=args.verbose) | 185 echo=args.verbose) |
| 186 shellcmd(( | 186 shellcmd(( |
| 187 'objcopy --redefine-sym _start=_user_start {obj}' | 187 'objcopy --redefine-sym _start=_user_start {obj}' |
| 188 ).format(obj=obj_llc), echo=args.verbose) | 188 ).format(obj=obj_llc), echo=args.verbose) |
| 189 shellcmd(( | 189 shellcmd(( |
| 190 'nm {obj} | sed -n "s/.* [a-zA-Z] //p" > {sym}' | 190 'nm {obj} | sed -n "s/.* [a-zA-Z] //p" > {sym}' |
| 191 ).format(obj=obj_llc, sym=sym_llc), echo=args.verbose) | 191 ).format(obj=obj_llc, sym=sym_llc), echo=args.verbose) |
| 192 szrt_bitcode_src = ( | |
| 193 '{root}/toolchain_build/src/subzero/runtime/szrt_i686.ll' | |
| 194 ).format(root=nacl_root) | |
| 195 szrt_bitcode_obj = ( | |
| 196 '{root}/toolchain_build/src/subzero/build/szrt_i686.o' | |
| 197 ).format(root=nacl_root) | |
| 198 if args.force or \ | |
| 199 NewerThanOrNotThere(szrt_bitcode_src, szrt_bitcode_obj) or \ | |
| 200 NewerThanOrNotThere(llcbin, szrt_bitcode_obj): | |
| 201 shellcmd(['pnacl-translate', | |
| 202 '-ffunction-sections', | |
| 203 '-c', | |
| 204 '-arch', 'x86-32-linux', | |
| 205 '-O2', | |
| 206 '--pnacl-driver-append-LLC_FLAGS_EXTRA=-externalize', | |
| 207 '-o', szrt_bitcode_obj] + | |
| 208 args.llc_args + | |
| 209 [szrt_bitcode_src], | |
| 210 echo=args.verbose) | |
| 192 if args.force or NewerThanOrNotThere(pexe, obj_sz) or \ | 211 if args.force or NewerThanOrNotThere(pexe, obj_sz) or \ |
| 193 NewerThanOrNotThere(llvm2ice, obj_sz): | 212 NewerThanOrNotThere(llvm2ice, obj_sz): |
| 194 shellcmd([llvm2ice, | 213 shellcmd([llvm2ice, |
| 195 '-O' + opt_level, | 214 '-O' + opt_level, |
| 196 '-bitcode-format=pnacl', | 215 '-bitcode-format=pnacl', |
| 197 '-disable-globals', | 216 '-disable-globals', |
| 198 '-externalize', | 217 '-externalize', |
| 199 '-ffunction-sections', | 218 '-ffunction-sections', |
| 200 '-o', asm_sz] + | 219 '-o', asm_sz] + |
| 201 args.sz_args + | 220 args.sz_args + |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 246 'ld -r -m elf_i386 -o {partial} {sz} {llc}' | 265 'ld -r -m elf_i386 -o {partial} {sz} {llc}' |
| 247 ).format(partial=obj_partial, sz=obj_sz_weak, llc=obj_llc_weak), | 266 ).format(partial=obj_partial, sz=obj_sz_weak, llc=obj_llc_weak), |
| 248 echo=args.verbose) | 267 echo=args.verbose) |
| 249 shellcmd(( | 268 shellcmd(( |
| 250 'objcopy -w --localize-symbol="*" {partial}' | 269 'objcopy -w --localize-symbol="*" {partial}' |
| 251 ).format(partial=obj_partial), echo=args.verbose) | 270 ).format(partial=obj_partial), echo=args.verbose) |
| 252 shellcmd(( | 271 shellcmd(( |
| 253 'objcopy --globalize-symbol=_user_start {partial}' | 272 'objcopy --globalize-symbol=_user_start {partial}' |
| 254 ).format(partial=obj_partial), echo=args.verbose) | 273 ).format(partial=obj_partial), echo=args.verbose) |
| 255 shellcmd(( | 274 shellcmd(( |
| 256 'gcc -m32 {partial} -o {exe} ' + | 275 'gcc -m32 {partial} -o {exe} ' + |
|
Jim Stichnoth
2014/10/07 21:57:47
Could we avoid the above compilation step of szrt_
jvoung (off chromium)
2014/10/07 22:55:54
Good idea -- done.
| |
| 257 # Keep the rest of this command line (except szrt.c) in sync | 276 # Keep the rest of this command line (except szrt.c) in sync |
| 258 # with RunHostLD() in pnacl-translate.py. | 277 # with RunHostLD() in pnacl-translate.py. |
| 259 '{root}/toolchain/linux_x86/pnacl_newlib/translator/x86-32-linux/lib/' + | 278 '{root}/toolchain/linux_x86/pnacl_newlib/translator/x86-32-linux/lib/' + |
| 260 '{{unsandboxed_irt,irt_query_list}}.o ' + | 279 '{{unsandboxed_irt,irt_query_list}}.o ' + |
| 261 '{root}/toolchain_build/src/subzero/runtime/szrt.c ' + | 280 '{root}/toolchain_build/src/subzero/runtime/szrt.c ' + |
| 281 szrt_bitcode_obj + ' ' + | |
| 262 '-lpthread -lrt' | 282 '-lpthread -lrt' |
| 263 ).format(partial=obj_partial, exe=exe, root=nacl_root), | 283 ).format(partial=obj_partial, exe=exe, root=nacl_root), |
| 264 echo=args.verbose) | 284 echo=args.verbose) |
| 265 # Put the extra verbose printing at the end. | 285 # Put the extra verbose printing at the end. |
| 266 if args.verbose: | 286 if args.verbose: |
| 267 print 'PATH={path}'.format(path=os.environ['PATH']) | 287 print 'PATH={path}'.format(path=os.environ['PATH']) |
| 268 print 'include={regex}'.format(regex=re_include_str) | 288 print 'include={regex}'.format(regex=re_include_str) |
| 269 print 'exclude={regex}'.format(regex=re_exclude_str) | 289 print 'exclude={regex}'.format(regex=re_exclude_str) |
| 270 print 'default_match={dm}'.format(dm=default_match) | 290 print 'default_match={dm}'.format(dm=default_match) |
| 271 print 'Number of Subzero syms = {num}'.format(num=len(sz_syms)) | 291 print 'Number of Subzero syms = {num}'.format(num=len(sz_syms)) |
| 272 | 292 |
| 273 if __name__ == '__main__': | 293 if __name__ == '__main__': |
| 274 main() | 294 main() |
| OLD | NEW |