Skip to content

toolchain: Apple CC toolchain not found when adding a hermetic toolchain #577

@jagobagascon

Description

@jagobagascon

I'm trying to update our project to start using hermetic toolchains. But after adding the "toolchains_llvm" rule I get the following error:

ERROR: /Users/jagoba/projects/salto/saltosystems-internal/srpc/framework/ble/platform/macos/BUILD:6:13: in objc_library rule //ble/platform/macos:ble_macos: 
Traceback (most recent call last):
        File "/virtual_builtins_bzl/common/objc/objc_library.bzl", line 59, column 52, in _objc_library_impl
        File "/virtual_builtins_bzl/common/objc/semantics.bzl", line 32, column 13, in _check_toolchain_supports_objc_compile
Error in fail: Compiling objc_library targets requires the Apple CC toolchain which can be found here: https://github.com/bazelbuild/apple_support#toolchain-setup

Our project contains Objective-C code that only builds on Macos. And compiles and runs fine when I use rules_cc with the auto detected toolchain.

load('@rules_cc//cc:defs.bzl', 'objc_library')

objc_library(
    name = 'ble_macos',
    srcs = ['ble_macos.m'],
    hdrs = ['ble_macos.h'],
    sdk_frameworks = ['CoreBluetooth'],
    target_compatible_with = ["@platforms//os:macos"],
)

Here's my MODULE.bazel file for reference:

bazel_dep(name = "apple_support", version = "2.2.0", repo_name = "build_bazel_apple_support")
# important apple_support must come above rules_cc 
bazel_dep(name = "rules_cc", version = "0.2.16")

# Adding these lines throws the error above
bazel_dep(name = "toolchains_llvm", version = "1.6.0")
# Configure and register the toolchain.
llvm = use_extension("@toolchains_llvm//toolchain/extensions:llvm.bzl", "llvm")
llvm.toolchain(
    llvm_version = "20.1.0", # https://releases.llvm.org/
)
use_repo(llvm, "llvm_toolchain")
register_toolchains("@llvm_toolchain//:all")

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions