Disable optimization

Lennart Kolmodin kolmodin at dtek.chalmers.se
Wed Feb 20 13:55:36 EST 2008

Ross Paterson wrote:
> On Wed, Feb 20, 2008 at 05:16:22PM +0100, Henning Thielemann wrote:
>>  I have upgraded to Cabal 1.2 while still using GHC-6.4.1. In the Haskore 
>> project there is the module NewResolutions.lhs which let GHC run into  
>> extensive swapping (certainly due to excessive memory consumption) on  
>> compilation when compiled with optimization. One can say, it cannot be  
>> compiled this way. This is clearly a compiler bug, but upgrading the  
>> compiler is not an option here. Thus I used unoptimized compilation so  
>> far. Now, Cabal 1.2 seems to have optimization set by default. While it  
>> was easy to add optimization by using 'GHC-Options' field it is not  
>> obvious how to override Cabal defaults.
> How about an OPTIONS -Onot pragma in the affected source file?
> (Putting optimization options in GHC-Options is now discouraged.)

If you're developing and later will distribute your copy, a solution is 
to run

./setup configure --disable-optimization

which will make all further building to be done without optimization.

Adding a -0not to the .cabal or source file will make it permanent to 
all users of your code, disregarding of compiler version.

If your modified copy only will be used by yourself, I prefer the 
suggestion by Ross as most of the project will be built with optimization.

   Lennart Kolmodin

More information about the cabal-devel mailing list