From bd0e4784e4ade9e18ecb8d3b3905a6e71eac3016 Mon Sep 17 00:00:00 2001 From: Keith Smiley Date: Wed, 25 Mar 2026 13:09:17 -0700 Subject: [PATCH] Set target_libc to macosx for Apple platforms This is read by the legacy features logic to determine how to pass Apple specific flags. Theoretically this is readable by anyone as well, similar to the other ones, but I don't think it's widely used. --- cc/toolchains/impl/toolchain_config.bzl | 3 ++- cc/toolchains/toolchain.bzl | 4 ++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/cc/toolchains/impl/toolchain_config.bzl b/cc/toolchains/impl/toolchain_config.bzl index 1f6efefe5..863bb4a70 100644 --- a/cc/toolchains/impl/toolchain_config.bzl +++ b/cc/toolchains/impl/toolchain_config.bzl @@ -84,9 +84,9 @@ def _cc_toolchain_config_impl(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 # These fields are only relevant for legacy toolchain resolution. target_system_name = "", - target_libc = "", abi_version = "", abi_libc_version = "", ), @@ -105,6 +105,7 @@ cc_toolchain_config = rule( # Attributes new to this rule. "compiler": attr.string(default = ""), "cpu": attr.string(default = ""), + "target_libc": attr.string(default = ""), "tool_map": attr.label(providers = [ToolConfigInfo], mandatory = True), "args": attr.label_list(providers = [ArgsListInfo]), "known_features": attr.label_list(providers = [FeatureSetInfo]), diff --git a/cc/toolchains/toolchain.bzl b/cc/toolchains/toolchain.bzl index fa41163ab..c0b712426 100644 --- a/cc/toolchains/toolchain.bzl +++ b/cc/toolchains/toolchain.bzl @@ -186,6 +186,10 @@ def cc_toolchain( Label("//cc/toolchains/impl:windows_x86_64"): "win64", "//conditions:default": "", }), + target_libc = select({ + Label("//cc/toolchains/platforms:apple"): "macosx", + "//conditions:default": "", + }), visibility = ["//visibility:private"], **kwargs )