-
Notifications
You must be signed in to change notification settings - Fork 29.7k
[tools] Make SnapshotType.platform non-nullable #146958
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[tools] Make SnapshotType.platform non-nullable #146958
Conversation
When performing artifact lookups for Artifact.genSnapshot, a TargetPlatform is used to determine the name of the tool, typically `gen_snapshot_$TARGET_ARCH`. Formerly, this tool was always named `gen_snapshot`. The astute reader may ask "but Chris, didn't we support TWO target architectures on iOS and therefore need TWO gen_snapshot binaries?" Yes, we did support both armv7 and arm64 target architectures on iOS. No, we didn't have two gen_snapshot binaries. At the time, the bitness of the gen_snapshot tool needed to match the bitness of the target architecture. As such we did *build* two gen_snapshots: * A 32-bit x86 binary that emitted armv7 AOT code * A 64-bit x64 binary that emitted arm64 AOT code However, to avoid having to do a lot of work plumbing through suffixed gen_snapshot names, the author of that work elected to "cleverly" lipo the two together into a single multi-architecture macOS binary. See: flutter/engine#4948 This was later remediated over the course of several patches, including: See: flutter#37445 See: flutter/engine#10430 See: flutter/engine#22818 However, there were still cases (notably --local-engine workflows in the tool) where we weren't computing the target platform and thus referenced the generic gen_snapshot tool. See: flutter#38933 Fixed in: flutter/engine#28345 The test removed in this PR, which ensured that null SnapshotType.platform was supported was introduced in flutter#11924 as a followup to flutter#11820 when the snapshotting logic was originally extracted to the `GenSnapshot` class. Since there are no longer any cases where TargetPlatform isn't passed when looking up Artifacts.genSnapshot, we can safely make the platform non-nullable and remove the test. This is pre-factoring towrards the removal of the generic gen_snapshot artifact, which is pre-factoring towards the goal of building gen_snapshot binaries with an arm64 host architecture, and eliminate the need to use Rosetta during iOS and macOS Flutter builds. Issue: flutter#101138 Issue: flutter#103386
jmagman
left a comment
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.
If you make
| TargetPlatform? platform, |
required TargetPlatform platform, there's definitely no gen_snapshot places where null is passed? Hopefully it's all covered by tests.
Maybe longer-term, can we refactor this for different paths for platforms than non-platform artifacts?
There are still cases where a null And yes I definitely like the idea of splitting out the lookup of target-specific binaries from generic host-only binaries just to ensure we're not missing anything. Looks like there's an existing issue for this: #80875 |
I should note that while I was banging this patch up up, I did give that a shot out of curiosity, but there were ~105 errors/warnings that popped up (a ton in tests, in particular), so that's a separate, much larger chunk of work. |
vashworth
left a comment
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.
LGTM
flutter/flutter@fb110b9...98685a0 2024-04-19 [email protected] Replace CocoaPods deprecated `exists?` with `exist?` (flutter/flutter#147056) 2024-04-19 [email protected] Roll Flutter Engine from 4ed7a2d6aed9 to 7fafbbf17c02 (2 revisions) (flutter/flutter#147046) 2024-04-19 [email protected] Roll Flutter Engine from 25d773ea90c4 to 4ed7a2d6aed9 (3 revisions) (flutter/flutter#147038) 2024-04-19 [email protected] Update link branches to `main` (continued) (flutter/flutter#146985) 2024-04-19 [email protected] Roll Flutter Engine from b6234dd1984e to 25d773ea90c4 (1 revision) (flutter/flutter#147035) 2024-04-19 [email protected] Roll Flutter Engine from ff471881e90a to b6234dd1984e (2 revisions) (flutter/flutter#147029) 2024-04-19 [email protected] Roll Flutter Engine from 442d14a7e840 to ff471881e90a (1 revision) (flutter/flutter#147025) 2024-04-19 [email protected] Roll Flutter Engine from 6e4a15d31769 to 442d14a7e840 (2 revisions) (flutter/flutter#147023) 2024-04-19 [email protected] Opt out users from GA3 if opted out of GA4 (flutter/flutter#146453) 2024-04-19 [email protected] Roll Flutter Engine from 61bf47d129bb to 6e4a15d31769 (1 revision) (flutter/flutter#147022) 2024-04-18 [email protected] Roll Flutter Engine from 13a6ce419664 to 61bf47d129bb (4 revisions) (flutter/flutter#147017) 2024-04-18 [email protected] Add a breadcrumb for the pub autoroller (flutter/flutter#146786) 2024-04-18 98614782+auto-submit[bot]@users.noreply.github.com Reverts "Add generic type for result in PopScope (#139164)" (flutter/flutter#147015) 2024-04-18 [email protected] Redundant message fix (flutter/flutter#143978) 2024-04-18 [email protected] Clean up flutterRoot (flutter/flutter#147010) 2024-04-18 49699333+dependabot[bot]@users.noreply.github.com Bump actions/upload-artifact from 4.3.1 to 4.3.2 (flutter/flutter#147011) 2024-04-18 [email protected] Add Swift Package Manager as new opt-in feature for iOS and macOS (flutter/flutter#146256) 2024-04-18 [email protected] Refactor framework coverage tests (flutter/flutter#146210) 2024-04-18 [email protected] Roll Flutter Engine from 46ff024bff10 to 13a6ce419664 (3 revisions) (flutter/flutter#147006) 2024-04-18 [email protected] Changing the renderer on the web target should change its build key. (flutter/flutter#147003) 2024-04-18 [email protected] Roll Flutter Engine from 6abfa565a9f9 to 46ff024bff10 (1 revision) (flutter/flutter#147005) 2024-04-18 [email protected] Add generic type for result in PopScope (flutter/flutter#139164) 2024-04-18 [email protected] Roll Flutter Engine from aa6f7411c219 to 6abfa565a9f9 (1 revision) (flutter/flutter#147002) 2024-04-18 [email protected] [tools] Make SnapshotType.platform non-nullable (flutter/flutter#146958) 2024-04-18 [email protected] Roll Flutter Engine from b8e802515b5a to aa6f7411c219 (1 revision) (flutter/flutter#146996) 2024-04-18 [email protected] Roll Flutter Engine from 2c3e9c8bfce6 to b8e802515b5a (2 revisions) (flutter/flutter#146993) 2024-04-18 [email protected] Roll Packages from d39830e to 0e3809d (9 revisions) (flutter/flutter#146992) 2024-04-18 [email protected] Fix memory leaks in navigation rail (flutter/flutter#146988) If this roll has caused a breakage, revert this CL and stop the roller using the controls here: https://autoroll.skia.org/r/flutter-packages Please CC [email protected],[email protected],[email protected] on the revert to ensure that a human is aware of the problem. To file a bug in Packages: https://github.com/flutter/flutter/issues/new/choose To report a problem with the AutoRoller itself, please file a bug: https://issues.skia.org/issues/new?component=1389291&template=1850622 Documentation for the AutoRoller is here: https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md
When performing artifact lookups for `Artifact.genSnapshot` for macOS desktop builds, a `TargetPlatform` is used to determine the name of the tool, typically `gen_snapshot_$TARGET_ARCH`. Formerly, this tool was always named `gen_snapshot`. The astute reader may ask "but Chris, didn't we support TWO target architectures on iOS and therefore need TWO `gen_snapshot` binaries?" Yes, we did support both armv7 and arm64 target architectures on iOS. But no, we didn't initially have two `gen_snapshot` binaries. We did *build* two `gen_snapshots`: * A 32-bit x86 binary that emitted armv7 AOT code * A 64-bit x64 binary that emitted arm64 AOT code At the time, the bitness of the `gen_snapshot` tool needed to match the bitness of the target architecture, and to avoid having to do a lot of work plumbing through suffixed `gen_snapshot` names, the author of that work (who, as evidenced by this patch, is still paying for his code crimes) elected to "cleverly" lipo the two together into a single multi-architecture macOS binary still named `gen_snapshot`. See: flutter/engine#4948 This was later remediated over the course of several patches, including: * flutter/engine#10430 * flutter/engine#22818 * flutter#37445 However, there were still cases (notably `--local-engine` workflows in the tool) where we weren't computing the target platform and thus referenced the generic `gen_snapshot` tool. See: flutter#38933 Fixed in: flutter/engine#28345 The test removed in this PR, which ensured that null `SnapshotType.platform` was supported was introduced in flutter#11924 as a followup to flutter#11820 when the snapshotting logic was originally extracted to the `GenSnapshot` class, and most invocations still passed a null target platform. Since there are no longer any cases where `TargetPlatform` isn't passed when looking up `Artifact.genSnapshot`, we can safely make the platform non-nullable and remove the test. This is pre-factoring towards the removal of the generic `gen_snapshot` artifact from the macOS host binaries (which are currently unused since we never pass a null `TargetPlatform`), which is pre-factoring towards the goal of building `gen_snapshot` binaries with an arm64 host architecture, and eliminate the need to use Rosetta during iOS and macOS Flutter builds. Part of: flutter#101138 Umbrella issue: flutter#103386 Umbrella issue: flutter#69157 No new tests since the behaviour is enforced by the compiler.
flutter/flutter@fb110b9...98685a0 2024-04-19 [email protected] Replace CocoaPods deprecated `exists?` with `exist?` (flutter/flutter#147056) 2024-04-19 [email protected] Roll Flutter Engine from 4ed7a2d6aed9 to 7fafbbf17c02 (2 revisions) (flutter/flutter#147046) 2024-04-19 [email protected] Roll Flutter Engine from 25d773ea90c4 to 4ed7a2d6aed9 (3 revisions) (flutter/flutter#147038) 2024-04-19 [email protected] Update link branches to `main` (continued) (flutter/flutter#146985) 2024-04-19 [email protected] Roll Flutter Engine from b6234dd1984e to 25d773ea90c4 (1 revision) (flutter/flutter#147035) 2024-04-19 [email protected] Roll Flutter Engine from ff471881e90a to b6234dd1984e (2 revisions) (flutter/flutter#147029) 2024-04-19 [email protected] Roll Flutter Engine from 442d14a7e840 to ff471881e90a (1 revision) (flutter/flutter#147025) 2024-04-19 [email protected] Roll Flutter Engine from 6e4a15d31769 to 442d14a7e840 (2 revisions) (flutter/flutter#147023) 2024-04-19 [email protected] Opt out users from GA3 if opted out of GA4 (flutter/flutter#146453) 2024-04-19 [email protected] Roll Flutter Engine from 61bf47d129bb to 6e4a15d31769 (1 revision) (flutter/flutter#147022) 2024-04-18 [email protected] Roll Flutter Engine from 13a6ce419664 to 61bf47d129bb (4 revisions) (flutter/flutter#147017) 2024-04-18 [email protected] Add a breadcrumb for the pub autoroller (flutter/flutter#146786) 2024-04-18 98614782+auto-submit[bot]@users.noreply.github.com Reverts "Add generic type for result in PopScope (#139164)" (flutter/flutter#147015) 2024-04-18 [email protected] Redundant message fix (flutter/flutter#143978) 2024-04-18 [email protected] Clean up flutterRoot (flutter/flutter#147010) 2024-04-18 49699333+dependabot[bot]@users.noreply.github.com Bump actions/upload-artifact from 4.3.1 to 4.3.2 (flutter/flutter#147011) 2024-04-18 [email protected] Add Swift Package Manager as new opt-in feature for iOS and macOS (flutter/flutter#146256) 2024-04-18 [email protected] Refactor framework coverage tests (flutter/flutter#146210) 2024-04-18 [email protected] Roll Flutter Engine from 46ff024bff10 to 13a6ce419664 (3 revisions) (flutter/flutter#147006) 2024-04-18 [email protected] Changing the renderer on the web target should change its build key. (flutter/flutter#147003) 2024-04-18 [email protected] Roll Flutter Engine from 6abfa565a9f9 to 46ff024bff10 (1 revision) (flutter/flutter#147005) 2024-04-18 [email protected] Add generic type for result in PopScope (flutter/flutter#139164) 2024-04-18 [email protected] Roll Flutter Engine from aa6f7411c219 to 6abfa565a9f9 (1 revision) (flutter/flutter#147002) 2024-04-18 [email protected] [tools] Make SnapshotType.platform non-nullable (flutter/flutter#146958) 2024-04-18 [email protected] Roll Flutter Engine from b8e802515b5a to aa6f7411c219 (1 revision) (flutter/flutter#146996) 2024-04-18 [email protected] Roll Flutter Engine from 2c3e9c8bfce6 to b8e802515b5a (2 revisions) (flutter/flutter#146993) 2024-04-18 [email protected] Roll Packages from d39830e to 0e3809d (9 revisions) (flutter/flutter#146992) 2024-04-18 [email protected] Fix memory leaks in navigation rail (flutter/flutter#146988) If this roll has caused a breakage, revert this CL and stop the roller using the controls here: https://autoroll.skia.org/r/flutter-packages Please CC [email protected],[email protected],[email protected] on the revert to ensure that a human is aware of the problem. To file a bug in Packages: https://github.com/flutter/flutter/issues/new/choose To report a problem with the AutoRoller itself, please file a bug: https://issues.skia.org/issues/new?component=1389291&template=1850622 Documentation for the AutoRoller is here: https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md
When performing artifact lookups for
Artifact.genSnapshotfor macOS desktop builds, aTargetPlatformis used to determine the name of the tool, typicallygen_snapshot_$TARGET_ARCH. Formerly, this tool was always namedgen_snapshot.The astute reader may ask "but Chris, didn't we support TWO target architectures on iOS and therefore need TWO
gen_snapshotbinaries?" Yes, we did support both armv7 and arm64 target architectures on iOS. But no, we didn't initially have twogen_snapshotbinaries. We did build twogen_snapshots:At the time, the bitness of the
gen_snapshottool needed to match the bitness of the target architecture, and to avoid having to do a lot of work plumbing through suffixedgen_snapshotnames, the author of that work (who, as evidenced by this patch, is still paying for his code crimes) elected to "cleverly" lipo the two together into a single multi-architecture macOS binary still namedgen_snapshot. See: flutter/engine#4948This was later remediated over the course of several patches, including:
However, there were still cases (notably
--local-engineworkflows in the tool) where we weren't computing the target platform and thus referenced the genericgen_snapshottool.See: #38933
Fixed in: flutter/engine#28345
The test removed in this PR, which ensured that null
SnapshotType.platformwas supported was introduced in #11924 as a followup to #11820 when the snapshotting logic was originally extracted to theGenSnapshotclass, and most invocations still passed a null target platform.Since there are no longer any cases where
TargetPlatformisn't passed when looking upArtifact.genSnapshot, we can safely make the platform non-nullable and remove the test.This is pre-factoring towards the removal of the generic
gen_snapshotartifact from the macOS host binaries (which are currently unused since we never pass a nullTargetPlatform), which is pre-factoring towards the goal of buildinggen_snapshotbinaries with an arm64 host architecture, and eliminate the need to use Rosetta during iOS and macOS Flutter builds.Part of: #101138
Umbrella issue: #103386
Umbrella issue: #69157
No new tests since the behaviour is enforced by the compiler.
Pre-launch Checklist
///).If you need help, consider asking for advice on the #hackers-new channel on Discord.