From 166da1133ddf9deacea7a92da62980e53994ff34 Mon Sep 17 00:00:00 2001 From: mergify <37929162+mergify@users.noreply.github.com> Date: Thu, 23 May 2024 15:05:00 +0000 Subject: [PATCH 1/9] Add GHC bindist version 9.10.1 --- haskell/private/ghc_bindist_generated.json | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/haskell/private/ghc_bindist_generated.json b/haskell/private/ghc_bindist_generated.json index 8eb6b28a7..f145ae1ad 100644 --- a/haskell/private/ghc_bindist_generated.json +++ b/haskell/private/ghc_bindist_generated.json @@ -444,5 +444,27 @@ "https://downloads.haskell.org/~ghc/9.8.2/ghc-9.8.2-x86_64-unknown-mingw32.tar.xz", "f7d496b850686ea5fbfcecc722ec399ec7acb8d06ebec23bb4dcb9338f430764" ] + }, + "9.10.1": { + "linux_amd64": [ + "https://downloads.haskell.org/~ghc/9.10.1/ghc-9.10.1-x86_64-deb9-linux.tar.xz", + "5c4fb1c2185320afd6b1efaa155f97e956fa782004ce829fb41879ad0fd1cd14" + ], + "linux_arm64": [ + "https://downloads.haskell.org/~ghc/9.10.1/ghc-9.10.1-aarch64-deb10-linux.tar.xz", + "e6df50e62b696e3a8b759670fc79207ccc26e88a79a047561ca1ccb8846157dd" + ], + "darwin_amd64": [ + "https://downloads.haskell.org/~ghc/9.10.1/ghc-9.10.1-x86_64-apple-darwin.tar.xz", + "8cf22188930e10d7ac5270d425e21a3dab606af73a655493639345200c650be9" + ], + "darwin_arm64": [ + "https://downloads.haskell.org/~ghc/9.10.1/ghc-9.10.1-aarch64-apple-darwin.tar.xz", + "ffaf83b5d7a8b2c04920c6e3909c0be21dde27baf380d095fa27e840a3a2e804" + ], + "windows_amd64": [ + "https://downloads.haskell.org/~ghc/9.10.1/ghc-9.10.1-x86_64-unknown-mingw32.tar.xz", + "8bac01906ec2fa5c10c730b5ee5b8165654d654dbaf25ba9d3c42f8e26484c6a" + ] } } From 8f90263daf77eceeee9e43456e4b07bf17c657f4 Mon Sep 17 00:00:00 2001 From: Claudio Bley Date: Fri, 24 May 2024 10:43:21 +0200 Subject: [PATCH 2/9] Use `lib` folder for GHC >= 9.10.1 The layout of the ghc installation changed again, the libdir is now located in `lib`. --- haskell/ghc_bindist.bzl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/haskell/ghc_bindist.bzl b/haskell/ghc_bindist.bzl index 73a87db23..51b740dbf 100644 --- a/haskell/ghc_bindist.bzl +++ b/haskell/ghc_bindist.bzl @@ -226,9 +226,9 @@ rm -f libdir = "lib" if GHC_BINDIST_LIBDIR.get(version) != None and GHC_BINDIST_LIBDIR[version].get(target) != None: libdir = GHC_BINDIST_LIBDIR[version][target] - elif os == "darwin" and version_tuple >= (9, 0, 2): + elif os == "darwin" and version_tuple >= (9, 0, 2) and version_tuple < (9, 10, 1): libdir = "lib/lib" - elif os == "linux" and version_tuple >= (9, 4, 1): + elif os == "linux" and version_tuple >= (9, 4, 1) and version_tuple < (9, 10, 1): libdir = "lib/lib" docdir = "doc" From eff074e935409400e0fd9a1b540bd3f9182bc7a5 Mon Sep 17 00:00:00 2001 From: Claudio Bley Date: Fri, 24 May 2024 10:50:53 +0200 Subject: [PATCH 3/9] Make ghci binary optional `ghci` is just a wrapper that calls `ghc --interactive`. Starting with GHC 9.10.1, the ghci wrapper is not installed to the `bin` folder when using `RelocatableBuild := YES`. Use `ghc --interactive` instead of `ghci`. --- haskell/repl.bzl | 6 +++--- haskell/toolchain.bzl | 16 ++++++++++++++-- 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/haskell/repl.bzl b/haskell/repl.bzl index 0089d7011..253707f12 100644 --- a/haskell/repl.bzl +++ b/haskell/repl.bzl @@ -486,10 +486,10 @@ def _haskell_repl_impl(ctx): is_executable = True, substitutions = { "%{ENV}": render_env(env), - "%{TOOL}": hs.tools.ghci.path, + "%{TOOL}": hs.tools.ghc.path, "%{OUTPUT}": paths.dirname(output.path), "%{ARGS}": "(" + " ".join( - args + [ + ["--interactive"] + args + [ shell.quote(a) for a in quote_args ], @@ -500,7 +500,7 @@ def _haskell_repl_impl(ctx): runfiles = [ ctx.runfiles( files = [ - hs.tools.ghci, + hs.tools.ghc, ghci_repl_script, ], transitive_files = inputs, diff --git a/haskell/toolchain.bzl b/haskell/toolchain.bzl index 7d64878ec..8fb1b9016 100644 --- a/haskell/toolchain.bzl +++ b/haskell/toolchain.bzl @@ -41,7 +41,7 @@ load( "HaskellLibraryInfo", ) -_GHC_BINARIES = ["ghc", "ghc-pkg", "hsc2hs", "haddock", "ghci", "runghc", "hpc"] +_GHC_BINARIES = ["ghc", "ghc-pkg", "hsc2hs", "haddock", "runghc", "hpc"] def _toolchain_library_symlink(dynamic_library): prefix = dynamic_library.owner.workspace_root.replace("_", "_U").replace("/", "_S") @@ -331,7 +331,19 @@ def _haskell_toolchain_impl(ctx): for tool, asterius_binary in ahc_binaries.items(): tools_struct_args[ASTERIUS_BINARIES[tool]] = asterius_binary else: - ghc_binaries = _lookup_binaries(_GHC_BINARIES, ctx.files.tools, ctx.attr.version) + ghc_tools = _GHC_BINARIES + + # GHC > 9.10 does not install ghci with relocatable = true, add the tool if it is available + if any([file.basename.startswith("ghci") for file in ctx.files.tools]): + ghc_tools = ghc_tools + ["ghci"] + else: + print( + "WARN: ghci binary is not available for {}, `tools.ghci` will not exist on its haskell toolchain".format( + ctx.label.repo_name, + ), + ) + + ghc_binaries = _lookup_binaries(ghc_tools, ctx.files.tools, ctx.attr.version) tools_struct_args = { name.replace("-", "_"): file for name, file in ghc_binaries.items() From aaf4c3653a51496982e0f02cce3986962cc58d74 Mon Sep 17 00:00:00 2001 From: Claudio Bley Date: Fri, 24 May 2024 10:52:16 +0200 Subject: [PATCH 4/9] Add resolver for GHC 9.6 to start script - use nightly for unsupported versions --- start | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/start b/start index b58f1e26d..76bdeafc5 100755 --- a/start +++ b/start @@ -201,8 +201,6 @@ case "${MODE}" in ;; esac > "${ZLIB_BUILD_FILE}" -SNAPSHOT=lts-20.3 - case "$GHC_VERSION" in 8.10.*) SNAPSHOT=lts-18.28 @@ -216,7 +214,11 @@ case "$GHC_VERSION" in 9.4.*) SNAPSHOT=lts-21.5 ;; + 9.6.*) + SNAPSHOT=lts-22.22 + ;; *) + SNAPSHOT=nightly-2024-05-24 stderr "warning: unsupported GHC version: ${GHC_VERSION}, using stack resolver ${SNAPSHOT}" esac From bbd7d0325143c98225243de1a6d8be64bfd1809c Mon Sep 17 00:00:00 2001 From: Claudio Bley Date: Thu, 2 May 2024 18:25:59 +0200 Subject: [PATCH 5/9] Bump maximum Bazel version in start script --- start | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/start b/start index 76bdeafc5..640436307 100755 --- a/start +++ b/start @@ -13,7 +13,7 @@ readonly MIN_BAZEL_MAJOR=6 readonly MIN_BAZEL_MINOR=0 readonly MAX_BAZEL_MAJOR=6 -readonly MAX_BAZEL_MINOR=4 +readonly MAX_BAZEL_MINOR=5 stderr () { >&2 echo "$*" From e6925a5e7036ef500e62e1994ccf1d5dd1cb5876 Mon Sep 17 00:00:00 2001 From: Claudio Bley Date: Thu, 2 May 2024 18:26:58 +0200 Subject: [PATCH 6/9] Remove unused path setting --- .github/workflows/patch-test.yaml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/patch-test.yaml b/.github/workflows/patch-test.yaml index 11eb56f71..02a99830b 100644 --- a/.github/workflows/patch-test.yaml +++ b/.github/workflows/patch-test.yaml @@ -71,7 +71,6 @@ jobs: - name: Build & test shell: bash run: | - export PATH=$HOME/bazel:$PATH export GHC_VERSION=${{ matrix.ghc-version }} cd rules_haskell_tests ./tests/run-start-script.sh --use-bindists From fbb00627a9da6324ebe8f037b070ae9e077b9a47 Mon Sep 17 00:00:00 2001 From: Claudio Bley Date: Fri, 3 May 2024 14:42:59 +0200 Subject: [PATCH 7/9] Specify version for bazelisk via `USE_BAZEL_VERSION` bazelisk does not read the `.bazelversion` file when there is no WORKSPACE and first fetches the latest Bazel version, which causes a warning and later fetches the Bazel version specified in the `.bazelversion` file. See https://github.com/bazelbuild/bazelisk/issues/523 --- rules_haskell_tests/tests/run-start-script.sh | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/rules_haskell_tests/tests/run-start-script.sh b/rules_haskell_tests/tests/run-start-script.sh index e7ea85542..27200c7e6 100755 --- a/rules_haskell_tests/tests/run-start-script.sh +++ b/rules_haskell_tests/tests/run-start-script.sh @@ -14,6 +14,11 @@ rm -rf $workdir mkdir $workdir cd $workdir cp "$rules_haskell_dir/.bazelversion" . + +# specify version for bazelisk via `USE_BAZEL_VERSION`, since it does not read the .bazelversion when there is no WORKSPACE file +USE_BAZEL_VERSION=$( cat .bazelversion ) +export USE_BAZEL_VERSION + # arguments are passed on to the start script "$rules_haskell_dir/start" "$@" From b4cfa8ed4de1613865c406bc30e492df2e78966d Mon Sep 17 00:00:00 2001 From: Claudio Bley Date: Fri, 24 May 2024 13:37:17 +0200 Subject: [PATCH 8/9] Disable use of pkg-config for zlib In recent versions haskell zlib is using pkg-config to locate the C zlib but thoughtfully there is a flag to disable it. --- rules_haskell_tests/non_module_deps_2.bzl | 2 ++ start | 3 +++ 2 files changed, 5 insertions(+) diff --git a/rules_haskell_tests/non_module_deps_2.bzl b/rules_haskell_tests/non_module_deps_2.bzl index 1f3c34450..85fcecced 100644 --- a/rules_haskell_tests/non_module_deps_2.bzl +++ b/rules_haskell_tests/non_module_deps_2.bzl @@ -31,6 +31,8 @@ def repositories(*, bzlmod): # @unused local_snapshot = "//:stackage_snapshot{}.yaml".format( "_" + str(GHC_VERSION) if GHC_VERSION else "", ), + # disable calling pkg-config + flags = {"zlib": ["-pkg-config"]}, packages = ["zlib"], stack_snapshot_json = ("//:stackage-zlib-snapshot{}.json".format( "_" + str(GHC_VERSION) if GHC_VERSION else "", diff --git a/start b/start index 640436307..16cc405a2 100755 --- a/start +++ b/start @@ -271,6 +271,9 @@ stack_snapshot( extra_deps = {"zlib": ["@zlib.dev//:zlib"]}, packages = ["zlib"], + # disable calling pkg-config + flags = {"zlib": ["-pkg-config"]}, + # LTS snapshot published for ghc-${GHC_VERSION} (default version used by rules_haskell) snapshot = "$SNAPSHOT", From a6cf36f21f3dd24494ba381b82b4654775d96f13 Mon Sep 17 00:00:00 2001 From: Claudio Bley Date: Tue, 28 May 2024 10:38:44 +0200 Subject: [PATCH 9/9] Disable haddock for nightly stack snapshot on Windows This works around https://github.com/tweag/rules_haskell/issues/2200 --- start | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/start b/start index 16cc405a2..5a33fff33 100755 --- a/start +++ b/start @@ -201,6 +201,8 @@ case "${MODE}" in ;; esac > "${ZLIB_BUILD_FILE}" +WITH_HADDOCK=True + case "$GHC_VERSION" in 8.10.*) SNAPSHOT=lts-18.28 @@ -218,6 +220,12 @@ case "$GHC_VERSION" in SNAPSHOT=lts-22.22 ;; *) + # zlib >= 0.7.1.0 depends on zlib-clib on Windows (unless using pkg-config), since zlib-clib is + # a C only cabal library that does not produce any haddock this results in an error. + # See https://github.com/tweag/rules_haskell/issues/2200 + case "$( uname )" in + WindowsNT | MINGW* | MSYS* ) WITH_HADDOCK=False ;; + esac SNAPSHOT=nightly-2024-05-24 stderr "warning: unsupported GHC version: ${GHC_VERSION}, using stack resolver ${SNAPSHOT}" esac @@ -273,6 +281,7 @@ stack_snapshot( # disable calling pkg-config flags = {"zlib": ["-pkg-config"]}, + haddock = $WITH_HADDOCK, # LTS snapshot published for ghc-${GHC_VERSION} (default version used by rules_haskell) snapshot = "$SNAPSHOT",