2 # Copyright 2012 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.
6 # Calling convention test to ensure interoperabilty of nacl-gcc and
11 # This test does not make any sense for pure pnacl
12 if not env.Bit('bitcode'):
15 if env.Bit('pnacl_generate_pexe'):
18 # This test is disabled for MIPS because we do not have a MIPS-enabled nacl-gcc
19 # to test PNaCl against.
20 if env.Bit('target_mips32'):
23 env_pnacl_cc = env.Clone()
24 env_pnacl_cc.PNaClForceNative()
25 # for ppapi headers which include other ppapi headers
26 env_pnacl_cc.Append(CPPPATH='${SCONSTRUCT_DIR}/tests/callingconv_ppapi')
28 if env.Bit('target_arm'):
29 pnacl_nativecc_flags = ['--target=armv7a-unknown-nacl-gnueabi',
31 elif env.Bit('target_x86_32'):
32 pnacl_nativecc_flags = ['--target=i686-unknown-nacl']
33 elif env.Bit('target_x86_64'):
34 pnacl_nativecc_flags = ['--target=x86_64-unknown-nacl']
36 env_pnacl_cc_calling = env_pnacl_cc.Clone()
37 env_pnacl_cc_calling.Append(
38 CCFLAGS=pnacl_nativecc_flags,
39 # force invoked functions to have "gcc" prefix
40 CPPDEFINES=['INVOCATION_PREFIX=gcc'])
41 env_pnacl_cc_called = env_pnacl_cc.Clone()
42 env_pnacl_cc_called.Append(
43 CCFLAGS=pnacl_nativecc_flags,
44 # force both defined and invoked functions to have the "pnacl" prefix
45 CPPDEFINES=['FUNCTION_PREFIX=pnacl', 'INVOCATION_PREFIX=pnacl'])
47 gcc_cc_env = env_pnacl_cc.PNaClGetNNaClEnv()
48 # GCC's C++ EH support requires GCC's runtime, which we don't link with.
49 gcc_cc_env.Append(CXXFLAGS=['-fno-exceptions'])
51 # This can generate references to runtime code we won't link with.
52 gcc_cc_env.FilterOut(CCFLAGS=['-fasynchronous-unwind-tables'])
54 env_gcc_cc_calling = gcc_cc_env.Clone()
55 env_gcc_cc_calling.Append(
56 # force invoked functions to have "pnacl" prefix
57 CPPDEFINES=['INVOCATION_PREFIX=pnacl'])
58 env_gcc_cc_called = gcc_cc_env.Clone()
59 env_gcc_cc_called.Append(
60 # force both defined and invoked functions to have the "gcc" prefix
61 CPPDEFINES=['FUNCTION_PREFIX=gcc', 'INVOCATION_PREFIX=gcc'])
63 # Note: this file is alwyas built with the pnacl TC
64 obj_support = env_pnacl_cc.ComponentObject('support.c')
66 env_pnacl_cc_called.ComponentObject('obj_pnacl_called',
67 'ppapi_callingconv_test.cpp')
69 env_pnacl_cc_calling.ComponentObject('obj_pnacl_calling',
70 'ppapi_callingconv_test.cpp')
71 env_pnacl_cc.ComponentObject('obj_pnacl_both',
72 'ppapi_callingconv_test.cpp')
74 env_gcc_cc_called.ComponentObject('obj_gcc_called',
75 'ppapi_callingconv_test.cpp')
77 env_gcc_cc_calling.ComponentObject('obj_gcc_calling',
78 'ppapi_callingconv_test.cpp')
80 gcc_cc_env.ComponentObject('obj_gcc_both',
81 'ppapi_callingconv_test.cpp')
85 # pnacl self consistency tests
86 ('pnacl_both', ['obj_pnacl_both', obj_support]),
87 # gcc self consistency tests
88 ('gcc_both', ['obj_gcc_both', obj_support]),
89 # gcc compiled code invoking pnacl compiled code:
90 # * obj_gcc_calling contains gcc compiled code invoking functions
91 # with the "pnacl" prefix
92 # * obj_pnacl_called contains pnacl compiled functions with the "pnacl"
94 ('gcc_calls_pnacl', ['obj_gcc_calling', 'obj_pnacl_called', obj_support]),
95 # pnacl compiled code invoking gcc compiled code:
96 # * obj_pnacl_calling contains pnacl compiled code invoking functions
97 # with the "gcc" prefix
98 # * obj_gcc_called contains gcc compiled functions with the "gcc"
100 ('pnacl_calls_gcc',['obj_pnacl_calling', 'obj_gcc_called', obj_support]),
104 for name, objs in TARGETS:
105 nexe = env_pnacl_cc.ComponentProgram('callingconv_ppapi_%s' % name,
107 EXTRA_LIBS=['${NONIRT_LIBS}'])
108 test= env.CommandSelLdrTestNacl('callingconv_ppapi_%s.out' % name,
110 stdout_golden=env.File('golden.out'))
111 env.AddNodeToTestSuite(test,
112 ['medium_tests', 'nonpexe_tests'],
113 'run_callingconv_ppapi_%s_test' % name)