Stream: Dune devs & users

Topic: per file flags?


view this post on Zulip Gaëtan Gilbert (Sep 28 2022 at 20:34):

Is it possible to pass ocaml flags specific to a file?
I'm thinking specifically of passing -rectypes for a .ml but not for the corresponding .mli

view this post on Zulip Ali Caglayan (Sep 28 2022 at 21:38):

https://github.com/ocaml/dune/issues/61

view this post on Zulip Ali Caglayan (Sep 28 2022 at 21:38):

so not atm

view this post on Zulip Emilio Jesús Gallego Arias (Sep 28 2022 at 22:51):

we could hack this with a library

view this post on Zulip Emilio Jesús Gallego Arias (Sep 28 2022 at 22:51):

and include

view this post on Zulip Emilio Jesús Gallego Arias (Sep 28 2022 at 22:52):

but yeah, it should be improved, with Dune 3.0 implementing this shouldn't take too long

view this post on Zulip Emilio Jesús Gallego Arias (Sep 28 2022 at 22:52):

I guess the use cases are very limited tho, that's why people didn't bother

view this post on Zulip Emilio Jesús Gallego Arias (Sep 28 2022 at 22:53):

on the other hand can you link modules with -rectypes with modules that don't use -rectypes?

view this post on Zulip Emilio Jesús Gallego Arias (Sep 28 2022 at 22:54):

maybe that could be done in the mli file with a [@@@ ] pragma

view this post on Zulip Ali Caglayan (Sep 28 2022 at 22:56):

rectypes can link with non rectypes but not viceversa

view this post on Zulip Emilio Jesús Gallego Arias (Sep 28 2022 at 22:56):

yeah so you force all users of the .ml to link with -rectypes anyways

view this post on Zulip Gaëtan Gilbert (Sep 29 2022 at 10:53):

Emilio Jesús Gallego Arias said:

we could hack this with a library

nope
because library has the same flags for mli and ml
but with rectypes if the ml has rectypes and the mli doesn't, it works and users don't need rectypes

view this post on Zulip Emilio Jesús Gallego Arias (Sep 29 2022 at 14:18):

I was thinking of a library just for the ml, then use a hack. Also we could add the rule just for that object.

view this post on Zulip Emilio Jesús Gallego Arias (Sep 29 2022 at 14:18):

the hack would be include

view this post on Zulip Emilio Jesús Gallego Arias (Sep 29 2022 at 14:18):

but indeed best is to have per_file flags

view this post on Zulip Gaëtan Gilbert (Sep 29 2022 at 14:23):

you mean use (action (run ocamlopt ...)) instead of the automatic rule?

view this post on Zulip Emilio Jesús Gallego Arias (Sep 29 2022 at 19:51):

Yup, but that's tricky too, you need to use then some special stuff for the cmo/cmx , as rules can't overlap

view this post on Zulip Emilio Jesús Gallego Arias (Sep 29 2022 at 19:51):

Dune 2.0 made hard to implement the flags per file, but 3.0 should be better so I guess it is just better to do so


Last updated: Jan 30 2023 at 18:04 UTC