[commit: ghc] master: Build the stage0 ghc-pkg with Cabal (ac5a314)

Ian Lynagh igloo at earth.li
Sat Feb 16 18:22:31 CET 2013


Repository : ssh://darcs.haskell.org//srv/darcs/ghc

On branch  : master

http://hackage.haskell.org/trac/ghc/changeset/ac5a314504554ddef0e855ef9e2fcf51e961f4a6

>---------------------------------------------------------------

commit ac5a314504554ddef0e855ef9e2fcf51e961f4a6
Author: Ian Lynagh <ian at well-typed.com>
Date:   Sat Feb 16 15:39:32 2013 +0000

    Build the stage0 ghc-pkg with Cabal
    
    This solves the problem of how to define MIN_VERSION_base for
    the binary package.
    
    Also fixed a couple of build system bugs along the way.

>---------------------------------------------------------------

 ghc.mk                 |   10 ++++---
 rules/build-package.mk |    1 +
 rules/build-prog.mk    |    6 ++--
 utils/ghc-pkg/ghc.mk   |   69 +++++++++---------------------------------------
 4 files changed, 23 insertions(+), 63 deletions(-)

diff --git a/ghc.mk b/ghc.mk
index 3e926dc..c354632 100644
--- a/ghc.mk
+++ b/ghc.mk
@@ -355,7 +355,7 @@ PKGS_THAT_USE_TH := $(PKGS_THAT_ARE_DPH)
 #
 # We assume that the stage0 compiler has a suitable bytestring package,
 # so we don't have to include it below.
-PKGS_THAT_BUILD_WITH_STAGE0 = Cabal/Cabal hpc binary bin-package-db hoopl transformers
+PKGS_THAT_BUILD_WITH_STAGE0 = Cabal/Cabal hpc binary bin-package-db hoopl transformers terminfo
 
 # $(EXTRA_PACKAGES)  is another classification, of packages built but
 #                    not installed
@@ -464,7 +464,7 @@ $(eval $(call extra-packages))
 # parallelism, but we don't know the dependencies until we've
 # generated the package-data.mk files.
 define fixed_pkg_dep
-libraries/$1/$2/package-data.mk : $$(GHC_PKG_INPLACE) $$(fixed_pkg_prev)
+libraries/$1/$2/package-data.mk : $$(fixed_pkg_prev)
 fixed_pkg_prev:=libraries/$1/$2/package-data.mk
 endef
 
@@ -738,8 +738,8 @@ $(eval $(call clean-target,$(BOOTSTRAPPING_CONF),,$(BOOTSTRAPPING_CONF)))
 # lost).
 fixed_pkg_prev=
 $(foreach pkg,$(PACKAGES_STAGE0),$(eval $(call fixed_pkg_dep,$(pkg),dist-boot)))
-
-compiler/stage1/package-data.mk : $(fixed_pkg_prev)
+utils/ghc-pkg/dist/package-data.mk: $(fixed_pkg_prev)
+compiler/stage1/package-data.mk:    $(fixed_pkg_prev)
 endif
 
 ifneq "$(BINDIST)" "YES"
@@ -1333,6 +1333,8 @@ endif
 # Numbered phase targets
 
 .PHONY: phase_0_builds
+phase_0_builds: $(utils/ghc-pkg_dist_depfile_haskell)
+phase_0_builds: $(utils/ghc-pkg_dist_depfile_c_asm)
 phase_0_builds: $(utils/hsc2hs_dist_depfile_haskell)
 phase_0_builds: $(utils/hsc2hs_dist_depfile_c_asm)
 phase_0_builds: $(utils/genprimopcode_dist_depfile_haskell)
