diff --git a/haskell/cabal.bzl b/haskell/cabal.bzl index 081ab0c021..2b65a72e58 100644 --- a/haskell/cabal.bzl +++ b/haskell/cabal.bzl @@ -164,8 +164,9 @@ def _cabal_toolchain_info(hs, cc, workspace_name, runghc): # TODO: remove this if Bazel fixes its behavior. # Upstream ticket: https://github.com/bazelbuild/bazel/issues/5127. ar = cc.tools.ar - if ar.find("libtool") >= 0: - ar = "/usr/bin/ar" + if paths.basename(ar) == "libtool": + # assume `ar` is available at the same place as `libtool` + ar = paths.join(paths.dirname(ar), "ar") return struct( ghc = hs.tools.ghc.path, diff --git a/haskell/cc.bzl b/haskell/cc.bzl index 201b9a18cc..93e50c692f 100644 --- a/haskell/cc.bzl +++ b/haskell/cc.bzl @@ -136,8 +136,10 @@ def cc_interop_info(ctx, override_cc_toolchain = None): # "/usr/bin/libtool". Since we call ar directly, override it. # TODO: remove this if Bazel fixes its behavior. # Upstream ticket: https://github.com/bazelbuild/bazel/issues/5127. - if tools["ar"].find("libtool") >= 0: - tools["ar"] = "/usr/bin/ar" + ar_tool = tools["ar"] + if paths.basename(ar_tool) == "libtool": + # assume `ar` is available at the same place as `libtool` + tools["ar"] = paths.join(paths.dirname(ar_tool), "ar") env = {} if hs_toolchain.is_darwin: