Skip to content
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

Use locateFile in the dynamic module loader #18382

Merged
merged 2 commits into from
Dec 15, 2022

Conversation

georgestagg
Copy link
Contributor

@georgestagg georgestagg commented Dec 15, 2022

With this change, in loadLibData the path to libFile is passed through locateFile before attempting to download the data from an external source. Fixes #14502.

A test for dynamic linking with locateFile is added that creates the liblib.so side module in a temporary directory rather than in the current directory, as default. The side module is linked by passing the full file path to liblib.so, and locateFile is then used to tell Emscripten at runtime where to find the file. The test only passes when the dynamic module loader is indeed able to use locateFile to find the side module for loading.

@georgestagg georgestagg force-pushed the dylink_locate_file branch 3 times, most recently from c4b5fdf to 4a3e598 Compare December 15, 2022 14:43
@sbc100 sbc100 self-requested a review December 15, 2022 18:12
Copy link
Collaborator

@sbc100 sbc100 left a comment

Choose a reason for hiding this comment

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

Great! Thanks for PR. Just a couple of nits in the test code.

@needs_dylink
def test_dylink_locate_file(self):
name = 'liblib.so'
with tempfile.TemporaryDirectory() as tmpdir:
Copy link
Collaborator

Choose a reason for hiding this comment

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

I don't think there is any need to use a random tmpdir here.

How about just doing:`

so_dir = 'so_dir'
os.makedir(so_dir)

Each test already runs inside its own temporary sandbox directory anyway

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sounds good to me. I was trying to clean up after myself but I can see now that tests run in a tmpdir anyway.

test/test_core.py Outdated Show resolved Hide resolved
Make the expected error in test_dlfcn_missing more general to support
the addition of using `locateFile` in `loadLibData`.
test/test_core.py Show resolved Hide resolved
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.

locateFile not used when loading SIDE_MODULES
2 participants