Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(493)

Side by Side Diff: build/toolchain/gcc_toolchain.gni

Issue 2726983004: Output a linker map file for official builds (Closed)
Patch Set: linux Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « build/toolchain/gcc_solink_wrapper.py ('k') | build/toolchain/linux/BUILD.gn » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/android/config.gni") 5 import("//build/config/android/config.gni")
6 import("//build/config/clang/clang.gni") 6 import("//build/config/clang/clang.gni")
7 import("//build/config/nacl/config.gni") 7 import("//build/config/nacl/config.gni")
8 import("//build/config/sanitizers/sanitizers.gni") 8 import("//build/config/sanitizers/sanitizers.gni")
9 import("//build/config/v8_target_cpu.gni") 9 import("//build/config/v8_target_cpu.gni")
10 import("//build/toolchain/cc_wrapper.gni") 10 import("//build/toolchain/cc_wrapper.gni")
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after
207 } else { 207 } else {
208 extra_cxxflags = "" 208 extra_cxxflags = ""
209 } 209 }
210 210
211 if (defined(invoker.extra_ldflags) && invoker.extra_ldflags != "") { 211 if (defined(invoker.extra_ldflags) && invoker.extra_ldflags != "") {
212 extra_ldflags = " " + invoker.extra_ldflags 212 extra_ldflags = " " + invoker.extra_ldflags
213 } else { 213 } else {
214 extra_ldflags = "" 214 extra_ldflags = ""
215 } 215 }
216 216
217 enable_linker_map =
218 defined(invoker.enable_linker_map) && invoker.enable_linker_map
219
217 # These library switches can apply to all tools below. 220 # These library switches can apply to all tools below.
218 lib_switch = "-l" 221 lib_switch = "-l"
219 lib_dir_switch = "-L" 222 lib_dir_switch = "-L"
220 223
221 # Object files go in this directory. 224 # Object files go in this directory.
222 object_subdir = "{{target_out_dir}}/{{label_name}}" 225 object_subdir = "{{target_out_dir}}/{{label_name}}"
223 226
224 tool("cc") { 227 tool("cc") {
225 depfile = "{{output}}.d" 228 depfile = "{{output}}.d"
226 command = "$cc -MMD -MF $depfile ${rebuild_string}{{defines}} {{include_di rs}} {{cflags}} {{cflags_c}}${extra_cppflags}${extra_cflags} -c {{source}} -o {{ output}}" 229 command = "$cc -MMD -MF $depfile ${rebuild_string}{{defines}} {{include_di rs}} {{cflags}} {{cflags_c}}${extra_cppflags}${extra_cflags} -c {{source}} -o {{ output}}"
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
312 } 315 }
313 316
314 # These variables are not built into GN but are helpers that 317 # These variables are not built into GN but are helpers that
315 # implement (1) linking to produce a .so, (2) extracting the symbols 318 # implement (1) linking to produce a .so, (2) extracting the symbols
316 # from that file (3) if the extracted list differs from the existing 319 # from that file (3) if the extracted list differs from the existing
317 # .TOC file, overwrite it, otherwise, don't change it. 320 # .TOC file, overwrite it, otherwise, don't change it.
318 tocfile = sofile + ".TOC" 321 tocfile = sofile + ".TOC"
319 322
320 link_command = "$ld -shared {{ldflags}}${extra_ldflags} -o \"$unstripped_s ofile\" -Wl,-soname=\"$soname\" @\"$rspfile\"" 323 link_command = "$ld -shared {{ldflags}}${extra_ldflags} -o \"$unstripped_s ofile\" -Wl,-soname=\"$soname\" @\"$rspfile\""
321 324
325 # Generate a map file to be used for binary size analysis.
326 # Map file adds ~10% to the link time on a z620.
327 # With target_os="android", libchrome.so.map.gz is ~20MB.
328 map_switch = ""
329 if (enable_linker_map && is_official_build) {
330 map_file = "$unstripped_sofile.map.gz"
331 map_switch = " --map-file \"$map_file\""
332 }
333
322 assert(defined(readelf), "to solink you must have a readelf") 334 assert(defined(readelf), "to solink you must have a readelf")
323 assert(defined(nm), "to solink you must have an nm") 335 assert(defined(nm), "to solink you must have an nm")
324 strip_switch = "" 336 strip_switch = ""
325 if (defined(invoker.strip)) { 337 if (defined(invoker.strip)) {
326 strip_switch = "--strip=${invoker.strip}" 338 strip_switch = "--strip=${invoker.strip} "
327 } 339 }
328 340
329 # This needs a Python script to avoid using a complex shell command 341 # This needs a Python script to avoid using a complex shell command
330 # requiring sh control structures, pipelines, and POSIX utilities. 342 # requiring sh control structures, pipelines, and POSIX utilities.
331 # The host might not have a POSIX shell and utilities (e.g. Windows). 343 # The host might not have a POSIX shell and utilities (e.g. Windows).
332 solink_wrapper = rebase_path("//build/toolchain/gcc_solink_wrapper.py") 344 solink_wrapper = rebase_path("//build/toolchain/gcc_solink_wrapper.py")
333 command = "$python_path \"$solink_wrapper\" --readelf=\"$readelf\" --nm=\" $nm\" $strip_switch --sofile=\"$unstripped_sofile\" --tocfile=\"$tocfile\" --out put=\"$sofile\"$whitelist_flag -- $link_command" 345 command = "$python_path \"$solink_wrapper\" --readelf=\"$readelf\" --nm=\" $nm\" $strip_switch--sofile=\"$unstripped_sofile\" --tocfile=\"$tocfile\"$map_sw itch --output=\"$sofile\"$whitelist_flag -- $link_command"
334 346
335 rspfile_content = "-Wl,--whole-archive {{inputs}} {{solibs}} -Wl,--no-whol e-archive $solink_libs_section_prefix {{libs}} $solink_libs_section_postfix" 347 rspfile_content = "-Wl,--whole-archive {{inputs}} {{solibs}} -Wl,--no-whol e-archive $solink_libs_section_prefix {{libs}} $solink_libs_section_postfix"
336 348
337 description = "SOLINK $sofile" 349 description = "SOLINK $sofile"
338 350
339 # Use this for {{output_extension}} expansions unless a target manually 351 # Use this for {{output_extension}} expansions unless a target manually
340 # overrides it (in which case {{output_extension}} will be what the target 352 # overrides it (in which case {{output_extension}} will be what the target
341 # specifies). 353 # specifies).
342 default_output_extension = default_shlib_extension 354 default_output_extension = default_shlib_extension
343 355
(...skipping 14 matching lines...) Expand all
358 outputs = [ 370 outputs = [
359 sofile, 371 sofile,
360 tocfile, 372 tocfile,
361 ] 373 ]
362 if (enable_resource_whitelist_generation) { 374 if (enable_resource_whitelist_generation) {
363 outputs += [ whitelist_file ] 375 outputs += [ whitelist_file ]
364 } 376 }
365 if (sofile != unstripped_sofile) { 377 if (sofile != unstripped_sofile) {
366 outputs += [ unstripped_sofile ] 378 outputs += [ unstripped_sofile ]
367 } 379 }
380 if (defined(map_file)) {
381 outputs += [ map_file ]
382 }
368 link_output = sofile 383 link_output = sofile
369 depend_output = tocfile 384 depend_output = tocfile
370 } 385 }
371 386
372 tool("solink_module") { 387 tool("solink_module") {
373 soname = "{{target_output_name}}{{output_extension}}" # e.g. "libfoo.so". 388 soname = "{{target_output_name}}{{output_extension}}" # e.g. "libfoo.so".
374 sofile = "{{output_dir}}/$soname" 389 sofile = "{{output_dir}}/$soname"
375 rspfile = sofile + ".rsp" 390 rspfile = sofile + ".rsp"
376 pool = "//build/toolchain:link_pool($default_toolchain)" 391 pool = "//build/toolchain:link_pool($default_toolchain)"
377 392
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
426 # overrides it (in which case {{output_extension}} will be what the target 441 # overrides it (in which case {{output_extension}} will be what the target
427 # specifies). 442 # specifies).
428 default_output_extension = default_executable_extension 443 default_output_extension = default_executable_extension
429 444
430 default_output_dir = "{{root_out_dir}}" 445 default_output_dir = "{{root_out_dir}}"
431 446
432 if (defined(invoker.strip)) { 447 if (defined(invoker.strip)) {
433 unstripped_outfile = "{{root_out_dir}}/exe.unstripped/$exename" 448 unstripped_outfile = "{{root_out_dir}}/exe.unstripped/$exename"
434 } 449 }
435 450
436 command = "$ld {{ldflags}}${extra_ldflags} -o \"$unstripped_outfile\" -Wl, --start-group @\"$rspfile\" {{solibs}} -Wl,--end-group $libs_section_prefix {{li bs}} $libs_section_postfix" 451 # Generate a map file to be used for binary size analysis.
452 # Map file adds ~10% to the link time on a z620.
453 # With target_os="android", libchrome.so.map.gz is ~20MB.
454 map_switch = ""
455 if (enable_linker_map && is_official_build) {
456 map_file = "$unstripped_outfile.map.gz"
457 map_switch = " --map-file \"$map_file\""
458 }
459
460 link_command = "$ld {{ldflags}}${extra_ldflags} -o \"$unstripped_outfile\" -Wl,--start-group @\"$rspfile\" {{solibs}} -Wl,--end-group $libs_section_prefix {{libs}} $libs_section_postfix"
461
462 strip_switch = ""
437 if (defined(invoker.strip)) { 463 if (defined(invoker.strip)) {
438 link_wrapper = 464 strip_switch = " --strip=\"${invoker.strip}\" --unstripped-file=\"$unstr ipped_outfile\""
439 rebase_path("//build/toolchain/gcc_link_wrapper.py", root_build_dir)
440 command = "$python_path \"$link_wrapper\" --strip=\"${invoker.strip}\" - -unstripped-file=\"$unstripped_outfile\" --output=\"$outfile\" -- $command"
441 } 465 }
466
467 link_wrapper =
468 rebase_path("//build/toolchain/gcc_link_wrapper.py", root_build_dir)
469 command = "$python_path \"$link_wrapper\" --output=\"$outfile\"$strip_swit ch$map_switch -- $link_command"
442 description = "LINK $outfile" 470 description = "LINK $outfile"
443 rspfile_content = "{{inputs}}" 471 rspfile_content = "{{inputs}}"
444 outputs = [ 472 outputs = [
445 outfile, 473 outfile,
446 ] 474 ]
447 if (outfile != unstripped_outfile) { 475 if (outfile != unstripped_outfile) {
448 outputs += [ unstripped_outfile ] 476 outputs += [ unstripped_outfile ]
449 } 477 }
450 if (defined(invoker.link_outputs)) { 478 if (defined(invoker.link_outputs)) {
451 outputs += invoker.link_outputs 479 outputs += invoker.link_outputs
452 } 480 }
481 if (defined(map_file)) {
482 outputs += [ map_file ]
483 }
453 } 484 }
454 485
455 # These two are really entirely generic, but have to be repeated in 486 # These two are really entirely generic, but have to be repeated in
456 # each toolchain because GN doesn't allow a template to be used here. 487 # each toolchain because GN doesn't allow a template to be used here.
457 # See //build/toolchain/toolchain.gni for details. 488 # See //build/toolchain/toolchain.gni for details.
458 tool("stamp") { 489 tool("stamp") {
459 command = stamp_command 490 command = stamp_command
460 description = stamp_description 491 description = stamp_description
461 } 492 }
462 tool("copy") { 493 tool("copy") {
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
504 root_build_dir) 535 root_build_dir)
505 cxx = analyzer_wrapper + " --clang-cxx-path=${cxx} --analyzer=" + 536 cxx = analyzer_wrapper + " --clang-cxx-path=${cxx} --analyzer=" +
506 rebase_path("//third_party/scan-build/src/libexec/c++-analyzer", 537 rebase_path("//third_party/scan-build/src/libexec/c++-analyzer",
507 root_build_dir) 538 root_build_dir)
508 } 539 }
509 540
510 readelf = "${toolprefix}readelf" 541 readelf = "${toolprefix}readelf"
511 ar = "${toolprefix}ar" 542 ar = "${toolprefix}ar"
512 nm = "${toolprefix}nm" 543 nm = "${toolprefix}nm"
513 544
514 forward_variables_from(invoker, [ "strip" ]) 545 forward_variables_from(invoker,
546 [
547 "enable_linker_map",
548 "strip",
549 ])
515 550
516 toolchain_args = { 551 toolchain_args = {
517 if (defined(invoker.toolchain_args)) { 552 if (defined(invoker.toolchain_args)) {
518 forward_variables_from(invoker.toolchain_args, "*") 553 forward_variables_from(invoker.toolchain_args, "*")
519 } 554 }
520 is_clang = true 555 is_clang = true
521 } 556 }
522 } 557 }
523 } 558 }
OLDNEW
« no previous file with comments | « build/toolchain/gcc_solink_wrapper.py ('k') | build/toolchain/linux/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698