Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(84)

Side by Side Diff: pydir/run-pnacl-sz.py

Issue 1085733002: Subzero: Auto-detect cmake versus autoconf LLVM build. (Closed) Base URL: https://chromium.googlesource.com/native_client/pnacl-subzero.git@master
Patch Set: Fix the sb build libs Created 5 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « crosstest/lit.cfg ('k') | tests_lit/lit.cfg » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 #!/usr/bin/env python2 1 #!/usr/bin/env python2
2 2
3 import argparse 3 import argparse
4 import itertools 4 import itertools
5 import os 5 import os
6 import re 6 import re
7 import subprocess 7 import subprocess
8 import sys 8 import sys
9 import tempfile 9 import tempfile
10 10
(...skipping 22 matching lines...) Expand all
33 help='Parse pexe into llvm IR first, then ' + 33 help='Parse pexe into llvm IR first, then ' +
34 'convert to Subzero') 34 'convert to Subzero')
35 argparser.add_argument('--llvm-source', required=False, 35 argparser.add_argument('--llvm-source', required=False,
36 action='store_true', 36 action='store_true',
37 help='Parse source directly into llvm IR ' + 37 help='Parse source directly into llvm IR ' +
38 '(without generating a pexe), then ' + 38 '(without generating a pexe), then ' +
39 'convert to Subzero') 39 'convert to Subzero')
40 argparser.add_argument( 40 argparser.add_argument(
41 '--pnacl-sz', required=False, default='./pnacl-sz', metavar='PNACL-SZ', 41 '--pnacl-sz', required=False, default='./pnacl-sz', metavar='PNACL-SZ',
42 help="Subzero translator 'pnacl-sz'") 42 help="Subzero translator 'pnacl-sz'")
43 argparser.add_argument('--llvm-bin-path', required=False, 43 argparser.add_argument('--pnacl-bin-path', required=False,
44 default=None, metavar='LLVM_BIN_PATH', 44 default=None, metavar='PNACL_BIN_PATH',
45 help='Path to LLVM executables ' + 45 help='Path to LLVM & Binutils executables ' +
46 '(for building PEXE files)') 46 '(e.g. for building PEXE files)')
47 argparser.add_argument('--binutils-bin-path', required=False,
48 default=None, metavar='BINUTILS_BIN_PATH',
49 help='Path to Binutils executables')
50 argparser.add_argument('--assemble', required=False, 47 argparser.add_argument('--assemble', required=False,
51 action='store_true', 48 action='store_true',
52 help='Assemble the output') 49 help='Assemble the output')
53 argparser.add_argument('--disassemble', required=False, 50 argparser.add_argument('--disassemble', required=False,
54 action='store_true', 51 action='store_true',
55 help='Disassemble the assembled output') 52 help='Disassemble the assembled output')
56 argparser.add_argument('--dis-flags', required=False, 53 argparser.add_argument('--dis-flags', required=False,
57 action='append', default=[], 54 action='append', default=[],
58 help='Add a disassembler flag') 55 help='Add a disassembler flag')
59 argparser.add_argument('--filetype', default='iasm', dest='filetype', 56 argparser.add_argument('--filetype', default='iasm', dest='filetype',
60 choices=['obj', 'asm', 'iasm'], 57 choices=['obj', 'asm', 'iasm'],
61 help='Output file type. Default %(default)s.') 58 help='Output file type. Default %(default)s.')
62 argparser.add_argument('--echo-cmd', required=False, 59 argparser.add_argument('--echo-cmd', required=False,
63 action='store_true', 60 action='store_true',
64 help='Trace command that generates ICE instructions') 61 help='Trace command that generates ICE instructions')
65 argparser.add_argument('--args', '-a', nargs=argparse.REMAINDER, 62 argparser.add_argument('--args', '-a', nargs=argparse.REMAINDER,
66 default=[], 63 default=[],
67 help='Remaining arguments are passed to pnacl-sz') 64 help='Remaining arguments are passed to pnacl-sz')
68 65
69 args = argparser.parse_args() 66 args = argparser.parse_args()
70 llvm_bin_path = args.llvm_bin_path 67 pnacl_bin_path = args.pnacl_bin_path
71 binutils_bin_path = args.binutils_bin_path
72 llfile = args.input 68 llfile = args.input
73 69
74 if args.llvm and args.llvm_source: 70 if args.llvm and args.llvm_source:
75 raise RuntimeError("Can't specify both '--llvm' and '--llvm-source'") 71 raise RuntimeError("Can't specify both '--llvm' and '--llvm-source'")
76 72
77 if args.llvm_source and args.no_local_syms: 73 if args.llvm_source and args.no_local_syms:
78 raise RuntimeError("Can't specify both '--llvm-source' and " + 74 raise RuntimeError("Can't specify both '--llvm-source' and " +
79 "'--no-local-syms'") 75 "'--no-local-syms'")
80 76
81 cmd = [] 77 cmd = []
82 if not args.llvm_source: 78 if not args.llvm_source:
83 cmd = [os.path.join(llvm_bin_path, 'llvm-as'), llfile, '-o', '-', '|', 79 cmd = [os.path.join(pnacl_bin_path, 'llvm-as'), llfile, '-o', '-', '|',
84 os.path.join(llvm_bin_path, 'pnacl-freeze')] 80 os.path.join(pnacl_bin_path, 'pnacl-freeze')]
85 if not args.no_local_syms: 81 if not args.no_local_syms:
86 cmd += ['--allow-local-symbol-tables'] 82 cmd += ['--allow-local-symbol-tables']
87 cmd += ['|'] 83 cmd += ['|']
88 cmd += [args.pnacl_sz] 84 cmd += [args.pnacl_sz]
89 if args.insts: 85 if args.insts:
90 # If the tests are based on '-verbose inst' output, force 86 # If the tests are based on '-verbose inst' output, force
91 # single-threaded translation because dump output does not get 87 # single-threaded translation because dump output does not get
92 # reassembled into order. 88 # reassembled into order.
93 cmd += ['-verbose', 'inst', '-notranslate', '-threads=0'] 89 cmd += ['-verbose', 'inst', '-notranslate', '-threads=0']
94 if not args.llvm_source: 90 if not args.llvm_source:
95 cmd += ['--bitcode-format=pnacl'] 91 cmd += ['--bitcode-format=pnacl']
96 if not args.no_local_syms: 92 if not args.no_local_syms:
97 cmd += ['--allow-local-symbol-tables'] 93 cmd += ['--allow-local-symbol-tables']
98 if args.llvm or args.llvm_source: 94 if args.llvm or args.llvm_source:
99 cmd += ['--build-on-read=0'] 95 cmd += ['--build-on-read=0']
100 else: 96 else:
101 cmd += ['--build-on-read=1'] 97 cmd += ['--build-on-read=1']
102 cmd += ['--filetype=' + args.filetype] 98 cmd += ['--filetype=' + args.filetype]
103 cmd += args.args 99 cmd += args.args
104 if args.llvm_source: 100 if args.llvm_source:
105 cmd += [llfile] 101 cmd += [llfile]
106 asm_temp = None 102 asm_temp = None
107 if args.assemble or args.disassemble: 103 if args.assemble or args.disassemble:
108 # On windows we may need to close the file first before it can be 104 # On windows we may need to close the file first before it can be
109 # re-opened by the other tools, so don't do delete-on-close, 105 # re-opened by the other tools, so don't do delete-on-close,
110 # and instead manually delete. 106 # and instead manually delete.
111 asm_temp = tempfile.NamedTemporaryFile(delete=False) 107 asm_temp = tempfile.NamedTemporaryFile(delete=False)
112 asm_temp.close() 108 asm_temp.close()
113 if args.assemble and args.filetype != 'obj': 109 if args.assemble and args.filetype != 'obj':
114 cmd += ['|', os.path.join(llvm_bin_path, 'llvm-mc'), 110 cmd += ['|', os.path.join(pnacl_bin_path, 'llvm-mc'),
115 # TODO(stichnot): -triple=i686-nacl should be used for a 111 # TODO(stichnot): -triple=i686-nacl should be used for a
116 # sandboxing test. This means there should be an args.sandbox 112 # sandboxing test. This means there should be an args.sandbox
117 # argument that also gets passed through to pnacl-sz. 113 # argument that also gets passed through to pnacl-sz.
118 '-triple=i686', 114 '-triple=i686',
119 '-filetype=obj', '-o', asm_temp.name] 115 '-filetype=obj', '-o', asm_temp.name]
120 elif asm_temp: 116 elif asm_temp:
121 cmd += ['-o', asm_temp.name] 117 cmd += ['-o', asm_temp.name]
122 if args.disassemble: 118 if args.disassemble:
123 # Show wide instruction encodings, diassemble, and show relocs. 119 # Show wide instruction encodings, diassemble, and show relocs.
124 cmd += (['&&', os.path.join(binutils_bin_path, 'le32-nacl-objdump')] + 120 cmd += (['&&', os.path.join(pnacl_bin_path, 'le32-nacl-objdump')] +
125 args.dis_flags + 121 args.dis_flags +
126 ['-w', '-d', '-r', '-Mintel', asm_temp.name]) 122 ['-w', '-d', '-r', '-Mintel', asm_temp.name])
127 123
128 stdout_result = shellcmd(cmd, echo=args.echo_cmd) 124 stdout_result = shellcmd(cmd, echo=args.echo_cmd)
129 if not args.echo_cmd: 125 if not args.echo_cmd:
130 sys.stdout.write(stdout_result) 126 sys.stdout.write(stdout_result)
131 if asm_temp: 127 if asm_temp:
132 os.remove(asm_temp.name) 128 os.remove(asm_temp.name)
133 129
134 if __name__ == '__main__': 130 if __name__ == '__main__':
135 main() 131 main()
OLDNEW
« no previous file with comments | « crosstest/lit.cfg ('k') | tests_lit/lit.cfg » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698