| 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 |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 77 # Write full szrt_native_{target}.o. | 77 # Write full szrt_native_{target}.o. |
| 78 PartialLink([TmpFile('{dir}/szrt_native_{target}.tmp.o'), | 78 PartialLink([TmpFile('{dir}/szrt_native_{target}.tmp.o'), |
| 79 TmpFile('{dir}/szrt_native_asm_{target}.o'), | 79 TmpFile('{dir}/szrt_native_asm_{target}.o'), |
| 80 TmpFile('{dir}/szrt_native_profiler_{target}.o')], | 80 TmpFile('{dir}/szrt_native_profiler_{target}.o')], |
| 81 ['-m {ld_emu}'.format(ld_emu=target_info.ld_emu)], | 81 ['-m {ld_emu}'.format(ld_emu=target_info.ld_emu)], |
| 82 OutFile('{rtdir}/szrt_native_{target}.o'), | 82 OutFile('{rtdir}/szrt_native_{target}.o'), |
| 83 verbose) | 83 verbose) |
| 84 shellcmd([GetObjcopyCmd(), | 84 shellcmd([GetObjcopyCmd(), |
| 85 '--strip-symbol=NATIVE', | 85 '--strip-symbol=NATIVE', |
| 86 OutFile('{rtdir}/szrt_native_{target}.o')]) | 86 OutFile('{rtdir}/szrt_native_{target}.o')]) |
| 87 # Compile srcdir/szrt_asan.c to |
| 88 # tempdir/szrt_native_asan_{target}.o |
| 89 shellcmd(['clang', |
| 90 '-O2', |
| 91 '-target=' + target_info.triple, |
| 92 '-c', |
| 93 '{srcdir}/szrt_asan.c'.format(srcdir=srcdir), |
| 94 '-o', OutFile('{rtdir}/szrt_asan_{target}.o') |
| 95 ], echo=verbose) |
| 87 | 96 |
| 88 # Helper function for building the sandboxed runtime. | 97 # Helper function for building the sandboxed runtime. |
| 89 def MakeSandboxedRuntime(): | 98 def MakeSandboxedRuntime(): |
| 90 """Builds just the sandboxed runtime.""" | 99 """Builds just the sandboxed runtime.""" |
| 91 # Translate tempdir/szrt.ll and tempdir/szrt_ll.ll to szrt_sb_{target}.o. | 100 # Translate tempdir/szrt.ll and tempdir/szrt_ll.ll to szrt_sb_{target}.o. |
| 92 # The sandboxed library does not get the profiler helper function as the | 101 # The sandboxed library does not get the profiler helper function as the |
| 93 # binaries are linked with -nostdlib. | 102 # binaries are linked with -nostdlib. |
| 94 Translate(ll_files, | 103 Translate(ll_files, |
| 95 ['-mtriple=' + targets.ConvertTripleToNaCl(target_info.triple)] + | 104 ['-mtriple=' + targets.ConvertTripleToNaCl(target_info.triple)] + |
| 96 target_info.llc_flags, | 105 target_info.llc_flags, |
| (...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 206 | 215 |
| 207 finally: | 216 finally: |
| 208 try: | 217 try: |
| 209 shutil.rmtree(tempdir) | 218 shutil.rmtree(tempdir) |
| 210 except OSError as exc: | 219 except OSError as exc: |
| 211 if exc.errno != errno.ENOENT: # ENOENT - no such file or directory | 220 if exc.errno != errno.ENOENT: # ENOENT - no such file or directory |
| 212 raise # re-raise exception | 221 raise # re-raise exception |
| 213 | 222 |
| 214 if __name__ == '__main__': | 223 if __name__ == '__main__': |
| 215 main() | 224 main() |
| OLD | NEW |