Skip to content

Conversation

@rsuderman
Copy link
Contributor

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.

Comment on lines +111 to +114
// 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);
Copy link
Member

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.

Copy link
Contributor Author

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).

#include <span>
#include <sstream>
#include <string>
#include <vector>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unrelated to this PR but we should include <cstdint> for the uint8_t type used below. I wonder why clang-tidy didn't catch this before.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Clang just auto includes core libraries a lot of the time. Not really sure why they chose to do that but they did ¯_(ツ)_/¯

Signed-off-by: Rob Suderman <rob.suderman@gmail.com>
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

Successfully merging this pull request may close these issues.

2 participants