diff --git a/.bazelrc b/.bazelrc index 37001e8f54f08..14cda5a03e7f1 100644 --- a/.bazelrc +++ b/.bazelrc @@ -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' @@ -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. diff --git a/.bazelversion b/.bazelversion index 024b066c0bb7a..643916c03f1f6 100644 --- a/.bazelversion +++ b/.bazelversion @@ -1 +1 @@ -6.2.1 +7.3.1 diff --git a/hw/bitstream/vivado/BUILD b/hw/bitstream/vivado/BUILD index 398fcd5e542da..05cbb01217928 100644 --- a/hw/bitstream/vivado/BUILD +++ b/hw/bitstream/vivado/BUILD @@ -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"], @@ -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"], @@ -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"], diff --git a/rules/fusesoc.bzl b/rules/fusesoc.bzl index 8ad8e88474a84..2d40d7c439699 100644 --- a/rules/fusesoc.bzl +++ b/rules/fusesoc.bzl @@ -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 = [] 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) @@ -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) @@ -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) @@ -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(), diff --git a/third_party/lint/repos.bzl b/third_party/lint/repos.bzl index ea956aeca97cf..c9ee86276b75d 100644 --- a/third_party/lint/repos.bzl +++ b/third_party/lint/repos.bzl @@ -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://github.com/lowRISC/misc-linters/archive/refs/tags/20240820_01.tar.gz", + sha256 = "365fe67d8168fee1a0fc3aea4bb80588bf721dc4fc83b40463b09eb50897cda3", + strip_prefix = "misc-linters-20240823_01", + url = "https://github.com/lowRISC/misc-linters/archive/refs/tags/20240823_01.tar.gz", ) diff --git a/third_party/rust/deps.bzl b/third_party/rust/deps.bzl index ea5dba2a2e891..0196684568159 100644 --- a/third_party/rust/deps.bzl +++ b/third_party/rust/deps.bzl @@ -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() @@ -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://github.com/bazelbuild/rules_rust/issues/1166#issuecomment-1060888166 + # + # This is no longer needed for `rules_rust>=0.38.0`. + import_deps() diff --git a/util/prep-bazel-airgapped-build.sh b/util/prep-bazel-airgapped-build.sh index f1b02543059e8..1462e17709929 100755 --- a/util/prep-bazel-airgapped-build.sh +++ b/util/prep-bazel-airgapped-build.sh @@ -114,16 +114,16 @@ if [[ ${AIRGAPPED_DIR_CONTENTS} == "ALL" || \ https://github.com/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://github.com/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 ################################################################################