Fix memory regression objc_library

The regression was introduced by https://github.com/bazelbuild/bazel/commit/f6c4e624dc89ee0600b418eeea7108b6ed5c9708 which made create_linking_context_from_compilation_outputs() create empty archives for libraries without sources.

That behavior is needed for cc_library but we can simply not call the method when there are no sources in objc_libraries.

RELNOTES:none
PiperOrigin-RevId: 433420864
diff --git a/src/main/starlark/builtins_bzl/common/objc/compilation_support.bzl b/src/main/starlark/builtins_bzl/common/objc/compilation_support.bzl
index e46b3d3..326eaa2 100644
--- a/src/main/starlark/builtins_bzl/common/objc/compilation_support.bzl
+++ b/src/main/starlark/builtins_bzl/common/objc/compilation_support.bzl
@@ -482,19 +482,20 @@
     if hasattr(common_variables.ctx.attr, "deps"):
         linking_contexts = cc_helper.get_linking_contexts_from_deps(common_variables.ctx.attr.deps)
 
-    cc_common.create_linking_context_from_compilation_outputs(
-        actions = ctx.actions,
-        feature_configuration = feature_configuration,
-        cc_toolchain = common_variables.toolchain,
-        compilation_outputs = compilation_outputs,
-        linking_contexts = linking_contexts,
-        name = common_variables.ctx.label.name + intermediate_artifacts.archive_file_name_suffix,
-        language = language,
-        disallow_dynamic_library = True,
-        additional_inputs = additional_inputs,
-        grep_includes = _get_grep_includes(ctx),
-        variables_extension = non_arc_extensions,
-    )
+    if len(compilation_outputs.objects) != 0 or len(compilation_outputs.pic_objects) != 0:
+        cc_common.create_linking_context_from_compilation_outputs(
+            actions = ctx.actions,
+            feature_configuration = feature_configuration,
+            cc_toolchain = common_variables.toolchain,
+            compilation_outputs = compilation_outputs,
+            linking_contexts = linking_contexts,
+            name = common_variables.ctx.label.name + intermediate_artifacts.archive_file_name_suffix,
+            language = language,
+            disallow_dynamic_library = True,
+            additional_inputs = additional_inputs,
+            grep_includes = _get_grep_includes(ctx),
+            variables_extension = non_arc_extensions,
+        )
 
     arc_output_groups = cc_helper.build_output_groups_for_emitting_compile_providers(
         arc_compilation_outputs,