[Haskell-cafe] cabal sdist warns about optimization levels

Duncan Coutts duncan.coutts at googlemail.com
Sun Jan 13 23:12:49 CET 2013


On 13 January 2013 20:27, Petr P <petr.mvd at gmail.com> wrote:

> to the cabal file. Now cabal sdist complains with:
>
>     'ghc-options: -O2' is rarely needed. Check that it is giving a real
> benefit and not just imposing longer compile times on your users.
>
> I wonder:
>
> (1) Is there a way how to disable the warning? As the main aim of the
> library is speed, I believe -O2 is appropriate here. And since the code is
> quite short, I'm quite sure the increased compile time won't be noticeable.

No, but you can just ignore it. You clearly have checked and you're
satisfied it's the right thing to do, so it's fine.

You don't need to hit 0 warnings, nobody is going to give you or your
package black marks becuase of it! :-)

> (2) Why does cabal complain about it at the first place?

There's lots of programs where it makes no measurable difference
except to make compile times longer. To some extent it's to try to
break the habbit of C programmers who always default to -O2. With gcc
-O2 will almost always be significantly better than -O, but with ghc
that's not the case: -O is the sensible default (almost by definition,
to a first approximation, things that are always a win get put into
-O, things that are sometimes a win and sometimes not go into -O2).

Duncan



More information about the Haskell-Cafe mailing list