Discussion:
[ocaml-platform] Package compilation and debug mode
Daniel Bünzli
2016-03-12 21:35:38 UTC
Permalink
Hello,

I'd like to know what the consensus is about distributing packages that always compile in debug mode. It seems that some persons do want to have debug always enabled [1,2], but the discussion is not clear cut [1].

By default all my packages are released with -g disabled. It seems easy enough to have an opam switch (even the official one) that automatically enables the flag.

So I think OCaml's opam repository should have a policy here. The answer should also take system package managers into account since those pull directly from the tarballs (if this document [3] is still in use for debian it seems they do require compilation with debug mode).

Personally I don't have an opinion about it, I'm rather seeking an answer here.

Best,

Daniel

[1] http://caml.inria.fr/mantis/view.php?id=6728
[2] http://rgrinberg.com/blog/2016/02/26/opam-package-checklist/
[3] http://pkg-ocaml-maint.alioth.debian.org/ocaml_packaging_policy.html/c305.html#AEN307
Ivan Gotovchits
2016-03-13 19:16:22 UTC
Permalink
It looks like, that currently the `-g` option has no performance cost at all (correct me if I’m wrong). Presumably, there is some increase in the package size, but who cares. With these premises, I think it would be a good policy to distribute packages with `-g` flag enabled.
Post by Daniel Bünzli
Hello,
I'd like to know what the consensus is about distributing packages that always compile in debug mode. It seems that some persons do want to have debug always enabled [1,2], but the discussion is not clear cut [1].
By default all my packages are released with -g disabled. It seems easy enough to have an opam switch (even the official one) that automatically enables the flag.
So I think OCaml's opam repository should have a policy here. The answer should also take system package managers into account since those pull directly from the tarballs (if this document [3] is still in use for debian it seems they do require compilation with debug mode).
Personally I don't have an opinion about it, I'm rather seeking an answer here.
Best,
Daniel
[1] http://caml.inria.fr/mantis/view.php?id=6728
[2] http://rgrinberg.com/blog/2016/02/26/opam-package-checklist/
[3] http://pkg-ocaml-maint.alioth.debian.org/ocaml_packaging_policy.html/c305.html#AEN307
--
https://sympa.inria.fr/sympa/arc/caml-list
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
Bug reports: http://caml.inria.fr/bin/caml-bugs
Mark Shinwell
2016-03-14 08:24:09 UTC
Permalink
I think there is a penalty (albeit a lesser one) with -g even if
OCAMLRUNPARAM does not contain "b". Raising an exception from OCaml
code causes a function call, which it does not otherwise.

Mark
There is a performance penalty with -g: it makes the raising of
exceptions slower (due to recording of backtraces). I think that may
be the only difference at present, though I'm not completely sure.
This penalty is only present with OCAMLRUNPARAM=b, which is now on by
default. This is a good thing, because lack of backtraces is something
100% of newcomers trip over; and anyone who dislikes the penalty
can trivially turn it off.
However, -g also inhibits some optimizations along with adding debug info.
So it is still not free.
IMO there should be another option, something like -debug-info, that is
equivalent to -g but does not inhibit any optimizations. Then it would
be enabled by default.
Mark
Post by Ivan Gotovchits
It looks like, that currently the `-g` option has no performance cost at
all (correct me if I’m wrong). Presumably, there is some increase in the
package size, but who cares. With these premises, I think it would be a good
policy to distribute packages with `-g` flag enabled.
Post by Daniel Bünzli
Hello,
I'd like to know what the consensus is about distributing packages that
always compile in debug mode. It seems that some persons do want to have
debug always enabled [1,2], but the discussion is not clear cut [1].
By default all my packages are released with -g disabled. It seems easy
enough to have an opam switch (even the official one) that automatically
enables the flag.
So I think OCaml's opam repository should have a policy here. The answer
should also take system package managers into account since those pull
directly from the tarballs (if this document [3] is still in use for debian
it seems they do require compilation with debug mode).
Personally I don't have an opinion about it, I'm rather seeking an answer here.
Best,
Daniel
[1] http://caml.inria.fr/mantis/view.php?id=6728
[2] http://rgrinberg.com/blog/2016/02/26/opam-package-checklist/
[3]
http://pkg-ocaml-maint.alioth.debian.org/ocaml_packaging_policy.html/c305.html#AEN307
--
https://sympa.inria.fr/sympa/arc/caml-list
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
Bug reports: http://caml.inria.fr/bin/caml-bugs
--
https://sympa.inria.fr/sympa/arc/caml-list
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
Bug reports: http://caml.inria.fr/bin/caml-bugs
--
whitequark
Daniel Bünzli
2016-03-23 09:43:06 UTC
Permalink
Post by Daniel Bünzli
So I think OCaml's opam repository should have a policy here. The answer should also take system package managers into account since those pull directly from the tarballs (if this document [3] is still in use for debian it seems they do require compilation with debug mode).
Would it be possible to get an official answer from OCaml's OPAM repository managers ?

