diff --git a/.bazelrc b/.bazelrc index 140d38715..b0e64f9d9 100644 --- a/.bazelrc +++ b/.bazelrc @@ -1,3 +1,6 @@ +# bazel < 7 needs explicit enabling of bzlmod dependencies. +build --enable_bzlmod + # Enable support for absl types like string_view in gtest. build --define="absl=1" @@ -26,6 +29,17 @@ common:macos --features=-supports_dynamic_linker --linkopt=-framework --linkopt= # Since we use designated initializers (C99 ... but >= c++20), compiler really wants the c++20 mode common:windows --compiler=clang-cl --cxxopt=/std:c++20 --host_cxxopt=/std:c++20 --client_env=BAZEL_CXXOPTS=/std:c++20 +build --cxxopt="-Wno-unknown-warning-option" --host_cxxopt="-Wno-unknown-warning-option" +# TODO: this looks like benign where it happens but to be explored further +build --cxxopt="-Wno-dangling-reference" --host_cxxopt="-Wno-dangling-reference" +# Newer bisons create an unused label. +build --cxxopt="-Wno-unused-label" --host_cxxopt="-Wno-unused-label" + +# For 3rd party code: Disable warnings entirely. +# They are not actionable and just create noise. +build --per_file_copt=external/.*@-w +build --host_per_file_copt=external/.*@-w + # Address sanitizer settings. build:asan --strip=never build:asan --copt -fsanitize=address diff --git a/.github/bin/run-clang-format.sh b/.github/bin/run-clang-format.sh index 5d1f26225..6d45297a3 100755 --- a/.github/bin/run-clang-format.sh +++ b/.github/bin/run-clang-format.sh @@ -32,7 +32,7 @@ find . -name "*.h" -o -name "*.cc" \ # If we have buildifier installed, use that on BUILD files if command -v ${BUILDIFIER} >/dev/null; then echo "Run $(buildifier --version)" - ${BUILDIFIER} -lint=fix WORKSPACE MODULE.bazel $(find . -name BUILD -o -name "*.bzl") + ${BUILDIFIER} -lint=fix MODULE.bazel $(find . -name BUILD -o -name "*.bzl") fi # Check if we got any diff diff --git a/.github/settings.sh b/.github/settings.sh index 80cb80c99..4601e2393 100644 --- a/.github/settings.sh +++ b/.github/settings.sh @@ -32,7 +32,7 @@ export BAZEL_CXXOPTS="-std=c++17" export BAZEL_OPTS="-c opt --noshow_progress" # Used to fetch the BAZEL version where needed. -export BAZEL_VERSION=5.4.1 +export BAZEL_VERSION=6.5.0 # Kythe version for extracting xRefs export KYTHE_VERSION=v0.0.52 diff --git a/.github/workflows/verible-ci.yml b/.github/workflows/verible-ci.yml index dbfb3cf2a..21ab15034 100644 --- a/.github/workflows/verible-ci.yml +++ b/.github/workflows/verible-ci.yml @@ -103,20 +103,20 @@ jobs: path: | /root/.cache/clang-tidy /root/.cache/bazel - key: clang-tidy-${{ steps.cache_timestamp.outputs.time }} - restore-keys: clang-tidy- + key: clang-tidy2-${{ steps.cache_timestamp.outputs.time }} + restore-keys: clang-tidy2- - name: Build Project genrules run: | # Fetch all dependencies and run genrules for bant to see every file - # that makes it into the compile to build comile DB.f - bazel fetch ... + # that makes it into the compile to build comile DB. bazel build \ //verible/common/analysis:command-file-lexer \ //verible/verilog/parser:verilog-lex \ //verible/verilog/parser:verilog-y \ //verible/verilog/parser:verilog-y-final \ - //verible/common/analysis:command-file-lexer_test + //verible/common/analysis:command-file-lexer_test \ + //verible/common/lsp:lsp-text-buffer bazel build $(bin/bant -q genrule-outputs | awk '{print $2}') \ $(bin/bant list-targets | grep cc_proto_library | awk '{print $3}') @@ -164,7 +164,6 @@ jobs: run: | # Fetch all dependencies and run genrules for bant to see every file # that makes it into the compile. Use bant itself to find genrules. - bazel fetch ... bazel build $(bin/bant -q genrule-outputs | awk '{print $2}') \ //verible/common/analysis:command-file-lexer \ //verible/verilog/parser:verilog-lex \ @@ -195,7 +194,6 @@ jobs: - compile-clang - compile-static - compile-static-clang - - coverage - clean arch: - x86_64 @@ -211,8 +209,6 @@ jobs: arch: arm64 - mode: asan-clang arch: arm64 - - mode: coverage - arch: arm64 env: MODE: ${{ matrix.mode }} ARCH: ${{ matrix.arch }} @@ -238,8 +234,8 @@ jobs: if: matrix.mode != 'clean' && matrix.mode != 'coverage' with: path: "/root/.cache/bazel" - key: bazelcache3_${{ matrix.arch }}_${{ matrix.mode }}_${{ steps.cache_timestamp.outputs.time }} - restore-keys: bazelcache3_${{ matrix.arch }}_${{ matrix.mode }}_ + key: bazelcache_${{ matrix.arch }}_${{ matrix.mode }}_${{ steps.cache_timestamp.outputs.time }} + restore-keys: bazelcache_${{ matrix.arch }}_${{ matrix.mode }}_ - name: Install Dependencies run: | @@ -274,15 +270,6 @@ jobs: - name: ${{ matrix.mode }} Verible run: ./.github/bin/build-and-test.sh - - name: Upload coverage - # will show up under https://app.codecov.io/gh/chipsalliance/verible - if: matrix.mode == 'coverage' - uses: codecov/codecov-action@v2 - with: - files: bazel-out/_coverage/_coverage_report.dat - verbose: true - continue-on-error: true - - name: Gather and pack binaries if: matrix.mode == 'compile' && matrix.arch == 'x86_64' run: | @@ -397,8 +384,8 @@ jobs: with: path: | /private/var/tmp/_bazel_runner - key: bazelcache_macos_${{ steps.cache_timestamp.outputs.time }} - restore-keys: bazelcache_macos_ + key: bazelcache_macos1_${{ steps.cache_timestamp.outputs.time }} + restore-keys: bazelcache_macos1_ - name: Tests # MacOS has a broken patch utility: @@ -451,14 +438,14 @@ jobs: uses: actions/cache@v3 with: path: "c:/users/runneradmin/_bazel_runneradmin" - key: bazelcache_windows_${{ steps.cache_timestamp.outputs.time }} - restore-keys: bazelcache_windows_ + key: bazelcache_windows3_${{ steps.cache_timestamp.outputs.time }} + restore-keys: bazelcache_windows3_ - name: Install dependencies run: | - choco install bazel --force --version=6.4.0 + choco install bazel --force --version=6.5.0 choco install winflexbison3 - choco install llvm --allow-downgrade --version=16.0.6 + choco install llvm --allow-downgrade --version=17.0.6 - name: Debug bazel directory settings # We need to explicitly call the bazel binary from choco, otherwise diff --git a/MODULE.bazel b/MODULE.bazel index cf7da38b2..6850ea4f2 100644 --- a/MODULE.bazel +++ b/MODULE.bazel @@ -2,13 +2,14 @@ module( name = "verible", ) -bazel_dep(name = "platforms", version = "0.0.8") -bazel_dep(name = "bazel_skylib", version = "1.5.0") -bazel_dep(name = "rules_license", version = "0.0.8") -bazel_dep(name = "rules_proto", version = "6.0.0-rc2") -bazel_dep(name = "rules_cc", version = "0.0.9") +bazel_dep(name = "platforms", version = "0.0.10") +bazel_dep(name = "bazel_skylib", version = "1.7.1") +bazel_dep(name = "rules_license", version = "1.0.0") +bazel_dep(name = "nlohmann_json", version = "3.11.3.bcr.1", repo_name = "jsonhpp") +bazel_dep(name = "re2", version = "2024-07-02.bcr.1", repo_name = "com_googlesource_code_re2") +bazel_dep(name = "zlib", version = "1.3.1.bcr.3") -# Register m4 rules and toolchain. +# Register m4/flex/bison rules and toolchains bazel_dep(name = "rules_m4", version = "0.2.3") m4 = use_extension( @@ -24,23 +25,6 @@ use_repo(m4, "m4") register_toolchains("@m4//:toolchain") -# Register bison rules and toolchain. -bazel_dep(name = "rules_bison", version = "0.3") - -bison = use_extension( - "@rules_bison//bison/extensions:bison_repository_ext.bzl", - "bison_repository_ext", -) -bison.repository( - name = "bison", - extra_copts = ["-O3"], - version = "3.3.2", -) -use_repo(bison, "bison") - -register_toolchains("@bison//:toolchain") - -# Register flex rules and toolchain. bazel_dep(name = "rules_flex", version = "0.3") flex = use_extension( @@ -56,9 +40,25 @@ use_repo(flex, "flex") register_toolchains("@flex//:toolchain") +bazel_dep(name = "rules_bison", version = "0.3") + +bison = use_extension( + "@rules_bison//bison/extensions:bison_repository_ext.bzl", + "bison_repository_ext", +) +bison.repository( + name = "bison", + extra_copts = ["-O3"], + version = "3.3.2", +) +use_repo(bison, "bison") + +register_toolchains("@bison//:toolchain") + # abseil-cpp and googletest can not be updated beyond the following currently, # as newer googletest is not compatible with bazel 6 anymore, and abseil-cpp -# depends on it :( -- to support all active bazel's, we're stuck till Dec 2025. +# depends on it :( -- to support all active bazel's, we're stuck till EOL bazel6 +bazel_dep(name = "googletest", version = "1.14.0.bcr.1", repo_name = "com_google_googletest") bazel_dep(name = "abseil-cpp", version = "20240116.2", repo_name = "com_google_absl") single_version_override( module_name = "abseil-cpp", @@ -67,8 +67,10 @@ single_version_override( version = "20240116.2", ) -bazel_dep(name = "googletest", version = "1.14.0.bcr.1", repo_name = "com_google_googletest") -bazel_dep(name = "nlohmann_json", version = "3.11.3.bcr.1", repo_name = "jsonhpp") -bazel_dep(name = "protobuf", version = "26.0", repo_name = "com_google_protobuf") -bazel_dep(name = "re2", version = "2023-09-01", repo_name = "com_googlesource_code_re2") -bazel_dep(name = "zlib", version = "1.3.1") +# Last protobuf version working with windows without strange linking errors. +# This also means that we unfortunately can't use the @protobuf//bazel rules +# but have to use rules_cc and rules_proto. +# TODO: figure out how we can make proto compile beyond 24.4 on Windows. +bazel_dep(name = "protobuf", version = "24.4", repo_name = "com_google_protobuf") +bazel_dep(name = "rules_cc", version = "0.0.9") +bazel_dep(name = "rules_proto", version = "6.0.0-rc2") diff --git a/README.md b/README.md index 743236f51..ca9b40e0a 100644 --- a/README.md +++ b/README.md @@ -183,7 +183,7 @@ the nix package manager simply run `nix-shell` to get a build environment. ```bash # Build all tools and libraries -# bazel 5/6/7 +# bazel 6/7/8 bazel build -c opt //... ``` diff --git a/WORKSPACE b/WORKSPACE deleted file mode 100644 index 6861e035c..000000000 --- a/WORKSPACE +++ /dev/null @@ -1,157 +0,0 @@ -workspace(name = "com_google_verible") - -load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") - -http_archive( - name = "rules_license", - sha256 = "6157e1e68378532d0241ecd15d3c45f6e5cfd98fc10846045509fb2a7cc9e381", - urls = [ - "https://github.com/bazelbuild/rules_license/releases/download/0.0.4/rules_license-0.0.4.tar.gz", - "https://mirror.bazel.build/github.com/bazelbuild/rules_license/releases/download/0.0.4/rules_license-0.0.4.tar.gz", - ], -) - -# Bazel platform rules, needed as dependency to absl. -http_archive( - name = "platforms", - sha256 = "8150406605389ececb6da07cbcb509d5637a3ab9a24bc69b1101531367d89d74", - urls = [ - "https://mirror.bazel.build/github.com/bazelbuild/platforms/releases/download/0.0.8/platforms-0.0.8.tar.gz", - "https://github.com/bazelbuild/platforms/releases/download/0.0.8/platforms-0.0.8.tar.gz", - ], -) - -http_archive( - name = "bazel_skylib", - sha256 = "74d544d96f4a5bb630d465ca8bbcfe231e3594e5aae57e1edbf17a6eb3ca2506", - urls = [ - "https://mirror.bazel.build/github.com/bazelbuild/bazel-skylib/releases/download/1.3.0/bazel-skylib-1.3.0.tar.gz", - "https://github.com/bazelbuild/bazel-skylib/releases/download/1.3.0/bazel-skylib-1.3.0.tar.gz", - ], -) - -load("@bazel_skylib//:workspace.bzl", "bazel_skylib_workspace") - -bazel_skylib_workspace() - -http_archive( - name = "com_google_absl", - # On MSVC's STL implementation, string_view cannot be constructed from - # a string_view::iterator. This patch forces the use of absl's string_view - # implementation to solve the issue - patch_args = ["-p1"], - patches = [ - "//bazel:absl.patch", - ], - sha256 = "338420448b140f0dfd1a1ea3c3ce71b3bc172071f24f4d9a57d59b45037da440", - strip_prefix = "abseil-cpp-20240116.0", - urls = ["https://github.com/abseil/abseil-cpp/archive/refs/tags/20240116.0.tar.gz"], -) - -http_archive( - name = "com_googlesource_code_re2", - sha256 = "8b4a8175da7205df2ad02e405a950a02eaa3e3e0840947cd598e92dca453199b", - strip_prefix = "re2-2023-06-01", - urls = ["https://github.com/google/re2/archive/refs/tags/2023-06-01.tar.gz"], -) - -http_archive( - name = "com_google_googletest", - sha256 = "1f357c27ca988c3f7c6b4bf68a9395005ac6761f034046e9dde0896e3aba00e4", - strip_prefix = "googletest-1.14.0", - urls = ["https://github.com/google/googletest/archive/refs/tags/v1.14.0.zip"], -) - -http_archive( - name = "rules_cc", - sha256 = "69fb4b965c538509324960817965791761d57010f42bf12ce9769c4259c7d018", - strip_prefix = "rules_cc-e7c97c3af74e279a5db516a19f642e862ff58548", - urls = ["https://github.com/bazelbuild/rules_cc/archive/e7c97c3af74e279a5db516a19f642e862ff58548.zip"], -) - -# -# External tools needed -# - -http_archive( - name = "rules_m4", - sha256 = "10ce41f150ccfbfddc9d2394ee680eb984dc8a3dfea613afd013cfb22ea7445c", - urls = ["https://github.com/jmillikin/rules_m4/releases/download/v0.2.3/rules_m4-v0.2.3.tar.xz"], -) - -load("@rules_m4//m4:m4.bzl", "m4_register_toolchains") - -m4_register_toolchains(version = "1.4.18") - -http_archive( - name = "rules_flex", - sha256 = "99393873d4a1bce44853f1cf0c48a34640583cee3d06f2d3d439e12fb1529036", - # flex 2.6.4 - urls = ["https://github.com/jmillikin/rules_flex/releases/download/v0.3/rules_flex-v0.3.tar.xz"], -) - -load("@rules_flex//flex:flex.bzl", "flex_register_toolchains") - -flex_register_toolchains(version = "2.6.4") - -http_archive( - name = "rules_bison", - sha256 = "9577455967bfcf52f9167274063ebb74696cb0fd576e4226e14ed23c5d67a693", - urls = ["https://github.com/jmillikin/rules_bison/releases/download/v0.2.1/rules_bison-v0.2.1.tar.xz"], -) - -load("@rules_bison//bison:bison.bzl", "bison_register_toolchains") - -bison_register_toolchains(version = "3.3.2") - -# We, but also protobuf needs zlib. Make sure we define it first. -http_archive( - name = "zlib", - build_file = "//bazel:zlib.BUILD", - sha256 = "9a93b2b7dfdac77ceba5a558a580e74667dd6fede4585b91eefb60f03b72df23", - strip_prefix = "zlib-1.3.1", - urls = [ - "https://zlib.net/zlib-1.3.1.tar.gz", - "https://zlib.net/fossils/zlib-1.3.1.tar.gz", - ], -) - -http_archive( - name = "com_google_protobuf", - patch_args = ["-p1"], - patches = [ - "//bazel:proto-fix-uninitialized-value.patch", - ], - sha256 = "8ff511a64fc46ee792d3fe49a5a1bcad6f7dc50dfbba5a28b0e5b979c17f9871", - strip_prefix = "protobuf-25.2", - urls = [ - "https://github.com/protocolbuffers/protobuf/releases/download/v25.2/protobuf-25.2.tar.gz", - ], -) - -load("@com_google_protobuf//:protobuf_deps.bzl", "protobuf_deps") - -protobuf_deps() - -http_archive( - name = "rules_proto", - sha256 = "dc3fb206a2cb3441b485eb1e423165b231235a1ea9b031b4433cf7bc1fa460dd", - strip_prefix = "rules_proto-5.3.0-21.7", - urls = [ - "https://github.com/bazelbuild/rules_proto/archive/refs/tags/5.3.0-21.7.tar.gz", - ], -) - -load("@rules_proto//proto:repositories.bzl", "rules_proto_dependencies") - -rules_proto_dependencies() - -http_archive( - name = "jsonhpp", - build_file = "//bazel:jsonhpp.BUILD", - sha256 = "0d8ef5af7f9794e3263480193c491549b2ba6cc74bb018906202ada498a79406", - strip_prefix = "json-3.11.3", - urls = [ - "https://github.com/nlohmann/json/archive/refs/tags/v3.11.3.tar.gz", - ], -) diff --git a/WORKSPACE.bzlmod b/WORKSPACE.bzlmod deleted file mode 100644 index e69de29bb..000000000 diff --git a/bazel/zlib.BUILD b/bazel/zlib.BUILD deleted file mode 100644 index 197650f41..000000000 --- a/bazel/zlib.BUILD +++ /dev/null @@ -1,73 +0,0 @@ -load("@rules_cc//cc:defs.bzl", "cc_library") - -licenses(["notice"]) # BSD/MIT-like license (for zlib) - -exports_files(["zlib.BUILD"]) - -_ZLIB_HEADERS = [ - "crc32.h", - "deflate.h", - "gzguts.h", - "inffast.h", - "inffixed.h", - "inflate.h", - "inftrees.h", - "trees.h", - "zconf.h", - "zlib.h", - "zutil.h", -] - -_ZLIB_PREFIXED_HEADERS = ["zlib/include/" + hdr for hdr in _ZLIB_HEADERS] - -# In order to limit the damage from the `includes` propagation -# via `:zlib`, copy the public headers to a subdirectory and -# expose those. -genrule( - name = "copy_public_headers", - srcs = _ZLIB_HEADERS, - outs = _ZLIB_PREFIXED_HEADERS, - cmd_bash = "cp $(SRCS) $(@D)/zlib/include/", - cmd_bat = " && ".join( - ["@copy /Y $(location %s) $(@D)\\zlib\\include\\ >NUL" % - s for s in _ZLIB_HEADERS], - ), -) - -cc_library( - name = "zlib", - srcs = [ - "adler32.c", - "compress.c", - "crc32.c", - "deflate.c", - "gzclose.c", - "gzlib.c", - "gzread.c", - "gzwrite.c", - "infback.c", - "inffast.c", - "inflate.c", - "inftrees.c", - "trees.c", - "uncompr.c", - "zutil.c", - # Include the un-prefixed headers in srcs to work - # around the fact that zlib isn't consistent in its - # choice of <> or "" delimiter when including itself. - ] + _ZLIB_HEADERS, - hdrs = [ # _ZLIB_PREFIXED_HEADERS, but we only need a few. - "zlib/include/zconf.h", - "zlib/include/zlib.h", - ], - copts = select({ - "@bazel_tools//src/conditions:windows": [], - "//conditions:default": [ - "-Wno-deprecated-non-prototype", - "-Wno-unused-variable", - "-Wno-implicit-function-declaration", - ], - }), - includes = ["zlib/include/"], - visibility = ["//visibility:public"], -) diff --git a/third_party/proto/kythe/BUILD b/third_party/proto/kythe/BUILD index 0df5ac3fa..f2e9e553e 100644 --- a/third_party/proto/kythe/BUILD +++ b/third_party/proto/kythe/BUILD @@ -1,3 +1,5 @@ +# Unfortunately, can't use @com_google_protobuf//bazel:cc_proto_library.bzl +# here, as this does not seem to work with windows. load("@rules_cc//cc:defs.bzl", "cc_proto_library") load("@rules_proto//proto:defs.bzl", "proto_library")