From 7cc6c629c2475062bed3abca004c4fcfb9d4adb5 Mon Sep 17 00:00:00 2001 From: Cal Peyser Date: Wed, 1 Mar 2017 19:39:08 +0000 Subject: 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 --- .../google/devtools/build/lib/rules/cpp/Link.java | 4 ++-- .../build/lib/rules/cpp/LinkCommandLine.java | 27 ++++++++++------------ .../rules/objc/CrosstoolCompilationSupport.java | 1 + 3 files changed, 15 insertions(+), 17 deletions(-) (limited to 'src/main/java/com/google') 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 bddde77baf..ff24408a40 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 @@ public abstract class Link { /** An objc executable. */ OBJC_EXECUTABLE( "", - Staticness.STATIC, + Staticness.DYNAMIC, "objc-executable", Picness.NOPIC, ArtifactCategory.EXECUTABLE, @@ -155,7 +155,7 @@ public abstract class Link { /** 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 bb3cdbdb79..82d2e26bc7 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 @@ public final class LinkCommandLine extends CommandLine { .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 @@ public final class LinkCommandLine extends CommandLine { 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 dbf6632d3c..52cf6b828c 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 @@ public class CrosstoolCompilationSupport extends CompilationSupport { .addActionInput(inputFileList) .setLinkType(linkType) .setLinkStaticness(LinkStaticness.FULLY_STATIC) + .addLinkopts(ImmutableList.copyOf(extraLinkArgs)) .addVariablesExtension(extension) .setFeatureConfiguration(getFeatureConfiguration(ruleContext, buildConfiguration)) .build(); -- cgit v1.2.3