Skip to content

Make RTLD_LOCAL work correctly for recursively loaded DSOs#18924

Merged
sbc100 merged 1 commit intomainfrom
rtld_local2
Mar 9, 2023
Merged

Make RTLD_LOCAL work correctly for recursively loaded DSOs#18924
sbc100 merged 1 commit intomainfrom
rtld_local2

Conversation

@sbc100
Copy link
Collaborator

@sbc100 sbc100 commented Mar 8, 2023

When dlopen is first called with RTLD_LOCAL a new local scope is created. All symbols from the DSO being loaded and any of its transitive dependencies get added to this scrope (instead of the global scope).

@sbc100 sbc100 requested a review from dschuff March 8, 2023 22:15
@sbc100 sbc100 force-pushed the rtld_local2 branch 2 times, most recently from 3dad6f6 to ee8da4b Compare March 8, 2023 23:47
@sbc100 sbc100 requested a review from kripken March 9, 2023 00:37
@sbc100 sbc100 enabled auto-merge (squash) March 9, 2023 00:55

if (typeof result == 'function') {
// Workaround for closure compiler error if f.stub is accessed directly
// on the line below.
Copy link
Member

Choose a reason for hiding this comment

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

Weird error... what's the error message, if you still have it?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Closure says that Function does not have a stub attribute. Which is true for most functions, but we sometimes at them, which I guess is not something closure likes in general (attributes that might or might not exist). Should I add more detail to the comment?

Copy link
Member

Choose a reason for hiding this comment

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

No need, thanks, I was just curious.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I think the problem is that closure treat the if (typeof result == 'function') type refinement and will then assume that result to be of type Function.

shutil.move(outfile, 'liblib.so')
cmd = [compiler_for(filename), filename, '-o', outfile] + self.get_emcc_args()
if emcc_args:
cmd += emcc_args
Copy link
Member

Choose a reason for hiding this comment

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

Why do we need this in addition to get_emcc_args() on the prevoius line?

Copy link
Collaborator Author

@sbc100 sbc100 Mar 9, 2023

Choose a reason for hiding this comment

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

I used it below on the line self.build_dlfcn_lib('liba.c', outfile='liba.so', emcc_args=['libb.so'])

Here i want to set libb.so as an argument to compile step, but I don't want to add it to all the following compile steps in the test.

We have several functions that both take emcc_args and honor the global emcc_args. Sometimes it makes more sense to use one over the other I think.

Copy link
Member

Choose a reason for hiding this comment

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

I see, thanks, I was just confused by the name then.

shutil.move(outfile, 'liblib.so')
cmd = [compiler_for(filename), filename, '-o', outfile] + self.get_emcc_args()
if emcc_args:
cmd += emcc_args
Copy link
Member

Choose a reason for hiding this comment

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

I see, thanks, I was just confused by the name then.

When dlopen is first called with `RTLD_LOCAL` a new local scope is
created.  All symbols from the DSO being loaded and any of its
transitive dependencies get added to this scrope (instead of the global
scope).
@sbc100 sbc100 merged commit c9a5e63 into main Mar 9, 2023
@sbc100 sbc100 deleted the rtld_local2 branch March 9, 2023 23:29
impact-maker pushed a commit to impact-maker/emscripten that referenced this pull request Mar 17, 2023
…n-core#18924)

When dlopen is first called with `RTLD_LOCAL` a new local scope is
created.  All symbols from the DSO being loaded and any of its
transitive dependencies get added to this scrope (instead of the global
scope).
impact-maker pushed a commit to impact-maker/emscripten that referenced this pull request Mar 17, 2023
…n-core#18924)

When dlopen is first called with `RTLD_LOCAL` a new local scope is
created.  All symbols from the DSO being loaded and any of its
transitive dependencies get added to this scrope (instead of the global
scope).
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