Skip to content

Commit

Permalink
Also update cc_toolchain.toolchain_identifier when CC_TOOLCHAIN_NAME …
Browse files Browse the repository at this point in the history
…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
  • Loading branch information
hlopko authored and katre committed Nov 14, 2018
1 parent eb2af0f commit 555772b
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 12 deletions.
2 changes: 1 addition & 1 deletion tools/cpp/BUILD.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ cc_toolchain_suite(

cc_toolchain(
name = "cc-compiler-%{name}",
toolchain_identifier = "local",
toolchain_identifier = "%{cc_toolchain_identifier}",
all_files = ":compiler_deps",
compiler_files = ":compiler_deps",
cpu = "%{name}",
Expand Down
15 changes: 4 additions & 11 deletions tools/cpp/unix_cc_configure.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -500,11 +500,13 @@ def configure_unix_toolchain(repository_ctx, cpu_value, overriden_tools):
crosstool_content = _crosstool_content(repository_ctx, cc, cpu_value, darwin)
opt_content = _opt_content(repository_ctx, cc, darwin)
dbg_content = _dbg_content()
cc_toolchain_identifier = get_env_var(repository_ctx, "CC_TOOLCHAIN_NAME", "local", False)

repository_ctx.template(
"BUILD",
paths["@bazel_tools//tools/cpp:BUILD.tpl"],
{
"%{cc_toolchain_identifier}": cc_toolchain_identifier,
"%{name}": cpu_value,
"%{supports_param_files}": "0" if darwin else "1",
"%{cc_compiler_deps}": ":cc_wrapper" if darwin else ":empty",
Expand Down Expand Up @@ -534,17 +536,8 @@ def configure_unix_toolchain(repository_ctx, cpu_value, overriden_tools):
paths["@bazel_tools//tools/cpp:CROSSTOOL.tpl"],
{
"%{cpu}": escape_string(cpu_value),
"%{default_toolchain_name}": escape_string(
get_env_var(
repository_ctx,
"CC_TOOLCHAIN_NAME",
"local",
False,
),
),
"%{toolchain_name}": escape_string(
get_env_var(repository_ctx, "CC_TOOLCHAIN_NAME", "local", False),
),
"%{default_toolchain_name}": escape_string(cc_toolchain_identifier),
"%{toolchain_name}": escape_string(cc_toolchain_identifier),
"%{content}": _build_crosstool(crosstool_content) + "\n" +
_build_tool_path(tool_paths),
"%{opt_content}": _build_crosstool(opt_content, " "),
Expand Down

0 comments on commit 555772b

Please sign in to comment.