OLD | NEW |
---|---|
1 # Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 # Copyright (c) 2013 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 import("//build/config/clang/clang.gni") | 5 import("//build/config/clang/clang.gni") |
6 import("//build/config/nacl/config.gni") | 6 import("//build/config/nacl/config.gni") |
7 import("//build/config/sanitizers/sanitizers.gni") | 7 import("//build/config/sanitizers/sanitizers.gni") |
8 import("//build/config/v8_target_cpu.gni") | 8 import("//build/config/v8_target_cpu.gni") |
9 import("//build/toolchain/cc_wrapper.gni") | 9 import("//build/toolchain/cc_wrapper.gni") |
10 import("//build/toolchain/goma.gni") | 10 import("//build/toolchain/goma.gni") |
11 import("//build/toolchain/toolchain.gni") | 11 import("//build/toolchain/toolchain.gni") |
12 import("//build/toolchain/concurrent_links.gni") | 12 import("//build/toolchain/concurrent_links.gni") |
13 import("//tools/grit/grit_rule.gni") | |
13 | 14 |
14 # This template defines a toolchain for something that works like gcc | 15 # This template defines a toolchain for something that works like gcc |
15 # (including clang). | 16 # (including clang). |
16 # | 17 # |
17 # It requires the following variables specifying the executables to run: | 18 # It requires the following variables specifying the executables to run: |
18 # - ar | 19 # - ar |
19 # - cc | 20 # - cc |
20 # - cxx | 21 # - cxx |
21 # - ld | 22 # - ld |
22 # and the following which is used in the toolchain_args | 23 # and the following which is used in the toolchain_args |
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
216 } | 217 } |
217 | 218 |
218 # These library switches can apply to all tools below. | 219 # These library switches can apply to all tools below. |
219 lib_switch = "-l" | 220 lib_switch = "-l" |
220 lib_dir_switch = "-L" | 221 lib_dir_switch = "-L" |
221 | 222 |
222 # Object files go in this directory. | 223 # Object files go in this directory. |
223 object_subdir = "{{target_out_dir}}/{{label_name}}" | 224 object_subdir = "{{target_out_dir}}/{{label_name}}" |
224 | 225 |
225 tool("cc") { | 226 tool("cc") { |
227 if (enable_resource_whitelist_generation) { | |
228 whitelistfile = "{{output}}.whitelist" | |
229 } else { | |
230 whitelistfile = "" | |
231 } | |
226 depfile = "{{output}}.d" | 232 depfile = "{{output}}.d" |
227 command = "$cc -MMD -MF $depfile ${rebuild_string}{{defines}} {{include_di rs}} {{cflags}} {{cflags_c}}${extra_cppflags}${extra_cflags} -c {{source}} -o {{ output}}" | 233 command = "$cc -MMD -MF $depfile ${rebuild_string}{{defines}} {{include_di rs}} {{cflags}} {{cflags_c}}${extra_cppflags}${extra_cflags} -c {{source}} -o {{ output}}" |
228 depsformat = "gcc" | 234 depsformat = "gcc" |
229 description = "CC {{output}}" | 235 description = "CC {{output}}" |
230 outputs = [ | 236 outputs = [ |
237 # The whitelist file is also an output, but ninja does not | |
238 # currently support multiple outputs for tool("cc"). | |
231 "$object_subdir/{{source_name_part}}.o", | 239 "$object_subdir/{{source_name_part}}.o", |
232 ] | 240 ] |
241 compile_wrapper = rebase_path("//build/toolchain/gcc_compile_wrapper.py", | |
242 root_build_dir) | |
243 command = "$python_path \"$compile_wrapper\" --resource-whitelist=\"$white listfile\" $command" | |
agrieve
2016/07/29 01:55:21
For all of these commands, we should not pass --re
estevenson
2016/07/29 15:33:57
Done.
| |
233 } | 244 } |
234 | 245 |
235 tool("cxx") { | 246 tool("cxx") { |
247 if (enable_resource_whitelist_generation) { | |
248 whitelistfile = "{{output}}.whitelist" | |
249 } else { | |
250 whitelistfile = "" | |
251 } | |
236 depfile = "{{output}}.d" | 252 depfile = "{{output}}.d" |
237 command = "$cxx -MMD -MF $depfile ${rebuild_string}{{defines}} {{include_d irs}} {{cflags}} {{cflags_cc}}${extra_cppflags}${extra_cxxflags} -c {{source}} - o {{output}}" | 253 command = "$cxx -MMD -MF $depfile ${rebuild_string}{{defines}} {{include_d irs}} {{cflags}} {{cflags_cc}}${extra_cppflags}${extra_cxxflags} -c {{source}} - o {{output}}" |
238 depsformat = "gcc" | 254 depsformat = "gcc" |
239 description = "CXX {{output}}" | 255 description = "CXX {{output}}" |
240 outputs = [ | 256 outputs = [ |
257 # The whitelist file is also an output, but ninja does not | |
258 # currently support multiple outputs for tool("cxx"). | |
241 "$object_subdir/{{source_name_part}}.o", | 259 "$object_subdir/{{source_name_part}}.o", |
242 ] | 260 ] |
261 compile_wrapper = rebase_path("//build/toolchain/gcc_compile_wrapper.py", | |
262 root_build_dir) | |
263 command = "$python_path \"$compile_wrapper\" --resource-whitelist=\"$white listfile\" $command" | |
243 } | 264 } |
244 | 265 |
245 tool("asm") { | 266 tool("asm") { |
246 # For GCC we can just use the C compiler to compile assembly. | 267 # For GCC we can just use the C compiler to compile assembly. |
247 depfile = "{{output}}.d" | 268 depfile = "{{output}}.d" |
248 command = "$cc -MMD -MF $depfile ${rebuild_string}{{defines}} {{include_di rs}} {{asmflags}} -c {{source}} -o {{output}}" | 269 command = "$cc -MMD -MF $depfile ${rebuild_string}{{defines}} {{include_di rs}} {{asmflags}} -c {{source}} -o {{output}}" |
249 depsformat = "gcc" | 270 depsformat = "gcc" |
250 description = "ASM {{output}}" | 271 description = "ASM {{output}}" |
251 outputs = [ | 272 outputs = [ |
252 "$object_subdir/{{source_name_part}}.o", | 273 "$object_subdir/{{source_name_part}}.o", |
253 ] | 274 ] |
254 } | 275 } |
255 | 276 |
256 tool("alink") { | 277 tool("alink") { |
257 rspfile = "{{output}}.rsp" | 278 rspfile = "{{output}}.rsp" |
279 if (enable_resource_whitelist_generation) { | |
280 whitelistfile = "{{output}}.whitelist" | |
281 } else { | |
282 whitelistfile = "" | |
283 } | |
258 | 284 |
259 # This needs a Python script to avoid using simple sh features in this | 285 # This needs a Python script to avoid using simple sh features in this |
260 # command, in case the host does not use a POSIX shell (e.g. compiling | 286 # command, in case the host does not use a POSIX shell (e.g. compiling |
261 # POSIX-like toolchains such as NaCl on Windows). | 287 # POSIX-like toolchains such as NaCl on Windows). |
262 ar_wrapper = | 288 ar_wrapper = |
263 rebase_path("//build/toolchain/gcc_ar_wrapper.py", root_build_dir) | 289 rebase_path("//build/toolchain/gcc_ar_wrapper.py", root_build_dir) |
264 command = "$python_path \"$ar_wrapper\" --output={{output}} --ar=\"$ar\" { {arflags}} rcsD @\"$rspfile\"" | 290 command = "$python_path \"$ar_wrapper\" --resource-whitelist=\"$whitelistf ile\" --output={{output}} --ar=\"$ar\" {{arflags}} rcsD @\"$rspfile\"" |
265 description = "AR {{output}}" | 291 description = "AR {{output}}" |
266 rspfile_content = "{{inputs}}" | 292 rspfile_content = "{{inputs}}" |
267 outputs = [ | 293 outputs = [ |
268 "{{output_dir}}/{{target_output_name}}{{output_extension}}", | 294 "{{output_dir}}/{{target_output_name}}{{output_extension}}", |
269 ] | 295 ] |
270 | 296 |
271 # Shared libraries go in the target out directory by default so we can | 297 # Shared libraries go in the target out directory by default so we can |
272 # generate different targets with the same name and not have them collide. | 298 # generate different targets with the same name and not have them collide. |
273 default_output_dir = "{{target_out_dir}}" | 299 default_output_dir = "{{target_out_dir}}" |
274 default_output_extension = ".a" | 300 default_output_extension = ".a" |
275 output_prefix = "lib" | 301 output_prefix = "lib" |
276 } | 302 } |
277 | 303 |
278 tool("solink") { | 304 tool("solink") { |
279 soname = "{{target_output_name}}{{output_extension}}" # e.g. "libfoo.so". | 305 soname = "{{target_output_name}}{{output_extension}}" # e.g. "libfoo.so". |
280 sofile = "{{output_dir}}/$soname" # Possibly including toolchain dir. | 306 sofile = "{{output_dir}}/$soname" # Possibly including toolchain dir. |
281 rspfile = sofile + ".rsp" | 307 rspfile = sofile + ".rsp" |
308 if (enable_resource_whitelist_generation) { | |
309 whitelistfile = "$sofile.whitelist" | |
agrieve
2016/07/29 01:55:21
nit: whitelistfile -> whitelist_file
estevenson
2016/07/29 15:33:57
Done.
| |
310 } else { | |
311 whitelistfile = "" | |
312 } | |
282 | 313 |
283 if (defined(invoker.strip)) { | 314 if (defined(invoker.strip)) { |
284 unstripped_sofile = "{{root_out_dir}}/lib.unstripped/$soname" | 315 unstripped_sofile = "{{root_out_dir}}/lib.unstripped/$soname" |
285 } else { | 316 } else { |
286 unstripped_sofile = sofile | 317 unstripped_sofile = sofile |
287 } | 318 } |
288 | 319 |
289 # These variables are not built into GN but are helpers that | 320 # These variables are not built into GN but are helpers that |
290 # implement (1) linking to produce a .so, (2) extracting the symbols | 321 # implement (1) linking to produce a .so, (2) extracting the symbols |
291 # from that file (3) if the extracted list differs from the existing | 322 # from that file (3) if the extracted list differs from the existing |
292 # .TOC file, overwrite it, otherwise, don't change it. | 323 # .TOC file, overwrite it, otherwise, don't change it. |
293 tocfile = sofile + ".TOC" | 324 tocfile = sofile + ".TOC" |
294 | 325 |
295 link_command = "$ld -shared {{ldflags}}${extra_ldflags} -o \"$unstripped_s ofile\" -Wl,-soname=\"$soname\" @\"$rspfile\"" | 326 link_command = "$ld -shared {{ldflags}}${extra_ldflags} -o \"$unstripped_s ofile\" -Wl,-soname=\"$soname\" @\"$rspfile\"" |
296 | 327 |
297 assert(defined(readelf), "to solink you must have a readelf") | 328 assert(defined(readelf), "to solink you must have a readelf") |
298 assert(defined(nm), "to solink you must have an nm") | 329 assert(defined(nm), "to solink you must have an nm") |
299 strip_switch = "" | 330 strip_switch = "" |
300 if (defined(invoker.strip)) { | 331 if (defined(invoker.strip)) { |
301 strip_switch = "--strip=${invoker.strip}" | 332 strip_switch = "--strip=${invoker.strip}" |
302 } | 333 } |
303 | 334 |
304 # This needs a Python script to avoid using a complex shell command | 335 # This needs a Python script to avoid using a complex shell command |
305 # requiring sh control structures, pipelines, and POSIX utilities. | 336 # requiring sh control structures, pipelines, and POSIX utilities. |
306 # The host might not have a POSIX shell and utilities (e.g. Windows). | 337 # The host might not have a POSIX shell and utilities (e.g. Windows). |
307 solink_wrapper = rebase_path("//build/toolchain/gcc_solink_wrapper.py") | 338 solink_wrapper = rebase_path("//build/toolchain/gcc_solink_wrapper.py") |
308 command = "$python_path \"$solink_wrapper\" --readelf=\"$readelf\" --nm=\" $nm\" $strip_switch --sofile=\"$unstripped_sofile\" --tocfile=\"$tocfile\" --out put=\"$sofile\" -- $link_command" | 339 command = "$python_path \"$solink_wrapper\" --readelf=\"$readelf\" --nm=\" $nm\" $strip_switch --sofile=\"$unstripped_sofile\" --tocfile=\"$tocfile\" --out put=\"$sofile\" --resource-whitelist=\"$whitelistfile\" -- $link_command" |
309 | 340 |
310 rspfile_content = "-Wl,--whole-archive {{inputs}} {{solibs}} -Wl,--no-whol e-archive $solink_libs_section_prefix {{libs}} $solink_libs_section_postfix" | 341 rspfile_content = "-Wl,--whole-archive {{inputs}} {{solibs}} -Wl,--no-whol e-archive $solink_libs_section_prefix {{libs}} $solink_libs_section_postfix" |
311 | 342 |
312 description = "SOLINK $sofile" | 343 description = "SOLINK $sofile" |
313 | 344 |
314 # Use this for {{output_extension}} expansions unless a target manually | 345 # Use this for {{output_extension}} expansions unless a target manually |
315 # overrides it (in which case {{output_extension}} will be what the target | 346 # overrides it (in which case {{output_extension}} will be what the target |
316 # specifies). | 347 # specifies). |
317 default_output_extension = default_shlib_extension | 348 default_output_extension = default_shlib_extension |
318 | 349 |
319 default_output_dir = "{{root_out_dir}}" | 350 default_output_dir = "{{root_out_dir}}" |
320 if (shlib_subdir != ".") { | 351 if (shlib_subdir != ".") { |
321 default_output_dir += "/$shlib_subdir" | 352 default_output_dir += "/$shlib_subdir" |
322 } | 353 } |
323 | 354 |
324 output_prefix = "lib" | 355 output_prefix = "lib" |
325 | 356 |
326 # Since the above commands only updates the .TOC file when it changes, ask | 357 # Since the above commands only updates the .TOC file when it changes, ask |
327 # Ninja to check if the timestamp actually changed to know if downstream | 358 # Ninja to check if the timestamp actually changed to know if downstream |
328 # dependencies should be recompiled. | 359 # dependencies should be recompiled. |
329 restat = true | 360 restat = true |
330 | 361 |
331 # Tell GN about the output files. It will link to the sofile but use the | 362 # Tell GN about the output files. It will link to the sofile but use the |
332 # tocfile for dependency management. | 363 # tocfile for dependency management. |
333 outputs = [ | 364 outputs = [ |
334 sofile, | 365 sofile, |
335 tocfile, | 366 tocfile, |
367 whitelistfile, | |
agrieve
2016/07/29 01:55:21
Should not list this in outputs unless enable_reso
estevenson
2016/07/29 15:33:57
Done.
| |
336 ] | 368 ] |
337 if (sofile != unstripped_sofile) { | 369 if (sofile != unstripped_sofile) { |
338 outputs += [ unstripped_sofile ] | 370 outputs += [ unstripped_sofile ] |
339 } | 371 } |
340 link_output = sofile | 372 link_output = sofile |
341 depend_output = tocfile | 373 depend_output = tocfile |
342 } | 374 } |
343 | 375 |
344 tool("solink_module") { | 376 tool("solink_module") { |
345 soname = "{{target_output_name}}{{output_extension}}" # e.g. "libfoo.so". | 377 soname = "{{target_output_name}}{{output_extension}}" # e.g. "libfoo.so". |
(...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
538 "toolchain_os", | 570 "toolchain_os", |
539 "use_gold", | 571 "use_gold", |
540 "v8_toolchain_cpu", | 572 "v8_toolchain_cpu", |
541 ]) | 573 ]) |
542 | 574 |
543 if (defined(invoker.use_debug_fission)) { | 575 if (defined(invoker.use_debug_fission)) { |
544 use_debug_fission = invoker.use_debug_fission | 576 use_debug_fission = invoker.use_debug_fission |
545 } | 577 } |
546 } | 578 } |
547 } | 579 } |
OLD | NEW |