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

Side by Side Diff: pydir/build-runtime.py

Issue 1147023007: Subzero: Basic Block Profiler. (Closed) Base URL: https://chromium.googlesource.com/native_client/pnacl-subzero.git@master
Patch Set: Named constants; fflush; clang-format. Created 5 years, 6 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 | « Makefile.standalone ('k') | pydir/szbuild.py » ('j') | 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 shutil 5 import shutil
6 import tempfile 6 import tempfile
7 from utils import shellcmd 7 from utils import shellcmd
8 from utils import FindBaseNaCl 8 from utils import FindBaseNaCl
9 9
10 def Translate(ll_files, extra_args, obj, verbose): 10 def Translate(ll_files, extra_args, obj, verbose):
11 """Translate a set of input bitcode files into a single object file. 11 """Translate a set of input bitcode files into a single object file.
12 12
13 Use pnacl-llc to translate textual bitcode input ll_files into object file 13 Use pnacl-llc to translate textual bitcode input ll_files into object file
14 obj, using extra_args as the architectural flags. 14 obj, using extra_args as the architectural flags.
15 """ 15 """
16 shellcmd(['cat'] + ll_files + ['|', 16 shellcmd(['cat'] + ll_files + ['|',
17 'pnacl-llc', 17 'pnacl-llc',
18 '-externalize', 18 '-externalize',
19 '-function-sections', 19 '-function-sections',
20 '-O2', 20 '-O2',
21 '-filetype=obj', 21 '-filetype=obj',
22 '-bitcode-format=llvm', 22 '-bitcode-format=llvm',
23 '-o', obj 23 '-o', obj
24 ] + extra_args, echo=verbose) 24 ] + extra_args, echo=verbose)
25 shellcmd(['objcopy', 25 shellcmd(['objcopy',
26 '--localize-symbol=nacl_tp_tdb_offset', 26 '--strip-symbol=nacl_tp_tdb_offset',
27 '--localize-symbol=nacl_tp_tls_offset', 27 '--strip-symbol=nacl_tp_tls_offset',
28 obj 28 obj
29 ], echo=verbose) 29 ], echo=verbose)
30 30
31 def PartialLink(obj_files, extra_args, lib, verbose):
32 """Partially links a set of obj files into a final obj library."""
33 shellcmd(['ld',
34 '-o', lib,
35 '-r',
36 ] + extra_args + obj_files, echo=verbose)
37
31 def main(): 38 def main():
32 """Build the Subzero runtime support library for all architectures. 39 """Build the Subzero runtime support library for all architectures.
33 """ 40 """
34 argparser = argparse.ArgumentParser( 41 argparser = argparse.ArgumentParser(
35 description=' ' + main.__doc__, 42 description=' ' + main.__doc__,
36 formatter_class=argparse.RawTextHelpFormatter) 43 formatter_class=argparse.RawTextHelpFormatter)
37 argparser.add_argument('--verbose', '-v', dest='verbose', 44 argparser.add_argument('--verbose', '-v', dest='verbose',
38 action='store_true', 45 action='store_true',
39 help='Display some extra debugging output') 46 help='Display some extra debugging output')
40 argparser.add_argument('--pnacl-root', dest='pnacl_root', 47 argparser.add_argument('--pnacl-root', dest='pnacl_root',
(...skipping 24 matching lines...) Expand all
65 shellcmd(['pnacl-opt', 72 shellcmd(['pnacl-opt',
66 '-pnacl-abi-simplify-preopt', 73 '-pnacl-abi-simplify-preopt',
67 '-pnacl-abi-simplify-postopt', 74 '-pnacl-abi-simplify-postopt',
68 '-pnaclabi-allow-debug-metadata', 75 '-pnaclabi-allow-debug-metadata',
69 '{dir}/szrt.tmp.bc'.format(dir=tempdir), 76 '{dir}/szrt.tmp.bc'.format(dir=tempdir),
70 '-S', 77 '-S',
71 '-o', '{dir}/szrt.ll'.format(dir=tempdir) 78 '-o', '{dir}/szrt.ll'.format(dir=tempdir)
72 ], echo=args.verbose) 79 ], echo=args.verbose)
73 ll_files = ['{dir}/szrt.ll'.format(dir=tempdir), 80 ll_files = ['{dir}/szrt.ll'.format(dir=tempdir),
74 '{srcdir}/szrt_ll.ll'.format(srcdir=srcdir)] 81 '{srcdir}/szrt_ll.ll'.format(srcdir=srcdir)]
75 # Translate tempdir/szrt.ll and srcdir/szrt_ll.ll to szrt_native_x8632.o 82
83 # Translate tempdir/szrt.ll and tempdir/szrt_ll.ll to
84 # szrt_native_x8632.tmp.o.
76 Translate(ll_files, 85 Translate(ll_files,
77 ['-mtriple=i686', '-mcpu=pentium4m'], 86 ['-mtriple=i686', '-mcpu=pentium4m'],
78 '{rtdir}/szrt_native_x8632.o'.format(rtdir=rtdir), 87 '{dir}/szrt_native_x8632.tmp.o'.format(dir=tempdir),
79 args.verbose) 88 args.verbose)
80 # Translate tempdir/szrt.ll and srcdir/szrt_ll.ll to szrt_sb_x8632.o 89 # Compile srcdir/szrt_profiler.c to tempdir/szrt_profiler_native_i686.o
90 shellcmd(['clang',
91 '-O2',
92 '-target=i686',
93 '-c',
94 '{srcdir}/szrt_profiler.c'.format(srcdir=srcdir),
95 '-o', '{dir}/szrt_profiler_native_x8632.o'.format(dir=tempdir)
96 ], echo=args.verbose)
97 # Writing full szrt_native_i686.o.
98 PartialLink(['{dir}/szrt_native_x8632.tmp.o'.format(dir=tempdir),
99 '{dir}/szrt_profiler_native_x8632.o'.format(dir=tempdir)
100 ], ['-m elf_i386'],
101 '{rtdir}/szrt_native_x8632.o'.format(rtdir=rtdir), args.verbose)
102
103 # Translate tempdir/szrt.ll and tempdir/szrt_ll.ll to szrt_sb_x8632.o
104 # The sandboxed library does not get the profiler helper function as the
105 # binaries are linked with -nostdlib.
81 Translate(ll_files, 106 Translate(ll_files,
82 ['-mtriple=i686-nacl', '-mcpu=pentium4m'], 107 ['-mtriple=i686-nacl', '-mcpu=pentium4m'],
83 '{rtdir}/szrt_sb_x8632.o'.format(rtdir=rtdir), 108 '{rtdir}/szrt_sb_x8632.o'.format(rtdir=rtdir),
84 args.verbose) 109 args.verbose)
85 finally: 110 finally:
86 try: 111 try:
87 shutil.rmtree(tempdir) 112 shutil.rmtree(tempdir)
88 except OSError as exc: 113 except OSError as exc:
89 if exc.errno != errno.ENOENT: # ENOENT - no such file or directory 114 if exc.errno != errno.ENOENT: # ENOENT - no such file or directory
90 raise # re-raise exception 115 raise # re-raise exception
91 116
92 if __name__ == '__main__': 117 if __name__ == '__main__':
93 main() 118 main()
OLDNEW
« no previous file with comments | « Makefile.standalone ('k') | pydir/szbuild.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698