Skip to content

Evaluate PIC / shared-everything dynamic linking as an input ABI (dissolves the #351 reloc-drift class) — revisit ADR-6 #353

Description

@avrabe

Summary

Evaluate PIC / shared-everything dynamic linking as an input ABI for meld,
as an alternative (or complement) to the relocatable-inputs contract decided in
ADR-6. Raised by Christof re: #352 — with PIC inputs, address "rebasing" becomes
"set one __memory_base global per module", which structurally dissolves the
entire #351/#340 stale-reloc.CODE failure class
: there are no absolute
i32.const address literals to rewrite, so there is nothing for a producer's
LEB-relaxation to desync.

Refs: SharedEverythingDynamicLinking.md,
DynamicLinking.md.

Grounded findings (verified today — wasm-tools 1.243.0, wac 0.6.0, clang 22.1.8)

  1. PIC eliminates absolute addresses. clang --target=wasm32 -fPIC -O2 -c +
    wasm-ld --experimental-pic -shared turns dataB into
    (data (global.get $__memory_base) …) and ptr_b into
    global.get $__memory_base + offset. No i32.const <addr> literals exist.
  2. An AOT linker exists and works: wasm-tools component link (and wac 0.6.0) link two dylink.0 modules into a valid component — one $main
    module owns a shared memory and exports it; each dylib is instantiated
    (with "env" …) with that memory + a disjoint __memory_base; an
    $__init module applies relocations at instantiation. This is the
    SharedEverythingDynamicLinking model, working out of the box.
  3. This is exactly the path the fuse --memory auto/shared silently corrupts memory across components: load/store dynamic addresses are not rebased (no memory.grow; distinct from #172/#299) #326 spike (ADR-6) mis-scoped. The spike
    concluded "PIC excluded" — but it tested wasm-tools component **new**, which
    rejects a dylink core (reconfirmed today: error: failed to decode world from module; the CM forbids the env.memory/__memory_base non-function
    imports). component **link** is purpose-built for these and accepts the
    same core (reconfirmed). ADR-6's exclusion is really "excluded from the
    component new pipeline
    ", not "excluded".

Alignment with PulseEngine goals

Proposal

Treat input ABI as a spectrum, not a single choice:

Decisive spike (feasibility question to answer next)

Can meld consume PIC/-shared dylibs (or a component link-style shared-
everything graph) and statically flatten them into one core module —
resolving $__init's instantiation-time relocations at build time, assigning
disjoint bases itself? If yes, this is a cleaner ADR-6 successor. If the
instantiation-time relocation can't be statically resolved, PIC stays an
input-format improvement only.

Relation to existing work

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