How to set a GHC option for a single module and a specific version of GHC?

Hi, I'm looking for a way to set a GHC compile option on a specific module (not every module in the program) but only for a specific version of GHC. Ideally within the confines of cabal, and in a portable way. GHC provides the OPTIONS_GHC pragma, but it does not appear to provide a way for the pragma to fire for specific versions of GHC. Also, I can't use an #ifdef trick because "File-header pragmas are read once only, before pre-processing the file (e.g. with cpp)." Cabal provides conditional statements and a way to check the version of GHC, but I can't see a way to get it to only use certain compiler options for a particular module. In summary, what I really want is a modified version of the OPTIONS_GHC pragma: {-# OPTIONS_GHC ==6.12.1 ... #-} or a way to tell cabal to use certain compiler options for a particular module under certain conditions. Cheers, Bernie.

On 5 June 2010 09:28, Bernie Pope
Hi,
I'm looking for a way to set a GHC compile option on a specific module (not every module in the program) but only for a specific version of GHC. Ideally within the confines of cabal, and in a portable way.
GHC provides the OPTIONS_GHC pragma, but it does not appear to provide a way for the pragma to fire for specific versions of GHC. Also, I can't use an #ifdef trick because "File-header pragmas are read once only, before pre-processing the file (e.g. with cpp)."
Not that it helps you immediately, but this is now fixed: http://hackage.haskell.org/trac/ghc/ticket/3457 I'm not sure which release will include the fix. Duncan

On Sat, Jun 5, 2010 at 3:28 AM, Bernie Pope
Hi,
I'm looking for a way to set a GHC compile option on a specific module (not every module in the program) but only for a specific version of GHC. Ideally within the confines of cabal, and in a portable way.
GHC provides the OPTIONS_GHC pragma, but it does not appear to provide a way for the pragma to fire for specific versions of GHC. Also, I can't use an #ifdef trick because "File-header pragmas are read once only, before pre-processing the file (e.g. with cpp)."
Cabal provides conditional statements and a way to check the version of GHC, but I can't see a way to get it to only use certain compiler options for a particular module.
In summary, what I really want is a modified version of the OPTIONS_GHC pragma:
{-# OPTIONS_GHC ==6.12.1 ... #-}
or a way to tell cabal to use certain compiler options for a particular module under certain conditions.
A not-great work-around is to have this one file in a separate source directory, and then use a different extra source directory based on the GHC version (by using an if statement in the package description). Antoine
participants (3)
-
Antoine Latter
-
Bernie Pope
-
Duncan Coutts