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