Unverified Commit 4ba26191 authored by Vyacheslav Egorov's avatar Vyacheslav Egorov Committed by GitHub

Add support for producing unstripped AOT snapshots. (#75243)

parent 44d5950d
......@@ -137,9 +137,20 @@ class AOTSnapshotter {
final List<String> genSnapshotArgs = <String>[
'--deterministic',
];
// We strip snapshot by default, but allow to suppress this behavior
// by supplying --no-strip in extraGenSnapshotOptions.
bool shouldStrip = true;
if (extraGenSnapshotOptions != null && extraGenSnapshotOptions.isNotEmpty) {
_logger.printTrace('Extra gen_snapshot options: $extraGenSnapshotOptions');
genSnapshotArgs.addAll(extraGenSnapshotOptions);
for (final String option in extraGenSnapshotOptions) {
if (option == '--no-strip') {
shouldStrip = false;
continue;
}
genSnapshotArgs.add(option);
}
}
final String assembly = _fileSystem.path.join(outputDir.path, 'snapshot_assembly.S');
......@@ -147,17 +158,19 @@ class AOTSnapshotter {
genSnapshotArgs.addAll(<String>[
'--snapshot_kind=app-aot-assembly',
'--assembly=$assembly',
'--strip'
]);
} else {
final String aotSharedLibrary = _fileSystem.path.join(outputDir.path, 'app.so');
genSnapshotArgs.addAll(<String>[
'--snapshot_kind=app-aot-elf',
'--elf=$aotSharedLibrary',
'--strip'
]);
}
if (shouldStrip) {
genSnapshotArgs.add('--strip');
}
if (platform == TargetPlatform.android_arm || darwinArch == DarwinArch.armv7) {
// Use softfp for Android armv7 devices.
// This is the default for armv7 iOS builds, but harmless to set.
......
......@@ -666,5 +666,32 @@ void main() {
expect(genSnapshotExitCode, 0);
expect(processManager.hasRemainingExpectations, false);
});
testWithoutContext('--no-strip in extraGenSnapshotOptions suppresses --strip', () async {
final String outputPath = fileSystem.path.join('build', 'foo');
processManager.addCommand(FakeCommand(
command: <String>[
artifacts.getArtifactPath(Artifact.genSnapshot, platform: TargetPlatform.android_arm64, mode: BuildMode.release),
'--deterministic',
'--snapshot_kind=app-aot-elf',
'--elf=build/foo/app.so',
'main.dill',
]
));
final int genSnapshotExitCode = await snapshotter.build(
platform: TargetPlatform.android_arm64,
buildMode: BuildMode.release,
mainPath: 'main.dill',
outputPath: outputPath,
bitcode: false,
splitDebugInfo: null,
dartObfuscation: false,
extraGenSnapshotOptions: const <String>['--no-strip'],
);
expect(genSnapshotExitCode, 0);
expect(processManager.hasRemainingExpectations, false);
});
});
}
......@@ -294,6 +294,47 @@ void main() {
ProcessManager: () => processManager,
});
testUsingContext('--no-strip in kExtraGenSnapshotOptions suppresses --strip gen_snapshot flag', () async {
processManager = FakeProcessManager.list(<FakeCommand>[]);
final Environment environment = Environment.test(
fileSystem.currentDirectory,
outputDir: fileSystem.directory('out')..createSync(),
defines: <String, String>{
kBuildMode: 'release',
kExtraGenSnapshotOptions: 'foo,--no-strip,bar',
kTargetPlatform: 'android-arm',
},
processManager: processManager,
artifacts: artifacts,
fileSystem: fileSystem,
logger: logger,
);
processManager.addCommand(
FakeCommand(command: <String>[
artifacts.getArtifactPath(
Artifact.genSnapshot,
platform: TargetPlatform.android_arm64,
mode: BuildMode.release,
),
'--deterministic',
'foo',
'bar',
'--snapshot_kind=app-aot-elf',
'--elf=${environment.buildDir.childDirectory('arm64-v8a').childFile('app.so').path}',
environment.buildDir.childFile('app.dill').path
],
));
environment.buildDir.createSync(recursive: true);
environment.buildDir.childFile('app.dill').createSync();
environment.projectDir.childFile('.packages').writeAsStringSync('\n');
await const AndroidAot(TargetPlatform.android_arm64, BuildMode.release)
.build(environment);
}, overrides: <Type, Generator>{
FileSystem: () => fileSystem,
ProcessManager: () => processManager,
});
testWithoutContext('android aot bundle copies so from abi directory', () async {
final Environment environment = Environment.test(
fileSystem.currentDirectory,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment