Skip to content

Commit

Permalink
Windows bindist >= 9.4.1 ships with clang instead of GCC
Browse files Browse the repository at this point in the history
There is no `gcc.exe` anymore, but both of `cc.exe`.
  • Loading branch information
avdv committed May 4, 2023
1 parent 5a67b73 commit e381162
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 3 deletions.
6 changes: 4 additions & 2 deletions haskell/cc_toolchain_config.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ def _impl(ctx):
),
tool_path(
name = "gcc",
path = "mingw/bin/gcc",
path = "mingw/bin/clang" if ctx.attr.is_clang else "mingw/bin/gcc",
),
tool_path(
name = "gcov",
Expand Down Expand Up @@ -102,6 +102,8 @@ def _impl(ctx):

cc_toolchain_config = rule(
implementation = _impl,
attrs = {},
attrs = {
"is_clang": attr.bool(default = False, mandatory = False),
},
provides = [CcToolchainConfigInfo],
)
2 changes: 1 addition & 1 deletion haskell/ghc.BUILD.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -65,4 +65,4 @@ cc_toolchain(
toolchain_identifier = "ghc_windows_mingw64",
)

cc_toolchain_config(name = "ghc_windows_mingw64_config")
cc_toolchain_config(name = "ghc_windows_mingw64_config", is_clang=%{is_clang})
4 changes: 4 additions & 0 deletions haskell/ghc_bindist.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -213,13 +213,17 @@ rm -f
cabalopts = ctx.attr.cabalopts,
locale = repr(locale),
)

is_clang = ctx.path(paths.join(unpack_dir, "mingw", "bin", "clang.exe")).exists

ctx.template(
"BUILD",
filepaths["@rules_haskell//haskell:ghc.BUILD.tpl"],
substitutions = {
"%{toolchain_libraries}": toolchain_libraries,
"%{toolchain}": toolchain,
"%{docdir}": docdir,
"%{is_clang}": str(is_clang),
},
executable = False,
)
Expand Down

0 comments on commit e381162

Please sign in to comment.