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
16 changes: 13 additions & 3 deletions cc/private/toolchain/cc_configure.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
# limitations under the License.
"""Rules for configuring the C++ toolchain (experimental)."""

load("@bazel_features//:features.bzl", "bazel_features")
load(
":lib_cc_configure.bzl",
"get_cpu_value",
Expand All @@ -24,9 +25,18 @@ load(":windows_cc_configure.bzl", "configure_windows_toolchain")
def _should_disable_toolchain(repository_ctx):
"""Returns true if the toolchain should be disabled based on environment variables."""
env = repository_ctx.os.environ
disabled_via_env = "BAZEL_DO_NOT_DETECT_CPP_TOOLCHAIN" in env and env["BAZEL_DO_NOT_DETECT_CPP_TOOLCHAIN"] == "1"
macos_legacy_support = env.get("BAZEL_USE_LEGACY_MACOS_TOOLCHAIN", "1") == "1"
return disabled_via_env or (repository_ctx.os.name.startswith("mac os") and not macos_legacy_support)
if env.get("BAZEL_DO_NOT_DETECT_CPP_TOOLCHAIN") == "1":
return True

# Keep macOS toolchain before bazel 9.x
if not bazel_features.cc.cc_common_is_in_rules_cc:
return False

macos_legacy_support = env.get("BAZEL_USE_LEGACY_MACOS_TOOLCHAIN", "0") == "1"
if repository_ctx.os.name.startswith("mac os") and not macos_legacy_support:
return True

return False

def cc_autoconf_toolchains_impl(repository_ctx):
"""Generate BUILD file with 'toolchain' targets for the local host C++ toolchain.
Expand Down
2 changes: 2 additions & 0 deletions tests/integration/cc_tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,7 @@ def _cc_aspect_impl(target, ctx):
feature_configuration = feature_configuration,
name = ctx.label.name + "_aspect",
cc_toolchain = toolchain,
disallow_dynamic_library = True,
compilation_outputs = compilation_outputs,
)
)
Expand Down Expand Up @@ -240,6 +241,7 @@ def _cc_skylark_library_impl(ctx):
feature_configuration=feature_configuration,
linking_contexts = dep_linking_contexts,
name = ctx.label.name,
disallow_dynamic_library = True,
compilation_outputs=compilation_outputs)
)
return [CcInfo(
Expand Down