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

Unified 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 side-by-side diff with in-line comments
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 »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: build/toolchain/gcc_toolchain.gni
diff --git a/build/toolchain/gcc_toolchain.gni b/build/toolchain/gcc_toolchain.gni
index b31980668d89732523e9765f83e2e24f7caf1a4d..21985f88852ed678f085bdcb011f59d49234e0be 100644
--- a/build/toolchain/gcc_toolchain.gni
+++ b/build/toolchain/gcc_toolchain.gni
@@ -214,6 +214,9 @@ template("gcc_toolchain") {
extra_ldflags = ""
}
+ enable_linker_map =
+ defined(invoker.enable_linker_map) && invoker.enable_linker_map
+
# These library switches can apply to all tools below.
lib_switch = "-l"
lib_dir_switch = "-L"
@@ -319,18 +322,27 @@ template("gcc_toolchain") {
link_command = "$ld -shared {{ldflags}}${extra_ldflags} -o \"$unstripped_sofile\" -Wl,-soname=\"$soname\" @\"$rspfile\""
+ # Generate a map file to be used for binary size analysis.
+ # Map file adds ~10% to the link time on a z620.
+ # With target_os="android", libchrome.so.map.gz is ~20MB.
+ map_switch = ""
+ if (enable_linker_map && is_official_build) {
+ map_file = "$unstripped_sofile.map.gz"
+ map_switch = " --map-file \"$map_file\""
+ }
+
assert(defined(readelf), "to solink you must have a readelf")
assert(defined(nm), "to solink you must have an nm")
strip_switch = ""
if (defined(invoker.strip)) {
- strip_switch = "--strip=${invoker.strip}"
+ strip_switch = "--strip=${invoker.strip} "
}
# This needs a Python script to avoid using a complex shell command
# requiring sh control structures, pipelines, and POSIX utilities.
# The host might not have a POSIX shell and utilities (e.g. Windows).
solink_wrapper = rebase_path("//build/toolchain/gcc_solink_wrapper.py")
- command = "$python_path \"$solink_wrapper\" --readelf=\"$readelf\" --nm=\"$nm\" $strip_switch --sofile=\"$unstripped_sofile\" --tocfile=\"$tocfile\" --output=\"$sofile\"$whitelist_flag -- $link_command"
+ command = "$python_path \"$solink_wrapper\" --readelf=\"$readelf\" --nm=\"$nm\" $strip_switch--sofile=\"$unstripped_sofile\" --tocfile=\"$tocfile\"$map_switch --output=\"$sofile\"$whitelist_flag -- $link_command"
rspfile_content = "-Wl,--whole-archive {{inputs}} {{solibs}} -Wl,--no-whole-archive $solink_libs_section_prefix {{libs}} $solink_libs_section_postfix"
@@ -365,6 +377,9 @@ template("gcc_toolchain") {
if (sofile != unstripped_sofile) {
outputs += [ unstripped_sofile ]
}
+ if (defined(map_file)) {
+ outputs += [ map_file ]
+ }
link_output = sofile
depend_output = tocfile
}
@@ -433,12 +448,25 @@ template("gcc_toolchain") {
unstripped_outfile = "{{root_out_dir}}/exe.unstripped/$exename"
}
- command = "$ld {{ldflags}}${extra_ldflags} -o \"$unstripped_outfile\" -Wl,--start-group @\"$rspfile\" {{solibs}} -Wl,--end-group $libs_section_prefix {{libs}} $libs_section_postfix"
+ # Generate a map file to be used for binary size analysis.
+ # Map file adds ~10% to the link time on a z620.
+ # With target_os="android", libchrome.so.map.gz is ~20MB.
+ map_switch = ""
+ if (enable_linker_map && is_official_build) {
+ map_file = "$unstripped_outfile.map.gz"
+ map_switch = " --map-file \"$map_file\""
+ }
+
+ link_command = "$ld {{ldflags}}${extra_ldflags} -o \"$unstripped_outfile\" -Wl,--start-group @\"$rspfile\" {{solibs}} -Wl,--end-group $libs_section_prefix {{libs}} $libs_section_postfix"
+
+ strip_switch = ""
if (defined(invoker.strip)) {
- link_wrapper =
- rebase_path("//build/toolchain/gcc_link_wrapper.py", root_build_dir)
- command = "$python_path \"$link_wrapper\" --strip=\"${invoker.strip}\" --unstripped-file=\"$unstripped_outfile\" --output=\"$outfile\" -- $command"
+ strip_switch = " --strip=\"${invoker.strip}\" --unstripped-file=\"$unstripped_outfile\""
}
+
+ link_wrapper =
+ rebase_path("//build/toolchain/gcc_link_wrapper.py", root_build_dir)
+ command = "$python_path \"$link_wrapper\" --output=\"$outfile\"$strip_switch$map_switch -- $link_command"
description = "LINK $outfile"
rspfile_content = "{{inputs}}"
outputs = [
@@ -450,6 +478,9 @@ template("gcc_toolchain") {
if (defined(invoker.link_outputs)) {
outputs += invoker.link_outputs
}
+ if (defined(map_file)) {
+ outputs += [ map_file ]
+ }
}
# These two are really entirely generic, but have to be repeated in
@@ -511,7 +542,11 @@ template("clang_toolchain") {
ar = "${toolprefix}ar"
nm = "${toolprefix}nm"
- forward_variables_from(invoker, [ "strip" ])
+ forward_variables_from(invoker,
+ [
+ "enable_linker_map",
+ "strip",
+ ])
toolchain_args = {
if (defined(invoker.toolchain_args)) {
« 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