Coder Social home page Coder Social logo

howto-wasm-minimal's Introduction

howto-wasm-minimal

How to create minimal wasm module - PoC

Goals

  • use no Emscripten or any libs
  • simple toolchain, compile to wasm in a single step
  • wasm may use memory prepared by JavaScript
  • do something relative compute-intensive
  • do something visible

Mystic issue

Symptom: on some systems, the linker may hang, or produce output file with correct size but full of zeros (that's why build script contains a hexdump as last step).

Solution: update your linker.

More info: https://stackoverflow.com/questions/71573019/cant-compile-to-wasm-on-linux

Install

You need CLANG and CLANG's linker (LLD). Tested on versions 13 and 14.

Debian nightly pacakges: https://apt.llvm.org/

On MacOS, you should install CLANG from homebrew. More info on Mac troubleshooting: https://til.simonwillison.net/webassembly/compile-to-wasm-llvm-macos

On Windows, you may use Chocolatey package manager to install CLANG: https://chocolatey.org/

Summary

Why WASM?

Writing web app in any language which is not JavaScript is just pure joy.

Try it

The color change and the blur effect is a WASM module, written in C:

http://linkbroker.hu/stuff/howto-wasm-minimal/

howto-wasm-minimal's People

Contributors

ern0 avatar lovasoa avatar syrusakbary avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

howto-wasm-minimal's Issues

Is -nostdlib required?

Hello, when compiling this project I noticed that there is no difference in the size of the generated .wasm file even if the -nostdlib flag is removed from build.sh. inc.wasm is 2894 bytes on my machine regardless.
Could I get clarification on why it is included in the build script?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.