You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The inventory crate is super cool and it has become a critical part of some of the projects I am involved in. Thanks!
However, there are a number of issues due to inventory relying on a dynamic loader to invoke functions in the .ctor segment. Since inventory's interface is primarily for storing data that is later to be iterated over, it seems like it should be possible to implement inventory using custom data segments instead. Data segments are more portable and should be able to even work on platforms like WASM since it supports fetching custom sections. I guess the main difference when implementing inventory using data segments is that it can only support const expressions.
I have not tried to make it work in WASM yet, but I did make a proof-of-concept for Windows/OSX/Linux that seems to work. Check it out! It uses platform specifics to get pointers to the start and end of a custom data segment where the submitted data is stored. The linker concatenates all data in a custom data segment during the linking phase so that data from all modules can be iterated over. The idea is to have a custom data segment for each type by mangling the type name - the proof of concept only uses a constant name. Presumably this is something that can be done by a proc macro.
Does this seem like something that is worth doing or are there known issues with this approach that I should be aware of?
The text was updated successfully, but these errors were encountered:
Hi @kabergstrom, I have an implementation of your approach already in https://github.com/dtolnay/linkme. If I could interest you in contributing Windows support over there, it may be a better fit for your use case than inventory.
The
inventory
crate is super cool and it has become a critical part of some of the projects I am involved in. Thanks!However, there are a number of issues due to
inventory
relying on a dynamic loader to invoke functions in the.ctor
segment. Sinceinventory
's interface is primarily for storing data that is later to be iterated over, it seems like it should be possible to implementinventory
using custom data segments instead. Data segments are more portable and should be able to even work on platforms like WASM since it supports fetching custom sections. I guess the main difference when implementinginventory
using data segments is that it can only support const expressions.I have not tried to make it work in WASM yet, but I did make a proof-of-concept for Windows/OSX/Linux that seems to work. Check it out! It uses platform specifics to get pointers to the start and end of a custom data segment where the submitted data is stored. The linker concatenates all data in a custom data segment during the linking phase so that data from all modules can be iterated over. The idea is to have a custom data segment for each type by mangling the type name - the proof of concept only uses a constant name. Presumably this is something that can be done by a proc macro.
Does this seem like something that is worth doing or are there known issues with this approach that I should be aware of?
The text was updated successfully, but these errors were encountered: