Compiling haxe compiler with ocamlc to c files or bc.js

So I have the issue that I want to translate/compile the haxe compiler source to ocaml bytecode(c or js).

What I tried:

  • installed js_of_ocaml with opam
  • Modified the dune file in the haxe/src/dune to contain in the library (modes byte) or/and in executable (modes (byte c) js )

What I think is happening is that the makefile is overwriting my dune modes definitions. I dont know if the fact that the compiler uses C stubs could be an issue also.

I dont know if any of the compiler developers could or would have any insight into this.

Thank you and happy holidays,

The use of c code is going to be hard to transfer for js,
but the main problem preventing js_of_ocaml from working is the use of filesystem access across the compiler, which doesn’t match the vm filesystem-less execution of js in the browser.

Depending on your goal know that it might need a lot of work/restructure.

I build Haxe to ocaml bytecode by adding (modes (byte exe)) to the “executable” section of src/dune file. That works fine. That’s all I know regarding building to bytecode )

1 Like

So as of now I can build my ocaml code to c then compile it,camlrun,otherlibs(unix,str,etc.) and its stubs to emcc bytecode and then link them to a wasm file.

The issue I am having now is that ocamlrun expects 64 bit pointers, and, as of now wasm64 isn’t available with emscripten and wasienv. So the runtime always fails with “input_value: integer too large” that is emited by intern.c in ocaml runtime.

So I can either be patient and wait on emscripten support of wasm64(wasm64 is already in llvm it would just need to be a supported target by emscripten or wasienv) or I could revert to js_of_ocaml and make js stubs for filesystem access with wasmfs and make js stubs for sha1/pcre.

I think I want to be patient for now.

If someone is interested in this have a look here

1 Like