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 utils import shellcmd | 10 from utils import shellcmd |
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
115 target=args.target, sb='sb' if args.sandbox else 'nat', | 115 target=args.target, sb='sb' if args.sandbox else 'nat', |
116 opt=args.optlevel, attr=args.attr) | 116 opt=args.optlevel, attr=args.attr) |
117 base, ext = os.path.splitext(arg) | 117 base, ext = os.path.splitext(arg) |
118 if ext == '.ll': | 118 if ext == '.ll': |
119 bitcode = arg | 119 bitcode = arg |
120 else: | 120 else: |
121 # Use pnacl-clang and pnacl-opt to produce PNaCl bitcode. | 121 # Use pnacl-clang and pnacl-opt to produce PNaCl bitcode. |
122 bitcode_nonfinal = os.path.join(args.dir, base + '.' + key + '.bc') | 122 bitcode_nonfinal = os.path.join(args.dir, base + '.' + key + '.bc') |
123 bitcode = os.path.join(args.dir, base + '.' + key + '.pnacl.ll') | 123 bitcode = os.path.join(args.dir, base + '.' + key + '.pnacl.ll') |
124 shellcmd(['{bin}/pnacl-clang'.format(bin=bindir), | 124 shellcmd(['{bin}/pnacl-clang'.format(bin=bindir), |
125 ('-O2' if args.clang_opt else '-O0'), '-c', arg, | 125 ('-O2' if args.clang_opt else '-O0'), |
| 126 ('-DARM32' if args.target == 'arm32' else ''), '-c', arg, |
126 '-o', bitcode_nonfinal]) | 127 '-o', bitcode_nonfinal]) |
127 shellcmd(['{bin}/pnacl-opt'.format(bin=bindir), | 128 shellcmd(['{bin}/pnacl-opt'.format(bin=bindir), |
128 '-pnacl-abi-simplify-preopt', | 129 '-pnacl-abi-simplify-preopt', |
129 '-pnacl-abi-simplify-postopt', | 130 '-pnacl-abi-simplify-postopt', |
130 '-pnaclabi-allow-debug-metadata', | 131 '-pnaclabi-allow-debug-metadata', |
131 bitcode_nonfinal, '-S', '-o', bitcode]) | 132 bitcode_nonfinal, '-S', '-o', bitcode]) |
132 | 133 |
133 base_sz = '{base}.{key}'.format(base=base, key=key) | 134 base_sz = '{base}.{key}'.format(base=base, key=key) |
134 asm_sz = os.path.join(args.dir, base_sz + '.sz.s') | 135 asm_sz = os.path.join(args.dir, base_sz + '.sz.s') |
135 obj_sz = os.path.join(args.dir, base_sz + '.sz.o') | 136 obj_sz = os.path.join(args.dir, base_sz + '.sz.o') |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
178 objs.append(( | 179 objs.append(( |
179 '{root}/toolchain_build/src/subzero/build/runtime/' + | 180 '{root}/toolchain_build/src/subzero/build/runtime/' + |
180 'szrt_{sb}_' + args.target + '.o' | 181 'szrt_{sb}_' + args.target + '.o' |
181 ).format(root=nacl_root, sb='sb' if args.sandbox else 'native')) | 182 ).format(root=nacl_root, sb='sb' if args.sandbox else 'native')) |
182 pure_c = os.path.splitext(args.driver)[1] == '.c' | 183 pure_c = os.path.splitext(args.driver)[1] == '.c' |
183 | 184 |
184 # TargetX8664 is ilp32, but clang does not currently support such | 185 # TargetX8664 is ilp32, but clang does not currently support such |
185 # configuration. In order to run the crosstests we play nasty, dangerous | 186 # configuration. In order to run the crosstests we play nasty, dangerous |
186 # tricks with the stack pointer. | 187 # tricks with the stack pointer. |
187 needs_stack_hack = (args.target == 'x8664') | 188 needs_stack_hack = (args.target == 'x8664') |
188 stack_hack_params = [] | 189 target_params = [] |
189 if needs_stack_hack: | 190 if needs_stack_hack: |
190 shellcmd('{bin}/clang -g -o stack_hack.x8664.{key}.o -c ' | 191 shellcmd('{bin}/clang -g -o stack_hack.x8664.{key}.o -c ' |
191 'stack_hack.x8664.c'.format(bin=bindir, key=key)) | 192 'stack_hack.x8664.c'.format(bin=bindir, key=key)) |
192 stack_hack_params.append('-DX8664_STACK_HACK') | 193 target_params.append('-DX8664_STACK_HACK') |
193 stack_hack_params.append('stack_hack.x8664.{key}.o'.format(key=key)) | 194 target_params.append('stack_hack.x8664.{key}.o'.format(key=key)) |
| 195 |
| 196 if args.target == 'arm32': |
| 197 target_params.append('-DARM32') |
| 198 target_params.append('-static') |
194 | 199 |
195 # Set compiler to clang, clang++, pnacl-clang, or pnacl-clang++. | 200 # Set compiler to clang, clang++, pnacl-clang, or pnacl-clang++. |
196 compiler = '{bin}/{prefix}{cc}'.format( | 201 compiler = '{bin}/{prefix}{cc}'.format( |
197 bin=bindir, prefix='pnacl-' if args.sandbox else '', | 202 bin=bindir, prefix='pnacl-' if args.sandbox else '', |
198 cc='clang' if pure_c else 'clang++') | 203 cc='clang' if pure_c else 'clang++') |
199 sb_native_args = (['-O0', '--pnacl-allow-native', | 204 sb_native_args = (['-O0', '--pnacl-allow-native', |
200 '-arch', target_info.target, | 205 '-arch', target_info.target, |
201 '-Wn,-defsym=__Sz_AbsoluteZero=0'] | 206 '-Wn,-defsym=__Sz_AbsoluteZero=0'] |
202 if args.sandbox else | 207 if args.sandbox else |
203 ['-g', '-target=' + triple, | 208 ['-g', '-target=' + triple, |
204 '-lm', '-lpthread', | 209 '-lm', '-lpthread', |
205 '-Wl,--defsym=__Sz_AbsoluteZero=0'] + | 210 '-Wl,--defsym=__Sz_AbsoluteZero=0'] + |
206 target_info.cross_headers) | 211 target_info.cross_headers) |
207 shellcmd([compiler] + stack_hack_params + [args.driver] + objs + | 212 shellcmd([compiler] + target_params + [args.driver] + objs + |
208 ['-o', os.path.join(args.dir, args.output)] + sb_native_args) | 213 ['-o', os.path.join(args.dir, args.output)] + sb_native_args) |
209 | 214 |
210 if __name__ == '__main__': | 215 if __name__ == '__main__': |
211 main() | 216 main() |
OLD | NEW |