Removes call to CcLibraryHelper.link() in cc_binary.
This call is unnecessary when the sources of the cc_binary are being built as
EXECUTABLE or DYNAMIC LIBRARY. The call doesn't do anything, no linking outputs
are returned.
RELNOTES:none
@@ -249,9 +249,15 @@ public abstract class CcBinary implements RuleConfiguredTargetFactory {
// [*] The only library link type is STATIC_LIBRARY. EXECUTABLE specifies a normal
// cc_binary output, while DYNAMIC_LIBRARY is a cc_binary rules that produces an
// output matching a shared object, for example cc_binary(name="foo.so", ...) on linux.
- linkingHelper.setLinkType(
- linkCompileOutputSeparately ? LinkTargetType.STATIC_LIBRARY : linkType);
- Info.LinkingInfo linkingInfo = linkingHelper.link(ccCompilationOutputs, cppCompilationContext);
+ CcLinkingOutputs ccLinkingOutputs = CcLinkingOutputs.EMPTY;
+ if (linkCompileOutputSeparately) {
+ Info.LinkingInfo linkingInfo =
+ linkingHelper.link(ccCompilationOutputs, cppCompilationContext);
+ ccLinkingOutputs = linkingInfo.getCcLinkingOutputs();
+ linkingHelper.setLinkType(LinkTargetType.STATIC_LIBRARY);
+ } else {
+ linkingHelper.setLinkType(linkType);
+ }
CcLinkParams linkParams =
collectCcLinkParams(
@@ -268,7 +274,7 @@ public abstract class CcBinary implements RuleConfiguredTargetFactory {
common,
precompiledFiles,
ccCompilationOutputs,
- linkingInfo.getCcLinkingOutputs(),
+ ccLinkingOutputs,
cppCompilationContext.getTransitiveCompilationPrerequisites(),
fake,
binary,
@@ -448,7 +454,7 @@ public abstract class CcBinary implements RuleConfiguredTargetFactory {
ruleContext,
ccToolchain,
linkingOutputs,
- linkingInfo.getCcLinkingOutputs(),
+ ccLinkingOutputs,
cppCompilationContext,
linkStaticness,
filesToBuild,
