| 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 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 szbuild import LinkNonsfi | 10 from szbuild import LinkNonsfi |
| (...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 170 # currently the only situation where multiple translated files are | 170 # currently the only situation where multiple translated files are |
| 171 # linked into the executable, but when PNaCl supports shared nexe | 171 # linked into the executable, but when PNaCl supports shared nexe |
| 172 # libraries, this would need to change. | 172 # libraries, this would need to change. |
| 173 shellcmd(['{bin}/le32-nacl-objcopy'.format(bin=bindir), | 173 shellcmd(['{bin}/le32-nacl-objcopy'.format(bin=bindir), |
| 174 '--weaken-symbol=__Sz_block_profile_info', | 174 '--weaken-symbol=__Sz_block_profile_info', |
| 175 '--strip-symbol=nacl_tp_tdb_offset', | 175 '--strip-symbol=nacl_tp_tdb_offset', |
| 176 '--strip-symbol=nacl_tp_tls_offset', | 176 '--strip-symbol=nacl_tp_tls_offset', |
| 177 obj_sz]) | 177 obj_sz]) |
| 178 objs.append(obj_sz) | 178 objs.append(obj_sz) |
| 179 shellcmd(['{bin}/pnacl-llc'.format(bin=bindir), | 179 shellcmd(['{bin}/pnacl-llc'.format(bin=bindir), |
| 180 '-arm-enable-dwarf-eh=1', |
| 180 '-mtriple=' + triple, | 181 '-mtriple=' + triple, |
| 181 '-externalize', | 182 '-externalize', |
| 182 '-filetype=obj', | 183 '-filetype=obj', |
| 183 '-bitcode-format=llvm', | 184 '-bitcode-format=llvm', |
| 184 '-o=' + obj_llc, | 185 '-o=' + obj_llc, |
| 185 bitcode] + llc_flags) | 186 bitcode] + llc_flags) |
| 186 shellcmd(['{bin}/le32-nacl-objcopy'.format(bin=bindir), | 187 shellcmd(['{bin}/le32-nacl-objcopy'.format(bin=bindir), |
| 187 '--weaken-symbol=__Sz_block_profile_info', | 188 '--weaken-symbol=__Sz_block_profile_info', |
| 188 '--strip-symbol=nacl_tp_tdb_offset', | 189 '--strip-symbol=nacl_tp_tdb_offset', |
| 189 '--strip-symbol=nacl_tp_tls_offset', | 190 '--strip-symbol=nacl_tp_tls_offset', |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 230 return 0 | 231 return 0 |
| 231 | 232 |
| 232 base, ext = os.path.splitext(args.driver) | 233 base, ext = os.path.splitext(args.driver) |
| 233 bitcode_nonfinal = os.path.join(args.dir, base + '.' + key + '.bc') | 234 bitcode_nonfinal = os.path.join(args.dir, base + '.' + key + '.bc') |
| 234 bitcode = os.path.join(args.dir, base + '.' + key + '.pnacl.ll') | 235 bitcode = os.path.join(args.dir, base + '.' + key + '.pnacl.ll') |
| 235 asm_sz = os.path.join(args.dir, base + '.' + key + '.s') | 236 asm_sz = os.path.join(args.dir, base + '.' + key + '.s') |
| 236 obj_llc = os.path.join(args.dir, base + '.' + key + '.o') | 237 obj_llc = os.path.join(args.dir, base + '.' + key + '.o') |
| 237 compiler = '{bin}/{prefix}{cc}'.format( | 238 compiler = '{bin}/{prefix}{cc}'.format( |
| 238 bin=bindir, prefix='pnacl-', | 239 bin=bindir, prefix='pnacl-', |
| 239 cc='clang' if pure_c else 'clang++') | 240 cc='clang' if pure_c else 'clang++') |
| 240 shellcmd([compiler, | 241 shellcmd([compiler] + target_params + [ |
| 241 args.driver, | 242 args.driver, |
| 242 '-O2', | 243 '-O2', |
| 243 '-o', bitcode_nonfinal, | 244 '-o', bitcode_nonfinal, |
| 244 '-Wl,-r' | 245 '-Wl,-r' |
| 245 ]) | 246 ]) |
| 246 shellcmd(['{bin}/pnacl-opt'.format(bin=bindir), | 247 shellcmd(['{bin}/pnacl-opt'.format(bin=bindir), |
| 247 '-pnacl-abi-simplify-preopt', | 248 '-pnacl-abi-simplify-preopt', |
| 248 '-pnacl-abi-simplify-postopt', | 249 '-pnacl-abi-simplify-postopt', |
| 249 '-pnaclabi-allow-debug-metadata', | 250 '-pnaclabi-allow-debug-metadata', |
| 250 '-strip-metadata', | 251 '-strip-metadata', |
| 251 '-strip-module-flags', | 252 '-strip-module-flags', |
| 252 '-strip-debug', | 253 '-strip-debug', |
| 253 '-disable-opt', | 254 '-disable-opt', |
| 254 bitcode_nonfinal, '-S', '-o', bitcode]) | 255 bitcode_nonfinal, '-S', '-o', bitcode]) |
| 255 shellcmd(['{bin}/pnacl-llc'.format(bin=bindir), | 256 shellcmd(['{bin}/pnacl-llc'.format(bin=bindir), |
| 257 '-arm-enable-dwarf-eh=1', |
| 256 '-mtriple=' + triple, | 258 '-mtriple=' + triple, |
| 257 '-externalize', | 259 '-externalize', |
| 258 '-filetype=obj', | 260 '-filetype=obj', |
| 259 '-O2', | 261 '-O2', |
| 260 '-bitcode-format=llvm', | 262 '-bitcode-format=llvm', |
| 261 '-o', obj_llc, | 263 '-o', obj_llc, |
| 262 bitcode] + llc_flags) | 264 bitcode] + llc_flags) |
| 263 if not args.sandbox and not args.nonsfi: | 265 if not args.sandbox and not args.nonsfi: |
| 264 shellcmd(['{bin}/le32-nacl-objcopy'.format(bin=bindir), | 266 shellcmd(['{bin}/le32-nacl-objcopy'.format(bin=bindir), |
| 265 '--redefine-sym', '_start=_user_start', | 267 '--redefine-sym', '_start=_user_start', |
| 266 obj_llc | 268 obj_llc |
| 267 ]) | 269 ]) |
| 268 objs.append(obj_llc) | 270 objs.append(obj_llc) |
| 269 if args.nonsfi: | 271 if args.nonsfi: |
| 270 LinkNonsfi(objs, os.path.join(args.dir, args.output), args.target) | 272 LinkNonsfi(objs, os.path.join(args.dir, args.output), args.target) |
| 271 elif args.sandbox: | 273 elif args.sandbox: |
| 272 LinkSandbox(objs, os.path.join(args.dir, args.output), args.target) | 274 LinkSandbox(objs, os.path.join(args.dir, args.output), args.target) |
| 273 else: | 275 else: |
| 274 LinkNative(objs, os.path.join(args.dir, args.output), args.target) | 276 LinkNative(objs, os.path.join(args.dir, args.output), args.target) |
| 275 | 277 |
| 276 if __name__ == '__main__': | 278 if __name__ == '__main__': |
| 277 main() | 279 main() |
| OLD | NEW |