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.
8 if not env.Bit('bitcode'):
10 if env['TOOLCHAIN_FEATURE_VERSION'] < 6:
12 # Translating the PSO to an ELF DSO doesn't work on x86-64 yet. The
13 # Gold linker complains that the input "requires dynamic R_X86_64_32
14 # reloc against <blah> which may overflow at runtime". (In contrast,
15 # the BFD linker in the glibc toolchain does handle this relocation.)
16 # TODO(mseaborn): Fix this and enable the test for x86-64.
17 if env.Bit('target_x86_64'):
19 # The sandboxed translator does not support translating PSOs yet.
20 if env.Bit('use_sandboxed_translator'):
22 # The PNaCl dynamic loader currently only supports SFI NaCl's memory layout.
23 if env.Bit('nonsfi_nacl'):
27 def MakeAndTranslatePso(dest, bitcode_file, do_simplify):
28 # Run opt to apply PNaCl ABI simplifications to the IR and to run the
29 # PNaCl ABI checker. We are bypassing pnacl-ld for now because its
30 # invocation of Gold internalizes __pnacl_pso_root, which we want to keep
34 passes = '-pnacl-abi-simplify-preopt -pnacl-abi-simplify-postopt '
35 opt_result = env.Command(
36 dest + '.nonfinal.pso', [bitcode_file],
37 '${PNACLOPT} ' + passes +
38 '-verify-pnaclabi-module -verify-pnaclabi-functions '
39 '-pnaclabi-allow-debug-metadata '
40 '${SOURCES} -o ${TARGET}')
41 # Finalize to strip debugging info and to emit PNaCl bitcode.
42 finalized_result = env.Command(
43 dest + '.final.pso', [opt_result],
44 '${PNACLFINALIZE} ${SOURCES} -o ${TARGET}')
45 # Translate to an ELF loadable object.
46 translated_dso = env.Command(dest + '.so', [finalized_result],
47 '${TRANSLATE} -pso ${SOURCES} -o ${TARGET}')
51 def PsoFromLLVMAssembly(base_name):
52 bitcode_file = env.Command(
53 '%s.bc' % base_name, ['%s.ll' % base_name],
54 [Action('${ASCOM}', '${ASCOMSTR}')])
55 return MakeAndTranslatePso(base_name, [bitcode_file],
56 # Skip PNaCl passes because they add TLS functions.
60 dso1 = MakeAndTranslatePso('test_pso', [env.ComponentObject('test_pso.c')],
62 dso2 = PsoFromLLVMAssembly('data_only_pso')
63 dso3 = PsoFromLLVMAssembly('data_only_pso_largebss')
65 dynloader_test = env.ComponentProgram(
66 'dynloader_test', ['dynloader_test.c'],
67 EXTRA_LIBS=['${NONIRT_LIBS}', 'pnacl_dynloader', 'platform'])
69 node = env.CommandSelLdrTestNacl(
70 'dynloader_test.out', dynloader_test, [dso1, dso2, dso3],
71 # Add '-a' to enable filesystem access for opening DSOs.
73 env.AddNodeToTestSuite(
74 node, ['small_tests', 'toolchain_tests'],
75 'run_pnacl_dynamic_loading_test',
76 # The loader currently depends on the allocate_code_data() interface
77 # provided by the IRT.
78 is_broken=not env.Bit('tests_use_irt'))