-
Notifications
You must be signed in to change notification settings - Fork 6k
Add support of cross-building the engine for ARM64 Linux Host #20254
Add support of cross-building the engine for ARM64 Linux Host #20254
Conversation
@christopherfujino to route to the right reviewer for this. |
BUILD.gn
Outdated
@@ -71,7 +71,7 @@ group("flutter") { | |||
} | |||
|
|||
# If on the host, compile tools. | |||
if (current_toolchain == host_toolchain) { | |||
if (current_toolchain == host_toolchain || is_linux) { |
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 condition no longer matches the comment. Aren't these host tools? It's not clear to me why you are cross-compiling them.
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.
Yes, I have to modify the comment.
But I couldn't understand why if (current_toolchain == host_toolchain)
was necessary. In order to run the Flutter SDK and Flutter Apps on ARM64 Linux platforms, we need to build dart-sdk
, frontend_server.dart.snapshot
and const_finder.dart.snapshot
and so on. This condition is not necessary for cross build.
I think I got it for now. But I think you need to build the following in order to run Flutter SDK on ARM64 Linux. Correct?
- //flutter/flutter_frontend_server:frontend_server
- //third_party/dart:create_sdk
- //flutter/web_sdk
- //flutter/shell/testing
- //flutter/tools/const_finder
- //flutter/tools/font-subset
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.
I don't know the answer to that offhand.
Are they uploaded as artifacts and then downloaded and run by the flutter
tool? If so, then you are correct that they aren't host tools, in which case we should instead be deciding when to build them based on support Flutter SDK environments.
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.
@stuartmorgan
(cc: @christopherfujino please support me.)
Thank you for your reply.
Are they uploaded as artifacts and then downloaded and run by the flutter tool?
That's right.
I think that it is not necessary in the case where only cross build like Android and iOS, however it is necessary when running as Flutter SDK on Host.
I think that all can be built for ARM64 without problems.
//third_party/dart:create_sdk
This is dart-sdk and download to ${INSTALL_PATH}/flutter/bin/cache/dart-sdk
. ARM64 is already supported (link)
//flutter/flutter_frontend_server:frontend_server
This is the Dart project, it can be built for ARM64.
It's downloaded to ${INSTALL_PATH}/flutter/bin/cache/artifacts/engine/linux-${arch}/frontend_server.dart.snapshot
//flutter/web_sdk
I'm not sure about this.
//flutter/shell/testing
This is the C++ source code for flutter_test
?
It's downloaded to ${INSTALL_PATH}/flutter/bin/cache/artifacts/engine/linux-${arch}/flutter_tester
//flutter/tools/const_finder
This is the Dart project.
It's downloaded to ${INSTALL_PATH}/flutter/bin/cache/artifacts/engine/linux-${arch}/const_finder.dart.snapshot
//flutter/tools/font-subset
This is the C++ source code.
It's downloaded to ${INSTALL_PATH}/flutter/bin/cache/artifacts/engine/linux-${arch}/font-subset
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.
Makes sense; I thought "host" in the comment meant build host, rather that "Flutter host". I think you'll want (is_linux && !is_chromeos)
though.
The comment should probably be something like:
# Flutter SDK artifacts should only be built when either doing host builds, or
# for cross-compiled desktop targets.
(I wouldn't mention Linux since macOS and/or Windows could be done this way in the future.)
Also, you should extract this to a variable like build_engine_artifacts
since it's used in two places.
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.
Thank you so much. I fixed it. Could you review my change?
I've been able to complete the build step on my Linux x86 Host machine. |
@incon |
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.
Needs GN formatting so it passes CI, but otherwise LGTM. @chinmaygarde should review as well since he's more familiar with the engine artifacts though, to make sure that new logic makes sense to him as well.
@stuartmorgan Thank you so much. I fixed the formatting error. |
Using these instructions to run on pi 4. The debug works and I can run and debug the sample application on the pi. Very nice. However, I can't build a release. It seems that the clang_x64/gen_snapshot executable is still x86. Update: I copied gen_snapshot_product to the gen_snapshot and it successfully built a release bundle. Wahoo! Really nice write up has been created here: |
…flutter#20254)" This reverts commit 101d85a.
…flutter#20254)" This reverts commit 101d85a.
…flutter#20254)" This reverts commit 101d85a.
…flutter#20254)" This reverts commit 101d85a.
This reverts commit b243545.
…flutter#20254)" This reverts commit 101d85a.
This reverts commit b243545.
I don't understand why this PR claims cross compilation for aarch64. I was able to cross compile the engine for arrch64 long before this PR. |
I believe this PR is so that you can compile and run inside of a linux desktop that is running on arm64, a raspberry pi running raspberry pi OS for example. |
Yes I see the build on host, it also claims cross compilation. Imagine trying to build the engine on a raspberry pi? That would take an enternity... Hence why cross compiling is preferred, which already worked for ~2 years. |
…flutter#20254)" This reverts commit 101d85a.
…flutter#20254)" This reverts commit 101d85a.
…flutter#20254)" This reverts commit 101d85a.
…flutter#20254)" This reverts commit 101d85a.
…flutter#20254)" This reverts commit 101d85a.
…flutter#20254)" This reverts commit 101d85a.
…flutter#20254)" This reverts commit 101d85a.
…flutter#20254)" TK MERGES This reverts commit 101d85a.
Description
Added cross-building Flutter Engine for ARM64 Linux platforms. This PR is part of ARM64 Linux support in the Flutter SDK.
Related PRs
Related Issues
Tests
1. Build Test
First, I confirmed that Flutter Engine can be built for x64 and arm64. The procedure is as follows. All are operations on x64 Linux Host.
Get source code and setup build enviroment.
Cross-build for ARM64 Linux
Build for x64 Linux and Regression test.
2. Run Flutter SDK and app on ARM64 Linux (Jetson Nano)
Second, using the artifacts for ARM64 built by the above procedure, I have confirmed that the Flutter SDK and Flutter app can work fine on Jetson Nano (ARM64 CPU).
All are operations on ARM64 Linux Host (Jetson Nano).
Copy
dart-sdk
which was locally built to${your installpath}/bin/cache/
.Copy the Flutter SDK artifacts (build data) to
${your installpath}/bin/cache/artifacts/engine
directory manually.out/linux_debug_arm64/flutter_patched_sdk
to${your installpath}/bin/cache/artifacts/engine/common/flutter_patched_sdk
out/linux_debug_arm64/flutter_linux, gen/const_finder.dart.snapshot, flutter_tester, font-subset, gen/frontend_server.dart.snapshot, icudtl.dat, libflutter_linux_gtk.so, gen/flutter/lib/snapshot/isolate_snapshot.bin, gen/flutter/lib/snapshot/vm_isolate_snapshot.bin
to${your installpath}/bin/cache/artifacts/engine/artifacts/engine/linux-x64
out/linux_release_arm64/flutter_patched_sdk
to${your installpath}/bin/cache/artifacts/engine/common/flutter_patched_sdk_product
out/linux_release_arm64/flutter_linux, libflutter_linux_gtk.so
to${your installpath}/bin/cache/artifacts/engine/artifacts/engine/linux-x64-release
out/linux_release_arm64/clang_x64/gen_snapshot
to${your installpath}/bin/cache/artifacts/engine/artifacts/engine/linux-x64-release
${your installpath}/bin/cache/artifacts/engine/artifacts/engine/linux-x64-profile
is omitted.Checklist
Before you create this PR confirm that it meets all requirements listed below by checking the relevant checkboxes (
[x]
). This will ensure a smooth and quick review process.Breaking Change
Did any tests fail when you ran them? Please read handling breaking changes.