diff --git a/haskell/tests/mingw_cc/BUILD.bazel b/haskell/tests/mingw_cc/BUILD.bazel new file mode 100644 index 0000000000..a9e03def5b --- /dev/null +++ b/haskell/tests/mingw_cc/BUILD.bazel @@ -0,0 +1,44 @@ +load("@bazel_skylib//rules:build_test.bzl", "build_test") + +# Keep these loads in sync with _MINGW_CC_LOADS in haskell/toolchain/repos.bzl. +# Only the Windows GHC repo uses them, so this package loads them on every host. +load("@rules_cc//cc/toolchains:cc_toolchain.bzl", "cc_toolchain") +load("@rules_dx//quality:fixtures.bzl", "real_source_target") +load("@rules_haskell//haskell:cc_toolchain_config.bzl", "cc_toolchain_config") + +filegroup(name = "empty") + +cc_toolchain_config( + name = "config", + is_clang = True, +) + +cc_toolchain( + name = "toolchain", + all_files = ":empty", + ar_files = ":empty", + as_files = ":empty", + compiler_files = ":empty", + dwp_files = ":empty", + linker_files = ":empty", + objcopy_files = ":empty", + strip_files = ":empty", + supports_param_files = 0, + toolchain_config = ":config", + toolchain_identifier = "mingw_cc_test", +) + +build_test( + name = "mingw_cc_test", + targets = [ + ":config", + ":toolchain", + ], +) + +real_source_target( + name = "corpus_starlark", + testonly = True, + starlark_srcs = ["BUILD.bazel"], + tags = ["corpus"], +) diff --git a/haskell/toolchain/repos.bzl b/haskell/toolchain/repos.bzl index d22d3b9055..af318e1506 100644 --- a/haskell/toolchain/repos.bzl +++ b/haskell/toolchain/repos.bzl @@ -312,7 +312,7 @@ filegroup( # The bundled mingw clang as a C toolchain. Only the hub's gated toolchain() # entries select it. Loads sit at the top of the generated file. -_MINGW_CC_LOADS = """load("@rules_cc//cc:cc_toolchain.bzl", "cc_toolchain") +_MINGW_CC_LOADS = """load("@rules_cc//cc/toolchains:cc_toolchain.bzl", "cc_toolchain") load("@rules_haskell//haskell:cc_toolchain_config.bzl", "cc_toolchain_config") """ @@ -606,6 +606,7 @@ def _haskell_impl(mctx): Label("//patches/rules_haskell:hermetic_haskell.patch"), Label("//patches/rules_haskell:cabal_rules.patch"), Label("//patches/rules_haskell:toolchain_type_alias.patch"), + Label("//patches/rules_haskell:cc_toolchain_config_info.patch"), ], sha256 = RULES_HASKELL_SHA256, strip_prefix = "rules_haskell-" + RULES_HASKELL_COMMIT, diff --git a/patches/rules_haskell/BUILD.bazel b/patches/rules_haskell/BUILD.bazel index 1665188c42..c240210675 100644 --- a/patches/rules_haskell/BUILD.bazel +++ b/patches/rules_haskell/BUILD.bazel @@ -2,6 +2,7 @@ load("@rules_dx//quality:fixtures.bzl", "real_source_target") exports_files([ "cabal_rules.patch", + "cc_toolchain_config_info.patch", "coverage_wrapper_no_report.patch", "hermetic_haskell.patch", "toolchain_type_alias.patch", diff --git a/patches/rules_haskell/cc_toolchain_config_info.patch b/patches/rules_haskell/cc_toolchain_config_info.patch new file mode 100644 index 0000000000..7ca2d684bd --- /dev/null +++ b/patches/rules_haskell/cc_toolchain_config_info.patch @@ -0,0 +1,13 @@ +Load CcToolchainConfigInfo from rules_cc; the native global is None under Bazel 9. +Upstream: https://github.com/tweag/rules_haskell/issues/2483, https://github.com/tweag/rules_haskell/pull/2484 + +--- a/haskell/cc_toolchain_config.bzl ++++ b/haskell/cc_toolchain_config.bzl +@@ -11,6 +11,7 @@ + "tool_path", + ) + load("@rules_cc//cc:defs.bzl", "cc_common") ++load("@rules_cc//cc/toolchains:cc_toolchain_config_info.bzl", "CcToolchainConfigInfo") + + def _impl(ctx): + tool_paths = [