Skip to content

Add support for riscv64 desktop linux engine - #178712

Open
vhaudiquet wants to merge 3 commits into
flutter:masterfrom
vhaudiquet:riscv64-engine
Open

vhaudiquet wants to merge 3 commits 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.

Comment thread engine/src/flutter/ci/builders/linux_riscv_host_engine.json Outdated
Comment thread engine/src/build/config/compiler/BUILD.gn Outdated

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.

Do you only want to support this for local builds right now?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I would love to be able to build that engine in CI. It would help the RISC-V community. But I don't think you want to officially build and serve that, right? So in the mean time, if it could be built by third-party CI pipelines, and unofficially distributed by the RISC-V community, I would be happy. Building locally was for testing, but that seems to be automatically buildable, right?

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.

We could build this in post submit rather than blocking in the merge queue. The question is do we need to support this on release builds or only at master? I'll start a chat to follow up

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

If I understand correctly, you would be ready to build this in CI but without that build being required to push/merge a commit. That is wonderful news. Release builds would be better as it would almost be first-class support for RISC-V.

The main issue for me is that patch to swiftshader, which will be missing for the RISC-V build, but it seemed that patch was previously applied and reverted because it caused failure in Chromium/Chrome CI builds. I'm not sure if that is still the case though.

Please let me know about your decision!

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@jtmcdole any updates on this?

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.

I missed the github notifications. Until there's a .ci.yaml update that has something like name: Linux linux_host_engine, the artifacts are not built for master or release. We do not have a riscv machine in our pools - can this be built on arm or x64?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

This can be built on x64 - but with the patch I mentioned in the PR description to third_party/swiftshader. I'm not sure how that part works, or how to send a patch there. Plus, this patch had already been sent but rolled back AFAIK (for something related to failing chromium builds).

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.

There's a way to do patches in engine/src/flutter/third_party - @jason-simmons might be better able to help there.

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

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.

So.. took a while, but this did just land. Required more than your patch since llvm 16 and swiftshader were not happy with windows arm64.

@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

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.

There's a way to do patches in engine/src/flutter/third_party - @jason-simmons might be better able to help there.

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

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
Member

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 Aug 1, 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.

it does now.

@vhaudiquet

Copy link
Copy Markdown
Contributor Author

Hi @jtmcdole, thank you for your work on this!
What is left now to merge this one?
If needed, I can rebase this on top of master, and retry a build? Or do we want to get it in first, and land fixups later if the engine builds are not working? I will anyway try to find time this week to test an engine build with the new updated third_party/swiftshader.

@jtmcdole

Copy link
Copy Markdown
Member

I think a rebase and we should be able to review it, @vhaudiquet

This allows to cross-compile a Flutter engine for riscv64 desktop linux from an x64 linux host
@vhaudiquet

Copy link
Copy Markdown
Contributor Author

I have rebased on top of master.

I have retested a build, which works, but only after others small patches.

  • (1) Unfortunately, it seems that a workaround used in engine/src/flutter/shell/platform/linux/fl_view_accessible.cc breaks the build on trixie sysroots; and right now only riscv64 uses trixie (from the previous Flutter Android riscv64 builds, not this PR). Reading the workaround description, @robert-ancell is the one who fixed this upstream; but the fix has not made it into trixie (only in trixie-backports).
    We need a different workaround for trixie, as the code inside atk.h now uses real C++ features, so putting it all inside extern C is not possible. The more surgical fix is to only apply @robert-ancell fix to atkversion.h, but that file is not tracked in Git here... it is only inside the sysroot pulled by gclient.
    // Remove the old workaround that puts everything behind "extern C"
    diff --git a/engine/src/flutter/shell/platform/linux/fl_view_accessible.cc b/engine/src/flutte
    r/shell/platform/linux/fl_view_accessible.cc
    index df3a986ab9f..95cd63fe17f 100644
    --- a/engine/src/flutter/shell/platform/linux/fl_view_accessible.cc
    +++ b/engine/src/flutter/shell/platform/linux/fl_view_accessible.cc
    @@ -4,9 +4,7 @@
    
    - // Workaround missing C code compatibility in ATK header.
    - // Fixed in https://gitlab.gnome.org/GNOME/at-spi2-core/-/merge_requests/219
    -extern "C" {
     #include <atk/atk.h>
    -}
    
     #include "flutter/shell/platform/linux/fl_accessible_node.h"
     #include "flutter/shell/platform/linux/fl_accessible_text_field.h"
    // Surgically fix atkversion.h inside the sysroot
    --- a/engine/src/build/linux/debian_bullseye_amd64-sysroot/usr/include/atk-1.0/atk/atkversion.h
    +++ b/engine/src/build/linux/debian_bullseye_amd64-sysroot/usr/include/atk-1.0/atk/atkversion.h
    @@ -30,6 +30,8 @@
    
     #include <glib.h>
    
    +extern "C" {
    +
     /**
      * ATK_MAJOR_VERSION:
    @@ -474,5 +476,7 @@
     #define atk_interface_age atk_get_interface_age ()
    
    +}
    +
     #endif /* __ATK_VERSION_H__ */
  • (2) A second issue seems to come from the fact that Dart SDK is built from source here (as there are no published dart riscv64 tarballs AFAIK). Because of that, something related to wasm-opt seems to break (unfamiliar with how it works exactly).
    diff --git a/engine/src/flutter/tools/gn b/engine/src/flutter/tools/gn
    index b7c34d8cc89..a97eed32fe6 100755
    --- a/engine/src/flutter/tools/gn
    +++ b/engine/src/flutter/tools/gn
    @@ -719,6 +719,16 @@ def to_gn_args(args):
         # dartdevc, web SDK kernel and source files.
         gn_args['dart_platform_sdk'] = not args.full_dart_sdk
    
    +  # When the Dart SDK is built from source (i.e. no usable prebuilt is
    +  # available for the target, such as for riscv64 Linux cross builds), exclude
    +  # the wasm-opt target. Binaryen's wasm-opt is built with exceptions enabled
    +  # and links the toolchain libc++, whose bundled libcxxabi exception symbols
    +  # collide with the no-exceptions stubs in the engine's libcxxabi. The
    +  # prebuilt Dart SDK already ships a wasm-opt binary for platforms that have
    +  # one, so this only affects from-source builds.
    +  if not gn_args.get('flutter_prebuilt_dart_sdk'):
    +    gn_args['dart_include_wasm_opt'] = False
    +
       if args.build_glfw_shell is not None:
         gn_args['build_glfw_shell'] = args.build_glfw_shell
    I had AI's help on this one, and here is the AI summary:
    • riscv64 has no prebuilt Dart SDK (flutter/prebuilts/ only has linux-x64 and linux-arm64;
      can_use_prebuilt_dart returns False for linux_cpu=riscv64). So flutter_prebuilt_dart_sdk
      stays false and the Dart SDK is built from source.
    • Building the SDK from source builds wasm-opt (Binaryen), which is compiled with
      //build/config/compiler:enable_exceptions.
    • The engine's own libcxxabi
      (flutter/build/secondary/flutter/third_party/libcxxabi/BUILD.gn) compiles
      cxa_noexception.cpp on Linux — stubs that define __cxa_current_primary_exception,
      __setExceptionClass, etc. as no-op/terminate.
    • On Linux the build does not pass -nostdlib++ (build/config/compiler/BUILD.gn:644 only adds
      it if (!is_linux)), so the clang driver auto-links the toolchain's libc++.a. The riscv64
      buildtools/.../clang/lib/riscv64-unknown-linux-gnu/libc++.a bundles libcxxabi's
      cxa_exception.cpp.o (the real exception implementations).
    • wasm-opt uses exceptions → the linker resolves __cxa_throw etc. by pulling cxa_exception.o
      out of the toolchain libc++.a. That object also defines
      __cxa_current_primary_exception/__setExceptionClass/… → duplicate symbols with the
      already-linked libcxxabi.cxa_noexception.o.

After those two changes:

$ et build -c ci/linux_debug_riscv64
[2026-08-12T11:26:47.574][ci/linux_debug_riscv64: GN]: OK
[2026-08-12T11:26:56.767][ci/linux_debug_riscv64: ninja]: 100.0% (5/5) ACTION //flutter/build/archives:artifacts(//build/toolchain/linux:clang_riscv64)
[2026-08-12T11:26:56.783][ci/linux_debug_riscv64: ninja]: OK

I am not sure how to proceed here. I believe the second issue should be patched here, and I will add a commit on the PR for that patch (unless you advise me not to). It seems to me that it makes sense to disable that feature for every "from-source" builds, as it will break every from-source build otherwise, AFAIU.

For the first issue, it gets a bit more tricky. The right solution would be to send the fix to Debian so that it gets into Trixie. Current Trixie version for that package is 2.56.2-1+deb13u1, and the fix is available starting from upstream version 2.59.0. I'm not completely familiar with how patches are sent to non-devel Debian versions, but I believe that this is the cleanest way.

Another issue that we would have, though, is that Bullseye might be too old to patch (it is oldoldstable).

The only other way IMO would be a script here that applies this patch directly.

Thoughts? Does everything makes sense? Do we want to take in the PR without the Debian fix, so that then we can build by manually patching, or do we want to wait until everything is ready first? Or maybe add another trixie-specific workaround that applies the patch, while hoping that Debian takes it?

When the Dart SDK is built from source (i.e. no usable prebuilt is
available for the target, such as for riscv64 Linux cross builds),
exclude the wasm-opt target. Binaryen's wasm-opt is built with
exceptions enabled and links the toolchain libc++, whose bundled
libcxxabi exception symbols collide with the no-exceptions stubs in
the engine's libcxxabi. The prebuilt Dart SDK already ships a
wasm-opt binary for platforms that have one, so this only affects
from-source builds.
@vhaudiquet
vhaudiquet dismissed stale reviews from robert-ancell and jtmcdole via a681ad3 August 17, 2026 10:23
The atkversion.h header in at-spi2-core (Debian Bullseye 2.38 and
Trixie 2.56.2) lacks G_BEGIN_DECLS/G_END_DECLS, causing link failures
when included from C++ code. This was fixed upstream in
https://gitlab.gnome.org/GNOME/at-spi2-core/-/merge_requests/219
but the fix has not yet propagated to all Debian stable releases.

Previously, fl_view_accessible.cc and fl_accessibility_handler_test.cc
worked around this by wrapping #include <atk/atk.h> in extern "C" { }.
This breaks on Trixie sysroots where atk.h pulls in headers with C++
features that cannot be inside an extern "C" block.

This commit:
- Adds PatchAtkVersionHeader() to install-sysroot.py, which patches
  atkversion.h after sysroot extraction to add G_BEGIN_DECLS/
  G_END_DECLS (the same fix as upstream MR 219). Idempotent.
- Removes the extern "C" workaround from fl_view_accessible.cc and
  fl_accessibility_handler_test.cc, relying on the patched header
  for proper C linkage.
@vhaudiquet
vhaudiquet requested a review from a team as a code owner August 25, 2026 09:18
@github-actions github-actions Bot added 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 Aug 25, 2026
@vhaudiquet
vhaudiquet requested a review from jtmcdole August 25, 2026 09:19
@vhaudiquet

vhaudiquet commented Aug 25, 2026 •

Copy link
Copy Markdown
Contributor Author

The Debian route seems convoluted, and I have confirmed that there will be no way to fix bullseye. I have added a patch function in the sysroot setup, I believe that this is the cleaner fix, and it will also allow updating sysroots to Trixie for other arches desktop builds, so I believe this is a win-win?

With this patch, the engine build succeeds 😃
If you are willing to take all 3 commits, we will officially be able to cross-build the engine for riscv64

Nakiha pushed a commit to Nakiha/VoidPlayer-Flutter that referenced this pull request Sep 28, 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
flutter/flutter#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]>
felixonmars added a commit to felixonmars/archriscv-packages that referenced this pull request Oct 7, 2026
Pin Flutter’s bootstrap engine.version to the bundled meta-flutter RISC-V engine revision before invoking Flutter. Flutter 3.47.6 otherwise regenerates engine.stamp from 692136cb6582dbfc5af3fb33c2515a069f2f66d0 rather than the seeded 5d531788691ec3404cac0cee66ead4007b177363 Dart stamp, discards the supplied SDK and fetches an unavailable riscv64 archive; prepare() fails with "End-of-central-directory signature not found".

Keep the matching Dart 3.13.1 and local engine SDK. No applicable upstream bootstrap fix or meta-flutter release for the newer pinned revision was found.

https://archriscv.felixc.at/.status/logs/plezy/plezy-2.22.0-1.log
https://github.com/flutter/flutter/blob/3.47.6/bin/internal/update_engine_version.sh
https://github.com/flutter/flutter/blob/3.47.6/bin/internal/update_dart_sdk.sh
flutter/flutter#178712
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

a: accessibility Accessibility, e.g. VoiceOver or TalkBack. (aka a11y) a: desktop Running on desktop engine flutter/engine related. See also e: labels. platform-linux Building on or for Linux specifically team-linux Owned by the Linux platform team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants