fzyzcjy / flutter_rust_bridge

Flutter/Dart <-> Rust binding generator, feature-rich, but seamless and simple.
https://fzyzcjy.github.io/flutter_rust_bridge/
MIT License
4.26k stars 300 forks source link

`flutter_rust_bridge_codegen build-web` errors, WASM can't compile #2161

Closed CJBuchel closed 3 months ago

CJBuchel commented 4 months ago

Describe the bug

I'm using the default project created from doing the flutter_rust_bridge_codegen create my_app, and I'm trying to get the web working in my environment.

And following the docs I've installed the necessary toolchains, nightly build switch and the wasm-pack. But when I run the command for build-web I just get a heap of errors all relating to linking issues, making me think I don't have the correct libraries. But I'm pretty sure I've installed everything it's complaining about. (attached is the last one error, but they're all related to the same type of issue)

error: could not compile `compiler_builtins` (build script) due to 1 previous error
error: could not compile `libc` (build script) due to 1 previous error
error: linking with `cc` failed: exit status: 1
  |
  = note: LC_ALL="C" PATH="/home/cj/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/bin:/home/cj/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/bin/self-contained:/home/cj/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/bin:/home/cj/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/bin/self-contained:/home/cj/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/bin:/home/cj/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/bin/self-contained:/snap/flutter/current/usr/bin:/snap/flutter/current/bin:/home/cj/snap/flutter/common/flutter/bin:/snap/flutter/current/usr/bin:/snap/flutter/current/bin:/home/cj/snap/flutter/common/flutter/bin:/home/cj/.local/share/pnpm:/home/cj/.nvm/versions/node/v21.7.1/bin:/home/cj/.cargo/bin:/home/cj/.local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin:/snap/bin" VSLANG="1033" "cc" "-m64" "/tmp/rustcSo5LQd/symbols.o" "/home/cj/Documents/code/flutter_ffi/my_app/rust/target/debug/build/typenum-c2361923ad7a04d1/build_script_main-c2361923ad7a04d1.build_script_main.b91e46799a76ac98-cgu.0.rcgu.o" "/home/cj/Documents/code/flutter_ffi/my_app/rust/target/debug/build/typenum-c2361923ad7a04d1/build_script_main-c2361923ad7a04d1.build_script_main.b91e46799a76ac98-cgu.1.rcgu.o" "/home/cj/Documents/code/flutter_ffi/my_app/rust/target/debug/build/typenum-c2361923ad7a04d1/build_script_main-c2361923ad7a04d1.build_script_main.b91e46799a76ac98-cgu.2.rcgu.o" "/home/cj/Documents/code/flutter_ffi/my_app/rust/target/debug/build/typenum-c2361923ad7a04d1/build_script_main-c2361923ad7a04d1.build_script_main.b91e46799a76ac98-cgu.3.rcgu.o" "/home/cj/Documents/code/flutter_ffi/my_app/rust/target/debug/build/typenum-c2361923ad7a04d1/build_script_main-c2361923ad7a04d1.deg4vkk5k38sm14w3o0aylqxy.rcgu.o" "-Wl,--as-needed" "-L" "/home/cj/Documents/code/flutter_ffi/my_app/rust/target/debug/deps" "-L" "/home/cj/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib" "-Wl,-Bstatic" "/home/cj/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libstd-c6c045f3358c0b22.rlib" "/home/cj/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libpanic_unwind-5c2158c1682442e0.rlib" "/home/cj/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libobject-404d0b40d67de09f.rlib" "/home/cj/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libmemchr-e07eeabf48db885c.rlib" "/home/cj/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libaddr2line-c92423f648579064.rlib" "/home/cj/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libgimli-8dab5299a97564ae.rlib" "/home/cj/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/librustc_demangle-65891f932666bb65.rlib" "/home/cj/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libstd_detect-b2634d236d77b88a.rlib" "/home/cj/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libhashbrown-38ef4997455a5e72.rlib" "/home/cj/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/librustc_std_workspace_alloc-b2e6b39d803e65fe.rlib" "/home/cj/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libminiz_oxide-0864893dee726241.rlib" "/home/cj/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libadler-e599f337a82d59c4.rlib" "/home/cj/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libunwind-acbe32895031f6bc.rlib" "/home/cj/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libcfg_if-e21e611894cf2844.rlib" "/home/cj/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/liblibc-7b90a2705bcf265b.rlib" "/home/cj/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/liballoc-1f7e19b44251c73e.rlib" "/home/cj/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/librustc_std_workspace_core-f72b956e24d1de70.rlib" "/home/cj/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libcore-632ae0f28c5e55ff.rlib" "/home/cj/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libcompiler_builtins-4d7d16bbf0636a40.rlib" "-Wl,-Bdynamic" "-lgcc_s" "-lutil" "-lrt" "-lpthread" "-lm" "-ldl" "-lc" "-B/home/cj/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/bin/gcc-ld" "-B/home/cj/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/bin/gcc-ld" "-B/home/cj/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/bin/gcc-ld" "-fuse-ld=lld" "-Wl,--eh-frame-hdr" "-Wl,-z,noexecstack" "-L" "/home/cj/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib" "-L" "/home/cj/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/self-contained" "-o" "/home/cj/Documents/code/flutter_ffi/my_app/rust/target/debug/build/typenum-c2361923ad7a04d1/build_script_main-c2361923ad7a04d1" "-Wl,--gc-sections" "-pie" "-Wl,-z,relro,-z,now" "-nodefaultlibs"
  = note: rust-lld: error: undefined reference due to --no-allow-shlib-undefined: _dl_find_object@GLIBC_2.35
          >>> referenced by /usr/lib/gcc/x86_64-linux-gnu/11/../../../x86_64-linux-gnu/libgcc_s.so.1
          collect2: error: ld returned 1 exit status

