Skip to content

Add support for simultaneously using dynamic linking + pthreads. #3494

Closed

Description

@juj

Current pthreads implementation has a limitation that the dynamic linking feature cannot be used with it. Investigate what is needed to enable this.

Activity

  1. kripken commented on Jun 3, 2015

    @kripken
    Member

    I would hope that this would just work. Did you see a problem when trying it?

  2. juj commented on Jun 3, 2015

    @juj
    CollaboratorAuthor

    I did not try, this was motivated by your comment in the pull, will need a bit of an audit and testing.

  3. stale commented on Aug 31, 2019

    @stale

    This issue has been automatically marked as stale because there has been no activity in the past 2 years. It will be closed automatically if no further activity occurs in the next 7 days. Feel free to re-open at any time if this issue is still relevant.

  4. reopened this on Oct 7, 2019
  5. jbkempf commented on Dec 17, 2019

    @jbkempf

    Any update on this?

  6. kripken commented on Dec 17, 2019

    @kripken
    Member

    I don't believe anyone is working on it. It would require some design thinking, as say dlopen on one thread would require adding to the Table on all other threads. However, non-dlopen dynamic linking may be a lot easier.

  7. jbkempf commented on Dec 17, 2019

    @jbkempf

    What about dlopening all from the "main-thread"?

  8. jbkempf commented on Dec 17, 2019

    @jbkempf

    However, non-dlopen dynamic linking may be a lot easier.

    That would mean to have all the .so (is it really .so?) modules loaded all the time, no?

  9. msabwat commented on Dec 17, 2019

    @msabwat
    Contributor

    @sbc100 talked about a shared table instead, would it be feasible? the SIDE_MODULE would still expose its native table to JS (like a normal wasm module does). I don't see how emscripten reads the native table? is it here?

    For now, "agressively" disabling the errors when we USE_PTHREADS+SIDE_MODULE lands into a wasm-ld assert:

    /b/s/w/ir/cache/builder/emscripten-releases/llvm-project/lld/wasm/Writer.cpp:715: void lld::wasm::(anonymous namespace)::Writer::createInitMemoryFunction(): Assertion `WasmSym::initMemoryFlag' failed.
    

    Makes me think there's another write. Is it like that? :

    1. We extract the symbols from the binary. (with llvm-nm)
    2. We write them into a JS Table object.
    3. We give that table to wasm-ld to have the final .wasm binary.

    Dynamic linking in our case would be to be able to feed the JS table from SIDE_MODULES and read from it from the MAIN_MODULE.

  10. sbc100 commented on Dec 17, 2019

    @sbc100
    Collaborator

    Current there is no concept of a shared wasm table in the spec, so each thread necessarily has its own table. And the tables need to stay in sync because C/C++ code expects to be able the share function pointer between threads.

    Right now we really on the startup code on each thread insantiating the wasm module and the local table such that local table on each thread ends up with the same content.

    Each time you load a DLL new table entries get add, so these table entries (and the DLL itself) need to propagated to each thread). If it can be done deterministicly then as perhaps just loading the DLL on each thread would be enough to guarantee the same table contents?

  11. 20 remaining items

  12. stale commented on Apr 17, 2022

    @stale

    This issue has been automatically marked as stale because there has been no activity in the past year. It will be closed automatically if no further activity occurs in the next 30 days. Feel free to re-open at any time if this issue is still relevant.

  13. akien-mga commented on Apr 26, 2022

    @akien-mga
    Contributor

    I don't think this should be closed as wontfix, it's a major issue.

  14. sbc100 commented on Apr 26, 2022

    @sbc100
    Collaborator

    I think this is is largely complete. We still warn about it being experimental, but it should work % bugs. We can open specific bugs if/when they are found.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions