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

Side by Side Diff: crosstest/crosstest.py

Issue 525603002: Subzero: Remove the need for a separate NaCl SDK. (Closed) Base URL: https://chromium.googlesource.com/native_client/pnacl-subzero.git@master
Patch Set: Remove LLVM_BIN_PATH from crosstests run. Add llvm-as. Created 6 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 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 sys.path.insert(0, '../pydir') 10 sys.path.insert(0, '../pydir')
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
48 metavar='ATTRIBUTE', help='Target attribute') 48 metavar='ATTRIBUTE', help='Target attribute')
49 argparser.add_argument('--prefix', required=True, 49 argparser.add_argument('--prefix', required=True,
50 metavar='SZ_PREFIX', 50 metavar='SZ_PREFIX',
51 help='String prepended to Subzero symbol names') 51 help='String prepended to Subzero symbol names')
52 argparser.add_argument('--output', '-o', required=True, 52 argparser.add_argument('--output', '-o', required=True,
53 metavar='EXECUTABLE', 53 metavar='EXECUTABLE',
54 help='Executable to produce') 54 help='Executable to produce')
55 argparser.add_argument('--dir', required=False, default='.', 55 argparser.add_argument('--dir', required=False, default='.',
56 metavar='OUTPUT_DIR', 56 metavar='OUTPUT_DIR',
57 help='Output directory for all files') 57 help='Output directory for all files')
58 argparser.add_argument('--llvm-bin-path', required=False,
59 default=os.environ.get('LLVM_BIN_PATH'),
60 metavar='PATH',
61 help='Path to LLVM executables like llc ' +
62 '(defaults to $LLVM_BIN_PATH)')
63 argparser.add_argument('--crosstest-bitcode', required=False, 58 argparser.add_argument('--crosstest-bitcode', required=False,
64 default=1, type=int, 59 default=1, type=int,
65 help='Compile non-subzero crosstest object file ' + 60 help='Compile non-subzero crosstest object file ' +
66 'from the same bitcode as the subzero object. ' + 61 'from the same bitcode as the subzero object. ' +
67 'If 0, then compile it straight from source.') 62 'If 0, then compile it straight from source.')
68 args = argparser.parse_args() 63 args = argparser.parse_args()
69 64
65 # TODO(stichnot): Find a better way of getting to the top-level
66 # native_client directory.
67 nacl_root = '../../../..'
68 # Prepend host_x86_32/bin to $PATH.
69 os.environ['PATH'] = nacl_root + \
70 '/toolchain/linux_x86/pnacl_newlib/host_x86_32/bin' + \
71 os.pathsep + os.environ['PATH']
72
70 objs = [] 73 objs = []
71 remove_internal = re.compile('^define internal ') 74 remove_internal = re.compile('^define internal ')
72 fix_target = re.compile('le32-unknown-nacl') 75 fix_target = re.compile('le32-unknown-nacl')
73 llvm_bin_path = args.llvm_bin_path
74 for arg in args.test: 76 for arg in args.test:
75 base, ext = os.path.splitext(arg) 77 base, ext = os.path.splitext(arg)
76 if ext == '.ll': 78 if ext == '.ll':
77 bitcode = arg 79 bitcode = arg
78 else: 80 else:
79 bitcode = os.path.join(args.dir, base + '.pnacl.ll') 81 bitcode = os.path.join(args.dir, base + '.pnacl.ll')
80 shellcmd(['../pydir/build-pnacl-ir.py', '--disable-verify', 82 shellcmd(['../pydir/build-pnacl-ir.py', '--disable-verify',
81 '--dir', args.dir, arg]) 83 '--dir', args.dir, arg])
82 # Read in the bitcode file, fix it up, and rewrite the file. 84 # Read in the bitcode file, fix it up, and rewrite the file.
83 f = open(bitcode) 85 f = open(bitcode)
(...skipping 10 matching lines...) Expand all
94 asm_sz = os.path.join(args.dir, base_sz + '.sz.s') 96 asm_sz = os.path.join(args.dir, base_sz + '.sz.s')
95 obj_sz = os.path.join(args.dir, base_sz + '.sz.o') 97 obj_sz = os.path.join(args.dir, base_sz + '.sz.o')
96 obj_llc = os.path.join(args.dir, base + '.llc.o') 98 obj_llc = os.path.join(args.dir, base + '.llc.o')
97 shellcmd(['../llvm2ice', 99 shellcmd(['../llvm2ice',
98 '-O' + args.optlevel, 100 '-O' + args.optlevel,
99 '-mattr=' + args.attr, 101 '-mattr=' + args.attr,
100 '--target=' + args.target, 102 '--target=' + args.target,
101 '--prefix=' + args.prefix, 103 '--prefix=' + args.prefix,
102 '-o=' + asm_sz, 104 '-o=' + asm_sz,
103 bitcode]) 105 bitcode])
104 shellcmd([os.path.join(llvm_bin_path, 'llvm-mc'), 106 shellcmd(['llvm-mc',
105 '-arch=' + arch_map[args.target], 107 '-arch=' + arch_map[args.target],
106 '-x86-asm-syntax=intel', 108 '-x86-asm-syntax=intel',
107 '-filetype=obj', 109 '-filetype=obj',
108 '-o=' + obj_sz, 110 '-o=' + obj_sz,
109 asm_sz]) 111 asm_sz])
110 objs.append(obj_sz) 112 objs.append(obj_sz)
111 # Each original bitcode file needs to be translated by the 113 # Each original bitcode file needs to be translated by the
112 # LLVM toolchain and have its object file linked in. There 114 # LLVM toolchain and have its object file linked in. There
113 # are two ways to do this: explicitly use llc, or include the 115 # are two ways to do this: explicitly use llc, or include the
114 # .ll file in the link command. It turns out that these two 116 # .ll file in the link command. It turns out that these two
115 # approaches can produce different semantics on some undefined 117 # approaches can produce different semantics on some undefined
116 # bitcode behavior. Specifically, LLVM produces different 118 # bitcode behavior. Specifically, LLVM produces different
117 # results for overflowing fptoui instructions for i32 and i64 119 # results for overflowing fptoui instructions for i32 and i64
118 # on x86-32. As it turns out, Subzero lowering was based on 120 # on x86-32. As it turns out, Subzero lowering was based on
119 # inspecting the object code produced by the direct llc 121 # inspecting the object code produced by the direct llc
120 # command, so we need to directly run llc on the bitcode, even 122 # command, so we need to directly run llc on the bitcode, even
121 # though it makes this script longer, to avoid spurious 123 # though it makes this script longer, to avoid spurious
122 # failures. This behavior can be inspected by switching 124 # failures. This behavior can be inspected by switching
123 # use_llc between True and False. 125 # use_llc between True and False.
124 use_llc = False 126 use_llc = False
125 if not args.crosstest_bitcode: 127 if not args.crosstest_bitcode:
126 objs.append(arg) 128 objs.append(arg)
127 elif use_llc: 129 elif use_llc:
128 shellcmd([os.path.join(llvm_bin_path, 'llc'), 130 shellcmd(['llc'
129 '-filetype=obj', 131 '-filetype=obj',
130 '-o=' + obj_llc, 132 '-o=' + obj_llc,
131 bitcode]) 133 bitcode])
132 objs.append(obj_llc) 134 objs.append(obj_llc)
133 else: 135 else:
134 objs.append(bitcode) 136 objs.append(bitcode)
135 137
136 linker = 'clang' if os.path.splitext(args.driver)[1] == '.c' else 'clang++' 138 linker = 'clang' if os.path.splitext(args.driver)[1] == '.c' else 'clang++'
137 shellcmd([os.path.join(llvm_bin_path, linker), '-g', '-m32', args.driver] + 139 shellcmd([linker, '-g', '-m32', args.driver] +
138 objs + 140 objs +
139 ['-lm', '-lpthread', '-o', os.path.join(args.dir, args.output)]) 141 ['-lm', '-lpthread', '-o', os.path.join(args.dir, args.output)])
OLDNEW
« no previous file with comments | « Makefile.standalone ('k') | crosstest/runtests.sh » ('j') | pydir/build-pnacl-ir.py » ('J')

Powered by Google App Engine
This is Rietveld 408576698