ocamlc -linkall -c test.ml
should activate force-linking in test.cmo
#6409
Labels
ocamlc -linkall -c test.ml
should activate force-linking in test.cmo
#6409
Original bug ID: 6409
Reporter: @gasche
Status: resolved (set by @damiendoligez on 2017-03-01T14:27:43Z)
Resolution: fixed
Priority: low
Severity: feature
Category: compiler driver
Bug description
When producing an archive (cma, cmxa), adding -linkall marks compilation unit of the archive as force-linked. It would be consistent and helpful if -linkall did also work when producing .cmo/.cmx. As far as I can tell, it is currently ignored.
$ mkdir test
$ echo "let x = 1" > test.ml
$ ocamlc -linkall -c test.ml
$ ocamlobjinfo test.cmo | grep link
Force link: no
While .cmo/.cmx are always linked anyway when passed to a linking step, the interest of marking a .cmo with force-linking is that it would remain force-linked in any archive including it.
I stepped on this non-behavior of -linkall when playing with force-linking side-effecting modules of the compiler (eg. typing/typeclass.cmo) during the discussion of #53. In any situation where typeclass.cmo and typecore.cmo are available and typecore.cmo is used, it is unsafe not to link typeclass.cmo as well; it would make sense to simply compile typeclass.cmo with -linkall.
The text was updated successfully, but these errors were encountered: