Upstream version 5.34.92.0
[platform/framework/web/crosswalk.git] / src / native_client / src / untrusted / irt / nacl.scons
1 # -*- python -*-
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
4 # found in the LICENSE file.
5
6
7 Import('env')
8
9 # TODO(mseaborn): Enable -Wstrict-prototypes here.  Currently
10 # dlmalloc/malloc.c does not build with this warning.
11 env.FilterOut(CFLAGS=['-Wstrict-prototypes'])
12
13 # This module shouldn't be built in an environment that uses glibc.
14 if env.Bit('nacl_glibc'):
15   raise UserError('src/untrusted/irt/nacl.scons in the wrong environment?')
16
17 blob_env = env.Clone()
18 blob_env.Append(LINKFLAGS=['-Wl,-Trodata-segment=${IRT_BLOB_DATA_START}',
19                            '-Wl,-Ttext-segment=${IRT_BLOB_CODE_START}'])
20
21 irt_support_sources = [
22     'irt_entry.c',
23     'irt_malloc.c',
24     'irt_private_pthread.c',
25     'irt_private_tls.c',
26     ]
27
28 # NACL_GC_WRAP_SYSCALL uses ({...}) syntax.
29 blob_env.FilterOut(CCFLAGS=['-pedantic'])
30
31 irt_common_interfaces = [
32     'irt_basic.c',
33     'irt_fdio.c',
34     'irt_filename.c',
35     'irt_memory.c',
36     'irt_dyncode.c',
37     'irt_thread.c',
38     'irt_futex.c',
39     'irt_mutex.c',
40     'irt_cond.c',
41     'irt_sem.c',
42     'irt_tls.c',
43     'irt_blockhook.c',
44     'irt_clock.c',
45     'irt_dev_getpid.c',
46     'irt_exception_handling.c',
47     'irt_dev_list_mappings.c',
48     'irt_nameservice.c',
49     'irt_random.c',
50     ]
51
52 # These are the objects and libraries that go into every IRT image.
53 irt_support_objs = [blob_env.ComponentObject(x) for x in
54                     (irt_support_sources + irt_common_interfaces)]
55
56 # We also get nc_init_private.c, nc_thread.c and nc_tsd.c via
57 # #includes of .c files.
58 irt_support_objs += [
59     blob_env.ComponentObject(module,
60                              '${MAIN_DIR}/src/untrusted/pthread/%s.c' % module)
61     for module in ['nc_mutex',
62                    'nc_condvar']]
63
64 irt_support_objs += [
65     blob_env.ComponentObject('sys_private',
66                              '${MAIN_DIR}/src/untrusted/nacl/sys_private.c'),
67     blob_env.ComponentObject(
68         'dynamic_annotations.o',
69         '${MAIN_DIR}/src/untrusted/valgrind/dynamic_annotations.c'),
70     ]
71
72 if env.Bit('target_arm'):
73   read_tp_obj = blob_env.ComponentObject('aeabi_read_tp.o', 'aeabi_read_tp.S')
74   irt_support_objs.append(read_tp_obj)
75   # Publish the object file for tests/irt_private_pthread to use.
76   # Putting aeabi_read_tp.o into libirt_support_private is not
77   # sufficient because of link ordering issues.
78   env.Replicate('${STAGING_DIR}', read_tp_obj)
79
80 # Build a library so that irt_support_objs can be used in tests that
81 # cover IRT-internal code.
82 env.ComponentLibrary('libirt_support_private', irt_support_objs)
83
84 irt_nonbrowser = ['irt_interfaces.c',
85                   'irt_core_resource.c',
86                   ]
87
88 irt_libs = ['srpc',
89             'imc_syscalls',
90             'platform',
91             'gio',
92             'm',
93             ]
94
95 irt_core_library = blob_env.ComponentProgram(
96     'irt_core', irt_support_objs + irt_nonbrowser, EXTRA_LIBS=irt_libs)
97 env.SDKInstallBin('irt_core.nexe', irt_core_library)
98
99 # TODO(mcgrathr): these should be installed, but scons is a mystery
100 #env.AddHeaderToSdk(['irt.h'])
101 #env.AddHeaderToSdk(['irt_ppapi.h'])
102
103 # Make sure that the linked IRT nexe never uses TLS via the TLS ABI
104 # register (e.g., %gs on x86-32).  All IRT code must avoid direct use
105 # of the TLS ABI register, which is reserved for user TLS.  Instead,
106 # ensure all TLS accesses use a call to __nacl_read_tp (or __aeabi_read_tp
107 # for ARM), which the IRT code overrides to segregate IRT-private TLS
108 # from user TLS.
109 if ((env.Bit('build_arm') or env.Bit('build_x86_32'))
110     # Do not try to run OBJDUMP if 'built_elsewhere', since that *might*
111     # mean that a toolchain is not even present. E.g., the arm buildbots
112     # do not have the pnacl toolchain, since that is built for x86 hosts.
113     and not env.Bit('built_elsewhere')):
114   check_tls_arch = '${TARGET_FULLARCH}'
115   if env.Bit('build_arm'):
116     check_tls_arch = 'arm'
117   node = env.CommandTest('irt_core_tls_test.out',
118                          ['${PYTHON}', env.File('check_tls.py'),
119                           check_tls_arch, '${OBJDUMP}', irt_core_library],
120                          # don't run ${PYTHON} under the emulator.
121                          direct_emulation=False)
122   env.AddNodeToTestSuite(node, ['small_tests'], 'run_irt_core_tls_test')