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

Update Bazel to 6.4.0 #2063

Merged
merged 9 commits into from
Dec 18, 2023
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
1 change: 0 additions & 1 deletion .ci/bazel-6.2.0-darwin-x86_64.sha256

This file was deleted.

1 change: 0 additions & 1 deletion .ci/bazel-6.2.0-linux-x86_64.sha256

This file was deleted.

1 change: 0 additions & 1 deletion .ci/bazel-6.2.0-windows-x86_64.exe.sha256

This file was deleted.

1 change: 1 addition & 0 deletions .ci/bazel-6.4.0-darwin-x86_64.sha256
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
eef2661dabc3de09c9c8f839f7789b29763ea9987659e432b3c4e6246b3fe5df bazel-6.4.0-darwin-x86_64
1 change: 1 addition & 0 deletions .ci/bazel-6.4.0-linux-x86_64.sha256
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
79e4f370efa6e31717b486af5d9efd95864d0ef13da138582224ac9b2a1bad86 bazel-6.4.0-linux-x86_64
1 change: 1 addition & 0 deletions .ci/bazel-6.4.0-windows-x86_64.exe.sha256
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ff94279f7de7ec604c40b5d760f0dc10bdc880f07e915adced825f53e5f4fa1b bazel-6.4.0-windows-x86_64.exe
2 changes: 1 addition & 1 deletion .ci/bazelversion
Original file line number Diff line number Diff line change
@@ -1 +1 @@
6.2.0
6.4.0
8 changes: 4 additions & 4 deletions .github/workflows/workflow.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ jobs:
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-11]
os: [ubuntu-latest, macos-latest]
module: [rules_haskell, rules_haskell_nix, rules_haskell_tests]
bzlmod: [true, false]
ghc:
Expand Down Expand Up @@ -144,7 +144,7 @@ jobs:
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-11, windows-latest]
os: [ubuntu-latest, macos-latest, windows-latest]
module: [rules_haskell, rules_haskell_tests]
bzlmod: [true, false]
ghc:
Expand All @@ -165,14 +165,14 @@ jobs:
# prevent auto-detection of system compilers on Windows
BAZEL_DO_NOT_DETECT_CPP_TOOLCHAIN: ${{ matrix.os == 'windows-latest' && 1 || 0 }}
# do not use Xcode on macOS
BAZEL_USE_CPP_ONLY_TOOLCHAIN: ${{ matrix.os == 'macos-11' && 1 || 0 }}
BAZEL_USE_CPP_ONLY_TOOLCHAIN: ${{ matrix.os == 'macos-latest' && 1 || 0 }}
GHC_VERSION: ${{ matrix.ghc }}
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- uses: ./.github/actions/free_disk_space_on_linux
- uses: ./.github/actions/install_apt_pkgs
with:
with:
packages: libtinfo5
- name: Mount Bazel cache
uses: actions/cache@v3
Expand Down
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ for Haskell. Get started building your own project using these rules
with the [setup script below](#setup).

[bazel]: https://bazel.build/
[bazel-getting-started]: https://docs.bazel.build/versions/master/getting-started.html
[bazel-getting-started]: https://bazel.build/start
[bazel-cli]: https://docs.bazel.build/versions/master/command-line-reference.html
[external-repositories]: https://docs.bazel.build/versions/master/external.html
[nix]: https://nixos.org/nix
Expand All @@ -23,7 +23,7 @@ The full reference documentation for rules is at https://haskell.build.

## Setup

You'll need [Bazel >= 5.0][bazel-getting-started] installed.
You'll need [Bazel >= 6.0][bazel-getting-started] installed.

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

Expand Down Expand Up @@ -335,12 +335,12 @@ http_archive(

To reference a local checkout instead, use the
[`--override_repository`][override_repository] command line option:

```
bazel build/test/run/sync \
--override_repository rules_haskell=/path/to/checkout
```

If you don’t want to type that every time, [temporarily add it to
`.bazelrc`][bazelrc].

Expand Down
2 changes: 1 addition & 1 deletion docs/haskell-use-cases.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1228,7 +1228,7 @@ configuration can be avoided by telling Nix to fetch it from the
`haskell.nix binary cache`_.

.. _arm example: https://github.com/tweag/rules_haskell/blob/master/examples/arm/arm-cross.nix
.. _haskell.nix binary cache: https://input-output-hk.github.io/haskell.nix/tutorials/getting-started/#setting-up-the-binary-cache
.. _haskell.nix binary cache: https://input-output-hk.github.io/haskell.nix/tutorials/getting-started.html#setting-up-the-binary-cache

To tell ``rules_haskell`` about the cross-compiler, we can register it
in the `WORKSPACE file <https://github.com/tweag/rules_haskell/blob/master/examples/arm/WORKSPACE>`_. ::
Expand Down
2 changes: 1 addition & 1 deletion docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,5 @@ Requirements:
haskell-use-cases

.. _Bazel: https://bazel.build
.. _Bazel documentation: https://docs.bazel.build/versions/master/getting-started.html
.. _Bazel documentation: https://bazel.build/start
.. _start script: https://haskell.build/start
11 changes: 10 additions & 1 deletion examples/non_module_deps.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,16 @@ cc_library(
includes = ["."],
visibility = ["//visibility:public"],
)
cc_library(name = "z", srcs = glob(["*.c"]), hdrs = glob(["*.h"]))
cc_library(
name = "z",
srcs = glob(["*.c"]),
hdrs = glob(["*.h"]),
copts = select({
"@bazel_tools//src/conditions:windows": [],
# Needed to avoid "call to undeclared function" errors [-Wimplicit-function-declaration]
"//conditions:default": ["-DZ_HAVE_UNISTD_H"],
}),
)
""",
sha256 = "b5b06d60ce49c8ba700e0ba517fa07de80b5d4628a037f4be8ad16955be7a7c0",
strip_prefix = "zlib-1.3",
Expand Down
5 changes: 3 additions & 2 deletions haskell/cabal.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -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
ar = paths.join(paths.dirname(ar), "ar")

return struct(
ghc = hs.tools.ghc.path,
Expand Down
7 changes: 5 additions & 2 deletions haskell/cc.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ load(
"C_COMPILE_ACTION_NAME",
)
load("@rules_cc//cc:find_cc_toolchain.bzl", "find_cc_toolchain")
load("@bazel_skylib//lib:paths.bzl", "paths")
load(
"//haskell:providers.bzl",
"GhcPluginInfo",
Expand Down Expand Up @@ -136,8 +137,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 = tools["ar"]
if paths.basename(ar) == "libtool":
# assume `ar` is available at the same place
tools["ar"] = paths.join(paths.dirname(ar), "ar")

env = {}
if hs_toolchain.is_darwin:
Expand Down
3 changes: 3 additions & 0 deletions haskell/doctest.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,9 @@ def _haskell_doctest_single(target, ctx):
{env}
# doctest needs PATH to call GHC and the C compiler and linker.
export PATH
# signal our cc_wrapper to silence linker outputs as GHC < 9.4 writes that to
# the GHCI ouput which interferes with doctest's expected ouput
export RULES_HASKELL_SILENCE_LINKER=1
{doctest} "$@" {inputs} > {output} 2>&1 || (rc=$? && cat {output} && exit $rc)
""".format(
doctest = toolchain.doctest[0].path,
Expand Down
5 changes: 4 additions & 1 deletion haskell/private/cc_wrapper.py.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -570,7 +570,10 @@ def link(output, libraries, rpaths, args):
rpaths = shorten_rpaths(rpaths, libraries, output)

args.extend(rpath_args(rpaths))
run_cc(args, exit_on_error=True)
# Note: `RULES_HASKELL_SILENCE_LINKER` is only set if called from doctest,
# which is used to silence the linker output to not interfere with the output
# from GHCi
run_cc(args, capture_output="RULES_HASKELL_SILENCE_LINKER" in os.environ, exit_on_error=True)

if is_darwin():
darwin_rewrite_load_commands(darwin_rewrites, output)
Expand Down
2 changes: 1 addition & 1 deletion haskell/private/versions.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
# See https://github.com/tweag/rules_haskell/pull/1781#issuecomment-1187640454
SUPPORTED_BAZEL_VERSIONS = [
"6.0.0",
"6.2.0",
"6.3.2",
"6.4.0",
]

SUPPORTED_NIXPKGS_BAZEL_PACKAGES = [
Expand Down
6 changes: 3 additions & 3 deletions nixpkgs/default.nix
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{ ... }@args:
let
# 2023-10-20
sha256 = "07dv5x236rqf5b718b7bhpqf2yaq43h6w8mrz9fcb0hxwjzsxlpg";
rev = "80c1aab725151632ddc2a20caeb914e76dd0673c";
# 2023-11-30
sha256 = "sha256:06m9r85brk6pcghm63ksl2zsx9j1kbagic3fx2p656z20v1bd48z";
rev = "781e2a9797ecf0f146e81425c822dca69fe4a348";
in
import (fetchTarball {
inherit sha256;
Expand Down
2 changes: 1 addition & 1 deletion rules_haskell_tests/MODULE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -114,8 +114,8 @@ use_repo(
"asterius_bundle_linux_amd64",
"bazel_6",
"build_bazel_bazel_6_0_0",
"build_bazel_bazel_6_2_0",
"build_bazel_bazel_6_3_2",
"build_bazel_bazel_6_4_0",
"glibc_locales",
"linux_amd64_asterius-toolchain",
"nixpkgs_config_cc",
Expand Down
8 changes: 5 additions & 3 deletions rules_haskell_tests/non_module_deps.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -89,9 +89,11 @@ cc_library(
name = "z",
srcs = glob(["*.c"]),
hdrs = glob(["*.h"]),
# Needed because XCode 12.0 Clang errors by default.
# See https://developer.apple.com/documentation/xcode-release-notes/xcode-12-release-notes.
copts = ["-Wno-error=implicit-function-declaration"],
copts = select({
"@bazel_tools//src/conditions:windows": [],
# Needed to avoid "call to undeclared function" errors [-Wimplicit-function-declaration]
"//conditions:default": ["-DZ_HAVE_UNISTD_H"],
}),
# Cabal packages depending on dynamic C libraries fail on MacOS
# due to `-rpath` flags being forwarded indiscriminately.
# See https://github.com/tweag/rules_haskell/issues/1317
Expand Down
11 changes: 10 additions & 1 deletion shell.nix
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
{ pkgs ? import ./nixpkgs { }, docTools ? true, ghcVersion ? "9.2.8" }:

with pkgs;

let
macOS-security =
# make `/usr/bin/security` available in `PATH`, which is needed for stack
# on darwin which calls this binary to find certificates
writeScriptBin "security" ''exec /usr/bin/security "$@"'';
in
mkShell {
# XXX: hack for macosX, this flags disable bazel usage of xcode
# Note: this is set even for linux so any regression introduced by this flag
Expand Down Expand Up @@ -36,7 +43,9 @@ mkShell {
# check the start script for problems
shellcheck
file
] ++ lib.optionals docTools [ graphviz python39Packages.sphinx zip unzip ];
]
++ lib.optionals docTools [ graphviz python39Packages.sphinx zip unzip ]
++ lib.optional stdenv.isDarwin macOS-security;

packages = [ bazel_6 ];

Expand Down
2 changes: 1 addition & 1 deletion start
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ readonly MIN_BAZEL_MAJOR=6
readonly MIN_BAZEL_MINOR=0

readonly MAX_BAZEL_MAJOR=6
readonly MAX_BAZEL_MINOR=3
readonly MAX_BAZEL_MINOR=4

stderr () {
>&2 echo "$*"
Expand Down