Unverified Commit 064d2f42 authored by Chris Bracken's avatar Chris Bracken Committed by GitHub

Simplify split between assembly/blob AOT compile (#17157)

This de-duplicates assembly AOT configuration between Android and iOS,
and makes it easier to adjust parameters for 32-bit iOS (which, like
32-bit Android, requires --no-integer-division) in an upcoming patch.
parent bf42524b
...@@ -318,47 +318,27 @@ class Snapshotter { ...@@ -318,47 +318,27 @@ class Snapshotter {
genSnapshotArgs.addAll(extraGenSnapshotOptions); genSnapshotArgs.addAll(extraGenSnapshotOptions);
} }
// Compile-to-assembly outputs.
final String assembly = fs.path.join(outputDir.path, 'snapshot_assembly.S'); final String assembly = fs.path.join(outputDir.path, 'snapshot_assembly.S');
final String assemblyO = fs.path.join(outputDir.path, 'snapshot_assembly.o'); if (compileToSharedLibrary || platform == TargetPlatform.ios) {
final String assemblySo = fs.path.join(outputDir.path, 'app.so'); // Assembly AOT snapshot.
outputPaths.add(assembly);
switch (platform) { genSnapshotArgs.add('--snapshot_kind=app-aot-assembly');
case TargetPlatform.android_arm: genSnapshotArgs.add('--assembly=$assembly');
case TargetPlatform.android_arm64: } else {
case TargetPlatform.android_x64: // Blob AOT snapshot.
case TargetPlatform.android_x86: final String vmSnapshotInstructions = fs.path.join(outputDir.path, 'vm_snapshot_instr');
if (compileToSharedLibrary) { final String isolateSnapshotInstructions = fs.path.join(outputDir.path, 'isolate_snapshot_instr');
outputPaths.add(assemblySo); outputPaths.addAll(<String>[vmSnapshotData, isolateSnapshotData]);
genSnapshotArgs.add('--snapshot_kind=app-aot-assembly'); genSnapshotArgs.addAll(<String>[
genSnapshotArgs.add('--assembly=$assembly'); '--snapshot_kind=app-aot-blobs',
} else { '--vm_snapshot_instructions=$vmSnapshotInstructions',
final String vmSnapshotInstructions = fs.path.join(outputDir.path, 'vm_snapshot_instr'); '--isolate_snapshot_instructions=$isolateSnapshotInstructions',
final String isolateSnapshotInstructions = fs.path.join(outputDir.path, 'isolate_snapshot_instr'); ]);
outputPaths.addAll(<String>[vmSnapshotData, isolateSnapshotData]); }
genSnapshotArgs.addAll(<String>[
'--snapshot_kind=app-aot-blobs', if (platform == TargetPlatform.android_arm) {
'--vm_snapshot_instructions=$vmSnapshotInstructions', // Not supported by the Pixel in 32-bit mode.
'--isolate_snapshot_instructions=$isolateSnapshotInstructions', genSnapshotArgs.add('--no-use-integer-division');
]);
}
if (platform == TargetPlatform.android_arm) {
genSnapshotArgs.addAll(<String>[
'--no-use-integer-division', // Not supported by the Pixel in 32-bit mode.
]);
}
break;
case TargetPlatform.ios:
genSnapshotArgs.add('--snapshot_kind=app-aot-assembly');
genSnapshotArgs.add('--assembly=$assembly');
outputPaths.add(assemblyO);
break;
case TargetPlatform.darwin_x64:
case TargetPlatform.linux_x64:
case TargetPlatform.windows_x64:
case TargetPlatform.fuchsia:
case TargetPlatform.tester:
assert(false);
} }
genSnapshotArgs.add(mainPath); genSnapshotArgs.add(mainPath);
...@@ -397,8 +377,9 @@ class Snapshotter { ...@@ -397,8 +377,9 @@ class Snapshotter {
// end-developer can link into their app. // end-developer can link into their app.
if (platform == TargetPlatform.ios) { if (platform == TargetPlatform.ios) {
printStatus('Building App.framework...'); printStatus('Building App.framework...');
const List<String> commonBuildOptions = const <String>['-arch', 'arm64', '-miphoneos-version-min=8.0']; const List<String> commonBuildOptions = const <String>['-arch', 'arm64', '-miphoneos-version-min=8.0'];
final String assemblyO = fs.path.join(outputDir.path, 'snapshot_assembly.o');
await xcode.cc(commonBuildOptions.toList()..addAll(<String>['-c', assembly, '-o', assemblyO])); await xcode.cc(commonBuildOptions.toList()..addAll(<String>['-c', assembly, '-o', assemblyO]));
final String frameworkDir = fs.path.join(outputDir.path, 'App.framework'); final String frameworkDir = fs.path.join(outputDir.path, 'App.framework');
...@@ -422,6 +403,7 @@ class Snapshotter { ...@@ -422,6 +403,7 @@ class Snapshotter {
// based upon libunwind use just one and ignore the contents of the other // based upon libunwind use just one and ignore the contents of the other
// (which causes it to not look into the other section and therefore not // (which causes it to not look into the other section and therefore not
// find the correct unwinding information). // find the correct unwinding information).
final String assemblySo = fs.path.join(outputDir.path, 'app.so');
await runCheckedAsync(<String>[androidSdk.ndkCompiler] await runCheckedAsync(<String>[androidSdk.ndkCompiler]
..addAll(androidSdk.ndkCompilerArgs) ..addAll(androidSdk.ndkCompilerArgs)
..addAll(<String>[ '-shared', '-nostdlib', '-o', assemblySo, assembly ])); ..addAll(<String>[ '-shared', '-nostdlib', '-o', assemblySo, assembly ]));
......
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