Stop embedding bitcode for iOS in tool (#112831)

This commit is contained in:
Jenn Magder
2022-10-03 18:41:23 -07:00
committed by GitHub
parent 8c0aa6c66c
commit 35afe1bdac
22 changed files with 71 additions and 508 deletions

View File

@@ -171,7 +171,6 @@ Future<void> _testBuildIosFramework(Directory projectDir, { bool isModule = fals
);
await _checkDylib(appFrameworkPath);
await _checkBitcode(appFrameworkPath, mode);
final String aotSymbols = await _dylibSymbols(appFrameworkPath);
@@ -228,15 +227,14 @@ Future<void> _testBuildIosFramework(Directory projectDir, { bool isModule = fals
section("Check all modes' engine dylib");
for (final String mode in <String>['Debug', 'Profile', 'Release']) {
final String engineBinary = path.join(
checkFileExists(path.join(
outputPath,
mode,
'Flutter.xcframework',
'ios-arm64',
'Flutter.framework',
'Flutter',
);
await _checkBitcode(engineBinary, mode);
));
checkFileExists(path.join(
outputPath,
@@ -836,15 +834,6 @@ Future<void> _checkStatic(String pathToLibrary) async {
}
}
Future<void> _checkBitcode(String frameworkPath, String mode) async {
checkFileExists(frameworkPath);
// Bitcode only needed in Release mode for archiving.
if (mode == 'Release' && !await containsBitcode(frameworkPath)) {
throw TaskResult.failure('$frameworkPath does not contain bitcode');
}
}
Future<String> _dylibSymbols(String pathToDylib) {
return eval('nm', <String>[
'-g',

View File

@@ -47,43 +47,6 @@ Future<String?> minPhoneOSVersion(String pathToBinary) async {
return minVersion;
}
Future<bool> containsBitcode(String pathToBinary) async {
// See: https://stackoverflow.com/questions/32755775/how-to-check-a-static-library-is-built-contain-bitcode
final String loadCommands = await eval('otool', <String>[
'-l',
'-arch',
'arm64',
pathToBinary,
]);
if (!loadCommands.contains('__LLVM')) {
return false;
}
// Presence of the section may mean a bitcode marker was embedded (size=1), but there is no content.
if (!loadCommands.contains('size 0x0000000000000001')) {
return true;
}
// Check the false positives: size=1 wasn't referencing the __LLVM section.
bool emptyBitcodeMarkerFound = false;
// Section
// sectname __bundle
// segname __LLVM
// addr 0x003c4000
// size 0x0042b633
// offset 3932160
// ...
final List<String> lines = LineSplitter.split(loadCommands).toList();
lines.asMap().forEach((int index, String line) {
if (line.contains('segname __LLVM') && lines.length - index - 1 > 3) {
emptyBitcodeMarkerFound |= lines
.skip(index - 1)
.take(4)
.any((String line) => line.contains(' size 0x0000000000000001'));
}
});
return !emptyBitcodeMarkerFound;
}
/// Creates and boots a new simulator, passes the new simulator's identifier to
/// `testFunction`.
///