| 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 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 124 Subzero re-translation are needed. It checks timestamps of llc, pnacl-sz, | 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_raw |
| 135 """ | 135 """ |
| 136 argparser = argparse.ArgumentParser( | 136 argparser = argparse.ArgumentParser( |
| 137 description=' ' + main.__doc__, | 137 description=' ' + main.__doc__, |
| 138 formatter_class=argparse.RawTextHelpFormatter) | 138 formatter_class=argparse.RawTextHelpFormatter) |
| 139 AddOptionalArgs(argparser) | 139 AddOptionalArgs(argparser) |
| 140 argparser.add_argument('pexe', help='Finalized pexe to translate') | 140 argparser.add_argument('pexe', help='Finalized pexe to translate') |
| 141 args = argparser.parse_args() | 141 args = argparser.parse_args() |
| 142 pexe = args.pexe | 142 pexe = args.pexe |
| 143 exe = args.output | 143 exe = args.output |
| 144 ProcessPexe(args, pexe, exe) | 144 ProcessPexe(args, pexe, exe) |
| 145 | 145 |
| 146 def ProcessPexe(args, pexe, exe): | 146 def ProcessPexe(args, pexe, exe): |
| 147 [pexe_base, ext] = os.path.splitext(pexe) | 147 [pexe_base, ext] = os.path.splitext(pexe) |
| 148 if ext != '.pexe': | 148 if ext != '.pexe': |
| 149 pexe_base = pexe | 149 pexe_base = pexe |
| 150 pexe_base_unescaped = pexe_base | 150 pexe_base_unescaped = pexe_base |
| 151 pexe_base = pipes.quote(pexe_base) | 151 pexe_base = pipes.quote(pexe_base) |
| 152 pexe = pipes.quote(pexe) | 152 pexe = pipes.quote(pexe) |
| 153 | 153 |
| 154 nacl_root = FindBaseNaCl() | 154 nacl_root = FindBaseNaCl() |
| 155 path_addition = ( | 155 path_addition = ( |
| 156 '{root}/toolchain/linux_x86/pnacl_newlib/bin' | 156 '{root}/toolchain/linux_x86/pnacl_newlib_raw/bin' |
| 157 ).format(root=nacl_root) | 157 ).format(root=nacl_root) |
| 158 os.environ['PATH'] = ( | 158 os.environ['PATH'] = ( |
| 159 '{dir}{sep}{path}' | 159 '{dir}{sep}{path}' |
| 160 ).format(dir=path_addition, sep=os.pathsep, path=os.environ['PATH']) | 160 ).format(dir=path_addition, sep=os.pathsep, path=os.environ['PATH']) |
| 161 obj_llc = pexe_base + '.llc.o' | 161 obj_llc = pexe_base + '.llc.o' |
| 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 |
| (...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 279 'objcopy --globalize-symbol={start} {partial}' | 279 'objcopy --globalize-symbol={start} {partial}' |
| 280 ).format(partial=obj_partial, | 280 ).format(partial=obj_partial, |
| 281 start='_start' if args.sandbox else '_user_start'), | 281 start='_start' if args.sandbox else '_user_start'), |
| 282 echo=args.verbose) | 282 echo=args.verbose) |
| 283 | 283 |
| 284 # Run the linker regardless of hybrid mode. | 284 # Run the linker regardless of hybrid mode. |
| 285 linker = ( | 285 linker = ( |
| 286 '{root}/../third_party/llvm-build/Release+Asserts/bin/clang' | 286 '{root}/../third_party/llvm-build/Release+Asserts/bin/clang' |
| 287 ).format(root=nacl_root) | 287 ).format(root=nacl_root) |
| 288 if args.sandbox: | 288 if args.sandbox: |
| 289 linklib = ('{root}/toolchain/linux_x86/pnacl_newlib/translator/' + | 289 linklib = ('{root}/toolchain/linux_x86/pnacl_newlib_raw/translator/' + |
| 290 'x86-32/lib').format(root=nacl_root) | 290 'x86-32/lib').format(root=nacl_root) |
| 291 shellcmd(( | 291 shellcmd(( |
| 292 '{gold} -nostdlib --no-fix-cortex-a8 --eh-frame-hdr -z text ' + | 292 '{gold} -nostdlib --no-fix-cortex-a8 --eh-frame-hdr -z text ' + |
| 293 '--build-id --entry=__pnacl_start -static ' + | 293 '--build-id --entry=__pnacl_start -static ' + |
| 294 '{linklib}/crtbegin.o {partial} ' + | 294 '{linklib}/crtbegin.o {partial} ' + |
| 295 '{root}/toolchain_build/src/subzero/build/runtime/' + | 295 '{root}/toolchain_build/src/subzero/build/runtime/' + |
| 296 'szrt_sb_x8632.o ' + | 296 'szrt_sb_x8632.o ' + |
| 297 '{linklib}/libpnacl_irt_shim_dummy.a --start-group ' + | 297 '{linklib}/libpnacl_irt_shim_dummy.a --start-group ' + |
| 298 '{linklib}/libgcc.a {linklib}/libcrt_platform.a ' + | 298 '{linklib}/libgcc.a {linklib}/libcrt_platform.a ' + |
| 299 '--end-group {linklib}/crtend.o --undefined=_start ' + | 299 '--end-group {linklib}/crtend.o --undefined=_start ' + |
| 300 '--defsym=__Sz_AbsoluteZero=0 ' + | 300 '--defsym=__Sz_AbsoluteZero=0 ' + |
| 301 '-o {exe}' | 301 '-o {exe}' |
| 302 ).format(gold=gold, linklib=linklib, partial=obj_partial, exe=exe, | 302 ).format(gold=gold, linklib=linklib, partial=obj_partial, exe=exe, |
| 303 root=nacl_root), | 303 root=nacl_root), |
| 304 echo=args.verbose) | 304 echo=args.verbose) |
| 305 else: | 305 else: |
| 306 shellcmd(( | 306 shellcmd(( |
| 307 '{ld} -m32 {partial} -o {exe} ' + | 307 '{ld} -m32 {partial} -o {exe} ' + |
| 308 # Keep the rest of this command line (except szrt_native_x8632.o) in | 308 # Keep the rest of this command line (except szrt_native_x8632.o) in |
| 309 # sync with RunHostLD() in pnacl-translate.py. | 309 # sync with RunHostLD() in pnacl-translate.py. |
| 310 '{root}/toolchain/linux_x86/pnacl_newlib/translator/x86-32-linux/' + | 310 '{root}/toolchain/linux_x86/pnacl_newlib_raw/translator/' + |
| 311 'lib/{{unsandboxed_irt,irt_random,irt_query_list}}.o ' + | 311 'x86-32-linux/lib/' + |
| 312 '{{unsandboxed_irt,irt_random,irt_query_list}}.o ' + |
| 312 '{root}/toolchain_build/src/subzero/build/runtime/' + | 313 '{root}/toolchain_build/src/subzero/build/runtime/' + |
| 313 'szrt_native_x8632.o -lpthread -lrt ' + | 314 'szrt_native_x8632.o -lpthread -lrt ' + |
| 314 '-Wl,--defsym=__Sz_AbsoluteZero=0' | 315 '-Wl,--defsym=__Sz_AbsoluteZero=0' |
| 315 ).format(ld=linker, partial=obj_partial, exe=exe, root=nacl_root), | 316 ).format(ld=linker, partial=obj_partial, exe=exe, root=nacl_root), |
| 316 echo=args.verbose) | 317 echo=args.verbose) |
| 317 | 318 |
| 318 # Put the extra verbose printing at the end. | 319 # Put the extra verbose printing at the end. |
| 319 if args.verbose: | 320 if args.verbose: |
| 320 print 'PATH: {path}'.format(path=path_addition) | 321 print 'PATH: {path}'.format(path=path_addition) |
| 321 if hybrid: | 322 if hybrid: |
| 322 print 'include={regex}'.format(regex=re_include_str) | 323 print 'include={regex}'.format(regex=re_include_str) |
| 323 print 'exclude={regex}'.format(regex=re_exclude_str) | 324 print 'exclude={regex}'.format(regex=re_exclude_str) |
| 324 print 'default_match={dm}'.format(dm=default_match) | 325 print 'default_match={dm}'.format(dm=default_match) |
| 325 print 'Number of Subzero syms = {num}'.format(num=len(sz_syms)) | 326 print 'Number of Subzero syms = {num}'.format(num=len(sz_syms)) |
| 326 | 327 |
| 327 if __name__ == '__main__': | 328 if __name__ == '__main__': |
| 328 main() | 329 main() |
| OLD | NEW |