ocaml/ocaml — pull request #39 by lpw25 (2014-04-17 16:25:03+00:00)
Title: Record "weak dependencies" with -trans-mod

Currently, -trans-mod simply ignores dependencies on unused module
aliases. This commit changes this behaviour so that unused module aliases are
included in the list of imported interfaces but without a CRC.

This change means that the imported interfaces list (as displayed by
`ocamlobjinfo`) is now an accurate representation of what was used during the
compilation of a module. Whilst the contents of unused module aliases is not
used, their existence is still required in order for the module to compile
successfully.

Previously, a simple file `foo.ml` containing an unused module alias to `Bar`
would have the following output from `ocamlobjinfo` for `foo.cmo`:

File foo.cmo
Unit name: Foo
Interfaces imported:
4ad29aa1be509426919169d97aad0a82 Pervasives
df1763e3e7e64b9b8ebea6f93b0a95b3 Foo
Uses unsafe features: no
Force link: no

with this patch it instead has output:

File foo.cmo
Unit name: Foo
Interfaces imported:
-------------------------------- Bar
6cda9672639792333f53de8e8ff9e71d Pervasives
df1763e3e7e64b9b8ebea6f93b0a95b3 Foo
Uses unsafe features: no
Force link: no

This is useful because now we can see that if `bar.cmi` is deleted then this
module will no longer compile successfully.

This commit achieves this change by making the digests optional in every list
of imported interfaces and implementations.

In the case of implementations this replaces the previous use of the
`cmx_not_found_crc` dummy value for implementations where a `.cmx` was not
available.

`ocamlobjinfo` and `read_cmt` print imports with an empty digest as a line of
dashes. All other uses of the imported interface lists ignore imports with an
empty digest, leaving their behaviour unchanged.

This commit also adds a (new) description of -trans-mod to the man pages.