Skip to content

wasm32-wasi: Cannot create dynamic library

Summary

Error while trying to create dynamic library.

System Information

  • Operating system: Host: Arch Linux. Client: WASI
  • Processor architecture: Host: x86_64. Client: wasm32
  • Compiler version: 3.3.1-9965-3.3.1-9978-g68cd1c39
  • Linker version: LLD 12.0.0
  • Device: Computer

Steps to reproduce

library testlib;

procedure Test;
begin
end;

exports
  Test;

end.

Compile the above code with fpc -Twasi -Pwasm32 -MObjFPC -Sh -otestlib.wasm testlib.pas

What is the current bug behavior?

Compilation ok but fails during linking process with the following message: wasm-ld: error: cannot open $MAP: No such file or directory If I try to remove $MAP in wasm-ld commands, then it links ok, but looks like the final binaries has no export symbols.

What is the expected (correct) behavior?

Compilation completes without any errors. The output library must contains all export symbols, plus _initialize export in order to execute code at initialization block, according to https://github.com/WebAssembly/WASI/blob/main/design/application-abi.md#current-unstable-abi

Edited by kagamma
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information