error: could not compile `typenum` (build script) due to 1 previous error
Error: Compiling your crate to WebAssembly failed
Caused by: Compiling your crate to WebAssembly failed
Caused by: failed to execute `cargo build`: exited with exit status: 101
  full command: cd "rust" && "cargo" "build" "--lib" "--target" "wasm32-unknown-unknown" "-Z" "build-std=std,panic_abort"
Unhandled exception:
ProcessException: Bad exit code (1). If you want to see extra information, set FRB_DART_RUN_COMMAND_STDERR=1
  Command: wasm-pack build -t no-modules -d /home/cj/Documents/code/flutter_ffi/my_app/web/pkg --no-typescript --out-name rust_lib_my_app --dev rust -- -Z build-std=std,panic_abort
#0      runCommand (package:flutter_rust_bridge/src/cli/run_command.dart:67:5)
<asynchronous suspension>
#1      _executeWasmPack (package:flutter_rust_bridge/src/cli/build_web/executor.dart:151:3)
<asynchronous suspension>
#2      executeBuildWeb (package:flutter_rust_bridge/src/cli/build_web/executor.dart:67:3)
<asynchronous suspension>
#3      BuildWebCommand.run (package:flutter_rust_bridge/src/cli/build_web/entrypoint.dart:18:5)
<asynchronous suspension>
#4      CommandRunner.runCommand (package:args/command_runner.dart:212:13)
<asynchronous suspension>
#5      main (file:///home/cj/.pub-cache/hosted/pub.dev/flutter_rust_bridge-2.0.0/bin/flutter_rust_bridge.dart:8:3)
<asynchronous suspension>
Error: Fail to execute command, please see logs above for details.

Steps to reproduce

Hint: A simple way to reproduce is to clone and modify the https://github.com/fzyzcjy/flutter_rust_bridge/tree/master/frb_example/dart_minimal example package according to your needs.

  1. create project using flutter_rust_bridge_codegen create my_app
  2. run flutter_rust_bridge_codegen build-web in my_app

Logs

