Skip to content

--enable-wasm-dynamic-linking does not produce a dynamic build on WASI #163114

Backlog

Description

@Yousef02

Problem

configure accepts --enable-wasm-dynamic-linking on WASI (gh-142234) and compiles with -fPIC, but sets no link flags. The LDSHARED branch says dnl not implemented yet and is unreachable. python.wasm stays a static executable and $(LDSHARED) cannot link an extension module (undefined symbol: PyModule_GetState). A working build needs LDSHARED and LINKFORSHARED passed through the environment.

Proposal

  • LDSHARED: add -Wl,--unresolved-symbols=import-dynamic.
  • On wasm32-wasip1: link python.wasm with -pie --import-memory --export-dynamic --export=__main_argc_argv, making it a main module of the tool-conventions dynamic linking ABI.

WASI 0.2+ links a component and is left alone. No C changes. The default build's link line is unchanged.

Tested

main, WASI SDK 34 and 33, --host=wasm32-wasip1 --enable-wasm-dynamic-linking, nothing else. Under a ~450-line Node loader for dylink.0:

  • xxlimited, _testmultiphase and _testsinglephase, linked with $(LDSHARED), import and work.
  • test_xxlimited passes. test_importlib.extension passes 34 of 37 once its is_wasi skip is lifted (two failures come from my case-insensitive host filesystem).

The default wasip1 build and a wasip3 build with the flag still run on Wasmtime.

Open question: testing

An earlier dlopen patch stalled because CPython could not test it without external tools. That still holds: Wasmtime does not load dylink.0 modules, and wasi-libc's dlopen is a stub.

  1. CI builds with the flag: checks linking, not loading.
  2. A test-only loader as the host runner, which I can contribute. It adds Node to CI.

Is (1) enough to start?

Linked PRs

Activity

  1. added a commit that references this issue on Dec 3, 2026
  2. added
    type-bug
    build
    on Dec 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    OS-wasibuildtype-bug

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions