From 402633463e0a5f23d256042ee0808ed8e725cec8 Mon Sep 17 00:00:00 2001 From: janakr Date: Fri, 11 Jan 2019 07:58:16 -0800 Subject: [PATCH] Embed the == and .equal number of linkstamp artifacts in the nativedeps 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 --- .../lib/rules/nativedeps/NativeDepsHelper.java | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/google/devtools/build/lib/rules/nativedeps/NativeDepsHelper.java b/src/main/java/com/google/devtools/build/lib/rules/nativedeps/NativeDepsHelper.java index 0f8cacd566cfe1..631abb833f451c 100644 --- a/src/main/java/com/google/devtools/build/lib/rules/nativedeps/NativeDepsHelper.java +++ b/src/main/java/com/google/devtools/build/lib/rules/nativedeps/NativeDepsHelper.java @@ -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; @@ -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. @@ -367,6 +370,19 @@ private static PathFragment getSharedNativeDepsPath(Iterable 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 identitySet = Sets.newIdentityHashSet(); + Iterables.addAll(identitySet, linkstamps); + if (identitySet.size() < linkstampsSize) { + linkstampsString += "_" + identitySet.size(); + } + ImmutableSet uniqueLinkStamps = ImmutableSet.copyOf(linkstamps); + if (uniqueLinkStamps.size() < linkstampsSize) { + linkstampsString += "__" + uniqueLinkStamps.size(); + } + } int buildInfoSize = 0; for (Artifact input : buildInfoArtifacts) { fp.addString(input.getExecPathString()); @@ -381,7 +397,7 @@ private static PathFragment getSharedNativeDepsPath(Iterable linkerInp + "_" + linkopts.size() + "_" - + linkstampsSize + + linkstampsString + "_" + buildInfoSize + "_"