From cee30d233dc10eab5938c803ba81fd2900207943 Mon Sep 17 00:00:00 2001 From: Henner Zeller Date: Mon, 27 Jan 2025 14:40:43 -0800 Subject: [PATCH] Convert to bzlmod, first steps. First steps towards exclusively using MODULE.bazel, for now a subset of changes already improving the state a lot. * Add MODULE.bazel and add dependencies already provided by the Bazel Central Registry. * Remove the above from WORKSPACE and dependency_support/{load,initialize}_external.bzl. * Add some patches, as some external dependencies used @rules_cc// to get cc_proto_library and cc_library, which is not available anymore in latest rules_cc (but provided by bazel itself) * Fallout: the compilation db currently can't be built anymore due to the compdb not compatible anymore with bzlmod. I have a plan to replace that, but not in this first CL; for now, it is just disabled. Things for follow-up PRs * move the remaining load_exernal.bzl also to MODULE.bazel, but use the repo rules to fetch projects. * Upstream more tools we use to Bazel Central Registry; e.g. low hanging fruit would be to get a later version of protoc-gen-validate in there or add lineoise. * Rules python and its toolchain can probably be simplified. * fix compilation db. Issues: https://github.com/google/xls/issues/931 --- .bazelrc | 8 +- .github/workflows/continuous-integration.yml | 15 + .gitignore | 1 + MODULE.bazel | 53 ++++ WORKSPACE | 52 +--- .../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_google_fuzztest/BUILD.bazel | 15 - ...d5277e34948ae7048cb5e48309e0288e8df3.patch | 42 --- .../ortools-no-rulescc.patch | 260 ++++++++++++++++++ .../com_grail_bazel_toolchain/BUILD.bazel | 15 - dependency_support/copy.bzl | 45 --- dependency_support/initialize_external.bzl | 17 +- dependency_support/load_external.bzl | 251 +---------------- .../protoc-gen-validate/no-rulescc.patch | 12 + dependency_support/pybind11_bazel/BUILD.bazel | 15 - .../pybind11_bazel/sysconfig_fix.patch | 15 - dependency_support/rules_hdl/workspace.bzl | 6 +- dependency_support/zlib/BUILD.bazel | 15 - dependency_support/zlib/bundled.BUILD.bazel | 74 ----- fuzztest.bazelrc | 52 +++- xls/dev_tools/make-compilation-db.sh | 23 +- 24 files changed, 407 insertions(+), 648 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_google_fuzztest/BUILD.bazel delete mode 100644 dependency_support/com_google_fuzztest/e317d5277e34948ae7048cb5e48309e0288e8df3.patch create mode 100644 dependency_support/com_google_ortools/ortools-no-rulescc.patch delete mode 100644 dependency_support/com_grail_bazel_toolchain/BUILD.bazel delete mode 100644 dependency_support/copy.bzl create mode 100644 dependency_support/protoc-gen-validate/no-rulescc.patch 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 e9e1cefeb20..39f78c74a9e 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/.github/workflows/continuous-integration.yml b/.github/workflows/continuous-integration.yml index 1c1f30a6db0..a8ea9c97259 100644 --- a/.github/workflows/continuous-integration.yml +++ b/.github/workflows/continuous-integration.yml @@ -49,3 +49,18 @@ jobs: - name: Bazel Test Including Contrib & DevTools (opt) run: | bazel test -c opt --noshow_progress --test_output=errors -- //... + + build: + # Temporary, during PR #1893 + name: Mac Bazel Build (opt) + runs-on: + labels: macos-latest-xlarge + timeout-minutes: 600 + steps: + - uses: actions/checkout@v2 + + # We don't use action/cache nighlty workflows to ensure full reproducibility of the build. + + - name: Bazel Build Tools (opt) + run: | + bazel build -c opt --noshow_progress --test_output=errors -- //xls/dslx:interpreter_main //xls/dslx/ir_convert:ir_converter_main //xls/tools:opt_main //xls/tools:codegen_main diff --git a/.gitignore b/.gitignore index 11e040bb541..e480093082e 100644 --- a/.gitignore +++ b/.gitignore @@ -8,3 +8,4 @@ user.bazelrc .vscode .cache docs/ +MODULE.bazel.lock diff --git a/MODULE.bazel b/MODULE.bazel new file mode 100644 index 00000000000..fb4f7aba58e --- /dev/null +++ b/MODULE.bazel @@ -0,0 +1,53 @@ +module( + name = "xls", + repo_name = "com_google_xls", +) + +# Compiler toolchain +bazel_dep(name = "toolchains_llvm", version = "1.3.0") + +# 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 = "20240722.1", repo_name = "com_google_absl") +bazel_dep(name = "abseil-py", version = "2.1.0", repo_name = "com_google_absl_py") +bazel_dep(name = "bazel_features", version = "1.25.0") +bazel_dep(name = "bazel_skylib", version = "1.7.1") +bazel_dep(name = "boringssl", version = "0.20250114.0") +bazel_dep(name = "googleapis", version = "0.0.0-20240819-fe8ba054a", repo_name = "com_google_googleapis") +bazel_dep(name = "grpc", version = "1.69.0", repo_name = "com_github_grpc_grpc") +bazel_dep(name = "nlohmann_json", version = "3.11.3.bcr.1") +bazel_dep(name = "platforms", version = "0.0.11") +bazel_dep(name = "protobuf", version = "29.3", repo_name = "com_google_protobuf") +bazel_dep(name = "re2", version = "2024-07-02.bcr.1", repo_name = "com_googlesource_code_re2") +bazel_dep(name = "riegeli", version = "0.0.0-20241218-3385e3c", repo_name = "com_google_riegeli") +bazel_dep(name = "rules_license", version = "1.0.0") +bazel_dep(name = "rules_pkg", version = "1.0.1") +bazel_dep(name = "rules_proto", version = "7.1.0") +bazel_dep(name = "verible", version = "0.0.3933") + +# Dev dependencies +bazel_dep(name = "fuzztest", version = "20241028.0", dev_dependency = True, repo_name = "com_google_fuzztest") +bazel_dep(name = "google_benchmark", version = "1.9.1", dev_dependency = True, repo_name = "com_google_benchmark") +bazel_dep(name = "googletest", version = "1.15.2", dev_dependency = True, repo_name = "com_google_googletest") + +# Repositories we don't really depend on directly, but we need to provide +# for other dependencies as they are using old versions that are not +# compatible with current bazel. +bazel_dep(name = "rules_bison", version = "0.3") +bazel_dep(name = "rules_flex", version = "0.3") +bazel_dep(name = "rules_java", version = "8.7.2") +bazel_dep(name = "protoc-gen-validate", version = "1.0.4.bcr.2") +single_version_override( + module_name = "protoc-gen-validate", + patch_strip = 1, + patches = ["//dependency_support:protoc-gen-validate/no-rulescc.patch"], + version = "1.0.4.bcr.2", +) diff --git a/WORKSPACE b/WORKSPACE index 595ce818c86..e568cf19f3a 100644 --- a/WORKSPACE +++ b/WORKSPACE @@ -12,45 +12,9 @@ # See the License for the specific language governing permissions and # limitations under the License. -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") +# TODO(https://github.com/google/xls/issues/931): Everything here should go away and migrate to MODULE.bazel -llvm_toolchain( - name = "llvm_toolchain", - llvm_version = "17.0.6", -) - -load("@llvm_toolchain//:toolchains.bzl", "llvm_register_toolchains") - -llvm_register_toolchains() +workspace(name = "com_google_xls") load("//dependency_support:load_external.bzl", "load_external_repositories") @@ -75,12 +39,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 +46,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 a83a80d46e6..00000000000 --- 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 bde7573e93e..00000000000 --- 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 a5bf9b83842..00000000000 --- 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 a1f21e73384..00000000000 --- 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_google_fuzztest/BUILD.bazel b/dependency_support/com_google_fuzztest/BUILD.bazel deleted file mode 100644 index 62318c7d703..00000000000 --- a/dependency_support/com_google_fuzztest/BUILD.bazel +++ /dev/null @@ -1,15 +0,0 @@ -# Copyright 2024 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/com_google_fuzztest/e317d5277e34948ae7048cb5e48309e0288e8df3.patch b/dependency_support/com_google_fuzztest/e317d5277e34948ae7048cb5e48309e0288e8df3.patch deleted file mode 100644 index 3cb9cf87caf..00000000000 --- a/dependency_support/com_google_fuzztest/e317d5277e34948ae7048cb5e48309e0288e8df3.patch +++ /dev/null @@ -1,42 +0,0 @@ -From e317d5277e34948ae7048cb5e48309e0288e8df3 Mon Sep 17 00:00:00 2001 -From: Nevena Kotlaja -Date: Thu, 29 Feb 2024 12:07:18 -0800 -Subject: [PATCH] Remove implicit dependencies of - `_allowlist_function_transition`. - -Rules are not required to have an implicit dependencies on the transition allowlist since Bazel knows where the file is. - -PiperOrigin-RevId: 611552493 ---- - centipede/instrument.bzl | 3 --- - centipede/testing/build_defs.bzl | 3 --- - 2 files changed, 6 deletions(-) - -diff --git a/centipede/instrument.bzl b/centipede/instrument.bzl -index 605ce905..8d223881 100644 ---- a/centipede/instrument.bzl -+++ b/centipede/instrument.bzl -@@ -78,9 +78,6 @@ target cc_binary. - cfg = strip_instrumentation_transition, - mandatory = True, - ), -- "_allowlist_function_transition": attr.label( -- default = "@bazel_tools//tools/allowlists/function_transition_allowlist", -- ), - }, - executable = True, - ) -diff --git a/centipede/testing/build_defs.bzl b/centipede/testing/build_defs.bzl -index ec3878f0..bb2bae05 100644 ---- a/centipede/testing/build_defs.bzl -+++ b/centipede/testing/build_defs.bzl -@@ -104,9 +104,6 @@ __sancov_fuzz_target = rule( - executable = True, - mandatory = True, - ), -- "_allowlist_function_transition": attr.label( -- default = "@bazel_tools//tools/allowlists/function_transition_allowlist", -- ), - "sancov": attr.string(), - }, - executable = True, diff --git a/dependency_support/com_google_ortools/ortools-no-rulescc.patch b/dependency_support/com_google_ortools/ortools-no-rulescc.patch new file mode 100644 index 00000000000..bfa74ea42f8 --- /dev/null +++ b/dependency_support/com_google_ortools/ortools-no-rulescc.patch @@ -0,0 +1,260 @@ +diff --git a/ortools/algorithms/BUILD.bazel b/ortools/algorithms/BUILD.bazel +index be5f372620..09781728ca 100644 +--- a/ortools/algorithms/BUILD.bazel ++++ b/ortools/algorithms/BUILD.bazel +@@ -12,7 +12,7 @@ + # limitations under the License. + + load("@bazel_skylib//rules:common_settings.bzl", "bool_flag") +-load("@rules_cc//cc:defs.bzl", "cc_library", "cc_proto_library") ++# load("@rules_cc//cc:defs.bzl", "cc_library", "cc_proto_library") + load("@rules_proto//proto:defs.bzl", "proto_library") + load("@rules_python//python:proto.bzl", "py_proto_library") + +diff --git a/ortools/algorithms/python/BUILD.bazel b/ortools/algorithms/python/BUILD.bazel +index fe3de2c5f9..912b8d9f8c 100644 +--- a/ortools/algorithms/python/BUILD.bazel ++++ b/ortools/algorithms/python/BUILD.bazel +@@ -16,7 +16,7 @@ load("@bazel_skylib//rules:common_settings.bzl", "bool_flag") + # Python wrapper for .. + load("@pip_deps//:requirements.bzl", "requirement") + load("@pybind11_bazel//:build_defs.bzl", "pybind_extension") +-load("@rules_cc//cc:defs.bzl", "cc_library") ++# load("@rules_cc//cc:defs.bzl", "cc_library") + load("@rules_python//python:defs.bzl", "py_test") + + # OSS solvers +diff --git a/ortools/bop/BUILD.bazel b/ortools/bop/BUILD.bazel +index 47209902d2..c9b2dc1f70 100644 +--- a/ortools/bop/BUILD.bazel ++++ b/ortools/bop/BUILD.bazel +@@ -11,7 +11,7 @@ + # See the License for the specific language governing permissions and + # limitations under the License. + +-load("@rules_cc//cc:defs.bzl", "cc_library", "cc_proto_library") ++# load("@rules_cc//cc:defs.bzl", "cc_library", "cc_proto_library") + load("@rules_proto//proto:defs.bzl", "proto_library") + load("@rules_python//python:proto.bzl", "py_proto_library") + +diff --git a/ortools/constraint_solver/BUILD.bazel b/ortools/constraint_solver/BUILD.bazel +index 99d9b4d9c9..18c01554e9 100644 +--- a/ortools/constraint_solver/BUILD.bazel ++++ b/ortools/constraint_solver/BUILD.bazel +@@ -13,7 +13,7 @@ + + # Home of constraint solver constraint_solver + +-load("@rules_cc//cc:defs.bzl", "cc_library", "cc_proto_library") ++# load("@rules_cc//cc:defs.bzl", "cc_library", "cc_proto_library") + load("@rules_proto//proto:defs.bzl", "proto_library") + + package(default_visibility = ["//visibility:public"]) +diff --git a/ortools/glop/BUILD.bazel b/ortools/glop/BUILD.bazel +index 687c48d363..c8bba33598 100644 +--- a/ortools/glop/BUILD.bazel ++++ b/ortools/glop/BUILD.bazel +@@ -11,7 +11,7 @@ + # See the License for the specific language governing permissions and + # limitations under the License. + +-load("@rules_cc//cc:defs.bzl", "cc_library", "cc_proto_library") ++# load("@rules_cc//cc:defs.bzl", "cc_library", "cc_proto_library") + load("@rules_proto//proto:defs.bzl", "proto_library") + load("@rules_python//python:proto.bzl", "py_proto_library") + +diff --git a/ortools/graph/BUILD.bazel b/ortools/graph/BUILD.bazel +index fe0f5883b5..e3d7d3ff2d 100644 +--- a/ortools/graph/BUILD.bazel ++++ b/ortools/graph/BUILD.bazel +@@ -11,7 +11,7 @@ + # See the License for the specific language governing permissions and + # limitations under the License. + +-load("@rules_cc//cc:defs.bzl", "cc_library", "cc_proto_library") ++# load("@rules_cc//cc:defs.bzl", "cc_library", "cc_proto_library") + load("@rules_proto//proto:defs.bzl", "proto_library") + + package(default_visibility = ["//visibility:public"]) +diff --git a/ortools/gscip/BUILD.bazel b/ortools/gscip/BUILD.bazel +index d9494838b3..28abaff1fd 100644 +--- a/ortools/gscip/BUILD.bazel ++++ b/ortools/gscip/BUILD.bazel +@@ -11,7 +11,7 @@ + # See the License for the specific language governing permissions and + # limitations under the License. + +-load("@rules_cc//cc:defs.bzl", "cc_proto_library") ++# load("@rules_cc//cc:defs.bzl", "cc_proto_library") + load("@rules_python//python:proto.bzl", "py_proto_library") + + package( +diff --git a/ortools/init/python/BUILD.bazel b/ortools/init/python/BUILD.bazel +index 1774f366bb..36f928cf3b 100644 +--- a/ortools/init/python/BUILD.bazel ++++ b/ortools/init/python/BUILD.bazel +@@ -15,7 +15,7 @@ + + load("@pip_deps//:requirements.bzl", "requirement") + load("@pybind11_bazel//:build_defs.bzl", "pybind_extension") +-load("@rules_cc//cc:defs.bzl", "cc_library") ++# load("@rules_cc//cc:defs.bzl", "cc_library") + load("@rules_python//python:defs.bzl", "py_test") + + cc_library( +diff --git a/ortools/linear_solver/BUILD.bazel b/ortools/linear_solver/BUILD.bazel +index 618e1921a6..60ea2fe95b 100644 +--- a/ortools/linear_solver/BUILD.bazel ++++ b/ortools/linear_solver/BUILD.bazel +@@ -13,7 +13,7 @@ + + load("@bazel_skylib//rules:common_settings.bzl", "bool_flag") + load("@bazel_skylib//rules:copy_file.bzl", "copy_file") +-load("@rules_cc//cc:defs.bzl", "cc_library", "cc_proto_library") ++# load("@rules_cc//cc:defs.bzl", "cc_library", "cc_proto_library") + load("@rules_proto//proto:defs.bzl", "proto_library") + load("@rules_python//python:proto.bzl", "py_proto_library") + +diff --git a/ortools/math_opt/BUILD.bazel b/ortools/math_opt/BUILD.bazel +index 3307bffff8..57fcf225f7 100644 +--- a/ortools/math_opt/BUILD.bazel ++++ b/ortools/math_opt/BUILD.bazel +@@ -11,7 +11,7 @@ + # See the License for the specific language governing permissions and + # limitations under the License. + +-load("@rules_cc//cc:defs.bzl", "cc_proto_library") ++# load("@rules_cc//cc:defs.bzl", "cc_proto_library") + load("@rules_python//python:proto.bzl", "py_proto_library") + + package(default_visibility = ["//visibility:public"]) +diff --git a/ortools/math_opt/solvers/BUILD.bazel b/ortools/math_opt/solvers/BUILD.bazel +index e7e8054a97..a3c517f72b 100644 +--- a/ortools/math_opt/solvers/BUILD.bazel ++++ b/ortools/math_opt/solvers/BUILD.bazel +@@ -11,7 +11,7 @@ + # See the License for the specific language governing permissions and + # limitations under the License. + +-load("@rules_cc//cc:defs.bzl", "cc_proto_library") ++# load("@rules_cc//cc:defs.bzl", "cc_proto_library") + load("@rules_python//python:proto.bzl", "py_proto_library") + + package(default_visibility = ["//ortools/math_opt:__subpackages__"]) +diff --git a/ortools/packing/BUILD.bazel b/ortools/packing/BUILD.bazel +index 04b7014f32..a8368d21b0 100644 +--- a/ortools/packing/BUILD.bazel ++++ b/ortools/packing/BUILD.bazel +@@ -11,7 +11,7 @@ + # See the License for the specific language governing permissions and + # limitations under the License. + +-load("@rules_cc//cc:defs.bzl", "cc_proto_library") ++# load("@rules_cc//cc:defs.bzl", "cc_proto_library") + + package(default_visibility = ["//visibility:public"]) + +diff --git a/ortools/pdlp/BUILD.bazel b/ortools/pdlp/BUILD.bazel +index 5b68856f23..ca7f3004a7 100644 +--- a/ortools/pdlp/BUILD.bazel ++++ b/ortools/pdlp/BUILD.bazel +@@ -11,7 +11,7 @@ + # See the License for the specific language governing permissions and + # limitations under the License. + +-load("@rules_cc//cc:defs.bzl", "cc_library", "cc_proto_library") ++# load("@rules_cc//cc:defs.bzl", "cc_library", "cc_proto_library") + load("@rules_proto//proto:defs.bzl", "proto_library") + load("@rules_python//python:proto.bzl", "py_proto_library") + +diff --git a/ortools/routing/parsers/BUILD.bazel b/ortools/routing/parsers/BUILD.bazel +index 94690f386f..3e15468f60 100644 +--- a/ortools/routing/parsers/BUILD.bazel ++++ b/ortools/routing/parsers/BUILD.bazel +@@ -11,7 +11,7 @@ + # See the License for the specific language governing permissions and + # limitations under the License. + +-load("@rules_cc//cc:defs.bzl", "cc_library", "cc_proto_library") ++# load("@rules_cc//cc:defs.bzl", "cc_library", "cc_proto_library") + load("@rules_proto//proto:defs.bzl", "proto_library") + + package(default_visibility = ["//visibility:public"]) +diff --git a/ortools/sat/BUILD.bazel b/ortools/sat/BUILD.bazel +index 222559fa88..991c52652f 100644 +--- a/ortools/sat/BUILD.bazel ++++ b/ortools/sat/BUILD.bazel +@@ -13,7 +13,7 @@ + + # Home of CP/SAT solver (which includes SAT, max-SAT and PB problems). + +-load("@rules_cc//cc:defs.bzl", "cc_library", "cc_proto_library") ++# load("@rules_cc//cc:defs.bzl", "cc_library", "cc_proto_library") + load("@rules_java//java:defs.bzl", "java_proto_library") + load("@rules_proto//proto:defs.bzl", "proto_library") + load("@rules_python//python:proto.bzl", "py_proto_library") +diff --git a/ortools/scheduling/BUILD.bazel b/ortools/scheduling/BUILD.bazel +index d2c0ef005d..bfab1c185e 100644 +--- a/ortools/scheduling/BUILD.bazel ++++ b/ortools/scheduling/BUILD.bazel +@@ -11,7 +11,7 @@ + # See the License for the specific language governing permissions and + # limitations under the License. + +-load("@rules_cc//cc:defs.bzl", "cc_proto_library") ++# load("@rules_cc//cc:defs.bzl", "cc_proto_library") + load("@rules_proto//proto:defs.bzl", "proto_library") + load("@rules_python//python:proto.bzl", "py_proto_library") + +diff --git a/ortools/service/v1/BUILD.bazel b/ortools/service/v1/BUILD.bazel +index 20a72e774d..3dd9f17563 100644 +--- a/ortools/service/v1/BUILD.bazel ++++ b/ortools/service/v1/BUILD.bazel +@@ -11,7 +11,7 @@ + # See the License for the specific language governing permissions and + # limitations under the License. + +-load("@rules_cc//cc:defs.bzl", "cc_proto_library") ++# load("@rules_cc//cc:defs.bzl", "cc_proto_library") + load("@rules_python//python:proto.bzl", "py_proto_library") + + package(default_visibility = [ +diff --git a/ortools/service/v1/mathopt/BUILD.bazel b/ortools/service/v1/mathopt/BUILD.bazel +index 0feaf21b1f..c702441d0b 100644 +--- a/ortools/service/v1/mathopt/BUILD.bazel ++++ b/ortools/service/v1/mathopt/BUILD.bazel +@@ -11,7 +11,7 @@ + # See the License for the specific language governing permissions and + # limitations under the License. + +-load("@rules_cc//cc:defs.bzl", "cc_proto_library") ++# load("@rules_cc//cc:defs.bzl", "cc_proto_library") + load("@rules_python//python:proto.bzl", "py_proto_library") + + package(default_visibility = [ +diff --git a/ortools/util/BUILD.bazel b/ortools/util/BUILD.bazel +index b2ee31597e..e075a5058b 100644 +--- a/ortools/util/BUILD.bazel ++++ b/ortools/util/BUILD.bazel +@@ -11,7 +11,7 @@ + # See the License for the specific language governing permissions and + # limitations under the License. + +-load("@rules_cc//cc:defs.bzl", "cc_proto_library") ++# load("@rules_cc//cc:defs.bzl", "cc_proto_library") + load("@rules_python//python:proto.bzl", "py_proto_library") + + package(default_visibility = ["//visibility:public"]) +diff --git a/ortools/util/python/BUILD.bazel b/ortools/util/python/BUILD.bazel +index 925cf571dc..4668b80870 100644 +--- a/ortools/util/python/BUILD.bazel ++++ b/ortools/util/python/BUILD.bazel +@@ -15,7 +15,7 @@ + + load("@pip_deps//:requirements.bzl", "requirement") + load("@pybind11_bazel//:build_defs.bzl", "pybind_extension") +-load("@rules_cc//cc:defs.bzl", "cc_library") ++# load("@rules_cc//cc:defs.bzl", "cc_library") + load("@rules_python//python:defs.bzl", "py_test") + + cc_library( 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 bde7573e93e..00000000000 --- 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/copy.bzl b/dependency_support/copy.bzl deleted file mode 100644 index aebe9b6f0df..00000000000 --- a/dependency_support/copy.bzl +++ /dev/null @@ -1,45 +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. - -"""Provides a utility macro that copies a file.""" - -def copy(name, src, out): - native.genrule( - name = name, - srcs = [src], - outs = [out], - cmd = "cp $(SRCS) $@", - message = "Copying $(SRCS)", - ) - -def touch(name, out, contents = None): - """Produces a genrule to creates a file, with optional #define contents. - - Args: - name: Name to use for the genrule. - out: Path for the output file. - contents: Optional mapping that will be materialized as - `#define $KEY $VALUE` in the output file. - """ - lines = [] - if contents: - for k, v in contents.items(): - lines.append("#define %s %s" % (k, v)) - contents = "\n".join(lines) - native.genrule( - name = name, - outs = [out], - cmd = "echo " + repr(contents) + " > $@", - message = "Touch $@", - ) diff --git a/dependency_support/initialize_external.bzl b/dependency_support/initialize_external.bzl index c88b6bebb91..cdf3ebcb8f8 100644 --- a/dependency_support/initialize_external.bzl +++ b/dependency_support/initialize_external.bzl @@ -14,35 +14,26 @@ """Provides helper that initializes external repositories with third-party code.""" -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") +# TODO(https://github.com/google/xls/issues/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("@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 load("@rules_hdl//:init.bzl", rules_hdl_init = "init") load("@rules_hdl//dependency_support:dependency_support.bzl", rules_hdl_dependency_support = "dependency_support") load("@rules_pkg//:deps.bzl", "rules_pkg_dependencies") -load("@rules_proto//proto:repositories.bzl", "rules_proto_dependencies") -load("@rules_proto//proto:setup.bzl", "rules_proto_setup") -load("@rules_proto//proto:toolchains.bzl", "rules_proto_toolchains") load("@rules_python//python:pip.bzl", "pip_parse") load("//dependency_support/boost:initialize.bzl", initialize_boost = "initialize") 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() rules_closure_dependencies() rules_closure_toolchains() - rules_proto_dependencies() - rules_proto_setup() - rules_proto_toolchains() pip_parse( name = "xls_pip_deps", requirements_lock = "//dependency_support:pip_requirements_lock.txt", @@ -51,6 +42,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 6280e33368b..6db781cfd4e 100644 --- a/dependency_support/load_external.bzl +++ b/dependency_support/load_external.bzl @@ -14,6 +14,10 @@ """Provides helper that loads external repositories with third-party code.""" +# TODO(https://github.com/google/xls/issues/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,122 +42,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.15.2 (released 2024-07-31, current as of 2024-10-16) - http_archive( - name = "com_google_googletest", - urls = ["https://github.com/google/googletest/archive/refs/tags/v1.15.2.zip"], - strip_prefix = "googletest-1.15.2", - integrity = "sha256-8XnsIX+bOz88bosC0+ftqZe0nkzibWsjXJBTvsnAv58=", - ) - - # LTS 20240722.0 (released 2024-07-22, current as of 2024-10-16) - http_archive( - name = "com_google_absl", - urls = ["https://github.com/abseil/abseil-cpp/archive/refs/tags/20240722.0.tar.gz"], - strip_prefix = "abseil-cpp-20240722.0", - integrity = "sha256-9Q5awxGoE4Laf6dblzEOS5AGR0+VYKxG9UqZZ/B9SuM=", - ) - - # 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", - }, - ) - - # Release on 2024-09-13, current as of 2024-10-01 - http_archive( - name = "bazel_features", - sha256 = "bdc12fcbe6076180d835c9dd5b3685d509966191760a0eb10b276025fcb76158", - strip_prefix = "bazel_features-1.17.0", - url = "https://github.com/bazel-contrib/bazel_features/releases/download/v1.17.0/bazel_features-v1.17.0.tar.gz", - ) - - # Release on 2024-06-17, current as of 2024-10-01 - http_archive( - name = "rules_proto", - sha256 = "6fb6767d1bef535310547e03247f7518b03487740c11b6c6adb7952033fe1295", - strip_prefix = "rules_proto-6.0.2", - urls = [ - "https://github.com/bazelbuild/rules_proto/releases/download/6.0.2/rules_proto-6.0.2.tar.gz", - ], - ) - # Released on 2024-09-24, current as of 2024-10-01 http_archive( name = "rules_python", @@ -189,53 +77,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", - sha256 = "736aeb64d86566d2236ddffa2865ee5d7a82d26c9016b36218fcc27ea4f09f86", - build_file = "@com_google_riegeli//third_party:snappy.BUILD", - strip_prefix = "snappy-1.2.1", - urls = ["https://github.com/google/snappy/archive/1.2.1.tar.gz"], - ) - - # Needed by fuzztest. Release 2023-08-31, current as of 2024-06-26 - http_archive( - name = "org_brotli", - sha256 = "e720a6ca29428b803f4ad165371771f5398faba397edf6778837a18599ea13ff", - strip_prefix = "brotli-1.1.0", - urls = ["https://github.com/google/brotli/archive/refs/tags/v1.1.0.tar.gz"], - ) - - # Needed by fuzztest. Commit from 2024-04-18, current as of 2024-06-26 - http_archive( - name = "highwayhash", - build_file = "@com_google_riegeli//third_party:highwayhash.BUILD", - sha256 = "d564c621618ef734e0ae68545f59526e97dfe4912612f80b2b8b9b31b9bb02b5", - strip_prefix = "highwayhash-f8381f3331d9c56a9792f9b4a35f61c41108c39e", - urls = ["https://github.com/google/highwayhash/archive/f8381f3331d9c56a9792f9b4a35f61c41108c39e.tar.gz"], - ) - - # Released 2024-06-07, current as of 2024-06-26. - 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", - }, - ) - # Used by xlscc. Tagged 2024-02-16 (note: release is lagging tag), current as of 2024-06-26 http_archive( name = "com_github_hlslibs_ac_types", @@ -245,16 +86,6 @@ 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-09-13, current as of 2024-10-16. ORTOOLS_VERSION = "9.11" http_archive( @@ -262,78 +93,12 @@ def load_external_repositories(): urls = ["https://github.com/google/or-tools/archive/refs/tags/v{tag}.tar.gz".format(tag = ORTOOLS_VERSION)], integrity = "sha256-9qC9W58wWKoagUt5jbXTk8Meycu2EDSGcomXtJqxJ7w=", 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-12-16, current as of 2024-12-17 - VERIBLE_TAG = "v0.0-3874-g4f3b8408" - http_archive( - name = "verible", - sha256 = "90cd9f3670ef001397524b33adc3bf6c0225a577916aaff085df030c661f058a", - strip_prefix = "verible-" + VERIBLE_TAG.lstrip("v"), - urls = ["https://github.com/chipsalliance/verible/archive/refs/tags/" + VERIBLE_TAG + ".tar.gz"], - # Verible already uses the canonical repository names - # used in the Bazel Central Registry - repo_mapping = { - "@abseil-cpp": "@com_google_absl", - "@re2": "@com_googlesource_code_re2", - }, - ) - - # Used by Verible; current as of 2024-12-17 - http_archive( - name = "nlohmann_json", - build_file = "@verible//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", - ], - ) - - # 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", + patches = ["//dependency_support:com_google_ortools/ortools-no-rulescc.patch"], + patch_args = ["-p1"], ) # HEAD as of 2024-10-11 on https://github.com/ryanhaining/cppitertools + # Filed https://github.com/ryanhaining/cppitertools/issues/107 to request new version to be tagged. http_archive( name = "cppitertools", urls = ["https://github.com/ryanhaining/cppitertools/archive/3f454640b491bc13b314deddbf53b3534f6d7f1f.zip"], @@ -342,10 +107,10 @@ def load_external_repositories(): ) # Used in C++ tests of the ZSTD Module - # Transitive dependency of fuzztest (required by riegeli in fuzztest workspace) # Version fdfb2aff released on 2024-07-31 # https://github.com/facebook/zstd/commit/fdfb2aff39dc498372d8c9e5f2330b692fea9794 # Updated 2024-08-08 + # Note: this exists in BCR, but TODO: include :decodecorpus http_archive( name = "zstd", sha256 = "9ace5a1b3c477048c6e034fe88d2abb5d1402ced199cae8e9eef32fdc32204df", diff --git a/dependency_support/protoc-gen-validate/no-rulescc.patch b/dependency_support/protoc-gen-validate/no-rulescc.patch new file mode 100644 index 00000000000..82feaad0514 --- /dev/null +++ b/dependency_support/protoc-gen-validate/no-rulescc.patch @@ -0,0 +1,12 @@ +diff --git a/validate/BUILD b/validate/BUILD +index a9d38c5..f633699 100644 +--- a/validate/BUILD ++++ b/validate/BUILD +@@ -1,6 +1,6 @@ + load("@com_google_protobuf//:protobuf.bzl", "py_proto_library") + load("@io_bazel_rules_go//proto:def.bzl", "go_proto_library") +-load("@rules_cc//cc:defs.bzl", "cc_library", "cc_proto_library") ++# load("@rules_cc//cc:defs.bzl", "cc_library", "cc_proto_library") + load("@rules_java//java:defs.bzl", "java_proto_library") + load("@rules_proto//proto:defs.bzl", "proto_library") + load("@io_bazel_rules_go//go:def.bzl", "go_library") diff --git a/dependency_support/pybind11_bazel/BUILD.bazel b/dependency_support/pybind11_bazel/BUILD.bazel deleted file mode 100644 index a1f21e73384..00000000000 --- 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 1c1ab9914cf..00000000000 --- 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/rules_hdl/workspace.bzl b/dependency_support/rules_hdl/workspace.bzl index d64882b5be2..9c1d3c801a8 100644 --- a/dependency_support/rules_hdl/workspace.bzl +++ b/dependency_support/rules_hdl/workspace.bzl @@ -58,9 +58,9 @@ def repo(): urls = ["https://github.com/jmillikin/rules_bison/releases/download/v0.2.2/rules_bison-v0.2.2.tar.xz"], ) - # Current as of 2024-10-01 - git_hash = "5023590057a3a83a98be7b6f3aa79eed47daf0e1" - archive_sha256 = "4dd1cf51573798da825717d8fbebdb390260d533b76fef908cbceb7bddea1302" + # Current as of 2025-01-29 + git_hash = "160115fe5353e8094917d620fc900014e0dbd956" + archive_sha256 = "a7c974d5e938d3fb8934e19a9f7ae9dd07f9863bf07c7804bb02b3d37e326785" maybe( http_archive, diff --git a/dependency_support/zlib/BUILD.bazel b/dependency_support/zlib/BUILD.bazel deleted file mode 100644 index f957489a3ba..00000000000 --- 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 cb849cdee05..00000000000 --- 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/fuzztest.bazelrc b/fuzztest.bazelrc index 00e06e06a1d..c5e70b9aed1 100644 --- a/fuzztest.bazelrc +++ b/fuzztest.bazelrc @@ -7,17 +7,11 @@ # And don't forget to add the following to your project's .bazelrc: # # try-import %workspace%/fuzztest.bazelrc - - ### Common options. # # Do not use directly. -# Compile and link with Address Sanitizer (ASAN). -build:fuzztest-common --linkopt=-fsanitize=address -build:fuzztest-common --copt=-fsanitize=address - -# Standard define for "ifdef-ing" any fuzz test specific code. +# Standard define for \"ifdef-ing\" any fuzz test specific code. build:fuzztest-common --copt=-DFUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION # In fuzz tests, we want to catch assertion violations even in optimized builds. @@ -26,12 +20,19 @@ build:fuzztest-common --copt=-UNDEBUG # Enable libc++ assertions. # See https://libcxx.llvm.org/UsingLibcxx.html#enabling-the-safe-libc-mode build:fuzztest-common --copt=-D_LIBCPP_ENABLE_ASSERTIONS=1 +### ASan (Address Sanitizer) build configuration. +# +# Use with: --config=asan - +build:asan --linkopt=-fsanitize=address +build:asan --copt=-fsanitize=address ### FuzzTest build configuration. # # Use with: --config=fuzztest +# +# Note that this configuration includes the ASan configuration. +build:fuzztest --config=asan build:fuzztest --config=fuzztest-common # Link statically. @@ -41,7 +42,38 @@ build:fuzztest --dynamic_mode=off # __has_feature(address_sanitizer) to know that we have an ASAN build even in # the uninstrumented runtime. build:fuzztest --copt=-DADDRESS_SANITIZER +# We apply coverage tracking instrumentation to everything but Centipede and the +# FuzzTest framework itself (including GoogleTest and GoogleMock). +build:fuzztest --copt=-fsanitize-coverage=inline-8bit-counters,trace-cmp,pc-table +build:fuzztest --per_file_copt=common/.*,fuzztest/.*,centipede/.*,-centipede/.*fuzz_target,googletest/.*,googlemock/.*@-fsanitize-coverage=0 +### Experimental FuzzTest build configuration. +# +# Use with: --config=fuzztest-experimental +# +# Use this instead of --config=fuzztest when building test binaries to run with +# Centipede. Eventually, this will be consolidated with --config=fuzztest. +# Note that this configuration doesn't include the ASan configuration. If you +# want to use both, you can use --config=fuzztest-experimental --config=asan. + +build:fuzztest-experimental --config=fuzztest-common +build:fuzztest-experimental --@com_google_fuzztest//fuzztest:centipede_integration + +# Generate line tables for debugging. +build:fuzztest-experimental --copt=-gline-tables-only +build:fuzztest-experimental --strip=never + +# Prevent memcmp & co from being inlined. +build:fuzztest-experimental --copt=-fno-builtin + +# Disable heap checking. +build:fuzztest-experimental --copt=-DHEAPCHECK_DISABLE + +# Link statically. +build:fuzztest-experimental --dynamic_mode=off -# We apply coverage tracking instrumentation to everything but the +# We apply coverage tracking instrumentation to everything but Centipede and the # FuzzTest framework itself (including GoogleTest and GoogleMock). -build:fuzztest --per_file_copt=+//,-fuzztest/.*,-centipede/.*,-googletest/.*,-googlemock/.*@-fsanitize-coverage=inline-8bit-counters,-fsanitize-coverage=trace-cmp,-fsanitize-coverage=pc-table +# TODO(b/374840534): Add -fsanitize-coverage=control-flow once we start building +# with clang 16+. +build:fuzztest-experimental --copt=-fsanitize-coverage=trace-pc-guard,pc-table,trace-loads,trace-cmp +build:fuzztest-experimental --per_file_copt=common/.*,fuzztest/.*,centipede/.*,-centipede/.*fuzz_target,googletest/.*,googlemock/.*@-fsanitize-coverage=0 diff --git a/xls/dev_tools/make-compilation-db.sh b/xls/dev_tools/make-compilation-db.sh index d65522e5bdd..8953528d779 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 - <