[GHC] #820: problem compiling a file with top level Template Haskell splice

GHC trac at galois.com
Fri Jul 7 18:53:23 EDT 2006


#820: problem compiling a file with top level Template Haskell splice
---------------------------------+------------------------------------------
    Reporter:  guest             |        Owner:         
        Type:  bug               |       Status:  new    
    Priority:  normal            |    Milestone:  6.4.2  
   Component:  Template Haskell  |      Version:  6.4.2  
    Severity:  normal            |     Keywords:         
          Os:  Linux             |   Difficulty:  Unknown
Architecture:  x86_64 (amd64)    |  
---------------------------------+------------------------------------------
when compiling a file has both the following
   a. a -package option that loads a package with ref to external library,
   b. a top level Template Haskell splice $(...)
 The compiler fails to load the library required by the package properly
 and yields a failed compile due to 'unknown symbol'

 I have a simple example that refers to the JRegex package, which loads
 libpcre.so. The compile fails when compiling UseTH.hs, which refers to the
 package JRegex, and has a top level splice.
 Regex is available with cabalized build setup at
 http://repetae.net/john/computer/haskell/JRegex/
 and is trivial to install.

 It is simple to get around the problem, as 'make separate' does here by
 eliminating the dependency on the package in the file that splices but in
 case someone else has this problem it doesn't hurt to have it documented.

 uname -a =
 Linux server2 2.6.14-1.1656_FC4 #1 Thu Jan 5 22:13:55 EST 2006 x86_64
 x86_64 x86_64 GNU/Linux

 ghc -v =
 Glasgow Haskell Compiler, Version 6.4.2, for Haskell 98, compiled by GHC
 version 6.4.2
 Using package config file: /usr/local/lib/ghc-6.4.2/package.conf
 Using package config file: /home/ben/.ghc/x86_64-linux-6.4.2/package.conf
 Hsc static flags: -static
 *** Deleting temp files
 Deleting:
 ghc-6.4.2: no input files
 Usage: For basic information, try the `--help' option.


 Files = Makefile, Regex.hs, DefineTH.hs, UseTH.hs

 Makefile
 --------------------------
 SRCS = Regex.hs UseTH.hs DefineTH.hs

 together : $(SRCS)
         ghc -v --make -package JRegex -fth -lpcre $^


 separate : $(SRCS:.hs=.o)
         ghc -v -package JRegex -package template-haskell -fth -lpcre $^

 # eliminate -package JRegex to get TH splice to work
 UseTH.o : UseTH.hs
         ghc -v -c -fth $<

 %.o:    %.hs
         ghc -v -c -i. -package JRegex -fth -lpcre $^

 %.hi:           %.o
                 @:


 .PHONY:         clean
 clean:
         rm *.hi *.o a.out

 Regex.o : UseTH.hi
 UseTH.o : DefineTH.hi



 -----------------------------
 Regex.hs
 -----------------------------
 module Main where

 import Text.JRegex
 import Data.Array
 import UseTH

 main = putStrLn "hello"


 ---------------------------------
 DefineTH.hs
 --------------------------------
 module DefineTH

 where
 import Language.Haskell.TH
 import Language.Haskell.TH.Syntax
 import System

 getEnvExpr :: String -> String -> ExpQ
 getEnvExpr s alt =
     (runIO $ System.getEnv s `catch` (\e -> return alt)) >>= lift


 ----------------------------
 UseTH.hs
 ------------------------------
 module UseTH
 where

 import DefineTH

 dir = $(getEnvExpr "HOME" "")



 ---------------------------------
 - run of make together
 ---------------------------------
 ghc -v --make -package JRegex -fth -lpcre Regex.hs UseTH.hs DefineTH.hs
 Glasgow Haskell Compiler, Version 6.4.2, for Haskell 98, compiled by GHC
 version 6.4.2
 Using package config file: /usr/local/lib/ghc-6.4.2/package.conf
 Using package config file: /home/ben/.ghc/x86_64-linux-6.4.2/package.conf
 Hsc static flags: -static
 *** Chasing dependencies:
 Chasing modules from: Regex.hs,UseTH.hs,DefineTH.hs
 Stable modules:
 *** Compiling DefineTH         ( DefineTH.hs, interpreted ):
 compile: input file DefineTH.hs
 *** Checking old interface for DefineTH:
 Compiling DefineTH         ( DefineTH.hs, DefineTH.o )
 *** Parser:
 *** Renamer/typechecker:
 *** Desugar:
     Result size = 44
 *** Simplify:
     Result size = 40
     Result size = 38
 *** Tidy Core:
     Result size = 38
 *** CorePrep:
     Result size = 46
 *** Stg2Stg:
 *** CodeGen:
 *** CodeOutput:
 *** Assembler
 gcc -I. -c /tmp/ghc28762.s -o DefineTH.o
 *** Deleting temp files
 Deleting: /tmp/ghc28762.s
 *** Compiling UseTH            ( UseTH.hs, interpreted ):
 compile: input file UseTH.hs
 *** Checking old interface for UseTH:
 Compiling UseTH            ( UseTH.hs, UseTH.o )
 *** Parser:
 *** Renamer/typechecker:
 *** Desugar:
 *** Simplify:
 *** CorePrep:
 *** ByteCodeGen:
 Loading package base-1.0 ... linking ... done.
 ghc-6.4.2: /usr/local/lib/JRegex-1.0/ghc-6.4.2/HSJRegex-1.0.o: unknown
 symbol `pcre_version'
 *** Deleting temp files
 Deleting: /tmp/ghc28762.s
 Warning: deleting non-existent /tmp/ghc28762.s
 Loading package JRegex-1.0 ... linking ... ghc-6.4.2: unable to load
 package `JRegex-1.0'
 make: *** [together] Error 1





 -------------------------------
 --- run of make separate
 ---------------------
 ghc -v -c -i. -package JRegex -fth -lpcre DefineTH.hs
 Glasgow Haskell Compiler, Version 6.4.2, for Haskell 98, compiled by GHC
 version 6.4.2
 Using package config file: /usr/local/lib/ghc-6.4.2/package.conf
 Using package config file: /home/ben/.ghc/x86_64-linux-6.4.2/package.conf
 Hsc static flags: -static
 *** Checking old interface for DefineTH:
 *** Parser:
 *** Renamer/typechecker:
 *** Desugar:
     Result size = 44
 *** Simplify:
     Result size = 40
     Result size = 38
 *** Tidy Core:
     Result size = 38
 *** CorePrep:
     Result size = 46
 *** Stg2Stg:
 *** CodeGen:
 *** CodeOutput:
 *** Assembler
 gcc -I. -c /tmp/ghc28779.s -o DefineTH.o
 *** Deleting temp files
 Deleting: /tmp/ghc28779.s
 ghc -v -c -fth UseTH.hs
 Glasgow Haskell Compiler, Version 6.4.2, for Haskell 98, compiled by GHC
 version 6.4.2
 Using package config file: /usr/local/lib/ghc-6.4.2/package.conf
 Using package config file: /home/ben/.ghc/x86_64-linux-6.4.2/package.conf
 Hsc static flags: -static
 *** Checking old interface for UseTH:
 *** Parser:
 *** Renamer/typechecker:
 *** Desugar:
 *** Simplify:
 *** CorePrep:
 *** ByteCodeGen:
 Loading package base-1.0 ... linking ... done.
 Loading package haskell98-1.0 ... linking ... done.
 Loading package template-haskell-1.0 ... linking ... done.
 *** Desugar:
     Result size = 41
 *** Simplify:
     Result size = 75
     Result size = 73
 *** Tidy Core:
     Result size = 73
 *** CorePrep:
     Result size = 73
 *** Stg2Stg:
 *** CodeGen:
 *** CodeOutput:
 *** Assembler
 gcc -I. -c /tmp/ghc28785.s -o UseTH.o
 *** Deleting temp files
 Deleting: /tmp/ghc28785.s
 ghc -v -c -i. -package JRegex -fth -lpcre Regex.hs UseTH.hi
 Glasgow Haskell Compiler, Version 6.4.2, for Haskell 98, compiled by GHC
 version 6.4.2
 Using package config file: /usr/local/lib/ghc-6.4.2/package.conf
 Using package config file: /home/ben/.ghc/x86_64-linux-6.4.2/package.conf
 Hsc static flags: -static
 *** Checking old interface for Main:
 *** Parser:
 *** Renamer/typechecker:
 *** Desugar:
     Result size = 10
 *** Simplify:
     Result size = 10
     Result size = 8
     Result size = 8
 *** Tidy Core:
     Result size = 8
 *** CorePrep:
     Result size = 10
 *** Stg2Stg:
 *** CodeGen:
 *** CodeOutput:
 *** Assembler
 gcc -I. -c /tmp/ghc28790.s -o Regex.o
 *** Deleting temp files
 Deleting: /tmp/ghc28790.s
 ghc -v -package JRegex -package template-haskell -fth -lpcre Regex.o
 UseTH.o DefineTH.o
 Glasgow Haskell Compiler, Version 6.4.2, for Haskell 98, compiled by GHC
 version 6.4.2
 Using package config file: /usr/local/lib/ghc-6.4.2/package.conf
 Using package config file: /home/ben/.ghc/x86_64-linux-6.4.2/package.conf
 Hsc static flags: -static
 *** Linker
 gcc -v -o a.out Regex.o UseTH.o DefineTH.o -lpcre
 -L/usr/local/lib/JRegex-1.0/ghc-6.4.2 -L/usr/local/lib/ghc-6.4.2
 -lHSJRegex-1.0 -lHStemplate-haskell -lHShaskell98 -lHSbase -lHSbase_cbits
 -lHSrts -lm -lgmp -ldl -u GHCziBase_Izh_static_info -u
 GHCziBase_Czh_static_info -u GHCziFloat_Fzh_static_info -u
 GHCziFloat_Dzh_static_info -u GHCziPtr_Ptr_static_info -u
 GHCziWord_Wzh_static_info -u GHCziInt_I8zh_static_info -u
 GHCziInt_I16zh_static_info -u GHCziInt_I32zh_static_info -u
 GHCziInt_I64zh_static_info -u GHCziWord_W8zh_static_info -u
 GHCziWord_W16zh_static_info -u GHCziWord_W32zh_static_info -u
 GHCziWord_W64zh_static_info -u GHCziStable_StablePtr_static_info -u
 GHCziBase_Izh_con_info -u GHCziBase_Czh_con_info -u
 GHCziFloat_Fzh_con_info -u GHCziFloat_Dzh_con_info -u
 GHCziPtr_Ptr_con_info -u GHCziPtr_FunPtr_con_info -u
 GHCziStable_StablePtr_con_info -u GHCziBase_False_closure -u
 GHCziBase_True_closure -u GHCziPack_unpackCString_closure -u
 GHCziIOBase_stackOverflow_closure -u GHCziIOBase_heapOverflow_closure -u
 GHCziIOBase_NonTermination_closure -u
 GHCziIOBase_BlockedOnDeadMVar_closure -u
 GHCziIOBase_BlockedIndefinitely_closure -u GHCziIOBase_Deadlock_closure -u
 GHCziIOBase_NestedAtomically_closure -u
 GHCziWeak_runFinalizzerBatch_closure -u __stginit_Prelude
 Using built-in specs.
 Target: x86_64-redhat-linux
 Configured with: ../configure --prefix=/usr --mandir=/usr/share/man
 --infodir=/usr/share/info --enable-shared --enable-threads=posix --enable-
 checking=release --with-system-zlib --enable-__cxa_atexit --disable-
 libunwind-exceptions --enable-libgcj-multifile --enable-
 languages=c,c++,objc,java,f95,ada --enable-java-awt=gtk --with-java-
 home=/usr/lib/jvm/java-1.4.2-gcj-1.4.2.0/jre --host=x86_64-redhat-linux
 Thread model: posix
 gcc version 4.0.2 20051125 (Red Hat 4.0.2-8)
  /usr/libexec/gcc/x86_64-redhat-linux/4.0.2/collect2 --eh-frame-hdr -m
 elf_x86_64 -dynamic-linker /lib64/ld-linux-x86-64.so.2 -o a.out -u
 GHCziBase_Izh_static_info -u GHCziBase_Czh_static_info -u
 GHCziFloat_Fzh_static_info -u GHCziFloat_Dzh_static_info -u
 GHCziPtr_Ptr_static_info -u GHCziWord_Wzh_static_info -u
 GHCziInt_I8zh_static_info -u GHCziInt_I16zh_static_info -u
 GHCziInt_I32zh_static_info -u GHCziInt_I64zh_static_info -u
 GHCziWord_W8zh_static_info -u GHCziWord_W16zh_static_info -u
 GHCziWord_W32zh_static_info -u GHCziWord_W64zh_static_info -u
 GHCziStable_StablePtr_static_info -u GHCziBase_Izh_con_info -u
 GHCziBase_Czh_con_info -u GHCziFloat_Fzh_con_info -u
 GHCziFloat_Dzh_con_info -u GHCziPtr_Ptr_con_info -u
 GHCziPtr_FunPtr_con_info -u GHCziStable_StablePtr_con_info -u
 GHCziBase_False_closure -u GHCziBase_True_closure -u
 GHCziPack_unpackCString_closure -u GHCziIOBase_stackOverflow_closure -u
 GHCziIOBase_heapOverflow_closure -u GHCziIOBase_NonTermination_closure -u
 GHCziIOBase_BlockedOnDeadMVar_closure -u
 GHCziIOBase_BlockedIndefinitely_closure -u GHCziIOBase_Deadlock_closure -u
 GHCziIOBase_NestedAtomically_closure -u
 GHCziWeak_runFinalizzerBatch_closure -u __stginit_Prelude /usr/lib/gcc
 /x86_64-redhat-linux/4.0.2/../../../../lib64/crt1.o /usr/lib/gcc/x86_64-
 redhat-linux/4.0.2/../../../../lib64/crti.o /usr/lib/gcc/x86_64-redhat-
 linux/4.0.2/crtbegin.o -L/usr/local/lib/JRegex-1.0/ghc-6.4.2
 -L/usr/local/lib/ghc-6.4.2 -L/usr/lib/gcc/x86_64-redhat-linux/4.0.2
 -L/usr/lib/gcc/x86_64-redhat-linux/4.0.2 -L/usr/lib/gcc/x86_64-redhat-
 linux/4.0.2/../../../../lib64 -L/usr/lib/gcc/x86_64-redhat-
 linux/4.0.2/../../.. -L/lib/../lib64 -L/usr/lib/../lib64 Regex.o UseTH.o
 DefineTH.o -lpcre -lHSJRegex-1.0 -lHStemplate-haskell -lHShaskell98
 -lHSbase -lHSbase_cbits -lHSrts -lm -lgmp -ldl -lgcc --as-needed -lgcc_s
 --no-as-needed -lc -lgcc --as-needed -lgcc_s --no-as-needed /usr/lib/gcc
 /x86_64-redhat-linux/4.0.2/crtend.o /usr/lib/gcc/x86_64-redhat-
 linux/4.0.2/../../../../lib64/crtn.o
 *** Deleting temp files
 Deleting:

-- 
Ticket URL: <http://hackage.haskell.org/trac/ghc/ticket/820>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler


More information about the Glasgow-haskell-bugs mailing list