#7405: use of -no-hs-main causes TH compiles to fail -------------------------+-------------------------------------------------- Reporter: MtnViewMark | Owner: Type: bug | Status: new Priority: normal | Component: Template Haskell Version: 7.4.2 | Keywords: Os: MacOS X | Architecture: x86 Failure: None/Unknown | Blockedby: Blocking: | Related: -------------------------+--------------------------------------------------
Comment(by MtnViewMark): '''tl;dr:''' If you have any .c files in a project, they can't depend (even transitively) on any .hs modules that use TH - since all .o files are loaded during the TH expansions. If you have a .c file for an alternate main (hence using -no-hs-main), then the whole program is a transitive dependency, and hence can't use TH anywhere! cabal-out.txt shows a somewhat re-formatted output of build from cabal -v -v. You can see that in the case that fails to build (the third executable) the ghc --make command includes the real-main.o file (from the C compilation), as one would expect. The problem is that this .o file is getting loaded during the TH execution... presumably GHC can't tell if the .o files will be needed or not by TH code being run, and so just includes it to be safe. The problem is that that .o file depends, in this case directly, on the module being spliced by TH. It turns out that the -no-hs-main flag is a red herring - it is just that when you compile with -no-hs-main, you usually include a .c file that depends on some Haskell main-like entry point.... which by design transitively depends on the rest of the program. Hence, none of the program can use TH - since the .o file compiled from the .c file will be loaded into all TH runs. -- Ticket URL: <http://hackage.haskell.org/trac/ghc/ticket/7405#comment:1> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler _______________________________________________ Glasgow-haskell-bugs mailing list Glasgow-haskell-bugs@haskell.org http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs