Allow returning None for null maps in LibraryToLink shared_non_lto_backend Starlark methods.
Dict.immutableCopyOf will fail if the input is null. In this case, we
have to return null because there is a distinction between an empty
map and "no map" (at least from the point of view of Go
compilation and linking).
@@ -129,7 +129,8 @@ public abstract class LibraryToLink implements LibraryToLinkApi<Artifact, LtoBac
public final Dict<Artifact, LtoBackendArtifacts> getSharedNonLtoBackendsForStarlark(
StarlarkThread thread) throws EvalException {
CcModule.checkPrivateStarlarkificationAllowlist(thread);
- return Dict.immutableCopyOf(getSharedNonLtoBackends());
+ ImmutableMap<Artifact, LtoBackendArtifacts> backends = getSharedNonLtoBackends();
+ return backends != null ? Dict.immutableCopyOf(backends) : null;
}
@Override
@@ -148,7 +149,8 @@ public abstract class LibraryToLink implements LibraryToLinkApi<Artifact, LtoBac
public final Dict<Artifact, LtoBackendArtifacts> getPicSharedNonLtoBackendsForStarlark(
StarlarkThread thread) throws EvalException {
CcModule.checkPrivateStarlarkificationAllowlist(thread);
- return Dict.immutableCopyOf(getPicSharedNonLtoBackends());
+ ImmutableMap<Artifact, LtoBackendArtifacts> backends = getPicSharedNonLtoBackends();
+ return backends != null ? Dict.immutableCopyOf(backends) : null;
}
LinkerInputs.LibraryToLink getStaticLibraryToLink() {
