Skip to content

Commit 555772b

Browse files
hlopkokatre
authored andcommitted
Also update cc_toolchain.toolchain_identifier when CC_TOOLCHAIN_NAME is set
Since we specify toolchain_identifier in cc_toolchain now, it is much more strict in selecting a CROSSTOOL toolchain. This broke when CC_TOOLCHAIN_NAME environment variable was set, as that only renamed toolchain identifier in the CROSSTOOL, but not in the cc_toolchain. This cl fixes that. This fixed bazelbuild/bazel-toolchains#198. RELNOTES: None PiperOrigin-RevId: 217666695
1 parent eb2af0f commit 555772b

File tree

2 files changed

+5
-12
lines changed

2 files changed

+5
-12
lines changed

tools/cpp/BUILD.tpl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ cc_toolchain_suite(
5656

5757
cc_toolchain(
5858
name = "cc-compiler-%{name}",
59-
toolchain_identifier = "local",
59+
toolchain_identifier = "%{cc_toolchain_identifier}",
6060
all_files = ":compiler_deps",
6161
compiler_files = ":compiler_deps",
6262
cpu = "%{name}",

tools/cpp/unix_cc_configure.bzl

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -500,11 +500,13 @@ def configure_unix_toolchain(repository_ctx, cpu_value, overriden_tools):
500500
crosstool_content = _crosstool_content(repository_ctx, cc, cpu_value, darwin)
501501
opt_content = _opt_content(repository_ctx, cc, darwin)
502502
dbg_content = _dbg_content()
503+
cc_toolchain_identifier = get_env_var(repository_ctx, "CC_TOOLCHAIN_NAME", "local", False)
503504

504505
repository_ctx.template(
505506
"BUILD",
506507
paths["@bazel_tools//tools/cpp:BUILD.tpl"],
507508
{
509+
"%{cc_toolchain_identifier}": cc_toolchain_identifier,
508510
"%{name}": cpu_value,
509511
"%{supports_param_files}": "0" if darwin else "1",
510512
"%{cc_compiler_deps}": ":cc_wrapper" if darwin else ":empty",
@@ -534,17 +536,8 @@ def configure_unix_toolchain(repository_ctx, cpu_value, overriden_tools):
534536
paths["@bazel_tools//tools/cpp:CROSSTOOL.tpl"],
535537
{
536538
"%{cpu}": escape_string(cpu_value),
537-
"%{default_toolchain_name}": escape_string(
538-
get_env_var(
539-
repository_ctx,
540-
"CC_TOOLCHAIN_NAME",
541-
"local",
542-
False,
543-
),
544-
),
545-
"%{toolchain_name}": escape_string(
546-
get_env_var(repository_ctx, "CC_TOOLCHAIN_NAME", "local", False),
547-
),
539+
"%{default_toolchain_name}": escape_string(cc_toolchain_identifier),
540+
"%{toolchain_name}": escape_string(cc_toolchain_identifier),
548541
"%{content}": _build_crosstool(crosstool_content) + "\n" +
549542
_build_tool_path(tool_paths),
550543
"%{opt_content}": _build_crosstool(opt_content, " "),

0 commit comments

Comments
 (0)