Discussion:
Metaocamlopt library problem
Alessandro Baretta
2006-02-06 09:11:38 UTC
Permalink
There are only two possible ways of generating the mentioned error message.
/opt/ocaml/309_alpha_029/lib/ocaml/metanative.cmxa
is not a compilation unit description
1) We are in the Asmlink module, in the scan_file function, trying to link a
cmxa file having a wrong magic number; however, this is not the case, for
cmxa_magic_number is defined as "Caml1999Z010", and metanative.cmxa does
actually start with this string.

2) We are in Compilenv.read_unit_info--the caller is Asmlink.scan_file--and we
are trying to link a cmx file. Obviously in this case the actual and expected
magic numbers do not match, and the exception Error(Not_a_unit_info filename) is
raised.

*******

Actually, a more careful reading of the code reveals that only the second
hypothesis, albeit apparently false, /can be true/. Notice that the the
Not_a_unit_info exception is defined twice--naughty boys!--in the two modules,
and the report error function selected by the Opterrors module obviously differs
for the two exceptions. The error message corresponding to
Asmlink.Not_a_unit_file(_) is "The file %s is not a compilation unit
description", while the error message I have produced is the following:

"/opt/ocaml/309_meta_029/ocaml/lib/metanative.cmxa \nis not a compilation unit
description."

which is compatible with the format string "%s@ is not a compilation unit
description." defined by Compilenv.report_error. Once we have discarded all
hypotheses but one, however absurd it might be, it must be true, my dear Watson ;)

I conclude that ocamlopt believes to be linking a cmx file, and correspondingly
looks for the cmx_magic_number instead of the cmxa_magic_number string. Let me
now try to discover why this happens.

Alex
--
*********************************************************************
http://www.barettadeit.com/
Baretta DE&IT
A division of Baretta SRL

tel. +39 02 370 111 55
fax. +39 02 370 111 54

Our technology:

The Application System/Xcaml (AS/Xcaml)
<http://www.asxcaml.org/>

The FreerP Project
<http://www.freerp.org/>
Alessandro Baretta
2006-02-06 10:33:50 UTC
Permalink
Post by Alessandro Baretta
There are only two possible ways of generating the mentioned error message.
/opt/ocaml/309_alpha_029/lib/ocaml/metanative.cmxa
is not a compilation unit description
"/opt/ocaml/309_meta_029/ocaml/lib/metanative.cmxa \nis not a
compilation unit description."
unit description." defined by Compilenv.report_error. Once we have
discarded all hypotheses but one, however absurd it might be, it must be
true, my dear Watson ;)
Almost true, actually. This is what happens. Optmain parses the command line,
identifies the -a option, sets the make_archive flag, and executes
Asmlibrarian.create_archive. This function expect the object files listed on the
command line to be cmx--not cmxa--files. Hence, Asmlibrarian.create_archive
iterates read_info on the listed objects, and read_info calls
Compilenv.read_unit_info, raising the mentioned exception. This seems to be an
idiosyncrasy of ocamlopt, for the problem is reproducible in vanilla ocaml.

To solve the problem it is necessary to change the metaocamlopt script so that
it does not provide the metanative.cmxa module to ocamlopt when linking a cmxa file.

The attached patch solves the issue for me. I am not a multi-shell aware
programmer, so my patch will only work with bash. It also solves some minor
issues with the Makefile, including the one I already mentioned.

Now, I will be able to start testing the AS/Xcaml with MetaOcaml. Thanks guys!

Alex
--
*********************************************************************


Studio Baretta
http://studio.baretta.com/

Consulenza Tecnologica e Ingegneria Industriale
Technological Consulting and Industrial Engineering

tel. +39 02 370 111 55
fax. +39 02 370 111 54
Loading...