error: could not compile `compiler_builtins` (build script) due to 1 previous error
error: could not compile `libc` (build script) due to 1 previous error
error: linking with `cc` failed: exit status: 1
  |
  = note: LC_ALL="C" PATH="/home/cj/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/bin:/home/cj/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/bin/self-contained:/home/cj/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/bin:/home/cj/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/bin/self-contained:/home/cj/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/bin:/home/cj/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/bin/self-contained:/snap/flutter/current/usr/bin:/snap/flutter/current/bin:/home/cj/snap/flutter/common/flutter/bin:/snap/flutter/current/usr/bin:/snap/flutter/current/bin:/home/cj/snap/flutter/common/flutter/bin:/home/cj/.local/share/pnpm:/home/cj/.nvm/versions/node/v21.7.1/bin:/home/cj/.cargo/bin:/home/cj/.local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin:/snap/bin" VSLANG="1033" "cc" "-m64" "/tmp/rustcSo5LQd/symbols.o" "/home/cj/Documents/code/flutter_ffi/my_app/rust/target/debug/build/typenum-c2361923ad7a04d1/build_script_main-c2361923ad7a04d1.build_script_main.b91e46799a76ac98-cgu.0.rcgu.o" "/home/cj/Documents/code/flutter_ffi/my_app/rust/target/debug/build/typenum-c2361923ad7a04d1/build_script_main-c2361923ad7a04d1.build_script_main.b91e46799a76ac98-cgu.1.rcgu.o" "/home/cj/Documents/code/flutter_ffi/my_app/rust/target/debug/build/typenum-c2361923ad7a04d1/build_script_main-c2361923ad7a04d1.build_script_main.b91e46799a76ac98-cgu.2.rcgu.o" "/home/cj/Documents/code/flutter_ffi/my_app/rust/target/debug/build/typenum-c2361923ad7a04d1/build_script_main-c2361923ad7a04d1.build_script_main.b91e46799a76ac98-cgu.3.rcgu.o" "/home/cj/Documents/code/flutter_ffi/my_app/rust/target/debug/build/typenum-c2361923ad7a04d1/build_script_main-c2361923ad7a04d1.deg4vkk5k38sm14w3o0aylqxy.rcgu.o" "-Wl,--as-needed" "-L" "/home/cj/Documents/code/flutter_ffi/my_app/rust/target/debug/deps" "-L" "/home/cj/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib" "-Wl,-Bstatic" "/home/cj/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libstd-c6c045f3358c0b22.rlib" "/home/cj/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libpanic_unwind-5c2158c1682442e0.rlib" "/home/cj/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libobject-404d0b40d67de09f.rlib" "/home/cj/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libmemchr-e07eeabf48db885c.rlib" "/home/cj/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libaddr2line-c92423f648579064.rlib" "/home/cj/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libgimli-8dab5299a97564ae.rlib" "/home/cj/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/librustc_demangle-65891f932666bb65.rlib" "/home/cj/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libstd_detect-b2634d236d77b88a.rlib" "/home/cj/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libhashbrown-38ef4997455a5e72.rlib" "/home/cj/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/librustc_std_workspace_alloc-b2e6b39d803e65fe.rlib" "/home/cj/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libminiz_oxide-0864893dee726241.rlib" "/home/cj/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libadler-e599f337a82d59c4.rlib" "/home/cj/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libunwind-acbe32895031f6bc.rlib" "/home/cj/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libcfg_if-e21e611894cf2844.rlib" "/home/cj/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/liblibc-7b90a2705bcf265b.rlib" "/home/cj/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/liballoc-1f7e19b44251c73e.rlib" "/home/cj/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/librustc_std_workspace_core-f72b956e24d1de70.rlib" "/home/cj/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libcore-632ae0f28c5e55ff.rlib" "/home/cj/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libcompiler_builtins-4d7d16bbf0636a40.rlib" "-Wl,-Bdynamic" "-lgcc_s" "-lutil" "-lrt" "-lpthread" "-lm" "-ldl" "-lc" "-B/home/cj/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/bin/gcc-ld" "-B/home/cj/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/bin/gcc-ld" "-B/home/cj/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/bin/gcc-ld" "-fuse-ld=lld" "-Wl,--eh-frame-hdr" "-Wl,-z,noexecstack" "-L" "/home/cj/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib" "-L" "/home/cj/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/self-contained" "-o" "/home/cj/Documents/code/flutter_ffi/my_app/rust/target/debug/build/typenum-c2361923ad7a04d1/build_script_main-c2361923ad7a04d1" "-Wl,--gc-sections" "-pie" "-Wl,-z,relro,-z,now" "-nodefaultlibs"
  = note: rust-lld: error: undefined reference due to --no-allow-shlib-undefined: _dl_find_object@GLIBC_2.35
          >>> referenced by /usr/lib/gcc/x86_64-linux-gnu/11/../../../x86_64-linux-gnu/libgcc_s.so.1
          collect2: error: ld returned 1 exit status

