From 0d11176c20feb3e8627e6297735b1b952613896a Mon Sep 17 00:00:00 2001 From: Herbert Valerio Riedel Date: Tue, 18 Jul 2017 23:08:55 +0200 Subject: Enable building Cabal with parsec Cabal's parser has been rewritten in terms of Parsec (which is not enabled yet in Cabal-2.0 by default, but can be enabled by a cabal flag). The plan for Cabal is to drop support for the non-parsec parser, so we need to prepare GHC to cope with new situation. However, this means that lib:Cabal requires three new library dependencies: - parsec - text - mtl What complicates matters is that we need to build `ghc-cabal` early on during the bootstrap phase which currently needs to invoke `ghc --make` directly. So these additional dependencies need to be integrated into the monolithic `ghc --make` invocation which produces the `ghc-cabal` executable. --- .gitmodules | 12 ++++++++++++ ghc.mk | 11 +++++++++-- libraries/mtl | 1 + libraries/parsec | 1 + libraries/text | 1 + mk/warnings.mk | 5 +++++ packages | 3 +++ rules/sdist-ghc-file.mk | 31 +++++++++++++++++++++++++++++++ utils/ghc-cabal/ghc.mk | 25 ++++++++++++++++++++++--- 9 files changed, 85 insertions(+), 5 deletions(-) create mode 160000 libraries/mtl create mode 160000 libraries/parsec create mode 160000 libraries/text diff --git a/.gitmodules b/.gitmodules index 55d360ae10..a2d9bb1e5a 100644 --- a/.gitmodules +++ b/.gitmodules @@ -121,3 +121,15 @@ [submodule ".arc-linters/arcanist-external-json-linter"] path = .arc-linters/arcanist-external-json-linter url = ../arcanist-external-json-linter.git +[submodule "libraries/parsec"] + path = libraries/parsec + url = ../packages/parsec.git + ignore = none +[submodule "libraries/mtl"] + path = libraries/mtl + url = ../packages/mtl.git + ignore = none +[submodule "libraries/text"] + path = libraries/text + url = ../packages/text.git + ignore = none diff --git a/ghc.mk b/ghc.mk index cdab331486..6cb62315cf 100644 --- a/ghc.mk +++ b/ghc.mk @@ -430,7 +430,7 @@ else # CLEANING # programs such as GHC and ghc-pkg, that we do not assume the stage0 # compiler already has installed (or up-to-date enough). -PACKAGES_STAGE0 = binary Cabal/Cabal hpc ghc-boot-th ghc-boot transformers template-haskell ghci +PACKAGES_STAGE0 = binary text transformers mtl parsec Cabal/Cabal hpc ghc-boot-th ghc-boot template-haskell ghci ifeq "$(Windows_Host)" "NO" PACKAGES_STAGE0 += terminfo endif @@ -457,11 +457,17 @@ PACKAGES_STAGE1 += process PACKAGES_STAGE1 += hpc PACKAGES_STAGE1 += pretty PACKAGES_STAGE1 += binary +PACKAGES_STAGE1 += text +PACKAGES_STAGE1 += transformers +PACKAGES_STAGE1 += mtl +PACKAGES_STAGE1 += parsec +# temporary until Cabal switches to parsec mode by default +libraries/Cabal/Cabal_dist-boot_CONFIGURE_OPTS += --flag parsec +libraries/Cabal/Cabal_dist-install_CONFIGURE_OPTS += --flag parsec PACKAGES_STAGE1 += Cabal/Cabal PACKAGES_STAGE1 += ghc-boot-th PACKAGES_STAGE1 += ghc-boot PACKAGES_STAGE1 += template-haskell -PACKAGES_STAGE1 += transformers PACKAGES_STAGE1 += ghc-compact ifeq "$(HADDOCK_DOCS)" "YES" @@ -1263,6 +1269,7 @@ $(eval $(call sdist-ghc-file,compiler,stage2,parser,Parser,y)) $(eval $(call sdist-ghc-file,utils/hpc,dist-install,,HpcParser,y)) $(eval $(call sdist-ghc-file,utils/genprimopcode,dist,,Lexer,x)) $(eval $(call sdist-ghc-file,utils/genprimopcode,dist,,Parser,y)) +$(eval $(call sdist-ghc-file2,libraries/Cabal/Cabal,dist-install,Distribution/Parsec,Lexer,x)) .PHONY: sdist-ghc-prep sdist-ghc-prep : sdist-ghc-prep-tree diff --git a/libraries/mtl b/libraries/mtl new file mode 160000 index 0000000000..b4725fe28c --- /dev/null +++ b/libraries/mtl @@ -0,0 +1 @@ +Subproject commit b4725fe28cba8a535e969e0ddbce3d5e05146ccd diff --git a/libraries/parsec b/libraries/parsec new file mode 160000 index 0000000000..d21d863879 --- /dev/null +++ b/libraries/parsec @@ -0,0 +1 @@ +Subproject commit d21d86387998614de31697a26fd8fec15d40e62b diff --git a/libraries/text b/libraries/text new file mode 160000 index 0000000000..240e1a58e2 --- /dev/null +++ b/libraries/text @@ -0,0 +1 @@ +Subproject commit 240e1a58e2c0cce5b177e3bc30139b905b1060a6 diff --git a/mk/warnings.mk b/mk/warnings.mk index af5f4f51d9..16d13a28ba 100644 --- a/mk/warnings.mk +++ b/mk/warnings.mk @@ -114,6 +114,11 @@ libraries/transformers_dist-install_EXTRA_HC_OPTS += -Wno-unused-matches -Wno-un libraries/transformers_dist-install_EXTRA_HC_OPTS += -Wno-redundant-constraints libraries/transformers_dist-install_EXTRA_HC_OPTS += -Wno-orphans +# parsec has various warnings +libraries/parsec_dist-install_EXTRA_HC_OPTS += -Wno-name-shadowing -Wno-unused-matches +libraries/parsec_dist-install_EXTRA_HC_OPTS += -Wno-unused-do-bind -Wno-missing-signatures +libraries/parsec_dist-install_EXTRA_HC_OPTS += -Wno-unused-imports -Wno-type-defaults + # Turn of trustworthy-safe warning libraries/base_dist-install_EXTRA_HC_OPTS += -Wno-trustworthy-safe libraries/ghc-prim_dist-install_EXTRA_HC_OPTS += -Wno-trustworthy-safe diff --git a/packages b/packages index 6ee80712f2..a44e31687e 100644 --- a/packages +++ b/packages @@ -52,9 +52,12 @@ libraries/directory - - ssh://g libraries/filepath - - ssh://git@github.com/haskell/filepath.git libraries/haskeline - - https://github.com/judah/haskeline.git libraries/hpc - - - +libraries/mtl - - https://github.com/ekmett/mtl.git +libraries/parsec - - https://github.com/haskell/parsec.git libraries/pretty - - https://github.com/haskell/pretty.git libraries/process - - ssh://git@github.com/haskell/process.git libraries/terminfo - - https://github.com/judah/terminfo.git +libraries/text - - https://github.com/bos/text.git libraries/time - - https://github.com/haskell/time.git libraries/transformers - - https://git.haskell.org/darcs-mirrors/transformers.git libraries/unix - - ssh://git@github.com/haskell/unix.git diff --git a/rules/sdist-ghc-file.mk b/rules/sdist-ghc-file.mk index 9ea0b6521a..d6a70e10fb 100644 --- a/rules/sdist-ghc-file.mk +++ b/rules/sdist-ghc-file.mk @@ -44,3 +44,34 @@ sdist_$1_$2_$4 : $1/$2/build/$4.hs # didn't generate all package-data.mk files. $$(eval $$(call hs-suffix-rules-srcdir,$1,$2,$3)) endef + +# ----------------------------------------------------------------------------- +# Variant of sdist-ghc-file whose `$3`-argument is interpreted +# differently in a more appropriate way for cabal-packages + +define sdist-ghc-file2 +# $1 = dir +# $2 = distdir +# $3 = moduledir +# $4 = filename +# $5 = extension + +.PHONY: sdist_$1_$2_$4 + +# We should do this before creating the `sdist-ghc` tarball, or when just +# running `make sdist-ghc-prep`. +sdist-ghc-prep : sdist_$1_$2_$4 + +# But first create SRC_DIST_GHC_DIR. +sdist_$1_$2_$4 : sdist-ghc-prep-tree + +# Generate the .hs files if they don't exist yet, then do actual copying and +# moving. +sdist_$1_$2_$4 : $1/$2/build/$3/$4.hs + "$(CP)" $1/$2/build/$3/$4.hs $(SRC_DIST_GHC_DIR)/$1/$3 + mv $(SRC_DIST_GHC_DIR)/$1/$3/$4.$5 $(SRC_DIST_GHC_DIR)/$1/$3/$4.$5.source + +# And make sure the rules for generating the .hs files exist, even when we +# didn't generate all package-data.mk files. +$$(eval $$(call hs-suffix-rules-srcdir,$1,$2,$3)) +endef diff --git a/utils/ghc-cabal/ghc.mk b/utils/ghc-cabal/ghc.mk index 6250484017..eeae8a715b 100644 --- a/utils/ghc-cabal/ghc.mk +++ b/utils/ghc-cabal/ghc.mk @@ -27,9 +27,9 @@ CABAL_CONSTRAINT := --constraint="Cabal == $(CABAL_DOTTED_VERSION)" # `cabal_macros_boot.h` also for GHC >= 8 (in which case it becomes a # dummy include that doesn't contribute any macro definitions). ifeq "$(Windows_Host)" "YES" -CABAL_BUILD_DEPS := base array time containers bytestring deepseq process pretty directory Win32 +CABAL_BUILD_DEPS := ghc-prim base array transformers time containers bytestring deepseq process pretty directory Win32 else -CABAL_BUILD_DEPS := base array time containers bytestring deepseq process pretty directory unix +CABAL_BUILD_DEPS := ghc-prim base array transformers time containers bytestring deepseq process pretty directory unix endif ghc-cabal_DIST_BINARY_NAME = ghc-cabal$(exeext0) @@ -40,11 +40,23 @@ ifneq "$(BINDIST)" "YES" $(ghc-cabal_INPLACE) : $(ghc-cabal_DIST_BINARY) | $$(dir $$@)/. "$(CP)" $< $@ +# Minor hack, since we can't reuse the `hs-suffix-rules-srcdir` macro +ifneq ($(wildcard libraries/Cabal/Cabal/Distribution/Parsec/Lexer.x),) +# Lexer.x exists so we have to call Alex ourselves +CABAL_LEXER_DEP := bootstrapping/Cabal/Distribution/Parsec/Lexer.hs + +bootstrapping/Cabal/Distribution/Parsec/Lexer.hs: libraries/Cabal/Cabal/Distribution/Parsec/Lexer.x + mkdir -p bootstrapping/Cabal/Distribution/Parsec + $(call cmd,ALEX) $< -o $@ +else +CABAL_LEXER_DEP := libraries/Cabal/Cabal/Distribution/Parsec/Lexer.hs +endif + $(ghc-cabal_DIST_BINARY): $(wildcard libraries/Cabal/Cabal/Distribution/*/*/*.hs) $(ghc-cabal_DIST_BINARY): $(wildcard libraries/Cabal/Cabal/Distribution/*/*.hs) $(ghc-cabal_DIST_BINARY): $(wildcard libraries/Cabal/Cabal/Distribution/*.hs) -$(ghc-cabal_DIST_BINARY): utils/ghc-cabal/Main.hs $(TOUCH_DEP) | $$(dir $$@)/. bootstrapping/. +$(ghc-cabal_DIST_BINARY): $(CABAL_LEXER_DEP) utils/ghc-cabal/Main.hs $(TOUCH_DEP) | $$(dir $$@)/. bootstrapping/. "$(GHC)" $(SRC_HC_OPTS) \ $(addprefix -optc, $(SRC_CC_OPTS) $(CONF_CC_OPTS_STAGE0)) \ $(addprefix -optl, $(SRC_LD_OPTS) $(CONF_GCC_LINKER_OPTS_STAGE0)) \ @@ -54,14 +66,21 @@ $(ghc-cabal_DIST_BINARY): utils/ghc-cabal/Main.hs $(TOUCH_DEP) | $$(dir $$@)/. b -no-user-$(GHC_PACKAGE_DB_FLAG) \ -Wall -fno-warn-unused-imports -fno-warn-warnings-deprecations \ -DCABAL_VERSION=$(CABAL_VERSION) \ + -DCABAL_PARSEC \ -DBOOTSTRAPPING \ -optP-include -optPutils/ghc-cabal/cabal_macros_boot.h \ -odir bootstrapping \ -hidir bootstrapping \ + $(CABAL_LEXER_DEP) \ -ilibraries/Cabal/Cabal \ -ilibraries/binary/src \ -ilibraries/filepath \ -ilibraries/hpc \ + -ilibraries/mtl \ + -ilibraries/text \ + libraries/text/cbits/cbits.c \ + -Ilibraries/text/include \ + -ilibraries/parsec \ $(utils/ghc-cabal_dist_EXTRA_HC_OPTS) \ $(EXTRA_HC_OPTS) "$(TOUCH_CMD)" $@ -- cgit v1.2.1