Skip to content

RamiHg/glib-emscripten

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

GLib for Emscripten

This is an Emscripten-compatible port of GLib 2.75.0. The port mostly works. However, some parts that are incompatible with Emscripten are either no-ops, or will fail at runtime. Do not use this in production until you've thoroughly tested your use-case.

The bulk of the work was done by @kleisauke in their excellent patch here.

This branch adds even more fixes and re-enables more components (like gregex).

Prerequisites

It is helpful to have a common installation prefix for Emscripten libraries. You can then set PKG_CONFIG_PATH to point to that directory's lib/pkgconfig. Packages can then reference each other seamlessly during compilation.

The build instructions below install Emscripten libraries in $HOME/emlib.

The build instructions also enable WASM_BIGINT by default. Remove references to -sWASM_BIGINT if you do not want to have it enabled.

PCRE2

git clone https://github.com/PCRE2Project/pcre2.git --branch pcre2-10.41
cd pcre2
./autogen.sh
emconfigure ./configure --prefix="$HOME/emlib" CFLAGS="-pthread -O3" LDFLAGS="-pthread -O3 -sWASM_BIGINT" --disable-shared
make -j$(nproc) install

zlib, libffi

TODO: Write simple instructions once the zlib fork is ready. For now, just follow the instructions in @kleisauke's gist linked above.

Building

First, setup the project. Use the $HOME/emlib directory that we've used to install dependencies as both the target directory, and the pkgconfig path. Then, only build the static version of the library, reference the Meson cross-file, and disable some unnecessary components.

export EM_PKG_CONFIG_PATH="$HOME/emlib/lib/pkconfig"
CFLAGS="pthread -O3" LDFLAGS="-pthread -O3 -sWASM_BIGINT" meson setup _build \
    --prefix="HOME/emlib" \
    --cross-file=./emscripten-crossfile.meson \
    --default-library=static \
    --buildtype=release \
    --force-fallback-for=gvdb \
    -Dselinux=disabled -Dxattr=false -Dlibmount=disabled -Dnls=disabled \
    -Dtests=false -Dglib_assert=false -Dglib_checks=false

Finally, build and install GLib to your target directory:

meson install -C _build

About

Emscripten-Compatible Fork of GLib.

Resources

License

Code of conduct

Security policy

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • C 96.2%
  • Python 2.0%
  • Meson 1.0%
  • Objective-C 0.2%
  • Shell 0.2%
  • M4 0.2%
  • Other 0.2%