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

[bazel] Update Bazel to version 7.3.1 #24392

Merged
merged 8 commits into from
Sep 17, 2024
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
5 changes: 5 additions & 0 deletions .bazelrc
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
# Licensed under the Apache License, Version 2.0, see LICENSE for details.
# SPDX-License-Identifier: Apache-2.0

# Opt-out of bzlmod for now and continue to use `WORKSPACE`.
common --noenable_bzlmod

# https://docs.opentitan.org/doc/rm/c_cpp_coding_style/#cxx-version specifies
build --action_env=BAZEL_CXXOPTS="-std=gnu++14"
build --cxxopt='-std=gnu++14'
Expand All @@ -14,10 +17,12 @@ build --strip='never'
# Override default enablement of flags from @crt//common to control C compiler
# warnings.
build --features=-pedantic_warnings
build --host_features=-pedantic_warnings

# Enable toolchain hardening features.
# `guards` adds `unimp` guard instructions after unconditional jumps.
build --features=guards
build --host_features=guards

# Use --config=disable_hardening to disable hardening to measure the
# impact of the hardened sequences on code size.
Expand Down
2 changes: 1 addition & 1 deletion .bazelversion
Original file line number Diff line number Diff line change
@@ -1 +1 @@
6.2.1
7.3.1
3 changes: 3 additions & 0 deletions hw/bitstream/vivado/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ fusesoc_build(
"bitstream": ["synth-vivado/lowrisc_systems_chip_earlgrey_cw310_0.1.bit"],
"rom_mmi": ["synth-vivado/rom.mmi"],
"otp_mmi": ["synth-vivado/otp.mmi"],
"logs": ["synth-vivado/lowrisc_systems_chip_earlgrey_cw310_0.1.runs/"],
},
systems = ["lowrisc:systems:chip_earlgrey_cw310"],
tags = ["manual"],
Expand Down Expand Up @@ -103,6 +104,7 @@ fusesoc_build(
"bitstream": ["synth-vivado/lowrisc_systems_chip_earlgrey_cw310_hyperdebug_0.1.bit"],
"rom_mmi": ["synth-vivado/rom.mmi"],
"otp_mmi": ["synth-vivado/otp.mmi"],
"logs": ["synth-vivado/lowrisc_systems_chip_earlgrey_cw310_hyperdebug_0.1.runs/"],
},
systems = ["lowrisc:systems:chip_earlgrey_cw310_hyperdebug"],
tags = ["manual"],
Expand Down Expand Up @@ -152,6 +154,7 @@ fusesoc_build(
"bitstream": ["synth-vivado/lowrisc_systems_chip_earlgrey_cw340_0.1.bit"],
"rom_mmi": ["synth-vivado/rom.mmi"],
"otp_mmi": ["synth-vivado/otp.mmi"],
"logs": ["synth-vivado/lowrisc_systems_chip_earlgrey_cw340_0.1.runs/"],
},
systems = ["lowrisc:systems:chip_earlgrey_cw340"],
tags = ["manual"],
Expand Down
27 changes: 20 additions & 7 deletions rules/fusesoc.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,13 @@ def _corefiles2rootarg(core):
return core.dirname

def _fusesoc_build_impl(ctx):
dirname = "build.{}".format(ctx.label.name)
out_dir = ctx.actions.declare_directory(dirname)
build_dir = "build.{}".format(ctx.label.name)
out_dir = "{}/{}/{}".format(ctx.bin_dir.path, ctx.label.package, build_dir)
flags = [ctx.expand_location(f, ctx.attr.srcs) for f in ctx.attr.flags]
outputs = [out_dir]
outputs = []
jwnrt marked this conversation as resolved.
Show resolved Hide resolved
groups = {}

cache_dir = "{}/fusesoc-cache".format(out_dir.path)
cache_dir = "{}/fusesoc-cache".format(out_dir)
cfg_file_path = "build.{}.fusesoc_config.toml".format(ctx.label.name)
cfg_file = ctx.actions.declare_file(cfg_file_path)
cfg_str = "[main]\n cache_root = {}".format(cache_dir)
Expand All @@ -41,7 +41,13 @@ def _fusesoc_build_impl(ctx):
args.add(cfg_file.path, format = "--config=%s")

for group, files in ctx.attr.output_groups.items():
deps = [ctx.actions.declare_file("{}/{}".format(dirname, f)) for f in files]
deps = []
for file in files:
path = "{}/{}".format(build_dir, file)
if file.endswith("/"):
deps.append(ctx.actions.declare_directory(path))
else:
deps.append(ctx.actions.declare_file(path))
outputs.extend(deps)
groups[group] = depset(deps)

Expand Down Expand Up @@ -69,7 +75,7 @@ def _fusesoc_build_impl(ctx):
"--setup",
"--build",
])
args.add(out_dir.path, format = "--build-root=%s")
args.add(out_dir, format = "--build-root=%s")

args.add_all(ctx.attr.systems)
args.add_all(flags)
Expand Down Expand Up @@ -106,7 +112,14 @@ fusesoc_build = rule(
"flags": attr.string_list(doc = "Flags controlling the FuseSOC system build"),
"output_groups": attr.string_list_dict(
allow_empty = True,
doc = "Mapping of group name to lists of files in that named group",
doc = """
Mappings from output group names to lists of paths contained in
that group.

Paths to directories must have a trailing `/`. It is not
possible to output both a directory and a file from within that
directory.
""",
),
"verilator_options": attr.label(),
"make_options": attr.label(),
Expand Down
6 changes: 3 additions & 3 deletions third_party/lint/repos.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ def lint_repos(lowrisc_lint = None):
http_archive_or_local(
name = "lowrisc_lint",
local = lowrisc_lint,
sha256 = "1303d2790b7d1a0a216558c01f8bc6255dfb840e9e60b523d988b3655a0ddab3",
strip_prefix = "misc-linters-20240820_01",
url = "https:/lowRISC/misc-linters/archive/refs/tags/20240820_01.tar.gz",
sha256 = "365fe67d8168fee1a0fc3aea4bb80588bf721dc4fc83b40463b09eb50897cda3",
strip_prefix = "misc-linters-20240823_01",
url = "https:/lowRISC/misc-linters/archive/refs/tags/20240823_01.tar.gz",
)
7 changes: 7 additions & 0 deletions third_party/rust/deps.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
load("@rules_rust//bindgen:repositories.bzl", "rust_bindgen_dependencies")
load("@rules_rust//rust:repositories.bzl", "rules_rust_dependencies", "rust_register_toolchains", "rust_repository_set")
load("@rules_rust//tools/rust_analyzer:deps.bzl", "rust_analyzer_dependencies")
load("@rules_rust//util/import:deps.bzl", "import_deps")

def rust_deps():
rules_rust_dependencies()
Expand All @@ -25,3 +26,9 @@ def rust_deps():
)

rust_analyzer_dependencies()

# We're not using this feature, but have to load the deps in Bazel 7 due to
# https:/bazelbuild/rules_rust/issues/1166#issuecomment-1060888166
#
# This is no longer needed for `rules_rust>=0.38.0`.
import_deps()
20 changes: 10 additions & 10 deletions util/prep-bazel-airgapped-build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -114,16 +114,16 @@ if [[ ${AIRGAPPED_DIR_CONTENTS} == "ALL" || \
https:/bazelbuild/bazel/releases/download/${BAZEL_VERSION}/bazel-${BAZEL_VERSION}-linux-x86_64 \
--output bazel
chmod +x bazel
git clone -b "${BAZEL_VERSION}" --depth 1 https:/bazelbuild/bazel bazel-repo
cd bazel-repo
echo "Cloned bazel repo @ \"${BAZEL_VERSION}\" (commit $(git rev-parse HEAD))"
../bazel build @additional_distfiles//:archives.tar
tar xvf bazel-bin/external/additional_distfiles/archives.tar \
-C "../${BAZEL_DISTDIR}" \
--strip-components=3
cd ..
rm -rf bazel-repo
echo "Done."

# Make Bazel sync its own dependencies to the repository cache:
# https://bazel.build/run/build#repository_cache_with_bazel_7_or_later
mkdir -p "${BAZEL_AIRGAPPED_DIR}/empty_workspace"
pushd "${BAZEL_AIRGAPPED_DIR}/empty_workspace"
touch MODULE.bazel
touch WORKSPACE
bazel sync --repository_cache="${BAZEL_AIRGAPPED_DIR}/${BAZEL_CACHEDIR}"
popd
rm -rf "${BAZEL_AIRGAPPED_DIR}/empty_workspace"
fi

################################################################################
Expand Down
Loading