OCaml Forge

Detail: [#1239] Warning when linking an executable with a internal packed library

Bugs: Browse | Download .csv | Monitor

[#1239] Warning when linking an executable with a internal packed library

Date:
2012-12-11 21:44
Priority:
3
State:
Open
Submitted by:
Philippe Veber (pveber)
Assigned to:
Philippe Veber (pveber)
Product:
OASIS
Due in version:
None
Resolution:
Accepted As Bug
Severity:
None
Version:
0.3.0~rc1
Component:
None
Operating System:
None
 
URL:
Summary:
Warning when linking an executable with a internal packed library

Detailed description
Compilation of the packedlib example issues a warning:

cochinois:~/oasis/examples/packedlib 22:36]$ocaml setup.ml -build
Finished, 1 target (0 cached) in 00:00:00.
+ ocamlfind ocamlc -g -linkpkg src/packedlib.cma src/packedlib.cmo test/main.cmo -o test/main.byte
File "src/packedlib.cmo", line 1:
Warning 31: files src/packedlib.cmo and src/packedlib.cma(Packedlib) both define a module named Packedlib
Finished, 21 targets (0 cached) in 00:00:00.

which is due to trying to compile main.ml adding both the cma and the cmo of the packed library. The cma is correct (and is added via the use_* tag, which is the intended behavior). Now I'm not sure why the cmo gets added. It seems to me that the module PackedLib is seen by ocamldep, then ocamlbuild sees the mlpack file and tries to be smart by adding the cmo automatically.

There is no problem when the packed library is findlib-installed, and this is only a warning but still. The only fix I see is in myocamlbuild.ml, refrain from adding the rule [use_foo => add foo.cma] when the library is packed.

Is there a better way to fix this issue?

Followup

Message
Date: 2012-12-15 17:52
Sender: Philippe Veber

The problem can be fixed if a packedlib.mllib is generated along with the packedlib.mlpack file. It should only contain the name of the pack, here Packedlib.

A similar problem happens when compiling a packed library foo that depends on another internal library bar. Without a foo.mllib file, foo.cma will contain the pack (foo.cmo) but also all modules of bar it depends on. This problem is detailled in the branch issue-1239 of my repo:

https://github.com/pveber/oasis/tree/issue-1239

please look at the commits:

https://github.com/pveber/oasis/commit/090acd582b437d17249c9a0bca840c4706980f95

and

https://github.com/pveber/oasis/commit/f20b2685841e74a2ccbbe29196161510e40bb361

Attached Files:

Changes:

Field Old Value Date By
VersionNone2012-12-15 17:52pveber
ResolutionNone2012-12-15 17:52pveber
assigned_tonone2012-12-15 17:52pveber
ProductNone2012-12-15 17:52pveber