Giter Site home page Giter Site logo

Comments (1)

e253 avatar e253 commented on June 4, 2024

A .wasm file will declare a bunch of functions it needs to execute properly. WASI and WASIX are standard sets of such functions. A pure WASI/WASIX web assembly program can be run in a WASI/WASIX runtime like wasmer without changes. At the moment, PGlite ships a wasm binary with a JS file that provides many custom Emscripten non-standard functions that wasmer doesn't have.

// postgres.js (generated)
var wasmImports = {
//...
      emscripten_date_now: _emscripten_date_now,
      emscripten_dispatch_result: emscripten_dispatch_result,
      emscripten_get_heap_max: _emscripten_get_heap_max,
      emscripten_get_now: _emscripten_get_now,
      emscripten_get_now_res: _emscripten_get_now_res,
      emscripten_memcpy_js: _emscripten_memcpy_js,
      emscripten_resize_heap: _emscripten_resize_heap,
      environ_get: _environ_get,
      environ_sizes_get: _environ_sizes_get,
      exit: _exit,
      fd_close: _fd_close,
      fd_fdstat_get: _fd_fdstat_get,
      fd_pread: _fd_pread,
      fd_pwrite: _fd_pwrite,
      fd_read: _fd_read,
      fd_seek: _fd_seek,
      fd_sync: _fd_sync,
      fd_write: _fd_write,
// ...
}

A WASIX (note the x, not WASI) build of pglite shouldn't be too tough because it has a very broad API. You link the wasix libc and that libc will compile imports in the .wasm binary that wasmer understands. You could even compile totally vanilla postgres to wasm32-wasix-none. I'd love to use a wasix pg instead of bloated, ram hungry docker pg! https://wasix.org/docs/language-guide/c/usage.

WASI should be possible through Emscripten by using the -sWASM_STANDALONE=1 linker flag. It can work, but will take some finagling to pass tests.

from pglite.

Related Issues (20)

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.