diff --git a/src/main/java/com/google/devtools/build/lib/rules/cpp/CcBinary.java b/src/main/java/com/google/devtools/build/lib/rules/cpp/CcBinary.java index 60a56cfbd110f5..0efc183f18fbdd 100644 --- a/src/main/java/com/google/devtools/build/lib/rules/cpp/CcBinary.java +++ b/src/main/java/com/google/devtools/build/lib/rules/cpp/CcBinary.java @@ -56,11 +56,9 @@ import com.google.devtools.build.lib.rules.apple.ApplePlatform; import com.google.devtools.build.lib.rules.cpp.CcCommon.CcFlagsSupplier; import com.google.devtools.build.lib.rules.cpp.CcCompilationHelper.CompilationInfo; -import com.google.devtools.build.lib.rules.cpp.CcLinkParams.LinkOptions; import com.google.devtools.build.lib.rules.cpp.CcToolchainFeatures.FeatureConfiguration; import com.google.devtools.build.lib.rules.cpp.CppConfiguration.DynamicMode; import com.google.devtools.build.lib.rules.cpp.CppConfiguration.Tool; -import com.google.devtools.build.lib.rules.cpp.LibraryToLinkWrapper.CcLinkingContext; import com.google.devtools.build.lib.rules.cpp.Link.LinkTargetType; import com.google.devtools.build.lib.rules.cpp.Link.LinkingMode; import com.google.devtools.build.lib.rules.cpp.LinkerInputs.LibraryToLink; @@ -114,11 +112,12 @@ public static class CcLauncherInfo extends NativeInfo { public static final Provider PROVIDER = new Provider(); private final CcCompilationOutputs ccCompilationOutputs; - private final CcInfo ccInfo; + private final CcLinkingInfo staticModeParamsForExecutable; - public CcLauncherInfo(CcInfo ccInfo, CcCompilationOutputs ccCompilationOutputs) { + public CcLauncherInfo( + CcLinkingInfo staticModeParamsForExecutable, CcCompilationOutputs ccCompilationOutputs) { super(PROVIDER); - this.ccInfo = ccInfo; + this.staticModeParamsForExecutable = staticModeParamsForExecutable; this.ccCompilationOutputs = ccCompilationOutputs; } @@ -127,9 +126,9 @@ public CcCompilationOutputs getCcCompilationOutputs(RuleContext ruleContext) { return ccCompilationOutputs; } - public CcInfo getCcInfo(RuleContext ruleContext) { + public CcLinkingInfo getStaticModeParamsForExecutable(RuleContext ruleContext) { checkRestrictedUsage(ruleContext); - return ccInfo; + return staticModeParamsForExecutable; } private void checkRestrictedUsage(RuleContext ruleContext) { @@ -359,8 +358,9 @@ public static ConfiguredTarget init(CppSemantics semantics, RuleContext ruleCont } boolean isStaticMode = linkingMode != LinkingMode.DYNAMIC; + boolean forDynamicLibrary = isLinkShared(ruleContext); - CcLinkingContext depsCcLinkingContext = collectCcLinkingContext(ruleContext); + CcLinkingInfo depsCcLinkingInfo = collectCcLinkingInfo(ruleContext); Artifact generatedDefFile = null; Artifact customDefFile = null; @@ -368,22 +368,14 @@ public static ConfiguredTarget init(CppSemantics semantics, RuleContext ruleCont if (featureConfiguration.isEnabled(CppRuleClasses.TARGETS_WINDOWS)) { ImmutableList.Builder objectFiles = ImmutableList.builder(); objectFiles.addAll(ccCompilationOutputs.getObjectFiles(false)); - - for (LibraryToLinkWrapper library : depsCcLinkingContext.getLibraries()) { - if (isStaticMode - || (library.getDynamicLibrary() == null && library.getInterfaceLibrary() == null)) { - if (library.getPicStaticLibrary() != null) { - if (library.getPicObjectFiles() != null) { - objectFiles.addAll(library.getPicObjectFiles()); - } - } else if (library.getStaticLibrary() != null) { - if (library.getObjectFiles() != null) { - objectFiles.addAll(library.getObjectFiles()); - } - } + for (LibraryToLink library : + depsCcLinkingInfo.getCcLinkParams(isStaticMode, forDynamicLibrary).getLibraries()) { + if (library.containsObjectFiles() + && library.getArtifactCategory() != ArtifactCategory.DYNAMIC_LIBRARY + && library.getArtifactCategory() != ArtifactCategory.INTERFACE_LIBRARY) { + objectFiles.addAll(library.getObjectFiles()); } } - generatedDefFile = CppHelper.createDefFileActions( ruleContext, @@ -403,12 +395,13 @@ public static ConfiguredTarget init(CppSemantics semantics, RuleContext ruleCont pdbFile = ruleContext.getRelatedArtifact(binary.getRootRelativePath(), ".pdb"); } - NestedSetBuilder extraLinkTimeLibrariesNestedSet = - NestedSetBuilder.linkOrder(); + NestedSetBuilder extraLinkTimeLibrariesNestedSet = NestedSetBuilder.linkOrder(); NestedSetBuilder extraLinkTimeRuntimeLibraries = NestedSetBuilder.linkOrder(); ExtraLinkTimeLibraries extraLinkTimeLibraries = - depsCcLinkingContext.getExtraLinkTimeLibraries(); + depsCcLinkingInfo + .getCcLinkParams(isStaticMode, forDynamicLibrary) + .getExtraLinkTimeLibraries(); if (extraLinkTimeLibraries != null) { ExtraLinkTimeLibrary.BuildLibraryOutput extraLinkBuildLibraryOutput = extraLinkTimeLibraries.buildLibraries( @@ -432,7 +425,7 @@ public static ConfiguredTarget init(CppSemantics semantics, RuleContext ruleCont ccCompilationContext, fake, binary, - depsCcLinkingContext, + depsCcLinkingInfo, extraLinkTimeLibrariesNestedSet.build(), linkCompileOutputSeparately, semantics, @@ -508,23 +501,14 @@ public static ConfiguredTarget init(CppSemantics semantics, RuleContext ruleCont // If the binary is linked dynamically and COPY_DYNAMIC_LIBRARIES_TO_BINARY is enabled, collect // all the dynamic libraries we need at runtime. Then copy these libraries next to the binary. if (featureConfiguration.isEnabled(CppRuleClasses.COPY_DYNAMIC_LIBRARIES_TO_BINARY)) { - ImmutableList.Builder runtimeLibraries = ImmutableList.builder(); - for (LibraryToLinkWrapper libraryToLinkWrapper : depsCcLinkingContext.getLibraries()) { - Artifact library = - libraryToLinkWrapper.getDynamicLibraryForRuntimeOrNull( - /* linkingStatically= */ isStaticMode); - if (library != null) { - runtimeLibraries.add(library); - } - } filesToBuild = NestedSetBuilder.fromNestedSet(filesToBuild) .addAll( createDynamicLibrariesCopyActions( ruleContext, - NestedSetBuilder.linkOrder() - .addAll(runtimeLibraries.build()) - .build())) + depsCcLinkingInfo + .getCcLinkParams(isStaticMode, forDynamicLibrary) + .getDynamicLibrariesForRuntime())) .build(); } @@ -614,8 +598,8 @@ public static Pair createTransitiveLinkingActi CcCompilationContext ccCompilationContext, boolean fake, Artifact binary, - CcLinkingContext depsCcLinkingContext, - NestedSet extraLinkTimeLibraries, + CcLinkingInfo depsCcLinkingInfo, + NestedSet extraLinkTimeLibraries, boolean linkCompileOutputSeparately, CppSemantics cppSemantics, LinkingMode linkingMode, @@ -640,26 +624,15 @@ public static Pair createTransitiveLinkingActi fdoContext, ruleContext.getConfiguration()); - CcInfo depsCcInfo = CcInfo.builder().setCcLinkingContext(depsCcLinkingContext).build(); - - CcLinkingContext.Builder currentCcLinkingContextBuilder = CcLinkingContext.builder(); + CcLinkParams.Builder ccLinkParamsBuilder = CcLinkParams.builder(); + ccLinkParamsBuilder.addTransitiveArgs( + depsCcLinkingInfo.getCcLinkParams( + linkingMode != LinkingMode.DYNAMIC, isLinkShared(ruleContext))); if (linkCompileOutputSeparately) { - ImmutableList.Builder localLibraries = ImmutableList.builder(); for (LibraryToLink library : ccLinkingOutputs.getDynamicLibrariesForLinking()) { - LibraryToLinkWrapper.Builder libraryToLinkWrapperBuilder = LibraryToLinkWrapper.builder(); - libraryToLinkWrapperBuilder.setLibraryIdentifier( - LibraryToLinkWrapper.setDynamicArtifactsAndReturnIdentifier( - libraryToLinkWrapperBuilder, - library, - library, - /* runtimeLibraryIterator= */ ImmutableList.of().listIterator())); - localLibraries.add(libraryToLinkWrapperBuilder.build()); + ccLinkParamsBuilder.addLibrary(library); } - currentCcLinkingContextBuilder.addLibraries( - NestedSetBuilder.linkOrder() - .addAll(localLibraries.build()) - .build()); ccCompilationOutputsWithOnlyObjects = new CcCompilationOutputs.Builder().build(); } @@ -667,81 +640,62 @@ public static Pair createTransitiveLinkingActi // First libraries from srcs. Shared library artifacts here are substituted with mangled symlink // artifacts generated by getDynamicLibraryLink(). This is done to minimize number of -rpath // entries during linking process. - ImmutableList.Builder precompiledLibraries = ImmutableList.builder(); for (Artifact library : precompiledFiles.getLibraries()) { if (Link.SHARED_LIBRARY_FILETYPES.matches(library.getFilename())) { - LibraryToLinkWrapper libraryToLinkWrapper = - LibraryToLinkWrapper.builder() - .setLibraryIdentifier(CcLinkingOutputs.libraryIdentifierOf(library)) - .setDynamicLibrary( - common.getDynamicLibrarySymlink(library, /* preserveName= */ true)) - .setResolvedSymlinkDynamicLibrary(library) - .build(); - precompiledLibraries.add(libraryToLinkWrapper); + ccLinkParamsBuilder.addLibrary( + LinkerInputs.solibLibraryToLink( + common.getDynamicLibrarySymlink(library, true), + library, + CcLinkingOutputs.libraryIdentifierOf(library))); } else if (Link.LINK_LIBRARY_FILETYPES.matches(library.getFilename())) { - LibraryToLinkWrapper libraryToLinkWrapper = - LibraryToLinkWrapper.builder() - .setLibraryIdentifier(CcLinkingOutputs.libraryIdentifierOf(library)) - .setStaticLibrary(library) - .setAlwayslink(true) - .build(); - precompiledLibraries.add(libraryToLinkWrapper); + ccLinkParamsBuilder.addLibrary( + LinkerInputs.precompiledLibraryToLink( + library, ArtifactCategory.ALWAYSLINK_STATIC_LIBRARY)); } else if (Link.ARCHIVE_FILETYPES.matches(library.getFilename())) { - LibraryToLinkWrapper libraryToLinkWrapper = - LibraryToLinkWrapper.builder() - .setLibraryIdentifier(CcLinkingOutputs.libraryIdentifierOf(library)) - .setStaticLibrary(library) - .build(); - precompiledLibraries.add(libraryToLinkWrapper); + ccLinkParamsBuilder.addLibrary( + LinkerInputs.precompiledLibraryToLink(library, ArtifactCategory.STATIC_LIBRARY)); } else { throw new IllegalStateException(); } } - currentCcLinkingContextBuilder.addLibraries( - NestedSetBuilder.wrap(Order.LINK_ORDER, precompiledLibraries.build())); - ImmutableList.Builder userLinkflags = ImmutableList.builder(); if (linkingMode != Link.LinkingMode.DYNAMIC && !cppConfiguration.disableEmittingStaticLibgcc()) { // Only force a static link of libgcc if static runtime linking is enabled (which // can't be true if runtimeInputs is empty). // TODO(bazel-team): Move this to CcToolchain. if (!ccToolchain.getStaticRuntimeLinkInputs(ruleContext, featureConfiguration).isEmpty()) { - userLinkflags.add("-static-libgcc"); + ccLinkParamsBuilder.addLinkOpts(ImmutableList.of("-static-libgcc")); } } - userLinkflags.addAll(common.getLinkopts()); - currentCcLinkingContextBuilder - .addNonCodeInputs( - NestedSetBuilder.linkOrder() - .addAll(ccCompilationContext.getTransitiveCompilationPrerequisites()) - .addAll(common.getLinkerScripts()) - .build()) - .addUserLinkFlags( - NestedSetBuilder.linkOrder() - .add(new LinkOptions(userLinkflags.build())) - .build()); - - CcInfo ccInfoWithoutExtraLinkTimeLibraries = - CcInfo.merge( - ImmutableList.of( - CcInfo.builder() - .setCcLinkingContext(currentCcLinkingContextBuilder.build()) - .build(), - depsCcInfo)); - - CcInfo extraLinkTimeLibrariesCcInfo = - CcInfo.builder() - .setCcLinkingContext( - CcLinkingContext.builder().addLibraries(extraLinkTimeLibraries).build()) + ccLinkParamsBuilder + .addNonCodeInputs(ccCompilationContext.getTransitiveCompilationPrerequisites()) + .addNonCodeInputs(common.getLinkerScripts()) + .addLinkOpts(common.getLinkopts()); + + CcLinkParams ccLinkParamsForLauncher = ccLinkParamsBuilder.build(); + CcLinkParams ccLinkParams = + CcLinkParams.builder() + .addTransitiveArgs(ccLinkParamsForLauncher) + .addLibraries(extraLinkTimeLibraries) + .addTransitiveArgs(CcLinkParams.builder().addLibraries(extraLinkTimeLibraries).build()) .build(); - CcInfo ccInfo = - CcInfo.merge( - ImmutableList.of(ccInfoWithoutExtraLinkTimeLibraries, extraLinkTimeLibrariesCcInfo)); + + CcLinkingInfo.Builder ccLinkingInfo = CcLinkingInfo.Builder.create(); + ccLinkingInfo.setStaticModeParamsForDynamicLibrary(ccLinkParams); + ccLinkingInfo.setStaticModeParamsForExecutable(ccLinkParams); + ccLinkingInfo.setDynamicModeParamsForDynamicLibrary(ccLinkParams); + ccLinkingInfo.setDynamicModeParamsForExecutable(ccLinkParams); + + CcLinkingInfo.Builder ccLinkingInfoForLauncher = CcLinkingInfo.Builder.create(); + ccLinkingInfoForLauncher.setStaticModeParamsForDynamicLibrary(ccLinkParamsForLauncher); + ccLinkingInfoForLauncher.setStaticModeParamsForExecutable(ccLinkParamsForLauncher); + ccLinkingInfoForLauncher.setDynamicModeParamsForDynamicLibrary(ccLinkParamsForLauncher); + ccLinkingInfoForLauncher.setDynamicModeParamsForExecutable(ccLinkParamsForLauncher); ccLinkingHelper - .addCcLinkingContexts(ImmutableList.of(ccInfo.getCcLinkingContext())) + .addCcLinkingInfos(ImmutableList.of(ccLinkingInfo.build())) .setUseTestOnlyFlags(ruleContext.isTestTarget()) .setShouldCreateStaticLibraries(false) .setLinkingMode(linkingMode) @@ -764,8 +718,7 @@ public static Pair createTransitiveLinkingActi return Pair.of( ccLinkingHelper.link(ccCompilationOutputsWithOnlyObjects), - new CcLauncherInfo( - ccInfoWithoutExtraLinkTimeLibraries, ccCompilationOutputsWithOnlyObjects)); + new CcLauncherInfo(ccLinkingInfoForLauncher.build(), ccCompilationOutputsWithOnlyObjects)); } /** @@ -985,7 +938,7 @@ private static Artifact getIntermediateDwpFile(RuleContext ruleContext, Artifact } /** Collect link parameters from the transitive closure. */ - private static CcLinkingContext collectCcLinkingContext(RuleContext context) { + private static CcLinkingInfo collectCcLinkingInfo(RuleContext context) { ImmutableList.Builder ccInfoListBuilder = ImmutableList.builder(); ccInfoListBuilder.addAll(context.getPrerequisites("deps", Mode.TARGET, CcInfo.PROVIDER)); @@ -995,7 +948,7 @@ private static CcLinkingContext collectCcLinkingContext(RuleContext context) { ccInfoListBuilder.add(ccInfo); } } - return CcInfo.merge(ccInfoListBuilder.build()).getCcLinkingContext(); + return CcInfo.merge(ccInfoListBuilder.build()).getCcLinkingInfo(); } private static void addTransitiveInfoProviders( diff --git a/src/main/java/com/google/devtools/build/lib/rules/cpp/CcLinkingHelper.java b/src/main/java/com/google/devtools/build/lib/rules/cpp/CcLinkingHelper.java index e6344ef89b7cc3..ed7e921f4861e8 100644 --- a/src/main/java/com/google/devtools/build/lib/rules/cpp/CcLinkingHelper.java +++ b/src/main/java/com/google/devtools/build/lib/rules/cpp/CcLinkingHelper.java @@ -211,13 +211,6 @@ public CcLinkingHelper addCcLinkingInfos(Iterable ccLinkingInfos) return this; } - public CcLinkingHelper addCcLinkingContexts(Iterable ccLinkingContexts) { - for (CcLinkingContext ccLinkingContext : ccLinkingContexts) { - ccLinkingInfos.add(ccLinkingContext.toCcLinkingInfo()); - } - return this; - } - /** * Adds the given linkstamps. Note that linkstamps are usually not compiled at the library level, * but only in the dependent binary rules. diff --git a/src/main/java/com/google/devtools/build/lib/rules/cpp/ExtraLinkTimeLibraries.java b/src/main/java/com/google/devtools/build/lib/rules/cpp/ExtraLinkTimeLibraries.java index 9f53944b6eb8d5..997ef10a8acdf9 100644 --- a/src/main/java/com/google/devtools/build/lib/rules/cpp/ExtraLinkTimeLibraries.java +++ b/src/main/java/com/google/devtools/build/lib/rules/cpp/ExtraLinkTimeLibraries.java @@ -20,6 +20,7 @@ import com.google.devtools.build.lib.collect.nestedset.NestedSetBuilder; import com.google.devtools.build.lib.packages.RuleClass.ConfiguredTargetFactory.RuleErrorException; import com.google.devtools.build.lib.rules.cpp.ExtraLinkTimeLibrary.BuildLibraryOutput; +import com.google.devtools.build.lib.rules.cpp.LinkerInputs.LibraryToLink; import com.google.devtools.build.lib.skyframe.serialization.autocodec.AutoCodec; import com.google.devtools.build.lib.skyframe.serialization.autocodec.AutoCodec.VisibleForSerialization; import java.util.Collection; @@ -106,7 +107,7 @@ public final Builder add(ExtraLinkTimeLibrary b) { public BuildLibraryOutput buildLibraries( RuleContext ruleContext, boolean staticMode, boolean forDynamicLibrary) throws InterruptedException, RuleErrorException { - NestedSetBuilder librariesToLink = NestedSetBuilder.linkOrder(); + NestedSetBuilder librariesToLink = NestedSetBuilder.linkOrder(); NestedSetBuilder runtimeLibraries = NestedSetBuilder.linkOrder(); for (ExtraLinkTimeLibrary extraLibrary : getExtraLibraries()) { BuildLibraryOutput buildLibraryOutput = diff --git a/src/main/java/com/google/devtools/build/lib/rules/cpp/ExtraLinkTimeLibrary.java b/src/main/java/com/google/devtools/build/lib/rules/cpp/ExtraLinkTimeLibrary.java index 28722fb0334cf0..fab76f856af2f9 100644 --- a/src/main/java/com/google/devtools/build/lib/rules/cpp/ExtraLinkTimeLibrary.java +++ b/src/main/java/com/google/devtools/build/lib/rules/cpp/ExtraLinkTimeLibrary.java @@ -18,6 +18,7 @@ import com.google.devtools.build.lib.analysis.RuleContext; import com.google.devtools.build.lib.collect.nestedset.NestedSet; import com.google.devtools.build.lib.packages.RuleClass.ConfiguredTargetFactory.RuleErrorException; +import com.google.devtools.build.lib.rules.cpp.LinkerInputs.LibraryToLink; /** * An extra library to include in a link. The actual library is built at link time. @@ -33,16 +34,16 @@ public interface ExtraLinkTimeLibrary { /** Output of {@link #buildLibraries}. Pair of libraries to link and runtime libraries. */ class BuildLibraryOutput { - public NestedSet librariesToLink; + public NestedSet librariesToLink; public NestedSet runtimeLibraries; public BuildLibraryOutput( - NestedSet librariesToLink, NestedSet runtimeLibraries) { + NestedSet librariesToLink, NestedSet runtimeLibraries) { this.librariesToLink = librariesToLink; this.runtimeLibraries = runtimeLibraries; } - public NestedSet getLibrariesToLink() { + public NestedSet getLibrariesToLink() { return librariesToLink; } diff --git a/src/main/java/com/google/devtools/build/lib/rules/cpp/LibraryToLinkWrapper.java b/src/main/java/com/google/devtools/build/lib/rules/cpp/LibraryToLinkWrapper.java index 90e1950e332626..0d1057bc42d06f 100644 --- a/src/main/java/com/google/devtools/build/lib/rules/cpp/LibraryToLinkWrapper.java +++ b/src/main/java/com/google/devtools/build/lib/rules/cpp/LibraryToLinkWrapper.java @@ -118,14 +118,11 @@ public static LibraryToLinkWrapper convertLinkOutputsToLibraryToLinkWrapper( return libraryToLinkWrapperBuilder.build(); } - public Artifact getDynamicLibraryForRuntimeOrNull(boolean linkingStatically) { - if (dynamicLibrary == null) { - return null; + public Artifact getDynamicLibraryForRuntimeOrNull() { + if (staticLibrary == null && picStaticLibrary == null && dynamicLibrary != null) { + return dynamicLibrary; } - if (linkingStatically && (staticLibrary != null || picStaticLibrary != null)) { - return null; - } - return dynamicLibrary; + return null; } /** Structure of the new CcLinkingContext. This will replace {@link CcLinkingInfo}. */ @@ -639,12 +636,11 @@ private static String setStaticArtifactsAndReturnIdentifier( @Nullable @SuppressWarnings("ReferenceEquality") - public static String setDynamicArtifactsAndReturnIdentifier( + private static String setDynamicArtifactsAndReturnIdentifier( LibraryToLinkWrapper.Builder libraryToLinkWrapperBuilder, LibraryToLink dynamicModeParamsForExecutableEntry, LibraryToLink dynamicModeParamsForDynamicLibraryEntry, ListIterator runtimeLibraryIterator) { - Preconditions.checkNotNull(runtimeLibraryIterator); Artifact artifact = dynamicModeParamsForExecutableEntry.getArtifact(); String libraryIdentifier = null; Artifact runtimeArtifact = null; @@ -913,28 +909,22 @@ private static CcLinkParams buildStaticModeParamsForExecutableCcLinkParams( initializeCcLinkParams(linkOpts, linkstamps, nonCodeInputs, extraLinkTimeLibraries); for (LibraryToLinkWrapper libraryToLinkWrapper : libraryToLinkWrappers) { boolean usedDynamic = false; - CcLinkParams.Builder oneSingleLibraryCcLinkParamsBuilder = CcLinkParams.builder(); if (libraryToLinkWrapper.getStaticLibrary() != null) { - oneSingleLibraryCcLinkParamsBuilder.addLibraries( - ImmutableList.of(libraryToLinkWrapper.getStaticLibraryToLink())); + ccLinkParamsBuilder.addLibrary(libraryToLinkWrapper.getStaticLibraryToLink()); } else if (libraryToLinkWrapper.getPicStaticLibrary() != null) { - oneSingleLibraryCcLinkParamsBuilder.addLibraries( - ImmutableList.of(libraryToLinkWrapper.getPicStaticLibraryToLink())); + ccLinkParamsBuilder.addLibrary(libraryToLinkWrapper.getPicStaticLibraryToLink()); } else if (libraryToLinkWrapper.getInterfaceLibrary() != null) { usedDynamic = true; - oneSingleLibraryCcLinkParamsBuilder.addLibraries( - ImmutableList.of(libraryToLinkWrapper.getInterfaceLibraryToLink())); + ccLinkParamsBuilder.addLibrary(libraryToLinkWrapper.getInterfaceLibraryToLink()); } else if (libraryToLinkWrapper.getDynamicLibrary() != null) { usedDynamic = true; - oneSingleLibraryCcLinkParamsBuilder.addLibraries( - ImmutableList.of(libraryToLinkWrapper.getDynamicLibraryToLink())); + ccLinkParamsBuilder.addLibrary(libraryToLinkWrapper.getDynamicLibraryToLink()); } if (usedDynamic && libraryToLinkWrapper.getDynamicLibrary() != null) { - oneSingleLibraryCcLinkParamsBuilder.addDynamicLibrariesForRuntime( + ccLinkParamsBuilder.addDynamicLibrariesForRuntime( ImmutableList.of(libraryToLinkWrapper.getDynamicLibrary())); } - ccLinkParamsBuilder.addTransitiveArgs(oneSingleLibraryCcLinkParamsBuilder.build()); } return ccLinkParamsBuilder.build(); } @@ -949,28 +939,22 @@ private static CcLinkParams buildStaticModeParamsForDynamicLibraryCcLinkParams( initializeCcLinkParams(linkOpts, linkstamps, nonCodeInputs, extraLinkTimeLibraries); for (LibraryToLinkWrapper libraryToLinkWrapper : libraryToLinkWrappers) { boolean usedDynamic = false; - CcLinkParams.Builder oneSingleLibraryCcLinkParamsBuilder = CcLinkParams.builder(); if (libraryToLinkWrapper.getPicStaticLibrary() != null) { - oneSingleLibraryCcLinkParamsBuilder.addLibraries( - ImmutableList.of(libraryToLinkWrapper.getPicStaticLibraryToLink())); + ccLinkParamsBuilder.addLibrary(libraryToLinkWrapper.getPicStaticLibraryToLink()); } else if (libraryToLinkWrapper.getStaticLibrary() != null) { - oneSingleLibraryCcLinkParamsBuilder.addLibraries( - ImmutableList.of(libraryToLinkWrapper.getStaticLibraryToLink())); + ccLinkParamsBuilder.addLibrary(libraryToLinkWrapper.getStaticLibraryToLink()); } else if (libraryToLinkWrapper.getInterfaceLibrary() != null) { usedDynamic = true; - oneSingleLibraryCcLinkParamsBuilder.addLibraries( - ImmutableList.of(libraryToLinkWrapper.getInterfaceLibraryToLink())); + ccLinkParamsBuilder.addLibrary(libraryToLinkWrapper.getInterfaceLibraryToLink()); } else if (libraryToLinkWrapper.getDynamicLibrary() != null) { usedDynamic = true; - oneSingleLibraryCcLinkParamsBuilder.addLibraries( - ImmutableList.of(libraryToLinkWrapper.getDynamicLibraryToLink())); + ccLinkParamsBuilder.addLibrary(libraryToLinkWrapper.getDynamicLibraryToLink()); } if (usedDynamic && libraryToLinkWrapper.getDynamicLibrary() != null) { - oneSingleLibraryCcLinkParamsBuilder.addDynamicLibrariesForRuntime( + ccLinkParamsBuilder.addDynamicLibrariesForRuntime( ImmutableList.of(libraryToLinkWrapper.getDynamicLibrary())); } - ccLinkParamsBuilder.addTransitiveArgs(oneSingleLibraryCcLinkParamsBuilder.build()); } return ccLinkParamsBuilder.build(); } @@ -985,28 +969,22 @@ private static CcLinkParams buildDynamicModeParamsForExecutableCcLinkParams( initializeCcLinkParams(linkOpts, linkstamps, nonCodeInputs, extraLinkTimeLibraries); for (LibraryToLinkWrapper libraryToLinkWrapper : libraryToLinkWrappers) { boolean usedDynamic = false; - CcLinkParams.Builder oneSingleLibraryCcLinkParamsBuilder = CcLinkParams.builder(); if (libraryToLinkWrapper.getInterfaceLibrary() != null) { usedDynamic = true; - oneSingleLibraryCcLinkParamsBuilder.addLibraries( - ImmutableList.of(libraryToLinkWrapper.getInterfaceLibraryToLink())); + ccLinkParamsBuilder.addLibrary(libraryToLinkWrapper.getInterfaceLibraryToLink()); } else if (libraryToLinkWrapper.getDynamicLibrary() != null) { usedDynamic = true; - oneSingleLibraryCcLinkParamsBuilder.addLibraries( - ImmutableList.of(libraryToLinkWrapper.getDynamicLibraryToLink())); + ccLinkParamsBuilder.addLibrary(libraryToLinkWrapper.getDynamicLibraryToLink()); } else if (libraryToLinkWrapper.getStaticLibrary() != null) { - oneSingleLibraryCcLinkParamsBuilder.addLibraries( - ImmutableList.of(libraryToLinkWrapper.getStaticLibraryToLink())); + ccLinkParamsBuilder.addLibrary(libraryToLinkWrapper.getStaticLibraryToLink()); } else if (libraryToLinkWrapper.getPicStaticLibrary() != null) { - oneSingleLibraryCcLinkParamsBuilder.addLibraries( - ImmutableList.of(libraryToLinkWrapper.getPicStaticLibraryToLink())); + ccLinkParamsBuilder.addLibrary(libraryToLinkWrapper.getPicStaticLibraryToLink()); } if (usedDynamic && libraryToLinkWrapper.getDynamicLibrary() != null) { - oneSingleLibraryCcLinkParamsBuilder.addDynamicLibrariesForRuntime( + ccLinkParamsBuilder.addDynamicLibrariesForRuntime( ImmutableList.of(libraryToLinkWrapper.getDynamicLibrary())); } - ccLinkParamsBuilder.addTransitiveArgs(oneSingleLibraryCcLinkParamsBuilder.build()); } return ccLinkParamsBuilder.build(); } @@ -1021,28 +999,22 @@ private static CcLinkParams buildDynamicModeParamsForDynamicLibraryCcLinkParams( initializeCcLinkParams(linkOpts, linkstamps, nonCodeInputs, extraLinkTimeLibraries); for (LibraryToLinkWrapper libraryToLinkWrapper : libraryToLinkWrappers) { boolean usedDynamic = false; - CcLinkParams.Builder oneSingleLibraryCcLinkParamsBuilder = CcLinkParams.builder(); if (libraryToLinkWrapper.getInterfaceLibrary() != null) { usedDynamic = true; - oneSingleLibraryCcLinkParamsBuilder.addLibraries( - ImmutableList.of(libraryToLinkWrapper.getInterfaceLibraryToLink())); + ccLinkParamsBuilder.addLibrary(libraryToLinkWrapper.getInterfaceLibraryToLink()); } else if (libraryToLinkWrapper.getDynamicLibrary() != null) { usedDynamic = true; - oneSingleLibraryCcLinkParamsBuilder.addLibraries( - ImmutableList.of(libraryToLinkWrapper.getDynamicLibraryToLink())); + ccLinkParamsBuilder.addLibrary(libraryToLinkWrapper.getDynamicLibraryToLink()); } else if (libraryToLinkWrapper.getPicStaticLibrary() != null) { - oneSingleLibraryCcLinkParamsBuilder.addLibraries( - ImmutableList.of(libraryToLinkWrapper.getPicStaticLibraryToLink())); + ccLinkParamsBuilder.addLibrary(libraryToLinkWrapper.getPicStaticLibraryToLink()); } else if (libraryToLinkWrapper.getStaticLibrary() != null) { - oneSingleLibraryCcLinkParamsBuilder.addLibraries( - ImmutableList.of(libraryToLinkWrapper.getStaticLibraryToLink())); + ccLinkParamsBuilder.addLibrary(libraryToLinkWrapper.getStaticLibraryToLink()); } if (usedDynamic && libraryToLinkWrapper.getDynamicLibrary() != null) { - oneSingleLibraryCcLinkParamsBuilder.addDynamicLibrariesForRuntime( + ccLinkParamsBuilder.addDynamicLibrariesForRuntime( ImmutableList.of(libraryToLinkWrapper.getDynamicLibrary())); } - ccLinkParamsBuilder.addTransitiveArgs(oneSingleLibraryCcLinkParamsBuilder.build()); } return ccLinkParamsBuilder.build(); }