diff --git a/.bazelignore b/.bazelignore index df15ae758f1d..4020a028cb93 100644 --- a/.bazelignore +++ b/.bazelignore @@ -8,8 +8,5 @@ bazel-carbon-lang # See github_tools/MODULE.bazel. github_tools -# Used as part of repo patching. -third_party/boost_unordered - # Example Bazel project. examples/bazel diff --git a/MODULE.bazel b/MODULE.bazel index d52063f63e0e..e25d0d2c67cb 100644 --- a/MODULE.bazel +++ b/MODULE.bazel @@ -33,8 +33,10 @@ http_archive = use_repo_rule( bazel_dep(name = "abseil-cpp", version = "20260107.1") bazel_dep(name = "bazel_skylib", version = "1.9.0") +bazel_dep(name = "boost.unordered", version = "1.90.0.bcr.1") bazel_dep(name = "google_benchmark", version = "1.9.5") bazel_dep(name = "googletest", version = "1.17.0.bcr.2") +bazel_dep(name = "libpfm", version = "4.13.0") bazel_dep(name = "re2", version = "2025-11-05.bcr.1") bazel_dep(name = "rules_cc", version = "0.2.17") bazel_dep(name = "rules_pkg", version = "1.2.0") @@ -42,25 +44,6 @@ bazel_dep(name = "rules_shell", version = "0.6.1") bazel_dep(name = "tcmalloc", version = "0.0.0-20250927-12f2552") bazel_dep(name = "tree-sitter-bazel", version = "0.26.5") -# The registry only has an old version. We use that here to avoid a miss but -# override it with a newer version. -bazel_dep(name = "libpfm", version = "4.11.0") - -libpfm_version = "4.13.0" - -# The official site is https://perfmon2.sourceforge.net/, but SourceForge makes -# it difficult to download from bazel. On GitHub action runners, -# https://git.code.sf.net/p/perfmon2/libpfm4 seems to be blocked. As a -# consequence, use a mirror. -archive_override( - module_name = "libpfm", - integrity = "sha256-sGBx1+UoQCplBCc+pwA1Tr/PS2L/4jnLZHH82wSuPz0=", - patch_strip = 1, - patches = ["@//bazel/libpfm:0001-Introduce-a-simple-native-Bazel-build.patch"], - strip_prefix = "libpfm4-{0}".format(libpfm_version), - urls = ["https://github.com/wcohen/libpfm4/archive/v{0}.tar.gz".format(libpfm_version)], -) - bazel_dep(name = "bazel_clang_tidy", dev_dependency = True) git_override( module_name = "bazel_clang_tidy", @@ -85,17 +68,6 @@ git_override( remote = "https://github.com/hedronvision/bazel-compile-commands-extractor.git", ) -# TODO: Switch to boost.unordered in BCR. -boost_unordered_version = "1.88.0" - -http_archive( - name = "boost_unordered", - build_file = "@//:third_party/boost_unordered/BUILD.bazel", - integrity = "sha256-a5ydXEQCspPhFmCD9vNa3JUIVeitbodEYaJhfOSO8no=", - strip_prefix = "boost_unordered-{0}".format(boost_unordered_version), - urls = ["https://github.com/MikePopoloski/boost_unordered/archive/v{0}.tar.gz".format(boost_unordered_version)], -) - # Required for llvm-project. bazel_dep(name = "platforms", version = "1.0.0") bazel_dep(name = "protobuf", version = "34.0.bcr.1", repo_name = "com_google_protobuf") diff --git a/MODULE.bazel.lock b/MODULE.bazel.lock index 5c73eb751248..250b72857b01 100644 --- a/MODULE.bazel.lock +++ b/MODULE.bazel.lock @@ -65,6 +65,26 @@ "https://bcr.bazel.build/modules/bazel_skylib/1.8.2/MODULE.bazel": "69ad6927098316848b34a9142bcc975e018ba27f08c4ff403f50c1b6e646ca67", "https://bcr.bazel.build/modules/bazel_skylib/1.9.0/MODULE.bazel": "72997b29dfd95c3fa0d0c48322d05590418edef451f8db8db5509c57875fb4b7", "https://bcr.bazel.build/modules/bazel_skylib/1.9.0/source.json": "7ad77c1e8c1b84222d9b3f3cae016a76639435744c19330b0b37c0a3c9da7dc0", + "https://bcr.bazel.build/modules/boost.assert/1.90.0.bcr.1/MODULE.bazel": "82fa42de969959b0eb59b03b528b6ed6fdc130429766f980f0bda20a7efd09bb", + "https://bcr.bazel.build/modules/boost.assert/1.90.0.bcr.1/source.json": "276a47c8c07761df24435e276ec6ed0ac859839ae9d62259787d222e022d23e2", + "https://bcr.bazel.build/modules/boost.config/1.90.0.bcr.1/MODULE.bazel": "c14d7f8f9d6ba5d13383df5dabe296dcfef3925b398158b71c1c4080e2a14365", + "https://bcr.bazel.build/modules/boost.config/1.90.0.bcr.1/source.json": "44b2941a2e656fd2c3747576ddd1e44e4d55c5d3ef5a22f0231f35c8dded3051", + "https://bcr.bazel.build/modules/boost.container_hash/1.90.0.bcr.1/MODULE.bazel": "99905e56c4de3090bd802393e9a683fcf885f9ef9a7add79c05333de1c41ccf7", + "https://bcr.bazel.build/modules/boost.container_hash/1.90.0.bcr.1/source.json": "9403da9bcc0f1600e569d7921aede5505a4f8407541597b00dcfd116ffb30580", + "https://bcr.bazel.build/modules/boost.core/1.90.0.bcr.1/MODULE.bazel": "c94d17f2da1e7557046730a5647e06943e4e0fc10d6537e3656dbd23f8a0a573", + "https://bcr.bazel.build/modules/boost.core/1.90.0.bcr.1/source.json": "5b3b6b9c6ea8e38e63d3b1a92370902a9ba78a4efd6c23df3c538d719a200cbe", + "https://bcr.bazel.build/modules/boost.describe/1.90.0.bcr.1/MODULE.bazel": "ee5316a4d469c5a272e90b6a1c6f8185fb842a2a6401e970da159b08b4bdcc6a", + "https://bcr.bazel.build/modules/boost.describe/1.90.0.bcr.1/source.json": "5ca72db73619c8915d030d88f7bcff970211daee4d7fa49a99ac3a510b507355", + "https://bcr.bazel.build/modules/boost.mp11/1.90.0.bcr.1/MODULE.bazel": "9180b001b76e786d764f40b9cf9f3cffc92fd58b36fe7680b1f481e8e9991d2a", + "https://bcr.bazel.build/modules/boost.mp11/1.90.0.bcr.1/source.json": "5720af0062e685970e3adcc72e925445171ba2ff192cde0b68c53031d25fa7f4", + "https://bcr.bazel.build/modules/boost.predef/1.90.0.bcr.1/MODULE.bazel": "0c92fea5e1d63e301f7bb81763a5bfbb5f27204d6b6127e09ae23ae7d1bb3eaa", + "https://bcr.bazel.build/modules/boost.predef/1.90.0.bcr.1/source.json": "f32e27769816c6de69925c5995733adf8e176e5a281d23c079c64aafae532e2f", + "https://bcr.bazel.build/modules/boost.throw_exception/1.90.0.bcr.1/MODULE.bazel": "57242f92eecc485f09b07a8a1c8e2c7a6bf211808abb4599eec6fdbe875bb33f", + "https://bcr.bazel.build/modules/boost.throw_exception/1.90.0.bcr.1/source.json": "1889e091be52f80ebb436305663c64bc631527445edb153e622f6e22010e6c9e", + "https://bcr.bazel.build/modules/boost.unordered/1.90.0.bcr.1/MODULE.bazel": "4f7e455c70e9b3c57b840307aa77224011c10045082b45c0e46a1f96fce141ef", + "https://bcr.bazel.build/modules/boost.unordered/1.90.0.bcr.1/source.json": "61fb5bd89e2f70131f4afb459e61f14faa5f0b6d5cbbfc0a5cc1e0bee6e6fece", + "https://bcr.bazel.build/modules/boost/1.90.0.bcr.1/MODULE.bazel": "2f0a26d9a55a46017cf1f8a7895e49250f11306486419b002355f85ab595390f", + "https://bcr.bazel.build/modules/boost/1.90.0.bcr.1/source.json": "3ba95d0dcf35d52e907cc82d460a27024270cd684641912e550bfb4102da1a9e", "https://bcr.bazel.build/modules/buildifier_prebuilt/7.3.1/MODULE.bazel": "537faf0ad9f5892910074b8e43b4c91c96f1d5d86b6ed04bdbe40cf68aa48b68", "https://bcr.bazel.build/modules/buildifier_prebuilt/8.2.1.1/MODULE.bazel": "2e2e306add04b7c7cd21e73c9293dcbd7528a08a84338e919036f402eb6b1e2e", "https://bcr.bazel.build/modules/buildifier_prebuilt/8.2.1.1/source.json": "4c86fd3a384a09613c2213fb1f71562d6d70471977e6e81173e6625fd6ce53bc", @@ -95,6 +115,10 @@ "https://bcr.bazel.build/modules/jsoncpp/1.9.5/MODULE.bazel": "31271aedc59e815656f5736f282bb7509a97c7ecb43e927ac1a37966e0578075", "https://bcr.bazel.build/modules/jsoncpp/1.9.6/MODULE.bazel": "2f8d20d3b7d54143213c4dfc3d98225c42de7d666011528dc8fe91591e2e17b0", "https://bcr.bazel.build/modules/jsoncpp/1.9.6/source.json": "a04756d367a2126c3541682864ecec52f92cdee80a35735a3cb249ce015ca000", + "https://bcr.bazel.build/modules/libpfm/4.11.0.bcr.1/MODULE.bazel": "e5362dadc90aab6724c83a2cc1e67cbed9c89a05d97fb1f90053c8deb1e445c8", + "https://bcr.bazel.build/modules/libpfm/4.11.0/MODULE.bazel": "45061ff025b301940f1e30d2c16bea596c25b176c8b6b3087e92615adbd52902", + "https://bcr.bazel.build/modules/libpfm/4.13.0/MODULE.bazel": "6f2fcac49a2ebd660573aa8075654d84a4904d3a8a7d416f3bde3678573a7244", + "https://bcr.bazel.build/modules/libpfm/4.13.0/source.json": "d77a2fd45f92dcebdd864a3c2a05f28506a4f2f71ce15f85333d9ce5b9e29742", "https://bcr.bazel.build/modules/nlohmann_json/3.6.1/MODULE.bazel": "6f7b417dcc794d9add9e556673ad25cb3ba835224290f4f848f8e2db1e1fca74", "https://bcr.bazel.build/modules/package_metadata/0.0.2/MODULE.bazel": "fb8d25550742674d63d7b250063d4580ca530499f045d70748b1b142081ebb92", "https://bcr.bazel.build/modules/package_metadata/0.0.2/source.json": "e53a759a72488d2c0576f57491ef2da0cf4aab05ac0997314012495935531b73", diff --git a/bazel/libpfm/0001-Introduce-a-simple-native-Bazel-build.patch b/bazel/libpfm/0001-Introduce-a-simple-native-Bazel-build.patch deleted file mode 100644 index a61b4c397497..000000000000 --- a/bazel/libpfm/0001-Introduce-a-simple-native-Bazel-build.patch +++ /dev/null @@ -1,133 +0,0 @@ -From 04fb28b5673d29a8c38519845c87f4c00c76e9cf Mon Sep 17 00:00:00 2001 -From: Chandler Carruth -Date: Sat, 13 Jan 2024 02:15:19 -0800 -Subject: [PATCH] Introduce a simple native Bazel build. - ---- - BUILD.bazel | 84 +++++++++++++++++++++++++++++++++++++++++++++++++ - MODULE.bazel | 10 ++++++ - WORKSPACE.bazel | 5 +++ - 3 files changed, 99 insertions(+) - create mode 100644 BUILD.bazel - create mode 100644 MODULE.bazel - create mode 100644 WORKSPACE.bazel - -diff --git a/BUILD.bazel b/BUILD.bazel -new file mode 100644 -index 0000000..427c854 ---- /dev/null -+++ b/BUILD.bazel -@@ -0,0 +1,84 @@ -+# Part of the Carbon Language project, under the Apache License v2.0 with LLVM -+# Exceptions. See /LICENSE for license information. -+# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -+ -+load("@rules_cc//cc:defs.bzl", "cc_library") -+ -+package(default_visibility = ["//visibility:public"]) -+ -+aarch64_srcs = [ -+ "lib/pfmlib_arm_perf_event.c", -+ "lib/pfmlib_arm.c", -+ "lib/pfmlib_arm_armv8.c", -+ "lib/pfmlib_arm_armv9.c", -+ "lib/pfmlib_tx2_unc_perf_event.c", -+ "lib/pfmlib_kunpeng_unc_perf_event.c", -+ "lib/pfmlib_arm_priv.h", -+ "lib/events/arm_cortex_a57_events.h", -+ "lib/events/arm_cortex_a53_events.h", -+ "lib/events/arm_xgene_events.h", -+ "lib/events/arm_cavium_tx2_events.h", -+ "lib/events/arm_marvell_tx2_unc_events.h", -+ "lib/events/arm_fujitsu_a64fx_events.h", -+ "lib/events/arm_neoverse_n1_events.h", -+ "lib/events/arm_neoverse_n2_events.h", -+ "lib/events/arm_neoverse_v1_events.h", -+ "lib/events/arm_neoverse_v2_events.h", -+ "lib/events/arm_hisilicon_kunpeng_events.h", -+ "lib/events/arm_hisilicon_kunpeng_unc_events.h", -+] -+ -+x86_64_srcs = [ -+ "lib/pfmlib_amd64_priv.h", -+] + glob( -+ [ -+ "lib/pfmlib_amd64*.c", -+ "lib/pfmlib_intel*.c", -+ "lib/pfmlib_intel*_priv.h", -+ "lib/events/amd64_events_*.h", -+ "lib/events/intel_*_events.h", -+ ], -+ exclude = [ -+ # 32-bit CPUs -+ "lib/pfmlib_intel_coreduo.c", -+ "lib/pfmlib_intel_p6.c", -+ ], -+) -+ -+cc_library( -+ name = "libpfm", -+ srcs = [ -+ "lib/events/perf_events.h", -+ "lib/pfmlib_common.c", -+ "lib/pfmlib_perf_event.c", -+ "lib/pfmlib_perf_event_pmu.c", -+ "lib/pfmlib_perf_event_priv.h", -+ "lib/pfmlib_perf_event_raw.c", -+ "lib/pfmlib_priv.h", -+ ] + select({ -+ "@platforms//cpu:aarch64": aarch64_srcs, -+ "@platforms//cpu:x86_64": x86_64_srcs, -+ }), -+ hdrs = glob(["include/perfmon/*.h"]), -+ copts = [ -+ "-DHAS_OPENAT", -+ "-D_REENTRANT", -+ "-I.", -+ "-fvisibility=hidden", -+ ] + select({ -+ "@platforms//cpu:x86_64": [ -+ "-DCONFIG_PFMLIB_ARCH_X86", -+ "-DCONFIG_PFMLIB_ARCH_X86_64", -+ ], -+ "//conditions:default": [], -+ }), -+ strip_include_prefix = "include", -+ target_compatible_with = select({ -+ # This library only makes sense on Linux, and we only include support -+ # for building on AArch64 and x86-64. Other CPUs can be added to this -+ # list if build support is added for them. -+ "@platforms//cpu:aarch64": ["@platforms//os:linux"], -+ "@platforms//cpu:x86_64": ["@platforms//os:linux"], -+ "//conditions:default": ["@platforms//:incompatible"], -+ }), -+) -diff --git a/MODULE.bazel b/MODULE.bazel -new file mode 100644 -index 0000000..c901cbe ---- /dev/null -+++ b/MODULE.bazel -@@ -0,0 +1,10 @@ -+# Part of the Carbon Language project, under the Apache License v2.0 with LLVM -+# Exceptions. See /LICENSE for license information. -+# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -+ -+"""Bazel modules.""" -+ -+module(name = "libpfm") -+ -+bazel_dep(name = "rules_cc", version = "0.0.9") -+bazel_dep(name = "platforms", version = "0.0.8") -diff --git a/WORKSPACE.bazel b/WORKSPACE.bazel -new file mode 100644 -index 0000000..9aad57c ---- /dev/null -+++ b/WORKSPACE.bazel -@@ -0,0 +1,5 @@ -+# Part of the Carbon Language project, under the Apache License v2.0 with LLVM -+# Exceptions. See /LICENSE for license information. -+# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -+ -+# See `MODULE.bazel` for details. --- -2.43.0 diff --git a/bazel/libpfm/BUILD b/bazel/libpfm/BUILD deleted file mode 100644 index 8fe7e2c41437..000000000000 --- a/bazel/libpfm/BUILD +++ /dev/null @@ -1,9 +0,0 @@ -# Part of the Carbon Language project, under the Apache License v2.0 with LLVM -# Exceptions. See /LICENSE for license information. -# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception - -package(default_visibility = ["//visibility:public"]) - -exports_files(glob([ - "*.patch", -])) diff --git a/common/BUILD b/common/BUILD index ca417f1e6b0b..c438381f5ff5 100644 --- a/common/BUILD +++ b/common/BUILD @@ -473,7 +473,7 @@ cc_binary( "//testing/base:benchmark_main", "@abseil-cpp//absl/container:flat_hash_map", "@abseil-cpp//absl/random", - "@boost_unordered", + "@boost.unordered", "@google_benchmark//:benchmark", "@llvm-project//llvm:Support", ], @@ -577,7 +577,7 @@ cc_library( "@abseil-cpp//absl/base:no_destructor", "@abseil-cpp//absl/hash", "@abseil-cpp//absl/random", - "@boost_unordered", + "@boost.unordered", "@google_benchmark//:benchmark", "@llvm-project//llvm:Support", ], diff --git a/scripts/BUILD b/scripts/BUILD index ede46e63a757..7540eee3ee07 100644 --- a/scripts/BUILD +++ b/scripts/BUILD @@ -16,12 +16,12 @@ cc_library( name = "deps_for_clangd_tidy", srcs = ["deps_for_clangd_tidy.cpp"], deps = [ - # `@boost_unordered` uses `strip_prefix`, which results in + # `@boost.unordered` uses `strip_prefix`, which results in # `_virtual_includes` being part of the `compile_commands.json`. To # support tools like `clangd-tidy`, this is intended to generate that directory. # - # For example: - # bazel-out//bin/external/+_repo_rules+boost_unordered/_virtual_includes/boost_unordered - "@boost_unordered", + # `@boost.unordered` uses `strip_prefix`, which results in + # bazel-out//bin/external/+_repo_rules+boost.unordered/_virtual_includes/boost.unordered + "@boost.unordered", ], ) diff --git a/scripts/fix_cc_deps.py b/scripts/fix_cc_deps.py index ee9a24af9391..2b2b5bd1c2f4 100755 --- a/scripts/fix_cc_deps.py +++ b/scripts/fix_cc_deps.py @@ -59,10 +59,9 @@ EXTERNAL_REPOS: dict[str, ExternalRepo] = { ":gtest", use_system_include=True, ), - # All of the `boost_unordered` headers are in a single rule. - "@boost_unordered": ExternalRepo( + "@boost.unordered": ExternalRepo( lambda x: re.sub("^(.*:include)/", "", x), - ":boost_unordered", + ":boost.unordered", use_system_include=True, ), } diff --git a/scripts/query_module_versions.py b/scripts/query_module_versions.py index 57b1934d88ef..c365800ee98d 100755 --- a/scripts/query_module_versions.py +++ b/scripts/query_module_versions.py @@ -33,48 +33,6 @@ def _query_bazel_deps(module_text: str) -> None: print(f" - {pkg}: Error {e}") -def _query_archive_overrides(module_text: str) -> None: - """Query Git for `archive_override` rule versions.""" - archive_re = re.compile( - r"archive_override\(\s*" - r'module_name\s*=\s*"([^"]+)".*?' - r'urls\s*=\s*\["[^"]*?github\.com/([^/]+/[^/]+?)/archive', - re.DOTALL, - ) - github_tags = sorted( - [ - (m[1], f"https://github.com/{m[2]}.git") - for m in archive_re.finditer(module_text) - ] - ) - - print("- GitHub Tag:") - for pkg, url in github_tags: - try: - output = subprocess.check_output( - ["git", "ls-remote", "--tags", url], text=True - ) - # Find the latest tag by sorting them (excluding the ^{} - # dereferenced tags). - tags = [ - line.split("/")[-1] - for line in output.splitlines() - if not line.endswith("^{}") - ] - - # Simple version sort (git-style) using split by common delimiters. - tags.sort( - key=lambda tag: [ - int(x) if x.isdigit() else x - for x in re.split(r"(\d+)", tag) - ] - ) - latest_tag = tags[-1] if tags else "Unknown" - print(f" - {pkg}: {latest_tag}") - except Exception as e: - print(f" - {pkg}: Error {e}") - - def _query_git_overrides(module_text: str) -> None: """Query GitHub for `git_override` rule versions.""" git_re = re.compile( @@ -101,7 +59,6 @@ def main() -> None: module_text = f.read() _query_bazel_deps(module_text) - _query_archive_overrides(module_text) _query_git_overrides(module_text) diff --git a/third_party/boost_unordered/BUILD.bazel b/third_party/boost_unordered/BUILD.bazel deleted file mode 100644 index 1b70fed62104..000000000000 --- a/third_party/boost_unordered/BUILD.bazel +++ /dev/null @@ -1,14 +0,0 @@ -# Part of the Carbon Language project, under the Apache License v2.0 with LLVM -# Exceptions. See /LICENSE for license information. -# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception - -load("@rules_cc//cc:defs.bzl", "cc_library") - -exports_files(["LICENSE"]) - -cc_library( - name = "boost_unordered", - hdrs = glob(["include/boost/**/*.hpp"]), - strip_include_prefix = "include", - visibility = ["//visibility:public"], -)