Source:
private Pair<Boolean, Boolean> addLinkerInputs( NestedSetBuilder<String> librarySearchDirectories, ImmutableSet.Builder<String> rpathEntries, SequenceBuilder librariesToLink, NestedSetBuilder<LinkerInput> expandedLinkerInputsBuilder) { boolean includeSolibDir = false; boolean includeToolchainLibrariesSolibDir = false; HashMap<String, PathFragment> linkedLibrariesPaths = new HashMap<>(); for (LinkerInput input : linkerInputs) { if (input.getArtifactCategory() == ArtifactCategory.DYNAMIC_LIBRARY || input.getArtifactCategory() == ArtifactCategory.INTERFACE_LIBRARY) { PathFragment libDir = input.getArtifact().getExecPath().getParentDirectory(); String libraryIdentifier = input.getLibraryIdentifier(); PathFragment previousLibDir = linkedLibrariesPaths.get(libraryIdentifier); if (previousLibDir == null) { linkedLibrariesPaths.put(libraryIdentifier, libDir); } else if (!previousLibDir.equals(libDir)) { ruleErrorConsumer.ruleError( String.format( "You are trying to link the same dynamic library %s built in a different configuration", libraryIdentifier)); } if (!featureConfiguration.isEnabled(CppRuleClasses.COPY_DYNAMIC_LIBRARIES_TO_BINARY)) { if (libDir.equals(solibDir)) { includeSolibDir = true; } if (libDir.equals(toolchainLibrariesSolibDir)) { includeToolchainLibrariesSolibDir = true; } } addDynamicInputLinkOptions( input, librariesToLink, expandedLinkerInputsBuilder, librarySearchDirectories, rpathEntries); } else { addStaticInputLinkOptions(input, librariesToLink, expandedLinkerInputsBuilder); } } return Pair.of(includeSolibDir, includeToolchainLibrariesSolibDir); }

Target:
private Pair<Boolean, Boolean> addLinkerInputs( NestedSetBuilder<String> librarySearchDirectories, ImmutableSet.Builder<String> rpathEntries, SequenceBuilder librariesToLink, NestedSetBuilder<LinkerInput> expandedLinkerInputsBuilder) { boolean includeSolibDir = false; boolean includeToolchainLibrariesSolibDir = false; Map<String, PathFragment> linkedLibrariesPaths = new HashMap<>(); for (LinkerInput input : linkerInputs) { if (input.getArtifactCategory() == ArtifactCategory.DYNAMIC_LIBRARY || input.getArtifactCategory() == ArtifactCategory.INTERFACE_LIBRARY) { PathFragment libDir = input.getArtifact().getExecPath().getParentDirectory(); Preconditions.checkNotNull(libDir); String libraryIdentifier = input.getLibraryIdentifier(); PathFragment previousLibDir = linkedLibrariesPaths.get(libraryIdentifier); if (previousLibDir == null) { linkedLibrariesPaths.put(libraryIdentifier, libDir); } else if (!previousLibDir.equals(libDir)) { ruleErrorConsumer.ruleError( String.format( "You are trying to link the same dynamic library %s built in a different configuration. " + "Previously registered instance had path %s, current one has path %s", libraryIdentifier, previousLibDir, libDir)); } if (!featureConfiguration.isEnabled(CppRuleClasses.COPY_DYNAMIC_LIBRARIES_TO_BINARY)) { if (libDir.equals(solibDir)) { includeSolibDir = true; } if (libDir.equals(toolchainLibrariesSolibDir)) { includeToolchainLibrariesSolibDir = true; } } addDynamicInputLinkOptions( input, librariesToLink, expandedLinkerInputsBuilder, librarySearchDirectories, rpathEntries); } else { addStaticInputLinkOptions(input, librariesToLink, expandedLinkerInputsBuilder); } } return Pair.of(includeSolibDir, includeToolchainLibrariesSolibDir); }