1 # Copyright (c) 2012 The Native Client Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file.
7 '../../../../build/common.gypi',
10 ['target_arch=="x64"', {
12 # No extra reservation.
13 'nacl_reserve_top': '0x0',
16 ['target_arch=="ia32"', {
19 'nacl_reserve_top': '0x40000000',
22 ['target_arch=="arm"', {
24 # 1G address space, plus 8K guard area above.
25 'nacl_reserve_top': '0x40002000',
28 ['target_arch=="mipsel"', {
30 # 1G address space, plus 32K guard area above.
31 'nacl_reserve_top': '0x40008000',
37 'target_name': 'nacl_bootstrap_lib',
38 'type': 'static_library',
39 'product_dir': '<(SHARED_INTERMEDIATE_DIR)/nacl_bootstrap',
48 # Prevent llvm-opt from replacing my_bzero with a call
51 # The tiny standalone bootstrap program is incompatible with
52 # -fstack-protector, which might be on by default. That switch
53 # requires using the standard libc startup code, which we do not.
54 '-fno-stack-protector',
55 # We don't want to compile it PIC (or its cousin PIE), because
56 # it goes at an absolute address anyway, and because any kind
57 # of PIC complicates life for the x86-32 assembly code. We
58 # append -fno-* flags here instead of using a 'cflags!' stanza
59 # to remove -f* flags, just in case some system's compiler
60 # defaults to using PIC for everything.
61 '-fno-pic', '-fno-PIC',
62 '-fno-pie', '-fno-PIE',
70 # We filter these out because release_extra_cflags or another
71 # such thing might be adding them in, and those options wind up
72 # coming after the -fno-stack-protector we added above.
74 '-fstack-protector-all',
75 '-fstack-protector-strong',
77 '-finstrument-functions',
79 # This causes an "unused argument" warning in C targets.
85 # TODO(bbudge) Remove this when Clang supports -fno-pic.
92 'target_name': 'nacl_bootstrap_raw',
94 # This magical flag tells Gyp that the dependencies of this target
95 # are nobody else's business and it should not propagate them up
96 # to things that list this as a dependency. Without this, it will
97 # wind up adding the nacl_bootstrap_lib static library into the
98 # link of sel_ldr or chrome just because one executable depends on
100 # TODO(mcgrathr): Maybe one day Gyp will grow a proper target type
101 # for the use we really want here: custom commands for linking an
102 # executable, and no peeking inside this target just because you
103 # depend on it. Then we could stop using this utterly arcane flag
104 # in favor of something vaguely self-explanatory.
105 # See http://code.google.com/p/gyp/issues/detail?id=239 for the
106 # history of the arcana.
107 'dependencies_traverse': 0,
109 'nacl_bootstrap_lib',
113 'action_name': 'link_with_ld_bfd',
115 'bootstrap_lib': '<(SHARED_INTERMEDIATE_DIR)/nacl_bootstrap/<(STATIC_LIB_PREFIX)nacl_bootstrap_lib<(STATIC_LIB_SUFFIX)',
116 'linker_script': 'nacl_bootstrap.x',
124 '<(PRODUCT_DIR)/nacl_bootstrap_raw',
126 'message': 'Linking nacl_bootstrap_raw',
128 ['target_arch=="x64"', {
130 'linker_emulation': 'elf_x86_64',
133 ['target_arch=="ia32"', {
135 'linker_emulation': 'elf_i386',
138 ['target_arch=="arm"', {
140 'linker_emulation': 'armelf_linux_eabi',
143 ['target_arch=="mipsel"', {
145 'linker_emulation': 'elf32ltsmip',
148 # ld_bfd.py needs to know the target compiler used for the
149 # build but the $CXX environment variable might only be
150 # set at gyp time. This is a hacky way to bake the correct
151 # CXX into the build at gyp time.
152 # TODO(sbc): Do this better by providing some gyp syntax
153 # for accessing the name of the configured compiler, or
154 # even a better way to access gyp time environment
155 # variables from within a gyp file.
158 'compiler': '<!(/bin/echo -n <(android_toolchain)/*-g++)',
161 # When building for ARM default to arm-linux-gnueabihf-g++ rather
162 # than g++. This is needed when building with clang (since in
163 # this case $CC and $CXX are not set in the environment).
164 ['OS!="android" and target_arch=="arm"', {
166 'compiler': '<!(echo ${CXX:=arm-linux-gnueabihf-g++})',
169 ['OS!="android" and target_arch!="arm"', {
171 'compiler': '<!(echo ${CXX:=g++})',
175 'action': ['python', 'ld_bfd.py',
176 '--compiler', '<(compiler)',
177 '-m', '<(linker_emulation)',
179 # This program is (almost) entirely
180 # standalone. It has its own startup code, so
181 # no crt1.o for it. It is statically linked,
182 # and on x86 it does not use libc at all.
183 # However, on ARM it needs a few (safe) things
186 # Link with custom linker script for special
187 # layout. The script uses the symbol RESERVE_TOP.
188 '--defsym', 'RESERVE_TOP=<(nacl_reserve_top)',
189 '--script=<(linker_script)',
190 '-o', '<@(_outputs)',
191 # On x86-64, the default page size with some
192 # linkers is 2M rather than the real Linux page
193 # size of 4K. A larger page size is incompatible
194 # with our custom linker script's special layout.
195 '-z', 'max-page-size=0x1000',
196 '--whole-archive', '<(bootstrap_lib)',
197 '--no-whole-archive',
203 'target_name': 'nacl_helper_bootstrap',
205 'nacl_bootstrap_raw',
208 # See above about this magical flag.
209 # It's actually redundant in practice to have it here as well.
210 # But it expresses the intent: that anything that depends on
211 # this target has no interest in what goes into building it.
212 'dependencies_traverse': 0,
214 'action_name': 'munge_phdr',
215 'inputs': ['nacl_bootstrap_munge_phdr.py',
216 '<(PRODUCT_DIR)/nacl_bootstrap_raw'],
217 'outputs': ['<(PRODUCT_DIR)/nacl_helper_bootstrap'],
218 'message': 'Munging ELF program header',
219 'action': ['python', '<@(_inputs)', '<@(_outputs)']