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 = [
57 'nacl_interface_query.c',
59 'nacl_irt_filename.c',
84 'stubs/get_current_dir_name.c',
112 'stubs/settimeofday.c',
115 'stubs/sigprocmask.c',
120 'stubs/tcsendbreak.c',
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
138 'pthread_initialize_minimal.c',
139 'pthread_stubs.c', # weak version of __pthread_initialize
144 # used by both glibc and newlib
145 SRCS_NACL_EXTENSIONS = [
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
159 sources = (SRCS_NACL_EXTENSIONS +
160 SRCS_NEWLIB_SYSCALL +
163 if env.Bit('target_arm') and not env.Bit('bitcode'):
164 sources.append('aeabi_read_tp.S')
166 # Do not make a shared version of libnacl.
167 libnacl = env.ComponentLibrary('libnacl', sources)
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)
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'])
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'])
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'])
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')])
202 'imc_makeboundsock.c',
203 'imc_mem_obj_create.c',
210 libimc_syscalls = env.NaClSdkLibrary('libimc_syscalls', imc_syscalls)
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.
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',
235 sys_private.append(env.Command('combined_private${OBJSUFFIX}',
237 '${LD} -relocatable -o ${TARGET} ${SOURCES}'))
239 if not env.Bit('nonsfi_nacl'):
240 env.ComponentLibrary('libnacl_sys_private', sys_private)