OLD | NEW |
1 # -*- python -*- | 1 # -*- python -*- |
2 # Copyright (c) 2014 The Native Client Authors. All rights reserved. | 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 | 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 Import('env') | 6 Import('env') |
7 | 7 |
8 if not env.Bit('bitcode'): | 8 if not env.Bit('bitcode'): |
9 Return() | 9 Return() |
10 # Translating the PSO to an ELF DSO doesn't work on x86-64 yet. The | 10 # Translating the PSO to an ELF DSO doesn't work on x86-64 yet. The |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
45 | 45 |
46 def PsoFromLLVMAssembly(base_name): | 46 def PsoFromLLVMAssembly(base_name): |
47 bitcode_file = env.Command( | 47 bitcode_file = env.Command( |
48 '%s.bc' % base_name, ['%s.ll' % base_name], | 48 '%s.bc' % base_name, ['%s.ll' % base_name], |
49 [Action('${ASCOM}', '${ASCOMSTR}')]) | 49 [Action('${ASCOM}', '${ASCOMSTR}')]) |
50 return MakeAndTranslatePso(base_name, [bitcode_file], | 50 return MakeAndTranslatePso(base_name, [bitcode_file], |
51 # Skip PNaCl passes because they add TLS functions. | 51 # Skip PNaCl passes because they add TLS functions. |
52 llvm_passes='') | 52 llvm_passes='') |
53 | 53 |
54 | 54 |
| 55 LLVM_PASSES = ( |
| 56 # The following is a subset of "-pnacl-abi-simplify-preopt". We don't |
| 57 # want to run the full "-pnacl-abi-simplify-preopt" because it |
| 58 # internalizes symbols that we want to export via "-convert-to-pso". |
| 59 '-resolve-aliases ' |
| 60 '-nacl-global-cleanup ' |
| 61 '-expand-varargs ' |
| 62 '-rewrite-pnacl-library-calls ' |
| 63 '-rewrite-llvm-intrinsic-calls ' |
| 64 # Convert thread-local variables into non-thread-local global variables |
| 65 # for now because ConvertToPSO doesn't support TLS yet. |
| 66 '-minsfi-strip-tls ' |
| 67 '-convert-to-pso ' |
| 68 '-pnacl-abi-simplify-postopt') |
| 69 |
| 70 |
55 def MakeAndTranslatePll(dest, source_file): | 71 def MakeAndTranslatePll(dest, source_file): |
56 return MakeAndTranslatePso( | 72 return MakeAndTranslatePso( |
57 dest, [env.ComponentObject(source_file)], | 73 dest, [env.ComponentObject(source_file)], |
58 # Skip the pre-opt passes because they add TLS functions. However, | 74 # Skip the pre-opt passes because they add TLS functions. However, |
59 # we still need to run the post-opt passes so that the LLVM IR passes | 75 # we still need to run the post-opt passes so that the LLVM IR passes |
60 # the PNaCl ABI checker. | 76 # the PNaCl ABI checker. |
61 llvm_passes='-convert-to-pso -pnacl-abi-simplify-postopt') | 77 llvm_passes=LLVM_PASSES) |
62 | 78 |
63 | 79 |
64 # Under SFI NaCl, the loader currently depends on the allocate_code_data() | 80 # Under SFI NaCl, the loader currently depends on the allocate_code_data() |
65 # interface provided by the IRT. | 81 # interface provided by the IRT. |
66 is_broken = not env.Bit('tests_use_irt') and not env.Bit('nonsfi_nacl') | 82 is_broken = not env.Bit('tests_use_irt') and not env.Bit('nonsfi_nacl') |
67 | 83 |
68 dso1 = MakeAndTranslatePso( | 84 dso1 = MakeAndTranslatePso( |
69 'test_pso', [env.ComponentObject('test_pso.c')], | 85 'test_pso', [env.ComponentObject('test_pso.c')], |
70 llvm_passes='-pnacl-abi-simplify-preopt -pnacl-abi-simplify-postopt') | 86 llvm_passes='-pnacl-abi-simplify-preopt -pnacl-abi-simplify-postopt') |
71 dso2 = PsoFromLLVMAssembly('data_only_pso') | 87 dso2 = PsoFromLLVMAssembly('data_only_pso') |
(...skipping 13 matching lines...) Expand all Loading... |
85 | 101 |
86 | 102 |
87 # Use of the ConvertToPSO pass requires this toolchain version. | 103 # Use of the ConvertToPSO pass requires this toolchain version. |
88 if env['TOOLCHAIN_FEATURE_VERSION'] < 18: | 104 if env['TOOLCHAIN_FEATURE_VERSION'] < 18: |
89 Return() | 105 Return() |
90 | 106 |
91 test_pll = MakeAndTranslatePll('test_pll', 'test_pll.c') | 107 test_pll = MakeAndTranslatePll('test_pll', 'test_pll.c') |
92 | 108 |
93 pll_symbols_test = env.ComponentProgram( | 109 pll_symbols_test = env.ComponentProgram( |
94 'pll_symbols_test', ['pll_symbols_test.cc'], | 110 'pll_symbols_test', ['pll_symbols_test.cc'], |
95 EXTRA_LIBS=['${NONIRT_LIBS}', 'pnacl_dynloader', 'pll_loader']) | 111 EXTRA_LIBS=['${NONIRT_LIBS}', 'pnacl_dynloader', 'pll_loader_lib']) |
96 | 112 |
97 node = env.CommandSelLdrTestNacl( | 113 node = env.CommandSelLdrTestNacl( |
98 'pll_symbols_test.out', pll_symbols_test, [test_pll], | 114 'pll_symbols_test.out', pll_symbols_test, [test_pll], |
99 # Add '-a' to enable filesystem access for opening DSOs. | 115 # Add '-a' to enable filesystem access for opening DSOs. |
100 sel_ldr_flags=['-a']) | 116 sel_ldr_flags=['-a']) |
101 env.AddNodeToTestSuite( | 117 env.AddNodeToTestSuite( |
102 node, ['small_tests', 'toolchain_tests'], | 118 node, ['small_tests', 'toolchain_tests'], |
103 'run_pll_symbols_test', is_broken=is_broken) | 119 'run_pll_symbols_test', is_broken=is_broken) |
104 | 120 |
105 | 121 |
106 test_pll_a = MakeAndTranslatePll('test_pll_a', 'test_pll_a.c') | 122 test_pll_a = MakeAndTranslatePll('test_pll_a', 'test_pll_a.c') |
107 test_pll_b = MakeAndTranslatePll('test_pll_b', 'test_pll_b.c') | 123 test_pll_b = MakeAndTranslatePll('test_pll_b', 'test_pll_b.c') |
108 | 124 |
109 pll_loader_test = env.ComponentProgram( | 125 pll_loader_test = env.ComponentProgram( |
110 'pll_loader_test', ['pll_loader_test.cc'], | 126 'pll_loader_test', ['pll_loader_test.cc'], |
111 EXTRA_LIBS=['${NONIRT_LIBS}', 'pll_loader']) | 127 EXTRA_LIBS=['${NONIRT_LIBS}', 'pll_loader_lib']) |
112 | 128 |
113 node = env.CommandSelLdrTestNacl( | 129 node = env.CommandSelLdrTestNacl( |
114 'pll_loader_test.out', pll_loader_test, [test_pll_a, test_pll_b], | 130 'pll_loader_test.out', pll_loader_test, [test_pll_a, test_pll_b], |
115 # Add '-a' to enable filesystem access for opening DSOs. | 131 # Add '-a' to enable filesystem access for opening DSOs. |
116 sel_ldr_flags=['-a']) | 132 sel_ldr_flags=['-a']) |
117 env.AddNodeToTestSuite( | 133 env.AddNodeToTestSuite( |
118 node, ['small_tests', 'toolchain_tests'], | 134 node, ['small_tests', 'toolchain_tests'], |
119 'run_pll_loader_test', is_broken=is_broken) | 135 'run_pll_loader_test', is_broken=is_broken) |
| 136 |
| 137 |
| 138 libc_obj = env.Command( |
| 139 'libc${OBJSUFFIX}', |
| 140 # libnacl should come first so that it can override definitions in libc. |
| 141 [env.File('${LIB_DIR}/libnacl.a'), |
| 142 env.File('${NACL_SDK_LIB}/libc.a'), |
| 143 env.ComponentObject('libc_entry.c')], |
| 144 '${LD} -r --whole-archive ${SOURCES} -o ${TARGET}') |
| 145 |
| 146 translated_pll_libc = MakeAndTranslatePso( |
| 147 'translated_pll_libc', libc_obj, |
| 148 llvm_passes=LLVM_PASSES) |
| 149 translated_pll_hello_world = MakeAndTranslatePso( |
| 150 'translated_pll_hello_world', |
| 151 [env.ComponentObject('hello_world${OBJSUFFIX}', |
| 152 '../hello_world/hello_world.c')], |
| 153 llvm_passes=LLVM_PASSES) |
| 154 |
| 155 # Ideally we would have this ComponentProgram() definition in |
| 156 # src/untrusted/pll_loader/nacl.scons instead; see the comment there for |
| 157 # why we don't. |
| 158 pll_loader = env.ComponentProgram( |
| 159 'pll_loader', [], |
| 160 EXTRA_LIBS=['${NONIRT_LIBS}', 'pll_loader_main', 'pll_loader_lib']) |
| 161 |
| 162 node = env.CommandSelLdrTestNacl( |
| 163 'pll_hello_world_test.out', pll_loader, |
| 164 [translated_pll_libc, translated_pll_hello_world], |
| 165 # Add '-a' to enable filesystem access for opening DSOs. |
| 166 sel_ldr_flags=['-a'], |
| 167 stdout_golden=env.File('../hello_world/hello_world.stdout')) |
| 168 env.AddNodeToTestSuite( |
| 169 node, ['small_tests', 'toolchain_tests'], |
| 170 'run_pll_hello_world_test', is_broken=is_broken) |
OLD | NEW |