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

Writing plugins in Rust is basically impossible due to its unstable ABI #71

Open
Sainan opened this issue Nov 12, 2023 · 2 comments
Open

Comments

@Sainan
Copy link
Contributor

Sainan commented Nov 12, 2023

I just recently had this issue where the Wooting Analog Plugin would link against the Wooting Analog SDK I compiled myself, but crash when attempting to read the buffer. I imagine a similar issue could occur when someone simply writes and publishes a Rust plugin and the Analog SDK is updated.

Possible solutions to this problem:

  1. Use the C ABI for all plugins
  2. Use some "stable ABI" crate like https://github.com/ZettaScaleLabs/stabby (Would need to ensure that all types that cross the ABI bridge are compatible, including HashMap, which is used as the result for read_analog_buffer.)
@simon-wh
Copy link
Member

(We've already discussed this a little bit on Discord, but I'm just gonna write my thoughts here for completeness)

My current feeling would be to just get rid of Rust plugins all together. Resulting in the main wooting-analog-plugin being part of the core SDK and just having the mechanism for plugins using the C ABI.

The whole unstable ABI is kinda annoying and I don't feel like it's really necessary to even have this ability when the project is open source. So if someone wants to support a device using Rust, they can just PR an update to the core.

Overall, this would simplify things a lot, as I feel like there are a number of aspects of this project that are somewhat over-engineered.

@Sainan
Copy link
Contributor Author

Sainan commented Oct 30, 2024

Historically, I did like the ability to disable/remove the wooting-analog-plugin to improve init time and avoid the issues there used to be.

I think a better approach would be simply updating it to using the C ABI. I'm not entirely sure how hard it would be to port the declare_plugin! macro to do that. But in the case of the wooting-analog-plugin, there's already a C version that's almost identical to the Rust version. :P

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