[GHC] #8527: The ordering of -I directives should be consistent with the ordering of -package directives (was: container's Typeable.h is being shadowed by base's Typeable.h during preprocessing)

GHC ghc-devs at haskell.org
Tue Nov 18 04:51:18 UTC 2014


#8527: The ordering of -I directives should be consistent with the ordering of
-package directives
-------------------------------------+-------------------------------------
              Reporter:  parcs       |            Owner:  parcs
                  Type:  bug         |           Status:  new
              Priority:  normal      |        Milestone:
             Component:  Package     |          Version:  7.7
  system                             |         Keywords:
            Resolution:              |     Architecture:  Unknown/Multiple
      Operating System:              |       Difficulty:  Unknown
  Unknown/Multiple                   |       Blocked By:
       Type of failure:              |  Related Tickets:
  None/Unknown                       |
             Test Case:              |
              Blocking:              |
Differential Revisions:              |
-------------------------------------+-------------------------------------

Old description:

> Here's a reduced test case:
>

> == cpp.hs ==
> {{{
> #!haskell
> {-# 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 intuitive 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?

New description:

 Here's a reduced test case:


 == cpp.hs ==
 {{{
 #!haskell
 {-# 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?

--

Comment (by thomie):

 Work has started:
 {{{
 commit 574ccfa231ca05d03d1da9d31e5bc81e74cc5e1e
 Author: Patrick Palka <patrick at parcs.ath.cx>
 Date:   Tue Nov 26 11:46:59 2013 -0500

     Respect the ordering of -package directives
 }}}
 But that commit was later reverted in
 fac831fd1377bcce5ef7513ab35a83661877f14c.

 With `ghc-7.9.20141115`, the warning from the description is always shown,
 regardless of the ordering of the package directives. So something ''has''
 changed.

 Note: "Typeable.h" might be removed when you read this. That doesn't mean
 that this issue is fixed though. A test should be added as well.

--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/8527#comment:2>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler


More information about the ghc-tickets mailing list