Skip to content

Add support for riscv64 desktop linux engine - #178712

Merged
auto-submit[bot] merged 1 commit into
flutter:masterfrom
vhaudiquet:riscv64-engine
Nov 7, 2026
Merged

auto-submit[bot] merged 1 commit into
flutter:masterfrom
vhaudiquet:riscv64-engine

Conversation

@vhaudiquet

Copy link
Copy Markdown
Contributor

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:

Screenshot from 2025-11-18 08-58-03

This allows to build a Flutter engine on x64 host, and then expose the artifacts with a webserver to the flutter tool of #178711:

# Host
et build -c ci/linux_debug_riscv64 && et build -c ci/linux_profile_riscv64 && et build -c ci/linux_release_riscv64
...http server...
# RISC-V
export FLUTTER_STORAGE_BASE_URL=http://host-server-url
flutter

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:

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",

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-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.

@github-actions github-actions Bot added the engine flutter/engine related. See also e: labels. label Nov 18, 2025

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@jwinarske

Copy link
Copy Markdown
Contributor

@vhaudiquet
This patch set is required for a proper risc-v 32/64 engine build:
https://github.com/meta-flutter/workspace-automation/tree/v2.0/patches/flutter-engine

Also found here:
https://github.com/meta-flutter/meta-flutter/tree/master/recipes-graphics/flutter-engine/files

They’ve been around since August of last year.

Two key issues:

  • engine needs to update llvm toolchain (cipd)
  • third_party deps need updates (before this repo)

committing flutter changes without the above two is a bit of a hack.

@vhaudiquet

Copy link
Copy Markdown
Contributor Author

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.

@jwinarske

jwinarske commented Nov 22, 2025 •

Copy link
Copy Markdown
Contributor

Did the llvm cipd get updated recently? If so in what version. Patches referenced are for stable (3.57.7) + llvm 21.

@vhaudiquet

Copy link
Copy Markdown
Contributor Author

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.
It might be related to the recently merged PRs that provide a Flutter engine for riscv64 Android.

robert-ancell
robert-ancell previously approved these changes Dec 1, 2025

@robert-ancell robert-ancell left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@vhaudiquet

vhaudiquet commented Dec 2, 2025 •

Copy link
Copy Markdown
Contributor Author

@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

Internal tests failed. Please contact a Google developer to help investigate the failure.

Can somebody help with that? 😃

@chinmaygarde

Copy link
Copy Markdown
Contributor

Ping @jtmcdole on landing and testing this.

@jtmcdole jtmcdole left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@vhaudiquet

Copy link
Copy Markdown
Contributor Author

Hello @jtmcdole, happy new year! 😃
Any updates? Is there anything still misssing?

@jtmcdole

jtmcdole commented Jan 5, 2026

Copy link
Copy Markdown
Member

Back from holidays, let me take a look

jtmcdole
jtmcdole previously approved these changes Jan 5, 2026
github-merge-queue Bot pushed a commit that referenced this pull request Jan 9, 2026
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]>
@vhaudiquet

Copy link
Copy Markdown
Contributor Author

Now that the tool PR has landed, is there a timeline for this one?

So right now, lets look at landing this; then get a patch in; then consider a x64 builder that can make artifacts at head.

If I can help getting the patch in for third_party/swiftshader, tell me 😃
I didn't know it was possible to patch this directly for Flutter usage. Also, I can help testing resulting artifacts, and testing everything basically, on RISC-V hardware. Let me know

@jtmcdole

Copy link
Copy Markdown
Member

Now that the tool PR has landed, is there a timeline for this one?

So right now, lets look at landing this; then get a patch in; then consider a x64 builder that can make artifacts at head.

If I can help getting the patch in for third_party/swiftshader, tell me 😃 I didn't know it was possible to patch this directly for Flutter usage. Also, I can help testing resulting artifacts, and testing everything basically, on RISC-V hardware. Let me know

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",

@jason-simmons

Copy link
Copy Markdown
Contributor

