prefer loading from extension_dir if gem spec is an active stub#31
Open
anthraxx wants to merge 1 commit intoffi:masterfrom
Open
prefer loading from extension_dir if gem spec is an active stub#31anthraxx wants to merge 1 commit intoffi:masterfrom
anthraxx wants to merge 1 commit intoffi:masterfrom
Conversation
extension_dir is the modern place to put the native libraries for a gem that is distributed. Try finding and loading the requested library first from this extension dir, in case the library path is covered by an active sub. This makes sure the extension we are trying to load is not just matched based on the gem-name, as there may be multiple versions, but its actually loading a gem spec from a potentially active stub that matches the expected gem version as provided by the gem's dependency constraints. In case the loader can't find a matching platform library inside an active extension dir, fall back to regular lib path lookup which is glob scanning the ascending path. This makes sure the ffi-compiler loader can also be used for legacy lib paths as well as simple local checkouts and folders. This is the safest approach that tries to prefer loading from modern extension_dir while still making sure any other use case remains functional. Signed-off-by: Levente Polyak <levente@leventepolyak.net>
Author
|
This supersedes #30 with a much simpler approach finding the actual library in question, without making any assumptions about how the library-name relates to the gem-name. |
Collaborator
|
Looks good to me! I don't see any reason not to merge this if it works correctly/as expected and no one has any objections. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
extension_dir is the modern place to put the native libraries for a gem that is distributed. Try finding and loading the requested library first from this extension dir, in case the library path is covered by an active sub. This makes sure the extension we are trying to load is not just matched based on the gem-name, as there may be multiple versions, but its actually loading a gem spec from a potentially active stub that matches the expected gem version as provided by the gem's dependency constraints.
In case the loader can't find a matching platform library inside an active extension dir, fall back to regular lib path lookup which is glob scanning the ascending path. This makes sure the ffi-compiler loader can also be used for legacy lib paths as well as simple local checkouts and folders.
This is the safest approach that tries to prefer loading from modern extension_dir while still making sure any other use case remains functional.