While browsing issues in the cabal github repository I encountered this comment by Oleg Grengrus:
[We] consider
ghc-options: -O2
(any -O flag) to be at the very least questionable practice.In
cabal.project
you can haveoptimization: 2
for all local, or per package (also non-local)
The core idea is that optimizations could be configured for all packages in an uniform way, without investigating if there’s some
dev
,devel
orfast
flag.Also as a bonus, changing optimization level (also possible from command line), won’t cause full recompilation (or worse: mixed-level compilation) as build products are kept separate.
This was news to me, so I thought some people here could also benefit from seeing this.