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