Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion cc/toolchains/impl/toolchain_config.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,8 @@ def _cc_toolchain_config_impl(ctx):
# compiler
compiler = ctx.attr.compiler,
target_cpu = ctx.attr.cpu,
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_system_name = "",
target_libc = "",
abi_version = "",
abi_libc_version = "",
Expand All @@ -105,6 +105,7 @@ cc_toolchain_config = rule(
# Attributes new to this rule.
"compiler": attr.string(default = ""),
"cpu": attr.string(default = ""),
"target_system_name": attr.string(default = ""),
"tool_map": attr.label(providers = [ToolConfigInfo], mandatory = True),
"args": attr.label_list(providers = [ArgsListInfo]),
"known_features": attr.label_list(providers = [FeatureSetInfo]),
Expand Down
14 changes: 14 additions & 0 deletions cc/toolchains/toolchain.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ def cc_toolchain(
supports_header_parsing = False,
supports_param_files = False,
compiler = "",
target_system_name = None,
**kwargs):
"""A C/C++ toolchain configuration.

Expand Down Expand Up @@ -158,6 +159,10 @@ def cc_toolchain(
compiler: (str) The type of compiler used by this toolchain (e.g. "gcc", "clang"). The current
toolchain's compiler is exposed to `@rules_cc//cc/private/toolchain:compiler
(compiler_flag)` as a flag value.
target_system_name: (str) The target system name for this toolchain. This is exposed through the
toolchain info providers. This string is commonly the target triple you would pass to
`clang -target` (e.g. "x86_64-unknown-linux-gnu", "aarch64-apple-darwin"). If not
provided, a default is selected based on the target platform..
**kwargs: [common attributes](https://bazel.build/reference/be/common-definitions#common-attributes)
that should be applied to all rules created by this macro.
"""
Expand All @@ -177,6 +182,15 @@ def cc_toolchain(
known_features = known_features,
enabled_features = enabled_features,
compiler = compiler,
target_system_name = target_system_name or select({
Label("//cc/toolchains/impl:darwin_aarch64"): "aarch64-apple-darwin",
Label("//cc/toolchains/impl:darwin_x86_64"): "x86_64-apple-darwin",
Label("//cc/toolchains/impl:linux_aarch64"): "aarch64-unknown-linux-gnu",
Label("//cc/toolchains/impl:linux_x86_64"): "x86_64-unknown-linux-gnu",
Label("//cc/toolchains/impl:windows_x86_32"): "i686-pc-windows-msvc",
Label("//cc/toolchains/impl:windows_x86_64"): "x86_64-pc-windows-msvc",
"//conditions:default": "",
}),
cpu = select({
Label("//cc/toolchains/impl:darwin_aarch64"): "darwin_arm64",
Label("//cc/toolchains/impl:darwin_x86_64"): "darwin_x86_64",
Expand Down