Skip to content

Adding a custom section to store RPATH #3854

@ryanking13

Description

@ryanking13

Background

Starting from #3234, we started embedding external shared libraries in the wheel file, which is part of the work to make the wheel file portable and standardized, similar to what manylinux is trying to do. With this, I want to make it easier for pyodide wheels to be used by runtimes other than pyodide in the future.

The manylinux wheel uses a tool called auditwheel, which copies the shared libraries that the wheel file depends on into the wheel file and sets the RPATH (run-time search path) of the ELF binary to a relative path to the copied shared libraries, making it easier to find the libraries at runtime.

Current status in Pyodide

We are using a tool called auditwheel-emscripten to do something similar to auditwheel: copying shared libraries into a wheel file. However, the difference is that the Emscripten dynamic linking spec does not have an RPATH, so we are using a hard-coded path in JavaScript to locate shared libraries.

Suggestions

So what I'd like to suggest is that we add a custom section to the WASM module (.so files) that we can use as RPATH. For example, with name rpath.0. I think this section can be created during the post process in auditwheel-emscripten after building a wheel.

This way, when a non-Pyodide interpreter wants to use the Pyodide wheel (or Emscripten wheel (#3823) ), it can read this section and know where they can find shared libraries.

Pseudo code

const rpathSection = WebAssembly.Module.customSections(binary, "rpath.0")
if (rpathSection.length == 0) { /* No rpath.0 section in the module, use default search directories */ }
else {
  const rpath: string[] = parseRuntimePath(rpathSection);
  loadModule(binary, rpath);
}

WDYT?

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions