A patch to hlibrary.mk in haskell-devscripts to prevent unknown symbol errors
Sometimes the "Setup build" command gets run twice, and in some mysterious way this causes unresolved symbols when loading a library compiled against a library to which this has happened, like this:
Loading package syb-with-class-instances-text-0.0.1 ... linking ... done.
ghc: /usr/lib/haskell-packages/ghc6/lib/happstack-extra-0.87/ghc-6.12.1/HShappstack-extra-0.87.o: unknown symbol `sybzmwithzmclasszm0zi6zi1_DataziGenericsziSYBziWithClassziInstances_constrZMada0ZN_closure'
ghc: unable to load package `happstack-extra-0.87'
This is saying that while loading happstack-extra, it had to load the dependent library syb-with-class-instances-text, and during that load it expected a symbol to appear in syb-with-class which did not. That symbol was in the library produced during the first Setup build, but it came out with a different name during the second. How did syb-with-class-instances-text find out about this old symbol name? I have no idea.
I do know that the second run occurs because the directory dist-ghc6 is being used as a make rule target in hlibrary.mk, rather than using a stamp file whose date won't change once it is created. The attached patch replaces the uses of dist-ghc6 as a make target. Instead, it uses the stamp file dist-ghc6/dist-ghc6-stamp. I am currently rebuilding all of our packages with this fix. I've verified that the build is now only happening once in syb-with-class, and the libraries with the unknown symbol above are being shipped.
--- haskell-devscripts/hlibrary.mk.orig 2010-03-09 16:45:43.000000000 -0800
+++ haskell-devscripts/hlibrary.mk 2010-05-07 04:40:31.395792759 -0700
@@ -68,15 +68,16 @@
if test ! -e Setup.lhs -a ! -e Setup.hs; then echo "No setup script found!"; exit 1; fi
for setup in Setup.lhs Setup.hs; do if test -e $$setup; then ghc6 --make $$setup -o $(DEB_SETUP_BIN_NAME); exit 0; fi; done
-dist-ghc6: $(DEB_SETUP_BIN_NAME)
+dist-ghc6/dist-ghc6-stamp: $(DEB_SETUP_BIN_NAME)
$(DEB_SETUP_BIN_NAME) configure --ghc -v2 \
--prefix=/usr --libdir=/usr/lib/haskell-packages/ghc6/lib \
--builddir=dist-ghc6 \
--haddockdir=$(DEB_HADDOCK_DIR) \
--htmldir=$(DEB_HADDOCK_HTML_DIR) $(ENABLE_PROFILING) \
$(DEB_SETUP_GHC6_CONFIGURE_ARGS) $(OPTIMIZATION)
+ touch $@
-build-ghc6-stamp: dist-ghc6
+build-ghc6-stamp: dist-ghc6/dist-ghc6-stamp
$(BUILD_GHC6) --builddir=dist-ghc6
touch build-ghc6-stamp
@@ -86,7 +87,7 @@
[ ! -x /usr/bin/haddock ] || $(DEB_SETUP_BIN_NAME) haddock --builddir=dist-ghc6 $(DEB_HADDOCK_OPTS)
touch build-haddock-stamp
-build/haskell-$(CABAL_PACKAGE)-doc build/libghc6-$(CABAL_PACKAGE)-doc:: dist-ghc6 build-haddock-stamp
+build/haskell-$(CABAL_PACKAGE)-doc build/libghc6-$(CABAL_PACKAGE)-doc:: dist-ghc6/dist-ghc6-stamp build-haddock-stamp
dist-hugs: $(DEB_SETUP_BIN_NAME)
$(DEB_SETUP_BIN_NAME) configure --hugs --prefix=/usr -v2 --builddir=dist-hugs $(DEB_SETUP_HUGS_CONFIGURE_ARGS)
@@ -94,7 +95,7 @@
build/libhugs-$(CABAL_PACKAGE):: dist-hugs
$(DEB_SETUP_BIN_NAME) build --builddir=dist-hugs
-debian/tmp-inst-ghc6: $(DEB_SETUP_BIN_NAME) dist-ghc6
+debian/tmp-inst-ghc6: $(DEB_SETUP_BIN_NAME) dist-ghc6/dist-ghc6-stamp
$(DEB_SETUP_BIN_NAME) copy --builddir=dist-ghc6 --destdir=debian/tmp-inst-ghc6
install/libghc6-$(CABAL_PACKAGE)-dev:: debian/tmp-inst-ghc6
Reply to: