OLD | NEW |
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 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
118 This script uses file modification timestamps to determine whether | 118 This script uses file modification timestamps to determine whether |
119 llc and Subzero re-translation are needed. It checks timestamps | 119 llc and Subzero re-translation are needed. It checks timestamps |
120 of llc, llvm2ice, and the pexe against the translated object files | 120 of llc, llvm2ice, and the pexe against the translated object files |
121 to determine the minimal work necessary. The --force option | 121 to determine the minimal work necessary. The --force option |
122 suppresses those checks and re-translates everything. | 122 suppresses those checks and re-translates everything. |
123 | 123 |
124 This script augments PATH so that various PNaCl and LLVM tools can | 124 This script augments PATH so that various PNaCl and LLVM tools can |
125 be run. These extra paths are within the native_client tree. | 125 be run. These extra paths are within the native_client tree. |
126 When changes are made to these tools, copy them this way: | 126 When changes are made to these tools, copy them this way: |
127 cd native_client | 127 cd native_client |
128 toolchain_build/toolchain_build_pnacl.py llvm_i686_linux \\ | 128 toolchain_build/toolchain_build_pnacl.py llvm_x86_64_linux \\ |
129 --install=toolchain/linux_x86/pnacl_newlib | 129 --install=toolchain/linux_x86/pnacl_newlib |
130 """ | 130 """ |
131 argparser = argparse.ArgumentParser( | 131 argparser = argparse.ArgumentParser( |
132 description=' ' + main.__doc__, | 132 description=' ' + main.__doc__, |
133 formatter_class=argparse.RawTextHelpFormatter) | 133 formatter_class=argparse.RawTextHelpFormatter) |
134 AddOptionalArgs(argparser) | 134 AddOptionalArgs(argparser) |
135 argparser.add_argument('pexe', help='Finalized pexe to translate') | 135 argparser.add_argument('pexe', help='Finalized pexe to translate') |
136 args = argparser.parse_args() | 136 args = argparser.parse_args() |
137 pexe = args.pexe | 137 pexe = args.pexe |
138 exe = args.output | 138 exe = args.output |
139 ProcessPexe(args, pexe, exe) | 139 ProcessPexe(args, pexe, exe) |
140 | 140 |
141 def ProcessPexe(args, pexe, exe): | 141 def ProcessPexe(args, pexe, exe): |
142 [pexe_base, ext] = os.path.splitext(pexe) | 142 [pexe_base, ext] = os.path.splitext(pexe) |
143 if ext != '.pexe': | 143 if ext != '.pexe': |
144 pexe_base = pexe | 144 pexe_base = pexe |
145 pexe_base_unescaped = pexe_base | 145 pexe_base_unescaped = pexe_base |
146 pexe_base = pipes.quote(pexe_base) | 146 pexe_base = pipes.quote(pexe_base) |
147 pexe = pipes.quote(pexe) | 147 pexe = pipes.quote(pexe) |
148 | 148 |
149 nacl_root = FindBaseNaCl() | 149 nacl_root = FindBaseNaCl() |
150 os.environ['PATH'] = ( | 150 os.environ['PATH'] = ( |
151 '{root}/toolchain/linux_x86/pnacl_newlib/bin{sep}' + | 151 '{root}/toolchain/linux_x86/pnacl_newlib/bin{sep}' + |
152 '{root}/toolchain/linux_x86/pnacl_newlib/host_x86_32/bin{sep}' + | |
153 '{path}' | 152 '{path}' |
154 ).format(root=nacl_root, sep=os.pathsep, path=os.environ['PATH']) | 153 ).format(root=nacl_root, sep=os.pathsep, path=os.environ['PATH']) |
155 obj_llc = pexe_base + '.llc.o' | 154 obj_llc = pexe_base + '.llc.o' |
156 obj_sz = pexe_base + '.sz.o' | 155 obj_sz = pexe_base + '.sz.o' |
157 asm_sz = pexe_base + '.sz.s' | 156 asm_sz = pexe_base + '.sz.s' |
158 obj_llc_weak = pexe_base + '.weak.llc.o' | 157 obj_llc_weak = pexe_base + '.weak.llc.o' |
159 obj_sz_weak = pexe_base + '.weak.sz.o' | 158 obj_sz_weak = pexe_base + '.weak.sz.o' |
160 obj_partial = pexe_base + '.o' | 159 obj_partial = pexe_base + '.o' |
161 sym_llc = pexe_base + '.sym.llc.txt' | 160 sym_llc = pexe_base + '.sym.llc.txt' |
162 sym_sz = pexe_base + '.sym.sz.txt' | 161 sym_sz = pexe_base + '.sym.sz.txt' |
163 sym_sz_unescaped = pexe_base_unescaped + '.sym.sz.txt' | 162 sym_sz_unescaped = pexe_base_unescaped + '.sym.sz.txt' |
164 whitelist_sz = pexe_base + '.wl.sz.txt' | 163 whitelist_sz = pexe_base + '.wl.sz.txt' |
165 whitelist_sz_unescaped = pexe_base_unescaped + '.wl.sz.txt' | 164 whitelist_sz_unescaped = pexe_base_unescaped + '.wl.sz.txt' |
166 llvm2ice = ( | 165 llvm2ice = ( |
167 '{root}/toolchain_build/src/subzero/llvm2ice' | 166 '{root}/toolchain_build/src/subzero/llvm2ice' |
168 ).format(root=nacl_root) | 167 ).format(root=nacl_root) |
169 llcbin = ( | 168 llcbin = ( |
170 '{root}/toolchain/linux_x86/pnacl_newlib/host_x86_32/bin/llc' | 169 '{root}/toolchain/linux_x86/pnacl_newlib/bin/llc' |
171 ).format(root=nacl_root) | 170 ).format(root=nacl_root) |
172 opt_level = args.optlevel | 171 opt_level = args.optlevel |
173 | 172 |
174 if args.force or NewerThanOrNotThere(pexe, obj_llc) or \ | 173 if args.force or NewerThanOrNotThere(pexe, obj_llc) or \ |
175 NewerThanOrNotThere(llcbin, obj_llc): | 174 NewerThanOrNotThere(llcbin, obj_llc): |
176 opt_level_map = { 'm1':'0', '-1':'0', '0':'0', '1':'1', '2':'2' } | 175 opt_level_map = { 'm1':'0', '-1':'0', '0':'0', '1':'1', '2':'2' } |
177 shellcmd(['pnacl-translate', | 176 shellcmd(['pnacl-translate', |
178 '-ffunction-sections', | 177 '-ffunction-sections', |
179 '-c', | 178 '-c', |
180 '-arch', 'x86-32-linux', | 179 '-arch', 'x86-32-linux', |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
266 # Put the extra verbose printing at the end. | 265 # Put the extra verbose printing at the end. |
267 if args.verbose: | 266 if args.verbose: |
268 print 'PATH={path}'.format(path=os.environ['PATH']) | 267 print 'PATH={path}'.format(path=os.environ['PATH']) |
269 print 'include={regex}'.format(regex=re_include_str) | 268 print 'include={regex}'.format(regex=re_include_str) |
270 print 'exclude={regex}'.format(regex=re_exclude_str) | 269 print 'exclude={regex}'.format(regex=re_exclude_str) |
271 print 'default_match={dm}'.format(dm=default_match) | 270 print 'default_match={dm}'.format(dm=default_match) |
272 print 'Number of Subzero syms = {num}'.format(num=len(sz_syms)) | 271 print 'Number of Subzero syms = {num}'.format(num=len(sz_syms)) |
273 | 272 |
274 if __name__ == '__main__': | 273 if __name__ == '__main__': |
275 main() | 274 main() |
OLD | NEW |