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

Julien Fischer jfischer at opturion.com
Sun Mar 15 13:55:11 AEDT 2020


Hi Patrick,

On Sat, 14 Mar 2020, Patrick Henning wrote:

> Hello again, I’ve made some progress with this but am still
> struggling. I was able to successfully carry out the “make" step with
> grade hlc.gc without errors occurring, but have not been able to run
> ‘make install’ successfully. For now I am attempting to make do with
> the results of the “make” step. 
> Currently I am stuck on a linking error: when attempting to do the
> final step of linking a simple mercury program object file with `emcc
> -o hello.js hello_init.o hello.o
> /mercury-srcdist-20.01.1/library/libmer_std.a
> /mercury-srcdist-20.01.1/runtime/libmer_rt.a
> /mercury-srcdist-20.01.1/boehm_gc/libgc.a`, I get two errors about
> symbols “MR_box_int64” and “MR_box_uint64” being undefined. 
> 
> These two symbols are defined in mercury.h, so I would expect them to
> be present in libmer_rt.a, but examining it with llvm-nm seems to
> indicate that they are not defined there or in fact in any of the
> other library files. Can anyone help point me in the direction of what
> I am missing? Does libmer_rt need to be built in a specific way to
> ensure that  “MR_box_int64” and “MR_box_uint64” are included? 

No, I think there is some code missing from the runtime.  The attached
(untested) patch to runtime/mercury.c should address it.

Julien.
-------------- next part --------------
diff --git a/runtime/mercury.c b/runtime/mercury.c
index cefd3d8..ab913b1 100644
--- a/runtime/mercury.c
+++ b/runtime/mercury.c
@@ -93,6 +93,40 @@ MR_OUTLINE_DEFN(
 
 #endif // MR_BOXED_FLOAT && !MR_GNUC
 
+#if defined(MR_BOXED_INT64S) && !defined(MR_GNUC)
+
+MR_OUTLINE_DEFN(
+    MR_Box
+    MR_box_int64(int64_t i)
+,
+    {
+        int64_t *ptr;
+
+        MR_make_hp_float_aligned();
+        ptr = MR_new_object_atomic(MR_Float, sizeof(int64_t),
+            MR_ALLOC_SITE_INT64, NULL);
+        *ptr = f;
+        return (MR_Box) ptr;
+    }
+)
+
+MR_OUTLINE_DEFN(
+    MR_Box
+    MR_box_uint64(uint64_t i)
+,
+    {
+        uint64_t *ptr;
+
+        MR_make_hp_uint64_aligned();
+        ptr = MR_new_object_atomic(uint64_t, sizeof(uint64_t),
+            MR_ALLOC_SITE_UINT64, NULL);
+        *ptr = i;
+        return (MR_Box) ptr;
+    }
+)
+
+#endif // MR_BOXED_INT64S && !MR_GNUC
+
 #endif // ! MR_HIGHLEVEL_CODE
 
 ////////////////////////////////////////////////////////////////////////////


More information about the developers mailing list