diff --git a/cc/toolchains/impl/toolchain_config.bzl b/cc/toolchains/impl/toolchain_config.bzl index 4300c1db8..69e0b6720 100644 --- a/cc/toolchains/impl/toolchain_config.bzl +++ b/cc/toolchains/impl/toolchain_config.bzl @@ -95,9 +95,9 @@ def cc_toolchain_config_impl_helper(ctx): # compiler compiler = ctx.attr.compiler, target_cpu = ctx.attr.cpu, + target_libc = ctx.attr.target_libc, # Used by legacy features to determine if we're building for Apple platfroms or not target_system_name = ctx.expand_make_variables("target_system_name", ctx.attr.target_system_name, {}), # These fields are only relevant for legacy toolchain resolution. - target_libc = "", abi_version = "", abi_libc_version = "", ), @@ -120,6 +120,7 @@ CC_TOOLCHAIN_CONFIG_PUBLIC_ATTRS = { # Attributes new to this rule. "compiler": attr.string(default = ""), "cpu": attr.string(default = ""), + "target_libc": attr.string(default = ""), "target_system_name": attr.string(default = ""), "tool_map": attr.label(providers = [ToolConfigInfo], mandatory = True), "args": attr.label_list(providers = [ArgsListInfo]), diff --git a/cc/toolchains/toolchain.bzl b/cc/toolchains/toolchain.bzl index 3890b3e80..6637d4481 100644 --- a/cc/toolchains/toolchain.bzl +++ b/cc/toolchains/toolchain.bzl @@ -172,6 +172,11 @@ def cc_toolchain( "//conditions:default": "", }) + target_libc = select({ + Label("//cc/settings:apple_constraint"): "macosx", + "//conditions:default": "", + }) + if bazel_features.cc.supports_starlarkified_toolchains: _cc_toolchain( name = name, @@ -183,6 +188,7 @@ def cc_toolchain( known_features = known_features, enabled_features = enabled_features, compiler = compiler, + target_libc = target_libc, cpu = cpu or _CPU, target_system_name = target_system_name, dynamic_runtime_lib = dynamic_runtime_lib, @@ -208,6 +214,7 @@ def cc_toolchain( enabled_features = enabled_features, compiler = compiler, cpu = cpu or _CPU, + target_libc = target_libc, target_system_name = target_system_name, visibility = ["//visibility:private"], **kwargs