Opened 9 years ago

Closed 8 years ago

#2800 closed bug (wontfix)

deprecated OPTIONS flag warnings generated during dep chasing?

Reported by: duncan Owned by:
Priority: normal Milestone: 6.12 branch
Component: Compiler Version: 6.8.3
Keywords: Cc:
Operating System: Unknown/Multiple Architecture: Unknown/Multiple
Type of failure: None/Unknown Test Case:
Blocked By: Blocking:
Related Tickets: Differential Rev(s):
Wiki Page:


It would appear that warnings about deprecated flags used in OPTIONS pragmas get spat out during the early pre-processing and module chasing phase when they would not be generated after pre-processing.

ghc --make has to scan each module to look for options and language extensions to know if it has to run cpp. At this stage it cannot of course run cpp so it does not necessarily get the full set of options and extensions since some may be conditional. So it should not at this stage generate any warnings since they may be suppressed by later cpp-conditional flags.

Another possible theory is that it generates the warnings before having read all the OPTIONS flags so the later warning suppression is ineffective. Unfortunately we have to put them in the order we do for compatibility with older versions of ghc.

Here's an example out of Cabal:

{-# OPTIONS -cpp -fffi #-}
-- OPTIONS required for ghc-6.4.x, and must appear first
{-# LANGUAGE CPP, ForeignFunctionInterface #-}
{-# OPTIONS_GHC -cpp -fffi #-}
{-# OPTIONS_NHC98 -cpp #-}
{-# OPTIONS_JHC -fcpp -fffi #-}
#if __GLASGOW_HASKELL__ >= 610
{-# OPTIONS_GHC -fno-warn-deprecated-flags #-}
-- the ghc flag -fffi is deprecated in ghc-6.10. We're
-- supposed to use the LANGUAGE pragmas instead. However
-- we have to maintain compatibility with older ghc versions
-- so we (try to) suppress this warning.

What we're trying to do here is make it work with ghc-6.4 + and not generate any warnings with the latest ghc. This seems quite tricky to do.

To support ghc-6.4 we have to put the OPTIONS pragma first, since it apparently only looks at the first couple lines. We then use the compiler-specific OPTIONS pragmas. In particular these are needed for ghc-6.6. For ghc-6.8 and later we can use the LANGUAGE pragmas.

In ghc-6.10 the -fffi option is deprecated. However we cannot conditionally compile the OPTIONS -cpp -fffi since ghc needs to see the -cpp to know that it has to cpp the module. Making the OPTIONS -cpp unconditional and the OPTIONS -cpp -fffi conditional does not work with ghc-6.4.

So instead we try suppressing the warning. We cannot do that unconditionally since the flag is only present in newer ghc versions. However if we do suppress conditionally then ghc still warns anyway, presumably because it is warning on the first pass rather than in the pass after running cpp.

All in all it's a bit tricky to do right. Indeed I cannot currently see a way to make it work at all without generating warnings. The sledgehammer would be to put a flag in the .cabal file and have it apply to all modules, however that does not prevent the warning happening during Cabal bootstrapping which uses plain ghc --make.

Change History (2)

comment:1 Changed 9 years ago by igloo

difficulty: Unknown
Milestone: 6.12 branch

comment:2 Changed 8 years ago by igloo

Resolution: wontfix
Status: newclosed

The only reason putting -fno-warn-deprecated-flags in the Cabal file doesn't work is because Cabal is a special case, and wants to be bootstrappable with just ghc --make. I think we should just live with a couple of warnings in this case, rather than going to lots of effort to work around the problem.

Also, the current warnings at least will stop being a problem as support for building with older GHC versions is dropped.

Note: See TracTickets for help on using tickets.