Chromium Code Reviews| 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 shutil | 5 import shutil |
| 6 import tempfile | 6 import tempfile |
| 7 | 7 |
| 8 import targets | 8 import targets |
| 9 from utils import FindBaseNaCl, GetObjcopyCmd, shellcmd | 9 from utils import FindBaseNaCl, GetObjcopyCmd, shellcmd |
| 10 | 10 |
| 11 | 11 |
| 12 def Translate(ll_files, extra_args, obj, verbose, target): | 12 def Translate(ll_files, extra_args, obj, verbose, target): |
| 13 """Translate a set of input bitcode files into a single object file. | 13 """Translate a set of input bitcode files into a single object file. |
| 14 | 14 |
| 15 Use pnacl-llc to translate textual bitcode input ll_files into object file | 15 Use pnacl-llc to translate textual bitcode input ll_files into object file |
| 16 obj, using extra_args as the architectural flags. | 16 obj, using extra_args as the architectural flags. |
| 17 """ | 17 """ |
| 18 externalize = [] if target == 'mips32' else ['-externalize'] | 18 externalize = ['-externalize'] |
| 19 shellcmd(['cat'] + ll_files + ['|', | 19 shellcmd(['cat'] + ll_files + ['|', |
| 20 'pnacl-llc', | 20 'pnacl-llc', |
| 21 '-function-sections', | 21 '-function-sections', |
| 22 '-O2', | 22 '-O2', |
| 23 '-filetype=obj', | 23 '-filetype=obj', |
| 24 '-bitcode-format=llvm', | 24 '-bitcode-format=llvm', |
| 25 '-o', obj | 25 '-o', obj |
| 26 ] + extra_args + externalize, echo=verbose) | 26 ] + extra_args + externalize, echo=verbose) |
| 27 strip_syms = [] if target == 'mips32' else ['nacl_tp_tdb_offset', | 27 strip_syms = [] if target == 'mips32' else ['nacl_tp_tdb_offset', |
| 28 'nacl_tp_tls_offset'] | 28 'nacl_tp_tls_offset'] |
| 29 shellcmd([GetObjcopyCmd(target), obj] + | 29 if target != 'mips32': |
|
Jim Stichnoth
2016/11/08 13:36:31
Is this diff actually needed? As I understand it,
Stefan Maksimovic
2016/11/08 14:59:55
Initially I got the undefined reference errors poi
Jim Stichnoth
2016/11/08 15:34:08
Ah sorry! I misread the logic in the new code. I
| |
| 30 [('--strip-symbol=' + sym) for sym in strip_syms]) | 30 shellcmd([GetObjcopyCmd(target), obj] + |
| 31 [('--strip-symbol=' + sym) for sym in strip_syms]) | |
| 32 else: | |
| 33 shellcmd([GetObjcopyCmd(target), obj] + | |
| 34 [('--strip-symbol=' + sym) for sym in strip_syms] + | |
| 35 ['-L','nacl_tp_tdb_offset','-L','nacl_tp_tls_offset']) | |
| 31 | 36 |
| 32 | 37 |
| 33 def PartialLink(obj_files, extra_args, lib, verbose): | 38 def PartialLink(obj_files, extra_args, lib, verbose): |
| 34 """Partially links a set of obj files into a final obj library.""" | 39 """Partially links a set of obj files into a final obj library.""" |
| 35 shellcmd(['le32-nacl-ld', | 40 shellcmd(['le32-nacl-ld', |
| 36 '-o', lib, | 41 '-o', lib, |
| 37 '-r', | 42 '-r', |
| 38 ] + extra_args + obj_files, echo=verbose) | 43 ] + extra_args + obj_files, echo=verbose) |
| 39 | 44 |
| 40 | 45 |
| (...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 223 | 228 |
| 224 finally: | 229 finally: |
| 225 try: | 230 try: |
| 226 shutil.rmtree(tempdir) | 231 shutil.rmtree(tempdir) |
| 227 except OSError as exc: | 232 except OSError as exc: |
| 228 if exc.errno != errno.ENOENT: # ENOENT - no such file or directory | 233 if exc.errno != errno.ENOENT: # ENOENT - no such file or directory |
| 229 raise # re-raise exception | 234 raise # re-raise exception |
| 230 | 235 |
| 231 if __name__ == '__main__': | 236 if __name__ == '__main__': |
| 232 main() | 237 main() |
| OLD | NEW |