[GHC] #14574: Template Haskell Uniq ~ Int leads to external interpreter cross compilation trouble
GHC
ghc-devs at haskell.org
Tue Dec 12 11:12:01 UTC 2017
#14574: Template Haskell Uniq ~ Int leads to external interpreter cross compilation
trouble
-------------------------------------+-------------------------------------
Reporter: luite | Owner: (none)
Type: bug | Status: new
Priority: normal | Milestone:
Component: Compiler | Version: 8.3
Keywords: | Operating System: Unknown/Multiple
Architecture: | Type of failure: None/Unknown
Unknown/Multiple |
Test Case: | Blocked By:
Blocking: | Related Tickets:
Differential Rev(s): | Wiki Page:
-------------------------------------+-------------------------------------
64 bit GHC has 64 bit Unique values, but they don't fit in a `template-
haskell` `NameU` when cross-compiling to a 32 bit target.
In theory we can support Template Haskell in this situation with
`-fexternal-interpreter` (and the earlier GHCJS implementation), but when
the target cannot represent GHC's uniques in an `Int`, things go wrong:
from `Language.Haskell.TH.Syntax`:
{{{#!hs
type Uniq = Int
}}}
I think we can fix this for now by changing the synonym to `type Uniq =
Int64` (or even `type Uniq = Integer`), making the `template-haskell`
`Uniq` at least as big as the GHC `Unique` in practice. This requires a
change in `DsMeta`.
the uses of `Int` below should really be changed to `Uniq`
{{{#!hs
data NameFlavour
= NameS -- ^ An unqualified name; dynamically bound
| NameQ ModName -- ^ A qualified name; dynamically bound
| NameU !Int -- ^ A unique local name
| NameL !Int -- ^ Local name bound outside of the TH AST
| NameG NameSpace PkgName ModName -- ^ Global name bound outside of the
TH AST:
-- An original name (occurrences only, not binders)
-- Need the namespace too to be sure which
-- thing we are naming
deriving ( Data, Eq, Ord, Show, Generic )
}}}
{{{#!hs
-- Global variable to generate unique symbols
counter :: IORef Int
{-# NOINLINE counter #-}
counter = unsafePerformIO (newIORef 0)
}}}
--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/14574>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
More information about the ghc-tickets
mailing list