Skip to content

Commit ac1d93a

Browse files
alanzhao1Chromium LUCI CQ
authored andcommitted
[libsupersize] Fix LTO detection for upcoming clang roll
This is a reland of the changes made in https://crrev.com/c/5254957 with an additional fix to _DetectLto(...). A consequence of llvm/llvm-project#78835 is that map files will no longer include the lto cache directory (see maskray@'s comment at https://g-issues.chromium.org/issues/41496774#comment17). This CL updates libsupersize to support that new filename format. Bug: 41496774 Change-Id: I8bc08cd8f54f7b241cd4a0d4f40879e640d03d04 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5277968 Reviewed-by: Andrew Grieve <[email protected]> Commit-Queue: Alan Zhao <[email protected]> Cr-Commit-Position: refs/heads/main@{#1258047}
1 parent 5dc1929 commit ac1d93a

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

tools/binary_size/libsupersize/linker_map_parser.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -563,7 +563,8 @@ def Parse(self, lines):
563563

564564
is_partial = False
565565
cur_obj = None
566-
elif cur_obj == 'lto.tmp' or 'thinlto-cache' in cur_obj:
566+
elif (cur_obj == 'lto.tmp' or 'thinlto-cache' in cur_obj
567+
or '.lto.' in cur_obj):
567568
thin_map[address] = os.path.basename(cur_obj)
568569
cur_obj = None
569570

@@ -670,8 +671,8 @@ def Parse(self, lines):
670671
def _DetectLto(lines):
671672
"""Scans LLD linker map file and returns whether LTO was used."""
672673
# It's assumed that the first line in |lines| was consumed to determine that
673-
# LLD was used. Seek 'thinlto-cache' prefix within an "indicator section" as
674-
# indicator for LTO.
674+
# LLD was used. Seek 'thinlto-cache' prefix or the string '.lto' within an
675+
# "indicator section" as indicator for LTO.
675676
found_indicator_section = False
676677
# Potential names of "main section". Only one gets used.
677678
indicator_section_set = set(['.rodata', '.ARM.exidx'])
@@ -695,7 +696,7 @@ def _DetectLto(lines):
695696
found_indicator_section = True
696697
elif indent_size == 8:
697698
if found_indicator_section:
698-
if tok.startswith('thinlto-cache'):
699+
if tok.startswith('thinlto-cache') or '.lto.' in tok:
699700
return True
700701
return False
701702

0 commit comments

Comments
 (0)