Skip to content

Commit 031862e

Browse files
fix: load CcSharedLibraryInfo from rules_cc for Bazel 9 (#1493)
This is to make `rules_foreign_cc` _consumable_ with Bazel 9 where `cc_external_rule_impl` currently fails on: ``` Error in fail: CcSharedLibraryInfo is only available in Bazel 7 or greater ``` The guard was relying on `bazel_features.globals.CcSharedLibraryInfo` to detect provider availability. In Bazel 9, `bazel_features` computes this via `native.legacy_globals.CcSharedLibraryInfo`, which is `None` because the symbol was removed from the `native` namespace. `CcSharedLibraryInfo` has been available in `@rules_cc` since 0.1.0, which predates the minimum `rules_cc` version required by `rules_foreign_cc`. Loading it directly from `@rules_cc//cc/common:cc_shared_library_info.bzl` makes the guard unnecessary and should satisfy all Bazel versions. Co-authored-by: Mike Lundy <milundy@cisco.com>
1 parent 7874a4a commit 031862e

1 file changed

Lines changed: 2 additions & 5 deletions

File tree

foreign_cc/private/framework.bzl

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@
22
with CMake, configure/make, autotools)
33
"""
44

5-
load("@bazel_features//:features.bzl", "bazel_features")
65
load("@bazel_skylib//lib:collections.bzl", "collections")
76
load("@bazel_skylib//lib:paths.bzl", "paths")
87
load("@bazel_tools//tools/cpp:toolchain_utils.bzl", "find_cpp_toolchain")
98
load("@rules_cc//cc:defs.bzl", "CcInfo", "cc_common")
9+
load("@rules_cc//cc/common:cc_shared_library_info.bzl", "CcSharedLibraryInfo")
1010
load("//foreign_cc:providers.bzl", "ForeignCcArtifactInfo", "ForeignCcDepsInfo")
1111
load("//foreign_cc/private:detect_root.bzl", "filter_containing_dirs_from_inputs")
1212
load("//foreign_cc/private:resource_sets.bzl", "SIZE_ATTRIBUTES", "get_resource_env_vars")
@@ -967,10 +967,7 @@ def _define_inputs(attrs):
967967
bazel_libs += _collect_libs(dep[CcInfo].linking_context)
968968

969969
for dynamic_dep in attrs.dynamic_deps:
970-
if not bazel_features.globals.CcSharedLibraryInfo:
971-
fail("CcSharedLibraryInfo is only available in Bazel 7 or greater")
972-
973-
linker_input = dynamic_dep[bazel_features.globals.CcSharedLibraryInfo].linker_input
970+
linker_input = dynamic_dep[CcSharedLibraryInfo].linker_input
974971
bazel_libs += _collect_shared_libs(linker_input)
975972
linking_context = cc_common.create_linking_context(
976973
linker_inputs = depset(direct = [linker_input]),

0 commit comments

Comments
 (0)