[rust] Fix supersize for latest Rust layout.
Rust/gn integration nowadays specifies .rlib files as input to the final
linking process, but not as explicit dependencies for the solink rule -
instead as implicit dependencies, and then a separate rlibs = variable.
Extend binary size tools to understand this layout.
Prior to this change, Rust symbols were correctly listed in the
supersize output but listed against (No path). After this change, they
are correctly accounted to the correct .rs source code file.
Testing:
Steps performed as in https://crrev.com/2b6ee85aa1c7d521688fa38062afee187a217705
except the diffing command is nowadays
tools/binary_size/supersize save_diff out.size out2.size report-diff.sizediff
Bug: 1454085
Change-Id: Ib053335e5a3b35bece5e82d26800139fac50ea90
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4614644
Commit-Queue: Adrian Taylor <adetaylor@chromium.org>
Reviewed-by: Andrew Grieve <agrieve@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1158054}
This commit is contained in:

committed by
Chromium LUCI CQ

parent
284bd80b4a
commit
ecad65b7a2
@ -18,6 +18,8 @@ import sys
|
||||
# build libmonochrome.so: __chrome_android_libmonochrome___rule | ...
|
||||
_REGEX = re.compile(r'build ([^:]+): \w+ (.*?)(?: *\||\n|$)')
|
||||
|
||||
_RLIBS_REGEX = re.compile(r' rlibs = (.*?)(?:\n|$)')
|
||||
|
||||
|
||||
class _SourceMapper:
|
||||
def __init__(self, dep_map, parsed_file_count):
|
||||
@ -85,6 +87,7 @@ def _OutputsAreObject(outputs):
|
||||
def _ParseOneFile(lines, dep_map, elf_path):
|
||||
sub_ninjas = []
|
||||
elf_inputs = None
|
||||
last_elf_paths = []
|
||||
for line in lines:
|
||||
if line.startswith('subninja '):
|
||||
sub_ninjas.append(line[9:-1])
|
||||
@ -100,11 +103,21 @@ def _ParseOneFile(lines, dep_map, elf_path):
|
||||
else:
|
||||
obj_paths = _ParseNinjaPathList(srcs)
|
||||
dep_map[output] = {os.path.basename(p): p for p in obj_paths}
|
||||
elif elf_path and elf_path in outputs:
|
||||
properly_parsed = [
|
||||
os.path.normpath(p) for p in _ParseNinjaPathList(outputs)]
|
||||
if elf_path in properly_parsed:
|
||||
elif elf_path:
|
||||
last_elf_paths = [
|
||||
os.path.normpath(p) for p in _ParseNinjaPathList(outputs)
|
||||
]
|
||||
if elf_path in last_elf_paths:
|
||||
elf_inputs = _ParseNinjaPathList(srcs)
|
||||
# Rust .rlibs are listed as implicit dependencies of the main
|
||||
# target linking rule, then are given as an extra
|
||||
# rlibs =
|
||||
# variable on a subsequent line. Watch out for that line.
|
||||
m = _RLIBS_REGEX.match(line)
|
||||
if m:
|
||||
if elf_path in last_elf_paths:
|
||||
elf_inputs.extend(_ParseNinjaPathList(m.group(1)))
|
||||
|
||||
return sub_ninjas, elf_inputs
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user