-
Notifications
You must be signed in to change notification settings - Fork 11
Add platform specific dynamic library loading #119
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
Conversation
include/fusilli/support/dllib.h
Outdated
| // Use dlmopen with LM_ID_NEWLM to load in a new namespace for isolation. | ||
| handle_ = dlmopen(LM_ID_NEWLM, path.c_str(), RTLD_LAZY | RTLD_LOCAL); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Was it intentional to not check if the library is already loaded and reuse if so? The previous code was doing that (RTLD_NOLOAD) but the new code always creates a new namespace via LM_ID_NEWLM. Just checking because this could lead to duplicate copies of the library in different namespaces.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So the idea I had was to support reloading the same library multiple times. It avoids having to manage separately loaded version (e.g. something load the libIreeCompiler.so for its own implementation now having duplicate ownership). One of the problems with core dlopen is that if another took uses the library it could get into an illegal state (because of self counting destroy).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Got it. Maybe elaborate the reasoning in the comments for reference.
9d34c1f to
bc9b249
Compare
sjain-stanford
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice restructuring to make the library interface platform agnostic. LGTM modulo few comments.
include/fusilli/support/dllib.h
Outdated
| // Use dlmopen with LM_ID_NEWLM to load in a new namespace for isolation. | ||
| handle_ = dlmopen(LM_ID_NEWLM, path.c_str(), RTLD_LAZY | RTLD_LOCAL); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Got it. Maybe elaborate the reasoning in the comments for reference.
Signed-off-by: Rob Suderman <rob.suderman@gmail.com>
Signed-off-by: Rob Suderman <rob.suderman@gmail.com>
Signed-off-by: Rob Suderman <rob.suderman@gmail.com>
Signed-off-by: Rob Suderman <rob.suderman@gmail.com>
Windows differs from Linux in how it loads from dynamic libraries. Adding a support shim to select between platforms allows the libraries to be loaded platform independently.