[GHC] #8060: Undefined symbols when using Template Haskell linked from another object with unexposed modules
GHC
ghc-devs at haskell.org
Mon Jul 15 19:17:55 CEST 2013
#8060: Undefined symbols when using Template Haskell linked from another object
with unexposed modules
-----------------------------------+---------------------------------------
Reporter: tvynr | Owner:
Type: bug | Status: new
Priority: normal | Milestone:
Component: Compiler | Version: 7.6.3
Keywords: | Operating System: Linux
Architecture: | Type of failure: Compile-time crash
Unknown/Multiple | Test Case:
Difficulty: Unknown | Blocking:
Blocked By: |
Related Tickets: |
-----------------------------------+---------------------------------------
I have constructed two Cabal projects named "first" and "second". The
"first" project defines three files: Logging.hs (which provides some basic
logging functionality) and FirstExample.hs and FirstDependent.hs (the
latter of which imports the former). In the cabal file, only Logging and
FirstDependent are exposed modules. FirstDependent uses a Template
Haskell function "loggingFunctions" which defines logging functions for
that module. Using cabal or cabal-dev to build this package works quite
nicely.
The second project depends on the first project and contains a single
file, Second.hs. This file imports Logging but neither of the other two
files. It also uses the loggingFunctions routine to generate local
logging functions. The presence of the "$(loggingFunctions)" splice in
Second.hs makes the problem visible, but the real problem is in the first
project. Upon compilation of the "second" project with cabal or cabal-
dev, the following error is generated:
{{{
cabal-dev -s ../cabal-dev-sandbox --with-cabal-install=cabal configure
Resolving dependencies...
Configuring second-0.1...
cabal-dev -s ../cabal-dev-sandbox --with-cabal-install=cabal build
Building second-0.1...
Preprocessing library second-0.1...
[1 of 1] Compiling Second ( lib-src/Second.hs,
dist/build/Second.o )
Loading package ghc-prim ... linking ... done.
Loading package integer-gmp ... linking ... done.
Loading package base ... linking ... done.
Loading package array-0.4.0.1 ... linking ... done.
Loading package deepseq-1.3.0.1 ... linking ... done.
Loading package containers-0.5.0.0 ... linking ... done.
Loading package filepath-1.3.0.1 ... linking ... done.
Loading package old-locale-1.0.0.5 ... linking ... done.
Loading package time-1.4.0.1 ... linking ... done.
Loading package bytestring-0.10.0.2 ... linking ... done.
Loading package unix-2.6.0.1 ... linking ... done.
Loading package directory-1.2.0.1 ... linking ... done.
Loading package transformers-0.3.0.0 ... linking ... done.
Loading package mtl-2.1.2 ... linking ... done.
Loading package text-0.11.3.1 ... linking ... done.
Loading package parsec-3.1.3 ... linking ... done.
Loading package network-2.4.1.2 ... linking ... done.
Loading package process-1.1.0.2 ... linking ... done.
Loading package hslogger-1.2.1 ... linking ... done.
Loading package pretty-1.1.1.0 ... linking ... done.
Loading package template-haskell ... linking ... done.
Loading package first-0.2 ... linking ... ghc: /home/some-
directories/example/first/../cabal-dev-
sandbox//lib/first-0.2/ghc-7.6.1.20121207/HSfirst-0.2.o: unknown symbol
`firstzm0zi2_FirstExample_zdfShowErrorSpec3_closure'
ghc: unable to load package `first-0.2'
make[1]: *** [build] Error 1
}}}
Upon further investigation, it would seem that the .o file constructed to
represent the "first" project has not been completely constructed:
{{{
$ objdump -t cabal-dev-
sandbox/lib/first-0.2/ghc-7.6.1.20121207/HSfirst-0.2.o | grep '\*UND\*' |
grep first
00000000 *UND* 00000000
firstzm0zi2_FirstExample_zdfOrdErrorSpeczuzdczg_info
00000000 *UND* 00000000
firstzm0zi2_FirstExample_zdfShowErrorSpec3_closure
00000000 *UND* 00000000
firstzm0zi2_FirstExample_zdfOrdErrorSpeczuzdczl_info
00000000 *UND* 00000000
firstzm0zi2_FirstExample_zdfEqErrorSpeczuzdczeze_info
00000000 *UND* 00000000
firstzm0zi2_FirstExample_zdfOrdErrorSpeczuzdczlze_info
00000000 *UND* 00000000
firstzm0zi2_FirstExample_zdfOrdErrorSpeczuzdccompare_info
00000000 *UND* 00000000
firstzm0zi2_FirstExample_zdfOrdErrorSpeczuzdczgze_info
}}}
(While the above dump is for ghc 7.6.1, this has also been tested on ghc
7.6.3 as well as on both i386- and amd64-based OS installs.)
If the "$(loggingFunctions)" splice is removed from Second.hs, then the
project builds (presumably because the logic used by non-Template Haskell
projects for linking differs from that of Template Haskell projects).
Fortunately, it seems that exposing every module of the "first" project
resolves this issue. But please note that the FirstExample.hs and
FirstDependent.hs files are completely unrelated to the Second.hs file;
the latter does not depend on the former in any way. It seems strange
that I can't use Template Haskell across projects without exposing all of
my project modules.
--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/8060>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
More information about the ghc-tickets
mailing list