Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add GHC 9.6.2 bindist to CI matrix #2045

Merged
merged 13 commits into from
Nov 28, 2023
Merged
2 changes: 1 addition & 1 deletion .bazelrc.common
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ common:ci-common --color=no

common:ci-common --nolegacy_important_outputs
build:ci-common --experimental_remote_cache_compression

build:ci-common --experimental_remote_build_event_upload=minimal
build:ci-common --loading_phase_threads=1
build:ci-common --verbose_failures
# Make sure we don't rely on the names of convenience symlinks because those
Expand Down
6 changes: 6 additions & 0 deletions .github/workflows/workflow.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -162,11 +162,17 @@ jobs:
ghc:
- 9.2.8
- 9.4.6
- 9.6.2
exclude:
# TODO: in a MODULE.bazel file we declare version specific dependencies, would need to use stack snapshot json
# and stack config per GHC version
- ghc: 9.4.6
bzlmod: true
- ghc: 9.6.2
bzlmod: true
# currently proto-lens-protoc fails with an access violation on Windows
- ghc: 9.6.2
os: windows-latest
env:
# prevent auto-detection of system compilers on Windows
BAZEL_DO_NOT_DETECT_CPP_TOOLCHAIN: ${{ matrix.os == 'windows-latest' && 1 || 0 }}
Expand Down
2 changes: 1 addition & 1 deletion WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ stack_snapshot(
"proto-lens-runtime",
"lens-family",
],
setup_deps = {
setup_deps = {} if GHC_VERSION and GHC_VERSION.startswith("9.6.") else {
# See https://github.com/tweag/rules_haskell/issues/1871
"HUnit": ["@Cabal//:Cabal"],
"bifunctors": ["@Cabal//:Cabal"],
Expand Down
21 changes: 20 additions & 1 deletion extensions/rules_haskell_dependencies.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,20 @@ load("@bazel_tools//tools/build_defs/repo:utils.bzl", "maybe")
load("@rules_haskell//tools:os_info.bzl", "os_info")
load("@rules_haskell_ghc_version//:ghc_version.bzl", "GHC_VERSION")

def _empty_repo_impl(rctx):
fail(rctx.attr.error_msg)

_empty_repo = repository_rule(
implementation = _empty_repo_impl,
doc = """A dummy repository that can be loaded from the MODULE.bazel file but not fetched.""",
attrs = {
"error_msg": attr.string(
doc = "The error message displayed if the repository is fetched",
mandatory = True,
),
},
)

def repositories(*, bzlmod): # @unused
rules_haskell_dependencies_bzlmod()

Expand All @@ -24,7 +38,12 @@ def repositories(*, bzlmod): # @unused

# TODO: Remove when tests are run with a ghc version containing Cabal >= 3.10
# See https://github.com/tweag/rules_haskell/issues/1871
if GHC_VERSION and GHC_VERSION.startswith("9.4."):
if GHC_VERSION and GHC_VERSION.startswith("9.6."):
_empty_repo(
name = "Cabal",
error_msg = "When using GHC >= 9.6, do not depend on @Cabal, as https://github.com/tweag/rules_haskell/issues/1871 is fixed.",
)
elif GHC_VERSION and GHC_VERSION.startswith("9.4."):
http_archive(
name = "Cabal",
build_file_content = """
Expand Down
29 changes: 29 additions & 0 deletions haskell/private/actions/link.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,23 @@ def link_binary(
args.add_all(hs.toolchain.ghcopts)
args.add_all(compiler_flags)

# NOTE When linking, GHC < 9.6 ignores -fplugin= arguments.
#
# GHC >= 9.6, however, tries to locate a package providing the given module.
#
# Failing to find a corresponding package it tries to find a source file with
# the given name and .hs, .lhs, .hsig or .lhsig extension.
#
# Passing appropriate -package-db and -plugin-package-id flags for
# the given plugin causes GHC to try building a dynamic library instead of
# an executable which fails in the linking step with:
#
# > error: main2.o: requires unsupported dynamic reloc 11; recompile with -fPIC
#
# Since compilation is already done at this stage, we simply clear all plugins
# here so they do not have any effect.
args.add("-fclear-plugins")

# By default, GHC will produce mostly-static binaries, i.e. in which all
# Haskell code is statically linked and foreign libraries and system
# dependencies are dynamically linked. If linkstatic is false, i.e. the user
Expand Down Expand Up @@ -351,6 +368,18 @@ def link_library_dynamic(hs, cc, posix, dep_info, extra_srcs, object_files, my_p
args.add_all(["-shared", "-dynamic"])
args.add_all(hs.toolchain.ghcopts)
args.add_all(compiler_flags)

# NOTE When linking, GHC < 9.6 ignores -fplugin= arguments.
#
# GHC >= 9.6, however, tries to locate a package providing the given module.
#
# Failing to find a corresponding package it tries to find a source file with
# the given name and .hs, .lhs, .hsig or .lhsig extension.
#
# Since compilation is already done at this stage, we simply clear all plugins
# here so they do not have any effect.
args.add("-fclear-plugins")

extra_prefix = empty_lib_prefix

(pkg_info_inputs, pkg_info_args) = pkg_info_to_compile_flags(
Expand Down
46 changes: 25 additions & 21 deletions rules_haskell_tests/WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -273,27 +273,31 @@ stack_snapshot(
"temporary",
],
setup_deps = {
"polysemy": ["cabal-doctest"],
# See https://github.com/tweag/rules_haskell/issues/1871
"HUnit": ["@Cabal//:Cabal"],
"bifunctors": ["@Cabal//:Cabal"],
"c2hs": ["@Cabal//:Cabal"],
"call-stack": ["@Cabal//:Cabal"],
"doctest": ["@Cabal//:Cabal"],
"generic-deriving": ["@Cabal//:Cabal"],
"happy": ["@Cabal//:Cabal"],
"hspec": ["@Cabal//:Cabal"],
"hspec-core": ["@Cabal//:Cabal"],
"hspec-discover": ["@Cabal//:Cabal"],
"hspec-expectations": ["@Cabal//:Cabal"],
"mono-traversable": ["@Cabal//:Cabal"],
"proto-lens-protoc": ["@Cabal//:Cabal"],
"proto-lens-runtime": ["@Cabal//:Cabal"],
"quickcheck-io": ["@Cabal//:Cabal"],
"transformers-compat": ["@Cabal//:Cabal"],
"type-errors": ["@Cabal//:Cabal"],
"typed-process": ["@Cabal//:Cabal"],
"unliftio-core": ["@Cabal//:Cabal"],
name: deps
for name, deps in {
"polysemy": ["cabal-doctest"],
# See https://github.com/tweag/rules_haskell/issues/1871
"HUnit": ["@Cabal//:Cabal"],
"bifunctors": ["@Cabal//:Cabal"],
"c2hs": ["@Cabal//:Cabal"],
"call-stack": ["@Cabal//:Cabal"],
"doctest": ["@Cabal//:Cabal"],
"generic-deriving": ["@Cabal//:Cabal"],
"happy": ["@Cabal//:Cabal"],
"hspec": ["@Cabal//:Cabal"],
"hspec-core": ["@Cabal//:Cabal"],
"hspec-discover": ["@Cabal//:Cabal"],
"hspec-expectations": ["@Cabal//:Cabal"],
"mono-traversable": ["@Cabal//:Cabal"],
"proto-lens-protoc": ["@Cabal//:Cabal"],
"proto-lens-runtime": ["@Cabal//:Cabal"],
"quickcheck-io": ["@Cabal//:Cabal"],
"transformers-compat": ["@Cabal//:Cabal"],
"type-errors": ["@Cabal//:Cabal"],
"typed-process": ["@Cabal//:Cabal"],
"unliftio-core": ["@Cabal//:Cabal"],
}.items()
if [d for d in deps if d != "@Cabal//:Cabal"] or not GHC_VERSION or not GHC_VERSION.startswith("9.6.")
},
stack_snapshot_json = "//:stackage_snapshot{}.json".format(
"_" + str(GHC_VERSION) if GHC_VERSION else "",
Expand Down
Loading