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

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