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

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: Fixing accidentaly removed parameters Created 4 years, 3 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': [],
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',
71 'base'],
68 metavar='ATTRIBUTE', 72 metavar='ATTRIBUTE',
69 help='Target attribute. Default %(default)s.') 73 help='Target attribute. Default %(default)s.')
70 argparser.add_argument('--sandbox', required=False, default=0, type=int, 74 argparser.add_argument('--sandbox', required=False, default=0, type=int,
71 dest='sandbox', 75 dest='sandbox',
72 help='Use sandboxing. Default "%(default)s".') 76 help='Use sandboxing. Default "%(default)s".')
73 argparser.add_argument('--nonsfi', required=False, default=0, type=int, 77 argparser.add_argument('--nonsfi', required=False, default=0, type=int,
74 dest='nonsfi', 78 dest='nonsfi',
75 help='Use Non-SFI mode. Default "%(default)s".') 79 help='Use Non-SFI mode. Default "%(default)s".')
76 argparser.add_argument('--prefix', required=True, 80 argparser.add_argument('--prefix', required=True,
77 metavar='SZ_PREFIX', 81 metavar='SZ_PREFIX',
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
160 164
161 # Each separately translated Subzero object file contains its own 165 # Each separately translated Subzero object file contains its own
162 # definition of the __Sz_block_profile_info profiling symbol. Avoid 166 # definition of the __Sz_block_profile_info profiling symbol. Avoid
163 # linker errors (multiply defined symbol) by making all copies weak. 167 # linker errors (multiply defined symbol) by making all copies weak.
164 # (This could also be done by Subzero if it supported weak symbol 168 # (This could also be done by Subzero if it supported weak symbol
165 # definitions.) This approach should be OK because cross tests are 169 # definitions.) This approach should be OK because cross tests are
166 # currently the only situation where multiple translated files are 170 # currently the only situation where multiple translated files are
167 # linked into the executable, but when PNaCl supports shared nexe 171 # linked into the executable, but when PNaCl supports shared nexe
168 # libraries, this would need to change. (Note: the same issue applies 172 # libraries, this would need to change. (Note: the same issue applies
169 # to the __Sz_revision symbol.) 173 # to the __Sz_revision symbol.)
170 shellcmd(['{bin}/{objcopy}'.format(bin=bindir, objcopy=GetObjcopyCmd()), 174 shellcmd(['{bin}/{objcopy}'.format(bin=bindir,
175 objcopy=GetObjcopyCmd(args.target)),
171 '--weaken-symbol=__Sz_block_profile_info', 176 '--weaken-symbol=__Sz_block_profile_info',
172 '--weaken-symbol=__Sz_revision', 177 '--weaken-symbol=__Sz_revision',
173 '--strip-symbol=nacl_tp_tdb_offset', 178 '--strip-symbol=nacl_tp_tdb_offset',
174 '--strip-symbol=nacl_tp_tls_offset', 179 '--strip-symbol=nacl_tp_tls_offset',
175 obj_sz]) 180 obj_sz])
176 objs.append(obj_sz) 181 objs.append(obj_sz)
177 shellcmd(['{bin}/pnacl-llc'.format(bin=bindir), 182 shellcmd(['{bin}/pnacl-llc'.format(bin=bindir),
178 '-arm-enable-dwarf-eh=1',
179 '-mtriple=' + triple, 183 '-mtriple=' + triple,
180 '-externalize', 184 '-externalize',
181 '-filetype=obj', 185 '-filetype=obj',
182 '-bitcode-format=llvm', 186 '-bitcode-format=llvm',
183 '-o=' + obj_llc, 187 '-o=' + obj_llc,
184 bitcode] + llc_flags) 188 bitcode] + llc_flags)
185 shellcmd(['{bin}/{objcopy}'.format(bin=bindir, objcopy=GetObjcopyCmd()), 189 strip_syms = []
Jim Stichnoth 2016/09/23 05:29:11 strip_syms = [] if args.target == 'mips32' else [
obucinac 2016/09/23 13:22:03 Done.
186 '--strip-symbol=nacl_tp_tdb_offset', 190 if args.target != 'mips32':
187 '--strip-symbol=nacl_tp_tls_offset', 191 strip_syms += ['nacl_tp_tdb_offset', 'nacl_tp_tls_offset']
188 obj_llc]) 192 shellcmd(['{bin}/{objcopy}'.format(bin=bindir,
193 objcopy=GetObjcopyCmd(args.target)),
194 obj_llc] +
195 [('--strip-symbol=' + sym) for sym in strip_syms])
189 objs.append(obj_llc) 196 objs.append(obj_llc)
190 197
191 # Add szrt_sb_${target}.o or szrt_native_${target}.o. 198 # Add szrt_sb_${target}.o or szrt_native_${target}.o.
192 if not args.nonsfi: 199 if not args.nonsfi:
193 objs.append(( 200 objs.append((
194 '{root}/toolchain_build/src/subzero/build/runtime/' + 201 '{root}/toolchain_build/src/subzero/build/runtime/' +
195 'szrt_{sb}_' + args.target + '.o' 202 'szrt_{sb}_' + args.target + '.o'
196 ).format(root=nacl_root, 203 ).format(root=nacl_root,
197 sb=get_sfi_string(args, 'sb', 'nonsfi', 'native'))) 204 sb=get_sfi_string(args, 'sb', 'nonsfi', 'native')))
198 205
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
237 shellcmd(['{bin}/pnacl-opt'.format(bin=bindir), 244 shellcmd(['{bin}/pnacl-opt'.format(bin=bindir),
238 '-pnacl-abi-simplify-preopt', 245 '-pnacl-abi-simplify-preopt',
239 '-pnacl-abi-simplify-postopt', 246 '-pnacl-abi-simplify-postopt',
240 '-pnaclabi-allow-debug-metadata', 247 '-pnaclabi-allow-debug-metadata',
241 '-strip-metadata', 248 '-strip-metadata',
242 '-strip-module-flags', 249 '-strip-module-flags',
243 '-strip-debug', 250 '-strip-debug',
244 '-disable-opt', 251 '-disable-opt',
245 bitcode_nonfinal, '-S', '-o', bitcode]) 252 bitcode_nonfinal, '-S', '-o', bitcode])
246 shellcmd(['{bin}/pnacl-llc'.format(bin=bindir), 253 shellcmd(['{bin}/pnacl-llc'.format(bin=bindir),
247 '-arm-enable-dwarf-eh=1',
248 '-mtriple=' + triple, 254 '-mtriple=' + triple,
249 '-externalize', 255 '-externalize',
250 '-filetype=obj', 256 '-filetype=obj',
251 '-O2', 257 '-O2',
252 '-bitcode-format=llvm', 258 '-bitcode-format=llvm',
253 '-o', obj_llc, 259 '-o', obj_llc,
254 bitcode] + llc_flags) 260 bitcode] + llc_flags)
255 if not args.sandbox and not args.nonsfi: 261 if not args.sandbox and not args.nonsfi:
256 shellcmd(['{bin}/{objcopy}'.format(bin=bindir, objcopy=GetObjcopyCmd()), 262 shellcmd(['{bin}/{objcopy}'.format(bin=bindir,
263 objcopy=GetObjcopyCmd(args.target)),
257 '--redefine-sym', '_start=_user_start', 264 '--redefine-sym', '_start=_user_start',
258 obj_llc 265 obj_llc
259 ]) 266 ])
260 objs.append(obj_llc) 267 objs.append(obj_llc)
261 if args.nonsfi: 268 if args.nonsfi:
262 LinkNonsfi(objs, os.path.join(args.dir, args.output), args.target) 269 LinkNonsfi(objs, os.path.join(args.dir, args.output), args.target)
263 elif args.sandbox: 270 elif args.sandbox:
264 LinkSandbox(objs, os.path.join(args.dir, args.output), args.target) 271 LinkSandbox(objs, os.path.join(args.dir, args.output), args.target)
265 else: 272 else:
266 LinkNative(objs, os.path.join(args.dir, args.output), args.target) 273 LinkNative(objs, os.path.join(args.dir, args.output), args.target)
267 274
268 if __name__ == '__main__': 275 if __name__ == '__main__':
269 main() 276 main()
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698