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.
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.
23 SRCS_NEWLIB_SYSCALL = [
60 'nacl_interface_query.c',
62 'nacl_irt_filename.c',
102 'stubs/freeaddrinfo.c',
104 'stubs/gai_strerror.c',
105 'stubs/get_current_dir_name.c',
106 'stubs/getaddrinfo.c',
107 'stubs/getdtablesize.c',
113 'stubs/getgrgid_r.c',
116 'stubs/gethostbyaddr.c',
117 'stubs/gethostbyname.c',
120 'stubs/getnameinfo.c',
121 'stubs/getpeername.c',
126 'stubs/getpwnam_r.c',
128 'stubs/getpwuid_r.c',
131 'stubs/getservbyport.c',
132 'stubs/getsockname.c',
133 'stubs/getsockopt.c',
137 'stubs/if_freenameindex.c',
138 'stubs/if_indextoname.c',
139 'stubs/if_nameindex.c',
140 'stubs/if_nametoindex.c',
143 'stubs/initgroups.c',
160 'stubs/pthread_sigmask.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',
183 'stubs/setsockopt.c',
184 'stubs/settimeofday.c',
189 'stubs/sigsuspend.c',
192 'stubs/socketpair.c',
199 'stubs/tcsendbreak.c',
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
217 'pthread_initialize_minimal.c',
218 'pthread_stubs.c', # weak version of __pthread_initialize
223 # used by both glibc and newlib
224 SRCS_NACL_EXTENSIONS = [
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
238 sources = (SRCS_NACL_EXTENSIONS +
239 SRCS_NEWLIB_SYSCALL +
242 if env.Bit('target_arm') and not env.Bit('bitcode'):
243 sources.append('aeabi_read_tp.S')
245 # Do not make a shared version of libnacl.
246 libnacl = env.ComponentLibrary('libnacl', sources)
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)
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'])
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'])
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'])
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')])
281 'imc_makeboundsock.c',
282 'imc_mem_obj_create.c',
289 libimc_syscalls = env.NaClSdkLibrary('libimc_syscalls', imc_syscalls)
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.
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',
314 sys_private.append(env.Command('combined_private${OBJSUFFIX}',
316 '${LD} -relocatable -o ${TARGET} ${SOURCES}'))
318 if not env.Bit('nonsfi_nacl'):
319 env.ComponentLibrary('libnacl_sys_private', sys_private)