From 8ff3808d09b91805cee62307b22dabd399b7a565 Mon Sep 17 00:00:00 2001 From: Julian Ospald Date: Tue, 1 Feb 2022 16:51:54 +0100 Subject: [PATCH 01/33] Implement distribution of dynamic builds --- .gitignore | 3 ++ Makefile | 69 +++++++++++++++++++++++++++++++++++++++++++++ bindist/Makefile.in | 28 ++++++++++++++++++ bindist/ghcs | 3 ++ bindist/wrapper.in | 38 +++++++++++++++++++++++++ 5 files changed, 141 insertions(+) create mode 100644 Makefile create mode 100644 bindist/Makefile.in create mode 100644 bindist/ghcs create mode 100644 bindist/wrapper.in diff --git a/.gitignore b/.gitignore index 97cc352475..9a9e3dd5e9 100644 --- a/.gitignore +++ b/.gitignore @@ -45,3 +45,6 @@ test/testdata/**/hie.yaml # nix result result-doc + +out/ +store/ diff --git a/Makefile b/Makefile new file mode 100644 index 0000000000..3dde22f8d2 --- /dev/null +++ b/Makefile @@ -0,0 +1,69 @@ +ROOT_DIR:=$(shell dirname $(realpath $(firstword $(MAKEFILE_LIST)))) + +GHC_VERSION ?= +HLS_VERSION ?= + +ifndef HLS_VERSION +$(error HLS_VERSION is not set) +endif + +CHMOD := chmod +INSTALL := install +PATCHELF := patchelf +FIND := find +SED := sed +MKDIR := mkdir +TAR := tar +CABAL := cabal +AWK := awk + +STORE_DIR := store +BINDIST_BASE_DIR := out/bindist +BINDIST_OUT_DIR := $(BINDIST_BASE_DIR)/haskell-language-server-$(HLS_VERSION) + +CABAL_ARGS ?= --store-dir=$(ROOT_DIR)/$(STORE_DIR) +CABAL_INSTALL_ARGS ?= --overwrite-policy=always --install-method=copy --installdir=$(ROOT_DIR)/out + +hls: bindist/ghcs + for ghc in $(shell cat bindist/ghcs) ; do \ + $(MAKE) GHC_VERSION=`echo $$ghc | $(AWK) -F ',' '{ print $$1 }'` PROJECT_FILE=`echo $$ghc | $(AWK) -F ',' '{ print $$2 }'` hls-ghc ; \ + done + +hls-ghc: + @if test -z "$(GHC_VERSION)" ; then echo >&2 "GHC_VERSION is not set" ; false ; fi + @if test -z "$(PROJECT_FILE)" ; then echo >&2 "PROJECT_FILE is not set" ; false ; fi + $(CABAL) $(CABAL_ARGS) v2-install --project-file=$(PROJECT_FILE) -w ghc-$(GHC_VERSION) $(CABAL_INSTALL_ARGS) + +bindist: + for ghc in $(shell cat bindist/ghcs) ; do \ + $(MAKE) GHC_VERSION=$$ghc bindist-ghc ; \ + done + $(SED) -e "s/@@HLS_VERSION@@/$(HLS_VERSION)/" \ + bindist/Makefile.in > $(BINDIST_OUT_DIR)/Makefile + cd $(BINDIST_BASE_DIR) ; $(TAR) caf $(ROOT_DIR)/out/haskell-language-server-$(HLS_VERSION).tar.xz haskell-language-server-$(HLS_VERSION) + +bindist-ghc: + if test -z "$(GHC_VERSION)" ; then echo >&2 "GHC_VERSION is not set" ; false ; fi + $(MKDIR) -p $(BINDIST_OUT_DIR)/bin + $(MKDIR) -p $(BINDIST_OUT_DIR)/lib/$(GHC_VERSION) + $(SED) -e "s/@@EXE_NAME@@/haskell-language-server-$(GHC_VERSION)/" -e "s/@@GHC_VERSION@@/$(GHC_VERSION)/" \ + bindist/wrapper.in > $(BINDIST_OUT_DIR)/haskell-language-server-$(GHC_VERSION) + $(SED) -e 's/@@EXE_NAME@@/haskell-language-server-wrapper/' -e "s/@@GHC_VERSION@@/$(GHC_VERSION)/" \ + bindist/wrapper.in > $(BINDIST_OUT_DIR)/haskell-language-server-wrapper + $(CHMOD) 755 $(BINDIST_OUT_DIR)/haskell-language-server-$(GHC_VERSION) + $(CHMOD) 755 $(BINDIST_OUT_DIR)/haskell-language-server-wrapper + $(INSTALL) -vDm 755 out/haskell-language-server $(BINDIST_OUT_DIR)/bin/haskell-language-server-$(GHC_VERSION) + $(PATCHELF) --set-rpath \$$ORIGIN/../lib/$(GHC_VERSION) $(BINDIST_OUT_DIR)/bin/haskell-language-server-$(GHC_VERSION) + $(INSTALL) -vDm 755 out/haskell-language-server-wrapper $(BINDIST_OUT_DIR)/bin/haskell-language-server-wrapper + $(PATCHELF) --set-rpath \$$ORIGIN/../lib/$(GHC_VERSION) $(BINDIST_OUT_DIR)/bin/haskell-language-server-wrapper + $(FIND) $(STORE_DIR) -type f -name '*.so' -execdir install -vDm 755 {} $(ROOT_DIR)/$(BINDIST_OUT_DIR)/lib/$(GHC_VERSION)/{} \; + $(FIND) $(ROOT_DIR)/$(BINDIST_OUT_DIR)/lib/$(GHC_VERSION) -type f -name '*.so' -execdir $(PATCHELF) --set-rpath \$$ORIGIN {} \; + + +clean: + rm -rf $(BINDIST_BASE_DIR) + +clean-all: + rm -rf $(BINDIST_BASE_DIR) $(STORE_DIR) + +.PHONY: hls hls-ghc bindist bindist-ghc clean clean-all diff --git a/bindist/Makefile.in b/bindist/Makefile.in new file mode 100644 index 0000000000..90e58c2c63 --- /dev/null +++ b/bindist/Makefile.in @@ -0,0 +1,28 @@ +DESTDIR ?= +PREFIX ?= /usr/local +LIBDIR ?= $(PREFIX)/lib +BINDIR ?= $(PREFIX)/bin + +HLS_VERSION := @@HLS_VERSION@@ + +INSTALL := install +SED := sed +CHMOD := chmod + +install: + $(INSTALL) -d $(BINDIR) + $(INSTALL) -d $(LIBDIR)/haskell-language-server-$(HLS_VERSION)/lib + $(INSTALL) -d $(LIBDIR)/haskell-language-server-$(HLS_VERSION)/bin + for f in $(wildcard lib/*/*) ; do \ + $(INSTALL) -vDm 755 $$f $(LIBDIR)/haskell-language-server-$(HLS_VERSION)/$$f ; \ + done + for b in $(wildcard bin/*) ; do \ + $(INSTALL) -vDm 755 $$b $(LIBDIR)/haskell-language-server-$(HLS_VERSION)/$$b ; \ + done + for h in $(wildcard haskell-language-server-*) ; do \ + $(SED) -e "s#@@EXE_DIR@@#$(LIBDIR)/haskell-language-server-$(HLS_VERSION)/bin/#" \ + $$h > $(BINDIR)/$$h ; \ + $(CHMOD) 755 $(BINDIR)/$$h ; \ + done + +.PHONY: install diff --git a/bindist/ghcs b/bindist/ghcs new file mode 100644 index 0000000000..f61eef13e6 --- /dev/null +++ b/bindist/ghcs @@ -0,0 +1,3 @@ +8.10.7,cabal.project +9.0.2,cabal-ghc90.project +9.2.1,cabal-ghc921.project diff --git a/bindist/wrapper.in b/bindist/wrapper.in new file mode 100644 index 0000000000..307956eb48 --- /dev/null +++ b/bindist/wrapper.in @@ -0,0 +1,38 @@ +#!/bin/sh + +exedir="@@EXE_DIR@@" +executablename="@@EXE_NAME@@" +GHC_VERSION="@@GHC_VERSION@@" + +if [ -n "${GHC_LIBDIR}" ] ; then + : +else + if [ -n "${GHC_BIN}" ] && command -v "${GHC_BIN}" >/dev/null ; then + ghc_bin=${GHC_BIN} + elif command -v ghc-${GHC_VERSION} >/dev/null ; then + ghc_bin=ghc-${GHC_VERSION} + elif command -v ghc >/dev/null ; then + ghc_bin=ghc + else + echo >&2 "Could not find a GHC installation!" + echo >&2 "Consider setting GHC_LIBDIR to the top-level directory of GHC shipped libraries (version ${GHC_VERSION})" + exit 42 + fi + + GHC_LIBDIR=$(${ghc_bin} --print-libdir) + ghc_ver="$(${ghc_bin} --numeric-version)" + if [ "${GHC_VERSION}" != "${ghc_ver}" ] ; then + echo >&2 "Need GHC version ${GHC_VERSION}, got ${ghc_ver}... trying anyway" + fi + unset ghc_ver ghc_bin +fi + +if [ -n "$LD_LIBRARY_PATH" ] ; then + LD_LIBRARY_PATH="$(for i in "${GHC_LIBDIR}"/* ; do [ -d "$i" ] && printf "%s" "$i:" ; done)$LD_LIBRARY_PATH" + export LD_LIBRARY_PATH +else + LD_LIBRARY_PATH="$(for i in "${GHC_LIBDIR}"/* ; do [ -d "$i" ] && printf "%s" "$i:" ; done | sed 's/:$//')" + export LD_LIBRARY_PATH +fi + +exec "${exedir}/${executablename}" ${1+"$@"} From ce17b1102812ed64c9bb076505747698f1e358af Mon Sep 17 00:00:00 2001 From: Julian Ospald Date: Tue, 1 Feb 2022 20:48:42 +0100 Subject: [PATCH 02/33] Use ghcup to detect GHC libdir, if available --- bindist/wrapper.in | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/bindist/wrapper.in b/bindist/wrapper.in index 307956eb48..30d4f227c9 100644 --- a/bindist/wrapper.in +++ b/bindist/wrapper.in @@ -4,9 +4,16 @@ exedir="@@EXE_DIR@@" executablename="@@EXE_NAME@@" GHC_VERSION="@@GHC_VERSION@@" +# try GHC_LIBDIR from the environment (e.g. user set it) if [ -n "${GHC_LIBDIR}" ] ; then : -else +# try ghcup, if available +elif command -v ghcup >/dev/null ; then + GHC_LIBDIR="$(ghcup whereis -d ghc ${GHC_VERSION})/../lib/ghc-${GHC_VERSION}/" || unset GHC_LIBDIR +fi + +# if above failed, try to examine ghc in PATH +if [ -z "${GHC_LIBDIR}" ] ; then if [ -n "${GHC_BIN}" ] && command -v "${GHC_BIN}" >/dev/null ; then ghc_bin=${GHC_BIN} elif command -v ghc-${GHC_VERSION} >/dev/null ; then @@ -27,6 +34,11 @@ else unset ghc_ver ghc_bin fi +if [ -z "${GHC_LIBDIR}" ] ; then + echo >&2 "Failed to find GHC libdir!" + exit 42 +fi + if [ -n "$LD_LIBRARY_PATH" ] ; then LD_LIBRARY_PATH="$(for i in "${GHC_LIBDIR}"/* ; do [ -d "$i" ] && printf "%s" "$i:" ; done)$LD_LIBRARY_PATH" export LD_LIBRARY_PATH From b38b1f6ab4c3bf37bb5d9c18029c5120706b5587 Mon Sep 17 00:00:00 2001 From: Julian Ospald Date: Tue, 1 Feb 2022 20:52:45 +0100 Subject: [PATCH 03/33] Factor out error function --- bindist/wrapper.in | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/bindist/wrapper.in b/bindist/wrapper.in index 30d4f227c9..9f0c29f340 100644 --- a/bindist/wrapper.in +++ b/bindist/wrapper.in @@ -4,6 +4,14 @@ exedir="@@EXE_DIR@@" executablename="@@EXE_NAME@@" GHC_VERSION="@@GHC_VERSION@@" +fail_libdir() { + echo >&2 "Could not find a GHC installation!" + echo >&2 "Consider setting GHC_LIBDIR env variable to the top-level directory of GHC shipped libraries (version ${GHC_VERSION})." + echo >&2 "This is needed to find dynamic libraries." + echo >&2 "exiting..." + exit 42 +} + # try GHC_LIBDIR from the environment (e.g. user set it) if [ -n "${GHC_LIBDIR}" ] ; then : @@ -21,9 +29,7 @@ if [ -z "${GHC_LIBDIR}" ] ; then elif command -v ghc >/dev/null ; then ghc_bin=ghc else - echo >&2 "Could not find a GHC installation!" - echo >&2 "Consider setting GHC_LIBDIR to the top-level directory of GHC shipped libraries (version ${GHC_VERSION})" - exit 42 + fail_libdir fi GHC_LIBDIR=$(${ghc_bin} --print-libdir) @@ -35,8 +41,7 @@ if [ -z "${GHC_LIBDIR}" ] ; then fi if [ -z "${GHC_LIBDIR}" ] ; then - echo >&2 "Failed to find GHC libdir!" - exit 42 + fail_libdir fi if [ -n "$LD_LIBRARY_PATH" ] ; then From bb32ffab362f8c1a4955b5a0c3490a295ee6c218 Mon Sep 17 00:00:00 2001 From: Julian Ospald Date: Tue, 1 Feb 2022 21:39:12 +0100 Subject: [PATCH 04/33] Fix building for multiple GHCs --- Makefile | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/Makefile b/Makefile index 3dde22f8d2..fc7dd15cb8 100644 --- a/Makefile +++ b/Makefile @@ -22,7 +22,7 @@ BINDIST_BASE_DIR := out/bindist BINDIST_OUT_DIR := $(BINDIST_BASE_DIR)/haskell-language-server-$(HLS_VERSION) CABAL_ARGS ?= --store-dir=$(ROOT_DIR)/$(STORE_DIR) -CABAL_INSTALL_ARGS ?= --overwrite-policy=always --install-method=copy --installdir=$(ROOT_DIR)/out +CABAL_INSTALL_ARGS ?= --overwrite-policy=always --install-method=copy hls: bindist/ghcs for ghc in $(shell cat bindist/ghcs) ; do \ @@ -32,11 +32,11 @@ hls: bindist/ghcs hls-ghc: @if test -z "$(GHC_VERSION)" ; then echo >&2 "GHC_VERSION is not set" ; false ; fi @if test -z "$(PROJECT_FILE)" ; then echo >&2 "PROJECT_FILE is not set" ; false ; fi - $(CABAL) $(CABAL_ARGS) v2-install --project-file=$(PROJECT_FILE) -w ghc-$(GHC_VERSION) $(CABAL_INSTALL_ARGS) + $(CABAL) $(CABAL_ARGS) v2-install --project-file=$(PROJECT_FILE) -w ghc-$(GHC_VERSION) $(CABAL_INSTALL_ARGS) --installdir=$(ROOT_DIR)/out/$(GHC_VERSION) bindist: for ghc in $(shell cat bindist/ghcs) ; do \ - $(MAKE) GHC_VERSION=$$ghc bindist-ghc ; \ + $(MAKE) GHC_VERSION=`echo $$ghc | $(AWK) -F ',' '{ print $$1 }'` bindist-ghc ; \ done $(SED) -e "s/@@HLS_VERSION@@/$(HLS_VERSION)/" \ bindist/Makefile.in > $(BINDIST_OUT_DIR)/Makefile @@ -52,11 +52,11 @@ bindist-ghc: bindist/wrapper.in > $(BINDIST_OUT_DIR)/haskell-language-server-wrapper $(CHMOD) 755 $(BINDIST_OUT_DIR)/haskell-language-server-$(GHC_VERSION) $(CHMOD) 755 $(BINDIST_OUT_DIR)/haskell-language-server-wrapper - $(INSTALL) -vDm 755 out/haskell-language-server $(BINDIST_OUT_DIR)/bin/haskell-language-server-$(GHC_VERSION) + $(INSTALL) -vDm 755 out/$(GHC_VERSION)/haskell-language-server $(BINDIST_OUT_DIR)/bin/haskell-language-server-$(GHC_VERSION) $(PATCHELF) --set-rpath \$$ORIGIN/../lib/$(GHC_VERSION) $(BINDIST_OUT_DIR)/bin/haskell-language-server-$(GHC_VERSION) - $(INSTALL) -vDm 755 out/haskell-language-server-wrapper $(BINDIST_OUT_DIR)/bin/haskell-language-server-wrapper + $(INSTALL) -vDm 755 out/$(GHC_VERSION)/haskell-language-server-wrapper $(BINDIST_OUT_DIR)/bin/haskell-language-server-wrapper $(PATCHELF) --set-rpath \$$ORIGIN/../lib/$(GHC_VERSION) $(BINDIST_OUT_DIR)/bin/haskell-language-server-wrapper - $(FIND) $(STORE_DIR) -type f -name '*.so' -execdir install -vDm 755 {} $(ROOT_DIR)/$(BINDIST_OUT_DIR)/lib/$(GHC_VERSION)/{} \; + $(FIND) $(STORE_DIR)/ghc-$(GHC_VERSION) -type f -name "*.so" -execdir install -vDm 755 {} $(ROOT_DIR)/$(BINDIST_OUT_DIR)/lib/$(GHC_VERSION)/{} \; $(FIND) $(ROOT_DIR)/$(BINDIST_OUT_DIR)/lib/$(GHC_VERSION) -type f -name '*.so' -execdir $(PATCHELF) --set-rpath \$$ORIGIN {} \; From f7beb71c985b7b345ddbe9a5cb56853bd01db752 Mon Sep 17 00:00:00 2001 From: Julian Ospald Date: Tue, 1 Feb 2022 22:18:28 +0100 Subject: [PATCH 05/33] Add version rule to bindist Makefile --- bindist/Makefile.in | 3 +++ 1 file changed, 3 insertions(+) diff --git a/bindist/Makefile.in b/bindist/Makefile.in index 90e58c2c63..5d719757c1 100644 --- a/bindist/Makefile.in +++ b/bindist/Makefile.in @@ -25,4 +25,7 @@ install: $(CHMOD) 755 $(BINDIR)/$$h ; \ done +version: + @echo $(HLS_VERSION) + .PHONY: install From b6e576e4a90f420825faf0a047cd95ce286d67ce Mon Sep 17 00:00:00 2001 From: Julian Ospald Date: Wed, 2 Feb 2022 15:05:45 +0100 Subject: [PATCH 06/33] Do libdir detection in haskell-language-server-wrapper --- Makefile | 36 ++-- bindist/Makefile.in | 3 + bindist/relpath.sh | 53 ++++++ bindist/wrapper.in | 11 +- exe/Wrapper.hs | 32 +++- haskell-language-server.cabal | 4 + src/Ide/Arguments.hs | 304 +++++++++++++++++----------------- src/Ide/Main.hs | 1 + 8 files changed, 272 insertions(+), 172 deletions(-) create mode 100755 bindist/relpath.sh diff --git a/Makefile b/Makefile index fc7dd15cb8..aa2d787e61 100644 --- a/Makefile +++ b/Makefile @@ -1,11 +1,8 @@ ROOT_DIR:=$(shell dirname $(realpath $(firstword $(MAKEFILE_LIST)))) GHC_VERSION ?= -HLS_VERSION ?= -ifndef HLS_VERSION -$(error HLS_VERSION is not set) -endif +HLS_VERSION := $(shell grep '^version:' haskell-language-server.cabal | awk '{ print $$2 }') CHMOD := chmod INSTALL := install @@ -22,7 +19,7 @@ BINDIST_BASE_DIR := out/bindist BINDIST_OUT_DIR := $(BINDIST_BASE_DIR)/haskell-language-server-$(HLS_VERSION) CABAL_ARGS ?= --store-dir=$(ROOT_DIR)/$(STORE_DIR) -CABAL_INSTALL_ARGS ?= --overwrite-policy=always --install-method=copy +CABAL_INSTALL_ARGS ?= --enable-executable-stripping --disable-tests --disable-profiling -O2 --overwrite-policy=always --install-method=copy hls: bindist/ghcs for ghc in $(shell cat bindist/ghcs) ; do \ @@ -32,7 +29,7 @@ hls: bindist/ghcs hls-ghc: @if test -z "$(GHC_VERSION)" ; then echo >&2 "GHC_VERSION is not set" ; false ; fi @if test -z "$(PROJECT_FILE)" ; then echo >&2 "PROJECT_FILE is not set" ; false ; fi - $(CABAL) $(CABAL_ARGS) v2-install --project-file=$(PROJECT_FILE) -w ghc-$(GHC_VERSION) $(CABAL_INSTALL_ARGS) --installdir=$(ROOT_DIR)/out/$(GHC_VERSION) + $(CABAL) $(CABAL_ARGS) v2-install --project-file=$(PROJECT_FILE) -w ghc-$(GHC_VERSION) $(CABAL_INSTALL_ARGS) --installdir=$(ROOT_DIR)/out/$(GHC_VERSION) exe:haskell-language-server exe:haskell-language-server-wrapper bindist: for ghc in $(shell cat bindist/ghcs) ; do \ @@ -40,30 +37,39 @@ bindist: done $(SED) -e "s/@@HLS_VERSION@@/$(HLS_VERSION)/" \ bindist/Makefile.in > $(BINDIST_OUT_DIR)/Makefile + $(INSTALL) -vDm 755 bindist/relpath.sh $(BINDIST_OUT_DIR)/scripts/relpath.sh + +tar-bindist: cd $(BINDIST_BASE_DIR) ; $(TAR) caf $(ROOT_DIR)/out/haskell-language-server-$(HLS_VERSION).tar.xz haskell-language-server-$(HLS_VERSION) bindist-ghc: if test -z "$(GHC_VERSION)" ; then echo >&2 "GHC_VERSION is not set" ; false ; fi $(MKDIR) -p $(BINDIST_OUT_DIR)/bin $(MKDIR) -p $(BINDIST_OUT_DIR)/lib/$(GHC_VERSION) + $(INSTALL) -vDm 755 out/$(GHC_VERSION)/haskell-language-server $(BINDIST_OUT_DIR)/bin/haskell-language-server-$(GHC_VERSION) + $(PATCHELF) --set-rpath \$$ORIGIN/../lib/$(GHC_VERSION) $(BINDIST_OUT_DIR)/bin/haskell-language-server-$(GHC_VERSION) $(SED) -e "s/@@EXE_NAME@@/haskell-language-server-$(GHC_VERSION)/" -e "s/@@GHC_VERSION@@/$(GHC_VERSION)/" \ bindist/wrapper.in > $(BINDIST_OUT_DIR)/haskell-language-server-$(GHC_VERSION) - $(SED) -e 's/@@EXE_NAME@@/haskell-language-server-wrapper/' -e "s/@@GHC_VERSION@@/$(GHC_VERSION)/" \ - bindist/wrapper.in > $(BINDIST_OUT_DIR)/haskell-language-server-wrapper $(CHMOD) 755 $(BINDIST_OUT_DIR)/haskell-language-server-$(GHC_VERSION) - $(CHMOD) 755 $(BINDIST_OUT_DIR)/haskell-language-server-wrapper - $(INSTALL) -vDm 755 out/$(GHC_VERSION)/haskell-language-server $(BINDIST_OUT_DIR)/bin/haskell-language-server-$(GHC_VERSION) - $(PATCHELF) --set-rpath \$$ORIGIN/../lib/$(GHC_VERSION) $(BINDIST_OUT_DIR)/bin/haskell-language-server-$(GHC_VERSION) $(INSTALL) -vDm 755 out/$(GHC_VERSION)/haskell-language-server-wrapper $(BINDIST_OUT_DIR)/bin/haskell-language-server-wrapper - $(PATCHELF) --set-rpath \$$ORIGIN/../lib/$(GHC_VERSION) $(BINDIST_OUT_DIR)/bin/haskell-language-server-wrapper $(FIND) $(STORE_DIR)/ghc-$(GHC_VERSION) -type f -name "*.so" -execdir install -vDm 755 {} $(ROOT_DIR)/$(BINDIST_OUT_DIR)/lib/$(GHC_VERSION)/{} \; $(FIND) $(ROOT_DIR)/$(BINDIST_OUT_DIR)/lib/$(GHC_VERSION) -type f -name '*.so' -execdir $(PATCHELF) --set-rpath \$$ORIGIN {} \; +install-ghcs: + ghcup install ghc recommended + ghcup set ghc recommended + for ghc in $(shell cat bindist/ghcs) ; do \ + ghcup install ghc `echo $$ghc | $(AWK) -F ',' '{ print $$1 }'` ; \ + done + +version: + @echo $(HLS_VERSION) + clean: - rm -rf $(BINDIST_BASE_DIR) + rm -rf out/* clean-all: - rm -rf $(BINDIST_BASE_DIR) $(STORE_DIR) + rm -rf out/* $(STORE_DIR) -.PHONY: hls hls-ghc bindist bindist-ghc clean clean-all +.PHONY: hls hls-ghc bindist bindist-ghc tar-bindist clean clean-all install-ghcs diff --git a/bindist/Makefile.in b/bindist/Makefile.in index 5d719757c1..0ea3c07e23 100644 --- a/bindist/Makefile.in +++ b/bindist/Makefile.in @@ -8,6 +8,7 @@ HLS_VERSION := @@HLS_VERSION@@ INSTALL := install SED := sed CHMOD := chmod +LN := ln install: $(INSTALL) -d $(BINDIR) @@ -24,6 +25,8 @@ install: $$h > $(BINDIR)/$$h ; \ $(CHMOD) 755 $(BINDIR)/$$h ; \ done + $(LN) -s `scripts/relpath.sh "\`realpath $(BINDIR)\`" "\`realpath $(LIBDIR)/haskell-language-server-$(HLS_VERSION)/bin/haskell-language-server-wrapper\`"` \ + $(BINDIR)/haskell-language-server-wrapper version: @echo $(HLS_VERSION) diff --git a/bindist/relpath.sh b/bindist/relpath.sh new file mode 100755 index 0000000000..8cd9217a60 --- /dev/null +++ b/bindist/relpath.sh @@ -0,0 +1,53 @@ +#!/bin/sh + +# POSIX shell implementation of `realpath --relative-to=$1 $2. +# This is an adaptation of the implementation from +# . + +# returns relative path to $2=$target from $1=$source +## NOTE : path are compared in text only. They don’t have to exist +## and they WONT be normalized/escaped +## Result in "$return_value"# both $1 and $2 are absolute paths beginning with / + +src="$(realpath $1)" +target="$(realpath $2)" + +common_part="$src" +result="" + +while test "${target#$common_part}" = "${target}" ; do + #echo "common_part is now : \"$common_part\"" + #echo "result is now : \"$result\"" + #echo "target#common_part : \"${target#$common_part}\"" + # no match, means that candidate common part is not correct + # go up one level (reduce common part) + common_part="$(dirname "$common_part")" + # and record that we went back + if test -z "$result" ; then + result=".." + else + result="../$result" + fi +done + +#echo "common_part is : \"$common_part\"" + +if test "$common_part" = "/" ; then + # special case for root (no common path) + result="$result/" +fi + +# since we now have identified the common part, +# compute the non-common part +forward_part="${target#$common_part}" +#echo "forward_part = \"$forward_part\"" + +if test -n "$result" && test -n "$forward_part" ; then + #echo "(simple concat)" + result="$result$forward_part" +elif test -n "$forward_part" ; then + #echo "(concat with slash removal)" + result="$(printf "%s" "$forward_part" | cut -c 1-)" +fi + +printf "%s" "$result" diff --git a/bindist/wrapper.in b/bindist/wrapper.in index 9f0c29f340..bf2fbb11d3 100644 --- a/bindist/wrapper.in +++ b/bindist/wrapper.in @@ -15,9 +15,16 @@ fail_libdir() { # try GHC_LIBDIR from the environment (e.g. user set it) if [ -n "${GHC_LIBDIR}" ] ; then : +# try hls-wrapper --print-libdir +elif command -v "${exedir}"/haskell-language-server-wrapper >/dev/null ; then + GHC_LIBDIR="$("${exedir}"/haskell-language-server-wrapper --print-libdir)" || unset GHC_LIBDIR +fi + +if [ -z "${GHC_LIBDIR}" ] ; then # try ghcup, if available -elif command -v ghcup >/dev/null ; then - GHC_LIBDIR="$(ghcup whereis -d ghc ${GHC_VERSION})/../lib/ghc-${GHC_VERSION}/" || unset GHC_LIBDIR + if command -v ghcup >/dev/null ; then + GHC_LIBDIR="$(ghcup whereis -d ghc ${GHC_VERSION})/../lib/ghc-${GHC_VERSION}/" || unset GHC_LIBDIR + fi fi # if above failed, try to examine ghc in PATH diff --git a/exe/Wrapper.hs b/exe/Wrapper.hs index 2cb2084b0c..ee2ec2a168 100644 --- a/exe/Wrapper.hs +++ b/exe/Wrapper.hs @@ -1,4 +1,5 @@ {-# LANGUAGE RecordWildCards #-} +{-# LANGUAGE CPP #-} -- | This module is based on the hie-wrapper.sh script in -- https://github.com/alanz/vscode-hie-server module Main where @@ -19,7 +20,12 @@ import System.Exit import System.FilePath import System.IO import System.Info +#ifndef mingw32_HOST_OS +import System.Posix.Process (executeFile) +import qualified Data.Map.Strict as Map +#else import System.Process +#endif -- --------------------------------------------------------------------- @@ -45,6 +51,10 @@ main = do BiosMode PrintCradleType -> print =<< findProjectCradle + PrintLibDir -> do + cradle <- findProjectCradle' False + (CradleSuccess libdir) <- HieBios.getRuntimeGhcLibDir cradle + putStr libdir _ -> launchHaskellLanguageServer args @@ -99,7 +109,14 @@ launchHaskellLanguageServer parsedArgs = do Nothing -> hPutStrLn stderr $ "Cannot find any haskell-language-server exe, looked for: " ++ intercalate ", " candidates Just e -> do hPutStrLn stderr $ "Launching haskell-language-server exe at:" ++ e +#ifdef mingw32_HOST_OS callProcess e args +#else + (CradleSuccess libdir) <- HieBios.getRuntimeGhcLibDir cradle + env <- Map.fromList <$> getEnvironment + let newEnv = Map.insert "GHC_LIBDIR" libdir env + executeFile e True args (Just (Map.toList newEnv)) +#endif -- | Version of 'getRuntimeGhcVersion' that dies if we can't get it, and also -- checks to see if the tool is missing if it is one of @@ -130,15 +147,22 @@ getRuntimeGhcVersion' cradle = do ++ show cradle findProjectCradle :: IO (Cradle Void) -findProjectCradle = do +findProjectCradle = findProjectCradle' True + +findProjectCradle' :: Bool -> IO (Cradle Void) +findProjectCradle' log = do d <- getCurrentDirectory let initialFp = d "a" hieYaml <- Session.findCradle def initialFp -- Some log messages - case hieYaml of - Just yaml -> hPutStrLn stderr $ "Found \"" ++ yaml ++ "\" for \"" ++ initialFp ++ "\"" - Nothing -> hPutStrLn stderr "No 'hie.yaml' found. Try to discover the project type!" + when log $ + case hieYaml of + Just yaml -> hPutStrLn stderr $ "Found \"" ++ yaml ++ "\" for \"" ++ initialFp ++ "\"" + Nothing -> hPutStrLn stderr "No 'hie.yaml' found. Try to discover the project type!" Session.loadCradle def hieYaml d + + + diff --git a/haskell-language-server.cabal b/haskell-language-server.cabal index 89d38e953d..92b5305f45 100644 --- a/haskell-language-server.cabal +++ b/haskell-language-server.cabal @@ -442,6 +442,10 @@ executable haskell-language-server-wrapper , optparse-applicative , optparse-simple , process + if !os(windows) + build-depends: + unix + , containers default-language: Haskell2010 diff --git a/src/Ide/Arguments.hs b/src/Ide/Arguments.hs index 0f1f5eb8a5..8c3fa98981 100644 --- a/src/Ide/Arguments.hs +++ b/src/Ide/Arguments.hs @@ -1,151 +1,153 @@ --- Copyright (c) 2019 The DAML Authors. All rights reserved. --- SPDX-License-Identifier: Apache-2.0 -{-# LANGUAGE CPP #-} -{-# LANGUAGE RecordWildCards #-} -{-# LANGUAGE TemplateHaskell #-} -{-# LANGUAGE TupleSections #-} -{-# OPTIONS_GHC -Wno-dodgy-imports #-} -- GHC no longer exports def in GHC 8.6 and above - -module Ide.Arguments - ( Arguments(..) - , GhcideArguments(..) - , PrintVersion(..) - , BiosAction(..) - , getArguments - , haskellLanguageServerVersion - , haskellLanguageServerNumericVersion - ) where - -import Data.Version -import Development.IDE (IdeState) -import Development.IDE.Main (Command (..), commandP) -import GitHash (giHash, tGitInfoCwdTry) -import Ide.Types (IdePlugins) -import Options.Applicative -import Paths_haskell_language_server -import System.Environment - --- --------------------------------------------------------------------- - -data Arguments - = VersionMode PrintVersion - | ProbeToolsMode - | ListPluginsMode - | BiosMode BiosAction - | Ghcide GhcideArguments - | VSCodeExtensionSchemaMode - | DefaultConfigurationMode - -data GhcideArguments = GhcideArguments - {argsCommand :: Command - ,argsCwd :: Maybe FilePath - ,argsShakeProfiling :: Maybe FilePath - ,argsTesting :: Bool - ,argsExamplePlugin :: Bool - -- These next two are for compatibility with existing hie clients, allowing - -- them to just change the name of the exe and still work. - , argsDebugOn :: Bool - , argsLogFile :: Maybe String - , argsThreads :: Int - , argsProjectGhcVersion :: Bool - } deriving Show - -data PrintVersion - = PrintVersion - | PrintNumericVersion - deriving (Show, Eq, Ord) - -data BiosAction - = PrintCradleType - deriving (Show, Eq, Ord) - -getArguments :: String -> IdePlugins IdeState -> IO Arguments -getArguments exeName plugins = execParser opts - where - opts = info (( - VersionMode <$> printVersionParser exeName - <|> probeToolsParser exeName - <|> listPluginsParser - <|> BiosMode <$> biosParser - <|> Ghcide <$> arguments plugins - ) - <**> helper) - ( fullDesc - <> progDesc "Used as a test bed to check your IDE Client will work" - <> header (exeName ++ " - GHC Haskell LSP server")) - -printVersionParser :: String -> Parser PrintVersion -printVersionParser exeName = - flag' PrintVersion - (long "version" <> help ("Show " ++ exeName ++ " and GHC versions")) - <|> - flag' PrintNumericVersion - (long "numeric-version" <> help ("Show numeric version of " ++ exeName)) - -biosParser :: Parser BiosAction -biosParser = - flag' PrintCradleType - (long "print-cradle" <> help "Print the project cradle type") - -probeToolsParser :: String -> Parser Arguments -probeToolsParser exeName = - flag' ProbeToolsMode - (long "probe-tools" <> help ("Show " ++ exeName ++ " version and other tools of interest")) - -listPluginsParser :: Parser Arguments -listPluginsParser = - flag' ListPluginsMode - (long "list-plugins" <> help "List all available plugins") - -arguments :: IdePlugins IdeState -> Parser GhcideArguments -arguments plugins = GhcideArguments - <$> (commandP plugins <|> lspCommand <|> checkCommand) - <*> optional (strOption $ long "cwd" <> metavar "DIR" - <> help "Change to this directory") - <*> optional (strOption $ long "shake-profiling" <> metavar "DIR" - <> help "Dump profiling reports to this directory") - <*> switch (long "test" - <> help "Enable additional lsp messages used by the testsuite") - <*> switch (long "example" - <> help "Include the Example Plugin. For Plugin devs only") - - <*> switch - ( long "debug" - <> short 'd' - <> help "Generate debug output" - ) - <*> optional (strOption - ( long "logfile" - <> short 'l' - <> metavar "LOGFILE" - <> help "File to log to, defaults to stdout" - )) - <*> option auto - (short 'j' - <> help "Number of threads (0: automatic)" - <> metavar "NUM" - <> value 0 - <> showDefault - ) - <*> switch (long "project-ghc-version" - <> help "Work out the project GHC version and print it") - where - lspCommand = LSP <$ flag' True (long "lsp" <> help "Start talking to an LSP server") - checkCommand = Check <$> many (argument str (metavar "FILES/DIRS...")) - --- --------------------------------------------------------------------- - -haskellLanguageServerNumericVersion :: String -haskellLanguageServerNumericVersion = showVersion version - -haskellLanguageServerVersion :: IO String -haskellLanguageServerVersion = do - path <- getExecutablePath - let gi = $$tGitInfoCwdTry - gitHashSection = case gi of - Right gi -> " (GIT hash: " <> giHash gi <> ")" - Left _ -> "" - return $ "haskell-language-server version: " <> haskellLanguageServerNumericVersion - <> " (GHC: " <> VERSION_ghc - <> ") (PATH: " <> path <> ")" - <> gitHashSection +-- Copyright (c) 2019 The DAML Authors. All rights reserved. +-- SPDX-License-Identifier: Apache-2.0 +{-# LANGUAGE CPP #-} +{-# LANGUAGE RecordWildCards #-} +{-# LANGUAGE TemplateHaskell #-} +{-# LANGUAGE TupleSections #-} +{-# OPTIONS_GHC -Wno-dodgy-imports #-} -- GHC no longer exports def in GHC 8.6 and above + +module Ide.Arguments + ( Arguments(..) + , GhcideArguments(..) + , PrintVersion(..) + , BiosAction(..) + , getArguments + , haskellLanguageServerVersion + , haskellLanguageServerNumericVersion + ) where + +import Data.Version +import Development.IDE (IdeState) +import Development.IDE.Main (Command (..), commandP) +import GitHash (giHash, tGitInfoCwdTry) +import Ide.Types (IdePlugins) +import Options.Applicative +import Paths_haskell_language_server +import System.Environment + +-- --------------------------------------------------------------------- + +data Arguments + = VersionMode PrintVersion + | ProbeToolsMode + | ListPluginsMode + | BiosMode BiosAction + | Ghcide GhcideArguments + | VSCodeExtensionSchemaMode + | DefaultConfigurationMode + | PrintLibDir + +data GhcideArguments = GhcideArguments + {argsCommand :: Command + ,argsCwd :: Maybe FilePath + ,argsShakeProfiling :: Maybe FilePath + ,argsTesting :: Bool + ,argsExamplePlugin :: Bool + -- These next two are for compatibility with existing hie clients, allowing + -- them to just change the name of the exe and still work. + , argsDebugOn :: Bool + , argsLogFile :: Maybe String + , argsThreads :: Int + , argsProjectGhcVersion :: Bool + } deriving Show + +data PrintVersion + = PrintVersion + | PrintNumericVersion + deriving (Show, Eq, Ord) + +data BiosAction + = PrintCradleType + deriving (Show, Eq, Ord) + +getArguments :: String -> IdePlugins IdeState -> IO Arguments +getArguments exeName plugins = execParser opts + where + opts = info (( + VersionMode <$> printVersionParser exeName + <|> probeToolsParser exeName + <|> listPluginsParser + <|> BiosMode <$> biosParser + <|> Ghcide <$> arguments plugins + <|> flag' PrintLibDir (long "print-libdir" <> help ("Print project GHCs libdir")) + ) + <**> helper) + ( fullDesc + <> progDesc "Used as a test bed to check your IDE Client will work" + <> header (exeName ++ " - GHC Haskell LSP server")) + +printVersionParser :: String -> Parser PrintVersion +printVersionParser exeName = + flag' PrintVersion + (long "version" <> help ("Show " ++ exeName ++ " and GHC versions")) + <|> + flag' PrintNumericVersion + (long "numeric-version" <> help ("Show numeric version of " ++ exeName)) + +biosParser :: Parser BiosAction +biosParser = + flag' PrintCradleType + (long "print-cradle" <> help "Print the project cradle type") + +probeToolsParser :: String -> Parser Arguments +probeToolsParser exeName = + flag' ProbeToolsMode + (long "probe-tools" <> help ("Show " ++ exeName ++ " version and other tools of interest")) + +listPluginsParser :: Parser Arguments +listPluginsParser = + flag' ListPluginsMode + (long "list-plugins" <> help "List all available plugins") + +arguments :: IdePlugins IdeState -> Parser GhcideArguments +arguments plugins = GhcideArguments + <$> (commandP plugins <|> lspCommand <|> checkCommand) + <*> optional (strOption $ long "cwd" <> metavar "DIR" + <> help "Change to this directory") + <*> optional (strOption $ long "shake-profiling" <> metavar "DIR" + <> help "Dump profiling reports to this directory") + <*> switch (long "test" + <> help "Enable additional lsp messages used by the testsuite") + <*> switch (long "example" + <> help "Include the Example Plugin. For Plugin devs only") + + <*> switch + ( long "debug" + <> short 'd' + <> help "Generate debug output" + ) + <*> optional (strOption + ( long "logfile" + <> short 'l' + <> metavar "LOGFILE" + <> help "File to log to, defaults to stdout" + )) + <*> option auto + (short 'j' + <> help "Number of threads (0: automatic)" + <> metavar "NUM" + <> value 0 + <> showDefault + ) + <*> switch (long "project-ghc-version" + <> help "Work out the project GHC version and print it") + where + lspCommand = LSP <$ flag' True (long "lsp" <> help "Start talking to an LSP server") + checkCommand = Check <$> many (argument str (metavar "FILES/DIRS...")) + +-- --------------------------------------------------------------------- + +haskellLanguageServerNumericVersion :: String +haskellLanguageServerNumericVersion = showVersion version + +haskellLanguageServerVersion :: IO String +haskellLanguageServerVersion = do + path <- getExecutablePath + let gi = $$tGitInfoCwdTry + gitHashSection = case gi of + Right gi -> " (GIT hash: " <> giHash gi <> ")" + Left _ -> "" + return $ "haskell-language-server version: " <> haskellLanguageServerNumericVersion + <> " (GHC: " <> VERSION_ghc + <> ") (PATH: " <> path <> ")" + <> gitHashSection diff --git a/src/Ide/Main.hs b/src/Ide/Main.hs index e4b7cec41e..8749da9d67 100644 --- a/src/Ide/Main.hs +++ b/src/Ide/Main.hs @@ -76,6 +76,7 @@ defaultMain args idePlugins = do DefaultConfigurationMode -> do LBS.putStrLn $ A.encodePretty $ pluginsToDefaultConfig idePlugins + _ -> pure () -- --------------------------------------------------------------------- From efb0608b0032c533a0b171512879c74ffdd7879c Mon Sep 17 00:00:00 2001 From: Julian Ospald Date: Wed, 2 Feb 2022 16:21:47 +0100 Subject: [PATCH 07/33] Fix CI to build proper bindists --- .gitlab-ci.yml | 48 ++++++++++++++----------------------------- .gitlab/ci.sh | 50 +++++++++++++++++++++++++++------------------ .gitlab/common.sh | 9 ++++++++ .gitlab/tar.sh | 8 ++++---- Makefile | 31 ++++++++++++++++++++++------ bindist/Makefile.in | 6 ++++-- 6 files changed, 87 insertions(+), 65 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 6ef38692a3..4a0fd3dac4 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -10,7 +10,7 @@ variables: CABAL_INSTALL_VERSION: 3.6.2.0 -.default_matrix: &default_matrix +.windows_matrix: &windows_matrix matrix: - GHC_VERSION: 8.8.4 CABAL_PROJECT: cabal.project @@ -21,27 +21,6 @@ variables: - GHC_VERSION: 9.2.1 CABAL_PROJECT: cabal-ghc921.project -# ghc-9.2.1 is broken for bsd -.freebsd_matrix: &freebsd_matrix - matrix: - - GHC_VERSION: 8.8.4 - CABAL_PROJECT: cabal.project - - GHC_VERSION: 8.10.7 - CABAL_PROJECT: cabal.project - - GHC_VERSION: 9.0.2 - CABAL_PROJECT: cabal-ghc90.project - -.m1_matrix: &m1_matrix - matrix: - - GHC_VERSION: 8.10.7 - CABAL_PROJECT: cabal.project - -.arm_matrix: &arm_matrix - matrix: - - GHC_VERSION: 8.10.7 - CABAL_PROJECT: cabal.project - - workflow: rules: - if: $CI_COMMIT_TAG @@ -68,10 +47,12 @@ workflow: build-aarch64-linux-deb10: extends: .build + before_script: + - sudo apt update + - sudo apt install -y patchelf tags: - aarch64-linux image: "registry.gitlab.haskell.org/ghc/ci-images/aarch64-linux-deb10:$DOCKER_REV" - parallel: *arm_matrix variables: ADD_CABAL_ARGS: "" @@ -90,10 +71,12 @@ tar-aarch64-linux-deb10: build-armv7-linux-deb10: extends: .build + before_script: + - sudo apt update + - sudo apt install -y patchelf tags: - armv7-linux image: "registry.gitlab.haskell.org/ghc/ci-images/armv7-linux-deb10:$DOCKER_REV" - parallel: *arm_matrix variables: ADD_CABAL_ARGS: "" @@ -112,10 +95,12 @@ tar-armv7-linux-deb10: build-x86_64-linux: extends: .build + before_script: + - sudo apt update + - sudo apt install -y patchelf tags: - x86_64-linux image: "registry.gitlab.haskell.org/ghc/ci-images/x86_64-linux-deb10:$DOCKER_REV" - parallel: *default_matrix variables: ADD_CABAL_ARGS: "--enable-split-sections" @@ -138,8 +123,7 @@ build-x86_64-linux-alpine: - x86_64-linux image: "registry.gitlab.haskell.org/ghc/ci-images/x86_64-linux-alpine3_12:$DOCKER_REV" before_script: - - sudo apk add --no-cache zlib zlib-dev zlib-static bzip2 bzip2-dev bzip2-static gmp gmp-dev xz xz-dev ncurses-static - parallel: *default_matrix + - sudo apk add --no-cache zlib zlib-dev zlib-static bzip2 bzip2-dev bzip2-static gmp gmp-dev xz xz-dev ncurses-static patchelf findutils variables: ADD_CABAL_ARGS: "--enable-split-sections --enable-executable-static" @@ -158,9 +142,10 @@ tar-x86_64-linux-alpine: build-x86_64-freebsd12: extends: .build + before_script: + - sudo pkg install --yes patchelf gmake tags: - x86_64-freebsd12 - parallel: *freebsd_matrix variables: ADD_CABAL_ARGS: "--enable-split-sections -j1" @@ -180,10 +165,9 @@ build-x86_64-freebsd13: extends: .build tags: - x86_64-freebsd13 - parallel: *freebsd_matrix before_script: - sudo pkg update - - sudo pkg install --yes compat12x-amd64 + - sudo pkg install --yes compat12x-amd64 patchelf gmake - sudo ln -s libncurses.so.6 /usr/local/lib/libncurses.so.6.2 variables: ADD_CABAL_ARGS: "--enable-split-sections -j1" @@ -204,7 +188,6 @@ build-x86_64-darwin: extends: .build tags: - x86_64-darwin - parallel: *default_matrix variables: ADD_CABAL_ARGS: "" @@ -258,7 +241,6 @@ build-aarch64-darwin: variables: MACOSX_DEPLOYMENT_TARGET: "10.7" ADD_CABAL_ARGS: "" - parallel: *m1_matrix tar-aarch64-darwin: extends: .artifacts @@ -276,7 +258,7 @@ build-x86_64-windows: extends: .build tags: - new-x86_64-windows - parallel: *default_matrix + parallel: *windows_matrix script: - $env:CHERE_INVOKING = "yes" - bash '-lc' "ADD_CABAL_ARGS=$env:ADD_CABAL_ARGS GHC_VERSION=$env:GHC_VERSION CABAL_INSTALL_VERSION=$CABAL_INSTALL_VERSION .gitlab/ci.sh" diff --git a/.gitlab/ci.sh b/.gitlab/ci.sh index 5267bc8c8f..8225449137 100755 --- a/.gitlab/ci.sh +++ b/.gitlab/ci.sh @@ -22,7 +22,7 @@ mkdir -p "$GHCUP_BINDIR" export PATH="$GHCUP_BINDIR:$PATH" export BOOTSTRAP_HASKELL_NONINTERACTIVE=1 -export BOOTSTRAP_HASKELL_GHC_VERSION="$GHC_VERSION" +export BOOTSTRAP_HASKELL_GHC_VERSION="${GHC_VERSION:-recommended}" export BOOTSTRAP_HASKELL_CABAL_VERSION="$CABAL_INSTALL_VERSION" export BOOTSTRAP_HASKELL_VERBOSE=1 export BOOTSTRAP_HASKELL_ADJUST_CABAL_CONFIG=yes @@ -45,29 +45,39 @@ case "$(uname -s)" in ;; esac -# Shorten binary names -sed -i.bak -e 's/haskell-language-server/hls/g' \ - -e 's/haskell_language_server/hls/g' \ - haskell-language-server.cabal $CABAL_PROJECT -sed -i.bak -e 's/Paths_haskell_language_server/Paths_hls/g' \ - src/**/*.hs exe/*.hs +case "$(uname)" in + MSYS_*|MINGW*) + # Shorten binary names + sed -i.bak -e 's/haskell-language-server/hls/g' \ + -e 's/haskell_language_server/hls/g' \ + haskell-language-server.cabal $CABAL_PROJECT + sed -i.bak -e 's/Paths_haskell_language_server/Paths_hls/g' \ + src/**/*.hs exe/*.hs -args=( - -O2 - -w "ghc-$GHC_VERSION" - --project-file "$CABAL_PROJECT" - --disable-profiling - --disable-tests - --enable-executable-stripping - ${ADD_CABAL_ARGS} -) + args=( + -O2 + -w "ghc-$GHC_VERSION" + --project-file "$CABAL_PROJECT" + --disable-profiling + --disable-tests + --enable-executable-stripping + ${ADD_CABAL_ARGS} + ) -run cabal v2-build ${args[@]} exe:hls exe:hls-wrapper + run cabal v2-build ${args[@]} exe:hls exe:hls-wrapper -mkdir "$CI_PROJECT_DIR/out" + mkdir "$CI_PROJECT_DIR/out" -cp "$(cabal list-bin ${args[@]} exe:hls)" "$CI_PROJECT_DIR/out/haskell-language-server-${GHC_VERSION}" -cp "$(cabal list-bin ${args[@]} exe:hls-wrapper)" "$CI_PROJECT_DIR/out/haskell-language-server-wrapper" + cp "$(cabal list-bin ${args[@]} exe:hls)" "$CI_PROJECT_DIR/out/haskell-language-server-${GHC_VERSION}" + cp "$(cabal list-bin ${args[@]} exe:hls-wrapper)" "$CI_PROJECT_DIR/out/haskell-language-server-wrapper" + ;; + *) + emake install-ghcs + emake hls + emake bindist + rm -rf out/*.*.* + ;; +esac cp dist-newstyle/cache/plan.json "$CI_PROJECT_DIR/out/plan.json" diff --git a/.gitlab/common.sh b/.gitlab/common.sh index b6bce698c9..e3973a1796 100644 --- a/.gitlab/common.sh +++ b/.gitlab/common.sh @@ -47,3 +47,12 @@ function run() { info "Running $*..." "$@" || ( error "$* failed"; return 1; ) } + +emake() { + if command -v gmake >/dev/null 2>&1 ; then + gmake "$@" + else + make "$@" + fi +} + diff --git a/.gitlab/tar.sh b/.gitlab/tar.sh index ba713d63fa..bbfe27ead9 100755 --- a/.gitlab/tar.sh +++ b/.gitlab/tar.sh @@ -5,19 +5,19 @@ set -Eeuxo pipefail source "$CI_PROJECT_DIR/.gitlab/common.sh" ls -la out/ -cd out/ # create tarball/zip -HLS_VERSION="$("$CI_PROJECT_DIR/out/haskell-language-server-wrapper" --numeric-version)" TARBALL_PREFIX="haskell-language-server" case "${TARBALL_EXT}" in zip) + HLS_VERSION="$("$CI_PROJECT_DIR/out/haskell-language-server-wrapper" --numeric-version)" + cd out/ zip "${TARBALL_PREFIX}-${TARBALL_ARCHIVE_SUFFIX}-${HLS_VERSION}.zip" haskell-language-server-* find . -type f ! -name '*.zip' -delete ;; tar.xz) - tar caf "${TARBALL_PREFIX}-${TARBALL_ARCHIVE_SUFFIX}-${HLS_VERSION}.tar.xz" haskell-language-server-* - find . -type f ! -name '*.tar.xz' -delete + emake bindist-tar + rm -rf out/bindist ;; *) fail "Unknown TARBALL_EXT: ${TARBALL_EXT}" diff --git a/Makefile b/Makefile index aa2d787e61..2ba08d8380 100644 --- a/Makefile +++ b/Makefile @@ -1,3 +1,4 @@ +UNAME := $(shell uname) ROOT_DIR:=$(shell dirname $(realpath $(firstword $(MAKEFILE_LIST)))) GHC_VERSION ?= @@ -13,13 +14,16 @@ MKDIR := mkdir TAR := tar CABAL := cabal AWK := awk +STRIP := strip + +INSTALL_NAME_TOOL := install_name_tool STORE_DIR := store BINDIST_BASE_DIR := out/bindist BINDIST_OUT_DIR := $(BINDIST_BASE_DIR)/haskell-language-server-$(HLS_VERSION) CABAL_ARGS ?= --store-dir=$(ROOT_DIR)/$(STORE_DIR) -CABAL_INSTALL_ARGS ?= --enable-executable-stripping --disable-tests --disable-profiling -O2 --overwrite-policy=always --install-method=copy +CABAL_INSTALL_ARGS ?= --disable-tests --disable-profiling -O2 --overwrite-policy=always --install-method=copy hls: bindist/ghcs for ghc in $(shell cat bindist/ghcs) ; do \ @@ -27,9 +31,17 @@ hls: bindist/ghcs done hls-ghc: + $(MKDIR) -p out/ @if test -z "$(GHC_VERSION)" ; then echo >&2 "GHC_VERSION is not set" ; false ; fi @if test -z "$(PROJECT_FILE)" ; then echo >&2 "PROJECT_FILE is not set" ; false ; fi $(CABAL) $(CABAL_ARGS) v2-install --project-file=$(PROJECT_FILE) -w ghc-$(GHC_VERSION) $(CABAL_INSTALL_ARGS) --installdir=$(ROOT_DIR)/out/$(GHC_VERSION) exe:haskell-language-server exe:haskell-language-server-wrapper +ifeq ($(UNAME), Darwin) + $(STRIP) $(ROOT_DIR)/out/$(GHC_VERSION)/haskell-language-server + $(STRIP) $(ROOT_DIR)/out/$(GHC_VERSION)/haskell-language-server-wrapper +else + $(STRIP) -s $(ROOT_DIR)/out/$(GHC_VERSION)/haskell-language-server + $(STRIP) -s $(ROOT_DIR)/out/$(GHC_VERSION)/haskell-language-server-wrapper +endif bindist: for ghc in $(shell cat bindist/ghcs) ; do \ @@ -37,21 +49,28 @@ bindist: done $(SED) -e "s/@@HLS_VERSION@@/$(HLS_VERSION)/" \ bindist/Makefile.in > $(BINDIST_OUT_DIR)/Makefile - $(INSTALL) -vDm 755 bindist/relpath.sh $(BINDIST_OUT_DIR)/scripts/relpath.sh + $(INSTALL) -d $(BINDIST_OUT_DIR)/scripts/ + $(INSTALL) -vm 755 bindist/relpath.sh $(BINDIST_OUT_DIR)/scripts/relpath.sh -tar-bindist: +bindist-tar: cd $(BINDIST_BASE_DIR) ; $(TAR) caf $(ROOT_DIR)/out/haskell-language-server-$(HLS_VERSION).tar.xz haskell-language-server-$(HLS_VERSION) bindist-ghc: if test -z "$(GHC_VERSION)" ; then echo >&2 "GHC_VERSION is not set" ; false ; fi $(MKDIR) -p $(BINDIST_OUT_DIR)/bin $(MKDIR) -p $(BINDIST_OUT_DIR)/lib/$(GHC_VERSION) - $(INSTALL) -vDm 755 out/$(GHC_VERSION)/haskell-language-server $(BINDIST_OUT_DIR)/bin/haskell-language-server-$(GHC_VERSION) + $(INSTALL) -d $(BINDIST_OUT_DIR)/bin/ + $(INSTALL) -vm 755 out/$(GHC_VERSION)/haskell-language-server $(BINDIST_OUT_DIR)/bin/haskell-language-server-$(GHC_VERSION) +ifeq ($(UNAME), Darwin) + $(INSTALL_NAME_TOOL) -add_rpath "@executable_path/../lib/$(GHC_VERSION)" $(BINDIST_OUT_DIR)/bin/haskell-language-server-$(GHC_VERSION) +else $(PATCHELF) --set-rpath \$$ORIGIN/../lib/$(GHC_VERSION) $(BINDIST_OUT_DIR)/bin/haskell-language-server-$(GHC_VERSION) +endif $(SED) -e "s/@@EXE_NAME@@/haskell-language-server-$(GHC_VERSION)/" -e "s/@@GHC_VERSION@@/$(GHC_VERSION)/" \ bindist/wrapper.in > $(BINDIST_OUT_DIR)/haskell-language-server-$(GHC_VERSION) $(CHMOD) 755 $(BINDIST_OUT_DIR)/haskell-language-server-$(GHC_VERSION) - $(INSTALL) -vDm 755 out/$(GHC_VERSION)/haskell-language-server-wrapper $(BINDIST_OUT_DIR)/bin/haskell-language-server-wrapper + $(INSTALL) -d $(BINDIST_OUT_DIR)/bin/ + $(INSTALL) -vm 755 out/$(GHC_VERSION)/haskell-language-server-wrapper $(BINDIST_OUT_DIR)/bin/haskell-language-server-wrapper $(FIND) $(STORE_DIR)/ghc-$(GHC_VERSION) -type f -name "*.so" -execdir install -vDm 755 {} $(ROOT_DIR)/$(BINDIST_OUT_DIR)/lib/$(GHC_VERSION)/{} \; $(FIND) $(ROOT_DIR)/$(BINDIST_OUT_DIR)/lib/$(GHC_VERSION) -type f -name '*.so' -execdir $(PATCHELF) --set-rpath \$$ORIGIN {} \; @@ -72,4 +91,4 @@ clean: clean-all: rm -rf out/* $(STORE_DIR) -.PHONY: hls hls-ghc bindist bindist-ghc tar-bindist clean clean-all install-ghcs +.PHONY: hls hls-ghc bindist bindist-ghc bindist-tar clean clean-all install-ghcs diff --git a/bindist/Makefile.in b/bindist/Makefile.in index 0ea3c07e23..156aef1fd6 100644 --- a/bindist/Makefile.in +++ b/bindist/Makefile.in @@ -15,10 +15,12 @@ install: $(INSTALL) -d $(LIBDIR)/haskell-language-server-$(HLS_VERSION)/lib $(INSTALL) -d $(LIBDIR)/haskell-language-server-$(HLS_VERSION)/bin for f in $(wildcard lib/*/*) ; do \ - $(INSTALL) -vDm 755 $$f $(LIBDIR)/haskell-language-server-$(HLS_VERSION)/$$f ; \ + $(INSTALL) -d $(LIBDIR)/haskell-language-server-$(HLS_VERSION)/ ; \ + $(INSTALL) -vm 755 $$f $(LIBDIR)/haskell-language-server-$(HLS_VERSION)/$$f ; \ done for b in $(wildcard bin/*) ; do \ - $(INSTALL) -vDm 755 $$b $(LIBDIR)/haskell-language-server-$(HLS_VERSION)/$$b ; \ + $(INSTALL) -d $(LIBDIR)/haskell-language-server-$(HLS_VERSION)/ ; \ + $(INSTALL) -vm 755 $$b $(LIBDIR)/haskell-language-server-$(HLS_VERSION)/$$b ; \ done for h in $(wildcard haskell-language-server-*) ; do \ $(SED) -e "s#@@EXE_DIR@@#$(LIBDIR)/haskell-language-server-$(HLS_VERSION)/bin/#" \ From b3a09b0d9dd59effe37e78c4f7b273e8e23ec8ee Mon Sep 17 00:00:00 2001 From: Julian Ospald Date: Wed, 2 Feb 2022 21:45:03 +0100 Subject: [PATCH 08/33] Compare ABI hashes of 'ghc' pkg and deps --- Makefile | 5 ++++- bindist/wrapper.in | 32 ++++++++++++++++++++++++++++++++ exe/Wrapper.hs | 8 +++++--- 3 files changed, 41 insertions(+), 4 deletions(-) diff --git a/Makefile b/Makefile index 2ba08d8380..38a861e8fb 100644 --- a/Makefile +++ b/Makefile @@ -66,7 +66,10 @@ ifeq ($(UNAME), Darwin) else $(PATCHELF) --set-rpath \$$ORIGIN/../lib/$(GHC_VERSION) $(BINDIST_OUT_DIR)/bin/haskell-language-server-$(GHC_VERSION) endif - $(SED) -e "s/@@EXE_NAME@@/haskell-language-server-$(GHC_VERSION)/" -e "s/@@GHC_VERSION@@/$(GHC_VERSION)/" \ + $(SED) \ + -e "s/@@EXE_NAME@@/haskell-language-server-$(GHC_VERSION)/" \ + -e "s/@@GHC_VERSION@@/$(GHC_VERSION)/" \ + -e "s/@@ABI_HASHES@@/$(shell for dep in ghc `ghc-pkg-$(GHC_VERSION) field ghc depends --simple-output` ; do ghc-pkg-$(GHC_VERSION) field $$dep abi --simple-output ; done | tr '\n' ' ' | xargs)/" \ bindist/wrapper.in > $(BINDIST_OUT_DIR)/haskell-language-server-$(GHC_VERSION) $(CHMOD) 755 $(BINDIST_OUT_DIR)/haskell-language-server-$(GHC_VERSION) $(INSTALL) -d $(BINDIST_OUT_DIR)/bin/ diff --git a/bindist/wrapper.in b/bindist/wrapper.in index bf2fbb11d3..86b54a182b 100644 --- a/bindist/wrapper.in +++ b/bindist/wrapper.in @@ -3,6 +3,15 @@ exedir="@@EXE_DIR@@" executablename="@@EXE_NAME@@" GHC_VERSION="@@GHC_VERSION@@" +ABI_HASHES="@@ABI_HASHES@@" + +fail_ghc_pkg() { + echo >&2 "Could not find a ghc-pkg binary (found: $1)!" + echo >&2 "Your GHC installation may be borked." + echo >&2 "Consider installing GHC via ghcup or compile HLS from source." + echo >&2 "exiting..." + exit 42 +} fail_libdir() { echo >&2 "Could not find a GHC installation!" @@ -12,6 +21,17 @@ fail_libdir() { exit 42 } +fail_abi() { + echo >&2 "GHC ABIs don't match!" + echo >&2 "This means you're running an incompatible GHC and HLS won't work correctly." + echo >&2 "Consider installing GHC via ghcup or compile HLS from source." + echo >&2 "" + echo >&2 "Expected: ${ABI_HASHES}" + echo >&2 "Got: $1" + echo >&2 "exiting..." + exit 42 +} + # try GHC_LIBDIR from the environment (e.g. user set it) if [ -n "${GHC_LIBDIR}" ] ; then : @@ -51,6 +71,18 @@ if [ -z "${GHC_LIBDIR}" ] ; then fail_libdir fi +# check abi +GHC_PKG="${GHC_LIBDIR}"/bin/ghc-pkg +if "${GHC_PKG}" --version >/dev/null ; then + : +else + fail_ghc_pkg "${GHC_PKG}" +fi +PKGCONF="${GHC_LIBDIR}/package.conf.d" +MY_ABI_HASHES="$(for dep in ghc $("${GHC_PKG}" --global-package-db "$PKGCONF" field ghc depends --simple-output) ; do "${GHC_PKG}" --global-package-db "$PKGCONF" field "${dep}" abi --simple-output ; done | tr '\n' ' ' | xargs)" +[ "${ABI_HASHES}" = "${MY_ABI_HASHES}" ] || fail_abi "${MY_ABI_HASHES}" +unset PKGCONF + if [ -n "$LD_LIBRARY_PATH" ] ; then LD_LIBRARY_PATH="$(for i in "${GHC_LIBDIR}"/* ; do [ -d "$i" ] && printf "%s" "$i:" ; done)$LD_LIBRARY_PATH" export LD_LIBRARY_PATH diff --git a/exe/Wrapper.hs b/exe/Wrapper.hs index ee2ec2a168..0f5d0de82a 100644 --- a/exe/Wrapper.hs +++ b/exe/Wrapper.hs @@ -5,6 +5,7 @@ module Main where import Control.Monad.Extra +import Data.Char (isSpace) import Data.Default import Data.Foldable import Data.List @@ -55,7 +56,6 @@ main = do cradle <- findProjectCradle' False (CradleSuccess libdir) <- HieBios.getRuntimeGhcLibDir cradle putStr libdir - _ -> launchHaskellLanguageServer args launchHaskellLanguageServer :: Arguments -> IO () @@ -164,5 +164,7 @@ findProjectCradle' log = do Session.loadCradle def hieYaml d - - +trim :: String -> String +trim s = case lines s of + [] -> s + ls -> dropWhileEnd isSpace $ last ls From a71bf15a5c1af8d43965dd52be23ef7528cf5b07 Mon Sep 17 00:00:00 2001 From: Julian Ospald Date: Wed, 2 Feb 2022 23:05:15 +0100 Subject: [PATCH 09/33] Add --global to ghc-pkg invocations --- bindist/wrapper.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bindist/wrapper.in b/bindist/wrapper.in index 86b54a182b..2d47048c38 100644 --- a/bindist/wrapper.in +++ b/bindist/wrapper.in @@ -79,7 +79,7 @@ else fail_ghc_pkg "${GHC_PKG}" fi PKGCONF="${GHC_LIBDIR}/package.conf.d" -MY_ABI_HASHES="$(for dep in ghc $("${GHC_PKG}" --global-package-db "$PKGCONF" field ghc depends --simple-output) ; do "${GHC_PKG}" --global-package-db "$PKGCONF" field "${dep}" abi --simple-output ; done | tr '\n' ' ' | xargs)" +MY_ABI_HASHES="$(for dep in ghc $("${GHC_PKG}" --global --global-package-db "$PKGCONF" field ghc depends --simple-output) ; do "${GHC_PKG}" --global --global-package-db "$PKGCONF" field "${dep}" abi --simple-output ; done | tr '\n' ' ' | xargs)" [ "${ABI_HASHES}" = "${MY_ABI_HASHES}" ] || fail_abi "${MY_ABI_HASHES}" unset PKGCONF From 7863221b7481d582a5462265bf78b6200e38aecc Mon Sep 17 00:00:00 2001 From: Julian Ospald Date: Wed, 2 Feb 2022 23:05:34 +0100 Subject: [PATCH 10/33] Add CI tests --- .gitlab-ci.yml | 142 ++++++++++++++++++++++++++++++++++++++++++++++++ .gitlab/tar.sh | 2 +- .gitlab/test.sh | 59 ++++++++++++++++++++ Makefile | 3 +- 4 files changed, 204 insertions(+), 2 deletions(-) create mode 100644 .gitlab/test.sh diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 4a0fd3dac4..51176b115f 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,6 +1,7 @@ stages: - build - tar + - test # Used for ci setup in the gitlab mirror of the project: # https://gitlab.haskell.org/haskell/haskell-language-server/-/pipelines @@ -45,6 +46,17 @@ workflow: script: - bash .gitlab/ci.sh +.test: + extends: .artifacts:short + stage: test + script: + - bash .gitlab/test.sh + + +###################### +# aarch64 linux deb10 +###################### + build-aarch64-linux-deb10: extends: .build before_script: @@ -69,6 +81,18 @@ tar-aarch64-linux-deb10: TARBALL_ARCHIVE_SUFFIX: Linux-aarch64 TARBALL_EXT: tar.xz +test-aarch64-linux-deb10: + extends: .test + needs: ["tar-aarch64-linux-deb10"] + tags: + - aarch64-linux + image: "registry.gitlab.haskell.org/ghc/ci-images/aarch64-linux-deb10:$DOCKER_REV" + + +###################### +# armv7 linux deb10 +###################### + build-armv7-linux-deb10: extends: .build before_script: @@ -93,6 +117,18 @@ tar-armv7-linux-deb10: TARBALL_ARCHIVE_SUFFIX: Linux-armv7 TARBALL_EXT: tar.xz +test-armv7-linux-deb10: + extends: .test + needs: ["tar-armv7-linux-deb10"] + tags: + - armv7-linux + image: "registry.gitlab.haskell.org/ghc/ci-images/armv7-linux-deb10:$DOCKER_REV" + + +###################### +# x86_64 linux deb10 +###################### + build-x86_64-linux: extends: .build before_script: @@ -117,6 +153,18 @@ tar-x86_64-linux: TARBALL_ARCHIVE_SUFFIX: Linux-x86_64 TARBALL_EXT: tar.xz +test-x86_64-linux: + extends: .test + needs: ["tar-x86_64-linux"] + tags: + - x86_64-linux + image: "registry.gitlab.haskell.org/ghc/ci-images/x86_64-linux-deb10:$DOCKER_REV" + + +###################### +# x86_64 linux alpine +###################### + build-x86_64-linux-alpine: extends: .build tags: @@ -140,6 +188,20 @@ tar-x86_64-linux-alpine: TARBALL_ARCHIVE_SUFFIX: Linux-alpine-x86_64 TARBALL_EXT: tar.xz +tar-x86_64-linux-alpine: + extends: .test + needs: ["tar-x86_64-linux-alpine"] + tags: + - x86_64-linux + image: "registry.gitlab.haskell.org/ghc/ci-images/x86_64-linux-alpine3_12:$DOCKER_REV" + before_script: + - sudo apk add --no-cache zlib zlib-dev zlib-static bzip2 bzip2-dev bzip2-static gmp gmp-dev xz xz-dev ncurses-static + + +###################### +# x86_64 freebsd 12 +###################### + build-x86_64-freebsd12: extends: .build before_script: @@ -161,6 +223,19 @@ tar-x86_64-freebsd12: TARBALL_ARCHIVE_SUFFIX: FreeBSD12-x86_64 TARBALL_EXT: tar.xz +test-x86_64-freebsd12: + extends: .test + needs: ["tar-x86_64-freebsd12"] + tags: + - x86_64-freebsd12 + before_script: + - sudo pkg install --yes patchelf gmake + + +###################### +# x86_64 freebsd 13 +###################### + build-x86_64-freebsd13: extends: .build tags: @@ -184,6 +259,21 @@ tar-x86_64-freebsd13: TARBALL_ARCHIVE_SUFFIX: FreeBSD13-x86_64 TARBALL_EXT: tar.xz +test-x86_64-freebsd13: + extends: .test + needs: ["tar-x86_64-freebsd13"] + tags: + - x86_64-freebsd13 + before_script: + - sudo pkg update + - sudo pkg install --yes compat12x-amd64 gmake + - sudo ln -s libncurses.so.6 /usr/local/lib/libncurses.so.6.2 + + +###################### +# x86_64 darwin +###################### + build-x86_64-darwin: extends: .build tags: @@ -203,6 +293,17 @@ tar-x86_64-darwin: TARBALL_ARCHIVE_SUFFIX: macOS-x86_64 TARBALL_EXT: tar.xz +test-x86_64-darwin: + extends: .test + needs: ["tar-x86_64-darwin"] + tags: + - x86_64-darwin + + +###################### +# aarch64 darwin +###################### + build-aarch64-darwin: extends: .artifacts:short stage: build @@ -254,6 +355,47 @@ tar-aarch64-darwin: TARBALL_ARCHIVE_SUFFIX: macOS-aarch64 TARBALL_EXT: tar.xz +test-aarch64-darwin: + extends: .test + needs: ["tar-aarch64-darwin"] + tags: + - aarch64-darwin-m1 + before_script: + # Install brew locally in the project dir. Packages will also be installed here. + - '[ -e "$CI_PROJECT_DIR/.brew" ] || git clone --depth=1 https://github.com/Homebrew/brew $CI_PROJECT_DIR/.brew' + - export PATH="$CI_PROJECT_DIR/.brew/bin:$CI_PROJECT_DIR/.brew/sbin:$PATH" + + # otherwise we seem to get intel binaries + - export HOMEBREW_CHANGE_ARCH_TO_ARM=1 + + # make sure to not pollute the machine with temp files etc + - mkdir -p $CI_PROJECT_DIR/.brew_cache + - export HOMEBREW_CACHE=$CI_PROJECT_DIR/.brew_cache + - mkdir -p $CI_PROJECT_DIR/.brew_logs + - export HOMEBREW_LOGS=$CI_PROJECT_DIR/.brew_logs + - mkdir -p /private/tmp/.brew_tmp + - export HOMEBREW_TEMP=/private/tmp/.brew_tmp + + # update and install packages + - brew update + - brew install llvm + - brew install autoconf automake coreutils + script: | + export PATH="$CI_PROJECT_DIR/.brew/opt/llvm/bin:$CI_PROJECT_DIR/.brew/bin:$CI_PROJECT_DIR/.brew/sbin:$PATH" + export CC=$CI_PROJECT_DIR/.brew/opt/llvm/bin/clang + export CXX=$CI_PROJECT_DIR/.brew/opt/llvm/bin/clang++ + export LD=ld + export AR=$CI_PROJECT_DIR/.brew/opt/llvm/bin/llvm-ar + export RANLIB=$CI_PROJECT_DIR/.brew/opt/llvm/bin/llvm-ranlib + arch -arm64 /bin/bash ./.gitlab/test.sh + after_script: + - rm -Rf /private/tmp/.brew_tmp + + +###################### +# x86_64 windows +###################### + build-x86_64-windows: extends: .build tags: diff --git a/.gitlab/tar.sh b/.gitlab/tar.sh index bbfe27ead9..9468e31ef8 100755 --- a/.gitlab/tar.sh +++ b/.gitlab/tar.sh @@ -16,7 +16,7 @@ case "${TARBALL_EXT}" in find . -type f ! -name '*.zip' -delete ;; tar.xz) - emake bindist-tar + emake TARBALL="${TARBALL_PREFIX}-${TARBALL_ARCHIVE_SUFFIX}-${HLS_VERSION}.tar.xz" bindist-tar rm -rf out/bindist ;; *) diff --git a/.gitlab/test.sh b/.gitlab/test.sh new file mode 100644 index 0000000000..546f99d3c5 --- /dev/null +++ b/.gitlab/test.sh @@ -0,0 +1,59 @@ +#!/usr/bin/env bash + +set -Eeuxo pipefail + +source "$CI_PROJECT_DIR/.gitlab/common.sh" + +export GHCUP_INSTALL_BASE_PREFIX="$CI_PROJECT_DIR/toolchain" +export CABAL_DIR="$CI_PROJECT_DIR/cabal" + +case "$(uname)" in + MSYS_*|MINGW*) + export CABAL_DIR="$(cygpath -w "$CABAL_DIR")" + GHCUP_BINDIR="${GHCUP_INSTALL_BASE_PREFIX}/ghcup/bin" + ;; + *) + GHCUP_BINDIR="${GHCUP_INSTALL_BASE_PREFIX}/.ghcup/bin" + ;; +esac + +mkdir -p "$CABAL_DIR" +mkdir -p "$GHCUP_BINDIR" +export PATH="$GHCUP_BINDIR:$PATH" + +export BOOTSTRAP_HASKELL_NONINTERACTIVE=1 +export BOOTSTRAP_HASKELL_GHC_VERSION="${GHC_VERSION:-recommended}" +export BOOTSTRAP_HASKELL_CABAL_VERSION="$CABAL_INSTALL_VERSION" +export BOOTSTRAP_HASKELL_VERBOSE=1 +export BOOTSTRAP_HASKELL_ADJUST_CABAL_CONFIG=yes + +# for some reason the subshell doesn't pick up the arm64 environment on darwin +# and starts installing x86_64 GHC +case "$(uname -s)" in + "Darwin"|"darwin") + case "$(/usr/bin/arch)" in + aarch64|arm64|armv8l) + curl --proto '=https' --tlsv1.2 -sSf https://get-ghcup.haskell.org | arch -arm64 /bin/bash + ;; + *) + curl --proto '=https' --tlsv1.2 -sSf https://get-ghcup.haskell.org | sh + ;; + esac + ;; + *) + curl --proto '=https' --tlsv1.2 -sSf https://get-ghcup.haskell.org | sh + ;; +esac + +cd "$CI_PROJECT_DIR/out/" + +tar xf *.tar.xz +cd haskell-language-server-* +emake PREFIX=$HOME/.local +export PATH="$HOME/.local/bin:$PATH" +cd "$CI_PROJECT_DIR" +cabal unpack bytestring-0.11.2.0 +cd bytestring-0.11.2.0 +echo "cradle:" > hie.yaml +echo " cabal:" >> hie.yaml +haskell-language-server-wrapper typecheck Data/ByteString.hs diff --git a/Makefile b/Makefile index 38a861e8fb..5213dc8d95 100644 --- a/Makefile +++ b/Makefile @@ -4,6 +4,7 @@ ROOT_DIR:=$(shell dirname $(realpath $(firstword $(MAKEFILE_LIST)))) GHC_VERSION ?= HLS_VERSION := $(shell grep '^version:' haskell-language-server.cabal | awk '{ print $$2 }') +TARBALL ?= haskell-language-server-$(HLS_VERSION).tar.xz CHMOD := chmod INSTALL := install @@ -53,7 +54,7 @@ bindist: $(INSTALL) -vm 755 bindist/relpath.sh $(BINDIST_OUT_DIR)/scripts/relpath.sh bindist-tar: - cd $(BINDIST_BASE_DIR) ; $(TAR) caf $(ROOT_DIR)/out/haskell-language-server-$(HLS_VERSION).tar.xz haskell-language-server-$(HLS_VERSION) + cd $(BINDIST_BASE_DIR) ; $(TAR) caf $(ROOT_DIR)/out/$(TARBALL) haskell-language-server-$(HLS_VERSION) bindist-ghc: if test -z "$(GHC_VERSION)" ; then echo >&2 "GHC_VERSION is not set" ; false ; fi From 5d1028c940c4ecb7da53197ddb10b0a0766f8796 Mon Sep 17 00:00:00 2001 From: Julian Ospald Date: Wed, 2 Feb 2022 23:14:52 +0100 Subject: [PATCH 11/33] Implement --print-libdir for hls exe as well --- src/Ide/Main.hs | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/Ide/Main.hs b/src/Ide/Main.hs index 8749da9d67..3925c985a7 100644 --- a/src/Ide/Main.hs +++ b/src/Ide/Main.hs @@ -23,6 +23,8 @@ import qualified Development.IDE.Main as Main import qualified Development.IDE.Session as Session import Development.IDE.Types.Logger as G import qualified Development.IDE.Types.Options as Ghcide +import HIE.Bios.Types +import qualified HIE.Bios.Environment as HieBios import Ide.Arguments import Ide.Logger import Ide.Plugin.ConfigUtils (pluginsToDefaultConfig, @@ -31,7 +33,9 @@ import Ide.Types (IdePlugins, PluginId (PluginId), ipMap) import Ide.Version import qualified Language.LSP.Server as LSP +import System.Directory import qualified System.Directory.Extra as IO +import System.FilePath import System.IO import qualified System.Log.Logger as L @@ -76,7 +80,13 @@ defaultMain args idePlugins = do DefaultConfigurationMode -> do LBS.putStrLn $ A.encodePretty $ pluginsToDefaultConfig idePlugins - _ -> pure () + PrintLibDir -> do + d <- getCurrentDirectory + let initialFp = d "a" + hieYaml <- Session.findCradle def initialFp + cradle <- Session.loadCradle def hieYaml d + (CradleSuccess libdir) <- HieBios.getRuntimeGhcLibDir cradle + putStr libdir -- --------------------------------------------------------------------- From 7ba0415dc7c2ab06e9f34bec0f61b4ea3dff8848 Mon Sep 17 00:00:00 2001 From: Julian Ospald Date: Wed, 2 Feb 2022 23:22:37 +0100 Subject: [PATCH 12/33] Fix make --- .gitlab-ci.yml | 69 ++++++++++++++++++++------ .gitlab/ci.sh | 1 + .gitlab/common.sh | 10 ++++ .gitlab/tar.sh | 6 ++- .gitlab/test.sh | 4 +- GNUmakefile | 110 +++++++++++++++++++++++++++++++++++++++++ Makefile | 98 ------------------------------------ bindist/GNUmakefile.in | 40 +++++++++++++++ bindist/Makefile.in | 36 -------------- bindist/relpath.sh | 56 ++++++++++++++++++++- bindist/wrapper.in | 2 +- 11 files changed, 276 insertions(+), 156 deletions(-) create mode 100644 GNUmakefile delete mode 100644 Makefile create mode 100644 bindist/GNUmakefile.in delete mode 100644 bindist/Makefile.in diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 51176b115f..71fc285996 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -47,7 +47,6 @@ workflow: - bash .gitlab/ci.sh .test: - extends: .artifacts:short stage: test script: - bash .gitlab/test.sh @@ -78,7 +77,7 @@ tar-aarch64-linux-deb10: script: - ./.gitlab/tar.sh variables: - TARBALL_ARCHIVE_SUFFIX: Linux-aarch64 + TARBALL_ARCHIVE_SUFFIX: aarch64-deb10-linux TARBALL_EXT: tar.xz test-aarch64-linux-deb10: @@ -114,7 +113,7 @@ tar-armv7-linux-deb10: script: - ./.gitlab/tar.sh variables: - TARBALL_ARCHIVE_SUFFIX: Linux-armv7 + TARBALL_ARCHIVE_SUFFIX: armv7-deb10-linux TARBALL_EXT: tar.xz test-armv7-linux-deb10: @@ -150,7 +149,7 @@ tar-x86_64-linux: script: - ./.gitlab/tar.sh variables: - TARBALL_ARCHIVE_SUFFIX: Linux-x86_64 + TARBALL_ARCHIVE_SUFFIX: x86_64-deb10-linux TARBALL_EXT: tar.xz test-x86_64-linux: @@ -171,7 +170,7 @@ build-x86_64-linux-alpine: - x86_64-linux image: "registry.gitlab.haskell.org/ghc/ci-images/x86_64-linux-alpine3_12:$DOCKER_REV" before_script: - - sudo apk add --no-cache zlib zlib-dev zlib-static bzip2 bzip2-dev bzip2-static gmp gmp-dev xz xz-dev ncurses-static patchelf findutils + - sudo apk add --no-cache tar zlib zlib-dev zlib-static bzip2 bzip2-dev bzip2-static gmp gmp-dev xz xz-dev ncurses-static patchelf findutils variables: ADD_CABAL_ARGS: "--enable-split-sections --enable-executable-static" @@ -182,20 +181,22 @@ tar-x86_64-linux-alpine: tags: - x86_64-linux image: "registry.gitlab.haskell.org/ghc/ci-images/x86_64-linux-alpine3_12:$DOCKER_REV" + before_script: + - sudo apk add --no-cache tar zlib zlib-dev zlib-static bzip2 bzip2-dev bzip2-static gmp gmp-dev xz xz-dev ncurses-static script: - ./.gitlab/tar.sh variables: - TARBALL_ARCHIVE_SUFFIX: Linux-alpine-x86_64 + TARBALL_ARCHIVE_SUFFIX: x86_64-alpine3.12-linux TARBALL_EXT: tar.xz -tar-x86_64-linux-alpine: +test-x86_64-linux-alpine: extends: .test needs: ["tar-x86_64-linux-alpine"] tags: - x86_64-linux image: "registry.gitlab.haskell.org/ghc/ci-images/x86_64-linux-alpine3_12:$DOCKER_REV" before_script: - - sudo apk add --no-cache zlib zlib-dev zlib-static bzip2 bzip2-dev bzip2-static gmp gmp-dev xz xz-dev ncurses-static + - sudo apk add --no-cache tar zlib zlib-dev zlib-static bzip2 bzip2-dev bzip2-static gmp gmp-dev xz xz-dev ncurses-static ###################### @@ -220,7 +221,7 @@ tar-x86_64-freebsd12: script: - ./.gitlab/tar.sh variables: - TARBALL_ARCHIVE_SUFFIX: FreeBSD12-x86_64 + TARBALL_ARCHIVE_SUFFIX: x86_64-unknown-freebsd12 TARBALL_EXT: tar.xz test-x86_64-freebsd12: @@ -256,7 +257,7 @@ tar-x86_64-freebsd13: script: - ./.gitlab/tar.sh variables: - TARBALL_ARCHIVE_SUFFIX: FreeBSD13-x86_64 + TARBALL_ARCHIVE_SUFFIX: x86_64-unknown-freebsd13 TARBALL_EXT: tar.xz test-x86_64-freebsd13: @@ -280,6 +281,25 @@ build-x86_64-darwin: - x86_64-darwin variables: ADD_CABAL_ARGS: "" + before_script: + # Install brew locally in the project dir. Packages will also be installed here. + - '[ -e "$CI_PROJECT_DIR/.brew" ] || git clone --depth=1 https://github.com/Homebrew/brew $CI_PROJECT_DIR/.brew' + - export PATH="$CI_PROJECT_DIR/.brew/bin:$CI_PROJECT_DIR/.brew/sbin:$PATH" + + # make sure to not pollute the machine with temp files etc + - mkdir -p $CI_PROJECT_DIR/.brew_cache + - export HOMEBREW_CACHE=$CI_PROJECT_DIR/.brew_cache + - mkdir -p $CI_PROJECT_DIR/.brew_logs + - export HOMEBREW_LOGS=$CI_PROJECT_DIR/.brew_logs + - mkdir -p /private/tmp/.brew_tmp + - export HOMEBREW_TEMP=/private/tmp/.brew_tmp + + # update and install packages + - brew update + - brew install autoconf automake coreutils make + script: | + export PATH="$CI_PROJECT_DIR/.brew/bin:$CI_PROJECT_DIR/.brew/sbin:$PATH" + /bin/bash ./.gitlab/ci.sh tar-x86_64-darwin: extends: .artifacts @@ -287,10 +307,27 @@ tar-x86_64-darwin: needs: ["build-x86_64-darwin"] tags: - x86_64-darwin - script: - - ./.gitlab/tar.sh + before_script: + # Install brew locally in the project dir. Packages will also be installed here. + - '[ -e "$CI_PROJECT_DIR/.brew" ] || git clone --depth=1 https://github.com/Homebrew/brew $CI_PROJECT_DIR/.brew' + - export PATH="$CI_PROJECT_DIR/.brew/bin:$CI_PROJECT_DIR/.brew/sbin:$PATH" + + # make sure to not pollute the machine with temp files etc + - mkdir -p $CI_PROJECT_DIR/.brew_cache + - export HOMEBREW_CACHE=$CI_PROJECT_DIR/.brew_cache + - mkdir -p $CI_PROJECT_DIR/.brew_logs + - export HOMEBREW_LOGS=$CI_PROJECT_DIR/.brew_logs + - mkdir -p /private/tmp/.brew_tmp + - export HOMEBREW_TEMP=/private/tmp/.brew_tmp + + # update and install packages + - brew update + - brew install autoconf automake coreutils make + script: | + export PATH="$CI_PROJECT_DIR/.brew/bin:$CI_PROJECT_DIR/.brew/sbin:$PATH" + /bin/bash ./.gitlab/tar.sh variables: - TARBALL_ARCHIVE_SUFFIX: macOS-x86_64 + TARBALL_ARCHIVE_SUFFIX: x86_64-apple-darwin TARBALL_EXT: tar.xz test-x86_64-darwin: @@ -328,7 +365,7 @@ build-aarch64-darwin: # update and install packages - brew update - brew install llvm - - brew install autoconf automake coreutils + - brew install autoconf automake coreutils make script: | export PATH="$CI_PROJECT_DIR/.brew/opt/llvm/bin:$CI_PROJECT_DIR/.brew/bin:$CI_PROJECT_DIR/.brew/sbin:$PATH" export CC=$CI_PROJECT_DIR/.brew/opt/llvm/bin/clang @@ -352,7 +389,7 @@ tar-aarch64-darwin: script: - arch -arm64 /bin/bash ./.gitlab/tar.sh variables: - TARBALL_ARCHIVE_SUFFIX: macOS-aarch64 + TARBALL_ARCHIVE_SUFFIX: aarch64-apple-darwin TARBALL_EXT: tar.xz test-aarch64-darwin: @@ -417,5 +454,5 @@ tar-x86_64-windows: - $env:CHERE_INVOKING = "yes" - bash '-lc' "TARBALL_ARCHIVE_SUFFIX=$env:TARBALL_ARCHIVE_SUFFIX TARBALL_EXT=$env:TARBALL_EXT .gitlab/tar.sh" variables: - TARBALL_ARCHIVE_SUFFIX: Windows-x86_64 + TARBALL_ARCHIVE_SUFFIX: x86_64-unknown-mingw32 TARBALL_EXT: zip diff --git a/.gitlab/ci.sh b/.gitlab/ci.sh index 8225449137..c2d6893f94 100755 --- a/.gitlab/ci.sh +++ b/.gitlab/ci.sh @@ -72,6 +72,7 @@ case "$(uname)" in cp "$(cabal list-bin ${args[@]} exe:hls-wrapper)" "$CI_PROJECT_DIR/out/haskell-language-server-wrapper" ;; *) + emake --version emake install-ghcs emake hls emake bindist diff --git a/.gitlab/common.sh b/.gitlab/common.sh index e3973a1796..957b4fdc3e 100644 --- a/.gitlab/common.sh +++ b/.gitlab/common.sh @@ -56,3 +56,13 @@ emake() { fi } +mktempdir() { + case "$(uname -s)" in + "Darwin"|"darwin") + mktemp -d -t hls_ci.XXXXXXX + ;; + *) + mktemp -d + ;; + esac +} diff --git a/.gitlab/tar.sh b/.gitlab/tar.sh index 9468e31ef8..bca0a5d8a7 100755 --- a/.gitlab/tar.sh +++ b/.gitlab/tar.sh @@ -12,11 +12,13 @@ case "${TARBALL_EXT}" in zip) HLS_VERSION="$("$CI_PROJECT_DIR/out/haskell-language-server-wrapper" --numeric-version)" cd out/ - zip "${TARBALL_PREFIX}-${TARBALL_ARCHIVE_SUFFIX}-${HLS_VERSION}.zip" haskell-language-server-* + zip "${TARBALL_PREFIX}-${HLS_VERSION}-${TARBALL_ARCHIVE_SUFFIX}.zip" haskell-language-server-* find . -type f ! -name '*.zip' -delete ;; tar.xz) - emake TARBALL="${TARBALL_PREFIX}-${TARBALL_ARCHIVE_SUFFIX}-${HLS_VERSION}.tar.xz" bindist-tar + emake --version + HLS_VERSION="$(emake -s -C out/bindist/haskell-language-server-* version)" + emake TARBALL="${TARBALL_PREFIX}-${HLS_VERSION}-${TARBALL_ARCHIVE_SUFFIX}.tar.xz" bindist-tar rm -rf out/bindist ;; *) diff --git a/.gitlab/test.sh b/.gitlab/test.sh index 546f99d3c5..722189118c 100644 --- a/.gitlab/test.sh +++ b/.gitlab/test.sh @@ -48,10 +48,12 @@ esac cd "$CI_PROJECT_DIR/out/" tar xf *.tar.xz +rm *.tar.xz cd haskell-language-server-* emake PREFIX=$HOME/.local export PATH="$HOME/.local/bin:$PATH" -cd "$CI_PROJECT_DIR" +tmp_dir=$(mktempdir) +cd "$tmp_dir" cabal unpack bytestring-0.11.2.0 cd bytestring-0.11.2.0 echo "cradle:" > hie.yaml diff --git a/GNUmakefile b/GNUmakefile new file mode 100644 index 0000000000..10c13463dd --- /dev/null +++ b/GNUmakefile @@ -0,0 +1,110 @@ +UNAME := $(shell uname) +ROOT_DIR:=$(shell dirname $(realpath $(firstword $(MAKEFILE_LIST)))) + +GHC_VERSION ?= + +HLS_VERSION := $(shell grep '^version:' haskell-language-server.cabal | awk '{ print $$2 }') +TARBALL ?= haskell-language-server-$(HLS_VERSION).tar.xz + +CHMOD := chmod +CHMOD_X := $(CHMOD) 755 +INSTALL := install +INSTALL_D := $(INSTALL) -d +INSTALL_X := $(INSTALL) -vm 755 +PATCHELF := patchelf +FIND := find +SED := sed +MKDIR := mkdir +MKDIR_P := $(MKDIR) -p +TAR := tar +TAR_MK := $(TAR) caf +CABAL := cabal +AWK := awk +STRIP := strip +ifeq ($(UNAME), Darwin) +STRIP_S := strip +else +STRIP_S := strip -s +endif +RM := rm +RM_RF := $(RM) -rf +CD := cd + +INSTALL_NAME_TOOL := install_name_tool + +STORE_DIR := store +BINDIST_BASE_DIR := out/bindist +BINDIST_OUT_DIR := $(BINDIST_BASE_DIR)/haskell-language-server-$(HLS_VERSION) + +CABAL_ARGS ?= --store-dir=$(ROOT_DIR)/$(STORE_DIR) +CABAL_INSTALL_ARGS ?= --disable-tests --disable-profiling -O2 --overwrite-policy=always --install-method=copy +CABAL_INSTALL := $(CABAL) $(CABAL_ARGS) v2-install + +# set rpath relative to the current executable +# TODO: on darwin, this doesn't overwrite rpath, but just adds to it, +# so we'll have the old rpaths from the build host in there as well +define set_rpath + $(if $(filter Darwin,$(UNAME)), $(INSTALL_NAME_TOOL) -add_rpath "@executable_path/$(1)" "$(2)", $(PATCHELF) --force-rpath --set-rpath "\$$ORIGIN/$(1)" "$(2)") +endef + +hls: bindist/ghcs + for ghc in $(shell cat bindist/ghcs) ; do \ + $(MAKE) GHC_VERSION=`echo $$ghc | $(AWK) -F ',' '{ print $$1 }'` PROJECT_FILE=`echo $$ghc | $(AWK) -F ',' '{ print $$2 }'` hls-ghc ; \ + done + +hls-ghc: + $(MKDIR_P) out/ + @if test -z "$(GHC_VERSION)" ; then echo >&2 "GHC_VERSION is not set" ; false ; fi + @if test -z "$(PROJECT_FILE)" ; then echo >&2 "PROJECT_FILE is not set" ; false ; fi + $(CABAL_INSTALL) --project-file="$(PROJECT_FILE)" -w "ghc-$(GHC_VERSION)" $(CABAL_INSTALL_ARGS) --installdir="$(ROOT_DIR)/out/$(GHC_VERSION)" exe:haskell-language-server exe:haskell-language-server-wrapper + $(STRIP_S) "$(ROOT_DIR)/out/$(GHC_VERSION)/haskell-language-server" + $(STRIP_S) "$(ROOT_DIR)/out/$(GHC_VERSION)/haskell-language-server-wrapper" + +bindist: + for ghc in $(shell cat bindist/ghcs) ; do \ + $(MAKE) GHC_VERSION=`echo $$ghc | $(AWK) -F ',' '{ print $$1 }'` bindist-ghc ; \ + done + $(SED) -e "s/@@HLS_VERSION@@/$(HLS_VERSION)/" \ + bindist/GNUmakefile.in > "$(BINDIST_OUT_DIR)/GNUmakefile" + $(INSTALL_D) "$(BINDIST_OUT_DIR)/scripts/" + $(INSTALL_X) "bindist/relpath.sh" "$(BINDIST_OUT_DIR)/scripts/relpath.sh" + +bindist-tar: + $(CD) "$(BINDIST_BASE_DIR)" ; $(TAR_MK) "$(ROOT_DIR)/out/$(TARBALL)" "haskell-language-server-$(HLS_VERSION)" + +bindist-ghc: + if test -z "$(GHC_VERSION)" ; then echo >&2 "GHC_VERSION is not set" ; false ; fi + $(MKDIR_P) "$(BINDIST_OUT_DIR)/bin" + $(MKDIR_P) "$(BINDIST_OUT_DIR)/lib/$(GHC_VERSION)" + $(INSTALL_D) "$(BINDIST_OUT_DIR)/bin/" + $(INSTALL_X) "out/$(GHC_VERSION)/haskell-language-server" "$(BINDIST_OUT_DIR)/bin/haskell-language-server-$(GHC_VERSION)" + $(call set_rpath,../lib/$(GHC_VERSION),$(BINDIST_OUT_DIR)/bin/haskell-language-server-$(GHC_VERSION)) + $(SED) \ + -e "s/@@EXE_NAME@@/haskell-language-server-$(GHC_VERSION)/" \ + -e "s/@@GHC_VERSION@@/$(GHC_VERSION)/" \ + -e "s/@@ABI_HASHES@@/$(shell for dep in ghc `ghc-pkg-$(GHC_VERSION) field ghc depends --simple-output` ; do 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" + $(INSTALL_D) "$(BINDIST_OUT_DIR)/bin/" + $(INSTALL_X) "out/$(GHC_VERSION)/haskell-language-server-wrapper" "$(BINDIST_OUT_DIR)/bin/haskell-language-server-wrapper" + $(INSTALL_D) "$(ROOT_DIR)/$(BINDIST_OUT_DIR)/lib/$(GHC_VERSION)" + $(FIND) "$(STORE_DIR)/ghc-$(GHC_VERSION)" -type f -name "*.so" -execdir $(INSTALL_X) "{}" "$(ROOT_DIR)/$(BINDIST_OUT_DIR)/lib/$(GHC_VERSION)/{}" \; + $(FIND) "$(ROOT_DIR)/$(BINDIST_OUT_DIR)/lib/$(GHC_VERSION)" -type f -name '*.so' -execdir $(call set_rpath,,{}) \; + +install-ghcs: + ghcup install ghc recommended + ghcup set ghc recommended + for ghc in $(shell cat bindist/ghcs) ; do \ + ghcup install ghc `echo $$ghc | $(AWK) -F ',' '{ print $$1 }'` ; \ + done + +version: + @echo "$(HLS_VERSION)" + +clean: + $(RM_RF) out/* + +clean-all: + $(RM_RF) out/* $(STORE_DIR) + +.PHONY: hls hls-ghc bindist bindist-ghc bindist-tar clean clean-all install-ghcs diff --git a/Makefile b/Makefile deleted file mode 100644 index 5213dc8d95..0000000000 --- a/Makefile +++ /dev/null @@ -1,98 +0,0 @@ -UNAME := $(shell uname) -ROOT_DIR:=$(shell dirname $(realpath $(firstword $(MAKEFILE_LIST)))) - -GHC_VERSION ?= - -HLS_VERSION := $(shell grep '^version:' haskell-language-server.cabal | awk '{ print $$2 }') -TARBALL ?= haskell-language-server-$(HLS_VERSION).tar.xz - -CHMOD := chmod -INSTALL := install -PATCHELF := patchelf -FIND := find -SED := sed -MKDIR := mkdir -TAR := tar -CABAL := cabal -AWK := awk -STRIP := strip - -INSTALL_NAME_TOOL := install_name_tool - -STORE_DIR := store -BINDIST_BASE_DIR := out/bindist -BINDIST_OUT_DIR := $(BINDIST_BASE_DIR)/haskell-language-server-$(HLS_VERSION) - -CABAL_ARGS ?= --store-dir=$(ROOT_DIR)/$(STORE_DIR) -CABAL_INSTALL_ARGS ?= --disable-tests --disable-profiling -O2 --overwrite-policy=always --install-method=copy - -hls: bindist/ghcs - for ghc in $(shell cat bindist/ghcs) ; do \ - $(MAKE) GHC_VERSION=`echo $$ghc | $(AWK) -F ',' '{ print $$1 }'` PROJECT_FILE=`echo $$ghc | $(AWK) -F ',' '{ print $$2 }'` hls-ghc ; \ - done - -hls-ghc: - $(MKDIR) -p out/ - @if test -z "$(GHC_VERSION)" ; then echo >&2 "GHC_VERSION is not set" ; false ; fi - @if test -z "$(PROJECT_FILE)" ; then echo >&2 "PROJECT_FILE is not set" ; false ; fi - $(CABAL) $(CABAL_ARGS) v2-install --project-file=$(PROJECT_FILE) -w ghc-$(GHC_VERSION) $(CABAL_INSTALL_ARGS) --installdir=$(ROOT_DIR)/out/$(GHC_VERSION) exe:haskell-language-server exe:haskell-language-server-wrapper -ifeq ($(UNAME), Darwin) - $(STRIP) $(ROOT_DIR)/out/$(GHC_VERSION)/haskell-language-server - $(STRIP) $(ROOT_DIR)/out/$(GHC_VERSION)/haskell-language-server-wrapper -else - $(STRIP) -s $(ROOT_DIR)/out/$(GHC_VERSION)/haskell-language-server - $(STRIP) -s $(ROOT_DIR)/out/$(GHC_VERSION)/haskell-language-server-wrapper -endif - -bindist: - for ghc in $(shell cat bindist/ghcs) ; do \ - $(MAKE) GHC_VERSION=`echo $$ghc | $(AWK) -F ',' '{ print $$1 }'` bindist-ghc ; \ - done - $(SED) -e "s/@@HLS_VERSION@@/$(HLS_VERSION)/" \ - bindist/Makefile.in > $(BINDIST_OUT_DIR)/Makefile - $(INSTALL) -d $(BINDIST_OUT_DIR)/scripts/ - $(INSTALL) -vm 755 bindist/relpath.sh $(BINDIST_OUT_DIR)/scripts/relpath.sh - -bindist-tar: - cd $(BINDIST_BASE_DIR) ; $(TAR) caf $(ROOT_DIR)/out/$(TARBALL) haskell-language-server-$(HLS_VERSION) - -bindist-ghc: - if test -z "$(GHC_VERSION)" ; then echo >&2 "GHC_VERSION is not set" ; false ; fi - $(MKDIR) -p $(BINDIST_OUT_DIR)/bin - $(MKDIR) -p $(BINDIST_OUT_DIR)/lib/$(GHC_VERSION) - $(INSTALL) -d $(BINDIST_OUT_DIR)/bin/ - $(INSTALL) -vm 755 out/$(GHC_VERSION)/haskell-language-server $(BINDIST_OUT_DIR)/bin/haskell-language-server-$(GHC_VERSION) -ifeq ($(UNAME), Darwin) - $(INSTALL_NAME_TOOL) -add_rpath "@executable_path/../lib/$(GHC_VERSION)" $(BINDIST_OUT_DIR)/bin/haskell-language-server-$(GHC_VERSION) -else - $(PATCHELF) --set-rpath \$$ORIGIN/../lib/$(GHC_VERSION) $(BINDIST_OUT_DIR)/bin/haskell-language-server-$(GHC_VERSION) -endif - $(SED) \ - -e "s/@@EXE_NAME@@/haskell-language-server-$(GHC_VERSION)/" \ - -e "s/@@GHC_VERSION@@/$(GHC_VERSION)/" \ - -e "s/@@ABI_HASHES@@/$(shell for dep in ghc `ghc-pkg-$(GHC_VERSION) field ghc depends --simple-output` ; do ghc-pkg-$(GHC_VERSION) field $$dep abi --simple-output ; done | tr '\n' ' ' | xargs)/" \ - bindist/wrapper.in > $(BINDIST_OUT_DIR)/haskell-language-server-$(GHC_VERSION) - $(CHMOD) 755 $(BINDIST_OUT_DIR)/haskell-language-server-$(GHC_VERSION) - $(INSTALL) -d $(BINDIST_OUT_DIR)/bin/ - $(INSTALL) -vm 755 out/$(GHC_VERSION)/haskell-language-server-wrapper $(BINDIST_OUT_DIR)/bin/haskell-language-server-wrapper - $(FIND) $(STORE_DIR)/ghc-$(GHC_VERSION) -type f -name "*.so" -execdir install -vDm 755 {} $(ROOT_DIR)/$(BINDIST_OUT_DIR)/lib/$(GHC_VERSION)/{} \; - $(FIND) $(ROOT_DIR)/$(BINDIST_OUT_DIR)/lib/$(GHC_VERSION) -type f -name '*.so' -execdir $(PATCHELF) --set-rpath \$$ORIGIN {} \; - -install-ghcs: - ghcup install ghc recommended - ghcup set ghc recommended - for ghc in $(shell cat bindist/ghcs) ; do \ - ghcup install ghc `echo $$ghc | $(AWK) -F ',' '{ print $$1 }'` ; \ - done - -version: - @echo $(HLS_VERSION) - - -clean: - rm -rf out/* - -clean-all: - rm -rf out/* $(STORE_DIR) - -.PHONY: hls hls-ghc bindist bindist-ghc bindist-tar clean clean-all install-ghcs diff --git a/bindist/GNUmakefile.in b/bindist/GNUmakefile.in new file mode 100644 index 0000000000..9247dbc828 --- /dev/null +++ b/bindist/GNUmakefile.in @@ -0,0 +1,40 @@ +DESTDIR ?= +PREFIX ?= /usr/local +LIBDIR ?= $(PREFIX)/lib +BINDIR ?= $(PREFIX)/bin + +HLS_VERSION := @@HLS_VERSION@@ + +INSTALL := install +INSTALL_D := $(INSTALL) -d +INSTALL_X := $(INSTALL) -vm 755 +SED := sed +CHMOD := chmod +CHMOD_X := $(CHMOD) 755 +LN := ln +LN_S := $(LN) -sf + +install: + $(INSTALL_D) "$(DESTDIR)$(BINDIR)" + $(INSTALL_D) "$(DESTDIR)$(LIBDIR)/haskell-language-server-$(HLS_VERSION)/lib" + $(INSTALL_D) "$(DESTDIR)$(LIBDIR)/haskell-language-server-$(HLS_VERSION)/bin" + for f in $(wildcard lib/*/*) ; do \ + $(INSTALL_D) "$(DESTDIR)$(LIBDIR)/haskell-language-server-$(HLS_VERSION)/`dirname $$f`" && \ + $(INSTALL_X) "$$f" "$(DESTDIR)$(LIBDIR)/haskell-language-server-$(HLS_VERSION)/$$f" ; \ + done + for b in $(wildcard bin/*) ; do \ + $(INSTALL_D) "$(DESTDIR)$(LIBDIR)/haskell-language-server-$(HLS_VERSION)/" && \ + $(INSTALL_X) "$$b" "$(DESTDIR)$(LIBDIR)/haskell-language-server-$(HLS_VERSION)/$$b" ; \ + done + for h in $(wildcard haskell-language-server-*.in) ; do \ + $(SED) -e "s#@@EXE_DIR@@#$(LIBDIR)/haskell-language-server-$(HLS_VERSION)/bin/#" \ + "$$h" > "$(DESTDIR)$(BINDIR)/$$h" && \ + $(CHMOD_X) "$(DESTDIR)$(BINDIR)/$$h" ; \ + done + $(LN_S) "`scripts/relpath.sh "$(BINDIR)" "$(LIBDIR)/haskell-language-server-$(HLS_VERSION)/bin/haskell-language-server-wrapper"`" \ + "$(DESTDIR)$(BINDIR)/haskell-language-server-wrapper" + +version: + @echo "$(HLS_VERSION)" + +.PHONY: install diff --git a/bindist/Makefile.in b/bindist/Makefile.in deleted file mode 100644 index 156aef1fd6..0000000000 --- a/bindist/Makefile.in +++ /dev/null @@ -1,36 +0,0 @@ -DESTDIR ?= -PREFIX ?= /usr/local -LIBDIR ?= $(PREFIX)/lib -BINDIR ?= $(PREFIX)/bin - -HLS_VERSION := @@HLS_VERSION@@ - -INSTALL := install -SED := sed -CHMOD := chmod -LN := ln - -install: - $(INSTALL) -d $(BINDIR) - $(INSTALL) -d $(LIBDIR)/haskell-language-server-$(HLS_VERSION)/lib - $(INSTALL) -d $(LIBDIR)/haskell-language-server-$(HLS_VERSION)/bin - for f in $(wildcard lib/*/*) ; do \ - $(INSTALL) -d $(LIBDIR)/haskell-language-server-$(HLS_VERSION)/ ; \ - $(INSTALL) -vm 755 $$f $(LIBDIR)/haskell-language-server-$(HLS_VERSION)/$$f ; \ - done - for b in $(wildcard bin/*) ; do \ - $(INSTALL) -d $(LIBDIR)/haskell-language-server-$(HLS_VERSION)/ ; \ - $(INSTALL) -vm 755 $$b $(LIBDIR)/haskell-language-server-$(HLS_VERSION)/$$b ; \ - done - for h in $(wildcard haskell-language-server-*) ; do \ - $(SED) -e "s#@@EXE_DIR@@#$(LIBDIR)/haskell-language-server-$(HLS_VERSION)/bin/#" \ - $$h > $(BINDIR)/$$h ; \ - $(CHMOD) 755 $(BINDIR)/$$h ; \ - done - $(LN) -s `scripts/relpath.sh "\`realpath $(BINDIR)\`" "\`realpath $(LIBDIR)/haskell-language-server-$(HLS_VERSION)/bin/haskell-language-server-wrapper\`"` \ - $(BINDIR)/haskell-language-server-wrapper - -version: - @echo $(HLS_VERSION) - -.PHONY: install diff --git a/bindist/relpath.sh b/bindist/relpath.sh index 8cd9217a60..3385155e97 100755 --- a/bindist/relpath.sh +++ b/bindist/relpath.sh @@ -9,8 +9,60 @@ ## and they WONT be normalized/escaped ## Result in "$return_value"# both $1 and $2 are absolute paths beginning with / -src="$(realpath $1)" -target="$(realpath $2)" +# @FUNCTION: die +# @USAGE: [msg] +# @DESCRIPTION: +# Exits the shell script with status code 2 +# and prints the given message in red to STDERR, if any. +die() { + (>&2 echo "$1") + exit 2 +} + +# @FUNCTION: posix_realpath +# @USAGE: +# @DESCRIPTION: +# Portably gets the realpath and prints it to stdout. +# This was initially inspired by +# https://gist.github.com/tvlooy/cbfbdb111a4ebad8b93e +# and +# https://stackoverflow.com/a/246128 +# +# If the file does not exist, just prints it appended to the current directory. +# @STDOUT: realpath of the given file +posix_realpath() { + [ -z "$1" ] && die "Internal error: no argument given to posix_realpath" + current_loop=0 + max_loops=50 + mysource=$1 + + while [ -h "${mysource}" ]; do + current_loop=$((current_loop+1)) + mydir="$( cd -P "$( dirname "${mysource}" )" > /dev/null 2>&1 && pwd )" + mysource="$(readlink "${mysource}")" + [ "${mysource%${mysource#?}}"x != '/x' ] && mysource="${mydir}/${mysource}" + + if [ ${current_loop} -gt ${max_loops} ] ; then + (>&2 echo "${1}: Too many levels of symbolic links") + exit 1 + fi + done + mydir="$( cd -P "$( dirname "${mysource}" )" > /dev/null 2>&1 && pwd )" + + # TODO: better distinguish between "does not exist" and "permission denied" + if [ -z "${mydir}" ] ; then + (>&2 echo "${1}: Permission denied") + echo "$(pwd)/$1" + else + echo "${mydir%/}/$(basename "${mysource}")" + fi + + unset current_loop max_loops mysource mydir +} + + +src="$(posix_realpath $1)" || exit 1 +target="$(posix_realpath $2)" || exit 1 common_part="$src" result="" diff --git a/bindist/wrapper.in b/bindist/wrapper.in index 2d47048c38..72e05a4119 100644 --- a/bindist/wrapper.in +++ b/bindist/wrapper.in @@ -36,7 +36,7 @@ fail_abi() { if [ -n "${GHC_LIBDIR}" ] ; then : # try hls-wrapper --print-libdir -elif command -v "${exedir}"/haskell-language-server-wrapper >/dev/null ; then +elif "${exedir}"/haskell-language-server-wrapper --version >/dev/null 2>/dev/null ; then GHC_LIBDIR="$("${exedir}"/haskell-language-server-wrapper --print-libdir)" || unset GHC_LIBDIR fi From 88a375fe40023e75979ddffcb8b63dfe4b16415e Mon Sep 17 00:00:00 2001 From: Julian Ospald Date: Thu, 3 Feb 2022 15:57:42 +0100 Subject: [PATCH 13/33] Compare all boot packages for ABI --- GNUmakefile | 2 +- bindist/wrapper.in | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/GNUmakefile b/GNUmakefile index 10c13463dd..1ad6ec3736 100644 --- a/GNUmakefile +++ b/GNUmakefile @@ -82,7 +82,7 @@ bindist-ghc: $(SED) \ -e "s/@@EXE_NAME@@/haskell-language-server-$(GHC_VERSION)/" \ -e "s/@@GHC_VERSION@@/$(GHC_VERSION)/" \ - -e "s/@@ABI_HASHES@@/$(shell for dep in ghc `ghc-pkg-$(GHC_VERSION) field ghc depends --simple-output` ; do ghc-pkg-$(GHC_VERSION) field $$dep abi --simple-output ; done | tr '\n' ' ' | xargs)/" \ + -e "s/@@ABI_HASHES@@/$(shell for dep in `ghc-pkg-$(GHC_VERSION) --global list --simple-output` ; do 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" $(INSTALL_D) "$(BINDIST_OUT_DIR)/bin/" diff --git a/bindist/wrapper.in b/bindist/wrapper.in index 72e05a4119..efa0a18b10 100644 --- a/bindist/wrapper.in +++ b/bindist/wrapper.in @@ -79,7 +79,7 @@ else fail_ghc_pkg "${GHC_PKG}" fi PKGCONF="${GHC_LIBDIR}/package.conf.d" -MY_ABI_HASHES="$(for dep in ghc $("${GHC_PKG}" --global --global-package-db "$PKGCONF" field ghc depends --simple-output) ; do "${GHC_PKG}" --global --global-package-db "$PKGCONF" field "${dep}" abi --simple-output ; done | tr '\n' ' ' | xargs)" +MY_ABI_HASHES="$(for dep in $("${GHC_PKG}" --global --global-package-db "$PKGCONF" list --simple-output) ; do "${GHC_PKG}" --global --global-package-db "$PKGCONF" field "${dep}" abi --simple-output ; done | tr '\n' ' ' | xargs)" [ "${ABI_HASHES}" = "${MY_ABI_HASHES}" ] || fail_abi "${MY_ABI_HASHES}" unset PKGCONF From 2e861df6bbcf260789340e2322783a9bf4aceb0e Mon Sep 17 00:00:00 2001 From: Julian Ospald Date: Thu, 3 Feb 2022 16:37:06 +0100 Subject: [PATCH 14/33] Fix hls binary name --- bindist/GNUmakefile.in | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/bindist/GNUmakefile.in b/bindist/GNUmakefile.in index 9247dbc828..5e1b01de26 100644 --- a/bindist/GNUmakefile.in +++ b/bindist/GNUmakefile.in @@ -28,8 +28,8 @@ install: done for h in $(wildcard haskell-language-server-*.in) ; do \ $(SED) -e "s#@@EXE_DIR@@#$(LIBDIR)/haskell-language-server-$(HLS_VERSION)/bin/#" \ - "$$h" > "$(DESTDIR)$(BINDIR)/$$h" && \ - $(CHMOD_X) "$(DESTDIR)$(BINDIR)/$$h" ; \ + "$$h" > "$(DESTDIR)$(BINDIR)/$${h%.in}" && \ + $(CHMOD_X) "$(DESTDIR)$(BINDIR)/$${h%.in}" ; \ done $(LN_S) "`scripts/relpath.sh "$(BINDIR)" "$(LIBDIR)/haskell-language-server-$(HLS_VERSION)/bin/haskell-language-server-wrapper"`" \ "$(DESTDIR)$(BINDIR)/haskell-language-server-wrapper" From 33893e0ce6721963f3fafdc4136e36ad9830cf35 Mon Sep 17 00:00:00 2001 From: Julian Ospald Date: Thu, 3 Feb 2022 16:43:50 +0100 Subject: [PATCH 15/33] Fix exit code when no HLS exe could be found --- exe/Wrapper.hs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/exe/Wrapper.hs b/exe/Wrapper.hs index 0f5d0de82a..926620ef5f 100644 --- a/exe/Wrapper.hs +++ b/exe/Wrapper.hs @@ -106,7 +106,7 @@ launchHaskellLanguageServer parsedArgs = do mexes <- traverse findExecutable candidates case asum mexes of - Nothing -> hPutStrLn stderr $ "Cannot find any haskell-language-server exe, looked for: " ++ intercalate ", " candidates + Nothing -> die $ "Cannot find any haskell-language-server exe, looked for: " ++ intercalate ", " candidates Just e -> do hPutStrLn stderr $ "Launching haskell-language-server exe at:" ++ e #ifdef mingw32_HOST_OS From 58dab4f3d5e1fbd6f8cc177d823b07df65ea52ab Mon Sep 17 00:00:00 2001 From: Julian Ospald Date: Thu, 3 Feb 2022 17:53:23 +0100 Subject: [PATCH 16/33] Fix dll on mac --- GNUmakefile | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/GNUmakefile b/GNUmakefile index 1ad6ec3736..e22d8c44f2 100644 --- a/GNUmakefile +++ b/GNUmakefile @@ -30,6 +30,12 @@ RM := rm RM_RF := $(RM) -rf CD := cd +ifeq ($(UNAME), Darwin) +DLL := *.dylib +else +DLL := *.so +endif + INSTALL_NAME_TOOL := install_name_tool STORE_DIR := store @@ -88,8 +94,8 @@ bindist-ghc: $(INSTALL_D) "$(BINDIST_OUT_DIR)/bin/" $(INSTALL_X) "out/$(GHC_VERSION)/haskell-language-server-wrapper" "$(BINDIST_OUT_DIR)/bin/haskell-language-server-wrapper" $(INSTALL_D) "$(ROOT_DIR)/$(BINDIST_OUT_DIR)/lib/$(GHC_VERSION)" - $(FIND) "$(STORE_DIR)/ghc-$(GHC_VERSION)" -type f -name "*.so" -execdir $(INSTALL_X) "{}" "$(ROOT_DIR)/$(BINDIST_OUT_DIR)/lib/$(GHC_VERSION)/{}" \; - $(FIND) "$(ROOT_DIR)/$(BINDIST_OUT_DIR)/lib/$(GHC_VERSION)" -type f -name '*.so' -execdir $(call set_rpath,,{}) \; + $(FIND) "$(STORE_DIR)/ghc-$(GHC_VERSION)" -type f -name "$(DLL)" -execdir $(INSTALL_X) "{}" "$(ROOT_DIR)/$(BINDIST_OUT_DIR)/lib/$(GHC_VERSION)/{}" \; + $(FIND) "$(ROOT_DIR)/$(BINDIST_OUT_DIR)/lib/$(GHC_VERSION)" -type f -name '$(DLL)' -execdir $(call set_rpath,,{}) \; install-ghcs: ghcup install ghc recommended From 472955ed8f3e769b606cc0064b082a248786e57c Mon Sep 17 00:00:00 2001 From: Julian Ospald Date: Thu, 3 Feb 2022 22:21:00 +0100 Subject: [PATCH 17/33] Add more distros --- .gitlab-ci.yml | 114 ++++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 109 insertions(+), 5 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 71fc285996..d096b472ef 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -128,7 +128,7 @@ test-armv7-linux-deb10: # x86_64 linux deb10 ###################### -build-x86_64-linux: +build-x86_64-linux-deb10: extends: .build before_script: - sudo apt update @@ -139,10 +139,10 @@ build-x86_64-linux: variables: ADD_CABAL_ARGS: "--enable-split-sections" -tar-x86_64-linux: +tar-x86_64-linux-deb10: extends: .artifacts stage: tar - needs: ["build-x86_64-linux"] + needs: ["build-x86_64-linux-deb10"] tags: - x86_64-linux image: "registry.gitlab.haskell.org/ghc/ci-images/x86_64-linux-deb10:$DOCKER_REV" @@ -152,13 +152,117 @@ tar-x86_64-linux: TARBALL_ARCHIVE_SUFFIX: x86_64-deb10-linux TARBALL_EXT: tar.xz -test-x86_64-linux: +test-x86_64-linux-deb10: extends: .test - needs: ["tar-x86_64-linux"] + needs: ["tar-x86_64-linux-deb10"] tags: - x86_64-linux image: "registry.gitlab.haskell.org/ghc/ci-images/x86_64-linux-deb10:$DOCKER_REV" +###################### +# x86_64 linux deb9 +###################### + +build-x86_64-linux-deb9: + extends: .build + before_script: + - sudo apt update + - sudo apt install -y patchelf + tags: + - x86_64-linux + image: "registry.gitlab.haskell.org/ghc/ci-images/x86_64-linux-deb9:$DOCKER_REV" + variables: + ADD_CABAL_ARGS: "--enable-split-sections" + +tar-x86_64-linux-deb9: + extends: .artifacts + stage: tar + needs: ["build-x86_64-linux-deb9"] + tags: + - x86_64-linux + image: "registry.gitlab.haskell.org/ghc/ci-images/x86_64-linux-deb9:$DOCKER_REV" + script: + - ./.gitlab/tar.sh + variables: + TARBALL_ARCHIVE_SUFFIX: x86_64-deb9-linux + TARBALL_EXT: tar.xz + +test-x86_64-linux-deb9: + extends: .test + needs: ["tar-x86_64-linux-deb9"] + tags: + - x86_64-linux + image: "registry.gitlab.haskell.org/ghc/ci-images/x86_64-linux-deb9:$DOCKER_REV" + +###################### +# x86_64 linux centos7 +###################### + +build-x86_64-linux-centos7: + extends: .build + before_script: + - sudo yum install -y epel-release + - sudo yum install -y patchelf + tags: + - x86_64-linux + image: "registry.gitlab.haskell.org/ghc/ci-images/x86_64-linux-centos7:$DOCKER_REV" + variables: + ADD_CABAL_ARGS: "--enable-split-sections" + +tar-x86_64-linux-centos7: + extends: .artifacts + stage: tar + needs: ["build-x86_64-linux-centos7"] + tags: + - x86_64-linux + image: "registry.gitlab.haskell.org/ghc/ci-images/x86_64-linux-centos7:$DOCKER_REV" + script: + - ./.gitlab/tar.sh + variables: + TARBALL_ARCHIVE_SUFFIX: x86_64-centos7-linux + TARBALL_EXT: tar.xz + +test-x86_64-linux-centos7: + extends: .test + needs: ["tar-x86_64-linux-centos7"] + tags: + - x86_64-linux + image: "registry.gitlab.haskell.org/ghc/ci-images/x86_64-linux-centos7:$DOCKER_REV" + +###################### +# x86_64 linux fedora27 +###################### + +build-x86_64-linux-fedora27: + extends: .build + before_script: + - sudo dnf install -y patchelf + tags: + - x86_64-linux + image: "registry.gitlab.haskell.org/ghc/ci-images/x86_64-linux-fedora27:$DOCKER_REV" + variables: + ADD_CABAL_ARGS: "--enable-split-sections" + +tar-x86_64-linux-fedora27: + extends: .artifacts + stage: tar + needs: ["build-x86_64-linux-fedora27"] + tags: + - x86_64-linux + image: "registry.gitlab.haskell.org/ghc/ci-images/x86_64-linux-fedora27:$DOCKER_REV" + script: + - ./.gitlab/tar.sh + variables: + TARBALL_ARCHIVE_SUFFIX: x86_64-fedora27-linux + TARBALL_EXT: tar.xz + +test-x86_64-linux-fedora27: + extends: .test + needs: ["tar-x86_64-linux-fedora27"] + tags: + - x86_64-linux + image: "registry.gitlab.haskell.org/ghc/ci-images/x86_64-linux-fedora27:$DOCKER_REV" + ###################### # x86_64 linux alpine From e5087622232f4304e1476de42d3cebce4578874b Mon Sep 17 00:00:00 2001 From: Julian Ospald Date: Thu, 3 Feb 2022 23:15:13 +0100 Subject: [PATCH 18/33] Fix test on CentOS 7 https://github.com/haskell/bytestring/issues/481 --- .gitlab/test.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.gitlab/test.sh b/.gitlab/test.sh index 722189118c..efc9fa4d6e 100644 --- a/.gitlab/test.sh +++ b/.gitlab/test.sh @@ -54,8 +54,8 @@ emake PREFIX=$HOME/.local export PATH="$HOME/.local/bin:$PATH" tmp_dir=$(mktempdir) cd "$tmp_dir" -cabal unpack bytestring-0.11.2.0 -cd bytestring-0.11.2.0 +cabal unpack bytestring-0.11.1.0 +cd bytestring-0.11.1.0 echo "cradle:" > hie.yaml echo " cabal:" >> hie.yaml haskell-language-server-wrapper typecheck Data/ByteString.hs From 17b66dc3ce7016841dd3a6c7598f7068076e2448 Mon Sep 17 00:00:00 2001 From: Julian Ospald Date: Thu, 3 Feb 2022 23:30:28 +0100 Subject: [PATCH 19/33] Add after_script to darwin runs --- .gitlab-ci.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index d096b472ef..0188a5b88e 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -404,6 +404,8 @@ build-x86_64-darwin: script: | export PATH="$CI_PROJECT_DIR/.brew/bin:$CI_PROJECT_DIR/.brew/sbin:$PATH" /bin/bash ./.gitlab/ci.sh + after_script: + - rm -Rf /private/tmp/.brew_tmp tar-x86_64-darwin: extends: .artifacts @@ -430,6 +432,8 @@ tar-x86_64-darwin: script: | export PATH="$CI_PROJECT_DIR/.brew/bin:$CI_PROJECT_DIR/.brew/sbin:$PATH" /bin/bash ./.gitlab/tar.sh + after_script: + - rm -Rf /private/tmp/.brew_tmp variables: TARBALL_ARCHIVE_SUFFIX: x86_64-apple-darwin TARBALL_EXT: tar.xz From 6259067ac890f0527ab496846d263fd8262cde5d Mon Sep 17 00:00:00 2001 From: Julian Ospald Date: Fri, 4 Feb 2022 16:43:09 +0100 Subject: [PATCH 20/33] Refactor wrapper.in and make it more robust on Darwin --- bindist/wrapper.in | 214 +++++++++++++++++++++++++++++++-------------- 1 file changed, 146 insertions(+), 68 deletions(-) diff --git a/bindist/wrapper.in b/bindist/wrapper.in index efa0a18b10..90fb2d9540 100644 --- a/bindist/wrapper.in +++ b/bindist/wrapper.in @@ -5,90 +5,168 @@ executablename="@@EXE_NAME@@" GHC_VERSION="@@GHC_VERSION@@" ABI_HASHES="@@ABI_HASHES@@" -fail_ghc_pkg() { - echo >&2 "Could not find a ghc-pkg binary (found: $1)!" - echo >&2 "Your GHC installation may be borked." - echo >&2 "Consider installing GHC via ghcup or compile HLS from source." - echo >&2 "exiting..." - exit 42 +debug_msg() { + if [ -n "$HLS_WRAPPER_DEBUG" ] ; then + echo >&2 "$1" + fi } -fail_libdir() { - echo >&2 "Could not find a GHC installation!" - echo >&2 "Consider setting GHC_LIBDIR env variable to the top-level directory of GHC shipped libraries (version ${GHC_VERSION})." - echo >&2 "This is needed to find dynamic libraries." - echo >&2 "exiting..." - exit 42 +err_ghc_pkg() { + debug_msg >&2 "Could not find a ghc-pkg binary (found: $1)!" + debug_msg >&2 "Trying other methods..." } -fail_abi() { - echo >&2 "GHC ABIs don't match!" - echo >&2 "This means you're running an incompatible GHC and HLS won't work correctly." - echo >&2 "Consider installing GHC via ghcup or compile HLS from source." - echo >&2 "" - echo >&2 "Expected: ${ABI_HASHES}" - echo >&2 "Got: $1" - echo >&2 "exiting..." - exit 42 +err_abi() { + debug_msg >&2 "GHC ABIs don't match!" + debug_msg >&2 "" + debug_msg >&2 "Expected: ${ABI_HASHES}" + debug_msg >&2 "Got: $1" + debug_msg >&2 "Trying other methods..." } -# try GHC_LIBDIR from the environment (e.g. user set it) -if [ -n "${GHC_LIBDIR}" ] ; then - : -# try hls-wrapper --print-libdir -elif "${exedir}"/haskell-language-server-wrapper --version >/dev/null 2>/dev/null ; then - GHC_LIBDIR="$("${exedir}"/haskell-language-server-wrapper --print-libdir)" || unset GHC_LIBDIR -fi +err_ver() { + debug_msg >&2 "GHC versions don't match!" + debug_msg >&2 "" + debug_msg >&2 "Expected: ${GHC_VERSION}" + debug_msg >&2 "Got: $1" + debug_msg >&2 "Trying other methods..." +} -if [ -z "${GHC_LIBDIR}" ] ; then -# try ghcup, if available - if command -v ghcup >/dev/null ; then - GHC_LIBDIR="$(ghcup whereis -d ghc ${GHC_VERSION})/../lib/ghc-${GHC_VERSION}/" || unset GHC_LIBDIR - fi -fi +# Check the version of GHC and the ABI. +check_ghc() { + { [ -z "$1" ] || [ -z "$2" ] || [ -z "$3" ] || [ -z "$4" ] ;} && debug_msg "internal error: not enough arguments to check_ghc: 1:$1,2:$2,3:$3,4:$4" && return 4 + + debug_msg >&2 "Trying method $4" -# if above failed, try to examine ghc in PATH -if [ -z "${GHC_LIBDIR}" ] ; then - if [ -n "${GHC_BIN}" ] && command -v "${GHC_BIN}" >/dev/null ; then - ghc_bin=${GHC_BIN} - elif command -v ghc-${GHC_VERSION} >/dev/null ; then - ghc_bin=ghc-${GHC_VERSION} - elif command -v ghc >/dev/null ; then - ghc_bin=ghc + check_ghc_libdir=$1 + check_ghc_bin=$2 + GHC_PKG=$3 + check_ghc_ver="$("${check_ghc_bin}" --numeric-version 2>/dev/null)" + + # check version + if [ "${check_ghc_ver}" = "${GHC_VERSION}" ] ; then + # check ABI + if "${GHC_PKG}" --version >/dev/null ; then + : + elif "${GHC_PKG}-${GHC_VERSION}" --version >/dev/null ; then + GHC_PKG=${GHC_PKG}-${GHC_VERSION} + else + err_ghc_pkg "${GHC_PKG}" + unset GHC_LIBDIR + 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 "${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 + fi + unset PKGCONF else - fail_libdir + err_ver "${check_ghc_ver}" + unset GHC_LIBDIR + return 2 fi - GHC_LIBDIR=$(${ghc_bin} --print-libdir) - ghc_ver="$(${ghc_bin} --numeric-version)" - if [ "${GHC_VERSION}" != "${ghc_ver}" ] ; then - echo >&2 "Need GHC version ${GHC_VERSION}, got ${ghc_ver}... trying anyway" + unset check_ghc_libdir check_ghc_bindir GHC_PKG check_ghc_ver +} + +# Infer ghc-pkg from the given ghc path. Doesn't check for existence of any +# components. +infer_ghc_pkg() { + infer_ghc_path=$1 + infer_ghc_bin=${infer_ghc_path##**/} + infer_ghc_ver_suffix=${infer_ghc_bin#ghc} + path_prefix="$(dirname "${infer_ghc_path}")" + + if [ "${path_prefix}" = "." ] ; then + echo "ghc-pkg${infer_ghc_ver_suffix}" + elif [ "${path_prefix}" = "/" ] ; then + echo "${path_prefix}ghc-pkg${infer_ghc_ver_suffix}" + else + echo "${path_prefix}/ghc-pkg${infer_ghc_ver_suffix}" fi - unset ghc_ver ghc_bin -fi + unset infer_ghc_path infer_ghc_bin infer_ghc_ver_suffix path_prefix +} -if [ -z "${GHC_LIBDIR}" ] ; then - fail_libdir -fi +# Get the bin dir from GHCs internal libdir. This is wobbly. +ghc_bin_from_libdir() { + if [ -e "$1"/bin/ghc ] ; then + echo "$1"/bin/ghc + elif [ -e "$1"/bin/ghc-${GHC_VERSION} ] ; then + echo "$1"/bin/ghc-${GHC_VERSION} + elif [ -e "$1"/../bin/ghc ] ; then + echo "$1"/../bin/ghc + elif [ -e "$1"/../bin/ghc-${GHC_VERSION} ] ; then + echo "$1"/../bin/ghc-${GHC_VERSION} + fi +} -# check abi -GHC_PKG="${GHC_LIBDIR}"/bin/ghc-pkg -if "${GHC_PKG}" --version >/dev/null ; then +# try GHC_LIBDIR from the environment (e.g. user set it) +if [ -n "${GHC_LIBDIR}" ] && + check_ghc "${GHC_LIBDIR}" "$(ghc_bin_from_libdir "${GHC_LIBDIR}")" "$(infer_ghc_pkg "$(ghc_bin_from_libdir "${GHC_LIBDIR}")")" "GHC_LIBDIR" +then + : +# try GHC_BIN from the environment (e.g. user set it) +elif [ -n "${GHC_BIN}" ] && + GHC_LIBDIR="$("${GHC_BIN}" --print-libdir)" && + check_ghc "${GHC_LIBDIR}" "${GHC_BIN}" "$(infer_ghc_pkg "${GHC_BIN}")" "GHC_BIN" +then + : +# try ghcup +elif command -v ghcup >/dev/null && + GHC_BIN="$(ghcup whereis ghc "${GHC_VERSION}")" && + GHC_LIBDIR="$("${GHC_BIN}" --print-libdir)" && + check_ghc "${GHC_LIBDIR}" "${GHC_BIN}" "$(infer_ghc_pkg "${GHC_BIN}")" "ghcup" +then + : +# try ghc-${GHC_VERSION} +elif command -v ghc-${GHC_VERSION} >/dev/null && + GHC_LIBDIR="$("ghc-${GHC_VERSION}" --print-libdir)" && + check_ghc "${GHC_LIBDIR}" "ghc-${GHC_VERSION}" "$(infer_ghc_pkg "ghc-${GHC_VERSION}")" "ghc-" +then + : +# try ghc +elif command -v ghc >/dev/null && + GHC_LIBDIR="$(ghc --print-libdir)" && + check_ghc "${GHC_LIBDIR}" "ghc" "$(infer_ghc_pkg "ghc")" "ghc" +then + : +# try stack +elif command -v stack >/dev/null && + GHC_BIN="$(cd "$(mktemp -d)" && stack --install-ghc --resolver "ghc-${GHC_VERSION}" exec sh -- -c 'command -v ghc')" && + GHC_LIBDIR="$("${GHC_BIN}" --print-libdir)" && + check_ghc "${GHC_LIBDIR}" "${GHC_BIN}" "$(infer_ghc_pkg "${GHC_BIN}")" "stack" +then : else - fail_ghc_pkg "${GHC_PKG}" -fi -PKGCONF="${GHC_LIBDIR}/package.conf.d" -MY_ABI_HASHES="$(for dep in $("${GHC_PKG}" --global --global-package-db "$PKGCONF" list --simple-output) ; do "${GHC_PKG}" --global --global-package-db "$PKGCONF" field "${dep}" abi --simple-output ; done | tr '\n' ' ' | xargs)" -[ "${ABI_HASHES}" = "${MY_ABI_HASHES}" ] || fail_abi "${MY_ABI_HASHES}" -unset PKGCONF - -if [ -n "$LD_LIBRARY_PATH" ] ; then - LD_LIBRARY_PATH="$(for i in "${GHC_LIBDIR}"/* ; do [ -d "$i" ] && printf "%s" "$i:" ; done)$LD_LIBRARY_PATH" - export LD_LIBRARY_PATH -else - LD_LIBRARY_PATH="$(for i in "${GHC_LIBDIR}"/* ; do [ -d "$i" ] && printf "%s" "$i:" ; done | sed 's/:$//')" - export LD_LIBRARY_PATH + echo >&2 "All methods exhausted!" + echo >&2 "Couldn't find a working/matching GHC installation" + echo >&2 "exiting..." + exit 42 fi +debug_msg "Found GHC libdir at: ${GHC_LIBDIR}" + +case "$(uname -s)" in + "Darwin"|"darwin") + if [ -n "$DYLD_LIBRARY_PATH" ] ; then + DYLD_LIBRARY_PATH="$(for i in "${GHC_LIBDIR}"/* ; do [ -d "$i" ] && printf "%s" "$i:" ; done)$DYLD_LIBRARY_PATH" + export DYLD_LIBRARY_PATH + else + DYLD_LIBRARY_PATH="$(for i in "${GHC_LIBDIR}"/* ; do [ -d "$i" ] && printf "%s" "$i:" ; done | sed 's/:$//')" + export DYLD_LIBRARY_PATH + fi + ;; + *) + if [ -n "$LD_LIBRARY_PATH" ] ; then + LD_LIBRARY_PATH="$(for i in "${GHC_LIBDIR}"/* ; do [ -d "$i" ] && printf "%s" "$i:" ; done)$LD_LIBRARY_PATH" + export LD_LIBRARY_PATH + else + LD_LIBRARY_PATH="$(for i in "${GHC_LIBDIR}"/* ; do [ -d "$i" ] && printf "%s" "$i:" ; done | sed 's/:$//')" + export LD_LIBRARY_PATH + fi + ;; +esac + exec "${exedir}/${executablename}" ${1+"$@"} From 476d0c9dd263b5b1ed277826e21105d643c1a49d Mon Sep 17 00:00:00 2001 From: Julian Ospald Date: Fri, 4 Feb 2022 16:47:01 +0100 Subject: [PATCH 21/33] Also print pkg names additionally to abi hash --- .gitlab-ci.yml | 124 +++++++++++++++------------------------------ .gitlab/brew.sh | 19 +++++++ .gitlab/test.sh | 27 ++++++++-- GNUmakefile | 2 +- bindist/wrapper.in | 2 +- 5 files changed, 86 insertions(+), 88 deletions(-) create mode 100644 .gitlab/brew.sh diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 0188a5b88e..979010e0ac 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -60,7 +60,7 @@ build-aarch64-linux-deb10: extends: .build before_script: - sudo apt update - - sudo apt install -y patchelf + - sudo apt install -y patchelf tree tags: - aarch64-linux image: "registry.gitlab.haskell.org/ghc/ci-images/aarch64-linux-deb10:$DOCKER_REV" @@ -86,6 +86,9 @@ test-aarch64-linux-deb10: tags: - aarch64-linux image: "registry.gitlab.haskell.org/ghc/ci-images/aarch64-linux-deb10:$DOCKER_REV" + before_script: + - sudo apt update + - sudo apt install -y tree ###################### @@ -96,7 +99,7 @@ build-armv7-linux-deb10: extends: .build before_script: - sudo apt update - - sudo apt install -y patchelf + - sudo apt install -y patchelf tree tags: - armv7-linux image: "registry.gitlab.haskell.org/ghc/ci-images/armv7-linux-deb10:$DOCKER_REV" @@ -122,6 +125,9 @@ test-armv7-linux-deb10: tags: - armv7-linux image: "registry.gitlab.haskell.org/ghc/ci-images/armv7-linux-deb10:$DOCKER_REV" + before_script: + - sudo apt update + - sudo apt install -y tree ###################### @@ -132,7 +138,7 @@ build-x86_64-linux-deb10: extends: .build before_script: - sudo apt update - - sudo apt install -y patchelf + - sudo apt install -y patchelf tree tags: - x86_64-linux image: "registry.gitlab.haskell.org/ghc/ci-images/x86_64-linux-deb10:$DOCKER_REV" @@ -158,6 +164,9 @@ test-x86_64-linux-deb10: tags: - x86_64-linux image: "registry.gitlab.haskell.org/ghc/ci-images/x86_64-linux-deb10:$DOCKER_REV" + before_script: + - sudo apt update + - sudo apt install -y tree ###################### # x86_64 linux deb9 @@ -167,7 +176,7 @@ build-x86_64-linux-deb9: extends: .build before_script: - sudo apt update - - sudo apt install -y patchelf + - sudo apt install -y patchelf tree tags: - x86_64-linux image: "registry.gitlab.haskell.org/ghc/ci-images/x86_64-linux-deb9:$DOCKER_REV" @@ -193,6 +202,9 @@ test-x86_64-linux-deb9: tags: - x86_64-linux image: "registry.gitlab.haskell.org/ghc/ci-images/x86_64-linux-deb9:$DOCKER_REV" + before_script: + - sudo apt update + - sudo apt install -y tree ###################### # x86_64 linux centos7 @@ -202,7 +214,7 @@ build-x86_64-linux-centos7: extends: .build before_script: - sudo yum install -y epel-release - - sudo yum install -y patchelf + - sudo yum install -y patchelf tree tags: - x86_64-linux image: "registry.gitlab.haskell.org/ghc/ci-images/x86_64-linux-centos7:$DOCKER_REV" @@ -228,6 +240,8 @@ test-x86_64-linux-centos7: tags: - x86_64-linux image: "registry.gitlab.haskell.org/ghc/ci-images/x86_64-linux-centos7:$DOCKER_REV" + before_script: + - sudo yum install -y tree ###################### # x86_64 linux fedora27 @@ -236,7 +250,7 @@ test-x86_64-linux-centos7: build-x86_64-linux-fedora27: extends: .build before_script: - - sudo dnf install -y patchelf + - sudo dnf install -y patchelf tree tags: - x86_64-linux image: "registry.gitlab.haskell.org/ghc/ci-images/x86_64-linux-fedora27:$DOCKER_REV" @@ -262,6 +276,8 @@ test-x86_64-linux-fedora27: tags: - x86_64-linux image: "registry.gitlab.haskell.org/ghc/ci-images/x86_64-linux-fedora27:$DOCKER_REV" + before_script: + - sudo dnf install -y tree ###################### @@ -274,7 +290,7 @@ build-x86_64-linux-alpine: - x86_64-linux image: "registry.gitlab.haskell.org/ghc/ci-images/x86_64-linux-alpine3_12:$DOCKER_REV" before_script: - - sudo apk add --no-cache tar zlib zlib-dev zlib-static bzip2 bzip2-dev bzip2-static gmp gmp-dev xz xz-dev ncurses-static patchelf findutils + - sudo apk add --no-cache tar zlib zlib-dev zlib-static bzip2 bzip2-dev bzip2-static gmp gmp-dev xz xz-dev ncurses-static patchelf findutils tree variables: ADD_CABAL_ARGS: "--enable-split-sections --enable-executable-static" @@ -300,7 +316,7 @@ test-x86_64-linux-alpine: - x86_64-linux image: "registry.gitlab.haskell.org/ghc/ci-images/x86_64-linux-alpine3_12:$DOCKER_REV" before_script: - - sudo apk add --no-cache tar zlib zlib-dev zlib-static bzip2 bzip2-dev bzip2-static gmp gmp-dev xz xz-dev ncurses-static + - sudo apk add --no-cache tar zlib zlib-dev zlib-static bzip2 bzip2-dev bzip2-static gmp gmp-dev xz xz-dev ncurses-static tree ###################### @@ -310,7 +326,8 @@ test-x86_64-linux-alpine: build-x86_64-freebsd12: extends: .build before_script: - - sudo pkg install --yes patchelf gmake + - sudo pkg update + - sudo pkg install --yes patchelf gmake tree binutils tags: - x86_64-freebsd12 variables: @@ -334,7 +351,8 @@ test-x86_64-freebsd12: tags: - x86_64-freebsd12 before_script: - - sudo pkg install --yes patchelf gmake + - sudo pkg update + - sudo pkg install --yes patchelf gmake tree binutils ###################### @@ -347,7 +365,7 @@ build-x86_64-freebsd13: - x86_64-freebsd13 before_script: - sudo pkg update - - sudo pkg install --yes compat12x-amd64 patchelf gmake + - sudo pkg install --yes compat12x-amd64 patchelf gmake tree binutils - sudo ln -s libncurses.so.6 /usr/local/lib/libncurses.so.6.2 variables: ADD_CABAL_ARGS: "--enable-split-sections -j1" @@ -371,7 +389,7 @@ test-x86_64-freebsd13: - x86_64-freebsd13 before_script: - sudo pkg update - - sudo pkg install --yes compat12x-amd64 gmake + - sudo pkg install --yes compat12x-amd64 gmake tree binutils - sudo ln -s libncurses.so.6 /usr/local/lib/libncurses.so.6.2 @@ -386,21 +404,7 @@ build-x86_64-darwin: variables: ADD_CABAL_ARGS: "" before_script: - # Install brew locally in the project dir. Packages will also be installed here. - - '[ -e "$CI_PROJECT_DIR/.brew" ] || git clone --depth=1 https://github.com/Homebrew/brew $CI_PROJECT_DIR/.brew' - - export PATH="$CI_PROJECT_DIR/.brew/bin:$CI_PROJECT_DIR/.brew/sbin:$PATH" - - # make sure to not pollute the machine with temp files etc - - mkdir -p $CI_PROJECT_DIR/.brew_cache - - export HOMEBREW_CACHE=$CI_PROJECT_DIR/.brew_cache - - mkdir -p $CI_PROJECT_DIR/.brew_logs - - export HOMEBREW_LOGS=$CI_PROJECT_DIR/.brew_logs - - mkdir -p /private/tmp/.brew_tmp - - export HOMEBREW_TEMP=/private/tmp/.brew_tmp - - # update and install packages - - brew update - - brew install autoconf automake coreutils make + - /bin/bash ./.gitlab/brew.sh autoconf automake coreutils make tree script: | export PATH="$CI_PROJECT_DIR/.brew/bin:$CI_PROJECT_DIR/.brew/sbin:$PATH" /bin/bash ./.gitlab/ci.sh @@ -414,21 +418,7 @@ tar-x86_64-darwin: tags: - x86_64-darwin before_script: - # Install brew locally in the project dir. Packages will also be installed here. - - '[ -e "$CI_PROJECT_DIR/.brew" ] || git clone --depth=1 https://github.com/Homebrew/brew $CI_PROJECT_DIR/.brew' - - export PATH="$CI_PROJECT_DIR/.brew/bin:$CI_PROJECT_DIR/.brew/sbin:$PATH" - - # make sure to not pollute the machine with temp files etc - - mkdir -p $CI_PROJECT_DIR/.brew_cache - - export HOMEBREW_CACHE=$CI_PROJECT_DIR/.brew_cache - - mkdir -p $CI_PROJECT_DIR/.brew_logs - - export HOMEBREW_LOGS=$CI_PROJECT_DIR/.brew_logs - - mkdir -p /private/tmp/.brew_tmp - - export HOMEBREW_TEMP=/private/tmp/.brew_tmp - - # update and install packages - - brew update - - brew install autoconf automake coreutils make + - /bin/bash ./.gitlab/brew.sh autoconf automake coreutils make tree script: | export PATH="$CI_PROJECT_DIR/.brew/bin:$CI_PROJECT_DIR/.brew/sbin:$PATH" /bin/bash ./.gitlab/tar.sh @@ -443,6 +433,13 @@ test-x86_64-darwin: needs: ["tar-x86_64-darwin"] tags: - x86_64-darwin + before_script: + - /bin/bash ./.gitlab/brew.sh make tree + script: | + export PATH="$CI_PROJECT_DIR/.brew/bin:$CI_PROJECT_DIR/.brew/sbin:$PATH" + /bin/bash .gitlab/test.sh + after_script: + - rm -Rf /private/tmp/.brew_tmp ###################### @@ -455,25 +452,8 @@ build-aarch64-darwin: tags: - aarch64-darwin-m1 before_script: - # Install brew locally in the project dir. Packages will also be installed here. - - '[ -e "$CI_PROJECT_DIR/.brew" ] || git clone --depth=1 https://github.com/Homebrew/brew $CI_PROJECT_DIR/.brew' - - export PATH="$CI_PROJECT_DIR/.brew/bin:$CI_PROJECT_DIR/.brew/sbin:$PATH" - - # otherwise we seem to get intel binaries - export HOMEBREW_CHANGE_ARCH_TO_ARM=1 - - # make sure to not pollute the machine with temp files etc - - mkdir -p $CI_PROJECT_DIR/.brew_cache - - export HOMEBREW_CACHE=$CI_PROJECT_DIR/.brew_cache - - mkdir -p $CI_PROJECT_DIR/.brew_logs - - export HOMEBREW_LOGS=$CI_PROJECT_DIR/.brew_logs - - mkdir -p /private/tmp/.brew_tmp - - export HOMEBREW_TEMP=/private/tmp/.brew_tmp - - # update and install packages - - brew update - - brew install llvm - - brew install autoconf automake coreutils make + - arch -arm64 /bin/bash ./.gitlab/brew.sh llvm autoconf automake coreutils make tree script: | export PATH="$CI_PROJECT_DIR/.brew/opt/llvm/bin:$CI_PROJECT_DIR/.brew/bin:$CI_PROJECT_DIR/.brew/sbin:$PATH" export CC=$CI_PROJECT_DIR/.brew/opt/llvm/bin/clang @@ -506,32 +486,10 @@ test-aarch64-darwin: tags: - aarch64-darwin-m1 before_script: - # Install brew locally in the project dir. Packages will also be installed here. - - '[ -e "$CI_PROJECT_DIR/.brew" ] || git clone --depth=1 https://github.com/Homebrew/brew $CI_PROJECT_DIR/.brew' - - export PATH="$CI_PROJECT_DIR/.brew/bin:$CI_PROJECT_DIR/.brew/sbin:$PATH" - - # otherwise we seem to get intel binaries - export HOMEBREW_CHANGE_ARCH_TO_ARM=1 - - # make sure to not pollute the machine with temp files etc - - mkdir -p $CI_PROJECT_DIR/.brew_cache - - export HOMEBREW_CACHE=$CI_PROJECT_DIR/.brew_cache - - mkdir -p $CI_PROJECT_DIR/.brew_logs - - export HOMEBREW_LOGS=$CI_PROJECT_DIR/.brew_logs - - mkdir -p /private/tmp/.brew_tmp - - export HOMEBREW_TEMP=/private/tmp/.brew_tmp - - # update and install packages - - brew update - - brew install llvm - - brew install autoconf automake coreutils + - arch -arm64 /bin/bash ./.gitlab/brew.sh make tree script: | export PATH="$CI_PROJECT_DIR/.brew/opt/llvm/bin:$CI_PROJECT_DIR/.brew/bin:$CI_PROJECT_DIR/.brew/sbin:$PATH" - export CC=$CI_PROJECT_DIR/.brew/opt/llvm/bin/clang - export CXX=$CI_PROJECT_DIR/.brew/opt/llvm/bin/clang++ - export LD=ld - export AR=$CI_PROJECT_DIR/.brew/opt/llvm/bin/llvm-ar - export RANLIB=$CI_PROJECT_DIR/.brew/opt/llvm/bin/llvm-ranlib arch -arm64 /bin/bash ./.gitlab/test.sh after_script: - rm -Rf /private/tmp/.brew_tmp diff --git a/.gitlab/brew.sh b/.gitlab/brew.sh new file mode 100644 index 0000000000..de769632e6 --- /dev/null +++ b/.gitlab/brew.sh @@ -0,0 +1,19 @@ +#!/usr/bin/env bash + +set -Eeuxo pipefail + +# Install brew locally in the project dir. Packages will also be installed here. +[ -e "$CI_PROJECT_DIR/.brew" ] || git clone --depth=1 https://github.com/Homebrew/brew $CI_PROJECT_DIR/.brew +export PATH="$CI_PROJECT_DIR/.brew/bin:$CI_PROJECT_DIR/.brew/sbin:$PATH" + +# make sure to not pollute the machine with temp files etc +mkdir -p $CI_PROJECT_DIR/.brew_cache +export HOMEBREW_CACHE=$CI_PROJECT_DIR/.brew_cache +mkdir -p $CI_PROJECT_DIR/.brew_logs +export HOMEBREW_LOGS=$CI_PROJECT_DIR/.brew_logs +mkdir -p /private/tmp/.brew_tmp +export HOMEBREW_TEMP=/private/tmp/.brew_tmp + +# update and install packages +brew update +brew install ${1+"$@"} diff --git a/.gitlab/test.sh b/.gitlab/test.sh index efc9fa4d6e..5f08d97898 100644 --- a/.gitlab/test.sh +++ b/.gitlab/test.sh @@ -45,13 +45,34 @@ case "$(uname -s)" in ;; esac -cd "$CI_PROJECT_DIR/out/" +# make sure out/ dir is gone, so build host rpaths don't +# kick in (TODO: we should probably remove those) +mv "$CI_PROJECT_DIR/out"/*.tar.xz . +rm -rf "$CI_PROJECT_DIR/out/" +# cleanup from previous dirty runs +rm -rf "$HOME"/.local/lib/haskell-language-server-* || true + +# install tar xf *.tar.xz rm *.tar.xz cd haskell-language-server-* -emake PREFIX=$HOME/.local -export PATH="$HOME/.local/bin:$PATH" +INSTALL_DIR=$(dirname "${GHCUP_BINDIR}") || exit 1 +[ -d "$INSTALL_DIR" ] || exit 1 +emake PREFIX="${INSTALL_DIR}" install + +# print rpaths and libdirs +case "$(uname -s)" in + "Darwin"|"darwin") + otool -l "$INSTALL_DIR"/lib/haskell-language-server-*/bin/haskell-language-server-* + ;; + *) + objdump -x "$INSTALL_DIR"/lib/haskell-language-server-*/bin/haskell-language-server-* + ;; +esac +tree "$INSTALL_DIR"/lib/haskell-language-server-* +tree "$INSTALL_DIR"/bin + tmp_dir=$(mktempdir) cd "$tmp_dir" cabal unpack bytestring-0.11.1.0 diff --git a/GNUmakefile b/GNUmakefile index e22d8c44f2..b97952d1de 100644 --- a/GNUmakefile +++ b/GNUmakefile @@ -88,7 +88,7 @@ bindist-ghc: $(SED) \ -e "s/@@EXE_NAME@@/haskell-language-server-$(GHC_VERSION)/" \ -e "s/@@GHC_VERSION@@/$(GHC_VERSION)/" \ - -e "s/@@ABI_HASHES@@/$(shell for dep in `ghc-pkg-$(GHC_VERSION) --global list --simple-output` ; do ghc-pkg-$(GHC_VERSION) field $$dep abi --simple-output ; done | tr '\n' ' ' | xargs)/" \ + -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" $(INSTALL_D) "$(BINDIST_OUT_DIR)/bin/" diff --git a/bindist/wrapper.in b/bindist/wrapper.in index 90fb2d9540..e6e30b3c46 100644 --- a/bindist/wrapper.in +++ b/bindist/wrapper.in @@ -56,7 +56,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 "${GHC_PKG}" --global --global-package-db "$PKGCONF" field "${dep}" abi --simple-output ; done | tr '\n' ' ' | xargs)" + 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)" if [ "${ABI_HASHES}" != "${MY_ABI_HASHES}" ] ; then err_abi "${MY_ABI_HASHES}" return 3 From ed9bf0221b9fdf91b5d5e5693536faeade19f02e Mon Sep 17 00:00:00 2001 From: Julian Ospald Date: Fri, 4 Feb 2022 16:47:17 +0100 Subject: [PATCH 22/33] Improve gitlab CI --- .gitlab-ci.yml | 182 ++++++++++++++++++++++++++----------------------- 1 file changed, 98 insertions(+), 84 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 979010e0ac..474b188986 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -51,29 +51,62 @@ workflow: script: - bash .gitlab/test.sh +.aarch64-linux: + tags: + - aarch64-linux + image: "registry.gitlab.haskell.org/ghc/ci-images/aarch64-linux-deb10:$DOCKER_REV" + +.armv7-linux: + tags: + - armv7-linux + image: "registry.gitlab.haskell.org/ghc/ci-images/armv7-linux-deb10:$DOCKER_REV" + +.x86_64-linux-deb10: + tags: + - x86_64-linux + image: "registry.gitlab.haskell.org/ghc/ci-images/x86_64-linux-deb10:$DOCKER_REV" + +.x86_64-linux-deb9: + tags: + - x86_64-linux + image: "registry.gitlab.haskell.org/ghc/ci-images/x86_64-linux-deb9:$DOCKER_REV" + +.x86_64-linux-centos7: + tags: + - x86_64-linux + image: "registry.gitlab.haskell.org/ghc/ci-images/x86_64-linux-centos7:$DOCKER_REV" + +.x86_64-linux-fedora27: + tags: + - x86_64-linux + image: "registry.gitlab.haskell.org/ghc/ci-images/x86_64-linux-fedora27:$DOCKER_REV" + +.x86_64-linux-alpine: + tags: + - x86_64-linux + image: "registry.gitlab.haskell.org/ghc/ci-images/x86_64-linux-alpine3_12:$DOCKER_REV" + ###################### # aarch64 linux deb10 ###################### build-aarch64-linux-deb10: - extends: .build + extends: + - .build + - .aarch64-linux before_script: - sudo apt update - sudo apt install -y patchelf tree - tags: - - aarch64-linux - image: "registry.gitlab.haskell.org/ghc/ci-images/aarch64-linux-deb10:$DOCKER_REV" variables: ADD_CABAL_ARGS: "" tar-aarch64-linux-deb10: - extends: .artifacts + extends: + - .artifacts + - .aarch64-linux stage: tar needs: ["build-aarch64-linux-deb10"] - tags: - - aarch64-linux - image: "registry.gitlab.haskell.org/ghc/ci-images/aarch64-linux-deb10:$DOCKER_REV" script: - ./.gitlab/tar.sh variables: @@ -81,11 +114,10 @@ tar-aarch64-linux-deb10: TARBALL_EXT: tar.xz test-aarch64-linux-deb10: - extends: .test + extends: + - .test + - .aarch64-linux needs: ["tar-aarch64-linux-deb10"] - tags: - - aarch64-linux - image: "registry.gitlab.haskell.org/ghc/ci-images/aarch64-linux-deb10:$DOCKER_REV" before_script: - sudo apt update - sudo apt install -y tree @@ -96,23 +128,21 @@ test-aarch64-linux-deb10: ###################### build-armv7-linux-deb10: - extends: .build + extends: + - .build + - .armv7-linux before_script: - sudo apt update - sudo apt install -y patchelf tree - tags: - - armv7-linux - image: "registry.gitlab.haskell.org/ghc/ci-images/armv7-linux-deb10:$DOCKER_REV" variables: ADD_CABAL_ARGS: "" tar-armv7-linux-deb10: - extends: .artifacts + extends: + - .artifacts + - .armv7-linux stage: tar needs: ["build-armv7-linux-deb10"] - tags: - - armv7-linux - image: "registry.gitlab.haskell.org/ghc/ci-images/armv7-linux-deb10:$DOCKER_REV" script: - ./.gitlab/tar.sh variables: @@ -120,11 +150,10 @@ tar-armv7-linux-deb10: TARBALL_EXT: tar.xz test-armv7-linux-deb10: - extends: .test + extends: + - .test + - .armv7-linux needs: ["tar-armv7-linux-deb10"] - tags: - - armv7-linux - image: "registry.gitlab.haskell.org/ghc/ci-images/armv7-linux-deb10:$DOCKER_REV" before_script: - sudo apt update - sudo apt install -y tree @@ -135,23 +164,21 @@ test-armv7-linux-deb10: ###################### build-x86_64-linux-deb10: - extends: .build + extends: + - .build + - .x86_64-linux-deb10 before_script: - sudo apt update - sudo apt install -y patchelf tree - tags: - - x86_64-linux - image: "registry.gitlab.haskell.org/ghc/ci-images/x86_64-linux-deb10:$DOCKER_REV" variables: ADD_CABAL_ARGS: "--enable-split-sections" tar-x86_64-linux-deb10: - extends: .artifacts + extends: + - .artifacts + - .x86_64-linux-deb10 stage: tar needs: ["build-x86_64-linux-deb10"] - tags: - - x86_64-linux - image: "registry.gitlab.haskell.org/ghc/ci-images/x86_64-linux-deb10:$DOCKER_REV" script: - ./.gitlab/tar.sh variables: @@ -159,11 +186,10 @@ tar-x86_64-linux-deb10: TARBALL_EXT: tar.xz test-x86_64-linux-deb10: - extends: .test + extends: + - .test + - .x86_64-linux-deb10 needs: ["tar-x86_64-linux-deb10"] - tags: - - x86_64-linux - image: "registry.gitlab.haskell.org/ghc/ci-images/x86_64-linux-deb10:$DOCKER_REV" before_script: - sudo apt update - sudo apt install -y tree @@ -173,23 +199,21 @@ test-x86_64-linux-deb10: ###################### build-x86_64-linux-deb9: - extends: .build + extends: + - .build + - .x86_64-linux-deb9 before_script: - sudo apt update - sudo apt install -y patchelf tree - tags: - - x86_64-linux - image: "registry.gitlab.haskell.org/ghc/ci-images/x86_64-linux-deb9:$DOCKER_REV" variables: ADD_CABAL_ARGS: "--enable-split-sections" tar-x86_64-linux-deb9: - extends: .artifacts + extends: + - .artifacts + - .x86_64-linux-deb9 stage: tar needs: ["build-x86_64-linux-deb9"] - tags: - - x86_64-linux - image: "registry.gitlab.haskell.org/ghc/ci-images/x86_64-linux-deb9:$DOCKER_REV" script: - ./.gitlab/tar.sh variables: @@ -197,11 +221,10 @@ tar-x86_64-linux-deb9: TARBALL_EXT: tar.xz test-x86_64-linux-deb9: - extends: .test + extends: + - .test + - .x86_64-linux-deb9 needs: ["tar-x86_64-linux-deb9"] - tags: - - x86_64-linux - image: "registry.gitlab.haskell.org/ghc/ci-images/x86_64-linux-deb9:$DOCKER_REV" before_script: - sudo apt update - sudo apt install -y tree @@ -211,23 +234,21 @@ test-x86_64-linux-deb9: ###################### build-x86_64-linux-centos7: - extends: .build + extends: + - .build + - .x86_64-linux-centos7 before_script: - sudo yum install -y epel-release - sudo yum install -y patchelf tree - tags: - - x86_64-linux - image: "registry.gitlab.haskell.org/ghc/ci-images/x86_64-linux-centos7:$DOCKER_REV" variables: ADD_CABAL_ARGS: "--enable-split-sections" tar-x86_64-linux-centos7: - extends: .artifacts + extends: + - .artifacts + - .x86_64-linux-centos7 stage: tar needs: ["build-x86_64-linux-centos7"] - tags: - - x86_64-linux - image: "registry.gitlab.haskell.org/ghc/ci-images/x86_64-linux-centos7:$DOCKER_REV" script: - ./.gitlab/tar.sh variables: @@ -235,11 +256,10 @@ tar-x86_64-linux-centos7: TARBALL_EXT: tar.xz test-x86_64-linux-centos7: - extends: .test + extends: + - .test + - .x86_64-linux-centos7 needs: ["tar-x86_64-linux-centos7"] - tags: - - x86_64-linux - image: "registry.gitlab.haskell.org/ghc/ci-images/x86_64-linux-centos7:$DOCKER_REV" before_script: - sudo yum install -y tree @@ -248,22 +268,20 @@ test-x86_64-linux-centos7: ###################### build-x86_64-linux-fedora27: - extends: .build + extends: + - .build + - .x86_64-linux-fedora27 before_script: - sudo dnf install -y patchelf tree - tags: - - x86_64-linux - image: "registry.gitlab.haskell.org/ghc/ci-images/x86_64-linux-fedora27:$DOCKER_REV" variables: ADD_CABAL_ARGS: "--enable-split-sections" tar-x86_64-linux-fedora27: - extends: .artifacts + extends: + - .artifacts + - .x86_64-linux-fedora27 stage: tar needs: ["build-x86_64-linux-fedora27"] - tags: - - x86_64-linux - image: "registry.gitlab.haskell.org/ghc/ci-images/x86_64-linux-fedora27:$DOCKER_REV" script: - ./.gitlab/tar.sh variables: @@ -271,11 +289,10 @@ tar-x86_64-linux-fedora27: TARBALL_EXT: tar.xz test-x86_64-linux-fedora27: - extends: .test + extends: + - .test + - .x86_64-linux-fedora27 needs: ["tar-x86_64-linux-fedora27"] - tags: - - x86_64-linux - image: "registry.gitlab.haskell.org/ghc/ci-images/x86_64-linux-fedora27:$DOCKER_REV" before_script: - sudo dnf install -y tree @@ -285,22 +302,20 @@ test-x86_64-linux-fedora27: ###################### build-x86_64-linux-alpine: - extends: .build - tags: - - x86_64-linux - image: "registry.gitlab.haskell.org/ghc/ci-images/x86_64-linux-alpine3_12:$DOCKER_REV" + extends: + - .build + - .x86_64-linux-alpine before_script: - sudo apk add --no-cache tar zlib zlib-dev zlib-static bzip2 bzip2-dev bzip2-static gmp gmp-dev xz xz-dev ncurses-static patchelf findutils tree variables: ADD_CABAL_ARGS: "--enable-split-sections --enable-executable-static" tar-x86_64-linux-alpine: - extends: .artifacts + extends: + - .artifacts + - .x86_64-linux-alpine stage: tar needs: ["build-x86_64-linux-alpine"] - tags: - - x86_64-linux - image: "registry.gitlab.haskell.org/ghc/ci-images/x86_64-linux-alpine3_12:$DOCKER_REV" before_script: - sudo apk add --no-cache tar zlib zlib-dev zlib-static bzip2 bzip2-dev bzip2-static gmp gmp-dev xz xz-dev ncurses-static script: @@ -310,11 +325,10 @@ tar-x86_64-linux-alpine: TARBALL_EXT: tar.xz test-x86_64-linux-alpine: - extends: .test + extends: + - .test + - .x86_64-linux-alpine needs: ["tar-x86_64-linux-alpine"] - tags: - - x86_64-linux - image: "registry.gitlab.haskell.org/ghc/ci-images/x86_64-linux-alpine3_12:$DOCKER_REV" before_script: - sudo apk add --no-cache tar zlib zlib-dev zlib-static bzip2 bzip2-dev bzip2-static gmp gmp-dev xz xz-dev ncurses-static tree From 2d10024afe740fa9800052a27b189e7282f48676 Mon Sep 17 00:00:00 2001 From: Julian Ospald Date: Fri, 4 Feb 2022 18:07:00 +0100 Subject: [PATCH 23/33] Don't let stack install GHC --- bindist/wrapper.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bindist/wrapper.in b/bindist/wrapper.in index e6e30b3c46..ed15ee316b 100644 --- a/bindist/wrapper.in +++ b/bindist/wrapper.in @@ -134,7 +134,7 @@ then : # try stack elif command -v stack >/dev/null && - GHC_BIN="$(cd "$(mktemp -d)" && stack --install-ghc --resolver "ghc-${GHC_VERSION}" exec sh -- -c 'command -v ghc')" && + GHC_BIN="$(cd "$(mktemp -d)" && stack --no-system-ghc --no-install-ghc --resolver "ghc-${GHC_VERSION}" exec sh -- -c 'command -v ghc')" && GHC_LIBDIR="$("${GHC_BIN}" --print-libdir)" && check_ghc "${GHC_LIBDIR}" "${GHC_BIN}" "$(infer_ghc_pkg "${GHC_BIN}")" "stack" then From 23aa27d29c6fb51a5bb0e91ef4f32d3699702ca4 Mon Sep 17 00:00:00 2001 From: Julian Ospald Date: Sun, 6 Feb 2022 15:30:05 +0100 Subject: [PATCH 24/33] Document `bindist/ghcs` file --- docs/contributing/releases.md | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/contributing/releases.md b/docs/contributing/releases.md index ca1c78a143..ff5dfb6353 100644 --- a/docs/contributing/releases.md +++ b/docs/contributing/releases.md @@ -18,6 +18,7 @@ and it is being used in nix environments. ### prerelease sanity checks +- [ ] set the supported GHC versions and their corresponding cabal project-files in `bindist/ghcs` according to the [GHC version deprecation policy](../supported-versions.md#ghc-version-deprecation-policy) - [ ] [trigger manually](https://docs.github.com/es/actions/managing-workflow-runs/manually-running-a-workflow) the hackage workflow *without* uploading the packages - [ ] trigger manually the build workflow - [ ] create a prerelease tag `${version}-check-gitlab` and push it to the [project repo in gitlab](https://gitlab.haskell.org/haskell/haskell-language-server) to check the build is fine From ae442fbdee9c46ff7700648f1a1102d1ef3d4cbf Mon Sep 17 00:00:00 2001 From: Julian Ospald Date: Mon, 7 Feb 2022 00:11:59 +0100 Subject: [PATCH 25/33] Make ghc{,-pkg} detection more robust We don't need to guess the bin/ dir. Instead we only need ghc libdir (which we already have) and the full path to the ghc binary to reconstruct the ghc wrapper. --- bindist/wrapper.in | 24 ++++++------------------ exe/Wrapper.hs | 5 ++++- 2 files changed, 10 insertions(+), 19 deletions(-) diff --git a/bindist/wrapper.in b/bindist/wrapper.in index ed15ee316b..401849a540 100644 --- a/bindist/wrapper.in +++ b/bindist/wrapper.in @@ -89,28 +89,16 @@ infer_ghc_pkg() { unset infer_ghc_path infer_ghc_bin infer_ghc_ver_suffix path_prefix } -# Get the bin dir from GHCs internal libdir. This is wobbly. -ghc_bin_from_libdir() { - if [ -e "$1"/bin/ghc ] ; then - echo "$1"/bin/ghc - elif [ -e "$1"/bin/ghc-${GHC_VERSION} ] ; then - echo "$1"/bin/ghc-${GHC_VERSION} - elif [ -e "$1"/../bin/ghc ] ; then - echo "$1"/../bin/ghc - elif [ -e "$1"/../bin/ghc-${GHC_VERSION} ] ; then - echo "$1"/../bin/ghc-${GHC_VERSION} - fi -} - -# try GHC_LIBDIR from the environment (e.g. user set it) +# try GHC_LIBDIR from the environment (e.g. user set it, or haskell-language-server-wrapper) if [ -n "${GHC_LIBDIR}" ] && - check_ghc "${GHC_LIBDIR}" "$(ghc_bin_from_libdir "${GHC_LIBDIR}")" "$(infer_ghc_pkg "$(ghc_bin_from_libdir "${GHC_LIBDIR}")")" "GHC_LIBDIR" + [ -n "${GHC_BIN}" ] && + check_ghc "${GHC_LIBDIR}" "${GHC_BIN}" "$(infer_ghc_pkg "${GHC_BIN}")" "GHC_LIBDIR and GHC_BIN from env" then : # try GHC_BIN from the environment (e.g. user set it) elif [ -n "${GHC_BIN}" ] && GHC_LIBDIR="$("${GHC_BIN}" --print-libdir)" && - check_ghc "${GHC_LIBDIR}" "${GHC_BIN}" "$(infer_ghc_pkg "${GHC_BIN}")" "GHC_BIN" + check_ghc "${GHC_LIBDIR}" "${GHC_BIN}" "$(infer_ghc_pkg "${GHC_BIN}")" "GHC_BIN from env" then : # try ghcup @@ -123,13 +111,13 @@ then # try ghc-${GHC_VERSION} elif command -v ghc-${GHC_VERSION} >/dev/null && GHC_LIBDIR="$("ghc-${GHC_VERSION}" --print-libdir)" && - check_ghc "${GHC_LIBDIR}" "ghc-${GHC_VERSION}" "$(infer_ghc_pkg "ghc-${GHC_VERSION}")" "ghc-" + check_ghc "${GHC_LIBDIR}" "ghc-${GHC_VERSION}" "$(infer_ghc_pkg "ghc-${GHC_VERSION}")" "ghc-${GHC_VERSION} in PATH" then : # try ghc elif command -v ghc >/dev/null && GHC_LIBDIR="$(ghc --print-libdir)" && - check_ghc "${GHC_LIBDIR}" "ghc" "$(infer_ghc_pkg "ghc")" "ghc" + check_ghc "${GHC_LIBDIR}" "ghc" "$(infer_ghc_pkg "ghc")" "ghc in PATH" then : # try stack diff --git a/exe/Wrapper.hs b/exe/Wrapper.hs index 926620ef5f..f98760e89e 100644 --- a/exe/Wrapper.hs +++ b/exe/Wrapper.hs @@ -1,4 +1,5 @@ {-# LANGUAGE RecordWildCards #-} +{-# LANGUAGE NamedFieldPuns #-} {-# LANGUAGE CPP #-} -- | This module is based on the hie-wrapper.sh script in -- https://github.com/alanz/vscode-hie-server @@ -112,9 +113,11 @@ launchHaskellLanguageServer parsedArgs = do #ifdef mingw32_HOST_OS callProcess e args #else + let Cradle { cradleOptsProg = CradleAction { runGhcCmd } } = cradle + (CradleSuccess ghcBinary) <- fmap trim <$> runGhcCmd ["-v0", "-package-env=-", "-e", "putStr =<< System.Environment.getExecutablePath"] (CradleSuccess libdir) <- HieBios.getRuntimeGhcLibDir cradle env <- Map.fromList <$> getEnvironment - let newEnv = Map.insert "GHC_LIBDIR" libdir env + let newEnv = Map.insert "GHC_BIN" ghcBinary $ Map.insert "GHC_LIBDIR" libdir env executeFile e True args (Just (Map.toList newEnv)) #endif From db3bf2feda19f0761fa7ddbef911bc2712e777ca Mon Sep 17 00:00:00 2001 From: Julian Ospald Date: Mon, 7 Feb 2022 12:38:32 +0100 Subject: [PATCH 26/33] Exit early when GHC_LIBDIR and GHC_BIN are set And improve debug messages. --- bindist/wrapper.in | 73 +++++++++++++++++++++++++++++----------------- 1 file changed, 46 insertions(+), 27 deletions(-) diff --git a/bindist/wrapper.in b/bindist/wrapper.in index 401849a540..e29edac128 100644 --- a/bindist/wrapper.in +++ b/bindist/wrapper.in @@ -6,37 +6,50 @@ GHC_VERSION="@@GHC_VERSION@@" ABI_HASHES="@@ABI_HASHES@@" debug_msg() { - if [ -n "$HLS_WRAPPER_DEBUG" ] ; then - echo >&2 "$1" - fi + if [ -n "$HLS_WRAPPER_DEBUG" ] ; then + (>&2 printf "\\033[0;34m%s\\033[0m\\n" "$1") + fi +} + +err_msg() { + if [ -n "$HLS_WRAPPER_DEBUG" ] ; then + (>&2 printf "\\033[0;31m%s\\033[0m\\n" "$1") + elif [ -n "$HLS_WRAPPER_VERBOSE" ] ; then + (>&2 printf "\\033[0;31m%s\\033[0m\\n" "$1") + fi +} + +instruction_msg() { + (>&2 printf "\\033[0;35m%s\\033[0m\\n" "$1") +} + +err_fix() { + instruction_msg "" + instruction_msg "Consider installing ghc-${GHC_VERSION} via ghcup" + instruction_msg "or build HLS from source." } err_ghc_pkg() { - debug_msg >&2 "Could not find a ghc-pkg binary (found: $1)!" - debug_msg >&2 "Trying other methods..." + err_msg "Could not find a ghc-pkg binary (found: $1)!" } err_abi() { - debug_msg >&2 "GHC ABIs don't match!" - debug_msg >&2 "" - debug_msg >&2 "Expected: ${ABI_HASHES}" - debug_msg >&2 "Got: $1" - debug_msg >&2 "Trying other methods..." + err_msg "GHC ABIs don't match!" + err_msg "" + err_msg "Expected: ${ABI_HASHES}" + err_msg "Got: $1" } err_ver() { - debug_msg >&2 "GHC versions don't match!" - debug_msg >&2 "" - debug_msg >&2 "Expected: ${GHC_VERSION}" - debug_msg >&2 "Got: $1" - debug_msg >&2 "Trying other methods..." + err_msg "GHC versions don't match!" + err_msg "" + err_msg "Expected: ${GHC_VERSION}" + err_msg "Got: $1" } # Check the version of GHC and the ABI. check_ghc() { - { [ -z "$1" ] || [ -z "$2" ] || [ -z "$3" ] || [ -z "$4" ] ;} && debug_msg "internal error: not enough arguments to check_ghc: 1:$1,2:$2,3:$3,4:$4" && return 4 - - debug_msg >&2 "Trying method $4" + { [ -z "$1" ] || [ -z "$2" ] || [ -z "$3" ] ;} && debug_msg "internal error: not enough arguments to check_ghc: 1:$1,2:$2,3:$3" && return 4 check_ghc_libdir=$1 check_ghc_bin=$2 @@ -92,45 +105,47 @@ infer_ghc_pkg() { # try GHC_LIBDIR from the environment (e.g. user set it, or haskell-language-server-wrapper) if [ -n "${GHC_LIBDIR}" ] && [ -n "${GHC_BIN}" ] && - check_ghc "${GHC_LIBDIR}" "${GHC_BIN}" "$(infer_ghc_pkg "${GHC_BIN}")" "GHC_LIBDIR and GHC_BIN from env" + { debug_msg "Trying method: GHC_LIBDIR and GHC_BIN from env" ; HLS_WRAPPER_VERBOSE=1 ; check_ghc "${GHC_LIBDIR}" "${GHC_BIN}" "$(infer_ghc_pkg "${GHC_BIN}")" || { err_fix ; exit 1 ; } ; } then : # try GHC_BIN from the environment (e.g. user set it) elif [ -n "${GHC_BIN}" ] && GHC_LIBDIR="$("${GHC_BIN}" --print-libdir)" && - check_ghc "${GHC_LIBDIR}" "${GHC_BIN}" "$(infer_ghc_pkg "${GHC_BIN}")" "GHC_BIN from env" + { debug_msg "Trying method: GHC_BIN from env" ; HLS_WRAPPER_VERBOSE=1 ; check_ghc "${GHC_LIBDIR}" "${GHC_BIN}" "$(infer_ghc_pkg "${GHC_BIN}")" || { err_fix ; exit 2 ; } ; } then : # try ghcup elif command -v ghcup >/dev/null && GHC_BIN="$(ghcup whereis ghc "${GHC_VERSION}")" && GHC_LIBDIR="$("${GHC_BIN}" --print-libdir)" && - check_ghc "${GHC_LIBDIR}" "${GHC_BIN}" "$(infer_ghc_pkg "${GHC_BIN}")" "ghcup" + { debug_msg "Trying method: ghcup" ; check_ghc "${GHC_LIBDIR}" "${GHC_BIN}" "$(infer_ghc_pkg "${GHC_BIN}")" ; } then : # try ghc-${GHC_VERSION} elif command -v ghc-${GHC_VERSION} >/dev/null && GHC_LIBDIR="$("ghc-${GHC_VERSION}" --print-libdir)" && - check_ghc "${GHC_LIBDIR}" "ghc-${GHC_VERSION}" "$(infer_ghc_pkg "ghc-${GHC_VERSION}")" "ghc-${GHC_VERSION} in PATH" + { debug_msg "Trying method: ghc-${GHC_VERSION} in PATH" ; check_ghc "${GHC_LIBDIR}" "ghc-${GHC_VERSION}" "$(infer_ghc_pkg "ghc-${GHC_VERSION}")" ; } then : # try ghc elif command -v ghc >/dev/null && GHC_LIBDIR="$(ghc --print-libdir)" && - check_ghc "${GHC_LIBDIR}" "ghc" "$(infer_ghc_pkg "ghc")" "ghc in PATH" + { debug_msg "Trying method: ghc in PATH" ; check_ghc "${GHC_LIBDIR}" "ghc" "$(infer_ghc_pkg "ghc")" ; } then : # try stack elif command -v stack >/dev/null && GHC_BIN="$(cd "$(mktemp -d)" && stack --no-system-ghc --no-install-ghc --resolver "ghc-${GHC_VERSION}" exec sh -- -c 'command -v ghc')" && GHC_LIBDIR="$("${GHC_BIN}" --print-libdir)" && - check_ghc "${GHC_LIBDIR}" "${GHC_BIN}" "$(infer_ghc_pkg "${GHC_BIN}")" "stack" + { debug_msg "Trying method: stack" ; check_ghc "${GHC_LIBDIR}" "${GHC_BIN}" "$(infer_ghc_pkg "${GHC_BIN}")" ; } then : else - echo >&2 "All methods exhausted!" - echo >&2 "Couldn't find a working/matching GHC installation" - echo >&2 "exiting..." + HLS_WRAPPER_VERBOSE=1 + err_msg "All methods exhausted!" + err_msg "Couldn't find a working/matching GHC installation" + err_fix + err_msg "exiting..." exit 42 fi @@ -140,18 +155,22 @@ case "$(uname -s)" in "Darwin"|"darwin") if [ -n "$DYLD_LIBRARY_PATH" ] ; then DYLD_LIBRARY_PATH="$(for i in "${GHC_LIBDIR}"/* ; do [ -d "$i" ] && printf "%s" "$i:" ; done)$DYLD_LIBRARY_PATH" + debug_msg "Exporting DYLD_LIBRARY_PATH=${DYLD_LIBRARY_PATH}" export DYLD_LIBRARY_PATH else DYLD_LIBRARY_PATH="$(for i in "${GHC_LIBDIR}"/* ; do [ -d "$i" ] && printf "%s" "$i:" ; done | sed 's/:$//')" + debug_msg "Exporting DYLD_LIBRARY_PATH=${DYLD_LIBRARY_PATH}" export DYLD_LIBRARY_PATH fi ;; *) if [ -n "$LD_LIBRARY_PATH" ] ; then LD_LIBRARY_PATH="$(for i in "${GHC_LIBDIR}"/* ; do [ -d "$i" ] && printf "%s" "$i:" ; done)$LD_LIBRARY_PATH" + debug_msg "Exporting LD_LIBRARY_PATH=${LD_LIBRARY_PATH}" export LD_LIBRARY_PATH else LD_LIBRARY_PATH="$(for i in "${GHC_LIBDIR}"/* ; do [ -d "$i" ] && printf "%s" "$i:" ; done | sed 's/:$//')" + debug_msg "Exporting LD_LIBRARY_PATH=${LD_LIBRARY_PATH}" export LD_LIBRARY_PATH fi ;; From 6baf21fab51fc53d46504b24603bb6e812c07e6c Mon Sep 17 00:00:00 2001 From: Julian Ospald Date: Mon, 7 Feb 2022 22:53:00 +0100 Subject: [PATCH 27/33] Reduce space in CI --- .gitlab/ci.sh | 3 +-- GNUmakefile | 11 ++++------- 2 files changed, 5 insertions(+), 9 deletions(-) diff --git a/.gitlab/ci.sh b/.gitlab/ci.sh index c2d6893f94..6569832f07 100755 --- a/.gitlab/ci.sh +++ b/.gitlab/ci.sh @@ -73,8 +73,7 @@ case "$(uname)" in ;; *) emake --version - emake install-ghcs - emake hls + emake GHCUP=ghcup hls emake bindist rm -rf out/*.*.* ;; diff --git a/GNUmakefile b/GNUmakefile index b97952d1de..88fa3ace56 100644 --- a/GNUmakefile +++ b/GNUmakefile @@ -19,6 +19,7 @@ MKDIR_P := $(MKDIR) -p TAR := tar TAR_MK := $(TAR) caf CABAL := cabal +GHCUP ?= echo AWK := awk STRIP := strip ifeq ($(UNAME), Darwin) @@ -59,12 +60,15 @@ hls: bindist/ghcs done hls-ghc: + $(GHCUP) install ghc "$(GHC_VERSION)" + $(GHCUP) gc -p -s -c $(MKDIR_P) out/ @if test -z "$(GHC_VERSION)" ; then echo >&2 "GHC_VERSION is not set" ; false ; fi @if test -z "$(PROJECT_FILE)" ; then echo >&2 "PROJECT_FILE is not set" ; false ; fi $(CABAL_INSTALL) --project-file="$(PROJECT_FILE)" -w "ghc-$(GHC_VERSION)" $(CABAL_INSTALL_ARGS) --installdir="$(ROOT_DIR)/out/$(GHC_VERSION)" exe:haskell-language-server exe:haskell-language-server-wrapper $(STRIP_S) "$(ROOT_DIR)/out/$(GHC_VERSION)/haskell-language-server" $(STRIP_S) "$(ROOT_DIR)/out/$(GHC_VERSION)/haskell-language-server-wrapper" + $(GHCUP) rm ghc "$(GHC_VERSION)" bindist: for ghc in $(shell cat bindist/ghcs) ; do \ @@ -97,13 +101,6 @@ bindist-ghc: $(FIND) "$(STORE_DIR)/ghc-$(GHC_VERSION)" -type f -name "$(DLL)" -execdir $(INSTALL_X) "{}" "$(ROOT_DIR)/$(BINDIST_OUT_DIR)/lib/$(GHC_VERSION)/{}" \; $(FIND) "$(ROOT_DIR)/$(BINDIST_OUT_DIR)/lib/$(GHC_VERSION)" -type f -name '$(DLL)' -execdir $(call set_rpath,,{}) \; -install-ghcs: - ghcup install ghc recommended - ghcup set ghc recommended - for ghc in $(shell cat bindist/ghcs) ; do \ - ghcup install ghc `echo $$ghc | $(AWK) -F ',' '{ print $$1 }'` ; \ - done - version: @echo "$(HLS_VERSION)" From 23fc39c2bcdc46eb65036e4d61841b725e3c41a1 Mon Sep 17 00:00:00 2001 From: Julian Ospald Date: Tue, 8 Feb 2022 13:44:13 +0100 Subject: [PATCH 28/33] Fix CI issues --- .gitlab-ci.yml | 4 ++++ GNUmakefile | 15 ++++++++++----- bindist/ghcs-FreeBSD | 2 ++ 3 files changed, 16 insertions(+), 5 deletions(-) create mode 100644 bindist/ghcs-FreeBSD diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 474b188986..8fe44a866e 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -468,6 +468,7 @@ build-aarch64-darwin: before_script: - export HOMEBREW_CHANGE_ARCH_TO_ARM=1 - arch -arm64 /bin/bash ./.gitlab/brew.sh llvm autoconf automake coreutils make tree + # C_INCLUDE_PATH: https://gitlab.haskell.org/ghc/ghc/-/issues/20592 script: | export PATH="$CI_PROJECT_DIR/.brew/opt/llvm/bin:$CI_PROJECT_DIR/.brew/bin:$CI_PROJECT_DIR/.brew/sbin:$PATH" export CC=$CI_PROJECT_DIR/.brew/opt/llvm/bin/clang @@ -475,6 +476,7 @@ build-aarch64-darwin: export LD=ld export AR=$CI_PROJECT_DIR/.brew/opt/llvm/bin/llvm-ar export RANLIB=$CI_PROJECT_DIR/.brew/opt/llvm/bin/llvm-ranlib + export C_INCLUDE_PATH="`xcrun --show-sdk-path`/usr/include/ffi" arch -arm64 /bin/bash ./.gitlab/ci.sh after_script: - rm -Rf /private/tmp/.brew_tmp @@ -502,8 +504,10 @@ test-aarch64-darwin: before_script: - export HOMEBREW_CHANGE_ARCH_TO_ARM=1 - arch -arm64 /bin/bash ./.gitlab/brew.sh make tree + # C_INCLUDE_PATH: https://gitlab.haskell.org/ghc/ghc/-/issues/20592 script: | export PATH="$CI_PROJECT_DIR/.brew/opt/llvm/bin:$CI_PROJECT_DIR/.brew/bin:$CI_PROJECT_DIR/.brew/sbin:$PATH" + export C_INCLUDE_PATH="`xcrun --show-sdk-path`/usr/include/ffi" arch -arm64 /bin/bash ./.gitlab/test.sh after_script: - rm -Rf /private/tmp/.brew_tmp diff --git a/GNUmakefile b/GNUmakefile index 88fa3ace56..23adaa7e41 100644 --- a/GNUmakefile +++ b/GNUmakefile @@ -19,7 +19,6 @@ MKDIR_P := $(MKDIR) -p TAR := tar TAR_MK := $(TAR) caf CABAL := cabal -GHCUP ?= echo AWK := awk STRIP := strip ifeq ($(UNAME), Darwin) @@ -31,6 +30,9 @@ RM := rm RM_RF := $(RM) -rf CD := cd +# by default don't run ghcup +GHCUP ?= echo + ifeq ($(UNAME), Darwin) DLL := *.dylib else @@ -55,20 +57,20 @@ define set_rpath endef hls: bindist/ghcs - for ghc in $(shell cat bindist/ghcs) ; do \ + for ghc in $(shell [ -e "bindist/ghcs-`uname`" ] && cat "bindist/ghcs-`uname`" || cat "bindist/ghcs") ; do \ $(MAKE) GHC_VERSION=`echo $$ghc | $(AWK) -F ',' '{ print $$1 }'` PROJECT_FILE=`echo $$ghc | $(AWK) -F ',' '{ print $$2 }'` hls-ghc ; \ done hls-ghc: - $(GHCUP) install ghc "$(GHC_VERSION)" - $(GHCUP) gc -p -s -c + $(GHCUP) -v install ghc "$(GHC_VERSION)" + $(GHCUP) -v gc -p -s -c $(MKDIR_P) out/ @if test -z "$(GHC_VERSION)" ; then echo >&2 "GHC_VERSION is not set" ; false ; fi @if test -z "$(PROJECT_FILE)" ; then echo >&2 "PROJECT_FILE is not set" ; false ; fi $(CABAL_INSTALL) --project-file="$(PROJECT_FILE)" -w "ghc-$(GHC_VERSION)" $(CABAL_INSTALL_ARGS) --installdir="$(ROOT_DIR)/out/$(GHC_VERSION)" exe:haskell-language-server exe:haskell-language-server-wrapper $(STRIP_S) "$(ROOT_DIR)/out/$(GHC_VERSION)/haskell-language-server" $(STRIP_S) "$(ROOT_DIR)/out/$(GHC_VERSION)/haskell-language-server-wrapper" - $(GHCUP) rm ghc "$(GHC_VERSION)" + $(GHCUP) -v rm ghc "$(GHC_VERSION)" bindist: for ghc in $(shell cat bindist/ghcs) ; do \ @@ -83,6 +85,8 @@ bindist-tar: $(CD) "$(BINDIST_BASE_DIR)" ; $(TAR_MK) "$(ROOT_DIR)/out/$(TARBALL)" "haskell-language-server-$(HLS_VERSION)" bindist-ghc: + $(GHCUP) -v install ghc "$(GHC_VERSION)" + $(GHCUP) -v gc -p -s -c if test -z "$(GHC_VERSION)" ; then echo >&2 "GHC_VERSION is not set" ; false ; fi $(MKDIR_P) "$(BINDIST_OUT_DIR)/bin" $(MKDIR_P) "$(BINDIST_OUT_DIR)/lib/$(GHC_VERSION)" @@ -100,6 +104,7 @@ bindist-ghc: $(INSTALL_D) "$(ROOT_DIR)/$(BINDIST_OUT_DIR)/lib/$(GHC_VERSION)" $(FIND) "$(STORE_DIR)/ghc-$(GHC_VERSION)" -type f -name "$(DLL)" -execdir $(INSTALL_X) "{}" "$(ROOT_DIR)/$(BINDIST_OUT_DIR)/lib/$(GHC_VERSION)/{}" \; $(FIND) "$(ROOT_DIR)/$(BINDIST_OUT_DIR)/lib/$(GHC_VERSION)" -type f -name '$(DLL)' -execdir $(call set_rpath,,{}) \; + $(GHCUP) -v rm ghc "$(GHC_VERSION)" version: @echo "$(HLS_VERSION)" diff --git a/bindist/ghcs-FreeBSD b/bindist/ghcs-FreeBSD new file mode 100644 index 0000000000..cab2c69bb2 --- /dev/null +++ b/bindist/ghcs-FreeBSD @@ -0,0 +1,2 @@ +8.10.7,cabal.project +9.0.2,cabal-ghc90.project From 639016e830e9847988fbb90fd6c37ba4b72d48c9 Mon Sep 17 00:00:00 2001 From: Julian Ospald Date: Tue, 8 Feb 2022 13:56:00 +0100 Subject: [PATCH 29/33] Add Makefile documentation --- GNUmakefile | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/GNUmakefile b/GNUmakefile index 23adaa7e41..1eb3b21ae8 100644 --- a/GNUmakefile +++ b/GNUmakefile @@ -1,3 +1,12 @@ +#################################################### +# This makefile's main purpose is to build +# dynamically linked HLS executables on gitlab CI +# and produce appropriate bindists. This can also +# be executed locally on dev machines. +# +# It is not meant to be run by users. +# ################################################## + UNAME := $(shell uname) ROOT_DIR:=$(shell dirname $(realpath $(firstword $(MAKEFILE_LIST)))) From a611f3f9d771a636d8335417fc4e317daec37b05 Mon Sep 17 00:00:00 2001 From: Julian Ospald Date: Tue, 8 Feb 2022 14:36:18 +0100 Subject: [PATCH 30/33] Fix FreeBSD build --- GNUmakefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/GNUmakefile b/GNUmakefile index 1eb3b21ae8..e95b29a670 100644 --- a/GNUmakefile +++ b/GNUmakefile @@ -82,7 +82,7 @@ hls-ghc: $(GHCUP) -v rm ghc "$(GHC_VERSION)" bindist: - for ghc in $(shell cat bindist/ghcs) ; do \ + for ghc in $(shell [ -e "bindist/ghcs-`uname`" ] && cat "bindist/ghcs-`uname`" || cat "bindist/ghcs") ; do \ $(MAKE) GHC_VERSION=`echo $$ghc | $(AWK) -F ',' '{ print $$1 }'` bindist-ghc ; \ done $(SED) -e "s/@@HLS_VERSION@@/$(HLS_VERSION)/" \ From 4a8f19936f1cd8d607ec96d18aeb810bc6be4326 Mon Sep 17 00:00:00 2001 From: Julian Ospald Date: Tue, 8 Feb 2022 15:32:51 +0100 Subject: [PATCH 31/33] Fix --- .gitlab/ci.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitlab/ci.sh b/.gitlab/ci.sh index 6569832f07..58a66ff6d5 100755 --- a/.gitlab/ci.sh +++ b/.gitlab/ci.sh @@ -74,7 +74,7 @@ case "$(uname)" in *) emake --version emake GHCUP=ghcup hls - emake bindist + emake GHCUP=ghcup bindist rm -rf out/*.*.* ;; esac From 57e0a0663cf0d0e51714ac994fd5da23367b0ceb Mon Sep 17 00:00:00 2001 From: Julian Ospald Date: Tue, 8 Feb 2022 18:43:39 +0100 Subject: [PATCH 32/33] Fix ABI hashes --- GNUmakefile | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/GNUmakefile b/GNUmakefile index e95b29a670..d75818ebd8 100644 --- a/GNUmakefile +++ b/GNUmakefile @@ -67,23 +67,26 @@ endef hls: bindist/ghcs for ghc in $(shell [ -e "bindist/ghcs-`uname`" ] && cat "bindist/ghcs-`uname`" || cat "bindist/ghcs") ; do \ + $(GHCUP) -v install ghc `echo $$ghc | $(AWK) -F ',' '{ print $$1 }'` ; \ + $(GHCUP) -v gc -p -s -c ; \ $(MAKE) GHC_VERSION=`echo $$ghc | $(AWK) -F ',' '{ print $$1 }'` PROJECT_FILE=`echo $$ghc | $(AWK) -F ',' '{ print $$2 }'` hls-ghc ; \ + $(GHCUP) -v rm ghc `echo $$ghc | $(AWK) -F ',' '{ print $$1 }'` ; \ done hls-ghc: - $(GHCUP) -v install ghc "$(GHC_VERSION)" - $(GHCUP) -v gc -p -s -c $(MKDIR_P) out/ @if test -z "$(GHC_VERSION)" ; then echo >&2 "GHC_VERSION is not set" ; false ; fi @if test -z "$(PROJECT_FILE)" ; then echo >&2 "PROJECT_FILE is not set" ; false ; fi $(CABAL_INSTALL) --project-file="$(PROJECT_FILE)" -w "ghc-$(GHC_VERSION)" $(CABAL_INSTALL_ARGS) --installdir="$(ROOT_DIR)/out/$(GHC_VERSION)" exe:haskell-language-server exe:haskell-language-server-wrapper $(STRIP_S) "$(ROOT_DIR)/out/$(GHC_VERSION)/haskell-language-server" $(STRIP_S) "$(ROOT_DIR)/out/$(GHC_VERSION)/haskell-language-server-wrapper" - $(GHCUP) -v rm ghc "$(GHC_VERSION)" bindist: for ghc in $(shell [ -e "bindist/ghcs-`uname`" ] && cat "bindist/ghcs-`uname`" || cat "bindist/ghcs") ; do \ + $(GHCUP) -v install ghc `echo $$ghc | $(AWK) -F ',' '{ print $$1 }'` ; \ + $(GHCUP) -v gc -p -s -c ; \ $(MAKE) GHC_VERSION=`echo $$ghc | $(AWK) -F ',' '{ print $$1 }'` bindist-ghc ; \ + $(GHCUP) -v rm ghc `echo $$ghc | $(AWK) -F ',' '{ print $$1 }'` ; \ done $(SED) -e "s/@@HLS_VERSION@@/$(HLS_VERSION)/" \ bindist/GNUmakefile.in > "$(BINDIST_OUT_DIR)/GNUmakefile" @@ -94,8 +97,6 @@ bindist-tar: $(CD) "$(BINDIST_BASE_DIR)" ; $(TAR_MK) "$(ROOT_DIR)/out/$(TARBALL)" "haskell-language-server-$(HLS_VERSION)" bindist-ghc: - $(GHCUP) -v install ghc "$(GHC_VERSION)" - $(GHCUP) -v gc -p -s -c if test -z "$(GHC_VERSION)" ; then echo >&2 "GHC_VERSION is not set" ; false ; fi $(MKDIR_P) "$(BINDIST_OUT_DIR)/bin" $(MKDIR_P) "$(BINDIST_OUT_DIR)/lib/$(GHC_VERSION)" @@ -113,7 +114,6 @@ bindist-ghc: $(INSTALL_D) "$(ROOT_DIR)/$(BINDIST_OUT_DIR)/lib/$(GHC_VERSION)" $(FIND) "$(STORE_DIR)/ghc-$(GHC_VERSION)" -type f -name "$(DLL)" -execdir $(INSTALL_X) "{}" "$(ROOT_DIR)/$(BINDIST_OUT_DIR)/lib/$(GHC_VERSION)/{}" \; $(FIND) "$(ROOT_DIR)/$(BINDIST_OUT_DIR)/lib/$(GHC_VERSION)" -type f -name '$(DLL)' -execdir $(call set_rpath,,{}) \; - $(GHCUP) -v rm ghc "$(GHC_VERSION)" version: @echo "$(HLS_VERSION)" From 166eba88bb3ec24bbc7f86675780a0ba0ef9f7f3 Mon Sep 17 00:00:00 2001 From: Julian Ospald Date: Tue, 8 Feb 2022 20:38:33 +0100 Subject: [PATCH 33/33] Make sure sub-make fails properly --- GNUmakefile | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/GNUmakefile b/GNUmakefile index d75818ebd8..15a0066857 100644 --- a/GNUmakefile +++ b/GNUmakefile @@ -67,9 +67,9 @@ endef hls: bindist/ghcs for ghc in $(shell [ -e "bindist/ghcs-`uname`" ] && cat "bindist/ghcs-`uname`" || cat "bindist/ghcs") ; do \ - $(GHCUP) -v install ghc `echo $$ghc | $(AWK) -F ',' '{ print $$1 }'` ; \ - $(GHCUP) -v gc -p -s -c ; \ - $(MAKE) GHC_VERSION=`echo $$ghc | $(AWK) -F ',' '{ print $$1 }'` PROJECT_FILE=`echo $$ghc | $(AWK) -F ',' '{ print $$2 }'` hls-ghc ; \ + $(GHCUP) -v install ghc `echo $$ghc | $(AWK) -F ',' '{ print $$1 }'` && \ + $(GHCUP) -v gc -p -s -c && \ + $(MAKE) GHC_VERSION=`echo $$ghc | $(AWK) -F ',' '{ print $$1 }'` PROJECT_FILE=`echo $$ghc | $(AWK) -F ',' '{ print $$2 }'` hls-ghc && \ $(GHCUP) -v rm ghc `echo $$ghc | $(AWK) -F ',' '{ print $$1 }'` ; \ done @@ -83,9 +83,9 @@ hls-ghc: bindist: for ghc in $(shell [ -e "bindist/ghcs-`uname`" ] && cat "bindist/ghcs-`uname`" || cat "bindist/ghcs") ; do \ - $(GHCUP) -v install ghc `echo $$ghc | $(AWK) -F ',' '{ print $$1 }'` ; \ - $(GHCUP) -v gc -p -s -c ; \ - $(MAKE) GHC_VERSION=`echo $$ghc | $(AWK) -F ',' '{ print $$1 }'` bindist-ghc ; \ + $(GHCUP) -v install ghc `echo $$ghc | $(AWK) -F ',' '{ print $$1 }'` && \ + $(GHCUP) -v gc -p -s -c && \ + $(MAKE) GHC_VERSION=`echo $$ghc | $(AWK) -F ',' '{ print $$1 }'` bindist-ghc && \ $(GHCUP) -v rm ghc `echo $$ghc | $(AWK) -F ',' '{ print $$1 }'` ; \ done $(SED) -e "s/@@HLS_VERSION@@/$(HLS_VERSION)/" \