$ ghc -fext-core Panic.hs[1 of 1] Compiling Main ( Panic.hs, Panic.o )ghc: panic! (the 'impossible' happened) (GHC version 7.4.1 for x86_64-unknown-linux): MkExternalCore died: make_litPlease report this as a GHC bug: http://www.haskell.org/ghc/reportabug$
As it states, I am using GHC version 7.4.1 for x86_64 Linux, on an x86-64 Linux box running Ubuntu 11.10 an Linux kernel 3.0.0-14-generic.
Trac metadata
Trac field
Value
Version
7.4.1
Type
Bug
TypeOfFailure
OtherFailure
Priority
normal
Resolution
Unresolved
Component
Compiler
Test case
Differential revisions
BlockedBy
Related
Blocking
CC
Operating system
Linux
Architecture
x86_64 (amd64)
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information
Child items
...
Show closed items
Linked items
0
Link issues together to show that they're related or that one is blocking others.
Learn more.
This appears to be caused by the presence of the literal 1 in certain typing contexts. It crashes when I place the following in the position of 1 in the above test:
Short answer Yes... but there is a longer and more interesting answer. External Core is designed to round-trip, thus:
External Core is a data type defined in coreSyn/ExternalCore.
Core is converted to the External Core data type by coreSyn/MkExternalCore
The External Core data type is printed by PprExternalCore into concrete syntax.
The modified External Core can be parsed by parser/ParserCore. However, it is not parsed into the External Core data type, but rather into "Iface Core" defined in iface/IfaceSyn.
The Iface Core data type (thus parsed) can be converted to Core by iface/TcIface.
What is Iface Core? Iface Core is a data type that GHC uses every time you compile a module. During compilation, GHC converts Core into Iface Core, and then serialises Iface Core into the "M.hi" interface file, in a binary format. This is done by iface/BinIface. Then, when GHC wants to read an interface file, it de-serialises M.hi into Iface Core, and then converts Iface Core into Core with iface/TcIface. What this means is that Iface Core gets plenty of love: it is on our critical path.
Why does "External Core" do the round trip via the External Core data type on the way our, but via Iface Core data type on the way in? This mis-match just an aretefact of an earlier era: when we first implemented External Core, there was no Iface Core.
I think the Right Thing to do is to complete the change that we have already started:
Abandon the Exgternal Core data type entirely.
The conversion from Core to Iface Core is already done (in iface/MkIface), because GHC uses it every time it compiles a moudle.
Change the pretty-printer for External Core to pretty-print the Iface Core rarther than External Core. In fact there already is a pretty-printer for Iface Core, in iface/LoadIface.pprModIface, although it might require minor modification.
The bottom line is that we'd be abandoning the External Core data type (though not its concrete syntax), and switching entirely to Iface Core, which is much better maintained. Less code, more robust to change; what's not to like?
Now, while I say that there is a pretty printer for Iface Core already, it is designed mainly for humans; it is used when you say ghc --show-iface M.hi, and for no other purpose. The External Core concrete syntax, on the other hand, is designed to be parseable as well, so that the round-trip mechanism (print Exgternal Core, modify it, and read it back in) works right. But I think it would be quite acceptable to modify the Iface Core pretty-printer to use External Core syntax, because the Iface Core pretty printer has an output-only role in GHC. (If you do this, I suggest you put the new pretty-printer in a module of its own, perhaps iface/PprIface.)
If this was done, the maintenance burden of External Core, if/when we add new features to Core, would be reduced to
Designing new concrete (ASCII) syntax for the new features
Writing the pretty-printer and parser for this new syntax
I do think that the concrete syntax of External Core should be described by a human-readable BNF grammar, not only by a Happy parser. We have a very old Latex document describing External Core (including is syntax); I'd like to see it become a full part of the documentation, perhaps by convrting it to SGML and making it a full part of the GHC user manual.
This isn't a big task, and it's one that is well separated from the rest of GHC. Would anyone like to take it on? I'd be happy to advise if so.
We have a very old Latex document describing External Core (including is syntax); I'd like to see it become a full part of the documentation, perhaps by convrting it to SGML and making it a full part of the GHC user manual.
I'm a bit confused as to what the "official" GHC documentation is. There's the Developer wiki, Haskell wiki, and the user guide. Where would the External Core document go if converted?
(I ask because the user manual seems slightly strange place to document compiler internals. Perhaps not though.) Where is the source repository for the user manual?
Yes, your diagram is right, except that the arrow from .hi to Iface Core should be labelled iface/BinIface as well; BinIface does deserialisation as well a serialisation.
And rather that "External Iface" I might say "the output of ghc --show-iface or something like that.
Documenting in the user manual is slightly odd; but only slightly. After all, it's simply documenting what ghc -ext-core does; in particular, defining the language it produces into the .hcr file. The implementation diagram could form a useful part of the Commentary: http://hackage.haskell.org/trac/ghc/wiki/Commentary.
Yes converting core.tex to core.xml would be a great start.
I'm not experienced in ticketing systems so I'm not sure what the usual way of stating that I'm doing this is. For the moment I'm assigning this ticket to me.
I've attached my DocBook conversion of the External Core LaTeX document. It validates as a DocBook chapter, and builds OK with dblatex, but I can't work out how to build the User's Guide, so someone should check it builds.
Thanks for doing this James. We'll leave the ticket open for the larger question of refactoring the External Core handling as per my long comment above.
We'll leave the ticket open for the larger question of refactoring the External Core handling as per my long comment above.
IMO the next task would be to update the External Core document to represent the current code. Or would you consider this wasted effort if we're then changing things again?
Whatever the next task is, is the convention that I open a new ticket for it, or just to continue this discussion?
The two seems pretty independent to me: the doc is about the concrete syntax and how to drive it; the implementation will change but that should not radically change the external syntax.
I don't have a strong opinion about new vs old tickets. I'd stick to this one for now.