Skip to content

failed to merge package wasi:http@0.2.0 into existing copy #52

@pavelsavara

Description

@pavelsavara

I'm trying to export wasi:http incoming-handler and import wasi:http outgoing-handler in the same component.
But the export and the import are each in different C object files and I'm passing two .wit files via -Wl,--component-type.

I separately use

world wasi-http {
  import outgoing-handler;
}

And

world wasi-http {
  export incoming-handler;
}

For each of them I use wit-bindgen c-sharp -w wasi-http -r native-aot --internal wasi-http-0.2.0/wit
And get 2 different .wit files, both named WasiHttpWorld_component_type.wit but in different folders.

Difference between them is

interface incoming-handler {
  use types.{incoming-request, response-outparam};

  handle: func(request: incoming-request, response-out: response-outparam);
}

world wasi-http {
  import wasi:io/poll@0.2.0;
  import wasi:clocks/monotonic-clock@0.2.0;
  import wasi:io/error@0.2.0;
  import wasi:io/streams@0.2.0;
  import types;

  export incoming-handler;
}

vs

interface outgoing-handler {
  use types.{outgoing-request, request-options, future-incoming-response, error-code};

  handle: func(request: outgoing-request, options: option<request-options>) -> result<future-incoming-response, error-code>;
}

world wasi-http {
  import wasi:io/poll@0.2.0;
  import wasi:clocks/monotonic-clock@0.2.0;
  import wasi:io/error@0.2.0;
  import wasi:io/streams@0.2.0;
  import types;
  import outgoing-handler;
}

The rest of the file is identical (each containing the same used types).

Simplified link command is like

wasm-component-ld --verbose -m wasm32 -Lwasi-sdk/share/wasi-sysroot/lib/wasm32-wasip2 \
--component-type WasiHttpHandler/WasiHttpWorld_component_type.wit \
--component-type WasiHttpClient/WasiHttpWorld_component_type.wit \
-o Wasi.HttpServer.Sample.wasm

The interesting part of verbose log is

wasm-ld: createHeader: DATA body=4786023 total=4786028
wasm-ld: createHeader: CUSTOM(component-type:wasip2__wasi_libc) body=10759 total=10762
wasm-ld: -- writeMapFile
wasm-ld: -- openFile
wasm-ld: writing: C:\Users\PAVELS~1\AppData\Local\Temp\.tmp68sdsS
wasm-ld: -- writeSections
wasm-ld: writing TABLE
wasm-ld: writing ELEM
wasm-ld: writing CUSTOM(component-type:wasip2__wasi_libc) offset=10479636 size=10762 chunks=1
wasm-ld: writing CODE offset=34990 size=5658618
wasm-ld:  headersize=5
wasm-ld:  codeheadersize=2
wasm-ld: writing GLOBAL
wasm-ld: writing MEMORY
wasm-ld: writing FUNCTION
wasm-ld: writing IMPORT
wasm-ld: writing TYPE
wasm-ld: writing DATA offset=5693608 size=4786028 body=4786023
wasm-ld: writing EXPORT
error: failed to merge package `wasi:http@0.2.0` into existing copy

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions