Skip to content

Commit

Permalink
Embed the == and .equal number of linkstamp artifacts in the nativede…
Browse files Browse the repository at this point in the history
…ps hashed filename, since normally there should be only one linkstamp artifact in any case.

This shouldn't affect filenames or performance except in the exceptional mysterious case we're trying to track down.

PiperOrigin-RevId: 228882225
  • Loading branch information
janakdr authored and Copybara-Service committed Jan 11, 2019
1 parent 4798f47 commit 4026334
Showing 1 changed file with 17 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
import com.google.common.base.Preconditions;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableSet;
import com.google.common.collect.Iterables;
import com.google.common.collect.Sets;
import com.google.devtools.build.lib.actions.Artifact;
import com.google.devtools.build.lib.actions.ArtifactRoot;
import com.google.devtools.build.lib.analysis.RuleContext;
Expand Down Expand Up @@ -52,6 +54,7 @@
import java.util.Collection;
import java.util.LinkedList;
import java.util.List;
import java.util.Set;

/**
* Helper class to create a dynamic library for rules which support integration with native code.
Expand Down Expand Up @@ -367,6 +370,19 @@ private static PathFragment getSharedNativeDepsPath(Iterable<Artifact> linkerInp
fp.addString(input.getExecPathString());
linkstampsSize++;
}
// TODO(b/120206809): remove debugging info here (and in this whole filename construction).
String linkstampsString = Integer.toString(linkstampsSize);
if (linkstampsSize > 1) {
Set<Artifact> identitySet = Sets.newIdentityHashSet();
Iterables.addAll(identitySet, linkstamps);
if (identitySet.size() < linkstampsSize) {
linkstampsString += "_" + identitySet.size();
}
ImmutableSet<Artifact> uniqueLinkStamps = ImmutableSet.copyOf(linkstamps);
if (uniqueLinkStamps.size() < linkstampsSize) {
linkstampsString += "__" + uniqueLinkStamps.size();
}
}
int buildInfoSize = 0;
for (Artifact input : buildInfoArtifacts) {
fp.addString(input.getExecPathString());
Expand All @@ -381,7 +397,7 @@ private static PathFragment getSharedNativeDepsPath(Iterable<Artifact> linkerInp
+ "_"
+ linkopts.size()
+ "_"
+ linkstampsSize
+ linkstampsString
+ "_"
+ buildInfoSize
+ "_"
Expand Down

0 comments on commit 4026334

Please sign in to comment.