bazel: 4.1.0 toolchain failure with bazelisk 1.3.9 on Mac OS X 10.15.7

Description of the problem:

Observing the following toolchain error with the latest release of Bazelisk (1.3.9) that includes Bazel (4.1.0):

Starting local Bazel server and connecting to it...
...
Analyzing: 72 targets (214 packages loaded, 5638 targets configured)
ERROR: /private/var/tmp/_bazel_runner/8457af28b7e270ce29a11930611f114f/external/local_config_cc/BUILD:85:24: in cc_toolchain_config rule @local_config_cc//:ios_i386: 
Traceback (most recent call last):
	File "/private/var/tmp/_bazel_runner/8457af28b7e270ce29a11930611f114f/external/local_config_cc/cc_toolchain_config.bzl", line 2049, column 65, in _impl
		flags = _deterministic_libtool_flags(ctx) + [
	File "/private/var/tmp/_bazel_runner/8457af28b7e270ce29a11930611f114f/external/local_config_cc/cc_toolchain_config.bzl", line 53, column 38, in _deterministic_libtool_flags
		if _can_use_deterministic_libtool(ctx):
	File "/private/var/tmp/_bazel_runner/8457af28b7e270ce29a11930611f114f/external/local_config_cc/cc_toolchain_config.bzl", line 45, column 25, in _can_use_deterministic_libtool
		if _compare_versions(xcode_version, _SUPPORTS_DETERMINISTIC_MODE) >= 0:
	File "/private/var/tmp/_bazel_runner/8457af28b7e270ce29a11930611f114f/external/local_config_cc/cc_toolchain_config.bzl", line 38, column 15, in _compare_versions
		return dv1.compare_to(apple_common.dotted_version(v2))
Error: 'NoneType' value has no field or method 'compare_to'
Analysis of target '@local_config_cc//:ios_i386' failed
INFO: Elapsed time: 145.535s
INFO: 0 processes.

What operating system are you running Bazel on?

Mac OS X 10.15.7

What’s the output of bazel info release?

Since this is running remotely, the only information I have is:

https://releases.bazel.build/4.1.0/release/bazel-4.1.0-darwin-x86_64

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Reactions: 4
  • Comments: 20 (15 by maintainers)

Commits related to this issue

Most upvoted comments

After some debugging, I was able to get it working. The following commands fixed my issue:

1. bazel clean --expunge 
2. sudo xcode-select --switch /Library/Developer/CommandLineTools
3. bazel clean --expunge

Before, my xcode location was:

> xcode-select -p
/Applications/Xcode.app/Contents/Developer

I’m still seeing this issue

macOS 13.3
> xcode-select -p                                             
/Applications/Xcode.app/Contents/Developer
> bazel --version                                                                                                                  
bazel 5.0.0
> bazel info release
INFO: Invocation ID: 914b189c-bd26-48a3-a052-13a5f7ce2d5a
release 5.0.0
> cat $(bazel info output_base)/external/local_config_cc/BUILD
INFO: Invocation ID: e52548e4-d213-42c7-b952-9437d314242e
package(default_visibility = ["//visibility:public"])

load("@local_config_cc_toolchains//:osx_archs.bzl", "OSX_TOOLS_ARCHS")
load("@rules_cc//cc:defs.bzl", "cc_toolchain_suite", "cc_library")
load(":armeabi_cc_toolchain_config.bzl", "armeabi_cc_toolchain_config")
load(":cc_toolchain_config.bzl", "cc_toolchain_config")

# Reexporting osx_arch.bzl for backwards compatibility
# Originally this file was present in @local_config_cc, but with the split in
# https://github.com/bazelbuild/bazel/pull/8459 we had to move the file to
# @local_config_cc_toolchains. This alias is there to keep the code backwards
# compatible (and serves no other purpose).
alias(name = "osx_archs.bzl", actual = "@local_config_cc_toolchains//:osx_archs.bzl")

CC_TOOLCHAINS = [(
    cpu + "|compiler",
    ":cc-compiler-" + cpu,
) for cpu in OSX_TOOLS_ARCHS] + [(
    cpu,
    ":cc-compiler-" + cpu,
) for cpu in OSX_TOOLS_ARCHS] + [
    ("k8|compiler", ":cc-compiler-darwin_x86_64"),
    ("darwin|compiler", ":cc-compiler-darwin_x86_64"),
    ("k8", ":cc-compiler-darwin_x86_64"),
    ("darwin", ":cc-compiler-darwin_x86_64"),
    ("armeabi-v7a|compiler", ":cc-compiler-armeabi-v7a"),
    ("armeabi-v7a", ":cc-compiler-armeabi-v7a"),
]

cc_library(
    name = "malloc",
)

filegroup(
    name = "empty",
    srcs = [],
)

filegroup(
    name = "cc_wrapper",
    srcs = ["cc_wrapper.sh"],
)

cc_toolchain_suite(
    name = "toolchain",
    toolchains = dict(CC_TOOLCHAINS),
)

[
    filegroup(
        name = "osx_tools_" + arch,
        srcs = [
            ":cc_wrapper",
            ":libtool",
            ":libtool_check_unique",
            ":make_hashed_objlist.py",
            ":wrapped_clang",
            ":wrapped_clang_pp",
            ":xcrunwrapper.sh",
        ],
    )
    for arch in OSX_TOOLS_ARCHS
]

[
    apple_cc_toolchain(
        name = "cc-compiler-" + arch,
        all_files = ":osx_tools_" + arch,
        ar_files = ":osx_tools_" + arch,
        as_files = ":osx_tools_" + arch,
        compiler_files = ":osx_tools_" + arch,
        dwp_files = ":empty",
        linker_files = ":osx_tools_" + arch,
        objcopy_files = ":empty",
        strip_files = ":osx_tools_" + arch,
        supports_param_files = 1,
        toolchain_config = arch,
        toolchain_identifier = arch,
    )
    for arch in OSX_TOOLS_ARCHS
]

[
    cc_toolchain_config(
        name = arch,
        compiler = "compiler",
        cpu = arch,
        cxx_builtin_include_directories = [
            "/Applications/",
            "/Library/",
            "/Users/blaine.malone/Library/",
            "/Applications/Xcode.app/Contents/Developer",
        ],
        tool_paths_overrides = {},
    )
    for arch in OSX_TOOLS_ARCHS
]

# Android tooling requires a default toolchain for the armeabi-v7a cpu.
cc_toolchain(
    name = "cc-compiler-armeabi-v7a",
    toolchain_identifier = "stub_armeabi-v7a",
    toolchain_config = ":stub_armeabi-v7a",
    all_files = ":empty",
    ar_files = ":empty",
    as_files = ":empty",
    compiler_files = ":empty",
    dwp_files = ":empty",
    linker_files = ":empty",
    objcopy_files = ":empty",
    strip_files = ":empty",
    supports_param_files = 1,
)

armeabi_cc_toolchain_config(name = "stub_armeabi-v7a")