OLD | NEW |
1 # Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 # Copyright (c) 2011 The Chromium Authors. All rights reserved. |
2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
4 | 4 |
5 { | 5 { |
6 'target_defaults': { | 6 'target_defaults': { |
7 'variables': { | 7 'variables': { |
8 'nacl_target': 0, | 8 'nacl_target': 0, |
9 }, | 9 }, |
10 'target_conditions': [ | 10 'target_conditions': [ |
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
176 'NACL_BLOCK_SIZE=32', | 176 'NACL_BLOCK_SIZE=32', |
177 '<@(nacl_defines)', | 177 '<@(nacl_defines)', |
178 ], | 178 ], |
179 }, | 179 }, |
180 }, | 180 }, |
181 ], | 181 ], |
182 }], | 182 }], |
183 ['OS=="linux"', { | 183 ['OS=="linux"', { |
184 'targets': [ | 184 'targets': [ |
185 { | 185 { |
186 'target_name': 'nacl_helper', | 186 'target_name': 'nacl_helper.so', |
| 187 # 'executable' will be overridden below when we add the -shared |
| 188 # flag; here it prevents gyp from using the --whole-archive flag |
187 'type': 'executable', | 189 'type': 'executable', |
188 'include_dirs': [ | 190 'include_dirs': [ |
189 '..', | 191 '..', |
190 ], | 192 ], |
191 'dependencies': [ | 193 'dependencies': [ |
192 'nacl', | 194 'nacl', |
193 ], | 195 ], |
194 'sources': [ | 196 'sources': [ |
195 'nacl/nacl_helper_linux.cc', | 197 '../chrome/nacl/nacl_helper_linux.cc', |
196 ], | 198 ], |
197 'conditions': [ | 199 'conditions': [ |
198 ['toolkit_uses_gtk == 1', { | 200 ['toolkit_uses_gtk == 1', { |
199 'dependencies': [ | 201 'dependencies': [ |
200 '../build/linux/system.gyp:gtk', | 202 '../build/linux/system.gyp:gtk', |
201 ], | 203 ], |
202 }], | 204 }], |
203 ], | 205 ], |
204 'cflags': ['-fPIE'], | |
205 'link_settings': { | 206 'link_settings': { |
206 'ldflags': ['-pie'], | 207 # NOTE: '-shared' overrides 'executable' above |
207 }, | 208 'ldflags': ['-shared', |
208 }, | 209 '-Wl,--version-script=chrome/nacl/nacl_helper_exports.tx
t', |
209 { | 210 ], |
210 'target_name': 'nacl_helper_bootstrap_munge_phdr', | |
211 'type': 'executable', | |
212 'toolsets': ['host'], | |
213 'sources': [ | |
214 'nacl/nacl_helper_bootstrap_munge_phdr.c', | |
215 ], | |
216 'libraries': [ | |
217 '-lelf', | |
218 ], | |
219 # This is an ugly kludge because gyp doesn't actually treat | |
220 # host_arch=x64 target_arch=ia32 as proper cross compilation. | |
221 # It still wants to compile the "host" program with -m32 et | |
222 # al. Though a program built that way can indeed run on the | |
223 # x86-64 host, we cannot reliably build this program on such a | |
224 # host because Ubuntu does not provide the full suite of | |
225 # x86-32 libraries in packages that can be installed on an | |
226 # x86-64 host; in particular, libelf is missing. So here we | |
227 # use the hack of eliding all the -m* flags from the | |
228 # compilation lines, getting the command close to what they | |
229 # would be if gyp were to really build properly for the host. | |
230 # TODO(bradnelson): Clean up with proper cross support. | |
231 'conditions': [ | |
232 ['host_arch=="x64"', { | |
233 'cflags/': [['exclude', '-m.*']], | |
234 'ldflags/': [['exclude', '-m.*']], | |
235 }], | |
236 ], | |
237 }, | |
238 { | |
239 'target_name': 'nacl_helper_bootstrap_raw', | |
240 'type': 'executable', | |
241 'include_dirs': [ | |
242 '..', | |
243 ], | |
244 'sources': [ | |
245 'nacl/nacl_helper_bootstrap_linux.c', | |
246 # We list the linker script here for documentation purposes. | |
247 # But even this doesn't make gyp treat it as a dependency, | |
248 # so incremental builds won't relink when the script changes. | |
249 # TODO(bradnelson): Fix the dependency handling. | |
250 'nacl/nacl_helper_bootstrap_linux.x', | |
251 ], | |
252 'cflags': [ | |
253 # The tiny standalone bootstrap program is incompatible with | |
254 # -fstack-protector, which might be on by default. That switch | |
255 # requires using the standard libc startup code, which we do not. | |
256 '-fno-stack-protector', | |
257 # We don't want to compile it PIC (or its cousin PIE), because | |
258 # it goes at an absolute address anyway, and because any kind | |
259 # of PIC complicates life for the x86-32 assembly code. We | |
260 # append -fno-* flags here instead of using a 'cflags!' stanza | |
261 # to remove -f* flags, just in case some system's compiler | |
262 # defaults to using PIC for everything. | |
263 '-fno-pic', '-fno-PIC', | |
264 '-fno-pie', '-fno-PIE', | |
265 ], | |
266 'link_settings': { | |
267 'ldflags': [ | |
268 # TODO(bradchen): Delete the -B argument when Gold is verified | |
269 # to produce good results with our custom linker script. | |
270 # Until then use ld.bfd. | |
271 '-B', 'tools/ld_bfd', | |
272 # This programs is (almost) entirely standalone. It has | |
273 # its own startup code, so no crt1.o for it. It is | |
274 # statically linked, and on x86 it actually does not use | |
275 # libc at all. However, on ARM it needs a few (safe) | |
276 # things from libc, so we don't use '-nostdlib' here. | |
277 '-static', '-nostartfiles', | |
278 # Link with our custom linker script to get out special layout. | |
279 # TODO(bradnelson): Use some <(foo) instead of chrome/ here. | |
280 '-Wl,--script=chrome/nacl/nacl_helper_bootstrap_linux.x', | |
281 # On x86-64, the default page size with some | |
282 # linkers is 2M rather than the real Linux page | |
283 # size of 4K. A larger page size is incompatible | |
284 # with our custom linker script's special layout. | |
285 '-Wl,-z,max-page-size=0x1000', | |
286 ], | |
287 }, | 211 }, |
288 }, | 212 }, |
289 { | 213 { |
290 'target_name': 'nacl_helper_bootstrap', | 214 'target_name': 'nacl_helper_bootstrap', |
| 215 'type': 'executable', |
291 'dependencies': [ | 216 'dependencies': [ |
292 'nacl_helper_bootstrap_raw', | 217 'nacl_helper.so', |
293 'nacl_helper_bootstrap_munge_phdr#host', | |
294 ], | 218 ], |
295 'type': 'none', | 219 'sources': [ |
296 'actions': [{ | 220 '../chrome/nacl/nacl_helper_bootstrap_linux.c', |
297 'action_name': 'munge_phdr', | 221 ], |
298 'inputs': ['nacl/nacl_helper_bootstrap_munge_phdr.py', | 222 # TODO(bradchen): Delete the -B argument when Gold supports |
299 '<(PRODUCT_DIR)/nacl_helper_bootstrap_munge_phdr', | 223 # -Ttext properly. Until then use ld.bfd. |
300 '<(PRODUCT_DIR)/nacl_helper_bootstrap_raw'], | 224 'link_settings': { |
301 'outputs': ['<(PRODUCT_DIR)/nacl_helper_bootstrap'], | 225 'ldflags': ['-B', 'tools/ld_bfd', |
302 'message': 'Munging ELF program header', | 226 # Force text segment at 0x10000 (64KB) |
303 'action': ['python', '<@(_inputs)', '<@(_outputs)'] | 227 # The max-page-size option is needed on x86-64 linux |
304 }], | 228 # where 4K pages are not the default in the BFD linker. |
305 } | 229 '-Wl,-Ttext-segment,10000,-z,max-page-size=0x1000', |
| 230 # reference nacl_helper as a shared library |
| 231 '<(PRODUCT_DIR)/nacl_helper.so', |
| 232 '-Wl,-rpath,<(SHARED_LIB_DIR)', |
| 233 ], |
| 234 }, |
| 235 }, |
306 ], | 236 ], |
307 }], | 237 }], |
308 ], | 238 ], |
309 } | 239 } |
OLD | NEW |