Add support for producing unstripped AOT snapshots. (#75243)
This commit is contained in:
committed by
GitHub
parent
44d5950d27
commit
4ba26191ea
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user