title: OCaml as a compilation target
body: <p>I am implementing a ISO/IEC 13211-1:1995 compliant Prolog system in OCaml.</p>
  
  <p>For the code generation (a.k.a. JIT) part I ...</p>
  
  <ul>
  <li>... generate actual ".ml" code, ...</li>
  <li>... compile it with <code>ocamlopt</code>, ...</li>
  <li>... and use dynamic linking.</li>
  </ul>
  
  <p>The approach is somewhat crude but good enough as a proof-of-concept.</p>
  
  <p>Lately, it occurred to me that compiling to OCaml bytecode <em>could</em> be an alternative<sup>1</sup>.</p>
  
  <p>So my actual question is two-fold:</p>
  
  <ol>
  <li><p>How can I compile OCaml bytecode to native code?</p></li>
  <li><p>Are there OCaml libraries for emitting/handling bytecode?</p></li>
  </ol>
  
  <hr>
  
  <p><sup><strong>1</strong>  And a nice one, too, as this would allow using <code>js_of_ocaml</code>.</sup></p>