Skip to content
Advertisement

Can’t compile to .wasm on Linux

Summary

(Edit: removed all unnecessary information, added Windows10 experience, upgraded CLANG on Ubuntu to the same version, removed Debian10 due to old CLANG version)

I’ve created a pretty simple WASM module,

  • compiled on MacOS, works ✅,
  • compiled on MS-Windows10, works ✅,
  • compiled on Ubuntu21.10: produces 318 bytes of zeros ❌,

Details

Symptom

On Ubuntu21, the linker produces the file with correct length, but full of zeros:

JavaScript

The compiler also produces a temporary file named like inc.wasm.tmp611a2df, which is identical to the result inc.wasm, same size, zero bytes content.

Build commands

The compile command:

JavaScript

It produces good object file on any platform (compiled on Ubuntu, then linked on MS-Windows10: works).

The link command is (on MS-Windows10, use to caret “^” instead of backslash “”):

JavaScript

Versions

MacOS:

JavaScript

Ubuntu 21.10:

Compiler version:

JavaScript

Linker version:

JavaScript

Bottom line

Used strace on Debian10 with CLANG version 7, it was hanging after creating the result file, I copy here the strace output, but remember, it’s different version:

JavaScript

I have no idea, what’s going on.

Advertisement

Answer

I was just unlucky with two of my Linux VMs. A friend installed wasm-ld on his Arch Linux, and it worked out-of-the-box.

I’ve upgraded my Debian10 machine to Debian11, installed wasm-ld-13 and it just works.

User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement