OLD | NEW |
(Empty) | |
| 1 # -*- python -*- |
| 2 # Copyright (c) 2014 The Native Client Authors. All rights reserved. |
| 3 # Use of this source code is governed by a BSD-style license that can be |
| 4 # found in the LICENSE file. |
| 5 |
| 6 Import('env') |
| 7 |
| 8 if not env.Bit('bitcode'): |
| 9 Return() |
| 10 if env['TOOLCHAIN_FEATURE_VERSION'] < 6: |
| 11 Return() |
| 12 # The x86-64 instruction sequence that PNaCl generates for function calls, |
| 13 # which hides the sandbox base address, isn't compatible with PIC code |
| 14 # generation yet. |
| 15 # TODO(mseaborn): Generate a PIC-friendly instruction sequence for calls. |
| 16 if env.Bit('target_x86_64'): |
| 17 Return() |
| 18 # The sandboxed translator does not support translating PSOs yet. |
| 19 if env.Bit('use_sandboxed_translator'): |
| 20 Return() |
| 21 |
| 22 |
| 23 def MakeAndTranslatePso(dest, bitcode_file): |
| 24 # Run opt to apply PNaCl ABI simplifications to the IR and to run the |
| 25 # PNaCl ABI checker. We are bypassing pnacl-ld for now because its |
| 26 # invocation of Gold internalizes __pnacl_pso_root, which we want to keep |
| 27 # externally-visible. |
| 28 opt_result = env.Command( |
| 29 dest + '.nonfinal.pso', [bitcode_file], |
| 30 '${PNACLOPT} -pnacl-abi-simplify-preopt -pnacl-abi-simplify-postopt ' |
| 31 '-verify-pnaclabi-module -verify-pnaclabi-functions ' |
| 32 '-pnaclabi-allow-debug-metadata ' |
| 33 '${SOURCES} -o ${TARGET}') |
| 34 # Finalize to strip debugging info and to emit PNaCl bitcode. |
| 35 finalized_result = env.Command( |
| 36 dest + '.final.pso', [opt_result], |
| 37 '${PNACLFINALIZE} ${SOURCES} -o ${TARGET}') |
| 38 # Translate to an ELF loadable object. |
| 39 translated_dso = env.Command(dest + '.so', [finalized_result], |
| 40 '${TRANSLATE} -pso ${SOURCES} -o ${TARGET}') |
| 41 return translated_dso |
| 42 |
| 43 |
| 44 # TODO(mseaborn): Add an ELF dynamic loader for PNaCl and test that the DSO |
| 45 # we produce is loadable. |
| 46 node = MakeAndTranslatePso('test_pso', [env.ComponentObject('test_pso.c')]) |
| 47 env.AddNodeToTestSuite(node, ['small_tests', 'toolchain_tests'], |
| 48 'run_pnacl_dynamic_loading_test') |
OLD | NEW |