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

Side by Side Diff: pydir/szbuild.py

Issue 1185703006: Build ARM SZ runtime files. Use le32-nacl-objcopy in various places. (Closed) Base URL: https://chromium.googlesource.com/native_client/pnacl-subzero.git@master
Patch Set: Created 5 years, 6 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/crosstest.py ('k') | no next file » | 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 pipes 5 import pipes
6 import re 6 import re
7 import sys 7 import sys
8 8
9 from utils import shellcmd 9 from utils import shellcmd
10 from utils import FindBaseNaCl 10 from utils import FindBaseNaCl
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after
170 sym_llc = pexe_base + '.sym.llc.txt' 170 sym_llc = pexe_base + '.sym.llc.txt'
171 sym_sz = pexe_base + '.sym.sz.txt' 171 sym_sz = pexe_base + '.sym.sz.txt'
172 sym_sz_unescaped = pexe_base_unescaped + '.sym.sz.txt' 172 sym_sz_unescaped = pexe_base_unescaped + '.sym.sz.txt'
173 whitelist_sz = pexe_base + '.wl.sz.txt' 173 whitelist_sz = pexe_base + '.wl.sz.txt'
174 whitelist_sz_unescaped = pexe_base_unescaped + '.wl.sz.txt' 174 whitelist_sz_unescaped = pexe_base_unescaped + '.wl.sz.txt'
175 pnacl_sz = ( 175 pnacl_sz = (
176 '{root}/toolchain_build/src/subzero/pnacl-sz' 176 '{root}/toolchain_build/src/subzero/pnacl-sz'
177 ).format(root=nacl_root) 177 ).format(root=nacl_root)
178 llcbin = '{base}/pnacl-llc'.format(base=path_addition) 178 llcbin = '{base}/pnacl-llc'.format(base=path_addition)
179 gold = 'le32-nacl-ld.gold' 179 gold = 'le32-nacl-ld.gold'
180 objcopy = 'le32-nacl-objcopy'
180 opt_level = args.optlevel 181 opt_level = args.optlevel
181 opt_level_map = { 'm1':'0', '-1':'0', '0':'0', '1':'1', '2':'2' } 182 opt_level_map = { 'm1':'0', '-1':'0', '0':'0', '1':'1', '2':'2' }
182 hybrid = args.include or args.exclude 183 hybrid = args.include or args.exclude
183 184
184 if hybrid and (args.force or 185 if hybrid and (args.force or
185 NewerThanOrNotThere(pexe, obj_llc) or 186 NewerThanOrNotThere(pexe, obj_llc) or
186 NewerThanOrNotThere(llcbin, obj_llc)): 187 NewerThanOrNotThere(llcbin, obj_llc)):
187 # Only run pnacl-translate in hybrid mode. 188 # Only run pnacl-translate in hybrid mode.
188 shellcmd(['pnacl-translate', 189 shellcmd(['pnacl-translate',
189 '-split-module=1', 190 '-split-module=1',
190 '-ffunction-sections', 191 '-ffunction-sections',
191 '-fdata-sections', 192 '-fdata-sections',
192 '-c', 193 '-c',
193 '-arch', 'x86-32' if args.sandbox else 'x86-32-linux', 194 '-arch', 'x86-32' if args.sandbox else 'x86-32-linux',
194 '-O' + opt_level_map[opt_level], 195 '-O' + opt_level_map[opt_level],
195 '--pnacl-driver-append-LLC_FLAGS_EXTRA=-externalize', 196 '--pnacl-driver-append-LLC_FLAGS_EXTRA=-externalize',
196 '-o', obj_llc] + 197 '-o', obj_llc] +
197 (['--pnacl-driver-verbose'] if args.verbose else []) + 198 (['--pnacl-driver-verbose'] if args.verbose else []) +
198 args.llc_args + 199 args.llc_args +
199 [pexe], 200 [pexe],
200 echo=args.verbose) 201 echo=args.verbose)
201 if not args.sandbox: 202 if not args.sandbox:
202 shellcmd(( 203 shellcmd((
203 'objcopy --redefine-sym _start=_user_start {obj}' 204 '{objcopy} --redefine-sym _start=_user_start {obj}'
204 ).format(obj=obj_llc), echo=args.verbose) 205 ).format(objcopy=objcopy, obj=obj_llc), echo=args.verbose)
205 # Generate llc syms file for consistency, even though it's not used. 206 # Generate llc syms file for consistency, even though it's not used.
206 shellcmd(( 207 shellcmd((
207 'nm {obj} | sed -n "s/.* [a-zA-Z] //p" > {sym}' 208 'nm {obj} | sed -n "s/.* [a-zA-Z] //p" > {sym}'
208 ).format(obj=obj_llc, sym=sym_llc), echo=args.verbose) 209 ).format(obj=obj_llc, sym=sym_llc), echo=args.verbose)
209 210
210 if (args.force or 211 if (args.force or
211 NewerThanOrNotThere(pexe, obj_sz) or 212 NewerThanOrNotThere(pexe, obj_sz) or
212 NewerThanOrNotThere(pnacl_sz, obj_sz)): 213 NewerThanOrNotThere(pnacl_sz, obj_sz)):
213 # Run pnacl-sz regardless of hybrid mode. 214 # Run pnacl-sz regardless of hybrid mode.
214 shellcmd([pnacl_sz, 215 shellcmd([pnacl_sz,
(...skipping 11 matching lines...) Expand all
226 [pexe], 227 [pexe],
227 echo=args.verbose) 228 echo=args.verbose)
228 if args.filetype != 'obj': 229 if args.filetype != 'obj':
229 shellcmd(( 230 shellcmd((
230 'llvm-mc -triple={triple} -filetype=obj -o {obj} {asm}' 231 'llvm-mc -triple={triple} -filetype=obj -o {obj} {asm}'
231 ).format(asm=asm_sz, obj=obj_sz, 232 ).format(asm=asm_sz, obj=obj_sz,
232 triple='i686-nacl' if args.sandbox else 'i686'), 233 triple='i686-nacl' if args.sandbox else 'i686'),
233 echo=args.verbose) 234 echo=args.verbose)
234 if not args.sandbox: 235 if not args.sandbox:
235 shellcmd(( 236 shellcmd((
236 'objcopy --redefine-sym _start=_user_start {obj}' 237 '{objcopy} --redefine-sym _start=_user_start {obj}'
237 ).format(obj=obj_sz), echo=args.verbose) 238 ).format(objcopy=objcopy, obj=obj_sz), echo=args.verbose)
238 if hybrid: 239 if hybrid:
239 shellcmd(( 240 shellcmd((
240 'nm {obj} | sed -n "s/.* [a-zA-Z] //p" > {sym}' 241 'nm {obj} | sed -n "s/.* [a-zA-Z] //p" > {sym}'
241 ).format(obj=obj_sz, sym=sym_sz), echo=args.verbose) 242 ).format(obj=obj_sz, sym=sym_sz), echo=args.verbose)
242 243
243 if hybrid: 244 if hybrid:
244 with open(sym_sz_unescaped) as f: 245 with open(sym_sz_unescaped) as f:
245 sz_syms = f.read().splitlines() 246 sz_syms = f.read().splitlines()
246 re_include_str = BuildRegex(args.include, sz_syms) 247 re_include_str = BuildRegex(args.include, sz_syms)
247 re_exclude_str = BuildRegex(args.exclude, sz_syms) 248 re_exclude_str = BuildRegex(args.exclude, sz_syms)
248 re_include = re.compile(re_include_str) 249 re_include = re.compile(re_include_str)
249 re_exclude = re.compile(re_exclude_str) 250 re_exclude = re.compile(re_exclude_str)
250 # If a symbol doesn't explicitly match re_include or re_exclude, 251 # If a symbol doesn't explicitly match re_include or re_exclude,
251 # the default MatchSymbol() result is True, unless some --include 252 # the default MatchSymbol() result is True, unless some --include
252 # args are provided. 253 # args are provided.
253 default_match = not args.include 254 default_match = not args.include
254 255
255 whitelist_has_items = False 256 whitelist_has_items = False
256 with open(whitelist_sz_unescaped, 'w') as f: 257 with open(whitelist_sz_unescaped, 'w') as f:
257 for sym in sz_syms: 258 for sym in sz_syms:
258 if MatchSymbol(sym, re_include, re_exclude, default_match): 259 if MatchSymbol(sym, re_include, re_exclude, default_match):
259 f.write(sym + '\n') 260 f.write(sym + '\n')
260 whitelist_has_items = True 261 whitelist_has_items = True
261 shellcmd(( 262 shellcmd((
262 'objcopy --weaken {obj} {weak}' 263 '{objcopy} --weaken {obj} {weak}'
263 ).format(obj=obj_sz, weak=obj_sz_weak), echo=args.verbose) 264 ).format(objcopy=objcopy, obj=obj_sz, weak=obj_sz_weak),
265 echo=args.verbose)
264 if whitelist_has_items: 266 if whitelist_has_items:
265 # objcopy returns an error if the --weaken-symbols file is empty. 267 # objcopy returns an error if the --weaken-symbols file is empty.
266 shellcmd(( 268 shellcmd((
267 'objcopy --weaken-symbols={whitelist} {obj} {weak}' 269 '{objcopy} --weaken-symbols={whitelist} {obj} {weak}'
268 ).format(whitelist=whitelist_sz, obj=obj_llc, 270 ).format(objcopy=objcopy,
271 whitelist=whitelist_sz, obj=obj_llc,
269 weak=obj_llc_weak), 272 weak=obj_llc_weak),
270 echo=args.verbose) 273 echo=args.verbose)
271 else: 274 else:
272 shellcmd(( 275 shellcmd((
273 'objcopy {obj} {weak}' 276 '{objcopy} {obj} {weak}'
274 ).format(obj=obj_llc, weak=obj_llc_weak), echo=args.verbose) 277 ).format(objcopy=objcopy, obj=obj_llc, weak=obj_llc_weak),
278 echo=args.verbose)
275 obj_partial = pexe_base + '.o' 279 obj_partial = pexe_base + '.o'
276 shellcmd(( 280 shellcmd((
277 'ld -r -m elf_i386 -o {partial} {sz} {llc}' 281 'ld -r -m elf_i386 -o {partial} {sz} {llc}'
278 ).format(partial=obj_partial, sz=obj_sz_weak, llc=obj_llc_weak), 282 ).format(partial=obj_partial, sz=obj_sz_weak, llc=obj_llc_weak),
279 echo=args.verbose) 283 echo=args.verbose)
280 shellcmd(( 284 shellcmd((
281 'objcopy -w --localize-symbol="*" {partial}' 285 '{objcopy} -w --localize-symbol="*" {partial}'
282 ).format(partial=obj_partial), echo=args.verbose) 286 ).format(objcopy=objcopy, partial=obj_partial),
287 echo=args.verbose)
283 shellcmd(( 288 shellcmd((
284 'objcopy --globalize-symbol={start} {partial}' 289 '{objcopy} --globalize-symbol={start} {partial}'
285 ).format(partial=obj_partial, 290 ).format(objcopy=objcopy, partial=obj_partial,
286 start='_start' if args.sandbox else '_user_start'), 291 start='_start' if args.sandbox else '_user_start'),
287 echo=args.verbose) 292 echo=args.verbose)
288 293
289 # Run the linker regardless of hybrid mode. 294 # Run the linker regardless of hybrid mode.
290 linker = ( 295 linker = (
291 '{root}/../third_party/llvm-build/Release+Asserts/bin/clang' 296 '{root}/../third_party/llvm-build/Release+Asserts/bin/clang'
292 ).format(root=nacl_root) 297 ).format(root=nacl_root)
293 if args.sandbox: 298 if args.sandbox:
294 linklib = ('{root}/toolchain/linux_x86/pnacl_newlib_raw/translator/' + 299 linklib = ('{root}/toolchain/linux_x86/pnacl_newlib_raw/translator/' +
295 'x86-32/lib').format(root=nacl_root) 300 'x86-32/lib').format(root=nacl_root)
(...skipping 29 matching lines...) Expand all
325 if args.verbose: 330 if args.verbose:
326 print 'PATH: {path}'.format(path=path_addition) 331 print 'PATH: {path}'.format(path=path_addition)
327 if hybrid: 332 if hybrid:
328 print 'include={regex}'.format(regex=re_include_str) 333 print 'include={regex}'.format(regex=re_include_str)
329 print 'exclude={regex}'.format(regex=re_exclude_str) 334 print 'exclude={regex}'.format(regex=re_exclude_str)
330 print 'default_match={dm}'.format(dm=default_match) 335 print 'default_match={dm}'.format(dm=default_match)
331 print 'Number of Subzero syms = {num}'.format(num=len(sz_syms)) 336 print 'Number of Subzero syms = {num}'.format(num=len(sz_syms))
332 337
333 if __name__ == '__main__': 338 if __name__ == '__main__':
334 main() 339 main()
OLDNEW
« no previous file with comments | « pydir/crosstest.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698