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 # 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.
26 SRCS_NEWLIB_SYSCALL = [
56 'nacl_interface_query.c',
58 'nacl_irt_filename.c',
83 'stubs/get_current_dir_name.c',
110 'stubs/settimeofday.c',
113 'stubs/sigprocmask.c',
118 'stubs/tcsendbreak.c',
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
136 'pthread_initialize_minimal.c',
137 'pthread_stubs.c', # weak version of __pthread_initialize
142 # used by both glibc and newlib
143 SRCS_NACL_EXTENSIONS = [
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
157 sources = (SRCS_NACL_EXTENSIONS +
158 SRCS_NEWLIB_SYSCALL +
161 if env.Bit('target_arm') and not env.Bit('bitcode'):
162 sources.append('aeabi_read_tp.S')
164 # Do not make a shared version of libnacl.
165 libnacl = env.ComponentLibrary('libnacl', sources)
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)
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'])
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'])
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'])
193 'imc_makeboundsock.c',
194 'imc_mem_obj_create.c',
201 libimc_syscalls = env.NaClSdkLibrary('libimc_syscalls', imc_syscalls)
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.
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',
226 sys_private.append(env.Command('combined_private${OBJSUFFIX}',
228 '${LD} -relocatable -o ${TARGET} ${SOURCES}'))
230 env.ComponentLibrary('libnacl_sys_private', sys_private)