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

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

Issue 944333002: Subzero: Update tests and build scripts for sandboxing. (Closed) Base URL: https://chromium.googlesource.com/native_client/pnacl-subzero.git@master
Patch Set: More code review changes Created 5 years, 10 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/crosstest.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 #!/usr/bin/env python2
2
3 import argparse
4 import os
5 import shutil
6 import tempfile
7 from utils import shellcmd
8 from utils import FindBaseNaCl
9
10 def Translate(ll_files, extra_args, obj, verbose):
11 """Translate a set of input bitcode files into a single object file.
12
13 Use pnacl-llc to translate textual bitcode input ll_files into object file
14 obj, using extra_args as the architectural flags.
15 """
16 shellcmd(['cat'] + ll_files + ['|',
17 'pnacl-llc',
18 '-externalize',
19 '-filetype=obj',
20 '-bitcode-format=llvm',
21 '-o', obj
22 ] + extra_args, echo=verbose)
23 shellcmd(['objcopy',
24 '--localize-symbol=nacl_tp_tdb_offset',
25 '--localize-symbol=nacl_tp_tls_offset',
26 obj
27 ], echo=verbose)
28
29 def main():
30 """Build the Subzero runtime support library for all architectures.
31 """
32 argparser = argparse.ArgumentParser(
33 description=' ' + main.__doc__,
34 formatter_class=argparse.RawTextHelpFormatter)
35 argparser.add_argument('--verbose', '-v', dest='verbose',
36 action='store_true',
37 help='Display some extra debugging output')
38 args = argparser.parse_args()
39 nacl_root = FindBaseNaCl()
40 os.environ['PATH'] = (
41 '{root}/toolchain/linux_x86/pnacl_newlib/bin{sep}' +
42 '{path}'
43 ).format(root=nacl_root, sep=os.pathsep, path=os.environ['PATH'])
44 srcdir = (
45 '{root}/toolchain_build/src/subzero/runtime'
46 ).format(root=nacl_root)
47 rtdir = (
48 '{root}/toolchain_build/src/subzero/build/runtime'
49 ).format(root=nacl_root)
50 try:
51 tempdir = tempfile.mkdtemp()
52 if os.path.exists(rtdir) and not os.path.isdir(rtdir):
53 os.remove(rtdir)
54 if not os.path.exists(rtdir):
55 os.makedirs(rtdir)
56 # Compile srcdir/szrt.c to tempdir/szrt.ll
57 shellcmd(['pnacl-clang',
58 '-O2',
59 '-c',
60 '{srcdir}/szrt.c'.format(srcdir=srcdir),
61 '-o', '{dir}/szrt.tmp.bc'.format(dir=tempdir)
62 ], echo=args.verbose)
63 shellcmd(['pnacl-opt',
64 '-pnacl-abi-simplify-preopt',
65 '-pnacl-abi-simplify-postopt',
66 '-pnaclabi-allow-debug-metadata',
67 '{dir}/szrt.tmp.bc'.format(dir=tempdir),
68 '-S',
69 '-o', '{dir}/szrt.ll'.format(dir=tempdir)
70 ], echo=args.verbose)
71 ll_files = ['{dir}/szrt.ll'.format(dir=tempdir),
72 '{srcdir}/szrt_ll.ll'.format(srcdir=srcdir)]
73 # Translate tempdir/szrt.ll and srcdir/szrt_ll.ll to szrt_native_x8632.o
74 Translate(ll_files,
75 ['-mtriple=i386-unknown-linux-gnu', '-mcpu=pentium4m'],
76 '{rtdir}/szrt_native_x8632.o'.format(rtdir=rtdir),
77 args.verbose)
78 # Translate tempdir/szrt.ll and srcdir/szrt_ll.ll to szrt_sb_x8632.o
79 Translate(ll_files,
80 ['-mtriple=i686-none-nacl-gnu', '-mcpu=pentium4m'],
81 '{rtdir}/szrt_sb_x8632.o'.format(rtdir=rtdir),
82 args.verbose)
83 finally:
84 try:
85 shutil.rmtree(tempdir)
86 except OSError as exc:
87 if exc.errno != errno.ENOENT: # ENOENT - no such file or directory
88 raise # re-raise exception
89
90 if __name__ == '__main__':
91 main()
OLDNEW
« no previous file with comments | « Makefile.standalone ('k') | pydir/crosstest.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698