Skip to content

Commit eff074e

Browse files
committed
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`.
1 parent 8f90263 commit eff074e

File tree

2 files changed

+17
-5
lines changed

2 files changed

+17
-5
lines changed

haskell/repl.bzl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -486,10 +486,10 @@ def _haskell_repl_impl(ctx):
486486
is_executable = True,
487487
substitutions = {
488488
"%{ENV}": render_env(env),
489-
"%{TOOL}": hs.tools.ghci.path,
489+
"%{TOOL}": hs.tools.ghc.path,
490490
"%{OUTPUT}": paths.dirname(output.path),
491491
"%{ARGS}": "(" + " ".join(
492-
args + [
492+
["--interactive"] + args + [
493493
shell.quote(a)
494494
for a in quote_args
495495
],
@@ -500,7 +500,7 @@ def _haskell_repl_impl(ctx):
500500
runfiles = [
501501
ctx.runfiles(
502502
files = [
503-
hs.tools.ghci,
503+
hs.tools.ghc,
504504
ghci_repl_script,
505505
],
506506
transitive_files = inputs,

haskell/toolchain.bzl

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ load(
4141
"HaskellLibraryInfo",
4242
)
4343

44-
_GHC_BINARIES = ["ghc", "ghc-pkg", "hsc2hs", "haddock", "ghci", "runghc", "hpc"]
44+
_GHC_BINARIES = ["ghc", "ghc-pkg", "hsc2hs", "haddock", "runghc", "hpc"]
4545

4646
def _toolchain_library_symlink(dynamic_library):
4747
prefix = dynamic_library.owner.workspace_root.replace("_", "_U").replace("/", "_S")
@@ -331,7 +331,19 @@ def _haskell_toolchain_impl(ctx):
331331
for tool, asterius_binary in ahc_binaries.items():
332332
tools_struct_args[ASTERIUS_BINARIES[tool]] = asterius_binary
333333
else:
334-
ghc_binaries = _lookup_binaries(_GHC_BINARIES, ctx.files.tools, ctx.attr.version)
334+
ghc_tools = _GHC_BINARIES
335+
336+
# GHC > 9.10 does not install ghci with relocatable = true, add the tool if it is available
337+
if any([file.basename.startswith("ghci") for file in ctx.files.tools]):
338+
ghc_tools = ghc_tools + ["ghci"]
339+
else:
340+
print(
341+
"WARN: ghci binary is not available for {}, `tools.ghci` will not exist on its haskell toolchain".format(
342+
ctx.label.repo_name,
343+
),
344+
)
345+
346+
ghc_binaries = _lookup_binaries(ghc_tools, ctx.files.tools, ctx.attr.version)
335347
tools_struct_args = {
336348
name.replace("-", "_"): file
337349
for name, file in ghc_binaries.items()

0 commit comments

Comments
 (0)