| OLD | NEW |
| 1 # -*- python -*- | 1 # -*- 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 Import('env') | 6 Import('env') |
| 7 | 7 |
| 8 # force inclusion of entire library, so that we can validate it | 8 # force inclusion of entire library, so that we can validate it |
| 9 # NOTE: This approach does not work for -lc because of tons of | 9 # NOTE: This approach does not work for -lc because of tons of |
| 10 # undefined symbols which would have to be stubbed out | 10 # undefined symbols which would have to be stubbed out |
| 11 DEP_LIBS = ['nacl', 'srpc', 'imc_syscalls', 'platform', 'gio', 'pthread', 'm'] | 11 DEP_LIBS = ['nacl', 'srpc', 'imc_syscalls', 'platform', 'gio', 'pthread', 'm'] |
| 12 | 12 |
| 13 # -lgcc is not exposed to the bitcode in PNaCl | 13 # -lgcc is not exposed to the bitcode in PNaCl |
| 14 if env.Bit('bitcode'): | 14 if env.Bit('bitcode'): |
| 15 LIBGCC = [] | 15 LIBGCC = [] |
| 16 else: | 16 else: |
| 17 LIBGCC = ['-lgcc'] | 17 LIBGCC = ['-lgcc'] |
| 18 | 18 |
| 19 DEP_LINKFLAGS = (['-Wl,--whole-archive'] + LIBGCC + | 19 DEP_LINKFLAGS = (['-Wl,--whole-archive'] + LIBGCC + |
| 20 ['-l' + name for name in DEP_LIBS] + | 20 ['-l' + name for name in DEP_LIBS] + |
| 21 ['-Wl,--no-whole-archive']) | 21 ['-Wl,--no-whole-archive']) |
| 22 | 22 |
| 23 # TODO(robertm): get rid of -allow-asm once we can distinguish | 23 # TODO(robertm): get rid of -allow-asm once we can distinguish |
| 24 # real asms from the redirect ones used here | 24 # real asms from the redirect ones used here |
| 25 if env.Bit('bitcode'): | 25 if env.Bit('bitcode'): |
| 26 env.Append(CCFLAGS=['-allow-asm']) | 26 env.Append(CCFLAGS=['-allow-asm']) |
| 27 | 27 |
| 28 # Test C++11 code with both supported C++ standard libraries. | 28 # Test C++11 code with both supported C++ standard libraries. |
| 29 cpp11_libs = ['libstdc++', 'libc++'] | 29 cpp11_libs = ['libc++'] |
| 30 if env.Bit('bitcode'): |
| 31 # PNaCl still supports libstdc++ but nacl-clang does not. |
| 32 cpp11_libs.append('libstdc++') |
| 30 cpp11_envs = {} | 33 cpp11_envs = {} |
| 31 for lib in cpp11_libs: | 34 for lib in cpp11_libs: |
| 32 cpp11_envs[lib] = env.Clone() | 35 cpp11_envs[lib] = env.Clone() |
| 33 cpp11_envs[lib].Append(CCFLAGS=['-std=c++11', '-stdlib=' + lib]) | 36 cpp11_envs[lib].Append(CCFLAGS=['-std=c++11', '-stdlib=' + lib]) |
| 34 cpp11_envs[lib].Append(LINKFLAGS=['-stdlib=' + lib]) | 37 cpp11_envs[lib].Append(LINKFLAGS=['-stdlib=' + lib]) |
| 38 if lib == 'libstdc++': |
| 39 # c++ is added to NONIRT_LIBS for clang to ensure that its dependence on |
| 40 # pthreads can be satisfied by pthread_private instead of pthread. Filter it |
| 41 # out here to ensure that we use libstdc++. |
| 42 cpp11_envs[lib].FilterOut(NONIRT_LIBS=['c++']) |
| 35 | 43 |
| 36 # All the libraries were already included via -l switches in LINKFLAGS. | 44 # All the libraries were already included via -l switches in LINKFLAGS. |
| 37 # But we use them again in LIBS so scons knows about the dependencies. | 45 # But we use them again in LIBS so scons knows about the dependencies. |
| 38 # _LIBFLAGS is the internal variable that puts the expansion of LIBS | 46 # _LIBFLAGS is the internal variable that puts the expansion of LIBS |
| 39 # into the command line; so by clearing that, we prevent scons from | 47 # into the command line; so by clearing that, we prevent scons from |
| 40 # adding repeated -l switches at the end of the link. | 48 # adding repeated -l switches at the end of the link. |
| 41 nexe = env.ComponentProgram('dummy', 'dummy.c', | 49 nexe = env.ComponentProgram('dummy', 'dummy.c', |
| 42 EXTRA_LINKFLAGS=DEP_LINKFLAGS, | 50 EXTRA_LINKFLAGS=DEP_LINKFLAGS, |
| 43 LIBS=DEP_LIBS, | 51 LIBS=DEP_LIBS, |
| 44 _LIBFLAGS='') | 52 _LIBFLAGS='') |
| (...skipping 28 matching lines...) Expand all Loading... |
| 73 AddIntrinsicTest(env, 'float2.c', '0', golden_file=env.File('float2.stdout')) | 81 AddIntrinsicTest(env, 'float2.c', '0', golden_file=env.File('float2.stdout')) |
| 74 AddIntrinsicTest(env, 'synchronization_sync.c', '0', | 82 AddIntrinsicTest(env, 'synchronization_sync.c', '0', |
| 75 # TODO(jfb) Blocked on bugs 3579 and 2981. This should | 83 # TODO(jfb) Blocked on bugs 3579 and 2981. This should |
| 76 # work on PNaCl because it avoids the broken 16-bit | 84 # work on PNaCl because it avoids the broken 16-bit |
| 77 # instructions on x86-32 by using 32-bit instructions. | 85 # instructions on x86-32 by using 32-bit instructions. |
| 78 # The test also exercises instructions that confuse valgrind. | 86 # The test also exercises instructions that confuse valgrind. |
| 79 is_broken=((env.Bit('target_x86_32') and | 87 is_broken=((env.Bit('target_x86_32') and |
| 80 not env.Bit('bitcode')) or | 88 not env.Bit('bitcode')) or |
| 81 env.IsRunningUnderValgrind())) | 89 env.IsRunningUnderValgrind())) |
| 82 AddIntrinsicTest(env, 'synchronization_volatile.c', '0') | 90 AddIntrinsicTest(env, 'synchronization_volatile.c', '0') |
| 83 if env.Bit('bitcode'): | 91 if env.Bit('bitcode') or env.Bit('nacl_clang'): |
| 84 # The following tests were only made to work on LLVM for | 92 # The following tests were only made to work on LLVM for |
| 85 # PNaCl. Command-line flags and libraries need to be updated for GCC | 93 # PNaCl. Command-line flags and libraries need to be updated for GCC |
| 86 # support. | 94 # support. |
| 87 # pthread is needed when building with libc++. | 95 # pthread is needed when building with libc++. |
| 88 for lib in cpp11_envs: | 96 for lib in cpp11_envs: |
| 89 AddIntrinsicTest(cpp11_envs[lib], 'condition_variable_cpp11.cc', '0', | 97 AddIntrinsicTest(cpp11_envs[lib], 'condition_variable_cpp11.cc', '0', |
| 90 test_suffix=lib, EXTRA_LIBS=['${PTHREAD_LIBS}']) | 98 test_suffix=lib, EXTRA_LIBS=['${PTHREAD_LIBS}']) |
| 91 AddIntrinsicTest(cpp11_envs[lib], 'future_cpp11.cc', '0', | 99 AddIntrinsicTest(cpp11_envs[lib], 'future_cpp11.cc', '0', |
| 92 test_suffix=lib, EXTRA_LIBS=['${PTHREAD_LIBS}']) | 100 test_suffix=lib, EXTRA_LIBS=['${PTHREAD_LIBS}']) |
| 93 AddIntrinsicTest(cpp11_envs[lib], 'mutex_cpp11.cc', '0', | 101 AddIntrinsicTest(cpp11_envs[lib], 'mutex_cpp11.cc', '0', |
| 94 test_suffix=lib, EXTRA_LIBS=['${PTHREAD_LIBS}']) | 102 test_suffix=lib, EXTRA_LIBS=['${PTHREAD_LIBS}']) |
| 95 AddIntrinsicTest(cpp11_envs[lib], 'synchronization_cpp11.cc', '0', | 103 AddIntrinsicTest(cpp11_envs[lib], 'synchronization_cpp11.cc', '0', |
| 96 test_suffix=lib, EXTRA_LIBS=['${PTHREAD_LIBS}']) | 104 test_suffix=lib, EXTRA_LIBS=['${PTHREAD_LIBS}']) |
| 97 AddIntrinsicTest(cpp11_envs[lib], 'thread_cpp11.cc', '0', | 105 AddIntrinsicTest(cpp11_envs[lib], 'thread_cpp11.cc', '0', |
| 98 test_suffix=lib, EXTRA_LIBS=['${PTHREAD_LIBS}']) | 106 test_suffix=lib, EXTRA_LIBS=['${PTHREAD_LIBS}']) |
| 99 if lib != 'libstdc++': | 107 if lib != 'libstdc++': |
| 100 # TODO(jfb) Can't compile with libstdc++. | 108 # TODO(jfb) Can't compile with libstdc++. |
| 101 AddIntrinsicTest(cpp11_envs[lib], 'long_double_cpp11.cc', '0', | 109 AddIntrinsicTest(cpp11_envs[lib], 'long_double_cpp11.cc', '0', |
| 102 test_suffix=lib, EXTRA_LIBS=['${PTHREAD_LIBS}']) | 110 test_suffix=lib, EXTRA_LIBS=['${PTHREAD_LIBS}']) |
| 103 | 111 |
| 104 # This test redirects C function calls to llvm instrinsic functions, | 112 # This test redirects C function calls to llvm instrinsic functions, |
| 105 # so they only work w/ PNaCl. | 113 # so they only work w/ PNaCl. |
| 106 if env.Bit('bitcode'): | 114 if env.Bit('bitcode') or env.Bit('nacl_clang'): |
| 107 AddIntrinsicTest(env, 'llvm_bitmanip_intrinsics.c', '0', | 115 AddIntrinsicTest(env, 'llvm_bitmanip_intrinsics.c', '0', |
| 108 golden_file=env.File('llvm_bitmanip_intrinsics.stdout')) | 116 golden_file=env.File('llvm_bitmanip_intrinsics.stdout')) |
| 109 AddIntrinsicTest(env, 'llvm_math_intrinsics.c', '0', | 117 AddIntrinsicTest(env, 'llvm_math_intrinsics.c', '0', |
| 110 golden_file=env.File('llvm_math_intrinsics.stdout')) | 118 golden_file=env.File('llvm_math_intrinsics.stdout')) |
| 111 # Also test the math functions with -ffast-math, so we are a tiny bit more | 119 # Also test the math functions with -ffast-math, so we are a tiny bit more |
| 112 # confident that sin() or __builtin_sin() doesn't get turned into | 120 # confident that sin() or __builtin_sin() doesn't get turned into |
| 113 # something like llvm.sin.f64. | 121 # something like llvm.sin.f64. |
| 114 fastmath_env = env.Clone() | 122 fastmath_env = env.Clone() |
| 115 fastmath_env.Append(CCFLAGS=['-ffast-math']) | 123 fastmath_env.Append(CCFLAGS=['-ffast-math']) |
| 116 AddIntrinsicTest(fastmath_env, 'llvm_math_intrinsics.c', '0', | 124 AddIntrinsicTest(fastmath_env, 'llvm_math_intrinsics.c', '0', |
| (...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 235 new_env.Append(CCFLAGS=['-O2']) | 243 new_env.Append(CCFLAGS=['-O2']) |
| 236 else: | 244 else: |
| 237 new_env.FilterOut(CFLAGS=['-O2']) | 245 new_env.FilterOut(CFLAGS=['-O2']) |
| 238 new_env.FilterOut(CCFLAGS=['-O2']) | 246 new_env.FilterOut(CCFLAGS=['-O2']) |
| 239 new_env.FilterOut(LINKFLAGS=['-O3']) | 247 new_env.FilterOut(LINKFLAGS=['-O3']) |
| 240 return new_env | 248 return new_env |
| 241 | 249 |
| 242 EH_ENVIRONMENTS_TO_TRY = [] | 250 EH_ENVIRONMENTS_TO_TRY = [] |
| 243 | 251 |
| 244 base_eh_env = env.Clone() | 252 base_eh_env = env.Clone() |
| 253 |
| 245 supports_cxx11 = env.Bit('bitcode') or env.Bit('target_arm') | 254 supports_cxx11 = env.Bit('bitcode') or env.Bit('target_arm') |
| 246 base_eh_env.Append(CPPDEFINES=[['SUPPORTS_CXX11', str(int(supports_cxx11))]]) | 255 base_eh_env.Append(CPPDEFINES=[['SUPPORTS_CXX11', str(int(supports_cxx11))]]) |
| 247 if supports_cxx11: | 256 if supports_cxx11: |
| 248 # This flag is necessary for testing std::rethrow_exception(), at | 257 # This flag is necessary for testing std::rethrow_exception(), at |
| 249 # least when using libstdc++. | 258 # least when using libstdc++. |
| 250 base_eh_env.Append(CXXFLAGS=['-std=gnu++11']) | 259 base_eh_env.Append(CXXFLAGS=['-std=gnu++11']) |
| 251 | 260 |
| 252 if env.Bit('bitcode') and env['TOOLCHAIN_FEATURE_VERSION'] >= 1: | 261 if env.Bit('bitcode') and env['TOOLCHAIN_FEATURE_VERSION'] >= 1: |
| 253 for lib in ('libstdc++', 'libc++'): | 262 for lib in ('libstdc++', 'libc++'): |
| 254 sjlj_eh_env = base_eh_env.Clone() | 263 sjlj_eh_env = base_eh_env.Clone() |
| 255 sjlj_eh_env.Append(LINKFLAGS=['--pnacl-exceptions=sjlj', | 264 sjlj_eh_env.Append(LINKFLAGS=['--pnacl-exceptions=sjlj', |
| 256 '-stdlib=%s' % lib]) | 265 '-stdlib=%s' % lib]) |
| 257 sjlj_eh_env.Append(CCFLAGS=['-stdlib=%s' % lib]) | 266 sjlj_eh_env.Append(CCFLAGS=['-stdlib=%s' % lib]) |
| 267 # c++ is added to NONIRT_LIBS for clang to ensure that its dependence on |
| 268 # pthreads can be satisfied by pthread_private instead of pthread. Filter it |
| 269 # out here to ensure that we use libstdc++. |
| 270 if lib == 'libstdc++': |
| 271 sjlj_eh_env.FilterOut(NONIRT_LIBS=['c++']) |
| 258 EH_ENVIRONMENTS_TO_TRY.append(('sjlj_%s' % lib, sjlj_eh_env)) | 272 EH_ENVIRONMENTS_TO_TRY.append(('sjlj_%s' % lib, sjlj_eh_env)) |
| 259 | 273 |
| 260 if env.Bit('bitcode'): | 274 if env.Bit('bitcode'): |
| 261 zerocost_eh_env = base_eh_env.Clone() | 275 zerocost_eh_env = base_eh_env.Clone() |
| 262 zerocost_eh_env.Append(LINKFLAGS=['--pnacl-allow-exceptions']) | 276 zerocost_eh_env.Append(LINKFLAGS=['--pnacl-allow-exceptions']) |
| 263 zerocost_eh_env.Append(TRANSLATEFLAGS=['--pnacl-allow-exceptions']) | 277 zerocost_eh_env.Append(TRANSLATEFLAGS=['--pnacl-allow-exceptions']) |
| 264 else: | 278 else: |
| 265 zerocost_eh_env = base_eh_env | 279 zerocost_eh_env = base_eh_env |
| 266 # Zero-cost C++ exception handling is not currently supported in | 280 # Zero-cost C++ exception handling is not currently supported in |
| 267 # PNaCl's stable ABI. | 281 # PNaCl's stable ABI. |
| (...skipping 329 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 597 mixedlink_env.Append(CCFLAGS=['-Wt,-force-align-stack']) | 611 mixedlink_env.Append(CCFLAGS=['-Wt,-force-align-stack']) |
| 598 nexe = mixedlink_env.ComponentProgram( | 612 nexe = mixedlink_env.ComponentProgram( |
| 599 'stackalign_test', | 613 'stackalign_test', |
| 600 ['call_with_misaligned_stack.S', 'stackalign_test.c'], | 614 ['call_with_misaligned_stack.S', 'stackalign_test.c'], |
| 601 EXTRA_LIBS=['${NONIRT_LIBS}']) | 615 EXTRA_LIBS=['${NONIRT_LIBS}']) |
| 602 node = mixedlink_env.CommandSelLdrTestNacl('stackalign.out', nexe) | 616 node = mixedlink_env.CommandSelLdrTestNacl('stackalign.out', nexe) |
| 603 mixedlink_env.AddNodeToTestSuite( | 617 mixedlink_env.AddNodeToTestSuite( |
| 604 node, | 618 node, |
| 605 ['nonpexe_tests', 'small_tests', 'toolchain_tests'], | 619 ['nonpexe_tests', 'small_tests', 'toolchain_tests'], |
| 606 'run_stackalign_test') | 620 'run_stackalign_test') |
| OLD | NEW |