diff --git a/rules/build-package.mk b/rules/build-package.mk
index 47b706e..8b9723b 100644
--- a/rules/build-package.mk
+++ b/rules/build-package.mk
@@ -123,6 +123,7 @@ $$(foreach way,$$($1_$2_WAYS),$$(eval \
 # If dyn libs are not being built then $$($1_$2_dyn_LIB) will just
 # expand to the empty string, and be ignored.
 $1_$2_PROGRAM_DEP_LIB = $$($1_$2_v_LIB) $$($1_$2_dyn_LIB)
+$$($1_PACKAGE)-$$($1_$2_VERSION)_$2_PROGRAM_DEP_LIB = $$($1_$2_PROGRAM_DEP_LIB)
 
 # C and S files are possibly built the "dyn" way.
 ifeq "$$(BuildSharedLibs)" "YES"
diff --git a/rules/build-prog.mk b/rules/build-prog.mk
index 0419c3b..400c620 100644
--- a/rules/build-prog.mk
+++ b/rules/build-prog.mk
@@ -186,13 +186,13 @@ ifneq "$$(BINDIST)" "YES"
 # The quadrupled $'s here are because the _<way>_LIB variables aren't
 # necessarily set when this part of the makefile is read
 $1/$2/build/tmp/$$($1_$2_PROG) : \
-    $$(foreach dep,$$($1_$2_DEP_NAMES),\
-        $$(if $$(filter ghc,$$(dep)),\
+    $$(foreach dep,$$($1_$2_DEPS),\
+        $$(if $$(filter ghc%,$$(dep)),\
             $(if $(filter 0,$3),$$(compiler_stage1_PROGRAM_DEP_LIB),\
             $(if $(filter 1,$3),$$(compiler_stage2_PROGRAM_DEP_LIB),\
             $(if $(filter 2,$3),$$(compiler_stage2_PROGRAM_DEP_LIB),\
             $$(error Bad build stage)))),\
-        $$$$(libraries/$$(dep)_dist-$(if $(filter 0,$3),boot,install)_PROGRAM_DEP_LIB)))
+        $$$$($$(dep)_dist-$(if $(filter 0,$3),boot,install)_PROGRAM_DEP_LIB)))
 
 ifeq "$$($1_$2_LINK_WITH_GCC)" "NO"
 $1/$2/build/tmp/$$($1_$2_PROG) : $$($1_$2_$$($1_$2_PROGRAM_WAY)_HS_OBJS) $$($1_$2_$$($1_$2_PROGRAM_WAY)_C_OBJS) $$($1_$2_$$($1_$2_PROGRAM_WAY)_S_OBJS) $$($1_$2_OTHER_OBJS) | $$$$(dir $$$$@)/.
diff --git a/utils/ghc-pkg/ghc.mk b/utils/ghc-pkg/ghc.mk
index d904c48..fac39e8 100644
--- a/utils/ghc-pkg/ghc.mk
+++ b/utils/ghc-pkg/ghc.mk
@@ -15,60 +15,6 @@
 
 utils/ghc-pkg_dist_PROG = ghc-pkg$(exeext)
 
-ifeq "$(BootingFromHc)" "YES"
-
-inplace/bin/ghc-pkg : utils/ghc-pkg/dist-install/build/tmp/$(utils/ghc-pkg_dist_PROG)$(exeext)
-ifeq "$(Windows)" "YES"
-	cp $< $@
-else
-	$(call removeFiles,$@)
-	echo "#!/bin/sh" >>$@
-	echo "PKGCONF=$(TOP)/$(INPLACE_PACKAGE_CONF)" >>$@
-	echo '$(TOP)/$< --global-package-db $$PKGCONF $${1+"$$@"}' >> $@
-	chmod +x $@
-endif
-
-else
-
-$(GHC_PKG_INPLACE) : utils/ghc-pkg/dist/build/tmp/$(utils/ghc-pkg_dist_PROG)$(exeext) | $$(dir $$@)/. $(INPLACE_PACKAGE_CONF)/.
-	$(call removeFiles,$(wildcard $(INPLACE_PACKAGE_CONF)/*))
-ifeq "$(Windows)" "YES"
-	cp $< $@
-else
-	$(call removeFiles,$@)
-	echo "#!/bin/sh" >>$@
-	echo "PKGCONF=$(TOP)/$(INPLACE_PACKAGE_CONF)" >>$@
-	echo '$(TOP)/$< --global-package-db $$PKGCONF $${1+"$$@"}' >> $@
-	chmod +x $@
-endif
-
-endif
-
-# depend on ghc-cabal, otherwise we build Cabal twice when building in parallel.
-# (ghc-cabal is an order-only dependency, we don't need to rebuild ghc-pkg
-# if ghc-cabal is newer).
-# The binary package is not warning-clean, so we need a few -fno-warns here.
-#
-# ToDo: we might want to do this using ghc-cabal instead.
-#
-utils/ghc-pkg/dist/build/tmp/$(utils/ghc-pkg_dist_PROG)$(exeext): utils/ghc-pkg/Main.hs utils/ghc-pkg/dist/build/Version.hs | bootstrapping/. $$(dir $$@)/. $(GHC_CABAL_INPLACE) 
-	"$(GHC)" $(SRC_HC_OPTS) --make utils/ghc-pkg/Main.hs -o $@ \
-	       -no-user-$(GHC_PACKAGE_DB_FLAG) \
-	       -Wall -fno-warn-unused-imports -fno-warn-warnings-deprecations \
-	       $(SRC_HC_WARNING_OPTS) \
-	       -DCABAL_VERSION=$(CABAL_VERSION) \
-	       -DBOOTSTRAPPING \
-	       -odir  bootstrapping \
-	       -hidir bootstrapping \
-	       -iutils/ghc-pkg \
-	       -iutils/ghc-pkg/dist/build \
-	       -ilibraries/Cabal/Cabal \
-	       -ilibraries/filepath \
-	       -ilibraries/hpc \
-	       -ilibraries/binary/src \
-	       -ilibraries/bin-package-db
-
-
 utils/ghc-pkg/dist/build/Version.hs \
 utils/ghc-pkg/dist-install/build/Version.hs: mk/project.mk | $$(dir $$@)/.
 	$(call removeFiles,$@)
@@ -78,7 +24,7 @@ utils/ghc-pkg/dist-install/build/Version.hs: mk/project.mk | $$(dir $$@)/.
 	echo "targetOS   = \"$(TargetOS_CPP)\""        >> $@
 	echo "targetARCH = \"$(TargetArch_CPP)\""      >> $@
 
-$(eval $(call clean-target,utils/ghc-pkg,dist,utils/ghc-pkg/dist))
+utils/ghc-pkg_PACKAGE = ghc-pkg
 
 # -----------------------------------------------------------------------------
 # Cross-compile case: install our dist version
@@ -96,13 +42,24 @@ $(eval $(call shell-wrapper,utils/ghc-pkg,dist))
 
 endif
 
+utils/ghc-pkg_dist_USES_CABAL = YES
+utils/ghc-pkg_dist_PROG = ghc-pkg
+utils/ghc-pkg_dist_SHELL_WRAPPER = YES
+utils/ghc-pkg_dist_INSTALL_INPLACE = YES
+
+$(eval $(call build-prog,utils/ghc-pkg,dist,0))
+
+$(GHC_PKG_INPLACE) : | $(INPLACE_PACKAGE_CONF)/.
+
+utils/ghc-pkg/dist/package-data.mk: \
+    utils/ghc-pkg/dist/build/Version.hs
+
 # -----------------------------------------------------------------------------
 # Normal case: Build ghc-pkg with stage 1 and install it
 
 ifneq "$(Stage1Only)" "YES"
 
 utils/ghc-pkg_dist-install_USES_CABAL = YES
-utils/ghc-pkg_PACKAGE = ghc-pkg
 
 utils/ghc-pkg_dist-install_PROG = ghc-pkg
 utils/ghc-pkg_dist-install_SHELL_WRAPPER = YES





More information about the ghc-commits mailing list