error: could not compile `typenum` (build script) due to 1 previous error
Error: Compiling your crate to WebAssembly failed
Caused by: Compiling your crate to WebAssembly failed
Caused by: failed to execute `cargo build`: exited with exit status: 101
  full command: cd "rust" && "cargo" "build" "--lib" "--target" "wasm32-unknown-unknown" "-Z" "build-std=std,panic_abort"
Unhandled exception:
ProcessException: Bad exit code (1). If you want to see extra information, set FRB_DART_RUN_COMMAND_STDERR=1
  Command: wasm-pack build -t no-modules -d /home/cj/Documents/code/flutter_ffi/my_app/web/pkg --no-typescript --out-name rust_lib_my_app --dev rust -- -Z build-std=std,panic_abort
#0      runCommand (package:flutter_rust_bridge/src/cli/run_command.dart:67:5)
<asynchronous suspension>
#1      _executeWasmPack (package:flutter_rust_bridge/src/cli/build_web/executor.dart:151:3)
<asynchronous suspension>
#2      executeBuildWeb (package:flutter_rust_bridge/src/cli/build_web/executor.dart:67:3)
<asynchronous suspension>
#3      BuildWebCommand.run (package:flutter_rust_bridge/src/cli/build_web/entrypoint.dart:18:5)
<asynchronous suspension>
#4      CommandRunner.runCommand (package:args/command_runner.dart:212:13)
<asynchronous suspension>
#5      main (file:///home/cj/.pub-cache/hosted/pub.dev/flutter_rust_bridge-2.0.0/bin/flutter_rust_bridge.dart:8:3)
<asynchronous suspension>
Error: Fail to execute command, please see logs above for details.

Expected behavior

Generates the output wasm files for flutter

Generated binding code

No response

OS

Pop OS 22 (linux)

Version of flutter_rust_bridge_codegen

No response

Flutter info

[✓] Flutter (Channel stable, 3.22.2, on Pop!_OS 22.04 LTS 6.9.3-76060903-generic, locale en_AU.UTF-8)
    • Flutter version 3.22.2 on channel stable at /home/cj/snap/flutter/common/flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision 761747bfc5 (3 weeks ago), 2024-06-05 22:15:13 +0200
    • Engine revision edd8546116
    • Dart version 3.4.3
    • DevTools version 2.34.3

[✓] Android toolchain - develop for Android devices (Android SDK version 34.0.0)
    • Android SDK at /home/cj/Android/Sdk
    • Platform android-34, build-tools 34.0.0
    • Java binary at: /home/cj/Downloads/android-studio/jbr/bin/java
    • Java version OpenJDK Runtime Environment (build 17.0.9+0-17.0.9b1087.7-11185874)
    • All Android licenses accepted.

[✓] Chrome - develop for the web
    • Chrome at google-chrome

[✓] Linux toolchain - develop for Linux desktop
    • clang version 10.0.0-4ubuntu1
    • cmake version 3.16.3
    • ninja version 1.10.0
    • pkg-config version 0.29.1

[✓] Android Studio (version 2023.2)
    • Android Studio at /home/cj/Downloads/android-studio
    • Flutter plugin version 78.4.1
    • Dart plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/6351-dart
    • Java version OpenJDK Runtime Environment (build 17.0.9+0-17.0.9b1087.7-11185874)

[✓] VS Code (version 1.90.2)
    • VS Code at /usr/share/code
    • Flutter extension version 3.90.0

[✓] Connected device (2 available)
    • Linux (desktop) • linux  • linux-x64      • Pop!_OS 22.04 LTS 6.9.3-76060903-generic
    • Chrome (web)    • chrome • web-javascript • Google Chrome 126.0.6478.126

