Skip to content
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

organize snapshot/BUILD.gn targets and fix create_arm_gen_snapshot #28345

Merged
merged 6 commits into from
Aug 27, 2021

Conversation

cyanglaz
Copy link
Contributor

@cyanglaz cyanglaz commented Aug 27, 2021

  1. Make all the public_deps in snapshot/BUILD.gn into one single group target, adding create_arm_gen_snapshot into this new group target.
  2. From BUILD.gn, refer to the new group target instead.

This also fixes flutter/flutter#38933

The current code has create_arm_gen_snapshot inside source_set("snapshot"), which doesn't seem to be run at all.

I couldn't find any deps to source_set("snapshot") in the code base. Maybe we should just remove source_set("snapshot")? @zanderso

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.

@cyanglaz cyanglaz requested a review from jmagman August 27, 2021 19:28
@google-cla google-cla bot added the cla: yes label Aug 27, 2021
@jmagman jmagman requested a review from zanderso August 27, 2021 19:38
@jmagman
Copy link
Member

jmagman commented Aug 27, 2021

I defer to @zanderso, I didn't get it working in #22818

@zanderso
Copy link
Member

In GN, if the target has the same name as the directory it's in, then the target name can be omitted when depending on it, so instead of depending on //flutter/lib/snapshot:snapshot, you'll find a number of dependencies on //flutter/lib/snapshot.

@cyanglaz
Copy link
Contributor Author

@zanderso Thanks for the explanation!
I just scanned through all the targets depends on "//flutter/lib/snapshot", the only none-testing target that depends on it was host executable, I guess that was the reason it never ran.

@cyanglaz cyanglaz added the waiting for tree to go green This PR is approved and tested, but waiting for the tree to be green to land. label Aug 27, 2021
@fluttergithubbot fluttergithubbot merged commit e7b447e into flutter:master Aug 27, 2021
@cyanglaz cyanglaz deleted the ios_arm_64_snapshot_target branch August 27, 2021 23:35
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Aug 28, 2021
cbracken added a commit to cbracken/flutter that referenced this pull request Apr 17, 2024
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
auto-submit bot pushed a commit to flutter/flutter that referenced this pull request Apr 18, 2024
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
   * #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: #38933
Fixed in: flutter/engine#28345

The test removed in this PR, which ensured that null `SnapshotType.platform` was supported was introduced in #11924 as a followup to #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: #101138
Umbrella issue: #103386
Umbrella issue: #69157

No new tests since the behaviour is enforced by the compiler.
gilnobrega pushed a commit to gilnobrega/flutter that referenced this pull request Apr 22, 2024
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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cla: yes waiting for tree to go green This PR is approved and tested, but waiting for the tree to be green to land.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Local engine workflow for iOS profile/release mode is broken.
4 participants