mirror of
https://github.com/flutter/flutter.git
synced 2025-06-03 00:51:18 +00:00
Remove deprecated bitcode stripping from tooling (#140903)
Bitcode has been removed https://github.com/flutter/flutter/issues/107887, clean up the leftover commands.
This commit is contained in:
parent
fedf9ece4c
commit
5d4f5f77b8
@ -296,9 +296,6 @@ abstract class UnpackIOS extends Target {
|
||||
throw Exception('Binary $frameworkBinaryPath does not exist, cannot thin');
|
||||
}
|
||||
await _thinFramework(environment, frameworkBinaryPath, archs);
|
||||
if (buildMode == BuildMode.release) {
|
||||
await _bitcodeStripFramework(environment, frameworkBinaryPath);
|
||||
}
|
||||
await _signFramework(environment, frameworkBinary, buildMode);
|
||||
}
|
||||
|
||||
@ -376,26 +373,6 @@ abstract class UnpackIOS extends Target {
|
||||
throw Exception('Failed to extract $archs for $frameworkBinaryPath.\n${extractResult.stderr}\nRunning lipo -info:\n$lipoInfo');
|
||||
}
|
||||
}
|
||||
|
||||
/// Destructively strip bitcode from the framework. This can be removed
|
||||
/// when the framework is no longer built with bitcode.
|
||||
Future<void> _bitcodeStripFramework(
|
||||
Environment environment,
|
||||
String frameworkBinaryPath,
|
||||
) async {
|
||||
final ProcessResult stripResult = await environment.processManager.run(<String>[
|
||||
'xcrun',
|
||||
'bitcode_strip',
|
||||
frameworkBinaryPath,
|
||||
'-r', // Delete the bitcode segment.
|
||||
'-o',
|
||||
frameworkBinaryPath,
|
||||
]);
|
||||
|
||||
if (stripResult.exitCode != 0) {
|
||||
throw Exception('Failed to strip bitcode for $frameworkBinaryPath.\n${stripResult.stderr}');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Unpack the release prebuilt engine framework.
|
||||
|
@ -813,56 +813,6 @@ void main() {
|
||||
expect(processManager, hasNoRemainingExpectations);
|
||||
});
|
||||
|
||||
testWithoutContext('fails when bitcode strip fails', () async {
|
||||
binary.createSync(recursive: true);
|
||||
|
||||
final Environment environment = Environment.test(
|
||||
fileSystem.currentDirectory,
|
||||
processManager: processManager,
|
||||
artifacts: artifacts,
|
||||
logger: logger,
|
||||
fileSystem: fileSystem,
|
||||
outputDir: outputDir,
|
||||
defines: <String, String>{
|
||||
kIosArchs: 'arm64',
|
||||
kSdkRoot: 'path/to/iPhoneOS.sdk',
|
||||
},
|
||||
);
|
||||
|
||||
processManager.addCommands(<FakeCommand>[
|
||||
FakeCommand(command: <String>[
|
||||
'rsync',
|
||||
'-av',
|
||||
'--delete',
|
||||
'--filter',
|
||||
'- .DS_Store/',
|
||||
'Artifact.flutterFramework.TargetPlatform.ios.release.EnvironmentType.physical',
|
||||
outputDir.path,
|
||||
]),
|
||||
lipoCommandNonFatResult,
|
||||
lipoVerifyArm64Command,
|
||||
FakeCommand(command: <String>[
|
||||
'xcrun',
|
||||
'bitcode_strip',
|
||||
binary.path,
|
||||
'-r',
|
||||
'-o',
|
||||
binary.path,
|
||||
], exitCode: 1, stderr: 'bitcode_strip error'),
|
||||
]);
|
||||
|
||||
await expectLater(
|
||||
const ReleaseUnpackIOS().build(environment),
|
||||
throwsA(isException.having(
|
||||
(Exception exception) => exception.toString(),
|
||||
'description',
|
||||
contains('Failed to strip bitcode for output/Flutter.framework/Flutter.\nbitcode_strip error'),
|
||||
)),
|
||||
);
|
||||
|
||||
expect(processManager, hasNoRemainingExpectations);
|
||||
});
|
||||
|
||||
testWithoutContext('strips framework', () async {
|
||||
binary.createSync(recursive: true);
|
||||
|
||||
|
@ -7,11 +7,9 @@ import 'package:flutter_tools/src/base/file_system.dart';
|
||||
import 'package:flutter_tools/src/base/io.dart';
|
||||
import 'package:flutter_tools/src/base/utils.dart';
|
||||
import 'package:flutter_tools/src/build_info.dart';
|
||||
import 'package:flutter_tools/src/convert.dart';
|
||||
|
||||
import '../integration.shard/test_utils.dart';
|
||||
import '../src/common.dart';
|
||||
import '../src/fake_process_manager.dart';
|
||||
|
||||
void main() {
|
||||
group('iOS app validation', () {
|
||||
@ -157,9 +155,6 @@ void main() {
|
||||
));
|
||||
|
||||
expect(vmSnapshot.existsSync(), buildMode == BuildMode.debug);
|
||||
|
||||
// Builds should not contain deprecated bitcode.
|
||||
expect(_containsBitcode(outputFlutterFrameworkBinary.path, processManager), isFalse);
|
||||
});
|
||||
|
||||
testWithoutContext('Info.plist dart VM Service Bonjour service', () {
|
||||
@ -363,46 +358,3 @@ void main() {
|
||||
timeout: const Timeout(Duration(minutes: 7))
|
||||
);
|
||||
}
|
||||
|
||||
bool _containsBitcode(String pathToBinary, ProcessManager processManager) {
|
||||
// See: https://stackoverflow.com/questions/32755775/how-to-check-a-static-library-is-built-contain-bitcode
|
||||
final ProcessResult result = processManager.runSync(<String>[
|
||||
'otool',
|
||||
'-l',
|
||||
'-arch',
|
||||
'arm64',
|
||||
pathToBinary,
|
||||
]);
|
||||
final String loadCommands = result.stdout as String;
|
||||
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) {
|
||||
final bool bitcodeMarkerFound = lines
|
||||
.skip(index - 1)
|
||||
.take(4)
|
||||
.any((String line) => line.contains(' size 0x0000000000000001'));
|
||||
if (bitcodeMarkerFound) {
|
||||
emptyBitcodeMarkerFound = true;
|
||||
return;
|
||||
}
|
||||
}
|
||||
});
|
||||
return !emptyBitcodeMarkerFound;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user