Skip to content

Proposal: a new subsection type in dylink.0 section to support runtime path #244

@ryanking13

Description

@ryanking13

Summary

I propose a new subsection type in dylink.0 section: WASM_DYLINK_RUNTIME_PATH.

This subsection is basically equivalent to runtime path (RPATH) in Linux, which is passed from the -rpath flag.

Background

The overall background is explained in the issue in the Emscripten repository: emscripten-core/emscripten#22126

In Pyodide (Python runtime for the browser), we install packages during the runtime. Installing and loading packages requires loading multiple WASM modules (in Linux terms, shared libraries; in Emscripten terms, side modules) in the package, which has dependency relations.

In order to make the Python package portable, python packages often put all the shared libraries in the package and set the RPATH to the relative path to the shared libraries (PEP 513). However, currently Emscripten does not support RPATH in the WASM module, so we've been hacking around the internal Emscripten code to inject the directory path to the shared libraries.

So, I propose to add support for the runtime path.

Proposal Details

  1. Add a new subsection type in dylink.0 section: WASM_DYLINK_RUNTIME_PATH.
    a. 5 / WASM_DYLINK_RUNTIME_PATH

  2. This subsection contains following fields:
    b. string path: the rpath string

  3. The special string $ORIGIN need to be supported.
    c. $ORIGIN represents the directory where the WASM module is located in the (virtual) filesystem.

  4. Let emscripten use this field to locate the shared library in the runtime.


cc: @hoodmane

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions