From 5fd46c1aca5f8e447accbacf36771d15faa59215 Mon Sep 17 00:00:00 2001 From: Henner Zeller Date: Wed, 28 Aug 2024 09:24:46 -0700 Subject: [PATCH] First step towards using bzlmod * Move projects that are available already in https://registry.bazel.build/ from from load_external to MODULE.bazel. * This is not complete: there are probably more steps to simplify and clean-up after the first submit. * Switching to bzlmod broke making the compilation-db as the action hooks don't seem to work anymore ( xls/dev_tools//make-compilation-db.sh ). The used com_grail_bazel_compdb is not maintained anymore, so this needs to be updated to something more modern (hedronvision?). Since this is not actively needed in daily development (and I am the only one really using it), postponed for later. * Clean out things not needed anymore in dependency_support/$(various-dirs) Issues: #931 Also, needed to make Python rules to work well with --incompatible_default_to_explicit_init_py (bazelbuild/bazel#10076) --- .bazelrc | 8 +- .gitignore | 1 + MODULE.bazel | 38 ++++ WORKSPACE | 50 +---- .../0001-Add-absl-status-to-deps.patch | 24 --- .../com_github_grpc_grpc/BUILD.bazel | 15 -- .../com_google_absl/BUILD.bazel | 15 -- .../com_google_benchmark/BUILD.bazel | 15 -- .../com_grail_bazel_toolchain/BUILD.bazel | 15 -- dependency_support/initialize_external.bzl | 10 +- dependency_support/load_external.bzl | 204 +++--------------- dependency_support/pybind11_bazel/BUILD.bazel | 15 -- .../pybind11_bazel/sysconfig_fix.patch | 15 -- dependency_support/zlib/BUILD.bazel | 15 -- dependency_support/zlib/bundled.BUILD.bazel | 74 ------- xls/dev_tools/make-compilation-db.sh | 23 +- 16 files changed, 77 insertions(+), 460 deletions(-) create mode 100644 MODULE.bazel delete mode 100644 dependency_support/com_github_grpc_grpc/0001-Add-absl-status-to-deps.patch delete mode 100644 dependency_support/com_github_grpc_grpc/BUILD.bazel delete mode 100644 dependency_support/com_google_absl/BUILD.bazel delete mode 100644 dependency_support/com_google_benchmark/BUILD.bazel delete mode 100644 dependency_support/com_grail_bazel_toolchain/BUILD.bazel delete mode 100644 dependency_support/pybind11_bazel/BUILD.bazel delete mode 100644 dependency_support/pybind11_bazel/sysconfig_fix.patch delete mode 100644 dependency_support/zlib/BUILD.bazel delete mode 100755 dependency_support/zlib/bundled.BUILD.bazel diff --git a/.bazelrc b/.bazelrc index e64a31d8a8..5929a4f9d5 100644 --- a/.bazelrc +++ b/.bazelrc @@ -1,10 +1,14 @@ -# We use bazel >= 6, but no bzlmod yet. -common --noenable_bzlmod +common --enable_bzlmod # Disable rules_python Starlark rules for Bazel 7+. # See https://github.com/bazelbuild/rules_python/issues/1069#issuecomment-1942053014. build --action_env=RULES_PYTHON_ENABLE_PYSTAR=0 +# Disable automatic generation of __init__.py files. This allows +# namespace packages (such as `google`) to work correctly. +# https://github.com/bazelbuild/bazel/issues/10076 +build --incompatible_default_to_explicit_init_py=true + # Minimium c++ standard used. build --cxxopt "-std=c++20" --host_cxxopt "-std=c++20" build --action_env=BAZEL_CXXOPTS=-std=c++20 diff --git a/.gitignore b/.gitignore index 8cf3233933..abddb29368 100644 --- a/.gitignore +++ b/.gitignore @@ -7,3 +7,4 @@ xls_clang-tidy.out user.bazelrc .vscode .cache +MODULE.bazel.lock diff --git a/MODULE.bazel b/MODULE.bazel new file mode 100644 index 0000000000..a06dbb3cf7 --- /dev/null +++ b/MODULE.bazel @@ -0,0 +1,38 @@ +module( + name = "xls", + repo_name = "com_google_xls", +) + +# Compiler toolchain +bazel_dep(name = "toolchains_llvm", version = "1.1.2") + +# Configure and register the toolchain. +llvm = use_extension("@toolchains_llvm//toolchain/extensions:llvm.bzl", "llvm") +llvm.toolchain( + llvm_version = "17.0.6", +) +use_repo(llvm, "llvm_toolchain") + +register_toolchains("@llvm_toolchain//:all") + +# +bazel_dep(name = "abseil-cpp", version = "20240116.2", repo_name = "com_google_absl") +bazel_dep(name = "abseil-py", version = "2.1.0", repo_name = "com_google_absl_py") +bazel_dep(name = "bazel_skylib", version = "1.7.1") +bazel_dep(name = "boringssl", version = "0.0.0-20240530-2db0eb3") +bazel_dep(name = "google_benchmark", version = "1.8.5", repo_name = "com_google_benchmark") +bazel_dep(name = "googleapis", version = "0.0.0-20240326-1c8d509c5", repo_name = "com_google_googleapis") +bazel_dep(name = "googletest", version = "1.15.2", repo_name = "com_google_googletest") +bazel_dep(name = "grpc", version = "1.66.0", repo_name = "com_github_grpc_grpc") +bazel_dep(name = "nlohmann_json", version = "3.11.3", repo_name = "jsonhpp") +bazel_dep(name = "protobuf", version = "28.0-rc2", repo_name = "com_google_protobuf") +bazel_dep(name = "re2", version = "2024-07-02", repo_name = "com_googlesource_code_re2") +bazel_dep(name = "riegeli", version = "0.0.0-20240606-973b6f0", repo_name = "com_google_riegeli") +bazel_dep(name = "rules_cc", version = "0.0.9") +bazel_dep(name = "rules_license", version = "0.0.8") +bazel_dep(name = "rules_pkg", version = "1.0.1") + +# Not all external projects we directly need are available yet. +# This how to find what we use for further work on this file: +# find xls -name BUILD -o -name "*.bzl" | xargs sed 's/.*"\(@[_a-z0-9]*\).*/\1/p;d' | sort -u +# Once added here, remove from the {load,initialize}_external.bzl. diff --git a/WORKSPACE b/WORKSPACE index 595ce818c8..16abfe55f1 100644 --- a/WORKSPACE +++ b/WORKSPACE @@ -12,46 +12,12 @@ # See the License for the specific language governing permissions and # limitations under the License. +# TODO(#931): Everything here should go away and migrate to MODULE.bazel + workspace(name = "com_google_xls") -# Load and configure a hermetic LLVM based C/C++ toolchain. This is done here -# and not in load_external.bzl because it requires several sequential steps of -# declaring archives and using things in them, which is awkward to do in .bzl -# files because it's not allowed to use `load` inside of a function. load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") -# Released 2023-09-20, current as of 2024-06-26 (but there is already a 0.0.10rc1) -# Needs to be loaded first, as llvm toolchain has an ancient version of this. -http_archive( - name = "rules_cc", - urls = ["https://github.com/bazelbuild/rules_cc/releases/download/0.0.9/rules_cc-0.0.9.tar.gz"], - sha256 = "2037875b9a4456dce4a79d112a8ae885bbc4aad968e6587dca6e64f3a0900cdf", - strip_prefix = "rules_cc-0.0.9", -) - -# Commit on 2024-07-19, current as of 2024-07-21. -http_archive( - name = "toolchains_llvm", - integrity = "sha256-RVp0bZsDrelQAtxswWOLB4j8zCXQy/cSe1m3wL/E2PU=", - strip_prefix = "toolchains_llvm-01132cfdae7d7187a885cf79d5a3ac1ed8a02e5a", - url = "https://github.com/bazel-contrib/toolchains_llvm/archive/01132cfdae7d7187a885cf79d5a3ac1ed8a02e5a.tar.gz", -) - -load("@toolchains_llvm//toolchain:deps.bzl", "bazel_toolchain_dependencies") - -bazel_toolchain_dependencies() - -load("@toolchains_llvm//toolchain:rules.bzl", "llvm_toolchain") - -llvm_toolchain( - name = "llvm_toolchain", - llvm_version = "17.0.6", -) - -load("@llvm_toolchain//:toolchains.bzl", "llvm_register_toolchains") - -llvm_register_toolchains() - load("//dependency_support:load_external.bzl", "load_external_repositories") load_external_repositories() @@ -75,12 +41,6 @@ python_register_toolchains( ignore_root_user_error = True, ) -# gRPC deps should be loaded before initializing other repos. Otherwise, various -# errors occur during repo loading and initialization. -load("@com_github_grpc_grpc//bazel:grpc_deps.bzl", "grpc_deps") - -grpc_deps() - load("//dependency_support:initialize_external.bzl", "initialize_external_repositories") initialize_external_repositories() @@ -88,9 +48,3 @@ initialize_external_repositories() load("@xls_pip_deps//:requirements.bzl", xls_pip_install_deps = "install_deps") xls_pip_install_deps() - -# Loading the extra deps must be called after initialize_eternal_repositories or -# the call to pip_parse fails. -load("@com_github_grpc_grpc//bazel:grpc_extra_deps.bzl", "grpc_extra_deps") - -grpc_extra_deps() diff --git a/dependency_support/com_github_grpc_grpc/0001-Add-absl-status-to-deps.patch b/dependency_support/com_github_grpc_grpc/0001-Add-absl-status-to-deps.patch deleted file mode 100644 index a83a80d46e..0000000000 --- a/dependency_support/com_github_grpc_grpc/0001-Add-absl-status-to-deps.patch +++ /dev/null @@ -1,24 +0,0 @@ -From 160a546da6ce0a76b160b57e6350f610ccf8b808 Mon Sep 17 00:00:00 2001 -From: Paul Rigge -Date: Mon, 22 Jul 2024 20:59:04 -0700 -Subject: [PATCH] Add absl:status to deps. - ---- - src/core/BUILD | 1 + - 1 file changed, 1 insertion(+) - -diff --git src/core/BUILD src/core/BUILD -index e76dc300ac..0688bb9dcc 100644 ---- src/core/BUILD -+++ src/core/BUILD -@@ -2563,6 +2563,7 @@ grpc_cc_library( - external_deps = [ - "absl/container:flat_hash_map", - "absl/log:check", -+ "absl/status", - "absl/strings", - "absl/strings:str_format", - ], --- -2.45.2 - diff --git a/dependency_support/com_github_grpc_grpc/BUILD.bazel b/dependency_support/com_github_grpc_grpc/BUILD.bazel deleted file mode 100644 index bde7573e93..0000000000 --- a/dependency_support/com_github_grpc_grpc/BUILD.bazel +++ /dev/null @@ -1,15 +0,0 @@ -# Copyright 2020 The XLS Authors -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -# Needed to make this a package. diff --git a/dependency_support/com_google_absl/BUILD.bazel b/dependency_support/com_google_absl/BUILD.bazel deleted file mode 100644 index a5bf9b8384..0000000000 --- a/dependency_support/com_google_absl/BUILD.bazel +++ /dev/null @@ -1,15 +0,0 @@ -# Copyright 2021 The XLS Authors -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -# Needed to make this a package. diff --git a/dependency_support/com_google_benchmark/BUILD.bazel b/dependency_support/com_google_benchmark/BUILD.bazel deleted file mode 100644 index a1f21e7338..0000000000 --- a/dependency_support/com_google_benchmark/BUILD.bazel +++ /dev/null @@ -1,15 +0,0 @@ -# Copyright 2022 The XLS Authors -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -# Needed to make this a package. diff --git a/dependency_support/com_grail_bazel_toolchain/BUILD.bazel b/dependency_support/com_grail_bazel_toolchain/BUILD.bazel deleted file mode 100644 index bde7573e93..0000000000 --- a/dependency_support/com_grail_bazel_toolchain/BUILD.bazel +++ /dev/null @@ -1,15 +0,0 @@ -# Copyright 2020 The XLS Authors -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -# Needed to make this a package. diff --git a/dependency_support/initialize_external.bzl b/dependency_support/initialize_external.bzl index e25f2ca8d1..480e4e4239 100644 --- a/dependency_support/initialize_external.bzl +++ b/dependency_support/initialize_external.bzl @@ -14,10 +14,10 @@ """Provides helper that initializes external repositories with third-party code.""" +# TODO(#931): with MODULE.bazel, probably some of these can be removed now, with the +# eventual goal that none of this is needed anymore and the file can be removed. + load("@bazel_skylib//:workspace.bzl", "bazel_skylib_workspace") -load("@com_google_benchmark//:bazel/benchmark_deps.bzl", "benchmark_deps") -load("@com_google_protobuf//:protobuf_deps.bzl", "protobuf_deps") -load("@com_grail_bazel_compdb//:deps.bzl", "bazel_compdb_deps") load("@io_bazel_rules_closure//closure:repositories.bzl", "rules_closure_dependencies", "rules_closure_toolchains") load("@project_python//:defs.bzl", python_interpreter_target = "interpreter") load("@rules_7zip//:setup.bzl", "setup_7zip") # needed by rules_hdl @@ -31,8 +31,6 @@ load("//dependency_support/llvm:initialize.bzl", initialize_llvm = "initialize") def initialize_external_repositories(): """Calls set-up methods for external repositories that require that.""" - bazel_skylib_workspace() - protobuf_deps() rules_hdl_init(python_interpreter_target = python_interpreter_target) rules_hdl_dependency_support() setup_7zip() @@ -48,6 +46,4 @@ def initialize_external_repositories(): ) initialize_boost() initialize_llvm() - bazel_compdb_deps() - benchmark_deps() rules_pkg_dependencies() diff --git a/dependency_support/load_external.bzl b/dependency_support/load_external.bzl index 8fde9b98ea..bd90a2adb3 100644 --- a/dependency_support/load_external.bzl +++ b/dependency_support/load_external.bzl @@ -1,5 +1,6 @@ # Copyright 2020 The XLS Authors # +# # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at @@ -14,6 +15,10 @@ """Provides helper that loads external repositories with third-party code.""" +# TODO(#931): all the remaining toplevel projects we need should move to MODULE.bazel, +# somewhat dependent on what becomes available in https://registry.bazel.build/. +# Eventual goal that none of this is needed anymore and the file can be removed. + load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") load("//dependency_support/boost:workspace.bzl", repo_boost = "repo") load("//dependency_support/llvm:workspace.bzl", repo_llvm = "repo") @@ -38,104 +43,6 @@ def load_external_repositories(): repo_llvm() repo_rules_hdl() - # Release 2024-01-22, current as of 2024-06-26 - # zlib is added automatically by gRPC, but the zlib BUILD file used by gRPC - # does not include all the source code (e.g., gzread is missing) which - # breaks other users of zlib like iverilog. So add zlib explicitly here with - # a working BUILD file. - # Needs to be early in this file to make sure this is the version - # picked -- Version 1.3.x fixes function prototype warnings in c++20. - http_archive( - name = "zlib", - sha256 = "50b24b47bf19e1f35d2a21ff36d2a366638cdf958219a66f30ce0861201760e6", - strip_prefix = "zlib-1.3.1", - urls = [ - "https://github.com/madler/zlib/archive/v1.3.1.zip", - ], - build_file = "//dependency_support/zlib:bundled.BUILD.bazel", - ) - - # V 1.14.0 (released 2023-08-02, current as of 2024-06-26) - http_archive( - name = "com_google_googletest", - urls = ["https://github.com/google/googletest/archive/refs/tags/v1.14.0.zip"], - strip_prefix = "googletest-1.14.0", - sha256 = "1f357c27ca988c3f7c6b4bf68a9395005ac6761f034046e9dde0896e3aba00e4", - ) - - # LTS 20240116.2 (released 2024-04-08, current as of 2024-06-26) - http_archive( - name = "com_google_absl", - urls = ["https://github.com/abseil/abseil-cpp/archive/refs/tags/20240116.2.tar.gz"], - strip_prefix = "abseil-cpp-20240116.2", - sha256 = "733726b8c3a6d39a4120d7e45ea8b41a434cdacde401cba500f14236c49b39dc", - ) - - # Released 2024-06-03, current as of 2024-06-26 - # Protobuf depends on Skylib - # Load bazel skylib as per - # https://github.com/bazelbuild/bazel-skylib/releases - http_archive( - name = "bazel_skylib", - urls = [ - "https://github.com/bazelbuild/bazel-skylib/releases/download/1.7.1/bazel-skylib-1.7.1.tar.gz", - ], - sha256 = "bc283cdfcd526a52c3201279cda4bc298652efa898b10b4db0837dc51652756f", - ) - - http_archive( - name = "boringssl", - # Commit date: 2024-06-24 - # Note for updating: we need to use a commit from the main-with-bazel branch. - strip_prefix = "boringssl-e6b03733628149a89a1d18b3ef8f39aa1055aba8", - sha256 = "006596f84d9cc142d9d6c48600cf6208f9d24426943b05e8bcda06e523f69dc8", - urls = ["https://github.com/google/boringssl/archive/e6b03733628149a89a1d18b3ef8f39aa1055aba8.tar.gz"], - ) - - # Commit on 2023-02-09 - http_archive( - name = "pybind11_bazel", - strip_prefix = "pybind11_bazel-fc56ce8a8b51e3dd941139d329b63ccfea1d304b", - urls = ["https://github.com/pybind/pybind11_bazel/archive/fc56ce8a8b51e3dd941139d329b63ccfea1d304b.tar.gz"], - sha256 = "150e2105f9243c445d48f3820b5e4e828ba16c41f91ab424deae1fa81d2d7ac6", - ) - - http_archive( - name = "six_archive", - build_file_content = """py_library( - name = "six", - visibility = ["//visibility:public"], - srcs = glob(["*.py"]) - )""", - sha256 = "105f8d68616f8248e24bf0e9372ef04d3cc10104f1980f54d57b2ce73a5ad56a", - strip_prefix = "six-1.10.0", - urls = [ - "https://mirror.bazel.build/pypi.python.org/packages/source/s/six/six-1.10.0.tar.gz", - "https://pypi.python.org/packages/source/s/six/six-1.10.0.tar.gz", - ], - ) - - # Version release tag 2023-01-11 - http_archive( - name = "com_google_absl_py", - strip_prefix = "abseil-py-1.4.0", - urls = ["https://github.com/abseil/abseil-py/archive/refs/tags/v1.4.0.tar.gz"], - sha256 = "0fb3a4916a157eb48124ef309231cecdfdd96ff54adf1660b39c0d4a9790a2c0", - ) - - # Released on 2024-06-01, current as of 2024-06-26 - http_archive( - name = "com_googlesource_code_re2", - strip_prefix = "re2-2024-06-01", - sha256 = "7326c74cddaa90b12090fcfc915fe7b4655723893c960ee3c2c66e85c5504b6c", - urls = [ - "https://github.com/google/re2/archive/refs/tags/2024-06-01.tar.gz", - ], - repo_mapping = { - "@abseil-cpp": "@com_google_absl", - }, - ) - # Released on 2022-12-27. # Current as of 2024-06-26 would be 6.0.2, but that does not work yet # with rules_hdl (it assumes rules_proto_toolchains is in repositories.bzl) @@ -184,14 +91,6 @@ def load_external_repositories(): build_file = "//dependency_support/linenoise:bundled.BUILD.bazel", ) - # Commit from 2024-06-26 - http_archive( - name = "com_google_riegeli", - sha256 = "38fd4b6bc24958ae51e1a5a0eb57ce9c3dbbaf5034a78453a4d133597fbf31e4", - strip_prefix = "riegeli-cb68d579f108c96831b6a7815da43ff24b4e5242", - url = "https://github.com/google/riegeli/archive/cb68d579f108c96831b6a7815da43ff24b4e5242.tar.gz", - ) - # Needed by fuzztest. Release 2024-05-21, current as of 2024-06-26 http_archive( name = "snappy", @@ -218,17 +117,15 @@ def load_external_repositories(): urls = ["https://github.com/google/highwayhash/archive/f8381f3331d9c56a9792f9b4a35f61c41108c39e.tar.gz"], ) - # Released 2024-06-07, current as of 2024-06-26. + # Updated to head on 2024-03-14 + FUZZTEST_COMMIT = "393ae75c0fca5f9892e73969da5d6bce453ad318" http_archive( - name = "com_github_grpc_grpc", - urls = ["https://github.com/grpc/grpc/archive/v1.64.2.tar.gz"], - patches = ["//dependency_support/com_github_grpc_grpc:0001-Add-absl-status-to-deps.patch"], - sha256 = "c682fc39baefc6e804d735e6b48141157b7213602cc66dbe0bf375b904d8b5f9", - strip_prefix = "grpc-1.64.2", - repo_mapping = { - "@local_config_python": "@project_python", - "@system_python": "@project_python", - }, + name = "com_google_fuzztest", + strip_prefix = "fuzztest-" + FUZZTEST_COMMIT, + url = "https://github.com/google/fuzztest/archive/" + FUZZTEST_COMMIT + ".zip", + sha256 = "a0558ceb617d78ee93d7e6b62930b4aeebc02f1e5817d4d0dae53699f6f6c352", + patch_args = ["-p1", "-R"], # reverse patch until we upgrade bazel to 7.1; see: bazelbuild/bazel#19233. + patches = ["//dependency_support/com_google_fuzztest:e317d5277e34948ae7048cb5e48309e0288e8df3.patch"], ) # Used by xlscc. Tagged 2024-02-16 (note: release is lagging tag), current as of 2024-06-26 @@ -240,88 +137,35 @@ def load_external_repositories(): build_file = "//dependency_support/com_github_hlslibs_ac_types:bundled.BUILD.bazel", ) - # Released 2024-04-25, current as of 2024-06-26 - http_archive( - name = "platforms", - urls = [ - "https://mirror.bazel.build/github.com/bazelbuild/platforms/releases/download/0.0.10/platforms-0.0.10.tar.gz", - "https://github.com/bazelbuild/platforms/releases/download/0.0.10/platforms-0.0.10.tar.gz", - ], - sha256 = "218efe8ee736d26a3572663b374a253c012b716d8af0c07e842e82f238a0a7ee", - ) - # Released 2024-05-08, current as of 2024-06-26. ORTOOLS_VERSION = "9.10" http_archive( name = "com_google_ortools", - urls = ["https://github.com/google/or-tools/archive/refs/tags/v{tag}.tar.gz".format(tag = ORTOOLS_VERSION)], + urls = ["https://github.com/google/or-tools/archive/refs/tags/v{}.tar.gz".format(ORTOOLS_VERSION)], sha256 = "e7c27a832f3595d4ae1d7e53edae595d0347db55c82c309c8f24227e675fd378", strip_prefix = "or-tools-" + ORTOOLS_VERSION, ) - # Released 2024-05-23, current as of 2024-06-26. - http_archive( - name = "com_google_benchmark", - urls = ["https://github.com/google/benchmark/archive/refs/tags/v1.8.4.tar.gz"], - sha256 = "3e7059b6b11fb1bbe28e33e02519398ca94c1818874ebed18e504dc6f709be45", - strip_prefix = "benchmark-1.8.4", - ) - - # Updated to head on 2024-03-14 - FUZZTEST_COMMIT = "393ae75c0fca5f9892e73969da5d6bce453ad318" - http_archive( - name = "com_google_fuzztest", - strip_prefix = "fuzztest-" + FUZZTEST_COMMIT, - url = "https://github.com/google/fuzztest/archive/" + FUZZTEST_COMMIT + ".zip", - sha256 = "a0558ceb617d78ee93d7e6b62930b4aeebc02f1e5817d4d0dae53699f6f6c352", - patch_args = ["-p1", "-R"], # reverse patch until we upgrade bazel to 7.1; see: bazelbuild/bazel#19233. - patches = ["//dependency_support/com_google_fuzztest:e317d5277e34948ae7048cb5e48309e0288e8df3.patch"], - ) - - # Released 2024-01-24, current as of 2024-06-26 - http_archive( - name = "rules_license", - urls = [ - "https://github.com/bazelbuild/rules_license/releases/download/0.0.8/rules_license-0.0.8.tar.gz", - ], - sha256 = "241b06f3097fd186ff468832150d6cc142247dc42a32aaefb56d0099895fd229", - ) - - # 2022-09-19 - http_archive( - name = "com_grail_bazel_compdb", - sha256 = "a3ff6fe238eec8202270dff75580cba3d604edafb8c3408711e82633c153efa8", - strip_prefix = "bazel-compilation-database-940cedacdb8a1acbce42093bf67f3a5ca8b265f7", - urls = ["https://github.com/grailbio/bazel-compilation-database/archive/940cedacdb8a1acbce42093bf67f3a5ca8b265f7.tar.gz"], - ) - # Tagged 2024-08-23, current as of 2024-08-24 - VERIBLE_TAG = "v0.0-3756-gda9a0f8c" + VERIBLE_VERSION = "0.0-3756-gda9a0f8c" http_archive( name = "verible", sha256 = "0d45e646ce8cf618c55e614f827aead0377c34035be04b843aee225ea5be4527", - strip_prefix = "verible-" + VERIBLE_TAG.lstrip("v"), - urls = ["https://github.com/chipsalliance/verible/archive/refs/tags/" + VERIBLE_TAG + ".tar.gz"], + strip_prefix = "verible-" + VERIBLE_VERSION, + urls = ["https://github.com/chipsalliance/verible/archive/refs/tags/v{}.tar.gz".format(VERIBLE_VERSION)], patch_args = ["-p1"], patches = ["//dependency_support/verible:visibility.patch"], ) - # Used by Verible; current as of 2024-06-26 + # Needed by zstd + # Released 2024-04-25, current as of 2024-06-26 http_archive( - name = "jsonhpp", - build_file = "@verible//bazel:jsonhpp.BUILD", - sha256 = "0d8ef5af7f9794e3263480193c491549b2ba6cc74bb018906202ada498a79406", - strip_prefix = "json-3.11.3", + name = "platforms", urls = [ - "https://github.com/nlohmann/json/archive/refs/tags/v3.11.3.tar.gz", + "https://mirror.bazel.build/github.com/bazelbuild/platforms/releases/download/0.0.10/platforms-0.0.10.tar.gz", + "https://github.com/bazelbuild/platforms/releases/download/0.0.10/platforms-0.0.10.tar.gz", ], - ) - - # Released 2024-06-03, current as of 2024-06-26 - http_archive( - name = "rules_pkg", - urls = ["https://github.com/bazelbuild/rules_pkg/releases/download/1.0.0/rules_pkg-1.0.0.tar.gz"], - sha256 = "cad05f864a32799f6f9022891de91ac78f30e0fa07dc68abac92a628121b5b11", + sha256 = "218efe8ee736d26a3572663b374a253c012b716d8af0c07e842e82f238a0a7ee", ) # Used in C++ tests of the ZSTD Module @@ -329,6 +173,8 @@ def load_external_repositories(): # Version fdfb2aff released on 2024-07-31 # https://github.com/facebook/zstd/commit/fdfb2aff39dc498372d8c9e5f2330b692fea9794 # Updated 2024-08-08 + # This does exist already in https://registry.bazel.build/ - NB: when moving to MODULE.bazel, + # we probably need to use our local bundled.BUILD.bazel as it provides the decodecorpus. http_archive( name = "zstd", sha256 = "9ace5a1b3c477048c6e034fe88d2abb5d1402ced199cae8e9eef32fdc32204df", diff --git a/dependency_support/pybind11_bazel/BUILD.bazel b/dependency_support/pybind11_bazel/BUILD.bazel deleted file mode 100644 index a1f21e7338..0000000000 --- a/dependency_support/pybind11_bazel/BUILD.bazel +++ /dev/null @@ -1,15 +0,0 @@ -# Copyright 2022 The XLS Authors -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -# Needed to make this a package. diff --git a/dependency_support/pybind11_bazel/sysconfig_fix.patch b/dependency_support/pybind11_bazel/sysconfig_fix.patch deleted file mode 100644 index 1c1ab9914c..0000000000 --- a/dependency_support/pybind11_bazel/sysconfig_fix.patch +++ /dev/null @@ -1,15 +0,0 @@ -diff --git python_configure.bzl python_configure.bzl -index 1f5bffa..4225255 100644 ---- python_configure.bzl -+++ python_configure.bzl -@@ -252,8 +252,8 @@ def _get_python_include(repository_ctx, python_bin): - python_bin, - "-c", - "from __future__ import print_function;" + -- "from distutils import sysconfig;" + -- "print(sysconfig.get_python_inc())", -+ "import sysconfig; import os; " + -+ "print(os.path.dirname(sysconfig.get_config_h_filename()))", - ], - error_msg = "Problem getting python include path.", - error_details = ("Is the Python binary path set up right? " + diff --git a/dependency_support/zlib/BUILD.bazel b/dependency_support/zlib/BUILD.bazel deleted file mode 100644 index f957489a3b..0000000000 --- a/dependency_support/zlib/BUILD.bazel +++ /dev/null @@ -1,15 +0,0 @@ -# Copyright 2020 The XLS Authors -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -# Required to make this a package. diff --git a/dependency_support/zlib/bundled.BUILD.bazel b/dependency_support/zlib/bundled.BUILD.bazel deleted file mode 100755 index cb849cdee0..0000000000 --- a/dependency_support/zlib/bundled.BUILD.bazel +++ /dev/null @@ -1,74 +0,0 @@ -# Copyright 2020 The XLS Authors -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -package(default_visibility = ["//visibility:public"]) - -licenses(["notice"]) # BSD/MIT-like license (for zlib) - -_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 = "cp $(SRCS) $(@D)/zlib/include/", - visibility = ["//visibility:private"], -) - -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, - copts = [ - "-Wno-unused-variable", - "-Wno-implicit-function-declaration", - ], - includes = ["zlib/include/"], -) diff --git a/xls/dev_tools/make-compilation-db.sh b/xls/dev_tools/make-compilation-db.sh index d65522e5bd..8953528d77 100755 --- a/xls/dev_tools/make-compilation-db.sh +++ b/xls/dev_tools/make-compilation-db.sh @@ -13,24 +13,5 @@ # See the License for the specific language governing permissions and # limitations under the License. -set -u -set -e - -readonly OUTPUT_BASE="$(bazel info output_base)" - -readonly COMPDB_SCRIPT="${OUTPUT_BASE}/external/com_grail_bazel_compdb/generate.py" -[ -r "${COMPDB_SCRIPT}" ] || bazel fetch @com_grail_bazel_compdb//... - -python3 "${COMPDB_SCRIPT}" - -# Massage the output so that clang-tidy fully undestands the compile commands: -# remove flags where it gets confused. -# Also, make sure that the command also contains -xc++ (bazel sometimes does -# not add that in libraries that don't have a *.cc file but only *.h or *.inc) -sed -i compile_commands.json -f - <