Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Conversation

@cbracken
Copy link
Member

@cbracken cbracken commented Sep 29, 2022

The gen_snapshots.py tool is used to copy an input gen_snapshot to an output path with an architecture-specific suffix. For example, to copy gen_snapshot to gen_snapshot_arm64. Bitcode segments, if any, are stripped.

This moves the input/output filename hardcoding into the BUILD.gn file and generalises the logic to simply copy an input binary to an output path with bitcode segments stripped. Since the tool is no longer gen_snapshot specific, we rename it from gen_snapshots.py to strip_bitcode.py. This script is not used elsewhere in this repo or in our build recipes.

This also renames the generalised macos_gen_snapshots rule to strip_bitcode.

Since we're working on removing bitcode support from the engine, this script will eventually serve no purpose other than to copy the input binary to an output path, at which point this script, and the associated strip_bitcode template in //flutter/sky/tools/macos_tools.gni can be removed.

Along with the TODO, renaming the script and the rule help ensure we'll spot this and remove it when bitcode support is removed from the engine.

Finally, this fixes a dependency issue in the target //flutter/lib/snapshot:create_macos_gen_snapshots. Previously, it depended on :generate_snapshot_bin, but in fact, the only file it touches is gen_snapshot. This was built transitively as part of the :generate_snapshot_bin target, but is now depended on directly.

This is pre-factoring for merging the iOS and macOS gen_snapshot creation build rules in flutter/lib/snapshot/BUILD.gn.

Issue: flutter/flutter#103386
Issue: flutter/flutter#101138
Issue: flutter/flutter#107884

Pre-launch Checklist

  • I read the Contributor Guide and followed the process outlined there for submitting PRs.
  • I read the Tree Hygiene wiki page, which explains my responsibilities.
  • I read and followed the Flutter Style Guide and the C++, Objective-C, Java style guides.
  • I listed at least one issue that this PR fixes in the description above.
  • I added new tests to check the change I am making or feature I am adding, or Hixie said the PR is test-exempt. See testing the engine for instructions on
    writing and running engine tests.
  • I updated/added relevant documentation (doc comments with ///).
  • I signed the CLA.
  • All existing and new tests are passing.

If you need help, consider asking for advice on the #hackers-new channel on Discord.

# platform.
if (host_os == "mac" && (target_cpu == "arm" || target_cpu == "arm64")) {
if (host_os == "mac" && target_os != "mac" &&
(target_cpu == "arm" || target_cpu == "arm64")) {
Copy link
Member Author

@cbracken cbracken Sep 29, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note that this target:

  • wasn't built for x64 macOS builds (correct)
  • was built for arm64 macOS builds (incorrect - this target is used for iOS/Android)

The create_macos_gen_snapshots target:

  • was built for both x64 and arm64 builds (correct)

In a following patch, I'll be merging create_arm_gen_snapshot and create_macos_gen_snapshots into a single target.

The purpose of these is just to generate gen_snapshot binaries suffixed with the target architecture, which is something we only do for macOS hosts at the moment.

"root_out_dir")

input = "${host_output_dir}/gen_snapshot"
output = "${root_out_dir}/gen_snapshot_${target_cpu}"
Copy link
Member Author

@cbracken cbracken Sep 29, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the same output path where we've been historically emitted this binary. In a future patch, I'll make this consistent with the create_arm_gen_snapshot target, which emits it alongside the original in host_output_dir.

Not doing it in this patch since I'll need to verify expected paths used by the recipes first, and migrate stepwise if needed.

The gen_snapshots.py tool is used to copy an input gen_snapshot to an
output path with an architecture-specific suffix. For example, to copy
gen_snapshot to gen_snapshot_arm64. Bitcode segments, if any, are
stripped.

This moves the input/output filename hardcoding into the BUILD.gn file
and generalises the logic to simply copy an input binary to an output
path with bitcode segments stripped. Since the tool is no longer
gen_snapshot specific, we rename it from gen_snapshots.py to
strip_bitcode.py.

This also renames the generalised `macos_gen_snapshots` rule to
`strip_bitcode`.

Since we're working on removing bitcode support from the engine, this
script will eventually serve no purpose other than to copy the input
binary to an output path, at which point this script, and the associated
`strip_bitcode` template in `//flutter/sky/tools/macos_tools.gni` can be
removed.

Along with the TODO, renaming the script and the rule help ensure we'll
spot this and remove it when bitcode support is removed from the engine.

Finally, this fixes a dependency issue in the target
//flutter/lib/snapshot:create_macos_gen_snapshots. Previously, it
dependended on ":generate_snapshot_bin", but in fact, the only file it
touches is gen_snapshot. This was built transitively as part of the
":generate_snapshot_bin" target, but is now depended on directly.

This is pre-factoring for merging the iOS and macOS gen_snapshot
creation build rules in `flutter/lib/snapshot/BUILD.gn`.

Issue: flutter/flutter#103386
Issue: flutter/flutter#101138
Issue: flutter/flutter#107884
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants