Repository navigation
Add support for riscv64 desktop linux engine - #178712
Conversation
There was a problem hiding this comment.
Code Review
This pull request introduces support for cross-compiling the Flutter engine for riscv64 desktop Linux. The changes span across build configurations, CI definitions, and engine tooling to recognize and build for the new target. My review identified a couple of areas for improvement: a redundant build flag definition in the GN configuration and a potential typo in a path within the new CI build definition file for riscv64. Addressing these will improve the correctness and maintainability of the build configuration.
6309083 to
7effe97
Compare
|
@vhaudiquet They’ve been around since August of last year. Two key issues:
committing flutter changes without the above two is a bit of a hack. |
|
I've only had to apply a patch to third_party swiftshader (as explained above). Other patches seem to have already been applied, or to not be necessary anymore? I did not need anything except the swiftshader patch and this PR to build the engine. |
|
Did the llvm cipd get updated recently? If so in what version. Patches referenced are for stable (3.57.7) + llvm 21. |
|
I would think so, as effectively I tried applying my PR to the latest stable and it failed to build, so that one needed more patches. |
robert-ancell
left a comment
There was a problem hiding this comment.
Change looks generally good to me. If this is still experimental then perhaps some comments noting that or a message when building. On the other hand, this only runs if you have a RISCV builder right? So you probably know the limitations if you've done that.
|
@robert-ancell This allows cross-compiling the engine on an x86_64 host for a riscv64 target, so you don't technically need a riscv64 builder to do that. But to run that engine, you are right that you need a riscv64 host; for which I think all of the community understands that the support is experimental. But maybe we can still add a message somewhere? I see now that the "Google testing" failed. The test page says
Can somebody help with that? 😃 |
|
Ping @jtmcdole on landing and testing this. |
jtmcdole
left a comment
There was a problem hiding this comment.
This only builds locally for now. If we identify what machines we would need to build this at master, we could produce artifacts at a later time.
|
Hello @jtmcdole, happy new year! 😃 |
|
Back from holidays, let me take a look |
This adds support for buildind desktop linux applications for riscv64 on the flutter tool, as well as basic riscv64 support for the tool. This is a first move towards fixing #99963. Along with #178712 that allows building an engine for `riscv64`, this PR allows me to build and run the flutter 'hello world' app on RISC-V hardware: <img width="1920" height="1080" alt="Screenshot from 2025-11-18 08-58-03" src="https://github.com/user-attachments/assets/5e90bc7f-49a7-41a8-82b7-5a5d3247938a" /> This allows someone who built a flutter engine and exposed it on a webserver to run commands like: ``` export FLUTTER_STORAGE_BASE_URL=http://your-server-url flutter flutter doctor cd example/hello_world && flutter build linux ``` This means that even if Google does not want to support Flutter on RISC-V officially (hosting the artifacts), community-managed servers could host the RISC-V flutter engines/artifacts. It also means that internally, companies using Flutter on RISC-V would just have to build their engine and setup such a server, and it allows them to use the upstream Flutter tool. ## Pre-launch Checklist - [x] I read the [Contributor Guide] and followed the process outlined there for submitting PRs. - [x] I read the [Tree Hygiene] wiki page, which explains my responsibilities. - [x] I read and followed the [Flutter Style Guide], including [Features we expect every widget to implement]. - [x] I signed the [CLA]. - [x] I listed at least one issue that this PR fixes in the description above. - [ ] I updated/added relevant documentation (doc comments with `///`). - [ ] I added new tests to check the change I am making, or this PR is [test-exempt]. - [ ] I followed the [breaking change policy] and added [Data Driven Fixes] where supported. - [ ] All existing and new tests are passing. If you need help, consider asking for advice on the #hackers-new channel on [Discord]. **Note**: The Flutter team is currently trialing the use of [Gemini Code Assist for GitHub](https://developers.google.com/gemini-code-assist/docs/review-github-code). Comments from the `gemini-code-assist` bot should not be taken as authoritative feedback from the Flutter team. If you find its comments useful you can update your code accordingly, but if you are unsure or disagree with the feedback, please feel free to wait for a Flutter team member's review for guidance on which automated comments should be addressed. <!-- Links --> [Contributor Guide]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#overview [Tree Hygiene]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md [test-exempt]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#tests [Flutter Style Guide]: https://github.com/flutter/flutter/blob/main/docs/contributing/Style-guide-for-Flutter-repo.md [Features we expect every widget to implement]: https://github.com/flutter/flutter/blob/main/docs/contributing/Style-guide-for-Flutter-repo.md#features-we-expect-every-widget-to-implement [CLA]: https://cla.developers.google.com/ [flutter/tests]: https://github.com/flutter/tests [breaking change policy]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#handling-breaking-changes [Discord]: https://github.com/flutter/flutter/blob/main/docs/contributing/Chat.md [Data Driven Fixes]: https://github.com/flutter/flutter/blob/main/docs/contributing/Data-driven-Fixes.md --------- Co-authored-by: John "codefu" McDole <[email protected]>
|
Now that the tool PR has landed, is there a timeline for this one?
If I can help getting the patch in for |
The PR description says "For now, building the engine on RISC-V still requires another patch:" - since we'd be building this on x86, are we blocked waiting on this patch? @jason-simmons - can you help with how we would maintain a flutter-specific patch for: diff --git a/src/Reactor/BUILD.gn b/src/Reactor/BUILD.gn
index 67dfeb0ec..dcb13614a 100644
--- a/src/Reactor/BUILD.gn
+++ b/src/Reactor/BUILD.gn
@@ -307,7 +307,7 @@ if (supports_subzero) {
if (supports_llvm) {
swiftshader_source_set("swiftshader_llvm_reactor") {
- llvm_dir = "../../third_party/llvm-10.0"
+ llvm_dir = "../../third_party/llvm-16.0"
deps = [
":swiftshader_reactor_base", |
|
The SwiftShader upstream tried to land that patch 2 years ago. But apparently it was reverted due to an incompatibility with Chromium. If we want to use that patch in Flutter, then that would involve creating a mirror of SwiftShader on https://flutter.googlesource.com/ and adding the patch to a branch. |
Sorry, I meant for RISC-V. We will need that patch if we want to merge and build at the same time. |
|
i've created a mirror. I'll see about landing the patch there and then updating DEPs. |
|
Hey @jtmcdole this hasn't been updated in a while but is approved, are we still sitting on this? |
The idea was to merge that and also start to build the engine for riscv64 at the same time. The issue is that #181225 causes another problem, as it breaks builds on different cases, I'm not sure where (multiple tests are failing in CI, I think there are real failures on Windows and maybe others). I tried to reproduce locally but even with the swiftshader patch of #181225 the builds I tried did work 😃 I think there was a lack of time to debug that further, which is why the PR is still in this dangling state. |
|
still waiting on the patch from @jtmcdole, I've pinged him on that pr |
|
@jtmcdole friendly ping |
|
third_party/swiftshader doesn't build for me on infra. I've not had time to look into what is missing to get that building from the mirror. I can try an update the mirror / patch set sometime this week. |
Updates SwiftShader to our own mirror and applied patches for llvm16: New head commit: 1be9f83618f8ba258431c0c13d7a083eb193df11 https://flutter.googlesource.com/third_party/swiftshader/+/refs/heads/flutter-a7c547b55 ``` llvm16 + riscv on flutter Reapply "Default to use llvm16" + --- LLVM: Fix missing MCExternalSymbolizer on ARM64 This adds MCExternalSymbolizer.cpp and MCSymbolizer.cpp back to the build files by removing them from the ignore list in generate_build_files.py. It also fixes two Windows-specific bugs in generate_build_files.py that caused it to output thousands of extra files and CRLF line endings on Windows. This reverts commit 5b0479bd2d15058aaa9eb490e364f920ff824a8c. --- LLVM: Fix MSVC 14.44 build error in CFG.h Add default constructor to SuccIterator to satisfy std::default_initializable required by MSVC's C++20/C++23 std::reverse_iterator. ``` Must land before flutter#178712
|
I'm taking a quick look this morning. |
FYI I'll be splitting this into 3 PRs, one per commit. I was told that it made more sense scope-wise |
jtmcdole
left a comment
There was a problem hiding this comment.
This is super close. I'll add CICD, but I'm trusting you built this locally since I don't have riscv hardware.
This allows to cross-compile a Flutter engine for riscv64 desktop linux from an x64 linux host. As there is no prebuilt Dart SDK for riscv64 Linux, the CI builder runs with --no-prebuilt-dart-sdk and builds the SDK from source.
485c59f to
03ca6fa
Compare
|
So:
All of this is needed for building. Reminder that this allows cross-building the engine, so technically build-test does not need I produce regular builds of the engine for riscv64, all hosted on: https://flutter-experimental.ubuntu.com I will build-test locally again with all the 3 commits rebased and updated, I'll follow up with the results here. |
|
autosubmit label was removed for flutter/flutter/178712, because This PR has not met approval requirements for merging. The PR author is not a member of flutter-hackers and needs 1 more review(s) in order to merge this PR.
|
|
FYI I retested locally All 3 are build ok with the 3 commits mentioned above. |
…migration/phase0 Two conflicts in dev/bots: master's flutter#195536 adds runCommand's `checkExitCode` beside the branch's `acceptedExitCodes` (both kept: a check that is off accepts everything, an accepted code is never a failure), and its test beside ours. Rolls: Dart 3b174b7217fe (and the Dart packages DEPS pins), Skia b11315d0a096, pub -- deps.lock.bzl and pub.lock.bzl regenerated. master's new linux_riscv_host_engine.json (flutter#178712, GN) is noted by the converter as a platform the Bazel build has none for (configs.bazelrc); no other GN file changed. Checked: Bazel analysis of ci_host_debug_unopt (+tests) and the root suites under --config=prebuilt_engine; the converter's builder tests; `dart analyze` of the two dev/bots files.
flutter/flutter@09175cd...e36b370 2026-11-07 [email protected] Roll Fuchsia Linux SDK from KIc0XZbhLmvDpTluZ... to Sf2yvdTiFXAKkfLkD... (flutter/flutter#196160) 2026-11-07 [email protected] Roll pub packages (flutter/flutter#196155) 2026-11-07 [email protected] [iOS a11y] Use a real `UIScrollView` as a11y scrollable container (flutter/flutter#195731) 2026-11-07 [email protected] Add ParagraphStyle.hyphenCharacter to dart:ui (flutter/flutter#195345) 2026-11-07 [email protected] Roll pub packages (flutter/flutter#196143) 2026-11-06 [email protected] [Linux] Fix layer position when compositing without glBlitFramebuffer (flutter/flutter#196083) 2026-11-06 [email protected] Add support for riscv64 desktop linux engine (flutter/flutter#178712) 2026-11-06 [email protected] Add ResizeImagePolicy.cover (flutter/flutter#194665) 2026-11-06 [email protected] Roll Skia from f533d4034900 to b11315d0a096 (6 revisions) (flutter/flutter#196138) 2026-11-06 [email protected] iOS: Remove dead code/unused imports from FlutterPlatformViewsController (flutter/flutter#196084) 2026-11-06 [email protected] Replace pull_request_target workflows with pull_request + workflow_run (flutter/flutter#195536) 2026-11-06 [email protected] [master] Update Flutter DEPS to Dart 3b174b7217fe09b21da836ea623932b5f041b091 (flutter/flutter#196004) 2026-11-06 [email protected] Fix android_hardware_smoke_test retry mechanisms (flutter/flutter#195708) 2026-11-06 [email protected] Roll Skia from 452b9c1e5db6 to f533d4034900 (1 revision) (flutter/flutter#196129) 2026-11-06 [email protected] [flutter_tools] Use `ErrorHandlingFileSystem.deleteIfExists` for `IOSCoreDeviceControl` temp directory cleanup (flutter/flutter#195913) 2026-11-06 [email protected] Adds guideline tests to flutter create samples (flutter/flutter#195827) 2026-11-06 [email protected] refactor(flutter_tools): unify OptionDescriptor identity and addTo (flutter/flutter#196076) 2026-11-06 [email protected] Roll pub packages (flutter/flutter#196114) 2026-11-06 [email protected] Roll Skia from 5ce64e63a0e7 to 452b9c1e5db6 (5 revisions) (flutter/flutter#196111) 2026-11-06 [email protected] Add PlatformDispatcher.onAlwaysUse24HourFormatChanged callback (flutter/flutter#194670) 2026-11-06 [email protected] Roll Packages from 0478162 to 63881f9 (10 revisions) (flutter/flutter#196108) 2026-11-06 [email protected] Roll Skia from 793b8ac73d4b to 5ce64e63a0e7 (4 revisions) (flutter/flutter#196107) If this roll has caused a breakage, revert this CL and set the roller to dry run mode using the controls here: https://autoroll.skia.org/r/flutter-packages Please CC [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
This allows to cross-compile a Flutter engine for riscv64 desktop linux from an x64 linux host.
This is a first move towards fixing #99963. Along with #178711 that allows using the flutter tool on riscv64, this PR allows me to build and run the flutter 'hello world' app on RISC-V hardware:
This allows to build a Flutter engine on x64 host, and then expose the artifacts with a webserver to the flutter tool of #178711:
This means that even if Google does not want to support Flutter on RISC-V officially (hosting the artifacts), community-managed servers could host the RISC-V flutter engines/artifacts. It also means that internally, companies using Flutter on RISC-V would just have to build their engine with upstream flutter instead of relying on third-party patches.
For now, building the engine on RISC-V still requires another patch:
However once that dependency is upgraded, everything builds without issues.
Pre-launch Checklist
///).If you need help, consider asking for advice on the #hackers-new channel on Discord.
Note: The Flutter team is currently trialing the use of Gemini Code Assist for GitHub. Comments from the
gemini-code-assistbot should not be taken as authoritative feedback from the Flutter team. If you find its comments useful you can update your code accordingly, but if you are unsure or disagree with the feedback, please feel free to wait for a Flutter team member's review for guidance on which automated comments should be addressed.