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 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" 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" + ] } } 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() 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/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" "$@" diff --git a/start b/start index b58f1e26d..5a33fff33 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 "$*" @@ -201,7 +201,7 @@ case "${MODE}" in ;; esac > "${ZLIB_BUILD_FILE}" -SNAPSHOT=lts-20.3 +WITH_HADDOCK=True case "$GHC_VERSION" in 8.10.*) @@ -216,7 +216,17 @@ case "$GHC_VERSION" in 9.4.*) SNAPSHOT=lts-21.5 ;; + 9.6.*) + 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 @@ -269,6 +279,10 @@ stack_snapshot( extra_deps = {"zlib": ["@zlib.dev//:zlib"]}, packages = ["zlib"], + # 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",