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

Side by Side Diff: pydir/crosstest.py

Issue 1537703002: Subzero. x8664. Resurrects the Target. (Closed) Base URL: https://chromium.googlesource.com/native_client/pnacl-subzero.git@master
Patch Set: Beautifies the assembler. Created 5 years 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 utils import shellcmd 10 from utils import shellcmd
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
128 shellcmd(['{bin}/pnacl-opt'.format(bin=bindir), 128 shellcmd(['{bin}/pnacl-opt'.format(bin=bindir),
129 '-pnacl-abi-simplify-preopt', 129 '-pnacl-abi-simplify-preopt',
130 '-pnacl-abi-simplify-postopt', 130 '-pnacl-abi-simplify-postopt',
131 '-pnaclabi-allow-debug-metadata', 131 '-pnaclabi-allow-debug-metadata',
132 bitcode_nonfinal, '-S', '-o', bitcode]) 132 bitcode_nonfinal, '-S', '-o', bitcode])
133 133
134 base_sz = '{base}.{key}'.format(base=base, key=key) 134 base_sz = '{base}.{key}'.format(base=base, key=key)
135 asm_sz = os.path.join(args.dir, base_sz + '.sz.s') 135 asm_sz = os.path.join(args.dir, base_sz + '.sz.s')
136 obj_sz = os.path.join(args.dir, base_sz + '.sz.o') 136 obj_sz = os.path.join(args.dir, base_sz + '.sz.o')
137 obj_llc = os.path.join(args.dir, base_sz + '.llc.o') 137 obj_llc = os.path.join(args.dir, base_sz + '.llc.o')
138
138 shellcmd(['{path}/pnacl-sz'.format(path=os.path.dirname(mypath)), 139 shellcmd(['{path}/pnacl-sz'.format(path=os.path.dirname(mypath)),
139 ] + args.sz_args + [ 140 ] + args.sz_args + [
140 '-O' + args.optlevel, 141 '-O' + args.optlevel,
141 '-mattr=' + args.attr, 142 '-mattr=' + args.attr,
142 '--target=' + args.target, 143 '--target=' + args.target,
143 '--sandbox=' + str(args.sandbox), 144 '--sandbox=' + str(args.sandbox),
144 '--prefix=' + args.prefix, 145 '--prefix=' + args.prefix,
145 '-allow-uninitialized-globals', 146 '-allow-uninitialized-globals',
146 '-externalize', 147 '-externalize',
147 '-filetype=' + args.filetype, 148 '-filetype=' + args.filetype,
148 '-o=' + (obj_sz if args.filetype == 'obj' else asm_sz), 149 '-o=' + (obj_sz if args.filetype == 'obj' else asm_sz),
149 bitcode] + arch_sz_flags[args.target]) 150 bitcode] + arch_sz_flags[args.target])
150 if args.filetype != 'obj': 151 if args.filetype != 'obj':
151 shellcmd(['{bin}/llvm-mc'.format(bin=bindir), 152 shellcmd(['{bin}/llvm-mc'.format(bin=bindir),
152 '-triple=' + triple, 153 '-triple=' + triple,
153 '-filetype=obj', 154 '-filetype=obj',
154 '-o=' + obj_sz, 155 '-o=' + obj_sz,
155 asm_sz]) 156 asm_sz])
157
156 # Each separately translated Subzero object file contains its own 158 # Each separately translated Subzero object file contains its own
157 # definition of the __Sz_block_profile_info profiling symbol. Avoid 159 # definition of the __Sz_block_profile_info profiling symbol. Avoid
158 # linker errors (multiply defined symbol) by making all copies weak. 160 # linker errors (multiply defined symbol) by making all copies weak.
159 # (This could also be done by Subzero if it supported weak symbol 161 # (This could also be done by Subzero if it supported weak symbol
160 # definitions.) This approach should be OK because cross tests are 162 # definitions.) This approach should be OK because cross tests are
161 # currently the only situation where multiple translated files are 163 # currently the only situation where multiple translated files are
162 # linked into the executable, but when PNaCl supports shared nexe 164 # linked into the executable, but when PNaCl supports shared nexe
163 # libraries, this would need to change. 165 # libraries, this would need to change.
164 shellcmd(['{bin}/le32-nacl-objcopy'.format(bin=bindir), 166 shellcmd(['{bin}/le32-nacl-objcopy'.format(bin=bindir),
165 '--weaken-symbol=__Sz_block_profile_info', obj_sz]) 167 '--weaken-symbol=__Sz_block_profile_info', obj_sz])
166 objs.append(obj_sz) 168 objs.append(obj_sz)
167 if args.crosstest_bitcode: 169 if args.crosstest_bitcode:
168 shellcmd(['{bin}/pnacl-llc'.format(bin=bindir), 170 shellcmd(['{bin}/pnacl-llc'.format(bin=bindir),
169 '-mtriple=' + triple, 171 '-mtriple=' + triple,
170 '-externalize', 172 '-externalize',
171 '-filetype=obj', 173 '-filetype=obj',
172 '-o=' + obj_llc, 174 '-o=' + obj_llc,
173 bitcode] + llc_flags) 175 bitcode] + llc_flags)
174 objs.append(obj_llc) 176 objs.append(obj_llc)
175 else: 177 else:
176 objs.append(arg) 178 objs.append(arg)
177 179
178 # Add szrt_sb_${target}.o or szrt_native_${target}.o. 180 # Add szrt_sb_${target}.o or szrt_native_${target}.o.
179 objs.append(( 181 objs.append((
180 '{root}/toolchain_build/src/subzero/build/runtime/' + 182 '{root}/toolchain_build/src/subzero/build/runtime/' +
181 'szrt_{sb}_' + args.target + '.o' 183 'szrt_{sb}_' + args.target + '.o'
182 ).format(root=nacl_root, sb='sb' if args.sandbox else 'native')) 184 ).format(root=nacl_root, sb='sb' if args.sandbox else 'native'))
183 pure_c = os.path.splitext(args.driver)[1] == '.c' 185 pure_c = os.path.splitext(args.driver)[1] == '.c'
184 186
185 # TargetX8664 is ilp32, but pnacl-clang does not currently support such 187 # TODO(jpp): clean up stack hack related code.
186 # configuration. In order to run the crosstests we play nasty, dangerous 188 needs_stack_hack = False
187 # tricks with the stack pointer.
188 needs_stack_hack = (args.target == 'x8664')
189 target_params = [] 189 target_params = []
190 if needs_stack_hack: 190 if needs_stack_hack:
191 shellcmd('{bin}/clang -g -o stack_hack.x8664.{key}.o -c ' 191 shellcmd('{bin}/clang -g -o stack_hack.x8664.{key}.o -c '
192 'stack_hack.x8664.c'.format(bin=bindir, key=key)) 192 'stack_hack.x8664.c'.format(bin=bindir, key=key))
193 target_params.append('-DX8664_STACK_HACK') 193 target_params.append('-DX8664_STACK_HACK')
194 target_params.append('stack_hack.x8664.{key}.o'.format(key=key)) 194 target_params.append('stack_hack.x8664.{key}.o'.format(key=key))
195 195
196 if args.target == 'arm32': 196 if args.target == 'arm32':
197 target_params.append('-DARM32') 197 target_params.append('-DARM32')
198 target_params.append('-static') 198 target_params.append('-static')
199 199
200 # Set compiler to clang, clang++, pnacl-clang, or pnacl-clang++. 200 # Set compiler to clang, clang++, pnacl-clang, or pnacl-clang++.
201 compiler = '{bin}/{prefix}{cc}'.format( 201 compiler = '{bin}/{prefix}{cc}'.format(
202 bin=bindir, prefix='pnacl-' if args.sandbox else '', 202 bin=bindir, prefix='pnacl-' if args.sandbox else '',
203 cc='clang' if pure_c else 'clang++') 203 cc='clang' if pure_c else 'clang++')
204 sb_native_args = (['-O0', '--pnacl-allow-native', 204 sb_native_args = (['-O0', '--pnacl-allow-native',
205 '-arch', target_info.compiler_arch, 205 '-arch', target_info.compiler_arch,
206 '-Wn,-defsym=__Sz_AbsoluteZero=0'] 206 '-Wn,-defsym=__Sz_AbsoluteZero=0']
207 if args.sandbox else 207 if args.sandbox else
208 ['-g', '-target=' + triple, 208 ['-g', '-target=' + triple,
209 '-lm', '-lpthread', 209 '-lm', '-lpthread',
210 '-Wl,--defsym=__Sz_AbsoluteZero=0'] + 210 '-Wl,--defsym=__Sz_AbsoluteZero=0'] +
211 target_info.cross_headers) 211 target_info.cross_headers)
212 shellcmd([compiler] + target_params + [args.driver] + objs + 212 shellcmd([compiler] + target_params + [args.driver] + objs +
213 ['-o', os.path.join(args.dir, args.output)] + sb_native_args) 213 ['-o', os.path.join(args.dir, args.output)] + sb_native_args)
214 214
215 if __name__ == '__main__': 215 if __name__ == '__main__':
216 main() 216 main()
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698