Update To 11.40.268.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     'eaccess.c',
35     'fchdir.c',
36     'fchmod.c',
37     'fdatasync.c',
38     'fstat.c',
39     'fsync.c',
40     'ftruncate.c',
41     'getcwd.c',
42     'getdents.c',
43     'gethostname.c',
44     'getpagesize.c',
45     'getpid.c',
46     'gettimeofday.c',
47     'htonl.c',
48     'htons.c',
49     'isatty.c',
50     'link.c',
51     'lock.c',
52     'lseek.c',
53     'lstat.c',
54     'mkdir.c',
55     'mmap.c',
56     'mprotect.c',
57     'munmap.c',
58     'nanosleep.c',
59     'nacl_ext_supply.c',
60     'nacl_interface_query.c',
61     'nacl_irt_fdio.c',
62     'nacl_irt_filename.c',
63     'ntohl.c',
64     'ntohs.c',
65     'open.c',
66     'read.c',
67     'readlink.c',
68     'rename.c',
69     'rmdir.c',
70     'sbrk.c',
71     'sched_yield.c',
72     'sigblock.c',
73     'siggetmask.c',
74     'sigmask.c',
75     'sigprocmask.c',
76     'sigsetmask.c',
77     'stat.c',
78     'symlink.c',
79     'sysconf.c',
80     'truncate.c',
81     'unlink.c',
82     'utimes.c',
83     'write.c',
84 ]
85
86 SRCS_NEWLIB_STUBS = [
87     'stubs/_execve.c',
88     'stubs/accept.c',
89     'stubs/addmntent.c',
90     'stubs/bind.c',
91     'stubs/chown.c',
92     'stubs/closelog.c',
93     'stubs/connect.c',
94     'stubs/endgrent.c',
95     'stubs/endmntent.c',
96     'stubs/endpwent.c',
97     'stubs/environ.c',
98     'stubs/execvpe.c',
99     'stubs/fchown.c',
100     'stubs/fcntl.c',
101     'stubs/fork.c',
102     'stubs/freeaddrinfo.c',
103     'stubs/fstatvfs.c',
104     'stubs/gai_strerror.c',
105     'stubs/get_current_dir_name.c',
106     'stubs/getaddrinfo.c',
107     'stubs/getdtablesize.c',
108     'stubs/getegid.c',
109     'stubs/geteuid.c',
110     'stubs/getgid.c',
111     'stubs/getgrent.c',
112     'stubs/getgrgid.c',
113     'stubs/getgrgid_r.c',
114     'stubs/getgrnam.c',
115     'stubs/getgroups.c',
116     'stubs/gethostbyaddr.c',
117     'stubs/gethostbyname.c',
118     'stubs/getlogin.c',
119     'stubs/getmntent.c',
120     'stubs/getnameinfo.c',
121     'stubs/getpeername.c',
122     'stubs/getpgrp.c',
123     'stubs/getppid.c',
124     'stubs/getpwent.c',
125     'stubs/getpwnam.c',
126     'stubs/getpwnam_r.c',
127     'stubs/getpwuid.c',
128     'stubs/getpwuid_r.c',
129     'stubs/getrlimit.c',
130     'stubs/getrusage.c',
131     'stubs/getservbyport.c',
132     'stubs/getsockname.c',
133     'stubs/getsockopt.c',
134     'stubs/getuid.c',
135     'stubs/getwd.c',
136     'stubs/hasmntopt.c',
137     'stubs/if_freenameindex.c',
138     'stubs/if_indextoname.c',
139     'stubs/if_nameindex.c',
140     'stubs/if_nametoindex.c',
141     'stubs/inet_ntoa.c',
142     'stubs/inet_ntop.c',
143     'stubs/initgroups.c',
144     'stubs/ioctl.c',
145     'stubs/issetugid.c',
146     'stubs/kill.c',
147     'stubs/lchown.c',
148     'stubs/listen.c',
149     'stubs/llseek.c',
150     'stubs/major.c',
151     'stubs/makedev.c',
152     'stubs/minor.c',
153     'stubs/mkfifo.c',
154     'stubs/mknod.c',
155     'stubs/msync.c',
156     'stubs/openlog.c',
157     'stubs/pipe.c',
158     'stubs/poll.c',
159     'stubs/pselect.c',
160     'stubs/pthread_sigmask.c',
161     'stubs/readv.c',
162     'stubs/recv.c',
163     'stubs/recvfrom.c',
164     'stubs/recvmsg.c',
165     'stubs/sched_get_priority_max.c',
166     'stubs/sched_get_priority_min.c',
167     'stubs/sched_setparam.c',
168     'stubs/sched_setscheduler.c',
169     'stubs/select.c',
170     'stubs/send.c',
171     'stubs/sendmsg.c',
172     'stubs/sendto.c',
173     'stubs/setegid.c',
174     'stubs/seteuid.c',
175     'stubs/setgid.c',
176     'stubs/setgrent.c',
177     'stubs/setgroups.c',
178     'stubs/setmntent.c',
179     'stubs/setpgid.c',
180     'stubs/setpwent.c',
181     'stubs/setrlimit.c',
182     'stubs/setsid.c',
183     'stubs/setsockopt.c',
184     'stubs/settimeofday.c',
185     'stubs/setuid.c',
186     'stubs/shutdown.c',
187     'stubs/sigaction.c',
188     'stubs/signal.c',
189     'stubs/sigsuspend.c',
190     'stubs/sigvec.c',
191     'stubs/socket.c',
192     'stubs/socketpair.c',
193     'stubs/statvfs.c',
194     'stubs/syslog.c',
195     'stubs/tcdrain.c',
196     'stubs/tcflow.c',
197     'stubs/tcflush.c',
198     'stubs/tcgetattr.c',
199     'stubs/tcsendbreak.c',
200     'stubs/tcsetattr.c',
201     'stubs/times.c',
202     'stubs/ttyname.c',
203     'stubs/ttyname_r.c',
204     'stubs/umask.c',
205     'stubs/utime.c',
206     'stubs/vfork.c',
207     'stubs/wait.c',
208     'stubs/waitpid.c',
209 ]
210
211 SRCS_NEWLIB_MISC = [
212     'malloc.c',        # malloc wrapper
213     'stacktrace.c',    # stack tracing for use with "-finstrument"
214     'start.c',         # contains _start, preventing us from making this a .so
215     'nacl_add_tp.c',
216     'nacl_read_tp.c',
217     'pthread_initialize_minimal.c',
218     'pthread_stubs.c', # weak version of __pthread_initialize
219     'tls.c',
220 ]
221
222
223 # used by both glibc and newlib
224 SRCS_NACL_EXTENSIONS = [
225     'gc_hooks.c',
226     'nacl_irt.c',
227     'nacl_irt_init.c',
228     'nacl_tls_get.c',
229     'nacl_tls_init.c',
230     'random.c',
231     ]
232
233 if env.Bit('nacl_glibc'):
234   # For nacl-glibc, the standard interfaces are provided by glibc, so
235   # we do not build them here.
236   sources = SRCS_NACL_EXTENSIONS
237 else:
238   sources = (SRCS_NACL_EXTENSIONS +
239              SRCS_NEWLIB_SYSCALL +
240              SRCS_NEWLIB_STUBS +
241              SRCS_NEWLIB_MISC)
242   if env.Bit('target_arm') and not env.Bit('bitcode'):
243     sources.append('aeabi_read_tp.S')
244
245 # Do not make a shared version of libnacl.
246 libnacl = env.ComponentLibrary('libnacl', sources)
247
248 env.AddLibraryToSdk(libnacl)
249 header_install = env.AddHeaderToSdk([
250     'nacl_random.h', 'nacl_startup.h', 'nacl_thread.h'])
251 env.Requires('libnacl', header_install)
252
253 libnacl_dyncode = env.NaClSdkLibrary('libnacl_dyncode', ['dyncode.c'])
254 env.AddLibraryToSdk(libnacl_dyncode)
255 env.AddHeaderToSdk(['nacl_dyncode.h'])
256 env.ComponentLibrary('libnacl_dyncode_private', ['dyncode_private.c'])
257
258 libnacl_exception = env.NaClSdkLibrary('libnacl_exception',
259                                        ['nacl_exception.c'])
260 env.AddLibraryToSdk(libnacl_exception)
261 env.ComponentLibrary('libnacl_exception_private', ['nacl_exception_private.c'])
262
263 libnacl_list_mappings = env.NaClSdkLibrary(
264     'libnacl_list_mappings', ['list_mappings.c'])
265 env.AddLibraryToSdk(libnacl_list_mappings)
266 env.AddHeaderToSdk(['nacl_list_mappings.h'])
267 env.ComponentLibrary(
268     'libnacl_list_mappings_private', ['list_mappings_private.c'])
269
270 env.ComponentLibrary(
271     'libnacl_random_private',
272     [env.ComponentObject('irt_random',
273                          '${MAIN_DIR}/src/untrusted/irt/irt_random.c'),
274      env.ComponentObject('irt_nameservice',
275                          '${MAIN_DIR}/src/untrusted/irt/irt_nameservice.c')])
276
277
278 imc_syscalls = [
279     'imc_accept.c',
280     'imc_connect.c',
281     'imc_makeboundsock.c',
282     'imc_mem_obj_create.c',
283     'imc_recvmsg.c',
284     'imc_sendmsg.c',
285     'imc_socketpair.c',
286     'nameservice.c',
287     ]
288
289 libimc_syscalls = env.NaClSdkLibrary('libimc_syscalls', imc_syscalls)
290
291 sys_private = [
292     'null.c',
293     'sysbrk.c',
294     ]
295
296 if not env.Bit('nacl_glibc'):
297   sys_private.append(env.ComponentObject(
298       'private_blockhook', '${MAIN_DIR}/src/untrusted/irt/irt_blockhook.c'))
299   # We must combine these all into a single .o file so that there is no
300   # danger of some of this code not being brought in from the archive, and
301   # later getting the IRT-based versions from libnacl instead.
302   #
303   # For example, suppose mmap() were in a separate mmap.o file in
304   # libnacl_sys_private.o.  If your test calls only malloc() (defined in
305   # -lc) and malloc() is the only caller of mmap(), then when processing
306   # -lsys_private (before -lc) the linker will omit mmap.o, and only when
307   # processing -lc (which implicitly includes -lnacl) will it try to pull
308   # in some definition of mmap()--so it will get the libnacl one instead of
309   # the libnacl_sys_private one.  Putting everything important into a
310   # single .o file avoids this scenario.
311   private_combine = [env.ComponentObject(module, '%s.c' % module)
312                      for module in ['gc_hooks_private',
313                                     'sys_private']]
314   sys_private.append(env.Command('combined_private${OBJSUFFIX}',
315                                  private_combine,
316                                  '${LD} -relocatable -o ${TARGET} ${SOURCES}'))
317
318 if not env.Bit('nonsfi_nacl'):
319   env.ComponentLibrary('libnacl_sys_private', sys_private)