[m-dev.] Mercury, Emscripten, and WebAssembly

Julien Fischer jfischer at opturion.com
Wed Jan 29 10:13:47 AEDT 2020

Hi Patrick,

On Tue, 28 Jan 2020, Patrick Henning wrote:

> I am writing to request help with compiling Mercury code to
> WebAssembly via Emscripten. I believe this would involve using the
> Mercury compiler to compile the gc, runtime, standard library, etc, to
> c; and then using Emscripten to compile the c to WebAssembly code.
> From there it should be possibly to compile arbitrary Mercury code to
> c and then use Emscripten to compile that, linking in the previously
> prepared runtime and standard library and whatnot. 
> Does anyone know if and how it would be possbile to carry out the
> first step of compiling all the Mercury preliminaries to c (similar to
> the functionality that the '-C' flag for mmc provides)?

It's certainly possible to compile it all to C; that's how we build the
source distribution.

Take a look at the 'tar' target in the top-level Mmakefile -- this is
the target used to build the source distribution.  In particular, this

         cd util && mmake
         +cd runtime && $(SUBDIR_MMAKE) cs $(RT_LIB_NAME).init
         +cd library && $(SUBDIR_MMAKE) depend
         +cd library && $(SUBDIR_MMAKE) all-ints cs $(STD_LIB_NAME).init tags
         +cd mdbcomp && $(SUBDIR_MMAKE) depend
         +cd mdbcomp && $(SUBDIR_MMAKE) all-ints cs \
                 $(MDBCOMP_LIB_NAME).init tags
         +cd browser && $(SUBDIR_MMAKE) depend
         +cd browser && $(SUBDIR_MMAKE) all-ints cs \
                 $(BROWSER_LIB_NAME).init tags
         +cd ssdb && $(SUBDIR_MMAKE) depend
         +cd ssdb && $(SUBDIR_MMAKE) all-ints cs \
                 $(SSDB_LIB_NAME).init tags
         +cd trace && $(SUBDIR_MMAKE) cs
         +cd compiler && $(SUBDIR_MMAKE) depend
         +cd compiler && $(SUBDIR_MMAKE) cs tags
         +cd slice && $(SUBDIR_MMAKE) depend
         +cd slice && $(SUBDIR_MMAKE) cs tags
         +cd profiler && $(SUBDIR_MMAKE) depend
         +cd profiler && $(SUBDIR_MMAKE) cs tags
         +cd deep_profiler && $(SUBDIR_MMAKE) depend
         +cd deep_profiler && $(SUBDIR_MMAKE) cs tags
         +cd mfilterjavac && $(SUBDIR_MMAKE) depend
         +cd mfilterjavac && $(SUBDIR_MMAKE) cs tags

The 'cs' target builds all of the .c files in a directory
(i.e. without proceeding to compiling them to object code, linking etc.)


More information about the developers mailing list