Run iOS gen_snapshot as x86_64 arch (#16323)

We are about to begin building gen_snapshot as a multi-arch binary,
which when run as x86_64 will generate arm64 AOT output, and when run as
i386 will generate armv7 AOT output.

Currently, gen_snapshot is an x86_64 binary, so this change is
effectively preventative in nature, and is a no-op with the current
snapshotter.
This commit is contained in:
Chris Bracken 2018-04-09 19:12:05 -07:00 committed by GitHub
parent a0ed436227
commit 4576f56624
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 20 additions and 2 deletions

View File

@ -50,6 +50,15 @@ class GenSnapshot {
'--print_snapshot_sizes', '--print_snapshot_sizes',
]..addAll(additionalArgs); ]..addAll(additionalArgs);
final String snapshotterPath = artifacts.getArtifactPath(Artifact.genSnapshot, snapshotType.platform, snapshotType.mode); final String snapshotterPath = artifacts.getArtifactPath(Artifact.genSnapshot, snapshotType.platform, snapshotType.mode);
// iOS gen_snapshot is a multi-arch binary. Running as an i386 binary will
// generate armv7 code. Running as an x86_64 binary will generate arm64
// code. /usr/bin/arch can be used to run binaries with the specified
// architecture.
if (snapshotType.platform == TargetPlatform.ios) {
// TODO(cbracken): for the moment, always generate only arm64 code.
return runCommandAndStreamOutput(<String>['/usr/bin/arch', '-x86_64', snapshotterPath]..addAll(args));
}
return runCommandAndStreamOutput(<String>[snapshotterPath]..addAll(args)); return runCommandAndStreamOutput(<String>[snapshotterPath]..addAll(args));
} }
} }

View File

@ -260,7 +260,16 @@ Future<String> _buildAotSnapshot(
return null; return null;
} }
final List<String> genSnapshotCmd = <String>[ final List<String> genSnapshotCmd = <String>[];
// iOS gen_snapshot is a multi-arch binary. Running as an i386 binary will
// generate armv7 code. Running as an x86_64 binary will generate arm64
// code. /usr/bin/arch can be used to run binaries with the specified
// architecture.
//
// TODO(cbracken): update the GenSnapshot class to handle AOT builds.
if (platform == TargetPlatform.ios)
genSnapshotCmd.addAll(<String>['arch', '-x86_64']);
genSnapshotCmd.addAll(<String>[
genSnapshot, genSnapshot,
'--await_is_keyword', '--await_is_keyword',
'--vm_snapshot_data=$vmSnapshotData', '--vm_snapshot_data=$vmSnapshotData',
@ -271,7 +280,7 @@ Future<String> _buildAotSnapshot(
'--print_snapshot_sizes', '--print_snapshot_sizes',
'--dependencies=$dependencies', '--dependencies=$dependencies',
'--causal_async_stacks', '--causal_async_stacks',
]; ]);
if ((extraFrontEndOptions != null) && extraFrontEndOptions.isNotEmpty) if ((extraFrontEndOptions != null) && extraFrontEndOptions.isNotEmpty)
printTrace('Extra front-end options: $extraFrontEndOptions'); printTrace('Extra front-end options: $extraFrontEndOptions');