cunarist / rinf

Rust for native business logic, Flutter for flexible and beautiful GUI
MIT License
1.98k stars 70 forks source link

Rinf compiles for armv7 but this stops extism from compiling #341

Closed thejobsmarket closed 4 months ago

thejobsmarket commented 5 months ago

Report

Rinf always compiles rust packages for armv7 on Android and there is no way to exclude this from happening which makes using extism not possible because some of its dependencies do not work any more on armv7. Excluding armv7 in gradle is ignored.

Steps to Reproduce

Include extism 1.3.0 and do flutter run

System Information

rustup target armv7

temeddix commented 4 months ago

Hi @thejobsmarket :)

If I remember correctly, dependency crates are loaded and compiled only when you explicitly use them or call them. Therefore, I would suggest you to do something like this instead:

#[cfg(target_arch = "armv7")]
mod something_with_extism {
    use extism;
    pub some_function () {
        // Do something with extism...
    }
}

#[cfg(not(target_arch = "armv7"))]
mod something_with_extism {
    pub some_function () {
        // Empty placeholder function
    }
}

Below are the list of Rust targets and guides about conditional compilation, just in case:

Unfortunately, the builder/linker being used by Rinf called Cargokit doesn't have an option to exclude specific architectures. FYI, they do have some configuration options as explained here. If you need support from Cargokit developers, I'll try to assist you here. Please let me know if there are unsolved problems.

thejobsmarket commented 4 months ago

Just putting #[cfg(not(target_arch = "armv7"))] above my functions resolved the issue. Many thanks for the great help.