Skip to content

Conversation

@hhugo
Copy link
Member

@hhugo hhugo commented May 30, 2015

Example:
Compile the stdlib and an ml file (test_cmo.ml)

js_of_ocaml `ocamlc -where`/stdlib.cma -o stdlib.js
ocamlc -c test_cmo.ml
js_of_ocaml test_cmo.cmo

Run with

    <script type="text/javascript">
      var joo_global_object=this
    </script>
    <script type="text/javascript" src="runtime/runtime.js"></script>
    <script type="text/javascript" src="runtime/predefined_exceptions.js"></script>
    <script type="text/javascript" src="stdlib.js"></script>
    <script type="text/javascript" src="test_cmo.js"></script>

@Drup
Copy link
Member

Drup commented May 30, 2015

Wow, Great work! I think that is going to be very useful!

cc @andrewray Pretty sure you can simplify iokerneljs with that.

@andrewray
Copy link
Contributor

We can currently dynamically load libraries but that tends to lead to stack overflows. Will need to test if this improves matters. If so, then this is very interesting!

@avsm Its possible we could set up a build service for ocaml libraries with this.

hhugo added a commit that referenced this pull request May 31, 2015
Complier: Js_of_ocaml can now compile cmo and cma
@hhugo hhugo merged commit df20856 into master May 31, 2015
@hhugo hhugo deleted the compile_cmo_to_js branch May 31, 2015 18:26
@avsm
Copy link

avsm commented Jun 1, 2015

@andrewray I'll happily set up the bulk builds to expose this via opam.ocaml.org as a HTTP service! Just ping me whenever there's a released version of js_of_ocaml and I'll make sure that the right build artefacts are made available from the bulk engine. /cc @dsheets @samoht

@hhugo
Copy link
Member Author

hhugo commented Jun 1, 2015

@andrewray do you know what's causing the stack overflows you're talking about ?

@bobzhang
Copy link
Contributor

This looks cool, but I got an error when trying this feature

play_js> js_of_ocaml t.cmo                                                                                                                                                    
js_of_ocaml: Error: Not an ocaml bytecode file                                                                                                                                 
js_of_ocaml: Error: Invalid magic number "d\027\n\139\214\204\220@@@@@" 

@bobzhang
Copy link
Contributor

I am using the master branch, so it should include this thing

@hhugo
Copy link
Member Author

hhugo commented Jun 20, 2015

a cmo should start with Caml1999O010.
what's the output of head -c 12 t.cmo

@ejgallego
Copy link
Contributor

@hhugo , we are also getting stack overflows with dynamic compilation.

I'm trying to debug them, meanwhile you can see an example using firefox and loading ssreflect as instructed in (https://x80.org/rhino-coq/).

Chrome will also SO if loading ssr in the standard way:

Require Import Srreflect.ssreflect.

Thanks,
E.

@hhugo
Copy link
Member Author

hhugo commented May 24, 2016

there is now an example of separate compilation 9b59580

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants