[GHC] #16219: Backpack - TH+indefinite module interface file error

#16219: Backpack - TH+indefinite module interface file error -------------------------------------+------------------------------------- Reporter: lightandlight | Owner: (none) Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 8.7 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: -------------------------------------+------------------------------------- Repro: https://github.com/LightAndLight/backpack-test I've been stuck on this for a while now. There's a weird interaction between the Template Haskell pragma and indefinite modules. When Template Haskell is enabled in this particular file (but TH features aren't used) I get an interface error. When I remove the pragma, the project successfully compiles. I hope I haven't made some trivial .cabal blunder. Anyway, I'm interested in potentially trying to fix this, but I've been digging around in GHC for a couple of days and figured it was time to ask for help. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/16219 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#16219: Backpack - TH+indefinite module interface file error -------------------------------------+------------------------------------- Reporter: lightandlight | Owner: (none) Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 8.7 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Changes (by bgamari): * cc: ezyang (added) Comment: Edward, do you think you could offer some insight here? -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/16219#comment:1 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#16219: Backpack - TH+indefinite module interface file error -------------------------------------+------------------------------------- Reporter: lightandlight | Owner: (none) Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 8.7 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by ezyang): Yes, I plan to look into it. It may be related to https://github.com/haskell/cabal/issues/5634 -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/16219#comment:2 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#16219: Backpack - TH+indefinite module interface file error -------------------------------------+------------------------------------- Reporter: lightandlight | Owner: (none) Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 8.7 Resolution: | Keywords: backpack Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Changes (by ezyang): * keywords: => backpack -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/16219#comment:3 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#16219: Backpack - TH+indefinite module interface file error -------------------------------------+------------------------------------- Reporter: lightandlight | Owner: (none) Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 8.7 Resolution: | Keywords: backpack Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by ezyang): Looks like this is a proper GHC bug. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/16219#comment:4 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#16219: Backpack - TH+indefinite module interface file error -------------------------------------+------------------------------------- Reporter: lightandlight | Owner: (none) Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 8.7 Resolution: | Keywords: backpack Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by ezyang): It looks like the problem is GHC is incorrectly attempting to build the object file for the indefinite package. Working versus non-working (working version by commenting out TemplateHaskell) {{{ -[2 of 2] Compiling C ( library-b/C.hs, nothing ) +Read the interface file dist/build/library-b/C.hi +[2 of 2] Compiling C ( library-b/C.hs, /tmp/ghc11640_0/ghc_1.o ) }}} -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/16219#comment:5 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#16219: Backpack - TH+indefinite module interface file error -------------------------------------+------------------------------------- Reporter: lightandlight | Owner: (none) Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 8.7 Resolution: | Keywords: backpack Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by ezyang): From code reading, it looks like this is a bad interaction between indefinite packages, and our special logic to handle `-fno-code` builds that use TemplateHaskell. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/16219#comment:6 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#16219: Backpack - TH+indefinite module interface file error -------------------------------------+------------------------------------- Reporter: lightandlight | Owner: (none) Type: bug | Status: patch Priority: normal | Milestone: Component: Compiler | Version: 8.7 Resolution: | Keywords: backpack Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Phab:D5475 Wiki Page: | -------------------------------------+------------------------------------- Changes (by ezyang): * status: new => patch * differential: => Phab:D5475 -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/16219#comment:7 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#16219: Backpack - TH+indefinite module interface file error -------------------------------------+------------------------------------- Reporter: lightandlight | Owner: (none) Type: bug | Status: patch Priority: normal | Milestone: Component: Compiler | Version: 8.7 Resolution: | Keywords: backpack Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Phab:D5475 Wiki Page: | -------------------------------------+------------------------------------- Comment (by lightandlight): Your phabricator comment says:
It should work to write an indefinite package using TemplateHaskell, so long as all of the actual TH code lives outside of the package.
Will this always be the case? No TH in indefinite packages? -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/16219#comment:8 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#16219: Backpack - TH+indefinite module interface file error -------------------------------------+------------------------------------- Reporter: lightandlight | Owner: (none) Type: bug | Status: patch Priority: normal | Milestone: Component: Compiler | Version: 8.7 Resolution: | Keywords: backpack Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Phab:D5475 Wiki Page: | -------------------------------------+------------------------------------- Comment (by ezyang): So, hypothetically, it might be possible to get TH for modules which don't transitively depend on a signature in the indefinite package. But, fundamentally, there's no way to have TH which depends on a signature, since the TH splice affects type checking, but you have no idea what the actual implementation of the splice is! You can always work around these problems by making more packages. Maybe if you say more about your use case I might be able to better advise. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/16219#comment:9 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#16219: Backpack - TH+indefinite module interface file error -------------------------------------+------------------------------------- Reporter: lightandlight | Owner: (none) Type: bug | Status: patch Priority: normal | Milestone: Component: Compiler | Version: 8.7 Resolution: | Keywords: backpack Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Phab:D5475 Wiki Page: | -------------------------------------+------------------------------------- Comment (by lightandlight): My use case is that I have a large datatype, where some of the fields are datatypes that contain abstract datatypes (these abstract datatypes are declared in a signature in another package). I want to use TH to generate lenses for the large indefinite datatype. Also, should we take this particular discussion off the tracker? -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/16219#comment:10 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#16219: Backpack - TH+indefinite module interface file error -------------------------------------+------------------------------------- Reporter: lightandlight | Owner: (none) Type: bug | Status: patch Priority: normal | Milestone: Component: Compiler | Version: 8.7 Resolution: | Keywords: backpack Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Phab:D5475 Wiki Page: | -------------------------------------+------------------------------------- Comment (by ezyang): No, this is fine :) Lens generation shouldn't have problems on code front, because the splices should only ever refer to code in the lens package, which should be fully compiled at this point. But maybe the problem is we don't get good information about abstract data types at this time? I guess it would be good to see if this works at all or not at the moment. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/16219#comment:11 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#16219: Backpack - TH+indefinite module interface file error -------------------------------------+------------------------------------- Reporter: lightandlight | Owner: (none) Type: bug | Status: patch Priority: normal | Milestone: Component: Compiler | Version: 8.7 Resolution: | Keywords: backpack Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Phab:D5475 Wiki Page: | -------------------------------------+------------------------------------- Comment (by lightandlight): Yeah remove the license file. My test case would be to add a datatype containing an `A` to https://github.com/LightAndLight/backpack- test/blob/master/library-a/B.hs, then generate lenses for it. Does that seem appropriate? -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/16219#comment:12 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#16219: Backpack - TH+indefinite module interface file error
-------------------------------------+-------------------------------------
Reporter: lightandlight | Owner: (none)
Type: bug | Status: patch
Priority: normal | Milestone:
Component: Compiler | Version: 8.7
Resolution: | Keywords: backpack
Operating System: Unknown/Multiple | Architecture:
| Unknown/Multiple
Type of failure: None/Unknown | Test Case:
Blocked By: | Blocking:
Related Tickets: | Differential Rev(s): Phab:D5475
Wiki Page: |
-------------------------------------+-------------------------------------
Comment (by Ben Gamari
participants (1)
-
GHC