diff --git a/.bazelrc b/.bazelrc index 68adb0e90..7e7b7bd6d 100644 --- a/.bazelrc +++ b/.bazelrc @@ -18,8 +18,12 @@ build --incompatible_enable_cc_toolchain_resolution # Without this, one can use `--linkopt='-undefined dynamic_lookup'`. # This feature is intentionally not supported on macOS. build --features=-supports_dynamic_linker -# Not needed after https://github.com/grailbio/bazel-toolchain/pull/229. -build --features=-libtool + +# Port over all dependencies to use Bzlmod. Until then, disable it, +# as enabling it pulls in the module version of dependencies such +# as @@zlib~. By default, @@zlib~ doesn't build; we need to pass in +# in flags to disable warnings to make the code build. +common --enable_bzlmod=false ## ## Common build options across all build configurations diff --git a/.bazelversion b/.bazelversion index f22d756da..1985849fb 100644 --- a/.bazelversion +++ b/.bazelversion @@ -1 +1 @@ -6.5.0 +7.7.0 diff --git a/WORKSPACE b/WORKSPACE index cc0f94e6c..2754d4d7b 100644 --- a/WORKSPACE +++ b/WORKSPACE @@ -35,15 +35,36 @@ load("@toolchains_llvm//toolchain:deps.bzl", "bazel_toolchain_dependencies") bazel_toolchain_dependencies() +# bazel_features is used by rules_cc and toolchains_llvm to detect Bazel version +# capabilities. bazel_features_deps() sets up the @bazel_features_version repository +# which is needed by bazel_features internally. +load("@bazel_features//:deps.bzl", "bazel_features_deps") + +bazel_features_deps() + +# rules_cc 0.2.14+ requires the @cc_compatibility_proxy repository to be set up +# for WORKSPACE builds. This provides compatibility shims for native cc_* rules. +load("@rules_cc//cc:extensions.bzl", "compatibility_proxy_repo") + +compatibility_proxy_repo() + load("@toolchains_llvm//toolchain:rules.bzl", "llvm_toolchain") llvm_toolchain( name = "llvm_toolchain_15_0_6", - absolute_paths = True, + # absolute_paths = False (the default) creates symlinks for tools like + # llvm-libtool-darwin -> libtool in the toolchain bin directory, which is + # required for proper tool resolution on macOS. alternative_llvm_sources = [ "https://github.com/llvm/llvm-project/releases/download/llvmorg-{llvm_version}/{basename}", ], llvm_version = "15.0.6", + # The sysroots are needed for cross-compiling + sysroot = { + "": "", + "darwin-x86_64": "/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk", + "darwin-aarch64": "/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk", + }, ) load("@llvm_toolchain_15_0_6//:toolchains.bzl", "llvm_register_toolchains") @@ -107,12 +128,12 @@ load("@aspect_bazel_lib//lib:repositories.bzl", "aspect_bazel_lib_dependencies") aspect_bazel_lib_dependencies() -BAZEL_INSTALLER_VERSION_LINUX_X86_64_SHA = "c0161a346b9c0d00e6eb3d3e8f9c4dece32f6292520248c5ab2e3527265601c1" +BAZEL_INSTALLER_VERSION_LINUX_X86_64_SHA = "7e749f59fa4c4430fbc49ea38b0bc0a41dd1f460e8671c90978d70c2166bf0c4" # Bazel for linux-arm64 doesn't have an installer at the moment. # We have a workaround in `./bazel` to download the binary directly. -BAZEL_INSTALLER_VERSION_LINUX_ARM64_SHA = "5afe973cadc036496cac66f1414ca9be36881423f576db363d83afc9084c0c2f" +BAZEL_INSTALLER_VERSION_LINUX_ARM64_SHA = "8d404f7a266ead50be0918f913df1449a4880f5c8ef36c88d09d6204e67f114d" -BAZEL_INSTALLER_VERSION_DARWIN_X86_64_SHA = "455589bbaedf26e7bdb949288f777492ba1c53d67fd8329bfe066fb988df0e5c" +BAZEL_INSTALLER_VERSION_DARWIN_X86_64_SHA = "6a0a89a1c0b75e6c1d02fd881adf30f52ea921ea00feaf77a4e14331c488b56e" -BAZEL_INSTALLER_VERSION_DARWIN_ARM64_SHA = "c2b5f82dcc1561d25bc05c734a7cc7a5ff58d4e69185f3d6d21b51ddb53b488b" +BAZEL_INSTALLER_VERSION_DARWIN_ARM64_SHA = "8167011977bffd577cb4c8e9b2100f89134aa83c419a543914568f39a6b1c410" diff --git a/third_party/externals.bzl b/third_party/externals.bzl index 1fab0a722..1f64931d9 100644 --- a/third_party/externals.bzl +++ b/third_party/externals.bzl @@ -177,19 +177,16 @@ def register_sorbet_dependencies(): http_archive( name = "rules_cc", - sha256 = "b6f34b3261ec02f85dbc5a8bdc9414ce548e1f5f67e000d7069571799cb88b25", - strip_prefix = "rules_cc-726dd8157557f1456b3656e26ab21a1646653405", - urls = ["https://github.com/bazelbuild/rules_cc/archive/726dd8157557f1456b3656e26ab21a1646653405.tar.gz"], + sha256 = "a2fdfde2ab9b2176bd6a33afca14458039023edb1dd2e73e6823810809df4027", + strip_prefix = "rules_cc-0.2.14", + urls = ["https://github.com/bazelbuild/rules_cc/archive/refs/tags/0.2.14.tar.gz"], ) - # TODO(jez) We keep our changes on the `sorbet` branch of `sorbet/bazel-toolchain` - # The `master` branch is the commit of `bazel-contrib/toolchains_llvm` that we're based on - # In 2ddd7d791 (#7912) we upgraded the toolchain. Our old toolchain patches are on the `sorbet-old-toolchain` branch http_archive( name = "toolchains_llvm", - url = "https://github.com/sorbet/bazel-toolchain/archive/8d9165fd3560f6ff50bc4794972f714f4ba2adaa.tar.gz", - sha256 = "238b5a777bbfac3d5ec35cbd45ae2b84ca4118aa8f902ab27894912352e94658", - strip_prefix = "bazel-toolchain-8d9165fd3560f6ff50bc4794972f714f4ba2adaa", + url = "https://github.com/bazel-contrib/toolchains_llvm/releases/download/v1.5.0/toolchains_llvm-v1.5.0.tar.gz", + sha256 = "49e69c011bcaa4c9a7246a287ab1fb4f7ed3fde7cbd7300374c1030f40d2bb95", + strip_prefix = "toolchains_llvm-v1.5.0", ) http_archive(