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

Side by Side Diff: pydir/build-runtime.py

Issue 1777103002: Eliminate all uses of 'le32-nacl-objcopy'. (Closed) Base URL: https://chromium.googlesource.com/native_client/pnacl-subzero.git@master
Patch Set: Created 4 years, 9 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/crosstest.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 shutil 5 import shutil
6 import tempfile 6 import tempfile
7 7
8 import targets 8 import targets
9 from utils import GetObjcopyCmd
Jim Stichnoth 2016/03/09 23:15:24 Maybe put these 3 on a single sorted line like the
Sean Klein 2016/03/09 23:20:20 Done.
9 from utils import shellcmd 10 from utils import shellcmd
10 from utils import FindBaseNaCl 11 from utils import FindBaseNaCl
11 12
12 13
13 def Translate(ll_files, extra_args, obj, verbose): 14 def Translate(ll_files, extra_args, obj, verbose):
14 """Translate a set of input bitcode files into a single object file. 15 """Translate a set of input bitcode files into a single object file.
15 16
16 Use pnacl-llc to translate textual bitcode input ll_files into object file 17 Use pnacl-llc to translate textual bitcode input ll_files into object file
17 obj, using extra_args as the architectural flags. 18 obj, using extra_args as the architectural flags.
18 """ 19 """
19 shellcmd(['cat'] + ll_files + ['|', 20 shellcmd(['cat'] + ll_files + ['|',
20 'pnacl-llc', 21 'pnacl-llc',
21 '-externalize', 22 '-externalize',
22 '-function-sections', 23 '-function-sections',
23 '-O2', 24 '-O2',
24 '-filetype=obj', 25 '-filetype=obj',
25 '-bitcode-format=llvm', 26 '-bitcode-format=llvm',
26 '-arm-enable-dwarf-eh=1', 27 '-arm-enable-dwarf-eh=1',
27 '-o', obj 28 '-o', obj
28 ] + extra_args, echo=verbose) 29 ] + extra_args, echo=verbose)
29 shellcmd(['le32-nacl-objcopy', 30 shellcmd([GetObjcopyCmd(),
30 '--strip-symbol=nacl_tp_tdb_offset', 31 '--strip-symbol=nacl_tp_tdb_offset',
31 '--strip-symbol=nacl_tp_tls_offset', 32 '--strip-symbol=nacl_tp_tls_offset',
32 obj 33 obj
33 ], echo=verbose) 34 ], echo=verbose)
34 35
35 36
36 def PartialLink(obj_files, extra_args, lib, verbose): 37 def PartialLink(obj_files, extra_args, lib, verbose):
37 """Partially links a set of obj files into a final obj library.""" 38 """Partially links a set of obj files into a final obj library."""
38 shellcmd(['le32-nacl-ld', 39 shellcmd(['le32-nacl-ld',
39 '-o', lib, 40 '-o', lib,
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
75 '{srcdir}/szrt_asm_{target}.s'.format( 76 '{srcdir}/szrt_asm_{target}.s'.format(
76 srcdir=srcdir, target=target_info.target) 77 srcdir=srcdir, target=target_info.target)
77 ], echo=verbose) 78 ], echo=verbose)
78 # Write full szrt_native_{target}.o. 79 # Write full szrt_native_{target}.o.
79 PartialLink([TmpFile('{dir}/szrt_native_{target}.tmp.o'), 80 PartialLink([TmpFile('{dir}/szrt_native_{target}.tmp.o'),
80 TmpFile('{dir}/szrt_native_asm_{target}.o'), 81 TmpFile('{dir}/szrt_native_asm_{target}.o'),
81 TmpFile('{dir}/szrt_native_profiler_{target}.o')], 82 TmpFile('{dir}/szrt_native_profiler_{target}.o')],
82 ['-m {ld_emu}'.format(ld_emu=target_info.ld_emu)], 83 ['-m {ld_emu}'.format(ld_emu=target_info.ld_emu)],
83 OutFile('{rtdir}/szrt_native_{target}.o'), 84 OutFile('{rtdir}/szrt_native_{target}.o'),
84 verbose) 85 verbose)
85 shellcmd(['le32-nacl-objcopy', 86 shellcmd([GetObjcopyCmd(),
86 '--strip-symbol=NATIVE', 87 '--strip-symbol=NATIVE',
87 OutFile('{rtdir}/szrt_native_{target}.o')]) 88 OutFile('{rtdir}/szrt_native_{target}.o')])
88 89
89 # Helper function for building the sandboxed runtime. 90 # Helper function for building the sandboxed runtime.
90 def MakeSandboxedRuntime(): 91 def MakeSandboxedRuntime():
91 """Builds just the sandboxed runtime.""" 92 """Builds just the sandboxed runtime."""
92 # Translate tempdir/szrt.ll and tempdir/szrt_ll.ll to szrt_sb_{target}.o. 93 # Translate tempdir/szrt.ll and tempdir/szrt_ll.ll to szrt_sb_{target}.o.
93 # The sandboxed library does not get the profiler helper function as the 94 # The sandboxed library does not get the profiler helper function as the
94 # binaries are linked with -nostdlib. 95 # binaries are linked with -nostdlib.
95 Translate(ll_files, 96 Translate(ll_files,
96 ['-mtriple=' + targets.ConvertTripleToNaCl(target_info.triple)] + 97 ['-mtriple=' + targets.ConvertTripleToNaCl(target_info.triple)] +
97 target_info.llc_flags, 98 target_info.llc_flags,
98 TmpFile('{dir}/szrt_sb_{target}.tmp.o'), 99 TmpFile('{dir}/szrt_sb_{target}.tmp.o'),
99 verbose) 100 verbose)
100 # Assemble srcdir/szrt_asm_{target}.s to tempdir/szrt_asm_{target}.o. 101 # Assemble srcdir/szrt_asm_{target}.s to tempdir/szrt_asm_{target}.o.
101 shellcmd(['llvm-mc', 102 shellcmd(['llvm-mc',
102 '-triple=' + targets.ConvertTripleToNaCl(target_info.triple), 103 '-triple=' + targets.ConvertTripleToNaCl(target_info.triple),
103 '--defsym NACL=1', 104 '--defsym NACL=1',
104 '-filetype=obj', 105 '-filetype=obj',
105 '-o', TmpFile('{dir}/szrt_sb_asm_{target}.o'), 106 '-o', TmpFile('{dir}/szrt_sb_asm_{target}.o'),
106 '{srcdir}/szrt_asm_{target}.s'.format( 107 '{srcdir}/szrt_asm_{target}.s'.format(
107 srcdir=srcdir, target=target_info.target) 108 srcdir=srcdir, target=target_info.target)
108 ], echo=verbose) 109 ], echo=verbose)
109 PartialLink([TmpFile('{dir}/szrt_sb_{target}.tmp.o'), 110 PartialLink([TmpFile('{dir}/szrt_sb_{target}.tmp.o'),
110 TmpFile('{dir}/szrt_sb_asm_{target}.o')], 111 TmpFile('{dir}/szrt_sb_asm_{target}.o')],
111 ['-m {ld_emu}'.format(ld_emu=target_info.sb_emu)], 112 ['-m {ld_emu}'.format(ld_emu=target_info.sb_emu)],
112 OutFile('{rtdir}/szrt_sb_{target}.o'), 113 OutFile('{rtdir}/szrt_sb_{target}.o'),
113 verbose) 114 verbose)
114 shellcmd(['le32-nacl-objcopy', 115 shellcmd([GetObjcopyCmd(),
115 '--strip-symbol=NACL', 116 '--strip-symbol=NACL',
116 OutFile('{rtdir}/szrt_sb_{target}.o')]) 117 OutFile('{rtdir}/szrt_sb_{target}.o')])
117 118
118 # Helper function for building the Non-SFI runtime. 119 # Helper function for building the Non-SFI runtime.
119 def MakeNonsfiRuntime(): 120 def MakeNonsfiRuntime():
120 """Builds just the nonsfi runtime.""" 121 """Builds just the nonsfi runtime."""
121 # Translate tempdir/szrt.ll and tempdir/szrt_ll.ll to 122 # Translate tempdir/szrt.ll and tempdir/szrt_ll.ll to
122 # szrt_nonsfi_{target}.tmp.o. 123 # szrt_nonsfi_{target}.tmp.o.
123 Translate(ll_files, 124 Translate(ll_files,
124 ['-mtriple=' + target_info.triple] + target_info.llc_flags + 125 ['-mtriple=' + target_info.triple] + target_info.llc_flags +
125 ['-relocation-model=pic', '-force-tls-non-pic', '-malign-double'], 126 ['-relocation-model=pic', '-force-tls-non-pic', '-malign-double'],
126 TmpFile('{dir}/szrt_nonsfi_{target}.tmp.o'), 127 TmpFile('{dir}/szrt_nonsfi_{target}.tmp.o'),
127 verbose) 128 verbose)
128 # Assemble srcdir/szrt_asm_{target}.s to tempdir/szrt_asm_{target}.o. 129 # Assemble srcdir/szrt_asm_{target}.s to tempdir/szrt_asm_{target}.o.
129 shellcmd(['llvm-mc', 130 shellcmd(['llvm-mc',
130 '-triple=' + target_info.triple, '--defsym NONSFI=1', 131 '-triple=' + target_info.triple, '--defsym NONSFI=1',
131 '-filetype=obj', 132 '-filetype=obj',
132 '-o', TmpFile('{dir}/szrt_nonsfi_asm_{target}.o'), 133 '-o', TmpFile('{dir}/szrt_nonsfi_asm_{target}.o'),
133 '{srcdir}/szrt_asm_{target}.s'.format( 134 '{srcdir}/szrt_asm_{target}.s'.format(
134 srcdir=srcdir, target=target_info.target) 135 srcdir=srcdir, target=target_info.target)
135 ], echo=verbose) 136 ], echo=verbose)
136 # Write full szrt_nonsfi_{target}.o. 137 # Write full szrt_nonsfi_{target}.o.
137 PartialLink([TmpFile('{dir}/szrt_nonsfi_{target}.tmp.o'), 138 PartialLink([TmpFile('{dir}/szrt_nonsfi_{target}.tmp.o'),
138 TmpFile('{dir}/szrt_nonsfi_asm_{target}.o')], 139 TmpFile('{dir}/szrt_nonsfi_asm_{target}.o')],
139 ['-m {ld_emu}'.format(ld_emu=target_info.ld_emu)], 140 ['-m {ld_emu}'.format(ld_emu=target_info.ld_emu)],
140 OutFile('{rtdir}/szrt_nonsfi_{target}.o'), 141 OutFile('{rtdir}/szrt_nonsfi_{target}.o'),
141 verbose) 142 verbose)
142 shellcmd(['le32-nacl-objcopy', 143 shellcmd([GetObjcopyCmd(),
143 '--strip-symbol=NONSFI', 144 '--strip-symbol=NONSFI',
144 OutFile('{rtdir}/szrt_nonsfi_{target}.o')]) 145 OutFile('{rtdir}/szrt_nonsfi_{target}.o')])
145 146
146 147
147 # Run the helper functions. 148 # Run the helper functions.
148 MakeNativeRuntime() 149 MakeNativeRuntime()
149 MakeSandboxedRuntime() 150 MakeSandboxedRuntime()
150 MakeNonsfiRuntime() 151 MakeNonsfiRuntime()
151 152
152 153
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
207 208
208 finally: 209 finally:
209 try: 210 try:
210 shutil.rmtree(tempdir) 211 shutil.rmtree(tempdir)
211 except OSError as exc: 212 except OSError as exc:
212 if exc.errno != errno.ENOENT: # ENOENT - no such file or directory 213 if exc.errno != errno.ENOENT: # ENOENT - no such file or directory
213 raise # re-raise exception 214 raise # re-raise exception
214 215
215 if __name__ == '__main__': 216 if __name__ == '__main__':
216 main() 217 main()
OLDNEW
« no previous file with comments | « no previous file | pydir/crosstest.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698