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

Copy link
Member

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>
Copy link
Member

@sjain-stanford sjain-stanford left a 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.

Comment on lines 111 to 119
// 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.

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>
@rsuderman rsuderman linked an issue Jan 30, 2026 that may be closed by this pull request
Signed-off-by: Rob Suderman <rob.suderman@gmail.com>
@rsuderman rsuderman merged commit 4590405 into iree-org:main Jan 30, 2026
9 checks passed
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.

[Fusilli] Add support for windows build

2 participants