Upstream version 10.39.225.0
[platform/framework/web/crosswalk.git] / src / native_client / src / untrusted / nacl / 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 # NACL_GC_WRAP_SYSCALL uses ({...}) syntax.
10 env.FilterOut(CCFLAGS=['-pedantic'])
11 if env.Bit('bitcode'):
12   # silence a warning when compiling malloc.c with clang
13   # TODO(robertm): get rid of -allow-asm once we can distinguish
14   #                real asms from those used for redirects.
15   #                In this case:  asm("llvm.nacl.tp.tdb.offset")
16   #                from src/untrusted/nacl/tls_params.h
17   env.Append(CCFLAGS=['-Wno-self-assign', '-allow-asm'])
18 # Sources are split into essentially one function per file to be in
19 # alignment with the linker, which resolves symbols by including entire
20 # object files.  Placing multiple definitions in one file may result in
21 # object code bloat or possibly multiple definitions.
22
23 SRCS_NEWLIB_SYSCALL =  [
24     'abort.c',
25     'access.c',
26     'chdir.c',
27     'chmod.c',
28     'clock.c',
29     'clock_getres.c',
30     'clock_gettime.c',
31     'close.c',
32     'dup.c',
33     '_exit.c',
34     'fchdir.c',
35     'fchmod.c',
36     'fdatasync.c',
37     'fstat.c',
38     'fsync.c',
39     'ftruncate.c',
40     'getcwd.c',
41     'getdents.c',
42     'gethostname.c',
43     'getpagesize.c',
44     'getpid.c',
45     'gettimeofday.c',
46     'isatty.c',
47     'link.c',
48     'lock.c',
49     'lseek.c',
50     'lstat.c',
51     'mkdir.c',
52     'mmap.c',
53     'mprotect.c',
54     'munmap.c',
55     'nanosleep.c',
56     'nacl_ext_supply.c',
57     'nacl_interface_query.c',
58     'nacl_irt_fdio.c',
59     'nacl_irt_filename.c',
60     'open.c',
61     'read.c',
62     'readlink.c',
63     'rename.c',
64     'rmdir.c',
65     'sbrk.c',
66     'sched_yield.c',
67     'stat.c',
68     'symlink.c',
69     'sysconf.c',
70     'truncate.c',
71     'unlink.c',
72     'utimes.c',
73     'write.c',
74 ]
75
76 SRCS_NEWLIB_STUBS = [
77     'stubs/chown.c',
78     'stubs/endpwent.c',
79     'stubs/environ.c',
80     'stubs/_execve.c',
81     'stubs/fchown.c',
82     'stubs/fcntl.c',
83     'stubs/fork.c',
84     'stubs/get_current_dir_name.c',
85     'stubs/getegid.c',
86     'stubs/geteuid.c',
87     'stubs/getgid.c',
88     'stubs/getlogin.c',
89     'stubs/getrusage.c',
90     'stubs/getppid.c',
91     'stubs/getpwent.c',
92     'stubs/getpwnam.c',
93     'stubs/getpwnam_r.c',
94     'stubs/getpwuid.c',
95     'stubs/getpwuid_r.c',
96     'stubs/getuid.c',
97     'stubs/getwd.c',
98     'stubs/ioctl.c',
99     'stubs/issetugid.c',
100     'stubs/kill.c',
101     'stubs/lchown.c',
102     'stubs/llseek.c',
103     'stubs/pipe.c',
104     'stubs/pselect.c',
105     'stubs/recv.c',
106     'stubs/select.c',
107     'stubs/send.c',
108     'stubs/setegid.c',
109     'stubs/seteuid.c',
110     'stubs/setgid.c',
111     'stubs/setpwent.c',
112     'stubs/settimeofday.c',
113     'stubs/setuid.c',
114     'stubs/signal.c',
115     'stubs/sigprocmask.c',
116     'stubs/tcdrain.c',
117     'stubs/tcflow.c',
118     'stubs/tcflush.c',
119     'stubs/tcgetattr.c',
120     'stubs/tcsendbreak.c',
121     'stubs/tcsetattr.c',
122     'stubs/times.c',
123     'stubs/ttyname.c',
124     'stubs/ttyname_r.c',
125     'stubs/umask.c',
126     'stubs/utime.c',
127     'stubs/vfork.c',
128     'stubs/wait.c',
129     'stubs/waitpid.c',
130 ]
131
132 SRCS_NEWLIB_MISC = [
133     'malloc.c',        # malloc wrapper
134     'stacktrace.c',    # stack tracing for use with "-finstrument"
135     'start.c',         # contains _start, preventing us from making this a .so
136     'nacl_add_tp.c',
137     'nacl_read_tp.c',
138     'pthread_initialize_minimal.c',
139     'pthread_stubs.c', # weak version of __pthread_initialize
140     'tls.c',
141 ]
142
143
144 # used by both glibc and newlib
145 SRCS_NACL_EXTENSIONS = [
146     'gc_hooks.c',
147     'nacl_irt.c',
148     'nacl_irt_init.c',
149     'nacl_tls_get.c',
150     'nacl_tls_init.c',
151     'random.c',
152     ]
153
154 if env.Bit('nacl_glibc'):
155   # For nacl-glibc, the standard interfaces are provided by glibc, so
156   # we do not build them here.
157   sources = SRCS_NACL_EXTENSIONS
158 else:
159   sources = (SRCS_NACL_EXTENSIONS +
160              SRCS_NEWLIB_SYSCALL +
161              SRCS_NEWLIB_STUBS +
162              SRCS_NEWLIB_MISC)
163   if env.Bit('target_arm') and not env.Bit('bitcode'):
164     sources.append('aeabi_read_tp.S')
165
166 # Do not make a shared version of libnacl.
167 libnacl = env.ComponentLibrary('libnacl', sources)
168
169 env.AddLibraryToSdk(libnacl)
170 header_install = env.AddHeaderToSdk([
171     'nacl_random.h', 'nacl_startup.h', 'nacl_thread.h'])
172 env.Requires('libnacl', header_install)
173
174 libnacl_dyncode = env.NaClSdkLibrary('libnacl_dyncode', ['dyncode.c'])
175 env.AddLibraryToSdk(libnacl_dyncode)
176 env.AddHeaderToSdk(['nacl_dyncode.h'])
177 env.ComponentLibrary('libnacl_dyncode_private', ['dyncode_private.c'])
178
179 libnacl_exception = env.NaClSdkLibrary('libnacl_exception',
180                                        ['nacl_exception.c'])
181 env.AddLibraryToSdk(libnacl_exception)
182 env.ComponentLibrary('libnacl_exception_private', ['nacl_exception_private.c'])
183
184 libnacl_list_mappings = env.NaClSdkLibrary(
185     'libnacl_list_mappings', ['list_mappings.c'])
186 env.AddLibraryToSdk(libnacl_list_mappings)
187 env.AddHeaderToSdk(['nacl_list_mappings.h'])
188 env.ComponentLibrary(
189     'libnacl_list_mappings_private', ['list_mappings_private.c'])
190
191 env.ComponentLibrary(
192     'libnacl_random_private',
193     [env.ComponentObject('irt_random',
194                          '${MAIN_DIR}/src/untrusted/irt/irt_random.c'),
195      env.ComponentObject('irt_nameservice',
196                          '${MAIN_DIR}/src/untrusted/irt/irt_nameservice.c')])
197
198
199 imc_syscalls = [
200     'imc_accept.c',
201     'imc_connect.c',
202     'imc_makeboundsock.c',
203     'imc_mem_obj_create.c',
204     'imc_recvmsg.c',
205     'imc_sendmsg.c',
206     'imc_socketpair.c',
207     'nameservice.c',
208     ]
209
210 libimc_syscalls = env.NaClSdkLibrary('libimc_syscalls', imc_syscalls)
211
212 sys_private = [
213     'null.c',
214     'sysbrk.c',
215     ]
216
217 if not env.Bit('nacl_glibc'):
218   sys_private.append(env.ComponentObject(
219       'private_blockhook', '${MAIN_DIR}/src/untrusted/irt/irt_blockhook.c'))
220   # We must combine these all into a single .o file so that there is no
221   # danger of some of this code not being brought in from the archive, and
222   # later getting the IRT-based versions from libnacl instead.
223   #
224   # For example, suppose mmap() were in a separate mmap.o file in
225   # libnacl_sys_private.o.  If your test calls only malloc() (defined in
226   # -lc) and malloc() is the only caller of mmap(), then when processing
227   # -lsys_private (before -lc) the linker will omit mmap.o, and only when
228   # processing -lc (which implicitly includes -lnacl) will it try to pull
229   # in some definition of mmap()--so it will get the libnacl one instead of
230   # the libnacl_sys_private one.  Putting everything important into a
231   # single .o file avoids this scenario.
232   private_combine = [env.ComponentObject(module, '%s.c' % module)
233                      for module in ['gc_hooks_private',
234                                     'sys_private']]
235   sys_private.append(env.Command('combined_private${OBJSUFFIX}',
236                                  private_combine,
237                                  '${LD} -relocatable -o ${TARGET} ${SOURCES}'))
238
239 if not env.Bit('nonsfi_nacl'):
240   env.ComponentLibrary('libnacl_sys_private', sys_private)