-
Notifications
You must be signed in to change notification settings - Fork 6k
Generalise gen_snapshots.py to strip_bitcode.py #36496
Conversation
| # platform. | ||
| if (host_os == "mac" && (target_cpu == "arm" || target_cpu == "arm64")) { | ||
| if (host_os == "mac" && target_os != "mac" && | ||
| (target_cpu == "arm" || target_cpu == "arm64")) { |
There was a problem hiding this comment.
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}" |
There was a problem hiding this comment.
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
The
gen_snapshots.pytool is used to copy an inputgen_snapshotto an output path with an architecture-specific suffix. For example, to copygen_snapshottogen_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_snapshotspecific, we rename it fromgen_snapshots.pytostrip_bitcode.py. This script is not used elsewhere in this repo or in our build recipes.This also renames the generalised
macos_gen_snapshotsrule tostrip_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_bitcodetemplate in//flutter/sky/tools/macos_tools.gnican 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 isgen_snapshot. This was built transitively as part of the:generate_snapshot_bintarget, but is now depended on directly.This is pre-factoring for merging the iOS and macOS
gen_snapshotcreation build rules influtter/lib/snapshot/BUILD.gn.Issue: flutter/flutter#103386
Issue: flutter/flutter#101138
Issue: flutter/flutter#107884
Pre-launch Checklist
writing and running engine tests.
///).If you need help, consider asking for advice on the #hackers-new channel on Discord.