Skip to content

Commit

Permalink
Revert of Reland chromium#2 of Enable whitelist generation for offici…
Browse files Browse the repository at this point in the history
…al builds. (patchset chromium#2 id:20001 of https://codereview.chromium.org/2271673002/ )

Reason for revert:
Breaking perf try bot https://build.chromium.org/p/tryserver.chromium.perf/builders/android_perf_bisect_builder/builds/14535/steps/compile/logs/stdio

Original issue's description:
> Reland chromium#2 of Enable whitelist generation for official builds.
>
> Previous: https://codereview.chromium.org/2241383004/
>
> Currently, all resources are included in PAK files when Chrome is
> built locally. Only official_buildbot.sh uses a resource whitelist. This CL
> enables local builds to use resource whitelisting by setting the
> enable_resource_whitelist_generation gn flag to true, or by building an
> official build.
>
> This will allow developers to more easily monitor the changes in APK size
> for each commit they make.
>
> However, a large amount of output is generated (_pragma is used to
> create warnings to allow whitelisted resources to be listed), so for now
> the whitelist will only be generated for official builds.
>
> This change results in a ~1.5 mb difference when calculating the APK size with resource_sizes.py.
>
> BUG=632385
>
> Committed: https://crrev.com/c7e6104c8c2ed8080115e92ff3c6f9d748e7feae
> Cr-Commit-Position: refs/heads/master@{#413794}

TBR=agrieve@chromium.org,dpranke@chromium.org,estevenson@chromium.org
# Skipping CQ checks because original CL landed less than 1 days ago.
NOPRESUBMIT=true
NOTREECHECKS=true
NOTRY=true
BUG=632385

Review-Url: https://codereview.chromium.org/2277523002
Cr-Commit-Position: refs/heads/master@{#413860}
  • Loading branch information
pkotwicz authored and Commit bot committed Aug 23, 2016
1 parent 8275e26 commit e925fbc
Show file tree
Hide file tree
Showing 12 changed files with 89 additions and 308 deletions.
25 changes: 15 additions & 10 deletions build/toolchain/gcc_ar_wrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,20 @@
import subprocess
import sys

import wrapper_utils

# When running on a Windows host and using a toolchain whose tools are
# actually wrapper scripts (i.e. .bat files on Windows) rather than binary
# executables, the "command" to run has to be prefixed with this magic.
# The GN toolchain definitions take care of that for when GN/Ninja is
# running the tool directly. When that command is passed in to this
# script, it appears as a unitary string but needs to be split up so that
# just 'cmd' is the actual command given to Python's subprocess module.
BAT_PREFIX = 'cmd /c call '

def CommandToRun(command):
if command[0].startswith(BAT_PREFIX):
command = command[0].split(None, 3) + command[1:]
return command


def main():
Expand All @@ -31,20 +44,12 @@ def main():
metavar='ARCHIVE')
parser.add_argument('--plugin',
help='Load plugin')
parser.add_argument('--resource-whitelist',
help='Merge all resource whitelists into a single file.',
metavar='PATH')
parser.add_argument('operation',
help='Operation on the archive')
parser.add_argument('inputs', nargs='+',
help='Input files')
args = parser.parse_args()

if args.resource_whitelist:
whitelist_candidates = wrapper_utils.ResolveRspLinks(args.inputs)
wrapper_utils.CombineResourceWhitelists(
whitelist_candidates, args.resource_whitelist)

command = [args.ar, args.operation]
if args.plugin is not None:
command += ['--plugin', args.plugin]
Expand All @@ -59,7 +64,7 @@ def main():
raise

# Now just run the ar command.
return subprocess.call(wrapper_utils.CommandToRun(command))
return subprocess.call(CommandToRun(command))


if __name__ == "__main__":
Expand Down
44 changes: 0 additions & 44 deletions build/toolchain/gcc_compile_wrapper.py

This file was deleted.

37 changes: 21 additions & 16 deletions build/toolchain/gcc_solink_wrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,31 @@

import argparse
import os
import re
import subprocess
import sys

import wrapper_utils

# When running on a Windows host and using a toolchain whose tools are
# actually wrapper scripts (i.e. .bat files on Windows) rather than binary
# executables, the "command" to run has to be prefixed with this magic.
# The GN toolchain definitions take care of that for when GN/Ninja is
# running the tool directly. When that command is passed in to this
# script, it appears as a unitary string but needs to be split up so that
# just 'cmd' is the actual command given to Python's subprocess module.
BAT_PREFIX = 'cmd /c call '

def CommandToRun(command):
if command[0].startswith(BAT_PREFIX):
command = command[0].split(None, 3) + command[1:]
return command


def CollectSONAME(args):
"""Replaces: readelf -d $sofile | grep SONAME"""
toc = ''
readelf = subprocess.Popen(wrapper_utils.CommandToRun(
[args.readelf, '-d', args.sofile]), stdout=subprocess.PIPE, bufsize=-1)
readelf = subprocess.Popen(CommandToRun([args.readelf, '-d', args.sofile]),
stdout=subprocess.PIPE, bufsize=-1)
for line in readelf.stdout:
if 'SONAME' in line:
toc += line
Expand All @@ -32,7 +46,7 @@ def CollectSONAME(args):
def CollectDynSym(args):
"""Replaces: nm --format=posix -g -D $sofile | cut -f1-2 -d' '"""
toc = ''
nm = subprocess.Popen(wrapper_utils.CommandToRun([
nm = subprocess.Popen(CommandToRun([
args.nm, '--format=posix', '-g', '-D', args.sofile]),
stdout=subprocess.PIPE, bufsize=-1)
for line in nm.stdout:
Expand Down Expand Up @@ -82,9 +96,6 @@ def main():
required=True,
help='Final output shared object file',
metavar='FILE')
parser.add_argument('--resource-whitelist',
help='Merge all resource whitelists into a single file.',
metavar='PATH')
parser.add_argument('command', nargs='+',
help='Linking command')
args = parser.parse_args()
Expand All @@ -93,14 +104,8 @@ def main():
fast_env = dict(os.environ)
fast_env['LC_ALL'] = 'C'

if args.resource_whitelist:
whitelist_candidates = wrapper_utils.ResolveRspLinks(args.command)
wrapper_utils.CombineResourceWhitelists(
whitelist_candidates, args.resource_whitelist)

# First, run the actual link.
result = subprocess.call(
wrapper_utils.CommandToRun(args.command), env=fast_env)
result = subprocess.call(CommandToRun(args.command), env=fast_env)
if result != 0:
return result

Expand All @@ -115,8 +120,8 @@ def main():

# Finally, strip the linked shared object file (if desired).
if args.strip:
result = subprocess.call(wrapper_utils.CommandToRun(
[args.strip, '--strip-unneeded', '-o', args.output, args.sofile]))
result = subprocess.call(CommandToRun([args.strip, '--strip-unneeded',
'-o', args.output, args.sofile]))

return result

Expand Down
35 changes: 2 additions & 33 deletions build/toolchain/gcc_toolchain.gni
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import("//build/config/v8_target_cpu.gni")
import("//build/toolchain/cc_wrapper.gni")
import("//build/toolchain/goma.gni")
import("//build/toolchain/toolchain.gni")
import("//tools/grit/grit_rule.gni")

# This template defines a toolchain for something that works like gcc
# (including clang).
Expand Down Expand Up @@ -221,41 +220,23 @@ template("gcc_toolchain") {
object_subdir = "{{target_out_dir}}/{{label_name}}"

tool("cc") {
whitelist_flag = " "
if (enable_resource_whitelist_generation) {
whitelist_flag = " --resource-whitelist=\"{{output}}.whitelist\""
}
depfile = "{{output}}.d"
command = "$cc -MMD -MF $depfile ${rebuild_string}{{defines}} {{include_dirs}} {{cflags}} {{cflags_c}}${extra_cppflags}${extra_cflags} -c {{source}} -o {{output}}"
depsformat = "gcc"
description = "CC {{output}}"
outputs = [
# The whitelist file is also an output, but ninja does not
# currently support multiple outputs for tool("cc").
"$object_subdir/{{source_name_part}}.o",
]
compile_wrapper = rebase_path("//build/toolchain/gcc_compile_wrapper.py",
root_build_dir)
command = "$python_path \"$compile_wrapper\"$whitelist_flag $command"
}

tool("cxx") {
whitelist_flag = " "
if (enable_resource_whitelist_generation) {
whitelist_flag = " --resource-whitelist=\"{{output}}.whitelist\""
}
depfile = "{{output}}.d"
command = "$cxx -MMD -MF $depfile ${rebuild_string}{{defines}} {{include_dirs}} {{cflags}} {{cflags_cc}}${extra_cppflags}${extra_cxxflags} -c {{source}} -o {{output}}"
depsformat = "gcc"
description = "CXX {{output}}"
outputs = [
# The whitelist file is also an output, but ninja does not
# currently support multiple outputs for tool("cxx").
"$object_subdir/{{source_name_part}}.o",
]
compile_wrapper = rebase_path("//build/toolchain/gcc_compile_wrapper.py",
root_build_dir)
command = "$python_path \"$compile_wrapper\"$whitelist_flag $command"
}

tool("asm") {
Expand All @@ -271,17 +252,13 @@ template("gcc_toolchain") {

tool("alink") {
rspfile = "{{output}}.rsp"
whitelist_flag = " "
if (enable_resource_whitelist_generation) {
whitelist_flag = " --resource-whitelist=\"{{output}}.whitelist\""
}

# This needs a Python script to avoid using simple sh features in this
# command, in case the host does not use a POSIX shell (e.g. compiling
# POSIX-like toolchains such as NaCl on Windows).
ar_wrapper =
rebase_path("//build/toolchain/gcc_ar_wrapper.py", root_build_dir)
command = "$python_path \"$ar_wrapper\"$whitelist_flag --output={{output}} --ar=\"$ar\" {{arflags}} rcsD @\"$rspfile\""
command = "$python_path \"$ar_wrapper\" --output={{output}} --ar=\"$ar\" {{arflags}} rcsD @\"$rspfile\""
description = "AR {{output}}"
rspfile_content = "{{inputs}}"
outputs = [
Expand All @@ -300,11 +277,6 @@ template("gcc_toolchain") {
sofile = "{{output_dir}}/$soname" # Possibly including toolchain dir.
rspfile = sofile + ".rsp"
pool = "//build/toolchain:link_pool($default_toolchain)"
whitelist_flag = " "
if (enable_resource_whitelist_generation) {
whitelist_file = "$sofile.whitelist"
whitelist_flag = " --resource-whitelist=\"$whitelist_file\""
}

if (defined(invoker.strip)) {
unstripped_sofile = "{{root_out_dir}}/lib.unstripped/$soname"
Expand All @@ -331,7 +303,7 @@ template("gcc_toolchain") {
# 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\" --output=\"$sofile\" -- $link_command"

rspfile_content = "-Wl,--whole-archive {{inputs}} {{solibs}} -Wl,--no-whole-archive $solink_libs_section_prefix {{libs}} $solink_libs_section_postfix"

Expand Down Expand Up @@ -360,9 +332,6 @@ template("gcc_toolchain") {
sofile,
tocfile,
]
if (enable_resource_whitelist_generation) {
outputs += [ whitelist_file ]
}
if (sofile != unstripped_sofile) {
outputs += [ unstripped_sofile ]
}
Expand Down
105 changes: 0 additions & 105 deletions build/toolchain/wrapper_utils.py

This file was deleted.

Loading

0 comments on commit e925fbc

Please sign in to comment.