Fix a dependency bug in the build system
authorSimon Marlow <marlowsd@gmail.com>
Fri, 5 Oct 2012 09:34:42 +0000 (10:34 +0100)
committerSimon Marlow <marlowsd@gmail.com>
Mon, 8 Oct 2012 08:06:24 +0000 (09:06 +0100)
I've been meaning to track this one down for a long time.
Occasionally a build will fail with an error about a .so library being
truncated; the reason was that we weren't tracking the dependencies of
the GHC stage2 .so library correctly.

rules/build-package-way.mk

index 18ac917..a4b604f 100644 (file)
@@ -28,6 +28,7 @@ $(call hs-objs,$1,$2,$3)
 $1_$2_$3_LIB = $1/$2/build/libHS$$($1_PACKAGE)-$$($1_$2_VERSION)$$($3_libsuf)
 $$($1_PACKAGE)-$($1_$2_VERSION)_$2_$3_LIB = $$($1_$2_$3_LIB)
 
+# Note [inconsistent distdirs]
 # hack: the DEPS_LIBS mechanism assumes that the distdirs for packages
 # that depend on each other are the same, but that is not the case for
 # ghc where we use stage1/stage2 rather than dist/dist-install.
@@ -37,8 +38,11 @@ ifeq "$$($1_PACKAGE) $2" "ghc stage2"
 $$($1_PACKAGE)-$($1_$2_VERSION)_dist-install_$3_LIB = $$($1_$2_$3_LIB)
 endif
 
-# All the .a/.so library file dependencies for this library
-$1_$2_$3_DEPS_LIBS=$$(foreach dep,$$($1_$2_DEPS),$$($$(dep)_$2_$3_LIB))
+# All the .a/.so library file dependencies for this library.
+#
+# The $(subst stage2,dist-install,..) is needed due to Note
+# [inconsistent distdirs].
+$1_$2_$3_DEPS_LIBS=$$(foreach dep,$$($1_$2_DEPS),$$($$(dep)_$(subst stage2,dist-install,$2)_$3_LIB))
 
 ifeq "$$(BootingFromHc)" "YES"
 $1_$2_$3_C_OBJS += $$(shell $$(FIND) $1/$2/build -name "*_stub.c" -print | sed 's/c$$$$/o/')