Ticket #3725 (new bug)

Opened 4 years ago

Last modified 9 months ago

Annotations not written to interface files

Reported by: rl Owned by:
Priority: lowest Milestone: 7.6.2
Component: Compiler Version: 6.13
Keywords: Cc:
Operating System: Unknown/Multiple Architecture: Unknown/Multiple
Type of failure: Other Difficulty:
Test Case: Blocked By:
Blocking: #7867 Related Tickets:

Description

Small example:

module C where

data T a = T a

Compile it:

newbie:tests rl$ ~/projects/ndp/ghc/inplace/bin/ghc-stage2 -O2 -c C.hs
newbie:tests rl$ ls -l C.hi
-rw-r--r--  1 rl  rl  485  4 Dec 12:53 C.hi

Add an annotation: {-# ANN type T () #-}. Compile:

newbie:tests rl$ ~/projects/ndp/ghc/inplace/bin/ghc-stage2 -O2 -c C.hs
Loading package ghc-prim ... linking ... done.
Loading package integer-gmp ... linking ... done.
Loading package base ... linking ... done.
Loading package ffi-1.0 ... linking ... done.
newbie:tests rl$ ls -l C.hi
-rw-r--r--  1 rl  rl  485  4 Dec 12:53 C.hi

Note that the interface file hasn't been updated. Remove C.hi and recompile:

newbie:tests rl$ rm C.hi
newbie:tests rl$ ~/projects/ndp/ghc/inplace/bin/ghc-stage2 -O2 -c C.hs
Loading package ghc-prim ... linking ... done.
Loading package integer-gmp ... linking ... done.
Loading package base ... linking ... done.
Loading package ffi-1.0 ... linking ... done.
newbie:tests rl$ ls -l C.hi
-rw-r--r--  1 rl  rl  507  4 Dec 12:54 C.hi

Only now has the annotation been written to C.hi.

Change History

Changed 4 years ago by simonpj

Roman,

Quite right. The relevant code is in MkIface.lhs. Look at the declaration of IfaceDeclExtras:

data IfaceDeclExtras 
  = IfaceIdExtras    Fixity [IfaceRule]
  | IfaceDataExtras  Fixity [IfaceInstABI] [(Fixity,[IfaceRule])]
  | IfaceClassExtras Fixity [IfaceInstABI] [(Fixity,[IfaceRule])]
  | IfaceSynExtras   Fixity
  | IfaceOtherDeclExtras

This collects information that forms part of an Id's fingerprint, even though the information is not serialised along with the Id itself; instead it occurs elsewhere in the interface file. For example, fixity forms part of an Id's fingerprint, but appears in the mi_fixities field of the ModIface.

What we'd forgotten is that the annotations for an Id should form part of its "extras". So the IfaceIdExtras constructor should look like

  IfaceIdExtras Fixity [IfaceRule] [Serialized]

If you make that change, then I think the knock-on changes (notably filling in that field) will be obvious.

Could you have a go at doing this? Thanks

Simon

Changed 3 years ago by igloo

  • milestone set to 6.12.2

Changed 3 years ago by igloo

  • milestone changed from 6.12.2 to 6.12.3

Changed 3 years ago by igloo

  • priority changed from normal to low
  • milestone changed from 6.12.3 to 6.14.1

Changed 2 years ago by igloo

  • milestone changed from 7.0.1 to 7.0.2

Changed 2 years ago by igloo

  • milestone changed from 7.0.2 to 7.2.1

Changed 21 months ago by igloo

  • milestone changed from 7.2.1 to 7.4.1

Changed 16 months ago by igloo

  • priority changed from low to lowest
  • milestone changed from 7.4.1 to 7.6.1

Changed 9 months ago by igloo

  • milestone changed from 7.6.1 to 7.6.2

Changed 7 weeks ago by errge

  • blocking 7867 added

(In #7867) Nevermind my previous comment, I found the relevant bug:  http://hackage.haskell.org/trac/ghc/ticket/3725

OK, I will continue by investigating if it's possible to get this stuff from template haskell and if not, how hard would be to add it...

I'll get back to this ticket if I have or need further info.

Note: See TracTickets for help on using tickets.