-
Notifications
You must be signed in to change notification settings - Fork 303
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
The generated XXXWire.store_dart_post_cobject()
has the wrong signature - caused by ffigen
third-party library's fatal error 'stdarg.h' file not found
#108
Comments
Hi! Thanks for opening your first issue here! 😄 |
We're looking at using this crate for work so I'd be happy to contribute a fix. @fzyzcjy, do you have any suggestions for where I might want to start looking? I noticed the example uses a |
Thanks for the reply, and thanks for your interest! Let me have a look. |
Aha look at this line:
It says:
That seems to be the cause! |
Seems the same issue as: #53 |
Please refer to dart-lang/native#515 to see some discussions. In short: That is not a bug in this lib, but instead problem in the
|
XXXWire.store_dart_post_cobject()
has the wrong signatureXXXWire.store_dart_post_cobject()
has the wrong signature - caused by ffigen
third-party library's fatal error 'stdarg.h' file not found
By the way, EDIT: Well, I see: https://en.wikipedia.org/wiki/Stdarg.h
But we never generate that kind of code. Ok, so we can just throw away this header include. Wait a minute. |
A fix is created. After the CI passes, could you please have a try on it? |
I just installed d5f3d88 and now it complains about a missing
Maybe something funny is going on with library search paths and cross compiling, because |
could you please try what i suggested in dart-lang/native#515 , and see whether it works |
Looks like this works when we run $ export REPO_DIR=$PWD
$ cd /
$ flutter_rust_bridge_codegen \
--rust-input $REPO_DIR/rust/src/api.rs \
--dart-output $REPO_DIR/lib/bridge_generated.dart \
--c-output $REPO_DIR/ios/Classes/bridge_generated.h
[2021-10-22T14:39:33Z INFO flutter_rust_bridge_codegen] Picked config: Opts { rust_input_path: "/home/consulting/Documents/native_add/rust/src/api.rs", dart_output_path: "/home/consulting/Documents/native_add/lib/bridge_generated.dart", c_output_path: "/home/consulting/Documents/native_add/ios/Classes/bridge_generated.h", rust_crate_dir: "/home/consulting/Documents/native_add/rust", rust_output_path: "/home/consulting/Documents/native_add/rust/src/bridge_generated.rs", class_name: "NativeAdd", dart_format_line_length: 80, skip_add_mod_to_lib: false }
[2021-10-22T14:39:33Z INFO flutter_rust_bridge_codegen] Phase: Parse source code to AST
[2021-10-22T14:39:33Z INFO flutter_rust_bridge_codegen] Phase: Parse AST to IR
[2021-10-22T14:39:33Z INFO flutter_rust_bridge_codegen] Phase: Transform IR
[2021-10-22T14:39:33Z INFO flutter_rust_bridge_codegen] Phase: Generate Rust code
[2021-10-22T14:39:33Z INFO flutter_rust_bridge_codegen] Phase: Generate Dart code
[2021-10-22T14:39:33Z INFO flutter_rust_bridge_codegen] Phase: Other things
[2021-10-22T14:39:34Z INFO flutter_rust_bridge_codegen] Success! Now go and use it :)
$ cd $REPO_DIR |
Congratulations! |
Well, let me leave this open. I am not sure why this only succeeds if run from |
Something funny might be happening with environment variables, the current directory, or the Rust's |
I just installed e19d4a0 and got the same warning: $ cd ~/Documents/native_add
$ export REPO_DIR=$PWD
$ flutter_rust_bridge_codegen --rust-input $REPO_DIR/rust/src/api.rs --dart-output $REPO_DIR/lib/bridge_generated.dart --c-output $REPO_DIR/ios/Classes/bridge_generated.h
[2021-10-25T05:52:26Z INFO flutter_rust_bridge_codegen] Picked config: Opts { rust_input_path: "/home/consulting/Documents/native_add/rust/src/api.rs", dart_output_path: "/home/consulting/Documents/native_add/lib/bridge_generated.dart", c_output_path: "/home/consulting/Documents/native_add/ios/Classes/bridge_generated.h", rust_crate_dir: "/home/consulting/Documents/native_add/rust", rust_output_path: "/home/consulting/Documents/native_add/rust/src/bridge_generated.rs", class_name: "NativeAdd", dart_format_line_length: 80, skip_add_mod_to_lib: false, llvm_path: "" }
[2021-10-25T05:52:26Z INFO flutter_rust_bridge_codegen] Phase: Parse source code to AST
[2021-10-25T05:52:26Z INFO flutter_rust_bridge_codegen] Phase: Parse AST to IR
[2021-10-25T05:52:26Z INFO flutter_rust_bridge_codegen] Phase: Transform IR
[2021-10-25T05:52:26Z INFO flutter_rust_bridge_codegen] Phase: Generate Rust code
[2021-10-25T05:52:26Z INFO flutter_rust_bridge_codegen] Phase: Generate Dart code
[2021-10-25T05:52:26Z INFO flutter_rust_bridge_codegen] Phase: Other things
[2021-10-25T05:52:28Z WARN flutter_rust_bridge_codegen::commands] See keywords such as `error` in command output. Maybe there is a problem? command="sh" "-c" "dart pub global run ffigen --config /tmp/.tmpdgk6jo" output=Output { status: ExitStatus(unix_wait_status(0)), stdout: "Running in Directory: '/home/consulting/Documents/native_add'\nInput Headers: [/tmp/.tmpZoa4X6.h]\n[SEVERE] : Header /tmp/.tmpZoa4X6.h: Total errors/warnings: 1.\n[SEVERE] : /tmp/.tmpZoa4X6.h:1:10: fatal error: 'stdbool.h' file not found [Lexical or Preprocessor Issue]\nFinished, Bindings generated in /tmp/.tmpGcFynX\n", stderr: "" }
[2021-10-25T05:52:28Z INFO flutter_rust_bridge_codegen] Success! Now go and use it :) |
Ok... So is the generated code good or bad? Btw to examine the details, |
Sorry, I saw the logs from I've re-run Debug Logs
|
Sounds great! So shall I close this issue now? |
In addition, do you still need to run on |
I still need to run in Running from |
I am OK for both of your suggestions (personally perferring creating a new issue). By the way, have you created an issue in |
I was able to reproduce it fairly reliably on my computer and created a ticket upstream - dart-lang/native#338. This seems to be an issue with how they locate system headers and running from |
Hello everyone! and Hi @Michael-F-Bryan it is been a while! 😄 But yea, I found this issue a while ago while working on subsocial flutter SDK and the fix that I did is a bit of simple from the Here is the code from the let crate_dir = env::var("CARGO_MANIFEST_DIR").unwrap();
let config = cbindgen::Config {
language: cbindgen::Language::C,
documentation_style: cbindgen::DocumentationStyle::C99,
line_length: 100,
style: cbindgen::Style::Tag,
no_includes: true,
sys_includes: vec![String::from("stdint.h")],
..Default::default()
};
cbindgen::Builder::new()
.with_crate(crate_dir)
.with_config(config)
.generate()
.expect("Unable to generate bindings")
.write_to_file("binding.h"); and the Hope that helps. |
I've had the same bug when using ffigen directly. My solution is to add the include path of clang includes e.g.
|
Is it be possible to add compiler-opts as an argument to flutter_rust_bridge_codegen? |
@trobanga Sure. People have added other flags previously dart-archive/ffigen#119 . Feel free to make a PR! Hints:
|
I've just been playing with this on Arch (after playing around with it on my Mac laptop), and I hit this issue. Confirming that running from / also works for me. |
@saward Thanks |
Since we have documented it, I will close it. Feel free to reopen or create a new issue if you like! |
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. |
Describe the bug
The generated
store_dart_post_cobject()
method has a method signature that differs from the abstract method onFlutterRustBridgeWireBase
from version1.2.0
of theflutter_rust_bridge
Dart package.To Reproduce
You should be able to reproduce this using my
Michael-F-Bryan/native_add
repository.Now, trying to run the test (making sure
add(2, 2) == "2 + 2 = 4"
) will fail with the following:Expected behavior
The generated method should actually accept a
ffi.Pointer<...>
type and passptr.address
to_store_dart_post_cobject()
.Codegen logs
Generated binding code
The Dart code:
The C header:
The text was updated successfully, but these errors were encountered: