Commit ac5a3145 authored by ian@well-typed.com's avatar ian@well-typed.com

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.
parent 4c821f0c
......@@ -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)
......
......@@ -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"
......
......@@ -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 $$$$@)/.
......
......@@ -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
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment