From 80c77d5a29ffcbe50103f503f0a0c354b8a92e6f Mon Sep 17 00:00:00 2001 From: maralorn Date: Fri, 23 Sep 2022 04:44:59 +0200 Subject: [PATCH] wrapper.in: Allow runtime ghc-pkgs to be a subset of compile-time ghc-pkgs This still makes sure that ghc has been compiled with the same core libraries as hls while it allows runtime environments where other packages have been added to the ghc-pkg database. This commit also adds that file to the sdist, so that distro packagers can use it. --- GNUmakefile | 1 + bindist/wrapper.in | 9 +++++++-- haskell-language-server.cabal | 1 + 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/GNUmakefile b/GNUmakefile index b9c848798cb..f26c9b4b20b 100644 --- a/GNUmakefile +++ b/GNUmakefile @@ -106,6 +106,7 @@ bindist-ghc: $(SED) \ -e "s/@@EXE_NAME@@/haskell-language-server-$(GHC_VERSION)/" \ -e "s/@@GHC_VERSION@@/$(GHC_VERSION)/" \ + -e "s/@@BOOT_PKGS@@/$(shell ghc-pkg-$(GHC_VERSION) --global list --simple-output)/" \ -e "s/@@ABI_HASHES@@/$(shell for dep in `ghc-pkg-$(GHC_VERSION) --global list --simple-output` ; do printf "%s:" "$$dep" && ghc-pkg-$(GHC_VERSION) field $$dep abi --simple-output ; done | tr '\n' ' ' | xargs)/" \ bindist/wrapper.in > "$(BINDIST_OUT_DIR)/haskell-language-server-$(GHC_VERSION).in" $(CHMOD_X) "$(BINDIST_OUT_DIR)/haskell-language-server-$(GHC_VERSION).in" diff --git a/bindist/wrapper.in b/bindist/wrapper.in index 71804d40ec4..5aa27376e7f 100644 --- a/bindist/wrapper.in +++ b/bindist/wrapper.in @@ -3,6 +3,11 @@ exedir="@@EXE_DIR@@" executablename="@@EXE_NAME@@" GHC_VERSION="@@GHC_VERSION@@" + +# This space separated list contains the names and versions of the libraries present at compiletime of hls in the ghc-pkg database. +# The assumption is that these are the boot packages hls has been compiled with. +BOOT_PKGS="@@BOOT_PKGS@@" +# This space separated list contains the ABI hashes of the pkgs in BOOT_PKGS at compiletime. ABI_HASHES="@@ABI_HASHES@@" debug_msg() { @@ -62,7 +67,7 @@ check_ghc() { # check version if [ "${check_ghc_ver}" = "${GHC_VERSION}" ] ; then - # check ABI + # check for all packages listed in BOOT_PKGS that they are present with the same ABI hash as at hls-compiletime to prevent linking issues. if "${GHC_PKG}" --version >/dev/null ; then : elif "${GHC_PKG}-${GHC_VERSION}" --version >/dev/null ; then @@ -73,7 +78,7 @@ check_ghc() { return 1 fi PKGCONF="${check_ghc_libdir}/package.conf.d" - MY_ABI_HASHES="$(for dep in $("${GHC_PKG}" --global --global-package-db "$PKGCONF" list --simple-output) ; do printf "%s:" "${dep}" && "${GHC_PKG}" --global --global-package-db "$PKGCONF" field "${dep}" abi --simple-output ; done | tr '\n' ' ' | xargs)" + MY_ABI_HASHES="$(for dep in ${BOOT_PKGS} ; do printf "%s:" "${dep}" && "${GHC_PKG}" --global --global-package-db "$PKGCONF" field "${dep}" abi --simple-output ; done | tr '\n' ' ' | xargs)" if [ "${ABI_HASHES}" != "${MY_ABI_HASHES}" ] ; then err_abi "${MY_ABI_HASHES}" return 3 diff --git a/haskell-language-server.cabal b/haskell-language-server.cabal index bf38eefa48a..d6a63b16a19 100644 --- a/haskell-language-server.cabal +++ b/haskell-language-server.cabal @@ -22,6 +22,7 @@ extra-source-files: test/testdata/**/*.cabal test/testdata/**/*.yaml test/testdata/**/*.hs + bindist/wrapper.in flag pedantic description: Enable -Werror