MODULE.bazel 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177
  1. # Part of the Carbon Language project, under the Apache License v2.0 with LLVM
  2. # Exceptions. See /LICENSE for license information.
  3. # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  4. """Bazel modules.
  5. `MODULE.bazel.lock` may change locally when `bazel` is executed. This means one
  6. of:
  7. 1. An input is changing, typically `MODULE.bazel` or `.bazelversion`.
  8. - Running `bazel mod deps` provides a canonical update to
  9. `MODULE.bazel.lock`; include the changes.
  10. - GitHub test actions may also identify platform-specific lockfile
  11. updates.
  12. 2. The host platform hasn't yet been added to the lock file.
  13. - Platforms tested with GitHub actions are kept up-to-date. Other
  14. platforms may fall out of sync due to `bazel` or dependency changes,
  15. and should be updated with a PR the same way a platform is added.
  16. - Running `bazel mod deps` provides a canonical update to
  17. `MODULE.bazel.lock`; create a PR with those changes in order to include
  18. the host platform.
  19. For updates, run `scripts/query_module_versions.py` to list the latest package
  20. versions.
  21. """
  22. module(name = "carbon")
  23. http_archive = use_repo_rule(
  24. "@bazel_tools//tools/build_defs/repo:http.bzl",
  25. "http_archive",
  26. )
  27. bazel_dep(name = "abseil-cpp", version = "20260107.1")
  28. bazel_dep(name = "bazel_skylib", version = "1.9.0")
  29. bazel_dep(name = "google_benchmark", version = "1.9.5")
  30. bazel_dep(name = "googletest", version = "1.17.0.bcr.2")
  31. bazel_dep(name = "re2", version = "2025-11-05.bcr.1")
  32. bazel_dep(name = "rules_cc", version = "0.2.17")
  33. bazel_dep(name = "rules_pkg", version = "1.2.0")
  34. bazel_dep(name = "rules_shell", version = "0.6.1")
  35. bazel_dep(name = "tcmalloc", version = "0.0.0-20250927-12f2552")
  36. bazel_dep(name = "tree-sitter-bazel", version = "0.26.5")
  37. # The registry only has an old version. We use that here to avoid a miss but
  38. # override it with a newer version.
  39. bazel_dep(name = "libpfm", version = "4.11.0")
  40. libpfm_version = "4.13.0"
  41. # The official site is https://perfmon2.sourceforge.net/, but SourceForge makes
  42. # it difficult to download from bazel. On GitHub action runners,
  43. # https://git.code.sf.net/p/perfmon2/libpfm4 seems to be blocked. As a
  44. # consequence, use a mirror.
  45. archive_override(
  46. module_name = "libpfm",
  47. integrity = "sha256-sGBx1+UoQCplBCc+pwA1Tr/PS2L/4jnLZHH82wSuPz0=",
  48. patch_strip = 1,
  49. patches = ["@//bazel/libpfm:0001-Introduce-a-simple-native-Bazel-build.patch"],
  50. strip_prefix = "libpfm4-{0}".format(libpfm_version),
  51. urls = ["https://github.com/wcohen/libpfm4/archive/v{0}.tar.gz".format(libpfm_version)],
  52. )
  53. bazel_dep(name = "bazel_clang_tidy", dev_dependency = True)
  54. git_override(
  55. module_name = "bazel_clang_tidy",
  56. # HEAD as of 2026-01-28.
  57. commit = "c4d35e0d0b838309358e57a2efed831780f85cd0",
  58. remote = "https://github.com/erenon/bazel_clang_tidy.git",
  59. )
  60. bazel_cc_toolchain = use_extension(
  61. "//bazel/cc_toolchains:clang_configuration.bzl",
  62. "clang_toolchain_extension",
  63. )
  64. use_repo(bazel_cc_toolchain, "bazel_cc_toolchain")
  65. register_toolchains("@bazel_cc_toolchain//:all")
  66. bazel_dep(name = "hedron_compile_commands", dev_dependency = True)
  67. git_override(
  68. module_name = "hedron_compile_commands",
  69. # HEAD as of 2026-01-28.
  70. commit = "abb61a688167623088f8768cc9264798df6a9d10",
  71. remote = "https://github.com/hedronvision/bazel-compile-commands-extractor.git",
  72. )
  73. # TODO: Switch to boost.unordered in BCR.
  74. boost_unordered_version = "1.88.0"
  75. http_archive(
  76. name = "boost_unordered",
  77. build_file = "@//:third_party/boost_unordered/BUILD.bazel",
  78. integrity = "sha256-a5ydXEQCspPhFmCD9vNa3JUIVeitbodEYaJhfOSO8no=",
  79. strip_prefix = "boost_unordered-{0}".format(boost_unordered_version),
  80. urls = ["https://github.com/MikePopoloski/boost_unordered/archive/v{0}.tar.gz".format(boost_unordered_version)],
  81. )
  82. # Required for llvm-project.
  83. bazel_dep(name = "platforms", version = "1.0.0")
  84. bazel_dep(name = "protobuf", version = "34.0.bcr.1", repo_name = "com_google_protobuf")
  85. bazel_dep(name = "zlib-ng", version = "2.0.7", repo_name = "llvm_zlib")
  86. bazel_dep(name = "zstd", version = "1.5.7.bcr.1", repo_name = "llvm_zstd")
  87. ###############################################################################
  88. # llvm-project
  89. ###############################################################################
  90. # We pin to specific upstream commits and try to track top-of-tree reasonably
  91. # closely rather than pinning to a specific release.
  92. # HEAD as of 2026-02-12.
  93. llvm_project_version = "b20d7d0278059735bb8eb538ac51e13b58895c1a"
  94. # Load a repository for the raw llvm-project, pre-overlay.
  95. http_archive(
  96. name = "llvm-raw",
  97. build_file_content = "# empty",
  98. integrity = "sha256-sRZjS3KippWoaVcr1mWtJ1kFZ+jrjb/KoNkzh+N8HOM=",
  99. patch_args = ["-p1"],
  100. patches = [
  101. "@carbon//bazel/llvm_project:0001_Patch_for_mallinfo2_when_using_Bazel_build_system.patch",
  102. "@carbon//bazel/llvm_project:0002_Added_Bazel_build_for_compiler_rt_fuzzer.patch",
  103. "@carbon//bazel/llvm_project:0004_Introduce_basic_sources_exporting_for_libunwind.patch",
  104. "@carbon//bazel/llvm_project:0005_Introduce_basic_sources_exporting_for_libcxx_and_libcxxabi.patch",
  105. "@carbon//bazel/llvm_project:0009_Introduce_starlark_exporting_compiler-rt_build_information.patch",
  106. ],
  107. strip_prefix = "llvm-project-{0}".format(llvm_project_version),
  108. urls = ["https://github.com/llvm/llvm-project/archive/{0}.tar.gz".format(llvm_project_version)],
  109. )
  110. # Apply the overlay to produce llvm-project.
  111. llvm_project = use_extension(
  112. "//bazel/llvm_project:llvm_project.bzl",
  113. "llvm_project",
  114. )
  115. use_repo(llvm_project, "llvm-project")
  116. ###############################################################################
  117. # Python
  118. ###############################################################################
  119. bazel_dep(name = "rules_python", version = "1.9.0")
  120. python = use_extension("@rules_python//python/extensions:python.bzl", "python")
  121. python.toolchain(
  122. python_version = "3.11",
  123. )
  124. use_repo(python, "python_versions")
  125. ###############################################################################
  126. # Bazel integration testing
  127. ###############################################################################
  128. bazel_dep(
  129. name = "rules_bazel_integration_test",
  130. version = "0.37.1",
  131. dev_dependency = True,
  132. )
  133. # We test against our current Bazel version, the latest release, and the latest
  134. # release candidate.
  135. bazel_binaries = use_extension(
  136. "@rules_bazel_integration_test//:extensions.bzl",
  137. "bazel_binaries",
  138. dev_dependency = True,
  139. )
  140. bazel_binaries.download(version_file = "//:.bazelversion")
  141. bazel_binaries.download(version = "latest")
  142. bazel_binaries.download(version = "last_rc")
  143. use_repo(
  144. bazel_binaries,
  145. "bazel_binaries",
  146. "bazel_binaries_bazelisk",
  147. "build_bazel_bazel_.bazelversion",
  148. "build_bazel_bazel_last_rc",
  149. "build_bazel_bazel_latest",
  150. )