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

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: Code review changes. Undo the lock-prefix sandboxing workaround. 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
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 os.makedirs(rtdir)
53 # Compile srcdir/szrt.c to tempdir/szrt.ll
54 shellcmd(['pnacl-clang',
55 '-O2',
56 '-c',
57 '{srcdir}/szrt.c'.format(srcdir=srcdir),
58 '-o', '{dir}/szrt.tmp.bc'.format(dir=tempdir)
59 ], echo=args.verbose)
60 shellcmd(['pnacl-opt',
61 '-pnacl-abi-simplify-preopt',
62 '-pnacl-abi-simplify-postopt',
63 '-pnaclabi-allow-debug-metadata',
64 '{dir}/szrt.tmp.bc'.format(dir=tempdir),
65 '-S',
66 '-o', '{dir}/szrt.ll'.format(dir=tempdir)
67 ], echo=args.verbose)
68 ll_files = ['{dir}/szrt.ll'.format(dir=tempdir),
69 '{srcdir}/szrt_ll.ll'.format(srcdir=srcdir)]
70 # Translate tempdir/szrt.ll and srcdir/szrt_ll.ll to szrt_native_x8632.o
71 Translate(ll_files,
72 ['-mtriple=i386-unknown-linux-gnu', '-mcpu=pentium4m'],
73 '{rtdir}/szrt_native_x8632.o'.format(rtdir=rtdir),
74 args.verbose)
75 # Translate tempdir/szrt.ll and srcdir/szrt_ll.ll to szrt_sb_x8632.o
76 Translate(ll_files,
77 ['-mtriple=i686-none-nacl-gnu', '-mcpu=pentium4m'],
78 '{rtdir}/szrt_sb_x8632.o'.format(rtdir=rtdir),
79 args.verbose)
80 finally:
81 try:
82 shutil.rmtree(tempdir)
83 except OSError as exc:
84 if exc.errno != errno.ENOENT: # ENOENT - no such file or directory
85 raise # re-raise exception
86
87 if __name__ == '__main__':
88 main()
OLDNEW
« no previous file with comments | « Makefile.standalone ('k') | pydir/crosstest.py » ('j') | pydir/crosstest.py » ('J')

Powered by Google App Engine
This is Rietveld 408576698