From 5d4f5f77b8ca7854859eb1d07d6e33c878449a1c Mon Sep 17 00:00:00 2001 From: Jenn Magder Date: Wed, 3 Jan 2024 15:15:23 -0800 Subject: [PATCH] Remove deprecated bitcode stripping from tooling (#140903) Bitcode has been removed https://github.com/flutter/flutter/issues/107887, clean up the leftover commands. --- .../lib/src/build_system/targets/ios.dart | 23 --------- .../build_system/targets/ios_test.dart | 50 ------------------- .../ios_content_validation_test.dart | 48 ------------------ 3 files changed, 121 deletions(-) diff --git a/packages/flutter_tools/lib/src/build_system/targets/ios.dart b/packages/flutter_tools/lib/src/build_system/targets/ios.dart index 7c63a6ba2e2..0b8ddfbada1 100644 --- a/packages/flutter_tools/lib/src/build_system/targets/ios.dart +++ b/packages/flutter_tools/lib/src/build_system/targets/ios.dart @@ -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 _bitcodeStripFramework( - Environment environment, - String frameworkBinaryPath, - ) async { - final ProcessResult stripResult = await environment.processManager.run([ - '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. diff --git a/packages/flutter_tools/test/general.shard/build_system/targets/ios_test.dart b/packages/flutter_tools/test/general.shard/build_system/targets/ios_test.dart index 8c0f4a03d83..fd60327c33b 100644 --- a/packages/flutter_tools/test/general.shard/build_system/targets/ios_test.dart +++ b/packages/flutter_tools/test/general.shard/build_system/targets/ios_test.dart @@ -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: { - kIosArchs: 'arm64', - kSdkRoot: 'path/to/iPhoneOS.sdk', - }, - ); - - processManager.addCommands([ - FakeCommand(command: [ - 'rsync', - '-av', - '--delete', - '--filter', - '- .DS_Store/', - 'Artifact.flutterFramework.TargetPlatform.ios.release.EnvironmentType.physical', - outputDir.path, - ]), - lipoCommandNonFatResult, - lipoVerifyArm64Command, - FakeCommand(command: [ - '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); diff --git a/packages/flutter_tools/test/host_cross_arch.shard/ios_content_validation_test.dart b/packages/flutter_tools/test/host_cross_arch.shard/ios_content_validation_test.dart index c35287c6e04..8b68c28be8d 100644 --- a/packages/flutter_tools/test/host_cross_arch.shard/ios_content_validation_test.dart +++ b/packages/flutter_tools/test/host_cross_arch.shard/ios_content_validation_test.dart @@ -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([ - '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 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; -}