ios_test provides test-specific command line args when using the crosstool.
This requires passing linkopts through CrosstoolCompilationSupport into the 'legacy_link_flags' feature, as is done in c++.

--
PiperOrigin-RevId: 148911500
MOS_MIGRATED_REVID=148911500
diff --git a/src/main/java/com/google/devtools/build/lib/rules/cpp/Link.java b/src/main/java/com/google/devtools/build/lib/rules/cpp/Link.java
index bddde77..ff24408 100644
--- a/src/main/java/com/google/devtools/build/lib/rules/cpp/Link.java
+++ b/src/main/java/com/google/devtools/build/lib/rules/cpp/Link.java
@@ -146,7 +146,7 @@
     /** An objc executable. */
     OBJC_EXECUTABLE(
         "",
-        Staticness.STATIC,
+        Staticness.DYNAMIC,
         "objc-executable",
         Picness.NOPIC,
         ArtifactCategory.EXECUTABLE,
@@ -155,7 +155,7 @@
     /** An objc executable that includes objc++/c++ source. */
     OBJCPP_EXECUTABLE(
         "",
-        Staticness.STATIC,
+        Staticness.DYNAMIC,
         "objc++-executable",
         Picness.NOPIC,
         ArtifactCategory.EXECUTABLE,
diff --git a/src/main/java/com/google/devtools/build/lib/rules/cpp/LinkCommandLine.java b/src/main/java/com/google/devtools/build/lib/rules/cpp/LinkCommandLine.java
index bb3cdbd..82d2e26 100644
--- a/src/main/java/com/google/devtools/build/lib/rules/cpp/LinkCommandLine.java
+++ b/src/main/java/com/google/devtools/build/lib/rules/cpp/LinkCommandLine.java
@@ -397,18 +397,6 @@
                     .build()));
         break;
 
-      case DYNAMIC_LIBRARY:
-        argv.add(toolPath);
-        argv.addAll(
-            featureConfiguration.getCommandLine(
-                actionName,
-                new Variables.Builder()
-                    .addAll(variables)
-                    .addStringSequenceVariable(
-                        CppLinkActionBuilder.LEGACY_LINK_FLAGS_VARIABLE, getToolchainFlags())
-                    .build()));
-        break;
-
       case STATIC_LIBRARY:
       case PIC_STATIC_LIBRARY:
       case ALWAYS_LINK_STATIC_LIBRARY:
@@ -421,14 +409,23 @@
         argv.addAll(featureConfiguration.getCommandLine(actionName, variables));
         break;
 
-        // Since the objc case is not hardcoded in CppConfiguration, we can use the actual tool.
-        // TODO(b/30109612): make this pattern the case for all link variants.
+      // Since the objc case/dynamic libs is not hardcoded in CppConfiguration, we can use the
+      // actual tool.
+      // TODO(b/30109612): make this pattern the case for all link variants.
+      case DYNAMIC_LIBRARY:
       case OBJC_ARCHIVE:
       case OBJC_FULLY_LINKED_ARCHIVE:
       case OBJC_EXECUTABLE:
       case OBJCPP_EXECUTABLE:
         argv.add(toolPath);
-        argv.addAll(featureConfiguration.getCommandLine(actionName, variables));
+        argv.addAll(
+            featureConfiguration.getCommandLine(
+                actionName,
+                new Variables.Builder()
+                    .addAll(variables)
+                    .addStringSequenceVariable(
+                        CppLinkActionBuilder.LEGACY_LINK_FLAGS_VARIABLE, getToolchainFlags())
+                    .build()));
         break;
 
       default:
diff --git a/src/main/java/com/google/devtools/build/lib/rules/objc/CrosstoolCompilationSupport.java b/src/main/java/com/google/devtools/build/lib/rules/objc/CrosstoolCompilationSupport.java
index dbf6632..52cf6b8 100644
--- a/src/main/java/com/google/devtools/build/lib/rules/objc/CrosstoolCompilationSupport.java
+++ b/src/main/java/com/google/devtools/build/lib/rules/objc/CrosstoolCompilationSupport.java
@@ -252,6 +252,7 @@
             .addActionInput(inputFileList)
             .setLinkType(linkType)
             .setLinkStaticness(LinkStaticness.FULLY_STATIC)
+            .addLinkopts(ImmutableList.copyOf(extraLinkArgs))
             .addVariablesExtension(extension)
             .setFeatureConfiguration(getFeatureConfiguration(ruleContext, buildConfiguration))
             .build();