They are in charge of devising the switches which do allow global addition of compiler options. If global removal is not supported then I think packages should be distributed without -g and default switches should simply add this switch.

Daniel
Thomas Gazagnaire
2016-03-23 10:02:47 UTC
Permalink
Post by Daniel Bünzli
By default all my packages are released with -g disabled. It seems easy enough to have an opam switch (even the official one) that automatically enables the flag.
How do you envision such a global debug flag? As far as I know, there is no configuration-time option to enable that option in the compiler (which would be the cleaner option IMHO). I'd rather avoid using OCAMLPARAM for this. A new opam variable can be created and used in the opam file to pass the debug command (or not) explicitly to the build system, but this will require adapting all the build systems (and ideally a new release of opam, but we can work-around that by setting OPAMVAR_debug in the .comp file).
Post by Daniel Bünzli
So I think OCaml's opam repository should have a policy here. The answer should also take system package managers into account since those pull directly from the tarballs (if this document [3] is still in use for debian it seems they do require compilation with debug mode).
Personally I don't have an opinion about it, I'm rather seeking an answer here.
I don't have a strong opinion either. I like when packages come with -g by default, but I can understand that the (small) runtime cost can be a problem for deployment scenarios.

Thomas
Gabriel Scherer
2016-03-23 10:12:50 UTC
Permalink
The new (4.03)
ocaml_compiler_internal_params
mechanism might be of use here:
OCAMLPARAM option passed using a configuration file
https://github.com/ocaml/ocaml/pull/428

Note that as a software packager I would be fine fetching a %{debug}%
variable and adapt my configure/build chain to handle it. I already
have specific logic for ocaml-native and ocaml-native-tools. But I
wonder whether this approach scales to other preferences one may want
to set globally. (OCAMLPARAM is a kludge, but duplicating it inside
OPAM may not be much better.)

On Wed, Mar 23, 2016 at 11:02 AM, Thomas Gazagnaire
Post by Thomas Gazagnaire
Post by Daniel Bünzli
By default all my packages are released with -g disabled. It seems easy enough to have an opam switch (even the official one) that automatically enables the flag.
How do you envision such a global debug flag? As far as I know, there is no configuration-time option to enable that option in the compiler (which would be the cleaner option IMHO). I'd rather avoid using OCAMLPARAM for this. A new opam variable can be created and used in the opam file to pass the debug command (or not) explicitly to the build system, but this will require adapting all the build systems (and ideally a new release of opam, but we can work-around that by setting OPAMVAR_debug in the .comp file).
Post by Daniel Bünzli
So I think OCaml's opam repository should have a policy here. The answer should also take system package managers into account since those pull directly from the tarballs (if this document [3] is still in use for debian it seems they do require compilation with debug mode).
Personally I don't have an opinion about it, I'm rather seeking an answer here.
I don't have a strong opinion either. I like when packages come with -g by default, but I can understand that the (small) runtime cost can be a problem for deployment scenarios.
Thomas
_______________________________________________
Platform mailing list
http://lists.ocaml.org/listinfo/platform
Daniel Bünzli
2016-03-23 10:23:12 UTC
Permalink
Post by Thomas Gazagnaire
Post by Daniel Bünzli
By default all my packages are released with -g disabled. It seems easy enough to have an opam switch (even the official one) that automatically enables the flag.
How do you envision such a global debug flag? As far as I know, there is no configuration-time option to enable that option in the compiler (which would be the cleaner option IMHO). I'd rather avoid using OCAMLPARAM for this.
I don't know, I think a decent scheme should be figured out by the compiler dev team. It seems there's more than one way of doing this at the moment, see e.g.

https://github.com/ocaml/ocaml/pull/428
Post by Thomas Gazagnaire
A new opam variable can be created and used in the opam file to pass the debug command (or not) explicitly to the build system, but this will require adapting all the build systems (and ideally a new release of opam, but we can work-around that by setting OPAMVAR_debug in the .comp file).
I don't think this is a reasonable approach. Debug/profile seems rather a property of your switch than an individual package property. Though one could argue that this should still be added so that packages using other tools than the ocaml compilers can abide to the switch property.

Daniel
Loading...