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

Side by Side Diff: pydir/szbuild.py

Issue 1419173006: Subzero: Use explicit paths to PNaCl tools invoked in szbuild.py. (Closed) Base URL: https://chromium.googlesource.com/native_client/pnacl-subzero.git@master
Patch Set: Remove extra newline Created 5 years, 1 month 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 | « no previous file | 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 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
125 125
126 If no --include or --exclude arguments are given, the executable is produced 126 If no --include or --exclude arguments are given, the executable is produced
127 entirely using Subzero, without using llc or linker tricks. 127 entirely using Subzero, without using llc or linker tricks.
128 128
129 This script uses file modification timestamps to determine whether llc and 129 This script uses file modification timestamps to determine whether llc and
130 Subzero re-translation are needed. It checks timestamps of llc, pnacl-sz, 130 Subzero re-translation are needed. It checks timestamps of llc, pnacl-sz,
131 and the pexe against the translated object files to determine the minimal 131 and the pexe against the translated object files to determine the minimal
132 work necessary. The --force option suppresses those checks and 132 work necessary. The --force option suppresses those checks and
133 re-translates everything. 133 re-translates everything.
134 134
135 This script augments PATH so that various PNaCl and LLVM tools can be run. 135 This script expects various PNaCl and LLVM tools to be found within the
136 These extra paths are within the native_client tree. When changes are made 136 native_client tree. When changes are made to these tools, copy them this
137 to these tools, copy them this way: 137 way:
138 cd native_client 138 cd native_client
139 toolchain_build/toolchain_build_pnacl.py llvm_x86_64_linux \\ 139 toolchain_build/toolchain_build_pnacl.py llvm_x86_64_linux \\
140 --install=toolchain/linux_x86/pnacl_newlib_raw 140 --install=toolchain/linux_x86/pnacl_newlib_raw
141 """ 141 """
142 argparser = argparse.ArgumentParser( 142 argparser = argparse.ArgumentParser(
143 description=' ' + main.__doc__, 143 description=' ' + main.__doc__,
144 formatter_class=argparse.RawTextHelpFormatter) 144 formatter_class=argparse.RawTextHelpFormatter)
145 AddOptionalArgs(argparser) 145 AddOptionalArgs(argparser)
146 argparser.add_argument('pexe', help='Finalized pexe to translate') 146 argparser.add_argument('pexe', help='Finalized pexe to translate')
147 args = argparser.parse_args() 147 args = argparser.parse_args()
148 pexe = args.pexe 148 pexe = args.pexe
149 exe = args.output 149 exe = args.output
150 ProcessPexe(args, pexe, exe) 150 ProcessPexe(args, pexe, exe)
151 151
152 def ProcessPexe(args, pexe, exe): 152 def ProcessPexe(args, pexe, exe):
153 [pexe_base, ext] = os.path.splitext(pexe) 153 [pexe_base, ext] = os.path.splitext(pexe)
154 if ext != '.pexe': 154 if ext != '.pexe':
155 pexe_base = pexe 155 pexe_base = pexe
156 pexe_base_unescaped = pexe_base 156 pexe_base_unescaped = pexe_base
157 pexe_base = pipes.quote(pexe_base) 157 pexe_base = pipes.quote(pexe_base)
158 pexe = pipes.quote(pexe) 158 pexe = pipes.quote(pexe)
159 159
160 nacl_root = FindBaseNaCl() 160 nacl_root = FindBaseNaCl()
161 path_addition = ( 161 path_addition = (
162 '{root}/toolchain/linux_x86/pnacl_newlib_raw/bin' 162 '{root}/toolchain/linux_x86/pnacl_newlib_raw/bin'
163 ).format(root=nacl_root) 163 ).format(root=nacl_root)
164 os.environ['PATH'] = (
165 '{dir}{sep}{path}'
166 ).format(dir=path_addition, sep=os.pathsep, path=os.environ['PATH'])
167 obj_llc = pexe_base + '.llc.o' 164 obj_llc = pexe_base + '.llc.o'
168 obj_sz = pexe_base + '.sz.o' 165 obj_sz = pexe_base + '.sz.o'
169 asm_sz = pexe_base + '.sz.s' 166 asm_sz = pexe_base + '.sz.s'
170 obj_llc_weak = pexe_base + '.weak.llc.o' 167 obj_llc_weak = pexe_base + '.weak.llc.o'
171 obj_sz_weak = pexe_base + '.weak.sz.o' 168 obj_sz_weak = pexe_base + '.weak.sz.o'
172 obj_partial = obj_sz # overridden for hybrid mode 169 obj_partial = obj_sz # overridden for hybrid mode
173 sym_llc = pexe_base + '.sym.llc.txt' 170 sym_llc = pexe_base + '.sym.llc.txt'
174 sym_sz = pexe_base + '.sym.sz.txt' 171 sym_sz = pexe_base + '.sym.sz.txt'
175 sym_sz_unescaped = pexe_base_unescaped + '.sym.sz.txt' 172 sym_sz_unescaped = pexe_base_unescaped + '.sym.sz.txt'
176 whitelist_sz = pexe_base + '.wl.sz.txt' 173 whitelist_sz = pexe_base + '.wl.sz.txt'
177 whitelist_sz_unescaped = pexe_base_unescaped + '.wl.sz.txt' 174 whitelist_sz_unescaped = pexe_base_unescaped + '.wl.sz.txt'
178 pnacl_sz = ( 175 pnacl_sz = (
179 '{root}/toolchain_build/src/subzero/pnacl-sz' 176 '{root}/toolchain_build/src/subzero/pnacl-sz'
180 ).format(root=nacl_root) 177 ).format(root=nacl_root)
181 llcbin = '{base}/pnacl-llc'.format(base=path_addition) 178 llcbin = '{base}/pnacl-llc'.format(base=path_addition)
182 gold = 'le32-nacl-ld.gold' 179 gold = '{base}/le32-nacl-ld.gold'.format(base=path_addition)
183 objcopy = 'le32-nacl-objcopy' 180 objcopy = '{base}/le32-nacl-objcopy'.format(base=path_addition)
184 opt_level = args.optlevel 181 opt_level = args.optlevel
185 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' }
186 hybrid = args.include or args.exclude 183 hybrid = args.include or args.exclude
187 184
188 if hybrid and (args.force or 185 if hybrid and (args.force or
189 NewerThanOrNotThere(pexe, obj_llc) or 186 NewerThanOrNotThere(pexe, obj_llc) or
190 NewerThanOrNotThere(llcbin, obj_llc)): 187 NewerThanOrNotThere(llcbin, obj_llc)):
191 arch = { 188 arch = {
192 'arm32': 'armv7' if args.sandbox else 'arm-nonsfi', 189 'arm32': 'armv7' if args.sandbox else 'arm-nonsfi',
193 'x8632': 'x86-32' if args.sandbox else 'x86-32-linux', 190 'x8632': 'x86-32' if args.sandbox else 'x86-32-linux',
194 }[args.target] 191 }[args.target]
195 192
196 # Only run pnacl-translate in hybrid mode. 193 # Only run pnacl-translate in hybrid mode.
197 shellcmd(['pnacl-translate', 194 shellcmd(['{base}/pnacl-translate'.format(base=path_addition),
198 '-split-module=1', 195 '-split-module=1',
199 '-ffunction-sections', 196 '-ffunction-sections',
200 '-fdata-sections', 197 '-fdata-sections',
201 '-c', 198 '-c',
202 '-arch', arch, 199 '-arch', arch,
203 '-O' + opt_level_map[opt_level], 200 '-O' + opt_level_map[opt_level],
204 '--pnacl-driver-append-LLC_FLAGS_EXTRA=-externalize', 201 '--pnacl-driver-append-LLC_FLAGS_EXTRA=-externalize',
205 '-o', obj_llc] + 202 '-o', obj_llc] +
206 (['--pnacl-driver-verbose'] if args.verbose else []) + 203 (['--pnacl-driver-verbose'] if args.verbose else []) +
207 args.llc_args + 204 args.llc_args +
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after
360 '{{unsandboxed_irt,irt_random,irt_query_list}}.o ' + 357 '{{unsandboxed_irt,irt_random,irt_query_list}}.o ' +
361 '{root}/toolchain_build/src/subzero/build/runtime/' + 358 '{root}/toolchain_build/src/subzero/build/runtime/' +
362 'szrt_native_{target}.o -lpthread -lrt ' + 359 'szrt_native_{target}.o -lpthread -lrt ' +
363 '-Wl,--defsym=__Sz_AbsoluteZero=0' 360 '-Wl,--defsym=__Sz_AbsoluteZero=0'
364 ).format(ld=linker, ld_extra_args=extra_linker_args, 361 ).format(ld=linker, ld_extra_args=extra_linker_args,
365 partial=obj_partial, exe=exe, root=nacl_root, 362 partial=obj_partial, exe=exe, root=nacl_root,
366 target=args.target, lib_dir=lib_dir), 363 target=args.target, lib_dir=lib_dir),
367 echo=args.verbose) 364 echo=args.verbose)
368 365
369 # Put the extra verbose printing at the end. 366 # Put the extra verbose printing at the end.
370 if args.verbose: 367 if args.verbose and hybrid:
371 print 'PATH: {path}'.format(path=path_addition) 368 print 'include={regex}'.format(regex=re_include_str)
372 if hybrid: 369 print 'exclude={regex}'.format(regex=re_exclude_str)
373 print 'include={regex}'.format(regex=re_include_str) 370 print 'default_match={dm}'.format(dm=default_match)
374 print 'exclude={regex}'.format(regex=re_exclude_str) 371 print 'Number of Subzero syms = {num}'.format(num=len(sz_syms))
375 print 'default_match={dm}'.format(dm=default_match)
376 print 'Number of Subzero syms = {num}'.format(num=len(sz_syms))
377 372
378 if __name__ == '__main__': 373 if __name__ == '__main__':
379 main() 374 main()
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698