The ordering of -I directives should be consistent with the ordering of -package directives
Here's a reduced test case:
cpp.hs
{-# LANGUAGE CPP #-}
#include "Typeable.h"
main = return ()
command line
$ ghc-stage2 -c -package base cpp.hs
In file included from cpp.hs:4:0:
/home/patrick/code/ghc/libraries/base/include/Typeable.h:17:2:
warning: #warning <Typeable.h> is obsolete and will be removed in GHC 7.10 [-Wcpp]
#warning <Typeable.h> is obsolete and will be removed in GHC 7.10
^
compilation IS NOT required
$ ghc-stage2 -c -package base -package containers cpp.hs
compilation IS NOT required
$ ghc-stage2 -c -package containers -package base cpp.hs
Notice that if I pass -package containers to ghc, the cpp warning from Typeable.h (from the base library) doesn't appear. This is because containers also has a Typeable.h in its include path, and in the invocation of the preprocessor, containers' include path precedes base's no matter how I order the -package directives.
This behavior is unintuitive and limiting. To fix this, I think that the ordering of -I directives passed to the preprocessor should be consistent with the ordering of -package directives passed to ghc. For example, in the above test case, a warning should be shown in the 1st and 2nd invocations of ghc but not the 3rd, because in the 3rd invocation containers precedes base.
Does this sound okay?
Edited by Thomas Miedema