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
[flutter_tools] Add ARM64 Linux host and cross-building option support #61221
[flutter_tools] Add ARM64 Linux host and cross-building option support #61221
Conversation
It looks like this pull request may not have tests. Please make sure to add tests before merging. If you need an exemption to this rule, contact Hixie on the #hackers channel in Chat. Reviewers: Read the Tree Hygiene page and make sure this patch meets those guidelines before LGTMing. |
@@ -299,6 +299,7 @@ class AOTSnapshotter { | |||
TargetPlatform.ios, | |||
TargetPlatform.darwin_x64, | |||
TargetPlatform.linux_x64, | |||
TargetPlatform.linux_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.
We're trying to move away from the giant switch of platforms. The problem this causes is that it makes a lot of invalid states easily representable.
Instead this should be factored out into a LinuxArch enum. This could be done before any of the work to support arm
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.
@jonahwilliams
Okay. I will create a LinuxArch enum like Android/iOS and modify this PR.
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.
Looking at the cache APIs we have today, it doesn't seem easy to do this. I wonder if you've had any progress? Perhaps we should reconsider for now
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.
@jonahwilliams
I'm reading around the source code of cache.dart. I'm also considering a fix to support ARM64 Host. Please give me some time.
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.
@jonahwilliams
By the way, I think TargetPlatform
should be separated into OS and Arch. Are you already considering some kind of refactoring? It may take some time, but is it okay for me to consider it? However, there are many changes. The timing of merging is also difficult.
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.
Sorry I missed this - that is probably a good change but its a bit out of scope
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.
OK. Thank you.
@HidenoriMatsubayashi did you actually build the binaries and get this working, or is this a proof of concept? When I said I could help you with infra, I misunderstood and thought you had a working linux arm host setup. I can point you in the right direction, but I don't really have bandwidth to work on this at the moment. |
Yes, I did. I use my customized sysrootfs for aarch64, but here is a binary for sample flutter app built with Flutter SDK with this patch. Works with ARM64 platforms such as JetsonNao. Of course, I also use a locally built version of Flutter Engine.
I see. No problem at all. |
@HidenoriMatsubayashi That's awesome to hear! Did you cross-build Dart directly from the https://github.com/dart-lang/sdk repo, or via Flutter's engine environment? I was able to do the former, but got stuck on the latter before I had to move on to other things. |
A while ago, I tried to cross-build Dart directly from the https://github.com/dart-lang/sdk repo for running Flutter SDK (flutter commands) on ARM64 Host. I basically tried the steps here. I think the build result worked on Raspberry Pi 4.
What exactly was the problem? If you want to support running flutter sdk on ARM64 Host, I may be able to help you.. |
Any updates on this? |
Addressing some of the questions/comments in the initial description:
Yes, definitely (unless there's a fat/universal build option for Linux that I'm not aware of). We should not stomp builds with different target outputs.
This seems out of scope for Flutter; we don't ship and use a sysroot for the current builds.
This would be the first place to start, IMO. We also need confirmation/commitment from Dart folks that cross-compile tooling (e.g., for gen_snapshot) is a supported configuration on Linux. |
We found a Contributor License Agreement for you (the sender of this pull request), but were unable to find agreements for all the commit author(s) or Co-authors. If you authored these, maybe you used a different email address in the git commits than was used to sign the CLA (login here to double check)? If these were authored by someone else, then they will need to sign a CLA as well, and confirm that they're okay with these being contributed to Google. ℹ️ Googlers: Go here for more info. |
@nikiask @stuartmorgan @christopherfujino
Replace dart-sdk after the error.
|
Thanks for the response. Sorry I didn't respond, I've been busy putting out fires. I was also able to build the Dart SDK via the Dart repo directly. However, when I tried building it via the Flutter engine environment (link, this is how the Dart SDK that the Flutter SDK uses gets built) I got missing headers errors. I'm guessing I need to provide a sysroot? @HidenoriMatsubayashi |
Yes. There are two ways. One is to use an external sysroot. Another way is to modify I could cross-build and pass the build.. I am going to send the PR.
You need to modify
Build Flutter Engine. The build is successful. But it is necessary to be careful about version combinations when actually run a Flutter app because of version check of DartVM.
|
I confirmed that the dart-sdk built above works on ARM64 Host. However, the flutter app has not been executed yet due to the error of dart-sdk. I am currently investigating..
|
This is great! When I get some free time I'll check this out. |
@christopherfujino I was able to run flutte sdk & flutter app on ARM64 Host (Jetson Nano). I will send a PR after this, so I would like to request a review. |
CLAs look good, thanks! ℹ️ Googlers: Go here for more info. |
@jonahwilliams @christopherfujino
Your welcome! Actually, I (We) really want to use Flutter in our embedded Linux systems or products. I'm rooting for you (Flutter) :) |
I believe the |
Should I do that? |
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!
Actually, I'm mistaken, this is also happening upstream. The failure will have to be fixed upstream first. |
Can we use this on android arm64? |
on termux I tested on my smartphone(POCO X3) the HidenoriMatsubayashi fork on an Ubuntu 20.04 over termux instaled with Andronix, |
Using Termux or similar approach may be possible (as long as the app provides aarch64 userland and you have enough RAM - both will be impacted by how Android operates). Android build tools aren't available for aarch64 afaik. Pretty much the mention of Android Studio not supporting arm64 in the design document (note that IntelliJ IDEs are using Java and can run on arm devices however the android build tools to create the apps aren't available for that platform). Android host doesn't seem likely but that has a lot more to do with the OS itself. Your best bet would be Termux or similar (results will be of questionable success). This PR is addressing Linux aarch64 host support. If you get Linux aarch64 environment on Android - sure. Otherwise, the PR is not relevant to your use case |
You are correct, Android host is not supported by this PR, which specifically targets desktop linux. I'm not sure how Termux works, but I imagine even if you could get the CLI tool to start, there would be other blockers to actually being able to develop Flutter applications. |
The plugins were fixed upstream. I merged tip of tree to this branch to re-trigger CI. |
CLAs look good, thanks! ℹ️ Googlers: Go here for more info. |
@christopherfujino |
This is how termux works, Termux is not FHS compliant, and it is compiled with android ndk. Many packages have termux version, including dart. |
Hello, [144/258] python ../../build/rust/run.py /home/murat/dart-sdk/sdk/buildtools/linux-x64/rust/bin/cargo build --target-dir /home/murat/dart-sdk/sdk/out/ReleaseXARM64/obj/third_party/wasmer --manifest-path /home/murat/dart-sdk/sdk/third_party/wasmer/Cargo.toml --target aarch64-unknown-linux-gnu --release Compiling wasmer-c-api v1.0.2 |
Here's a successful LED build https://ci.chromium.org/raw/build/logs.chromium.org/flutter/led/fujino_google.com/8e8335c33506c69d98777c4d07f5eb68e447c7596d03c0c26ed8c40237f06824/+/annotations?server=chromium-swarm.appspot.com. There is no builder set up for this recipe yet, so after this CL lands I will update the builder config. Bug: flutter/flutter#61221 Change-Id: Ice10ec84127d60ae379b825fd03196b63fe7482a Reviewed-on: https://flutter-review.googlesource.com/c/recipes/+/9580 Commit-Queue: Christopher Fujino <fujino@google.com> Reviewed-by: Keyong Han <keyonghan@google.com>
Does it now support cross-compiling linux arm64 on linux x64? |
This comment was marked as off-topic.
This comment was marked as off-topic.
@danimesq |
1. Description
I want to support following functions.
flutter run -d linux
,flutter doctor
)Design documents
https://docs.google.com/document/d/19tzWySgtgtTA99XQsjx5Pg0SFJeZKXyUlYavR0EXv8c/edit?usp=sharing
Use Case
Running the flutter app on Arm64 Linux Host.
Cross-building a Flutter app for Arm64 on x64 Linux Host.
If you want to cross-build for Arm64, you need to prepare a target sysroot. You can specify it as a command line argument.
2. Related PRs
3. Related Issues
4. Tests
I have tested that it can be built and run for x84_64 Host and built for aarch64 to work with Jeston Nano.
5. 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.///
).flutter analyze --flutter-repo
) does not report any problems on my PR.Breaking Change
Did any tests fail when you ran them? Please read Handling breaking changes.