MODULE.bazel 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153
  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. If `MODULE.bazel.lock` changes locally, it means the host platform hasn't yet
  6. been added to the lock file. Running `bazel mod deps` provides a canonical
  7. update to `MODULE.bazel.lock`; create a PR with those changes in order to
  8. include the host platform.
  9. Platforms tested with GitHub actions are kept up-to-date. Other platforms may
  10. fall out of sync on dependency changes, and should be updated with a PR the same
  11. way a platform is added.
  12. """
  13. module(name = "carbon")
  14. http_archive = use_repo_rule(
  15. "@bazel_tools//tools/build_defs/repo:http.bzl",
  16. "http_archive",
  17. )
  18. bazel_dep(name = "bazel_skylib", version = "1.5.0")
  19. bazel_dep(name = "rules_pkg", version = "0.10.1")
  20. bazel_dep(name = "abseil-cpp", version = "20240116.1")
  21. bazel_dep(name = "re2", version = "2024-03-01")
  22. bazel_dep(name = "googletest", version = "1.14.0.bcr.1")
  23. google_benchmark_version = "1.8.3"
  24. bazel_dep(name = "google_benchmark", version = google_benchmark_version)
  25. archive_override(
  26. module_name = "google_benchmark",
  27. integrity = "sha256-a8GApX0j1NlRVRn5KwyD1hsFtbqxiJYfNqx7BrDZ6c4=",
  28. patch_strip = 1,
  29. patches = ["@//bazel/google_benchmark:0001-Use-libpfm-by-default-on-supported-platforms.patch"],
  30. strip_prefix = "benchmark-{0}".format(google_benchmark_version),
  31. urls = ["https://github.com/google/benchmark/archive/refs/tags/v{0}.tar.gz".format(google_benchmark_version)],
  32. )
  33. # The registry only has an old version. We use that here to avoid a miss but
  34. # override it with a newer version.
  35. bazel_dep(name = "libpfm", version = "4.11.0")
  36. libpfm_version = "4.13.0"
  37. archive_override(
  38. module_name = "libpfm",
  39. integrity = "sha256-0YuXdkx1VSjBBR03bjNUXQ62DG6/hWgENoE/pbBMw9E=",
  40. patch_strip = 1,
  41. patches = ["@//bazel/libpfm:0001-Introduce-a-simple-native-Bazel-build.patch"],
  42. strip_prefix = "libpfm-{0}".format(libpfm_version),
  43. urls = ["https://sourceforge.net/projects/perfmon2/files/libpfm4/libpfm-{0}.tar.gz".format(libpfm_version)],
  44. )
  45. bazel_dep(name = "rules_bison", version = "0.2.2")
  46. bazel_dep(name = "rules_flex", version = "0.2.1")
  47. bazel_dep(name = "rules_m4", version = "0.2.3")
  48. bazel_dep(name = "rules_cc", version = "0.0.9")
  49. bazel_dep(name = "rules_proto", version = "6.0.0-rc2")
  50. bazel_dep(name = "protobuf", version = "21.7")
  51. libprotobuf_mutator_version = "1.1"
  52. http_archive(
  53. name = "com_google_libprotobuf_mutator",
  54. build_file = "@//:third_party/libprotobuf_mutator/BUILD.txt",
  55. sha256 = "fd299fd72c5cf664259d9bd43a72cb74dc6a8b9604d107fe2d2e90885aeb7c16",
  56. strip_prefix = "libprotobuf-mutator-{0}".format(libprotobuf_mutator_version),
  57. urls = ["https://github.com/google/libprotobuf-mutator/archive/v{0}.tar.gz".format(libprotobuf_mutator_version)],
  58. )
  59. bazel_dep(name = "bazel_clang_tidy", dev_dependency = True)
  60. git_override(
  61. module_name = "bazel_clang_tidy",
  62. # HEAD as of 2024-03-12.
  63. commit = "bff5c59c843221b05ef0e37cef089ecc9d24e7da",
  64. remote = "https://github.com/erenon/bazel_clang_tidy.git",
  65. )
  66. bazel_cc_toolchain = use_extension(
  67. "//bazel/cc_toolchains:clang_configuration.bzl",
  68. "clang_toolchain_extension",
  69. )
  70. use_repo(bazel_cc_toolchain, "bazel_cc_toolchain")
  71. register_toolchains("@bazel_cc_toolchain//:all")
  72. bazel_dep(name = "hedron_compile_commands", dev_dependency = True)
  73. git_override(
  74. module_name = "hedron_compile_commands",
  75. # HEAD as of 2024-03-12.
  76. commit = "204aa593e002cbd177d30f11f54cff3559110bb9",
  77. remote = "https://github.com/hedronvision/bazel-compile-commands-extractor.git",
  78. )
  79. boost_unordered_version = "1.85.0"
  80. http_archive(
  81. name = "boost_unordered",
  82. build_file = "@//:third_party/boost_unordered/BUILD.bazel",
  83. integrity = "sha256-2dQ4IQH/xFiK1iWCkrMYLeR8zsSQqGchKOdTuf1u0zI=",
  84. strip_prefix = "boost_unordered-{0}".format(boost_unordered_version),
  85. urls = ["https://github.com/MikePopoloski/boost_unordered/archive/v{0}.tar.gz".format(boost_unordered_version)],
  86. )
  87. # Required for llvm-project.
  88. bazel_dep(name = "platforms", version = "0.0.8")
  89. bazel_dep(name = "zlib", version = "1.3.1.bcr.1", repo_name = "llvm_zlib")
  90. bazel_dep(name = "zstd", version = "1.5.5.bcr.1", repo_name = "llvm_zstd")
  91. ###############################################################################
  92. # llvm-project
  93. ###############################################################################
  94. # We pin to specific upstream commits and try to track top-of-tree reasonably
  95. # closely rather than pinning to a specific release.
  96. # HEAD as of 2024-05-17.
  97. llvm_project_version = "a68d20e986053ec571223a9f3ead3e146a27dc82"
  98. # Load a repository for the raw llvm-project, pre-overlay.
  99. http_archive(
  100. name = "llvm-raw",
  101. build_file_content = "# empty",
  102. patch_args = ["-p1"],
  103. patches = [
  104. "@carbon//bazel/llvm_project:0001_Patch_for_mallinfo2_when_using_Bazel_build_system.patch",
  105. "@carbon//bazel/llvm_project:0002_Added_Bazel_build_for_compiler_rt_fuzzer.patch",
  106. ],
  107. sha256 = "4c53512522cfd625a75aa7f201e6932f18ebf3fbe8ee89e05883c3d30ca935ac",
  108. strip_prefix = "llvm-project-{0}".format(llvm_project_version),
  109. urls = ["https://github.com/llvm/llvm-project/archive/{0}.tar.gz".format(llvm_project_version)],
  110. )
  111. # Apply the overlay to produce llvm-project.
  112. llvm_project = use_extension(
  113. "//bazel/llvm_project:llvm_project.bzl",
  114. "llvm_project",
  115. )
  116. use_repo(llvm_project, "llvm-project")
  117. ###############################################################################
  118. # Python
  119. ###############################################################################
  120. bazel_dep(name = "rules_python", version = "0.31.0")
  121. python = use_extension("@rules_python//python/extensions:python.bzl", "python")
  122. python.toolchain(
  123. python_version = "3.11",
  124. )
  125. use_repo(python, "python_versions")