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 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 |
| 11 from utils import shellcmd, FindBaseNaCl, get_sfi_string | 11 from utils import GetObjcopyCmd, shellcmd, FindBaseNaCl, get_sfi_string |
|
Jim Stichnoth
2016/03/09 22:41:13
I would say alphabetize these, even though they we
Sean Klein
2016/03/09 22:59:22
ASCII alphabetized (uppercase before lowercase).
| |
| 12 | 12 |
| 13 def main(): | 13 def main(): |
| 14 """Builds a cross-test binary for comparing Subzero and llc translation. | 14 """Builds a cross-test binary for comparing Subzero and llc translation. |
| 15 | 15 |
| 16 Each --test argument is compiled once by llc and once by Subzero. C/C++ | 16 Each --test argument is compiled once by llc and once by Subzero. C/C++ |
| 17 tests are first compiled down to PNaCl bitcode using pnacl-clang and | 17 tests are first compiled down to PNaCl bitcode using pnacl-clang and |
| 18 pnacl-opt. The --prefix argument ensures that symbol names are different | 18 pnacl-opt. The --prefix argument ensures that symbol names are different |
| 19 between the two object files, to avoid linking errors. | 19 between the two object files, to avoid linking errors. |
| 20 | 20 |
| 21 There is also a --driver argument that specifies the C/C++ file that calls | 21 There is also a --driver argument that specifies the C/C++ file that calls |
| (...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 159 asm_sz]) | 159 asm_sz]) |
| 160 | 160 |
| 161 # Each separately translated Subzero object file contains its own | 161 # Each separately translated Subzero object file contains its own |
| 162 # definition of the __Sz_block_profile_info profiling symbol. Avoid | 162 # definition of the __Sz_block_profile_info profiling symbol. Avoid |
| 163 # linker errors (multiply defined symbol) by making all copies weak. | 163 # linker errors (multiply defined symbol) by making all copies weak. |
| 164 # (This could also be done by Subzero if it supported weak symbol | 164 # (This could also be done by Subzero if it supported weak symbol |
| 165 # definitions.) This approach should be OK because cross tests are | 165 # definitions.) This approach should be OK because cross tests are |
| 166 # currently the only situation where multiple translated files are | 166 # currently the only situation where multiple translated files are |
| 167 # linked into the executable, but when PNaCl supports shared nexe | 167 # linked into the executable, but when PNaCl supports shared nexe |
| 168 # libraries, this would need to change. | 168 # libraries, this would need to change. |
| 169 shellcmd(['{bin}/le32-nacl-objcopy'.format(bin=bindir), | 169 shellcmd([('{bin}/' + GetObjcopyCmd()).format(bin=bindir), |
| 170 '--weaken-symbol=__Sz_block_profile_info', | 170 '--weaken-symbol=__Sz_block_profile_info', |
| 171 '--strip-symbol=nacl_tp_tdb_offset', | 171 '--strip-symbol=nacl_tp_tdb_offset', |
| 172 '--strip-symbol=nacl_tp_tls_offset', | 172 '--strip-symbol=nacl_tp_tls_offset', |
| 173 obj_sz]) | 173 obj_sz]) |
| 174 objs.append(obj_sz) | 174 objs.append(obj_sz) |
| 175 shellcmd(['{bin}/pnacl-llc'.format(bin=bindir), | 175 shellcmd(['{bin}/pnacl-llc'.format(bin=bindir), |
| 176 '-arm-enable-dwarf-eh=1', | 176 '-arm-enable-dwarf-eh=1', |
| 177 '-mtriple=' + triple, | 177 '-mtriple=' + triple, |
| 178 '-externalize', | 178 '-externalize', |
| 179 '-filetype=obj', | 179 '-filetype=obj', |
| 180 '-bitcode-format=llvm', | 180 '-bitcode-format=llvm', |
| 181 '-o=' + obj_llc, | 181 '-o=' + obj_llc, |
| 182 bitcode] + llc_flags) | 182 bitcode] + llc_flags) |
| 183 shellcmd(['{bin}/le32-nacl-objcopy'.format(bin=bindir), | 183 shellcmd([('{bin}/' + GetObjcopyCmd()).format(bin=bindir), |
| 184 '--weaken-symbol=__Sz_block_profile_info', | 184 '--weaken-symbol=__Sz_block_profile_info', |
| 185 '--strip-symbol=nacl_tp_tdb_offset', | 185 '--strip-symbol=nacl_tp_tdb_offset', |
| 186 '--strip-symbol=nacl_tp_tls_offset', | 186 '--strip-symbol=nacl_tp_tls_offset', |
| 187 obj_llc]) | 187 obj_llc]) |
| 188 objs.append(obj_llc) | 188 objs.append(obj_llc) |
| 189 | 189 |
| 190 # Add szrt_sb_${target}.o or szrt_native_${target}.o. | 190 # Add szrt_sb_${target}.o or szrt_native_${target}.o. |
| 191 if not args.nonsfi: | 191 if not args.nonsfi: |
| 192 objs.append(( | 192 objs.append(( |
| 193 '{root}/toolchain_build/src/subzero/build/runtime/' + | 193 '{root}/toolchain_build/src/subzero/build/runtime/' + |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 245 shellcmd(['{bin}/pnacl-llc'.format(bin=bindir), | 245 shellcmd(['{bin}/pnacl-llc'.format(bin=bindir), |
| 246 '-arm-enable-dwarf-eh=1', | 246 '-arm-enable-dwarf-eh=1', |
| 247 '-mtriple=' + triple, | 247 '-mtriple=' + triple, |
| 248 '-externalize', | 248 '-externalize', |
| 249 '-filetype=obj', | 249 '-filetype=obj', |
| 250 '-O2', | 250 '-O2', |
| 251 '-bitcode-format=llvm', | 251 '-bitcode-format=llvm', |
| 252 '-o', obj_llc, | 252 '-o', obj_llc, |
| 253 bitcode] + llc_flags) | 253 bitcode] + llc_flags) |
| 254 if not args.sandbox and not args.nonsfi: | 254 if not args.sandbox and not args.nonsfi: |
| 255 shellcmd(['{bin}/le32-nacl-objcopy'.format(bin=bindir), | 255 shellcmd([('{bin}/' + GetObjcopyCmd()).format(bin=bindir), |
| 256 '--redefine-sym', '_start=_user_start', | 256 '--redefine-sym', '_start=_user_start', |
| 257 obj_llc | 257 obj_llc |
| 258 ]) | 258 ]) |
| 259 objs.append(obj_llc) | 259 objs.append(obj_llc) |
| 260 if args.nonsfi: | 260 if args.nonsfi: |
| 261 LinkNonsfi(objs, os.path.join(args.dir, args.output), args.target) | 261 LinkNonsfi(objs, os.path.join(args.dir, args.output), args.target) |
| 262 elif args.sandbox: | 262 elif args.sandbox: |
| 263 LinkSandbox(objs, os.path.join(args.dir, args.output), args.target) | 263 LinkSandbox(objs, os.path.join(args.dir, args.output), args.target) |
| 264 else: | 264 else: |
| 265 LinkNative(objs, os.path.join(args.dir, args.output), args.target) | 265 LinkNative(objs, os.path.join(args.dir, args.output), args.target) |
| 266 | 266 |
| 267 if __name__ == '__main__': | 267 if __name__ == '__main__': |
| 268 main() | 268 main() |
| OLD | NEW |