MODULE.bazel 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172
  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. `MODULE.bazel` is changing.
  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 `bazel` version doesn't match the version used to generate the
  13. `MODULE.bazel.lock`.
  14. - Bazel releases can change the lock file contents.
  15. - We use Bazelisk in order to keep everyone using the same version:
  16. https://bazel.build/install/bazelisk
  17. - Developers are encouraged to alias `bazel` to `bazelisk` for
  18. ease-of-use; some setups, like Homebrew, will include that with a
  19. `bazelisk` install.
  20. - Contribution tools documentation includes `bazelisk` setup:
  21. https://github.com/carbon-language/carbon-lang/blob/trunk/docs/project/contribution_tools.md
  22. - Make sure `bazelisk --version` (or `bazel --version`) matches the
  23. version in `.bazeliskrc`.
  24. 3. The host platform hasn't yet been added to the lock file.
  25. - Platforms tested with GitHub actions are kept up-to-date. Other
  26. platforms may fall out of sync due to `bazel` or dependency changes,
  27. and should be updated with a PR the same way a platform is added.
  28. - Running `bazel mod deps` provides a canonical update to
  29. `MODULE.bazel.lock`; create a PR with those changes in order to include
  30. the host platform.
  31. """
  32. module(name = "carbon")
  33. http_archive = use_repo_rule(
  34. "@bazel_tools//tools/build_defs/repo:http.bzl",
  35. "http_archive",
  36. )
  37. bazel_dep(name = "bazel_skylib", version = "1.7.1")
  38. bazel_dep(name = "rules_pkg", version = "0.10.1")
  39. bazel_dep(name = "abseil-cpp", version = "20240116.2")
  40. bazel_dep(name = "re2", version = "2024-06-01")
  41. bazel_dep(name = "googletest", version = "1.14.0.bcr.1")
  42. bazel_dep(name = "google_benchmark", version = "1.8.4")
  43. # The registry only has an old version. We use that here to avoid a miss but
  44. # override it with a newer version.
  45. bazel_dep(name = "libpfm", version = "4.11.0")
  46. libpfm_version = "4.13.0"
  47. archive_override(
  48. module_name = "libpfm",
  49. integrity = "sha256-0YuXdkx1VSjBBR03bjNUXQ62DG6/hWgENoE/pbBMw9E=",
  50. patch_strip = 1,
  51. patches = ["@//bazel/libpfm:0001-Introduce-a-simple-native-Bazel-build.patch"],
  52. strip_prefix = "libpfm-{0}".format(libpfm_version),
  53. urls = ["https://sourceforge.net/projects/perfmon2/files/libpfm4/libpfm-{0}.tar.gz".format(libpfm_version)],
  54. )
  55. # The registry has a snapshot, but upstream is active and not regularly marking
  56. # releases. We start with the BCR snapshot to avoid a miss and then override it
  57. # with a more recent commit.
  58. bazel_dep(name = "tcmalloc", version = "0.0.0-20240411-5ed309d", dev_dependency = True)
  59. git_override(
  60. module_name = "tcmalloc",
  61. # HEAD as of 2024-07-14.
  62. commit = "923df94c922e0cd2d0512c1662d374f63c2c0c96",
  63. remote = "https://github.com/google/tcmalloc.git",
  64. )
  65. bazel_dep(name = "rules_bison", version = "0.2.2")
  66. bazel_dep(name = "rules_flex", version = "0.2.1")
  67. bazel_dep(name = "rules_m4", version = "0.2.3")
  68. bazel_dep(name = "rules_cc", version = "0.0.9")
  69. bazel_dep(name = "rules_proto", version = "6.0.2")
  70. bazel_dep(name = "protobuf", version = "27.1")
  71. libprotobuf_mutator_version = "1.3"
  72. http_archive(
  73. name = "com_google_libprotobuf_mutator",
  74. build_file = "@//:third_party/libprotobuf_mutator/BUILD.txt",
  75. sha256 = "1ee3473a6b0274494fce599539605bb19305c0efadc62b58d645812132c31baa",
  76. strip_prefix = "libprotobuf-mutator-{0}".format(libprotobuf_mutator_version),
  77. urls = ["https://github.com/google/libprotobuf-mutator/archive/v{0}.tar.gz".format(libprotobuf_mutator_version)],
  78. )
  79. bazel_dep(name = "bazel_clang_tidy", dev_dependency = True)
  80. git_override(
  81. module_name = "bazel_clang_tidy",
  82. # HEAD as of 2024-03-12.
  83. commit = "bff5c59c843221b05ef0e37cef089ecc9d24e7da",
  84. remote = "https://github.com/erenon/bazel_clang_tidy.git",
  85. )
  86. bazel_cc_toolchain = use_extension(
  87. "//bazel/cc_toolchains:clang_configuration.bzl",
  88. "clang_toolchain_extension",
  89. )
  90. use_repo(bazel_cc_toolchain, "bazel_cc_toolchain")
  91. register_toolchains("@bazel_cc_toolchain//:all")
  92. bazel_dep(name = "hedron_compile_commands", dev_dependency = True)
  93. git_override(
  94. module_name = "hedron_compile_commands",
  95. # HEAD as of 2024-03-12.
  96. commit = "204aa593e002cbd177d30f11f54cff3559110bb9",
  97. remote = "https://github.com/hedronvision/bazel-compile-commands-extractor.git",
  98. )
  99. boost_unordered_version = "1.85.0"
  100. http_archive(
  101. name = "boost_unordered",
  102. build_file = "@//:third_party/boost_unordered/BUILD.bazel",
  103. integrity = "sha256-2dQ4IQH/xFiK1iWCkrMYLeR8zsSQqGchKOdTuf1u0zI=",
  104. strip_prefix = "boost_unordered-{0}".format(boost_unordered_version),
  105. urls = ["https://github.com/MikePopoloski/boost_unordered/archive/v{0}.tar.gz".format(boost_unordered_version)],
  106. )
  107. # Required for llvm-project.
  108. bazel_dep(name = "platforms", version = "0.0.10")
  109. bazel_dep(name = "zlib", version = "1.3.1.bcr.3", repo_name = "llvm_zlib")
  110. bazel_dep(name = "zstd", version = "1.5.6", repo_name = "llvm_zstd")
  111. ###############################################################################
  112. # llvm-project
  113. ###############################################################################
  114. # We pin to specific upstream commits and try to track top-of-tree reasonably
  115. # closely rather than pinning to a specific release.
  116. # HEAD as of 2024-08-09.
  117. llvm_project_version = "4c5ef6690040383956461828457ac27f7f912edb"
  118. # Load a repository for the raw llvm-project, pre-overlay.
  119. http_archive(
  120. name = "llvm-raw",
  121. build_file_content = "# empty",
  122. patch_args = ["-p1"],
  123. patches = [
  124. "@carbon//bazel/llvm_project:0001_Patch_for_mallinfo2_when_using_Bazel_build_system.patch",
  125. "@carbon//bazel/llvm_project:0002_Added_Bazel_build_for_compiler_rt_fuzzer.patch",
  126. ],
  127. sha256 = "a30da7822f5307bc0aca8c497ffdd6369e3877186e87501e2ac1f3ec5ed1c0b7",
  128. strip_prefix = "llvm-project-{0}".format(llvm_project_version),
  129. urls = ["https://github.com/llvm/llvm-project/archive/{0}.tar.gz".format(llvm_project_version)],
  130. )
  131. # Apply the overlay to produce llvm-project.
  132. llvm_project = use_extension(
  133. "//bazel/llvm_project:llvm_project.bzl",
  134. "llvm_project",
  135. )
  136. use_repo(llvm_project, "llvm-project")
  137. ###############################################################################
  138. # Python
  139. ###############################################################################
  140. bazel_dep(name = "rules_python", version = "0.33.1")
  141. python = use_extension("@rules_python//python/extensions:python.bzl", "python")
  142. python.toolchain(
  143. python_version = "3.11",
  144. )
  145. use_repo(python, "python_versions")