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

Side by Side Diff: pydir/crosstest.py

Issue 2085303002: Subzero, MIPS32: Cross-testing enabled for MIPS32 (Closed) Base URL: https://chromium.googlesource.com/native_client/pnacl-subzero.git@master
Patch Set: Crosstests running Created 4 years, 4 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
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 subprocess 5 import subprocess
6 import sys 6 import sys
7 import tempfile 7 import tempfile
8 8
9 import targets 9 import targets
10 from szbuild import LinkNonsfi 10 from szbuild import LinkNonsfi
11 from utils import FindBaseNaCl, GetObjcopyCmd, get_sfi_string, shellcmd 11 from utils import FindBaseNaCl, GetObjcopyCmd, get_sfi_string, shellcmd
12 12
13 def main(): 13 def main():
14 """Builds a cross-test binary for comparing Subzero and llc translation. 14 """Builds a cross-test binary for comparing Subzero and llc translation.
15 15
16 Each --test argument is compiled once by llc and once by Subzero. C/C++ 16 Each --test argument is compiled once by llc and once by Subzero. C/C++
17 tests are first compiled down to PNaCl bitcode using pnacl-clang and 17 tests are first compiled down to PNaCl bitcode using pnacl-clang and
18 pnacl-opt. The --prefix argument ensures that symbol names are different 18 pnacl-opt. The --prefix argument ensures that symbol names are different
19 between the two object files, to avoid linking errors. 19 between the two object files, to avoid linking errors.
20 20
21 There is also a --driver argument that specifies the C/C++ file that calls 21 There is also a --driver argument that specifies the C/C++ file that calls
22 the test functions with a variety of interesting inputs and compares their 22 the test functions with a variety of interesting inputs and compares their
23 results. 23 results.
24 24
25 """ 25 """
26 # arch_map maps a Subzero target string to TargetInfo (e.g., triple). 26 # arch_map maps a Subzero target string to TargetInfo (e.g., triple).
27 arch_map = { 'x8632': targets.X8632Target, 27 arch_map = { 'x8632': targets.X8632Target,
28 'x8664': targets.X8664Target, 28 'x8664': targets.X8664Target,
29 'arm32': targets.ARM32Target } 29 'arm32': targets.ARM32Target,
30 'mips32': targets.MIPS32Target}
30 arch_sz_flags = { 'x8632': [], 31 arch_sz_flags = { 'x8632': [],
31 'x8664': [], 32 'x8664': [],
32 # For ARM, test a large stack offset as well. +/- 4095 is 33 # For ARM, test a large stack offset as well. +/- 4095 is
33 # the limit, so test somewhere near that boundary. 34 # the limit, so test somewhere near that boundary.
34 'arm32': ['--test-stack-extra', '4084'] 35 'arm32': ['--test-stack-extra', '4084'],
36 'mips32': ['--test-stack-extra', '4084']
35 } 37 }
36 arch_llc_flags_extra = { 38 arch_llc_flags_extra = {
37 # Use sse2 instructions regardless of input -mattr 39 # Use sse2 instructions regardless of input -mattr
38 # argument to avoid differences in (undefined) behavior of 40 # argument to avoid differences in (undefined) behavior of
39 # converting NaN to int. 41 # converting NaN to int.
40 'x8632': ['-mattr=sse2'], 42 'x8632': ['-mattr=sse2'],
41 'x8664': ['-mattr=sse2'], 43 'x8664': ['-mattr=sse2'],
42 'arm32': [], 44 'arm32': ['-arm-enable-dwarf-eh=1'],
45 'mips32':[],
43 } 46 }
44 desc = 'Build a cross-test that compares Subzero and llc translation.' 47 desc = 'Build a cross-test that compares Subzero and llc translation.'
45 argparser = argparse.ArgumentParser(description=desc) 48 argparser = argparse.ArgumentParser(description=desc)
46 argparser.add_argument('--test', required=True, action='append', 49 argparser.add_argument('--test', required=True, action='append',
47 metavar='TESTFILE_LIST', 50 metavar='TESTFILE_LIST',
48 help='List of C/C++/.ll files with test functions') 51 help='List of C/C++/.ll files with test functions')
49 argparser.add_argument('--driver', required=True, 52 argparser.add_argument('--driver', required=True,
50 metavar='DRIVER', 53 metavar='DRIVER',
51 help='Driver program') 54 help='Driver program')
52 argparser.add_argument('--target', required=False, default='x8632', 55 argparser.add_argument('--target', required=False, default='x8632',
53 choices=arch_map.keys(), 56 choices=arch_map.keys(),
54 metavar='TARGET', 57 metavar='TARGET',
55 help='Translation target architecture.' + 58 help='Translation target architecture.' +
56 ' Default %(default)s.') 59 ' Default %(default)s.')
57 argparser.add_argument('-O', required=False, default='2', dest='optlevel', 60 argparser.add_argument('-O', required=False, default='2', dest='optlevel',
58 choices=['m1', '-1', '0', '1', '2'], 61 choices=['m1', '-1', '0', '1', '2'],
59 metavar='OPTLEVEL', 62 metavar='OPTLEVEL',
60 help='Optimization level for llc and Subzero ' + 63 help='Optimization level for llc and Subzero ' +
61 '(m1 and -1 are equivalent).' + 64 '(m1 and -1 are equivalent).' +
62 ' Default %(default)s.') 65 ' Default %(default)s.')
63 argparser.add_argument('--clang-opt', required=False, default=True, 66 argparser.add_argument('--clang-opt', required=False, default=True,
64 dest='clang_opt') 67 dest='clang_opt')
65 argparser.add_argument('--mattr', required=False, default='sse2', 68 argparser.add_argument('--mattr', required=False, default='sse2',
66 dest='attr', choices=['sse2', 'sse4.1', 69 dest='attr', choices=['sse2', 'sse4.1',
67 'neon', 'hwdiv-arm'], 70 'neon', 'hwdiv-arm', 'base'],
68 metavar='ATTRIBUTE', 71 metavar='ATTRIBUTE',
69 help='Target attribute. Default %(default)s.') 72 help='Target attribute. Default %(default)s.')
70 argparser.add_argument('--sandbox', required=False, default=0, type=int, 73 argparser.add_argument('--sandbox', required=False, default=0, type=int,
71 dest='sandbox', 74 dest='sandbox',
72 help='Use sandboxing. Default "%(default)s".') 75 help='Use sandboxing. Default "%(default)s".')
73 argparser.add_argument('--nonsfi', required=False, default=0, type=int, 76 argparser.add_argument('--nonsfi', required=False, default=0, type=int,
74 dest='nonsfi', 77 dest='nonsfi',
75 help='Use Non-SFI mode. Default "%(default)s".') 78 help='Use Non-SFI mode. Default "%(default)s".')
76 argparser.add_argument('--prefix', required=True, 79 argparser.add_argument('--prefix', required=True,
77 metavar='SZ_PREFIX', 80 metavar='SZ_PREFIX',
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
160 163
161 # Each separately translated Subzero object file contains its own 164 # Each separately translated Subzero object file contains its own
162 # definition of the __Sz_block_profile_info profiling symbol. Avoid 165 # definition of the __Sz_block_profile_info profiling symbol. Avoid
163 # linker errors (multiply defined symbol) by making all copies weak. 166 # linker errors (multiply defined symbol) by making all copies weak.
164 # (This could also be done by Subzero if it supported weak symbol 167 # (This could also be done by Subzero if it supported weak symbol
165 # definitions.) This approach should be OK because cross tests are 168 # definitions.) This approach should be OK because cross tests are
166 # currently the only situation where multiple translated files are 169 # currently the only situation where multiple translated files are
167 # linked into the executable, but when PNaCl supports shared nexe 170 # linked into the executable, but when PNaCl supports shared nexe
168 # libraries, this would need to change. (Note: the same issue applies 171 # libraries, this would need to change. (Note: the same issue applies
169 # to the __Sz_revision symbol.) 172 # to the __Sz_revision symbol.)
170 shellcmd(['{bin}/{objcopy}'.format(bin=bindir, objcopy=GetObjcopyCmd()), 173 shellcmd(['{bin}/{objcopy}'.format(bin=bindir, objcopy=GetObjcopyCmd(arg s.target)),
Jim Stichnoth 2016/08/23 14:56:49 80-col
obucinac 2016/09/05 16:55:59 Done.
171 '--weaken-symbol=__Sz_block_profile_info', 174 '--weaken-symbol=__Sz_block_profile_info',
172 '--weaken-symbol=__Sz_revision', 175 '--weaken-symbol=__Sz_revision',
173 '--strip-symbol=nacl_tp_tdb_offset', 176 '--strip-symbol=nacl_tp_tdb_offset',
174 '--strip-symbol=nacl_tp_tls_offset', 177 '--strip-symbol=nacl_tp_tls_offset',
175 obj_sz]) 178 obj_sz])
176 objs.append(obj_sz) 179 objs.append(obj_sz)
177 shellcmd(['{bin}/pnacl-llc'.format(bin=bindir), 180 shellcmd(['{bin}/pnacl-llc'.format(bin=bindir),
178 '-arm-enable-dwarf-eh=1',
179 '-mtriple=' + triple, 181 '-mtriple=' + triple,
180 '-externalize', 182 '-externalize',
181 '-filetype=obj', 183 '-filetype=obj',
182 '-bitcode-format=llvm', 184 '-bitcode-format=llvm',
183 '-o=' + obj_llc, 185 '-o=' + obj_llc,
184 bitcode] + llc_flags) 186 bitcode] + llc_flags)
185 shellcmd(['{bin}/{objcopy}'.format(bin=bindir, objcopy=GetObjcopyCmd()), 187 shellcmd(['{bin}/{objcopy}'.format(bin=bindir, objcopy=GetObjcopyCmd(arg s.target)),
Jim Stichnoth 2016/08/23 14:56:49 80-col
obucinac 2016/09/05 16:55:59 Done.
186 '--strip-symbol=nacl_tp_tdb_offset',
187 '--strip-symbol=nacl_tp_tls_offset',
188 obj_llc]) 188 obj_llc])
189 objs.append(obj_llc) 189 objs.append(obj_llc)
190 190
191 # Add szrt_sb_${target}.o or szrt_native_${target}.o. 191 # Add szrt_sb_${target}.o or szrt_native_${target}.o.
192 if not args.nonsfi: 192 if not args.nonsfi:
193 objs.append(( 193 objs.append((
194 '{root}/toolchain_build/src/subzero/build/runtime/' + 194 '{root}/toolchain_build/src/subzero/build/runtime/' +
195 'szrt_{sb}_' + args.target + '.o' 195 'szrt_{sb}_' + args.target + '.o'
196 ).format(root=nacl_root, 196 ).format(root=nacl_root,
197 sb=get_sfi_string(args, 'sb', 'nonsfi', 'native'))) 197 sb=get_sfi_string(args, 'sb', 'nonsfi', 'native')))
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
237 shellcmd(['{bin}/pnacl-opt'.format(bin=bindir), 237 shellcmd(['{bin}/pnacl-opt'.format(bin=bindir),
238 '-pnacl-abi-simplify-preopt', 238 '-pnacl-abi-simplify-preopt',
239 '-pnacl-abi-simplify-postopt', 239 '-pnacl-abi-simplify-postopt',
240 '-pnaclabi-allow-debug-metadata', 240 '-pnaclabi-allow-debug-metadata',
241 '-strip-metadata', 241 '-strip-metadata',
242 '-strip-module-flags', 242 '-strip-module-flags',
243 '-strip-debug', 243 '-strip-debug',
244 '-disable-opt', 244 '-disable-opt',
245 bitcode_nonfinal, '-S', '-o', bitcode]) 245 bitcode_nonfinal, '-S', '-o', bitcode])
246 shellcmd(['{bin}/pnacl-llc'.format(bin=bindir), 246 shellcmd(['{bin}/pnacl-llc'.format(bin=bindir),
247 '-arm-enable-dwarf-eh=1',
248 '-mtriple=' + triple, 247 '-mtriple=' + triple,
249 '-externalize', 248 '-externalize',
250 '-filetype=obj', 249 '-filetype=obj',
251 '-O2', 250 '-O2',
252 '-bitcode-format=llvm', 251 '-bitcode-format=llvm',
253 '-o', obj_llc, 252 '-o', obj_llc,
254 bitcode] + llc_flags) 253 bitcode] + llc_flags)
255 if not args.sandbox and not args.nonsfi: 254 if not args.sandbox and not args.nonsfi:
256 shellcmd(['{bin}/{objcopy}'.format(bin=bindir, objcopy=GetObjcopyCmd()), 255 shellcmd(['{bin}/{objcopy}'.format(bin=bindir, objcopy=GetObjcopyCmd(arg s.target)),
Jim Stichnoth 2016/08/23 14:56:49 80-col
obucinac 2016/09/05 16:55:59 Done.
257 '--redefine-sym', '_start=_user_start', 256 '--redefine-sym', '_start=_user_start',
258 obj_llc 257 obj_llc
259 ]) 258 ])
260 objs.append(obj_llc) 259 objs.append(obj_llc)
261 if args.nonsfi: 260 if args.nonsfi:
262 LinkNonsfi(objs, os.path.join(args.dir, args.output), args.target) 261 LinkNonsfi(objs, os.path.join(args.dir, args.output), args.target)
263 elif args.sandbox: 262 elif args.sandbox:
264 LinkSandbox(objs, os.path.join(args.dir, args.output), args.target) 263 LinkSandbox(objs, os.path.join(args.dir, args.output), args.target)
265 else: 264 else:
266 LinkNative(objs, os.path.join(args.dir, args.output), args.target) 265 LinkNative(objs, os.path.join(args.dir, args.output), args.target)
267 266
268 if __name__ == '__main__': 267 if __name__ == '__main__':
269 main() 268 main()
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698