aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--src/main/java/com/google/devtools/build/lib/rules/cpp/CcBinary.java10
-rw-r--r--src/main/java/com/google/devtools/build/lib/rules/cpp/CcLinkingInfo.java14
2 files changed, 22 insertions, 2 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/rules/cpp/CcBinary.java b/src/main/java/com/google/devtools/build/lib/rules/cpp/CcBinary.java
index 36aca5f7df..871def83e3 100644
--- a/src/main/java/com/google/devtools/build/lib/rules/cpp/CcBinary.java
+++ b/src/main/java/com/google/devtools/build/lib/rules/cpp/CcBinary.java
@@ -886,6 +886,16 @@ public abstract class CcBinary implements RuleConfiguredTargetFactory {
ccCompilationInfoBuilder.setCcCompilationContext(ccCompilationContext);
CcLinkingInfo.Builder ccLinkingInfoBuilder = CcLinkingInfo.Builder.create();
+ // TODO(b/111289526): Remove CcLinkingInfo provider from cc_binary as soon as the flag
+ // --experimental_enable_cc_dynlibs_for_runtime is flipped. An empty CcLinkParamsStore is not
+ // needed, but here we set it to avoid a null pointer exception in places where we're expecting
+ // it. In the future CcLinkParamsStore will be obligatory.
+ ccLinkingInfoBuilder.setCcLinkParamsStore(
+ new CcLinkParamsStore(
+ /* staticModeParamsForDynamicLibrary= */ CcLinkParams.EMPTY,
+ /* staticModeParamsForExecutable= */ CcLinkParams.EMPTY,
+ /* dynamicModeParamsForDynamicLibrary= */ CcLinkParams.EMPTY,
+ /* dynamicModeParamsForExecutable= */ CcLinkParams.EMPTY));
if (cppConfiguration.enableCcDynamicLibrariesForRuntime()) {
ccLinkingInfoBuilder.setCcDynamicLibrariesForRuntime(
new CcDynamicLibrariesForRuntime(
diff --git a/src/main/java/com/google/devtools/build/lib/rules/cpp/CcLinkingInfo.java b/src/main/java/com/google/devtools/build/lib/rules/cpp/CcLinkingInfo.java
index 21494f7765..a8a27515af 100644
--- a/src/main/java/com/google/devtools/build/lib/rules/cpp/CcLinkingInfo.java
+++ b/src/main/java/com/google/devtools/build/lib/rules/cpp/CcLinkingInfo.java
@@ -30,6 +30,7 @@ import com.google.devtools.build.lib.syntax.FunctionSignature;
import com.google.devtools.build.lib.syntax.Runtime;
import com.google.devtools.build.lib.syntax.SkylarkType;
import java.util.Collection;
+import java.util.stream.Stream;
import javax.annotation.Nullable;
/** Wrapper for every C++ linking provider. */
@@ -110,6 +111,16 @@ public final class CcLinkingInfo extends NativeInfo implements CcLinkingInfoApi
}
};
+ public static final CcLinkingInfo EMPTY =
+ CcLinkingInfo.Builder.create()
+ .setCcLinkParamsStore(
+ new CcLinkParamsStore(
+ /* staticModeParamsForDynamicLibrary= */ CcLinkParams.EMPTY,
+ /* staticModeParamsForExecutable= */ CcLinkParams.EMPTY,
+ /* dynamicModeParamsForDynamicLibrary= */ CcLinkParams.EMPTY,
+ /* dynamicModeParamsForExecutable= */ CcLinkParams.EMPTY))
+ .build();
+
private final CcLinkParamsStore ccLinkParamsStore;
// TODO(b/111289526): These providers are not useful. All the information they provide can be
// obtained from CcLinkParams. CcRunfiles is already dead code and can be removed.
@@ -158,8 +169,7 @@ public final class CcLinkingInfo extends NativeInfo implements CcLinkingInfoApi
CcLinkingInfo.Builder builder = new CcLinkingInfo.Builder();
builder.setCcLinkParamsStore(
CcLinkParamsStore.merge(
- ccLinkingInfos
- .stream()
+ Stream.concat(Stream.of(CcLinkingInfo.EMPTY), ccLinkingInfos.stream())
.map(CcLinkingInfo::getCcLinkParamsStore)
.collect(ImmutableList.toImmutableList())));
return builder.build();