ocsigen / eliom

Multi-tier framework for programming web and mobile applications in OCaml.
http://eliom.org
Other
298 stars 53 forks source link

modules in let%lwt not linked #448

Open bruce-ricard opened 7 years ago

bruce-ricard commented 7 years ago

If your file main.ml has a line with code like:

let%lwt x = M1.stuff ...

and M1 is used nowhere else in the code, eliomdep (and ocamldep) don't figure out that M1 is a dependency of this file (seems like it's because it's inside a let%lwt block), and make byte thus fails. I put this bug here because it makes eliom build fail, but it looks like it's an issue of compatibility between lwt and ocamldep.

Drup commented 7 years ago

This is why ocamldep has a -ppx option. You should provide the Ppxs you are using to ocamldep.

How are you compiling ?

bruce-ricard commented 7 years ago

I'm using the makefile generated by the distillery which has lwt.ppx in both SERVER_PACKAGES and CLIENT_PACKAGES.

vasilisp commented 7 years ago

Can you provide a complete failing example? I can neither reproduce, nor understand how let%lwt could fool ocamldep (with lwt.ppx loaded, as in the distillery template).

vasilisp commented 7 years ago

Additionally, could you do a make distclean and then rebuild? That will get rid of the .depend files that may be in an inconsistent state for some reason.

bruce-ricard commented 7 years ago

git clone git@github.com:bruce-ricard/gobblet.git git checkout ceb67ea7903d49246c9334db23910074c791127e in lib/ make && make install in server make byte

It should tell you Error: Unbound module Connection_code you can then run make _server/connection_code.cmo and make byte again, and it works. But when you run make test.byte it fails with some reference to undefined global.

Using Ocaml version 4.02.3 and Eliom 5.0.0 [4.02.3], all installed through Opam.

I temporarily fixed my code by adding let _ = let open Common in let open Connection_code in () in the files involved, and it worked. (git checkout 6b503d69009a99e75857425aa5d7cbc76bf5e419).

I didn't know about distclean, but I manually removed _deps and .depend so that make regenerates them, but it didn't change anything. I just tried make distclean and it didn't fix it.

dboris commented 2 years ago

I also encountered this issue. Here is a reproducible example:

test1.ml

let connection_box () =
  Eliom_reference.get Core_lib.username

test2.ml

let connection_box () =
  let%lwt u = Eliom_reference.get Core_lib.username in
  Lwt.return u

Running eliomdep on these files produces:

eliomdep -server -ppx -package lwt_ppx -verbose test1.ml
+ ocamldep.opt '-ml-synonym' '.eliom' '-mli-synonym' '.eliomi' '-I' '.' '-impl' 'test1.ml'
_server/test1.cmo : _server/core_lib.cmo
_server/test1.cmx : _server/core_lib.cmx

eliomdep -server -ppx -package lwt_ppx -verbose test2.ml
+ ocamldep.opt '-ml-synonym' '.eliom' '-mli-synonym' '.eliomi' '-I' '.' '-impl' 'test2.ml'
_server/test2.cmo :
_server/test2.cmx :

For test2.ml, the dependencies have not been correctly inferred.