wasmtime
wasmtime copied to clipboard
Android support
This PR adds CMake compilation support (c-api) for Android. From my tests it does function correctly, no unexpected crashes, so no code modifications were made. It uses the ANDROID
CMake variable to transparently detect when Android compilation is being done and sets flags and some other environment variables accordingly. The environment variables are necessary for some crates (as far as I could tell). BUILD_SHARED_LIBS
might have to be off.
Some relevant issues are #3867, #3877, #3921.
I should note BUILD_BYPRODUCTS ${WASMTIME_BUILD_PRODUCT}
was required to add support for ninja, ninja ignores ExternalProject_Add
if no external product is specified. A little additional code was required to set that variable.
Subscribe to Label Action
cc @peterhuene
Thus the following users have been cc'd because of the following labels:
- peterhuene: wasmtime:c-api
To subscribe or unsubscribe from this label, edit the .github/subscribe-to-label.json
configuration file.
I only sort of barely understand cmake, but is this sort of configuration standard? I would expect all this toolchain configuration to be configured by whomever is building wasmtime-c-api
rather than hardcoded into cmake files. I feel like this sort of configuration is also necessary for cross-compiled builds and I don't think we'd want to hardcode everything for that per se?
This is all sort of on the side and fine to add but I'm not sure if you have a particular end goal for the cmake support in mind or how many other platforms might be added.
I suppose the reason it's so excessive here is that rust doesn't fit nicely into the CMake ecosystem so I have to manually pass it the compiler, archiver and locations of some required shared libs, especially because as noted in the comments rust incorrectly handles some shared libraries for later versions of the NDK. This process would be a lot cleaner if the calling CMake project could modify the compiler and libraries used by wasmtime but with ExternalProject you can't do that.
Could this perhaps be generalized to avoid duplication? Could --target
always be passed perhaps? Or could RUSTFLAGS
-the-env var be set to avoid duplicating the build command?
My PC won't have internet access for a couple of days but I'll see about that change. I do think this effortlessly pulls wasmtime into Android projects that don't understand rust but if it's messy I understand
Made a slight change to deduplicate ExternalProject_Add
and make the CMakeLists.txt
cleaner.
Cool, thank you!