The SwiftShader upstream tried to land that patch 2 years ago. But apparently it was reverted due to an incompatibility with Chromium.
(see https://swiftshader.googlesource.com/SwiftShader/+/eb75201a4e0354a36d315dd01077092ec9aa2356)

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.

@vhaudiquet

Copy link
Copy Markdown
Contributor Author

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?

Sorry, I meant for RISC-V. We will need that patch if we want to merge and build at the same time.

@jtmcdole

Copy link
Copy Markdown
Member

i've created a mirror. I'll see about landing the patch there and then updating DEPs.

@gaaclarke

Copy link
Copy Markdown
Member

Hey @jtmcdole this hasn't been updated in a while but is approved, are we still sitting on this?

@vhaudiquet

Copy link
Copy Markdown
Contributor Author

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.
Unfortunately, building the engine still requires a patch to third_party/swiftshader, so @jtmcdole opened #181225 to add that patch.

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.

@gaaclarke

Copy link
Copy Markdown
Member

still waiting on the patch from @jtmcdole, I've pinged him on that pr

@gaaclarke

Copy link
Copy Markdown
Member

@jtmcdole friendly ping

@jtmcdole

jtmcdole commented Jul 6, 2026

Copy link
Copy Markdown
Member

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.

pull Bot pushed a commit to edisplay/flutter that referenced this pull request Aug 1, 2026
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
@jtmcdole

jtmcdole commented Nov 5, 2026

Copy link
Copy Markdown
Member

I'm taking a quick look this morning.

@vhaudiquet

Copy link
Copy Markdown
Contributor Author

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 jtmcdole left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is super close. I'll add CICD, but I'm trusting you built this locally since I don't have riscv hardware.

@jtmcdole jtmcdole added the CICD Run CI/CD label Nov 5, 2026
Comment thread engine/src/flutter/tools/gn Resolved
Comment thread engine/src/flutter/tools/gn Resolved
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.
@flutter-dashboard flutter-dashboard Bot removed the CICD Run CI/CD label Nov 6, 2026
@github-actions github-actions Bot removed a: accessibility Accessibility, e.g. VoiceOver or TalkBack. (aka a11y) platform-linux Building on or for Linux specifically a: desktop Running on desktop team-linux Owned by the Linux platform team labels Nov 6, 2026
@vhaudiquet

vhaudiquet commented Nov 6, 2026 •

Copy link
Copy Markdown
Contributor Author

So:

All of this is needed for building. Reminder that this allows cross-building the engine, so technically build-test does not need riscv64 hardware, as this builds amd64 -> riscv64. However you do need RISC-V hardware in order to test that built engine afterwards.

I produce regular builds of the engine for riscv64, all hosted on: https://flutter-experimental.ubuntu.com
Those builds are production-tested in the Ubuntu Installer present in the Ubuntu Desktop images for RISC-V. So I would say that I am now a lot more confident in this being ready then I was when I first sent that PR.

I will build-test locally again with all the 3 commits rebased and updated, I'll follow up with the results here.

@jtmcdole jtmcdole added the CICD Run CI/CD label Nov 6, 2026
@jtmcdole jtmcdole added the autosubmit Merge PR when tree becomes green via auto submit App label Nov 6, 2026
@auto-submit auto-submit Bot removed the autosubmit Merge PR when tree becomes green via auto submit App label Nov 6, 2026
@auto-submit

auto-submit Bot commented Nov 6, 2026

Copy link
Copy Markdown
Contributor

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.

  • Merge guidelines: A PR needs at least one approved review if the author is already part of flutter-hackers or two member reviews if the author is not a member of flutter-hackers before re-applying the autosubmit label. Reviewers: If you left a comment approving, please use the "approve" review action instead.

@vhaudiquet

Copy link
Copy Markdown
Contributor Author

FYI I retested locally

et build -c ci/linux_debug_riscv64
et build -c ci/linux_profile_riscv64
et build -c ci/linux_release_riscv64

All 3 are build ok with the 3 commits mentioned above.

@loic-sharma loic-sharma added the autosubmit Merge PR when tree becomes green via auto submit App label Nov 6, 2026
@auto-submit
auto-submit Bot added this pull request to the merge queue Nov 6, 2026
Merged via the queue into flutter:master with commit 6c68490 Nov 7, 2026
36 checks passed
@flutter-dashboard flutter-dashboard Bot removed the autosubmit Merge PR when tree becomes green via auto submit App label Nov 7, 2026
chingjun added a commit to chingjun/flutter that referenced this pull request Nov 7, 2026
…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.
auto-submit Bot pushed a commit to flutter/packages that referenced this pull request Nov 7, 2026
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CICD Run CI/CD customer: canonical Various Canonical teams engine flutter/engine related. See also e: labels.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants