-
Notifications
You must be signed in to change notification settings - Fork 300
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
Using frb with main executable #2292
Comments
frb can be configured to generate C code (indeed a |
I just tried generating that header file using the |
For those, please refer to https://github.com/fzyzcjy/flutter_rust_bridge/tree/master/frb_dart/lib/src/ffigen_generated/intermediate. They are not generated during frb codegen phase, but pre-generated. |
Well, that's why I'm asking for a command to dump that list. It would remove the need to generate and parse C code, download the pre-generated header files from the github repo, etc. |
Another thought: Do all symbols prefix with |
The ones in the generated header file mostly start with |
|
Would it be possible to funnel all symbol lookups through a custom Rust function instead of dart:ffi's That would make the list of symbols that have to be exported static (at least per version), which would greatly simplify things. |
Are you using As for whether it can be static: A large part may not be hard; but e.g. the native finalizers of the rust opaque objects may needs some work. |
I’ve turned that off. A simple grep on symbols is easy on Linux, but my code also has to run on Windows, and there’s it’s much more complicated. |
Do you mean there is no |
Ok, so I tried generating the C header as the first step, but this doesn't work in the first place, making that approach not useful. I think I should create new tickets for the stuff I ran into there. |
Besides #2368, the other issue I have is just a cyclical type (ticket here), which shouldn't matter for this. |
Is your feature request related to a problem? Please describe.
I want to use flutter_rust_bridge with a project that uses the Flutter embedder API. The Rust code to be called by Dart is located in the executable directly, rather than a dynamic library.
Describe the solution you'd like
I'm using
ExternalLibrary.process(iKnowHowToUseIt: true)
right now. Ideally, this is all that's needed, but unfortunately it's not. The problem is that while building the executable, the linker strips out all of the symbols that are looked up dynamically by frb viaDynamicLibrary.lookup
, likefrb_get_rust_content_hash
.Describe alternatives you've considered
I've been able to make this work on Linux by adding the file
.cargo/config.toml
with the following content:This stops the linker from stripping any unused symbols.
However, it also stops it from stripping everything else in the binary, making it unnecessarily large (and more vulnerable to reverse engineering, which might be a problem). In addition, this approach doesn't work on Windows, because there the linker expects an explicit symbol name to include. ld also supports supplying an explicit list of symbols to include, which would fix this problem.
Now the problem is that the list of symbols seems to be an implementation detail. It seems to be generated based on some C header files in frb_dart_source_code.rs.
Summary
I think this basically boils down to the following request: Please add a command or flag (on
generate
) toflutter_rust_bridge_codegen
to export a list of symbols that are required to be used in the final binary (text file, one symbol per line). This list could then be picked up by my build system to be passed to the linker.The text was updated successfully, but these errors were encountered: