Skip to content
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

Errors with 32bit target #69

Open
gnunicorn opened this issue Jan 19, 2022 · 4 comments
Open

Errors with 32bit target #69

gnunicorn opened this issue Jan 19, 2022 · 4 comments

Comments

@gnunicorn
Copy link

gnunicorn commented Jan 19, 2022

Running with an x86 32bit emulator I couldn't get this to work. even something as simple as echoing the same string back, like below, failed.

fn echo(inp: string) -> Result<string>;
pub fn echo(inp: String) -> Result<String> {
    Ok(String::from(inp))
}

It fails when trying to read back the result string:

E/flutter ( 4879): [ERROR:flutter/lib/ui/ui_dart_state.cc(209)] Unhandled Exception: Invalid argument(s): length must be in the range [0, 1073741823].
E/flutter ( 4879): #0      _checkExternalTypedDataLength (dart:ffi-patch/ffi_patch.dart:58:5)
E/flutter ( 4879): #1      Uint8Pointer.asTypedList (dart:ffi-patch/ffi_patch.dart:624:5)
E/flutter ( 4879): #2      Api.echo
package:sdk/sdk.dart:393
E/flutter ( 4879): #3      main
package:app/main.dart:9

And putting a print("${tmp10};${tmp11};${tmp12}"); into the generated dart-code also shows why: I/flutter ( 4879):-5868786620503136931;-5095886506439946255;-2008385391117589139 are really not valid pointer and size values. I think there's some type-mixup happening as the dart-code is looking at it with a 64bit data-lense while the code that is generated for 32bit rust uses i32 and u32 ...

@dvc94ch
Copy link
Contributor

dvc94ch commented Jan 19, 2022

dart doesn't support cross compiling afaik, can you elaborate on how you built it? seems like you have 64bit dart code loading a 32bit library? note that you'll have to regenerate the bindings for a 32bit library.

@dvc94ch
Copy link
Contributor

dvc94ch commented Jan 19, 2022

here we select the type based on the target_pointer_width which is detected in the macro and it works with wasm32, so not sure what the issue might be.

@dvc94ch
Copy link
Contributor

dvc94ch commented Jan 21, 2022

saddly our infrastructure is quite complicated and not trivial to get it to work. if you're trying to evaluate the tlfs platform, I'd suggest sticking to supported targets and build configurations. if you want to use ffi-gen in your own project, a small test case would help. if you have some other needs consulting is available.

@gnunicorn
Copy link
Author

No worries, 64bit it is for not (I am not sure I'll need the 32bit architecture yet). If I do come across the issue again, I'll raise more info and/or a PR about it. Just wanted to have this already noted for reference.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants