OLD | NEW |
---|---|
1 #!/usr/bin/python | 1 #!/usr/bin/python |
2 # Copyright (c) 2012 The Native Client Authors. All rights reserved. | 2 # Copyright (c) 2012 The Native Client Authors. All rights reserved. |
3 # Use of this source code is governed by a BSD-style license that can be | 3 # Use of this source code is governed by a BSD-style license that can be |
4 # found in the LICENSE file. | 4 # found in the LICENSE file. |
5 | 5 |
6 """NaCl SDK tool SCons.""" | 6 """NaCl SDK tool SCons.""" |
7 | 7 |
8 import __builtin__ | 8 import __builtin__ |
9 import re | 9 import re |
10 import os | 10 import os |
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
169 elif env.Bit('host_mac'): | 169 elif env.Bit('host_mac'): |
170 arch = '%s-mac' % arch | 170 arch = '%s-mac' % arch |
171 if env.Bit('nonsfi_nacl'): | 171 if env.Bit('nonsfi_nacl'): |
172 arch += '-nonsfi' | 172 arch += '-nonsfi' |
173 arch_flag = ' -arch %s' % arch | 173 arch_flag = ' -arch %s' % arch |
174 if env.Bit('pnacl_generate_pexe'): | 174 if env.Bit('pnacl_generate_pexe'): |
175 ld_arch_flag = '' | 175 ld_arch_flag = '' |
176 else: | 176 else: |
177 ld_arch_flag = arch_flag | 177 ld_arch_flag = arch_flag |
178 | 178 |
179 llc_mtriple_flag = '' | |
180 if env.Bit('minsfi'): | |
181 llc_cpu = '' | |
182 if env.Bit('build_x86_32'): | |
183 llc_cpu = 'i686' | |
184 elif env.Bit('build_x86_64'): | |
185 llc_cpu = 'x86_64' | |
jvoung (off chromium)
2014/09/05 00:31:59
Not necessarily for this CL, but would be curious
dbrazdil
2014/09/05 19:41:36
Acknowledged.
| |
186 | |
187 if env.Bit('host_linux'): | |
188 llc_mtriple_flag = ' -mtriple=%s-linux-gnu' % llc_cpu | |
189 elif env.Bit('host_mac'): | |
190 llc_mtriple_flag = ' -mtriple=%s-apple-darwin' % llc_cpu | |
191 | |
179 translator_root = os.path.join(os.path.dirname(root), 'pnacl_translator') | 192 translator_root = os.path.join(os.path.dirname(root), 'pnacl_translator') |
180 | 193 |
181 binprefix = os.path.join(root, 'bin', 'pnacl-') | 194 binprefix = os.path.join(root, 'bin', 'pnacl-') |
182 binext = '' | 195 binext = '' |
183 if env.Bit('host_windows'): | 196 if env.Bit('host_windows'): |
184 binext = '.bat' | 197 binext = '.bat' |
185 | 198 |
186 pnacl_ar = binprefix + 'ar' + binext | 199 pnacl_ar = binprefix + 'ar' + binext |
187 pnacl_as = binprefix + 'as' + binext | 200 pnacl_as = binprefix + 'as' + binext |
188 pnacl_nm = binprefix + 'nm' + binext | 201 pnacl_nm = binprefix + 'nm' + binext |
189 pnacl_ranlib = binprefix + 'ranlib' + binext | 202 pnacl_ranlib = binprefix + 'ranlib' + binext |
190 # Use the standalone sandboxed translator in sbtc mode | 203 # Use the standalone sandboxed translator in sbtc mode |
191 if env.Bit('use_sandboxed_translator'): | 204 if env.Bit('use_sandboxed_translator'): |
192 pnacl_translate = os.path.join(translator_root, 'bin', | 205 pnacl_translate = os.path.join(translator_root, 'bin', |
193 'pnacl-translate' + binext) | 206 'pnacl-translate' + binext) |
194 else: | 207 else: |
195 pnacl_translate = binprefix + 'translate' + binext | 208 pnacl_translate = binprefix + 'translate' + binext |
196 | 209 |
197 pnacl_cc = binprefix + 'clang' + binext | 210 pnacl_cc = binprefix + 'clang' + binext |
198 pnacl_cxx = binprefix + 'clang++' + binext | 211 pnacl_cxx = binprefix + 'clang++' + binext |
199 | 212 |
200 pnacl_ld = binprefix + 'ld' + binext | 213 pnacl_ld = binprefix + 'ld' + binext |
201 pnacl_disass = binprefix + 'dis' + binext | 214 pnacl_disass = binprefix + 'dis' + binext |
202 pnacl_finalize = binprefix + 'finalize' + binext | 215 pnacl_finalize = binprefix + 'finalize' + binext |
203 pnacl_opt = binprefix + 'opt' + binext | 216 pnacl_opt = binprefix + 'opt' + binext |
204 pnacl_strip = binprefix + 'strip' + binext | 217 pnacl_strip = binprefix + 'strip' + binext |
218 pnacl_llc = binprefix + 'llc' + binext | |
205 | 219 |
206 # NOTE: XXX_flags start with space for easy concatenation | 220 # NOTE: XXX_flags start with space for easy concatenation |
207 # The flags generated here get baked into the commands (CC, CXX, LINK) | 221 # The flags generated here get baked into the commands (CC, CXX, LINK) |
208 # instead of CFLAGS etc to keep them from getting blown away by some | 222 # instead of CFLAGS etc to keep them from getting blown away by some |
209 # tests. Don't add flags here unless they always need to be preserved. | 223 # tests. Don't add flags here unless they always need to be preserved. |
210 pnacl_cxx_flags = '' | 224 pnacl_cxx_flags = '' |
211 pnacl_cc_flags = ' -std=gnu99' | 225 pnacl_cc_flags = ' -std=gnu99' |
212 pnacl_ld_flags = ' ' + ' '.join(env['PNACL_BCLDFLAGS']) | 226 pnacl_ld_flags = ' ' + ' '.join(env['PNACL_BCLDFLAGS']) |
213 pnacl_translate_flags = '' | 227 pnacl_translate_flags = '' |
228 pnacl_llc_flags = '' | |
214 | 229 |
215 if env.Bit('nacl_pic'): | 230 if env.Bit('nacl_pic'): |
216 pnacl_cc_flags += ' -fPIC' | 231 pnacl_cc_flags += ' -fPIC' |
217 pnacl_cxx_flags += ' -fPIC' | 232 pnacl_cxx_flags += ' -fPIC' |
218 # NOTE: this is a special hack for the pnacl backend which | 233 # NOTE: this is a special hack for the pnacl backend which |
219 # does more than linking | 234 # does more than linking |
220 pnacl_ld_flags += ' -fPIC' | 235 pnacl_ld_flags += ' -fPIC' |
221 pnacl_translate_flags += ' -fPIC' | 236 pnacl_translate_flags += ' -fPIC' |
222 | 237 |
238 if env.Bit('minsfi'): | |
239 pnacl_llc_flags += ' -relocation-model=pic -filetype=obj' | |
240 | |
223 if env.Bit('use_sandboxed_translator'): | 241 if env.Bit('use_sandboxed_translator'): |
224 sb_flags = ' --pnacl-sb' | 242 sb_flags = ' --pnacl-sb' |
225 pnacl_ld_flags += sb_flags | 243 pnacl_ld_flags += sb_flags |
226 pnacl_translate_flags += sb_flags | 244 pnacl_translate_flags += sb_flags |
227 | 245 |
228 if env.Bit('x86_64_zero_based_sandbox'): | 246 if env.Bit('x86_64_zero_based_sandbox'): |
229 pnacl_translate_flags += ' -sfi-zero-based-sandbox' | 247 pnacl_translate_flags += ' -sfi-zero-based-sandbox' |
230 | 248 |
231 env.Replace(# Replace header and lib paths. | 249 env.Replace(# Replace header and lib paths. |
232 NACL_SDK_INCLUDE=os.path.join(root, 'usr', 'include'), | 250 NACL_SDK_INCLUDE=os.path.join(root, 'usr', 'include'), |
(...skipping 21 matching lines...) Expand all Loading... | |
254 LD=pnacl_ld, | 272 LD=pnacl_ld, |
255 AR=pnacl_ar, | 273 AR=pnacl_ar, |
256 AS=pnacl_as + ld_arch_flag, | 274 AS=pnacl_as + ld_arch_flag, |
257 RANLIB=pnacl_ranlib, | 275 RANLIB=pnacl_ranlib, |
258 DISASS=pnacl_disass, | 276 DISASS=pnacl_disass, |
259 OBJDUMP=pnacl_disass, | 277 OBJDUMP=pnacl_disass, |
260 STRIP=pnacl_strip, | 278 STRIP=pnacl_strip, |
261 TRANSLATE=pnacl_translate + arch_flag + pnacl_translate_flags, | 279 TRANSLATE=pnacl_translate + arch_flag + pnacl_translate_flags, |
262 PNACLFINALIZE=pnacl_finalize, | 280 PNACLFINALIZE=pnacl_finalize, |
263 PNACLOPT=pnacl_opt, | 281 PNACLOPT=pnacl_opt, |
282 LLC=pnacl_llc + llc_mtriple_flag + pnacl_llc_flags, | |
264 ) | 283 ) |
265 | 284 |
266 if env.Bit('built_elsewhere'): | 285 if env.Bit('built_elsewhere'): |
267 def FakeInstall(dest, source, env): | 286 def FakeInstall(dest, source, env): |
268 print 'Not installing', dest | 287 print 'Not installing', dest |
269 _StubOutEnvToolsForBuiltElsewhere(env) | 288 _StubOutEnvToolsForBuiltElsewhere(env) |
270 env.Replace(INSTALL=FakeInstall) | 289 env.Replace(INSTALL=FakeInstall) |
271 if env.Bit('translate_in_build_step'): | 290 if env.Bit('translate_in_build_step'): |
272 env.Replace(TRANSLATE='true') | 291 env.Replace(TRANSLATE='true') |
273 env.Replace(PNACLFINALIZE='true') | 292 env.Replace(PNACLFINALIZE='true') |
(...skipping 411 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
685 # translation. | 704 # translation. |
686 if not os.path.exists(version_file) or env.Bit('use_sandboxed_translator'): | 705 if not os.path.exists(version_file) or env.Bit('use_sandboxed_translator'): |
687 version_file = os.path.join(os.path.dirname(root), 'pnacl_translator', | 706 version_file = os.path.join(os.path.dirname(root), 'pnacl_translator', |
688 'FEATURE_VERSION') | 707 'FEATURE_VERSION') |
689 if os.path.exists(version_file): | 708 if os.path.exists(version_file): |
690 with open(version_file, 'r') as fh: | 709 with open(version_file, 'r') as fh: |
691 version = int(fh.read()) | 710 version = int(fh.read()) |
692 else: | 711 else: |
693 version = 0 | 712 version = 0 |
694 env.Replace(TOOLCHAIN_FEATURE_VERSION=version) | 713 env.Replace(TOOLCHAIN_FEATURE_VERSION=version) |
OLD | NEW |