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

Side by Side Diff: pydir/crosstest.py

Issue 892803002: Subzero: Add a --elf arg to szbuild.py and crosstest.py. (Closed) Base URL: https://chromium.googlesource.com/native_client/pnacl-subzero.git@master
Patch Set: Created 5 years, 10 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 | « no previous file | pydir/szbuild.py » ('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 os 4 import os
5 import re 5 import re
6 import subprocess 6 import subprocess
7 import sys 7 import sys
8 import tempfile 8 import tempfile
9 9
10 from utils import shellcmd 10 from utils import shellcmd
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
58 argparser.add_argument('--dir', required=False, default='.', 58 argparser.add_argument('--dir', required=False, default='.',
59 metavar='OUTPUT_DIR', 59 metavar='OUTPUT_DIR',
60 help='Output directory for all files.' + 60 help='Output directory for all files.' +
61 ' Default "%(default)s".') 61 ' Default "%(default)s".')
62 argparser.add_argument('--crosstest-bitcode', required=False, 62 argparser.add_argument('--crosstest-bitcode', required=False,
63 default=1, type=int, 63 default=1, type=int,
64 help='Compile non-subzero crosstest object file ' + 64 help='Compile non-subzero crosstest object file ' +
65 'from the same bitcode as the subzero object. ' + 65 'from the same bitcode as the subzero object. ' +
66 'If 0, then compile it straight from source.' + 66 'If 0, then compile it straight from source.' +
67 ' Default %(default)d.') 67 ' Default %(default)d.')
68 argparser.add_argument('--elf', dest='elf',
69 action='store_true',
70 help='Directly generate ELF output')
68 args = argparser.parse_args() 71 args = argparser.parse_args()
69 72
70 nacl_root = FindBaseNaCl() 73 nacl_root = FindBaseNaCl()
71 # Prepend PNaCl bin to $PATH. 74 # Prepend PNaCl bin to $PATH.
72 os.environ['PATH'] = nacl_root + \ 75 os.environ['PATH'] = nacl_root + \
73 '/toolchain/linux_x86/pnacl_newlib/bin' + \ 76 '/toolchain/linux_x86/pnacl_newlib/bin' + \
74 os.pathsep + os.environ['PATH'] 77 os.pathsep + os.environ['PATH']
75 78
76 objs = [] 79 objs = []
77 remove_internal = re.compile('^define internal ') 80 remove_internal = re.compile('^define internal ')
(...skipping 20 matching lines...) Expand all
98 base_sz = '%s.O%s.%s.%s' % (base, args.optlevel, args.attr, args.target) 101 base_sz = '%s.O%s.%s.%s' % (base, args.optlevel, args.attr, args.target)
99 asm_sz = os.path.join(args.dir, base_sz + '.sz.s') 102 asm_sz = os.path.join(args.dir, base_sz + '.sz.s')
100 obj_sz = os.path.join(args.dir, base_sz + '.sz.o') 103 obj_sz = os.path.join(args.dir, base_sz + '.sz.o')
101 obj_llc = os.path.join(args.dir, base + '.llc.o') 104 obj_llc = os.path.join(args.dir, base + '.llc.o')
102 shellcmd(['../llvm2ice', 105 shellcmd(['../llvm2ice',
103 '-O' + args.optlevel, 106 '-O' + args.optlevel,
104 '-mattr=' + args.attr, 107 '-mattr=' + args.attr,
105 '--target=' + args.target, 108 '--target=' + args.target,
106 '--prefix=' + args.prefix, 109 '--prefix=' + args.prefix,
107 '-allow-uninitialized-globals', 110 '-allow-uninitialized-globals',
108 '-o=' + asm_sz, 111 '-o=' + (obj_sz if args.elf else asm_sz),
109 bitcode]) 112 bitcode] +
110 shellcmd(['llvm-mc', 113 (['-elf-writer'] if args.elf else []))
111 '-arch=' + arch_map[args.target], 114 if not args.elf:
112 '-filetype=obj', 115 shellcmd(['llvm-mc',
113 '-o=' + obj_sz, 116 '-arch=' + arch_map[args.target],
114 asm_sz]) 117 '-filetype=obj',
118 '-o=' + obj_sz,
119 asm_sz])
115 objs.append(obj_sz) 120 objs.append(obj_sz)
116 # Each original bitcode file needs to be translated by the 121 # Each original bitcode file needs to be translated by the
117 # LLVM toolchain and have its object file linked in. There 122 # LLVM toolchain and have its object file linked in. There
118 # are two ways to do this: explicitly use llc, or include the 123 # are two ways to do this: explicitly use llc, or include the
119 # .ll file in the link command. It turns out that these two 124 # .ll file in the link command. It turns out that these two
120 # approaches can produce different semantics on some undefined 125 # approaches can produce different semantics on some undefined
121 # bitcode behavior. Specifically, LLVM produces different 126 # bitcode behavior. Specifically, LLVM produces different
122 # results for overflowing fptoui instructions for i32 and i64 127 # results for overflowing fptoui instructions for i32 and i64
123 # on x86-32. As it turns out, Subzero lowering was based on 128 # on x86-32. As it turns out, Subzero lowering was based on
124 # inspecting the object code produced by the direct llc 129 # inspecting the object code produced by the direct llc
(...skipping 18 matching lines...) Expand all
143 objs.append(( 148 objs.append((
144 '{root}/toolchain_build/src/subzero/runtime/szrt.{ext}' 149 '{root}/toolchain_build/src/subzero/runtime/szrt.{ext}'
145 ).format(root=nacl_root, ext='c' if pure_c else 'cpp')) 150 ).format(root=nacl_root, ext='c' if pure_c else 'cpp'))
146 objs.append(( 151 objs.append((
147 '{root}/toolchain_build/src/subzero/runtime/szrt_i686.ll' 152 '{root}/toolchain_build/src/subzero/runtime/szrt_i686.ll'
148 ).format(root=nacl_root)) 153 ).format(root=nacl_root))
149 linker = 'clang' if pure_c else 'clang++' 154 linker = 'clang' if pure_c else 'clang++'
150 shellcmd([linker, '-g', '-m32', args.driver] + 155 shellcmd([linker, '-g', '-m32', args.driver] +
151 objs + 156 objs +
152 ['-lm', '-lpthread', '-o', os.path.join(args.dir, args.output)]) 157 ['-lm', '-lpthread', '-o', os.path.join(args.dir, args.output)])
OLDNEW
« no previous file with comments | « no previous file | pydir/szbuild.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698