Cross-module inlining fails

Markus Mottl markus.mottl at gmail.com
Mon Nov 19 18:16:55 GMT 2012


On Mon, Nov 19, 2012 at 1:00 PM, Sylvain Le Gall <sylvain at le-gall.net> wrote:
> Well, .cmx file should be installed EXCEPT if you are using packed
> modules...

The .cmx files of _submodules_ should not be installed for packed
libraries, this is correct, but the (single) .cmx file resulting from
packing should be installed for packed libraries.

> The culprit is:
> (not lib.lib_pack) && (* Do not install .cmx packed submodules *)
> in src/oasis/OASISLibrary.ml

This is the location of the likely bug.  My modification to setup.ml
below is completely untested and may not even compile, but the idea is
probably right:

    (* The .cmx that be compiled along *)
    let cmxs =
      let should_be_built =
          match bs.bs_compiled_object with
          | Native -> true
          | Best -> is_native
          | Byte -> false
      in
        if should_be_built then
          if lib.lib_pack then [ cs.cs_name ^ ".cmx" ]
          else
            find_modules
              (lib.lib_modules @ lib.lib_internal_modules)
              "cmx"
        else
          []
    in

> You can experiment installing .cmx by commenting this line. But I am really
> not sure this will help that much. I thought that .cmxs was a pack of .cmx
> so that inlining can work using what is inside this archive (contrary to
> .cmxa).
>
> Maybe the inlining using .cmxs doesn't work as excepted ?

.cmxs files are used for dynamic linking and are hence the "dynamic
brother" of .cmxa files.  Cross-module inlining, however, is done
during compilation, not linking.  It can only be done if the ".cmx"
files of modules referenced from the currently compiled file are
visible.  .cmxa and .cmxs files are completely ignored during
compilation.

Regards,
Markus

-- 
Markus Mottl        http://www.ocaml.info        markus.mottl at gmail.com



More information about the core mailing list