MODULE.bazel 5.9 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. `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. """
  20. module(name = "carbon")
  21. http_archive = use_repo_rule(
  22. "@bazel_tools//tools/build_defs/repo:http.bzl",
  23. "http_archive",
  24. )
  25. bazel_dep(name = "abseil-cpp", version = "20240722.0.bcr.2")
  26. bazel_dep(name = "bazel_skylib", version = "1.7.1")
  27. bazel_dep(name = "google_benchmark", version = "1.8.5")
  28. bazel_dep(name = "googletest", version = "1.15.2")
  29. bazel_dep(name = "re2", version = "2024-07-02.bcr.1")
  30. bazel_dep(name = "rules_pkg", version = "1.0.1")
  31. bazel_dep(name = "tree-sitter-bazel", version = "0.24.4")
  32. # The registry only has an old version. We use that here to avoid a miss but
  33. # override it with a newer version.
  34. bazel_dep(name = "libpfm", version = "4.11.0")
  35. libpfm_version = "4.13.0"
  36. # The official site is https://perfmon2.sourceforge.net/, but SourceForge makes
  37. # it difficult to download from bazel. On GitHub action runners,
  38. # https://git.code.sf.net/p/perfmon2/libpfm4 seems to be blocked. As a
  39. # consequence, use a mirror.
  40. archive_override(
  41. module_name = "libpfm",
  42. integrity = "sha256-sGBx1+UoQCplBCc+pwA1Tr/PS2L/4jnLZHH82wSuPz0=",
  43. patch_strip = 1,
  44. patches = ["@//bazel/libpfm:0001-Introduce-a-simple-native-Bazel-build.patch"],
  45. strip_prefix = "libpfm4-{0}".format(libpfm_version),
  46. urls = ["https://github.com/wcohen/libpfm4/archive/v{0}.tar.gz".format(libpfm_version)],
  47. )
  48. # The registry has a snapshot, but upstream is active and not regularly marking
  49. # releases. We start with the BCR snapshot to avoid a miss and then override it
  50. # with a more recent commit.
  51. bazel_dep(name = "tcmalloc", version = "0.0.0-20240411-5ed309d", dev_dependency = True)
  52. git_override(
  53. module_name = "tcmalloc",
  54. # HEAD as of 2025-01-09.
  55. commit = "d02a005a369252a4f239b36cc698daf7f87ba648",
  56. remote = "https://github.com/google/tcmalloc.git",
  57. )
  58. bazel_dep(name = "rules_bison", version = "0.3")
  59. bazel_dep(name = "rules_flex", version = "0.3")
  60. bazel_dep(name = "rules_m4", version = "0.2.4")
  61. bazel_dep(name = "rules_cc", version = "0.1.0")
  62. bazel_dep(name = "bazel_clang_tidy", dev_dependency = True)
  63. git_override(
  64. module_name = "bazel_clang_tidy",
  65. # HEAD as of 2025-01-09.
  66. commit = "db677011c7363509a288a9fb3bf0a50830bbf791",
  67. remote = "https://github.com/erenon/bazel_clang_tidy.git",
  68. )
  69. bazel_cc_toolchain = use_extension(
  70. "//bazel/cc_toolchains:clang_configuration.bzl",
  71. "clang_toolchain_extension",
  72. )
  73. use_repo(bazel_cc_toolchain, "bazel_cc_toolchain")
  74. register_toolchains("@bazel_cc_toolchain//:all")
  75. bazel_dep(name = "hedron_compile_commands", dev_dependency = True)
  76. git_override(
  77. module_name = "hedron_compile_commands",
  78. # HEAD as of 2025-01-09.
  79. commit = "4f28899228fb3ad0126897876f147ca15026151e",
  80. remote = "https://github.com/hedronvision/bazel-compile-commands-extractor.git",
  81. )
  82. boost_unordered_version = "1.85.0"
  83. http_archive(
  84. name = "boost_unordered",
  85. build_file = "@//:third_party/boost_unordered/BUILD.bazel",
  86. integrity = "sha256-2dQ4IQH/xFiK1iWCkrMYLeR8zsSQqGchKOdTuf1u0zI=",
  87. strip_prefix = "boost_unordered-{0}".format(boost_unordered_version),
  88. urls = ["https://github.com/MikePopoloski/boost_unordered/archive/v{0}.tar.gz".format(boost_unordered_version)],
  89. )
  90. # Required for llvm-project.
  91. bazel_dep(name = "platforms", version = "0.0.10")
  92. bazel_dep(name = "zlib", version = "1.3.1.bcr.4", repo_name = "llvm_zlib")
  93. bazel_dep(name = "zstd", version = "1.5.6", repo_name = "llvm_zstd")
  94. ###############################################################################
  95. # llvm-project
  96. ###############################################################################
  97. # We pin to specific upstream commits and try to track top-of-tree reasonably
  98. # closely rather than pinning to a specific release.
  99. # HEAD as of 2025-01-15.
  100. llvm_project_version = "6ca560a9092e29c9f9817db6d6da09edd5f0ded7"
  101. # Load a repository for the raw llvm-project, pre-overlay.
  102. http_archive(
  103. name = "llvm-raw",
  104. build_file_content = "# empty",
  105. patch_args = ["-p1"],
  106. patches = [
  107. "@carbon//bazel/llvm_project:0001_Patch_for_mallinfo2_when_using_Bazel_build_system.patch",
  108. "@carbon//bazel/llvm_project:0002_Added_Bazel_build_for_compiler_rt_fuzzer.patch",
  109. ],
  110. sha256 = "1ee1e9baa236ac35c43b1a0878629f82b8ca0b85effe83aa697736a0b515923d",
  111. strip_prefix = "llvm-project-{0}".format(llvm_project_version),
  112. urls = ["https://github.com/llvm/llvm-project/archive/{0}.tar.gz".format(llvm_project_version)],
  113. )
  114. # Apply the overlay to produce llvm-project.
  115. llvm_project = use_extension(
  116. "//bazel/llvm_project:llvm_project.bzl",
  117. "llvm_project",
  118. )
  119. use_repo(llvm_project, "llvm-project")
  120. ###############################################################################
  121. # Python
  122. ###############################################################################
  123. bazel_dep(name = "rules_python", version = "1.0.0")
  124. python = use_extension("@rules_python//python/extensions:python.bzl", "python")
  125. python.toolchain(
  126. python_version = "3.11",
  127. )
  128. use_repo(python, "python_versions")