[✓] Network resources
    • All expected network resources are available.

• No issues found!

Version of clang++

No response

Additional context

No response

welcome[bot] commented 4 months ago

Hi! Thanks for opening your first issue here! :smile:

fzyzcjy commented 4 months ago

Firstly, what is your rust version? IIRC someone mentioned -> https://github.com/fzyzcjy/flutter_rust_bridge/issues/2157 too old rust may have problems

Secondly, it runs well on CI windows/macos/linux, thus maybe we can debug by checking what's different from CI.

CJBuchel commented 4 months ago

Currently it's this

cargo 1.81.0-nightly (bc89bffa5 2024-06-22) rustup 1.27.1 (54dd3d00f 2024-04-24) rustc 1.81.0-nightly (fda509e81 2024-06-25)

I thought it might be a rust/flutter version issue, so I did an upgrade before hand. I think those are the latest versions

fzyzcjy commented 4 months ago

Hmm could you please google a bit about the error messages etc (e.g. a quick search gives https://github.com/fathyb/carbonyl/issues/133 but maybe different) - This looks like a general "why my Rust code does not compile" problem, since there is no frb or dart in this step, and it is only executing a pure cargo command:

"cargo" "build" "--lib" "--target" "wasm32-unknown-unknown" "-Z" "build-std=std,panic_abort"

Also try to execute that command directly on a terminal and see what happens

CJBuchel commented 4 months ago

hmmmm. so running the raw command works in the rust crate in the my_app project. Now if I run the flutter_rust_bridge_codegen build-web in the root project it works.

Just to check I deleted the target directory in the rust crate and now when I run the flutter_rust_bridge_codegen build-web I get the same set of weird errors again. So I guess I just have to compile the rust crate for wasm first before doing the codegen?

fzyzcjy commented 4 months ago

That's weird, I would guess it may be something related to env variable.

What about this: cargo build is auto run by the following command. When run it directly (after deleting target dir) does it work?

wasm-pack build -t no-modules -d /home/cj/Documents/code/flutter_ffi/my_app/web/pkg --no-typescript --out-name rust_lib_my_app --dev rust -- -Z build-std=std,panic_abort
CJBuchel commented 4 months ago

Did a bit more testing.

CJBuchel commented 4 months ago
cj@pop-os:~/Documents/code/flutter_ffi/my_app$ flutter_rust_bridge_codegen build-web
> which wasm-pack (pwd: null, env: null)
/home/cj/.cargo/bin/wasm-pack
> cargo read-manifest (pwd: rust, env: null)
> wasm-pack build -t no-modules -d /home/cj/Documents/code/flutter_ffi/my_app/web/pkg --no-typescript --out-name rust_lib_my_app --dev rust -- -Z build-std=std,panic_abort (pwd: null, env: {RUSTUP_TOOLCHAIN: nightly, RUSTFLAGS: -C target-feature=+atomics,+bulk-memory,+mutable-globals, CARGO_TERM_COLOR: always})
[INFO]: 🎯  Checking for the Wasm target...
[INFO]: 🌀  Compiling to Wasm...

I can also see the same command it's using when it launches the codegen. And it works fine by itself. So yea... I can only think my env variables are messed up for some reason. And it's not building the project properly when launched through the codegen.

fzyzcjy commented 4 months ago

I think so, probably because of some unknown env var issues... I do not have a reproducible environment, so cannot debug for this. If you like to test more, maybe clone frb repo and modify the ./frb_dart code related to building web to print out things etc to debug.

CJBuchel commented 4 months ago

Yea, well it's good to know that it's an isolated issue at least. Easy enough to get around anyway in the short term. I'll close up the issue, and if I ever do find a long-term solution I'll chuck here in the future for anyone else who might stumble on it.

github-actions[bot] commented 4 months ago

This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new issue.

fzyzcjy commented 3 months ago

Reopen because of https://github.com/fzyzcjy/flutter_rust_bridge/discussions/2236

fzyzcjy commented 3 months ago

Close since https://github.com/fzyzcjy/flutter_rust_bridge/discussions/2236#discussioncomment-10299362

github-actions[bot] commented 2 months ago

This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new issue.