-
Notifications
You must be signed in to change notification settings - Fork 4.6k
Fix native program loading when solana-runtime
is a git or crates.io dependency
#5966
Comments
What's an example of where/when this happens in practice? This almost feels like a "you're holding it wrong" kind of problem -- eg, stop using a native program, use BPF instead. |
@mvines it happens when testing bpf programs with the solana runtime in a different project. For example, this line was breaking because solana-runtime is a git dependency: https://github.com/solana-labs/solana-voib-demo/pull/10/files#diff-b8c3f81279869c0ce939d0328874bca3R218 |
It's not a problem if it's a crates.io dependency though right? |
Ah, I see. From cargo’s perspective there could be many versions of that crate in the build. We’re asking it to do something it’s not equipped for. We really want to |
@mvines I'm using this hacky workaround for now here: https://github.com/solana-labs/solana-voib-demo/pull/10/files#diff-5e76fee89c5d06973f4f702bc6b21a65R27. We definitely want something better for developers who wish to test their programs using the runtime in the future though. |
solana-runtime
git or crates.io dependency
solana-runtime
git or crates.io dependencysolana-runtime
git or crates.io dependency
For this kind of local testing we could statically link the native programs into the runtime, there's really no need for the dynamic loading at all |
Sounds good to me. Closing because there's a better approach unblocked by #5992 |
solana-runtime
git or crates.io dependencysolana-runtime
is a git or crates.io dependency
Re-opening to avoid this hacky workaround: #6383 |
Looks like the consistent messaging from the Rust folks is explicit dynamic linking of direct dependencies is not expected, encouraged, nor supported. Instead the recommendation is to treat these dependencies like any other FFI dependency and pull them in as separate projects (using build scripts for example). We can still keep the programs as direct dependencies for cases where we statically link them (treated as libs by runtime) but I didn't find any viable workarounds to address the file name hash while keeping the dynamically linked programs as direct dependencies. If we treat the dynamically linked programs as external dependencies I see two options:
Not super excited about either of these but they would address this issue. If we went down this path we might also want to split the programs living in Solana out to their own (or a single) repo. |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. |
This stale issue has been automatically closed. Thank you for your contributions. |
Problem
The native loader runtime looks for dynamic libraries with a specific filename like this:
libsolana_bpf_loader_program.dylib
and has been working fine when the runtime dependency is a relative path but breaks in other scenarios. Cargo seems to add an extra hash suffix to dependency filenames when pulling in dependencies from git and crates.ioProposed Solution
Handle hash suffixed dynamic library file names like this:
libsolana_bpf_loader_program-dad324483fd13565.dylib
The text was updated successfully, but these errors were encountered: