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

Side by Side Diff: pydir/crosstest.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 | « pydir/build-runtime.py ('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 re 5 import re
6 import subprocess 6 import subprocess
7 import sys 7 import sys
8 import tempfile 8 import tempfile
9 9
10 from utils import shellcmd 10 from utils import shellcmd
11 from utils import FindBaseNaCl 11 from utils import FindBaseNaCl
12 12
13 if __name__ == '__main__': 13 if __name__ == '__main__':
14 """Builds a cross-test binary that allows functions translated by 14 """Builds a cross-test binary that allows functions translated by
15 Subzero and llc to be compared. 15 Subzero and llc to be compared.
16 16
17 Each --test argument is compiled once by llc and once by Subzero. 17 Each --test argument is compiled once by llc and once by Subzero.
18 C/C++ tests are first compiled down to PNaCl bitcode by the 18 C/C++ tests are first compiled down to PNaCl bitcode by the
19 build-pnacl-ir.py script. The --prefix argument ensures that 19 build-pnacl-ir.py script. The --prefix argument ensures that
20 symbol names are different between the two object files, to avoid 20 symbol names are different between the two object files, to avoid
21 linking errors. 21 linking errors.
22 22
23 There is also a --driver argument that specifies the C/C++ file 23 There is also a --driver argument that specifies the C/C++ file
24 that calls the test functions with a variety of interesting inputs 24 that calls the test functions with a variety of interesting inputs
25 and compares their results. 25 and compares their results.
26 """ 26 """
27 # arch_map maps a Subzero target string to an llvm-mc -arch string. 27 # arch_map maps a Subzero target string to an llvm-mc -triple string.
28 arch_map = { 'x8632':'x86', 'x8664':'x86-64', 'arm':'arm' } 28 arch_map = { 'x8632':'i686', 'x8664':'x86_64', 'arm':'armv7a' }
29 desc = 'Build a cross-test that compares Subzero and llc translation.' 29 desc = 'Build a cross-test that compares Subzero and llc translation.'
30 argparser = argparse.ArgumentParser(description=desc) 30 argparser = argparse.ArgumentParser(description=desc)
31 argparser.add_argument('--test', required=True, action='append', 31 argparser.add_argument('--test', required=True, action='append',
32 metavar='TESTFILE_LIST', 32 metavar='TESTFILE_LIST',
33 help='List of C/C++/.ll files with test functions') 33 help='List of C/C++/.ll files with test functions')
34 argparser.add_argument('--driver', required=True, 34 argparser.add_argument('--driver', required=True,
35 metavar='DRIVER', 35 metavar='DRIVER',
36 help='Driver program') 36 help='Driver program')
37 argparser.add_argument('--target', required=False, default='x8632', 37 argparser.add_argument('--target', required=False, default='x8632',
38 choices=arch_map.keys(), 38 choices=arch_map.keys(),
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
106 '-O' + args.optlevel, 106 '-O' + args.optlevel,
107 '-mattr=' + args.attr, 107 '-mattr=' + args.attr,
108 '--target=' + args.target, 108 '--target=' + args.target,
109 '--prefix=' + args.prefix, 109 '--prefix=' + args.prefix,
110 '-allow-uninitialized-globals', 110 '-allow-uninitialized-globals',
111 '-filetype=' + args.filetype, 111 '-filetype=' + args.filetype,
112 '-o=' + (obj_sz if args.filetype == 'obj' else asm_sz), 112 '-o=' + (obj_sz if args.filetype == 'obj' else asm_sz),
113 bitcode]) 113 bitcode])
114 if args.filetype != 'obj': 114 if args.filetype != 'obj':
115 shellcmd(['llvm-mc', 115 shellcmd(['llvm-mc',
116 '-arch=' + arch_map[args.target], 116 '-triple=' + arch_map[args.target],
117 '-filetype=obj', 117 '-filetype=obj',
118 '-o=' + obj_sz, 118 '-o=' + obj_sz,
119 asm_sz]) 119 asm_sz])
120 objs.append(obj_sz) 120 objs.append(obj_sz)
121 # Each original bitcode file needs to be translated by the 121 # Each original bitcode file needs to be translated by the
122 # LLVM toolchain and have its object file linked in. There 122 # LLVM toolchain and have its object file linked in. There
123 # are two ways to do this: explicitly use llc, or include the 123 # are two ways to do this: explicitly use llc, or include the
124 # .ll file in the link command. It turns out that these two 124 # .ll file in the link command. It turns out that these two
125 # approaches can produce different semantics on some undefined 125 # approaches can produce different semantics on some undefined
126 # bitcode behavior. Specifically, LLVM produces different 126 # bitcode behavior. Specifically, LLVM produces different
(...skipping 10 matching lines...) Expand all
137 objs.append(arg) 137 objs.append(arg)
138 elif use_llc: 138 elif use_llc:
139 shellcmd(['llc' 139 shellcmd(['llc'
140 '-filetype=obj', 140 '-filetype=obj',
141 '-o=' + obj_llc, 141 '-o=' + obj_llc,
142 bitcode]) 142 bitcode])
143 objs.append(obj_llc) 143 objs.append(obj_llc)
144 else: 144 else:
145 objs.append(bitcode) 145 objs.append(bitcode)
146 146
147 # Use 'clang szrt.c' -or- 'clang++ szrt.cpp'
148 objs.append(( 147 objs.append((
149 '{root}/toolchain_build/src/subzero/runtime/szrt.{ext}' 148 '{root}/toolchain_build/src/subzero/build/runtime/' +
150 ).format(root=nacl_root, ext='c' if pure_c else 'cpp')) 149 'szrt_native_x8632.o'
151 objs.append((
152 '{root}/toolchain_build/src/subzero/runtime/szrt_i686.ll'
153 ).format(root=nacl_root)) 150 ).format(root=nacl_root))
154 linker = 'clang' if pure_c else 'clang++' 151 linker = 'clang' if pure_c else 'clang++'
155 shellcmd([linker, '-g', '-m32', args.driver] + 152 shellcmd([linker, '-g', '-m32', args.driver] +
156 objs + 153 objs +
157 ['-lm', '-lpthread', '-o', os.path.join(args.dir, args.output)]) 154 ['-lm', '-lpthread', '-o', os.path.join(args.dir, args.output)])
OLDNEW
« no previous file with comments | « pydir/build-runtime.py ('k') | pydir/szbuild.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698