Skip to content

Commit

Permalink
wrapper.in: Allow runtime ghc-pkgs to be a subset of compile-time ghc…
Browse files Browse the repository at this point in the history
…-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.
  • Loading branch information
maralorn committed Sep 25, 2022
1 parent b289e48 commit 80c77d5
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 2 deletions.
1 change: 1 addition & 0 deletions GNUmakefile
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
9 changes: 7 additions & 2 deletions bindist/wrapper.in
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down
1 change: 1 addition & 0 deletions haskell-language-server.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ extra-source-files:
test/testdata/**/*.cabal
test/testdata/**/*.yaml
test/testdata/**/*.hs
bindist/wrapper.in

flag pedantic
description: Enable -Werror
Expand Down

0 comments on commit 80c77d5

Please # to comment.