Remove NO_EXPORTING tag from cc_shared_library

The same behavior can be achieved via an indirect cc_library (i.e. not placed
in cc_shared_library.deps) that is LINKABLE_MORE_THAN_ONCE

RELNOTES:none
PiperOrigin-RevId: 514727112
Change-Id: Ic5053f7b534d3bd69b4c61639b299936dc9990eb
diff --git a/src/main/starlark/builtins_bzl/common/cc/experimental_cc_shared_library.bzl b/src/main/starlark/builtins_bzl/common/cc/experimental_cc_shared_library.bzl
index 28018e5..b06d341 100644
--- a/src/main/starlark/builtins_bzl/common/cc/experimental_cc_shared_library.bzl
+++ b/src/main/starlark/builtins_bzl/common/cc/experimental_cc_shared_library.bzl
@@ -33,22 +33,12 @@
 # used sparingly after making sure it's safe to use.
 LINKABLE_MORE_THAN_ONCE = "LINKABLE_MORE_THAN_ONCE"
 
-# Add this as a tag to any static lib target that doesn't export any symbols,
-# thus can be statically linked more than once. This is useful in some cases,
-# for example, a static lib has a constructor that needs to be run during
-# loading time of the shared lib that has it linked into, which is how the
-# code gets called by the OS. This static lib might need to be linked as a
-# whole archive dep for multiple shared libs, otherwise this static lib will
-# be dropped by the linker since there are no incoming symbol references.
-NO_EXPORTING = "NO_EXPORTING"
-
 GraphNodeInfo = provider(
     "Nodes in the graph of shared libraries.",
     fields = {
         "children": "Other GraphNodeInfo from dependencies of this target",
         "label": "Label of the target visited",
         "linkable_more_than_once": "Linkable into more than a single cc_shared_library",
-        "no_exporting": "The static lib doesn't export any symbols so don't export it",
     },
 )
 CcSharedLibraryInfo = provider(
@@ -504,12 +494,7 @@
     runfiles = runfiles.merge(ctx.runfiles(files = precompiled_only_dynamic_libraries_runfiles))
 
     for export in deps:
-        export_label = str(export.label)
-        if GraphNodeInfo in export and export[GraphNodeInfo].no_exporting:
-            if export_label in curr_link_once_static_libs_set:
-                curr_link_once_static_libs_set.remove(export_label)
-            continue
-        exports[export_label] = True
+        exports[str(export.label)] = True
 
     debug_files = []
     exports_debug_file = ctx.actions.declare_file(ctx.label.name + "_exports.txt")
@@ -577,19 +562,15 @@
     # TODO(bazel-team): Add flag to Bazel that can toggle the initialization of
     # linkable_more_than_once.
     linkable_more_than_once = False
-    no_exporting = False
     if hasattr(ctx.rule.attr, "tags"):
         for tag in ctx.rule.attr.tags:
             if tag == LINKABLE_MORE_THAN_ONCE:
                 linkable_more_than_once = True
-            elif tag == NO_EXPORTING:
-                no_exporting = True
 
     return [GraphNodeInfo(
         label = ctx.label,
         children = children,
         linkable_more_than_once = linkable_more_than_once,
-        no_exporting = no_exporting,
     )]
 
 graph_structure_aspect = aspect(
diff --git a/src/main/starlark/tests/builtins_bzl/cc/cc_shared_library/test_cc_shared_library/BUILD.builtin_test b/src/main/starlark/tests/builtins_bzl/cc/cc_shared_library/test_cc_shared_library/BUILD.builtin_test
index d1d12ae..4dd8bc4 100644
--- a/src/main/starlark/tests/builtins_bzl/cc/cc_shared_library/test_cc_shared_library/BUILD.builtin_test
+++ b/src/main/starlark/tests/builtins_bzl/cc/cc_shared_library/test_cc_shared_library/BUILD.builtin_test
@@ -7,7 +7,6 @@
     "linking_suffix_test",
     "paths_test",
     "runfiles_test",
-    "no_exporting_static_lib_test",
     "check_already_linked_inputs_are_not_passed_to_linking_action_test",
 )
 
@@ -386,51 +385,6 @@
     ],
 )
 
-cc_library(
-    name = "static_lib_no_exporting",
-    srcs = [
-        "bar.cc",
-        "bar.h",
-    ],
-    tags = ["NO_EXPORTING"],
-)
-
-cc_library(
-    name = "static_lib_exporting",
-    srcs = [
-        "bar2.cc",
-        "bar2.h",
-    ],
-)
-
-cc_shared_library(
-    name = "lib_with_no_exporting_roots_1",
-    deps = [":static_lib_no_exporting"],
-)
-
-cc_shared_library(
-    name = "lib_with_no_exporting_roots_2",
-    deps = [":static_lib_no_exporting"],
-    dynamic_deps = [":lib_with_no_exporting_roots_3"],
-)
-
-cc_shared_library(
-    name = "lib_with_no_exporting_roots_3",
-    deps = [":static_lib_no_exporting"],
-)
-
-cc_shared_library(
-    name = "lib_with_no_exporting_roots",
-    deps = [
-        ":static_lib_no_exporting",
-        ":static_lib_exporting",
-    ],
-    dynamic_deps = [
-        ":lib_with_no_exporting_roots_1",
-        ":lib_with_no_exporting_roots_2",
-    ],
-)
-
 build_failure_test(
     name = "two_dynamic_deps_same_export_in_so_test",
     message = "Two shared libraries in dependencies export the same symbols",
@@ -466,11 +420,6 @@
     target_under_test = ":python_test",
 )
 
-no_exporting_static_lib_test(
-    name = "no_exporting_static_lib_test",
-    target_under_test = ":lib_with_no_exporting_roots",
-)
-
 check_already_linked_inputs_are_not_passed_to_linking_action_test(
     name = "check_binary_doesnt_take_already_linked_in_libs",
     target_under_test = ":binary",
diff --git a/src/main/starlark/tests/builtins_bzl/cc/cc_shared_library/test_cc_shared_library/starlark_tests.bzl b/src/main/starlark/tests/builtins_bzl/cc/cc_shared_library/test_cc_shared_library/starlark_tests.bzl
index 678c03b..8732cea 100644
--- a/src/main/starlark/tests/builtins_bzl/cc/cc_shared_library/test_cc_shared_library/starlark_tests.bzl
+++ b/src/main/starlark/tests/builtins_bzl/cc/cc_shared_library/test_cc_shared_library/starlark_tests.bzl
@@ -246,21 +246,3 @@
         "libs_that_shouldnt_be_present": attr.string_list(),
     },
 )
-
-def _no_exporting_static_lib_test_impl(ctx):
-    env = analysistest.begin(ctx)
-
-    target_under_test = analysistest.target_under_test(env)
-
-    # There should be only one exported file
-    actual_file = target_under_test[CcSharedLibraryInfo].exports[0]
-
-    # Sometimes "@" is prefixed in some test environments
-    expected = "//src/main/starlark/tests/builtins_bzl/cc/cc_shared_library/test_cc_shared_library:static_lib_exporting"
-    asserts.true(env, actual_file.endswith(expected))
-
-    return analysistest.end(env)
-
-no_exporting_static_lib_test = analysistest.make(
-    _no_exporting_static_lib_test_impl,
-)