Skip to content

Commit 89d887f

Browse files
Strip debug symbols from ELF library snapshots (flutter#34250)
AOT compiled code is now packaged as an ELF library for Android targets. By default gen_snapshot's output contains debug symbols. The symbols could be stripped as a separate step, but that requires NDK tools that the user may not have available. This change passes a gen_snapshot flag that omits the symbols, and it filters out a warning printed when that flag is used.
1 parent 6d0e618 commit 89d887f

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

packages/flutter_tools/lib/src/base/build.dart

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,17 @@ class GenSnapshot {
6363
final String hostArch = iosArch == IOSArch.armv7 ? '-i386' : '-x86_64';
6464
return runCommandAndStreamOutput(<String>['/usr/bin/arch', hostArch, snapshotterPath]..addAll(args));
6565
}
66-
return runCommandAndStreamOutput(<String>[snapshotterPath]..addAll(args));
66+
67+
StringConverter outputFilter;
68+
if (additionalArgs.contains('--strip')) {
69+
// Filter out gen_snapshot's warning message about stripping debug symbols
70+
// from ELF library snapshots.
71+
const String kStripWarning = 'Warning: Generating ELF library without DWARF debugging information.';
72+
outputFilter = (String line) => line != kStripWarning ? line : null;
73+
}
74+
75+
return runCommandAndStreamOutput(<String>[snapshotterPath]..addAll(args),
76+
mapFunction: outputFilter);
6777
}
6878
}
6979

@@ -138,6 +148,7 @@ class AOTSnapshotter {
138148
outputPaths.add(aotSharedLibrary);
139149
genSnapshotArgs.add('--snapshot_kind=app-aot-elf');
140150
genSnapshotArgs.add('--elf=$aotSharedLibrary');
151+
genSnapshotArgs.add('--strip');
141152
} else {
142153
// Blob AOT snapshot.
143154
final String vmSnapshotData = fs.path.join(outputDir.path, 'vm_snapshot_data');

packages/flutter_tools/test/base/build_test.dart

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -418,6 +418,7 @@ void main() {
418418
'--deterministic',
419419
'--snapshot_kind=app-aot-elf',
420420
'--elf=build/foo/app.so',
421+
'--strip',
421422
'--no-sim-use-hardfp',
422423
'--no-use-integer-division',
423424
'main.dill',
@@ -447,6 +448,7 @@ void main() {
447448
'--deterministic',
448449
'--snapshot_kind=app-aot-elf',
449450
'--elf=build/foo/app.so',
451+
'--strip',
450452
'main.dill',
451453
]);
452454
}, overrides: contextOverrides);

0 commit comments

Comments
 (0)