diff --git a/src/main/java/com/google/devtools/build/lib/analysis/BUILD b/src/main/java/com/google/devtools/build/lib/analysis/BUILD index 4feb336d92689b..1bf62ab6bf67f7 100644 --- a/src/main/java/com/google/devtools/build/lib/analysis/BUILD +++ b/src/main/java/com/google/devtools/build/lib/analysis/BUILD @@ -1678,6 +1678,7 @@ java_library( deps = [ ":config/fragment_options", "//src/main/java/com/google/devtools/build/lib/cmdline", + "//src/main/java/com/google/devtools/build/lib/skyframe/serialization:visible-for-serialization", "//src/main/java/com/google/devtools/build/lib/skyframe/serialization/autocodec", "//src/main/java/com/google/devtools/build/lib/skyframe/serialization/autocodec:serialization-constant", "//src/main/java/com/google/devtools/build/lib/util", diff --git a/src/main/java/com/google/devtools/build/lib/analysis/config/BuildOptions.java b/src/main/java/com/google/devtools/build/lib/analysis/config/BuildOptions.java index c616868d8f8ffc..ea8eb19d28087a 100644 --- a/src/main/java/com/google/devtools/build/lib/analysis/config/BuildOptions.java +++ b/src/main/java/com/google/devtools/build/lib/analysis/config/BuildOptions.java @@ -31,6 +31,7 @@ import com.google.devtools.build.lib.skyframe.serialization.LeafObjectCodec; import com.google.devtools.build.lib.skyframe.serialization.SerializationDependencyProvider; import com.google.devtools.build.lib.skyframe.serialization.SerializationException; +import com.google.devtools.build.lib.skyframe.serialization.VisibleForSerialization; import com.google.devtools.build.lib.skyframe.serialization.autocodec.SerializationConstant; import com.google.devtools.build.lib.util.Fingerprint; import com.google.devtools.common.options.OptionDefinition; @@ -464,8 +465,20 @@ public BuildOptions build() { private Builder() {} } - @SuppressWarnings("unused") // Used reflectively. - private static final class Codec extends LeafObjectCodec { + /** + * Codec for {@link BuildOptions}. + * + *

This codec works by serializing the {@link BuildOptions#checksum} only. This works due to + * the assumption that anytime a value containing a particular configuration is deserialized, it + * was previously requested using the same configuration key, thus priming the cache. + */ + @VisibleForSerialization + public static final class Codec extends LeafObjectCodec { + private static final Codec INSTANCE = new Codec(); + + public static Codec buildOptionsCodec() { + return INSTANCE; + } @Override public Class getEncodedClass() {