MODULE.bazel 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144
  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 = "20250512.1")
  26. bazel_dep(name = "bazel_skylib", version = "1.9.0")
  27. bazel_dep(name = "google_benchmark", version = "1.9.4")
  28. bazel_dep(name = "googletest", version = "1.17.0")
  29. bazel_dep(name = "re2", version = "2024-07-02.bcr.1")
  30. bazel_dep(name = "rules_cc", version = "0.2.6")
  31. bazel_dep(name = "rules_pkg", version = "1.1.0")
  32. bazel_dep(name = "rules_shell", version = "0.6.1")
  33. bazel_dep(name = "tcmalloc", version = "0.0.0-20250331-43fcf6e")
  34. bazel_dep(name = "tree-sitter-bazel", version = "0.26.3")
  35. # The registry only has an old version. We use that here to avoid a miss but
  36. # override it with a newer version.
  37. bazel_dep(name = "libpfm", version = "4.11.0")
  38. libpfm_version = "4.13.0"
  39. # The official site is https://perfmon2.sourceforge.net/, but SourceForge makes
  40. # it difficult to download from bazel. On GitHub action runners,
  41. # https://git.code.sf.net/p/perfmon2/libpfm4 seems to be blocked. As a
  42. # consequence, use a mirror.
  43. archive_override(
  44. module_name = "libpfm",
  45. integrity = "sha256-sGBx1+UoQCplBCc+pwA1Tr/PS2L/4jnLZHH82wSuPz0=",
  46. patch_strip = 1,
  47. patches = ["@//bazel/libpfm:0001-Introduce-a-simple-native-Bazel-build.patch"],
  48. strip_prefix = "libpfm4-{0}".format(libpfm_version),
  49. urls = ["https://github.com/wcohen/libpfm4/archive/v{0}.tar.gz".format(libpfm_version)],
  50. )
  51. bazel_dep(name = "bazel_clang_tidy", dev_dependency = True)
  52. git_override(
  53. module_name = "bazel_clang_tidy",
  54. # HEAD as of 2025-01-09.
  55. commit = "db677011c7363509a288a9fb3bf0a50830bbf791",
  56. remote = "https://github.com/erenon/bazel_clang_tidy.git",
  57. )
  58. bazel_cc_toolchain = use_extension(
  59. "//bazel/cc_toolchains:clang_configuration.bzl",
  60. "clang_toolchain_extension",
  61. )
  62. use_repo(bazel_cc_toolchain, "bazel_cc_toolchain")
  63. register_toolchains("@bazel_cc_toolchain//:all")
  64. bazel_dep(name = "hedron_compile_commands", dev_dependency = True)
  65. git_override(
  66. module_name = "hedron_compile_commands",
  67. # HEAD as of 2025-01-09.
  68. commit = "4f28899228fb3ad0126897876f147ca15026151e",
  69. remote = "https://github.com/hedronvision/bazel-compile-commands-extractor.git",
  70. )
  71. boost_unordered_version = "1.85.0"
  72. http_archive(
  73. name = "boost_unordered",
  74. build_file = "@//:third_party/boost_unordered/BUILD.bazel",
  75. integrity = "sha256-2dQ4IQH/xFiK1iWCkrMYLeR8zsSQqGchKOdTuf1u0zI=",
  76. strip_prefix = "boost_unordered-{0}".format(boost_unordered_version),
  77. urls = ["https://github.com/MikePopoloski/boost_unordered/archive/v{0}.tar.gz".format(boost_unordered_version)],
  78. )
  79. # Required for llvm-project.
  80. bazel_dep(name = "platforms", version = "1.0.0")
  81. bazel_dep(name = "protobuf", version = "33.1", repo_name = "com_google_protobuf")
  82. bazel_dep(name = "zlib-ng", version = "2.0.7", repo_name = "llvm_zlib")
  83. bazel_dep(name = "zstd", version = "1.5.7", repo_name = "llvm_zstd")
  84. ###############################################################################
  85. # llvm-project
  86. ###############################################################################
  87. # We pin to specific upstream commits and try to track top-of-tree reasonably
  88. # closely rather than pinning to a specific release.
  89. # HEAD as of 2026-01-08.
  90. llvm_project_version = "21a1e6e6a70d70635c68b9aaa54f816ae36a6416"
  91. # Load a repository for the raw llvm-project, pre-overlay.
  92. http_archive(
  93. name = "llvm-raw",
  94. build_file_content = "# empty",
  95. integrity = "sha256-ouWG2d4Cob9P6+dxCLZnV4RldSOqZp7mtwd6vd+ZK3Q=",
  96. patch_args = ["-p1"],
  97. patches = [
  98. "@carbon//bazel/llvm_project:0001_Patch_for_mallinfo2_when_using_Bazel_build_system.patch",
  99. "@carbon//bazel/llvm_project:0002_Added_Bazel_build_for_compiler_rt_fuzzer.patch",
  100. "@carbon//bazel/llvm_project:0004_Introduce_basic_sources_exporting_for_libunwind.patch",
  101. "@carbon//bazel/llvm_project:0005_Introduce_basic_sources_exporting_for_libcxx_and_libcxxabi.patch",
  102. "@carbon//bazel/llvm_project:0008_Add_filegroups_for_installed_compiler-rt_headers.patch",
  103. ],
  104. strip_prefix = "llvm-project-{0}".format(llvm_project_version),
  105. urls = ["https://github.com/llvm/llvm-project/archive/{0}.tar.gz".format(llvm_project_version)],
  106. )
  107. # Apply the overlay to produce llvm-project.
  108. llvm_project = use_extension(
  109. "//bazel/llvm_project:llvm_project.bzl",
  110. "llvm_project",
  111. )
  112. use_repo(llvm_project, "llvm-project")
  113. ###############################################################################
  114. # Python
  115. ###############################################################################
  116. bazel_dep(name = "rules_python", version = "1.6.0")
  117. python = use_extension("@rules_python//python/extensions:python.bzl", "python")
  118. python.toolchain(
  119. python_version = "3.11",
  120. )
  121. use_repo(python, "python_versions")