[GHC] #12993: GHC 8.0.2-rc2 template Haskell interface file issue

#12993: GHC 8.0.2-rc2 template Haskell interface file issue -------------------------------------+------------------------------------- Reporter: glguy | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 8.0.2-rc1 Keywords: | Operating System: MacOS X Architecture: | Type of failure: GHC rejects Unknown/Multiple | valid program Test Case: | Blocked By: Blocking: | Related Tickets: Differential Rev(s): | Wiki Page: -------------------------------------+------------------------------------- When I try to build language-lua as found on Hackage with GHC 8.0.2-rc2 I get the following error. This package works with 8.0.1. I'm using the latest release of cabal-install/Cabal and alex-3.2.1 {{{#!hs src/Language/Lua/Annotated/Lexer.x:149:14: error: • Can't find interface-file declaration for variable AlexTools.runA Probable cause: bug in .hi-boot file, or inconsistent .hi file Use -ddump-if-trace to get an idea of which file caused the error • In the expression: AlexTools.runA x_a28iM inp_a28iQ x_a28iK x_a28iL mode_a28iP In the expression: case AlexTools.runA x_a28iM inp_a28iQ x_a28iK x_a28iL mode_a28iP of { (mode'_a28iR, ts_a28iS) -> (ts_a28iS ++ (go_a28iO mode'_a28iR x_a28iK)) } In a case alternative: AlexToken x_a28iK x_a28iL x_a28iM -> case AlexTools.runA x_a28iM inp_a28iQ x_a28iK x_a28iL mode_a28iP of { (mode'_a28iR, ts_a28iS) -> (ts_a28iS ++ (go_a28iO mode'_a28iR x_a28iK)) } }}} -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/12993 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#12993: GHC 8.0.2-rc2 template Haskell interface file issue -------------------------------------+------------------------------------- Reporter: glguy | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 8.0.2-rc1 Resolution: | Keywords: Operating System: MacOS X | Architecture: Type of failure: GHC rejects | Unknown/Multiple valid program | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Description changed by glguy: @@ -5,1 +5,1 @@ - {{{#!hs + {{{ New description: When I try to build language-lua as found on Hackage with GHC 8.0.2-rc2 I get the following error. This package works with 8.0.1. I'm using the latest release of cabal-install/Cabal and alex-3.2.1 {{{ src/Language/Lua/Annotated/Lexer.x:149:14: error: • Can't find interface-file declaration for variable AlexTools.runA Probable cause: bug in .hi-boot file, or inconsistent .hi file Use -ddump-if-trace to get an idea of which file caused the error • In the expression: AlexTools.runA x_a28iM inp_a28iQ x_a28iK x_a28iL mode_a28iP In the expression: case AlexTools.runA x_a28iM inp_a28iQ x_a28iK x_a28iL mode_a28iP of { (mode'_a28iR, ts_a28iS) -> (ts_a28iS ++ (go_a28iO mode'_a28iR x_a28iK)) } In a case alternative: AlexToken x_a28iK x_a28iL x_a28iM -> case AlexTools.runA x_a28iM inp_a28iQ x_a28iK x_a28iL mode_a28iP of { (mode'_a28iR, ts_a28iS) -> (ts_a28iS ++ (go_a28iO mode'_a28iR x_a28iK)) } }}} -- -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/12993#comment:1 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#12993: GHC 8.0.2-rc2 template Haskell interface file issue -------------------------------------+------------------------------------- Reporter: glguy | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 8.0.2-rc1 Resolution: | Keywords: Operating System: MacOS X | Architecture: Type of failure: GHC rejects | Unknown/Multiple valid program | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by glguy): The issue seemed to be that the the AlexTools module is using the `runA` record selector from Template Haskell but that that record selector is not exported to preserve an abstraction boundary https://github.com/GaloisInc/alex-tools/blob/master/src/AlexTools.hs#L268 If I export runA, or define runA as a top-level definition (even without exporting it) the bug does away. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/12993#comment:2 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#12993: GHC 8.0.2-rc2 template Haskell interface file issue -------------------------------------+------------------------------------- Reporter: glguy | Owner: Type: bug | Status: new Priority: highest | Milestone: Component: Compiler | Version: 8.0.2-rc1 Resolution: | Keywords: Operating System: MacOS X | Architecture: Type of failure: GHC rejects | Unknown/Multiple valid program | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Changes (by mpickering): * priority: normal => highest -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/12993#comment:3 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#12993: GHC 8.0.2-rc2 template Haskell interface file issue -------------------------------------+------------------------------------- Reporter: glguy | Owner: Type: bug | Status: new Priority: highest | Milestone: Component: Compiler | Version: 8.0.2-rc1 Resolution: | Keywords: Operating System: MacOS X | Architecture: Type of failure: GHC rejects | Unknown/Multiple valid program | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by rwbarton): The name `runA` is being "exported" through a quote. Minimal reproducer: {{{ -- TA.hs {-# LANGUAGE TemplateHaskell #-} module TA (q) where data X = X { x :: Int } q = [|x|] -- TB.hs {-# LANGUAGE TemplateHaskell #-} module TB where import TA f = $(q) }}} -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/12993#comment:4 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#12993: GHC 8.0.2-rc2 template Haskell interface file issue -------------------------------------+------------------------------------- Reporter: glguy | Owner: Type: bug | Status: new Priority: highest | Milestone: 8.0.2 Component: Template Haskell | Version: 8.0.2-rc2 Resolution: | Keywords: Operating System: MacOS X | Architecture: Type of failure: GHC rejects | Unknown/Multiple valid program | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Changes (by bgamari): * version: 8.0.2-rc1 => 8.0.2-rc2 * component: Compiler => Template Haskell * milestone: => 8.0.2 -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/12993#comment:5 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#12993: GHC 8.0.2-rc2 template Haskell interface file issue -------------------------------------+------------------------------------- Reporter: glguy | Owner: Type: bug | Status: new Priority: highest | Milestone: 8.0.2 Component: Template Haskell | Version: 8.0.2-rc2 Resolution: | Keywords: Operating System: MacOS X | Architecture: Type of failure: GHC rejects | Unknown/Multiple valid program | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by bgamari): It appears that the following declaration is present in the interface file produced by 8.0.1 and that produced by 8.0.2-rc2 with an explicit export of `x`, but missing from 8.0.2-rc2 otherwise, {{{ fb6798a720ab50725d554237e3ba2ff7 x :: X -> Int RecSel Left X }}} `master` is also afflicted with this issue. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/12993#comment:6 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#12993: GHC 8.0.2-rc2 template Haskell interface file issue
-------------------------------------+-------------------------------------
Reporter: glguy | Owner:
Type: bug | Status: new
Priority: highest | Milestone: 8.0.2
Component: Template Haskell | Version: 8.0.2-rc2
Resolution: | Keywords:
Operating System: MacOS X | Architecture:
Type of failure: GHC rejects | Unknown/Multiple
valid program | Test Case:
Blocked By: | Blocking:
Related Tickets: | Differential Rev(s):
Wiki Page: |
-------------------------------------+-------------------------------------
Comment (by Ben Gamari

#12993: GHC 8.0.2-rc2 template Haskell interface file issue
-------------------------------------+-------------------------------------
Reporter: glguy | Owner:
Type: bug | Status: new
Priority: highest | Milestone: 8.0.2
Component: Template Haskell | Version: 8.0.2-rc2
Resolution: | Keywords:
Operating System: MacOS X | Architecture:
Type of failure: GHC rejects | Unknown/Multiple
valid program | Test Case:
Blocked By: | Blocking:
Related Tickets: | Differential Rev(s):
Wiki Page: |
-------------------------------------+-------------------------------------
Changes (by bgamari):
* cc: osa1 (added)
Comment:
The culprit here appears to be 3a00ff92a3ee66c096b85b180d247d1a471a6b6e,
{{{
commit 3a00ff92a3ee66c096b85b180d247d1a471a6b6e
Author: Ömer Sinan Ağacan

#12993: GHC 8.0.2-rc2 template Haskell interface file issue -------------------------------------+------------------------------------- Reporter: glguy | Owner: Type: bug | Status: new Priority: highest | Milestone: 8.0.2 Component: Template Haskell | Version: 8.0.2-rc2 Resolution: | Keywords: Operating System: MacOS X | Architecture: Type of failure: GHC rejects | Unknown/Multiple valid program | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by osa1): The motivation behind that commit is that if a record selector is not exported and not used within the module, code for it was still generated. With that commit they're removed. I agree that this bug is caused by that change. I think a proper fix would be to detect that in these cases the selector is actually used. This is already done for toplevel definitions. For example: {{{#!haskell module Lib (x) where x, y :: Int x = 1 y = 2 }}} Compile and run `nm` on the object file, and you'll see that there isn't a symbol `Lib_y_closure`. If you export `y` you'll see that symbol. If I export `y` in a TH code it still works fine: {{{#!haskell module Lib (x, z) where x, y :: Int x = 1 y = 2 z = [|y|] }}} If you run `nm` you'll see that there's a `Lib_y_closure`. Apparently this last part is not done for record selectors and we should fix that. @bgamari, if this is urgent feel free to revert that commit, I can put it back once I figure out how to fix this. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/12993#comment:9 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#12993: GHC 8.0.2-rc2 template Haskell interface file issue
-------------------------------------+-------------------------------------
Reporter: glguy | Owner:
Type: bug | Status: new
Priority: highest | Milestone: 8.0.2
Component: Template Haskell | Version: 8.0.2-rc2
Resolution: | Keywords:
Operating System: MacOS X | Architecture:
Type of failure: GHC rejects | Unknown/Multiple
valid program | Test Case:
Blocked By: | Blocking:
Related Tickets: | Differential Rev(s):
Wiki Page: |
-------------------------------------+-------------------------------------
Comment (by Ben Gamari

#12993: GHC 8.0.2-rc2 template Haskell interface file issue -------------------------------------+------------------------------------- Reporter: glguy | Owner: Type: bug | Status: closed Priority: highest | Milestone: 8.0.2 Component: Template Haskell | Version: 8.0.2-rc2 Resolution: fixed | Keywords: Operating System: MacOS X | Architecture: Type of failure: GHC rejects | Unknown/Multiple valid program | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Changes (by bgamari): * status: new => closed * resolution: => fixed Comment: I've reverted the commit in question on `master` and `ghc-8.0`. osa1, perhaps you want to open a Task ticket to ensure that the original goal of your commit isn't lost? -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/12993#comment:11 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#12993: GHC 8.0.2-rc2 template Haskell interface file issue -------------------------------------+------------------------------------- Reporter: glguy | Owner: (none) Type: bug | Status: closed Priority: highest | Milestone: 8.0.2 Component: Template Haskell | Version: 8.0.2-rc2 Resolution: fixed | Keywords: Operating System: MacOS X | Architecture: Type of failure: GHC rejects | Unknown/Multiple valid program | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by niteria): I just run into this in our `ghc-8.0.2-facebook` branch (we cut from ghc-8.0 before the revert happened). It reproduces in an interesting way with `haddock` + `DuplicateRecordFields`: {{{ $ cat A.hs Main.hs; haddock A.hs Main.hs {-# LANGUAGE DuplicateRecordFields #-} {-# LANGUAGE DuplicateRecordFields #-} module A where data A = A { func :: Int -> Int } a :: A a = A { func = (*2) } module Main where import A main :: IO () main = print (func a 10) Haddock coverage: 0% ( 0 / 3) in 'A' Missing documentation for: Module header A (A.hs:4) a (A.hs:8) Main.hs:6:15: error: • Can't find interface-file declaration for variable A.$sel:func:A Probable cause: bug in .hi-boot file, or inconsistent .hi file Use -ddump-if-trace to get an idea of which file caused the error • In the first argument of ‘print’, namely ‘(func a 10)’ In the expression: print (func a 10) In an equation for ‘main’: main = print (func a 10) | 6 | main = print (func a 10) | }}} -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/12993#comment:12 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler
participants (1)
-
GHC