Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@ You'll need [Bazel >= 6.0][bazel-getting-started] installed.

If you are on NixOS, skip to the [Nixpkgs](#Nixpkgs) section.

> [!NOTE]
> Bazel 8 users will need to add
> `common --noincompatible_disallow_ctx_resolve_tools` to `.bazelrc`

### System dependencies

Refer to the "Before you begin" section in [the documentation](docs/haskell.rst).
Expand Down
2 changes: 1 addition & 1 deletion haskell/cabal.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ load("@bazel_skylib//lib:dicts.bzl", "dicts")
load("@bazel_skylib//lib:paths.bzl", "paths")
load("@bazel_skylib//lib:sets.bzl", "sets")
load("@bazel_tools//tools/build_defs/repo:utils.bzl", "maybe", "read_netrc", "use_netrc")
load("@bazel_tools//tools/cpp:lib_cc_configure.bzl", "get_cpu_value")
load("@rules_cc//cc:find_cc_toolchain.bzl", "find_cc_toolchain", "use_cc_toolchain")
load(":cc.bzl", "cc_interop_info", "ghc_cc_program_args")
load(":haddock.bzl", "generate_unified_haddock_info")
Expand All @@ -20,6 +19,7 @@ load(
load(":private/context.bzl", "haskell_context")
load(":private/dependencies.bzl", "gather_dep_info")
load(":private/expansions.bzl", "expand_make_variables")
load(":private/get_cpu_value.bzl", "get_cpu_value")
load(":private/mode.bzl", "is_profiling_enabled")
load(
":private/path_utils.bzl",
Expand Down
7 changes: 2 additions & 5 deletions haskell/ghc_bindist.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@

load("@bazel_skylib//lib:paths.bzl", "paths")
load("@bazel_tools//tools/build_defs/repo:utils.bzl", "patch")
load("@bazel_tools//tools/cpp:lib_cc_configure.bzl", "get_cpu_value")
load("@rules_cc//cc:find_cc_toolchain.bzl", "CC_TOOLCHAIN_TYPE")
load("@rules_sh//sh:posix.bzl", "sh_posix_configure")
load("//haskell:ghc.bzl", "DEFAULT_GHC_VERSION")
load(":private/bazel_platforms.bzl", "bazel_platforms")
load(":private/get_cpu_value.bzl", "get_cpu_value")
load(
":private/pkgdb_to_bzl.bzl",
"pkgdb_to_bzl",
Expand Down Expand Up @@ -628,10 +628,7 @@ def _configure_python3_toolchain_impl(repository_ctx):
else:
stub_shebang = ""
repository_ctx.file("BUILD.bazel", executable = False, content = """
load(
"@bazel_tools//tools/python:toolchain.bzl",
"py_runtime_pair",
)
load("@rules_python//python:py_runtime_pair.bzl", "py_runtime_pair")
py_runtime(
name = "python3_runtime",
interpreter_path = "{python3}",
Expand Down
40 changes: 40 additions & 0 deletions haskell/private/get_cpu_value.bzl
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# Bazel 8 fix
# Links:
# - https://github.com/tweag/rules_sh/blob/4524d11e15bea61c0f6841cbc3ae0bc9c09835d8/sh/private/get_cpu_value.bzl#L4
# - https://github.com/bazelbuild/rules_cc/blob/8395ec0172270f3bf92cd7b06c9b5b3f1f679e88/cc/private/toolchain/lib_cc_configure.bzl#L225
def get_cpu_value(repository_ctx):
"""Compute the cpu_value based on the OS name. Doesn't %-escape the result!

Args:
repository_ctx: The repository context.
Returns:
One of (darwin, freebsd, x64_windows, ppc, s390x, arm, aarch64, k8, piii)
"""
os_name = repository_ctx.os.name
arch = repository_ctx.os.arch
if os_name.startswith("mac os"):
# Check if we are on x86_64 or arm64 and return the corresponding cpu value.
return "darwin_" + ("arm64" if arch == "aarch64" else "x86_64")
if os_name.find("freebsd") != -1:
return "freebsd"
if os_name.find("openbsd") != -1:
return "openbsd"
if os_name.find("windows") != -1:
if arch == "aarch64":
return "arm64_windows"
else:
return "x64_windows"

if arch in ["power", "ppc64le", "ppc", "ppc64"]:
return "ppc"
if arch in ["s390x"]:
return "s390x"
if arch in ["mips64"]:
return "mips64"
if arch in ["riscv64"]:
return "riscv64"
if arch in ["arm", "armv7l"]:
return "arm"
if arch in ["aarch64"]:
return "aarch64"
return "k8" if arch in ["amd64", "x86_64", "x64"] else "piii"
2 changes: 1 addition & 1 deletion tools/os_info.bzl
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
load("@bazel_tools//tools/cpp:lib_cc_configure.bzl", "get_cpu_value")
load("//haskell:private/get_cpu_value.bzl", "get_cpu_value")

_os_info_bzl_template = """
cpu_value = "{CPU_VALUE}"
Expand Down
Loading