[macOS][iOS] Eliminate strip_bitcode action (flutter/engine#36627)

Eliminates the `strip_bitcode` GN rule defined in
//flutter/sky/tools/mac.gni and the related script at
//flutter/sky/tools/strip_bitcode.py.

As of Xcode 14, bitcode is deprecated, no longer enabled by default, and
generates a warning message if a project enables it. Bitcode support
will be removed entirely from a future version of Xcode.

The `strip_bitcode` rule had two purposes:
1. Copy the binary specified by its input parameter to the path
   specified by its output parameter.
2. Strip bitcode segments as it does so.

While we no longer require the second of these functions, we still use
the first to create a `gen_snapshot` binary suffixed with the target
architecture. This replaces `strip_bitcode` with the built-in gn `copy`
rule instead.

Issue: https://github.com/flutter/flutter/issues/107884
Issue: https://github.com/flutter/flutter/issues/112896
Issue: https://github.com/flutter/flutter/issues/101138
Issue: https://github.com/flutter/flutter/issues/103386
This commit is contained in:
Chris Bracken
2022-10-06 00:26:35 +01:00
committed by GitHub
parent aadc2d3094
commit ad77065cad
3 changed files with 6 additions and 92 deletions

View File

@@ -6,7 +6,6 @@ import("//build/compiled_action.gni")
import("//build/fuchsia/sdk.gni")
import("//flutter/common/config.gni")
import("//flutter/lib/ui/dart_ui.gni")
import("//flutter/sky/tools/macos.gni")
import("//third_party/dart/utils/compile_platform.gni")
# Generates the Dart/Flutter core platform files and tools.
@@ -252,7 +251,7 @@ bin_to_linkable("platform_strong_dill_linkable") {
# This target is used for builds targeting iOS/Android OS.
if (host_os == "mac" && target_os != "mac" &&
(target_cpu == "arm" || target_cpu == "arm64")) {
strip_bitcode("create_arm_gen_snapshot") {
copy("create_arm_gen_snapshot") {
# The toolchain-specific output directory. For cross-compiles, this is a
# clang-x64 or clang-arm64 subdirectory of the top-level build directory.
host_output_dir = get_label_info(
@@ -265,8 +264,8 @@ if (host_os == "mac" && target_os != "mac" &&
target_cpu_suffix = "armv7"
}
input = "${host_output_dir}/gen_snapshot"
output = "${host_output_dir}/gen_snapshot_${target_cpu_suffix}"
sources = [ "${host_output_dir}/gen_snapshot" ]
outputs = [ "${host_output_dir}/gen_snapshot_${target_cpu_suffix}" ]
deps = [ "//third_party/dart/runtime/bin:gen_snapshot($host_toolchain)" ]
visibility = [ ":*" ]
}
@@ -280,15 +279,15 @@ if (host_os == "mac" && target_os != "mac" &&
#
# This target is used for builds targeting macOS.
if (host_os == "mac" && target_os == "mac") {
strip_bitcode("create_macos_gen_snapshots") {
copy("create_macos_gen_snapshots") {
# The toolchain-specific output directory. For cross-compiles, this is a
# clang-x64 or clang-arm64 subdirectory of the top-level build directory.
host_output_dir = get_label_info(
"//third_party/dart/runtime/bin:gen_snapshot($host_toolchain)",
"root_out_dir")
input = "${host_output_dir}/gen_snapshot"
output = "${root_out_dir}/gen_snapshot_${target_cpu}"
sources = [ "${host_output_dir}/gen_snapshot" ]
outputs = [ "${root_out_dir}/gen_snapshot_${target_cpu}" ]
deps = [ "//third_party/dart/runtime/bin:gen_snapshot($host_toolchain)" ]
metadata = {
snapshot_entitlement_file_path = [ "gen_snapshot_{$target_cpu}" ]

View File

@@ -1,41 +0,0 @@
# Copyright 2013 The Flutter Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
import("//flutter/common/config.gni")
# Copies an input macOS binary to the specified output path. Bitcode segments,
# if any, are stripped.
#
# Example:
#
# strip_bitcode(
# input = "$root_build_dir/gen_snapshot"
# output = "$root_build_dir/gen_snapshot_arm64"
# deps = [ ":gen_snapshot" ]
# )
#
# TODO(cbracken): https://github.com/flutter/flutter/issues/107884
# When we stop building with bitcode enabled, this template and the
# strip_bitcode.py script can be deleted and users can call copy() instead.
template("strip_bitcode") {
assert(defined(invoker.input), "The input to strip_bitcode must be defined")
assert(defined(invoker.output), "The output to strip_bitcode most be defined")
action(target_name) {
forward_variables_from(invoker,
[
"deps",
"metadata",
"visibility",
])
script = "//flutter/sky/tools/strip_bitcode.py"
args = [
"--input",
rebase_path(invoker.input),
"--output",
rebase_path(invoker.output),
]
inputs = [ invoker.input ]
outputs = [ invoker.output ]
}
}

View File

@@ -1,44 +0,0 @@
#!/usr/bin/env python3
#
# Copyright 2013 The Flutter Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
import argparse
import os
import subprocess
import sys
def main():
parser = argparse.ArgumentParser(
description='Copies an input macOS binary to the specified output path. '
'Bitcode segments, if any, are stripped.'
)
parser.add_argument(
'--input',
type=str,
required=True,
help='path of input binary to be read'
)
parser.add_argument(
'--output',
type=str,
required=True,
help='path of output binary to be written'
)
args = parser.parse_args()
# Verify input binary exists.
if not os.path.isfile(args.input):
print('Cannot find input binary at %s' % args.input)
sys.exit(1)
# Copy input path to output path. Strip bitcode segments, if any.
subprocess.check_call([
'xcrun', 'bitcode_strip', '-r', args.input, '-o', args.output
])
if __name__ == '__main__':
sys.exit(main())