C++: Fix compile API to create at least one action
As an internal optimization we do not create nopic compile actions if we are
not in `-c opt` mode and PIC is supported. When passing disallowPicOutputs to
the API, we need to ensure that nopic actions are created.
RELNOTES:none
@@ -1559,6 +1559,10 @@ public abstract class CcModule
FileTypeSet.of(CppFileTypes.CPP_HEADER),
FileTypeSet.of(CppFileTypes.CPP_HEADER));
+ if (disallowNopicOutputs && disallowPicOutputs) {
+ throw new EvalException(location, "Either PIC or no PIC actions have to be created.");
+ }
+
CcCompilationHelper helper =
new CcCompilationHelper(
actions.asActionRegistry(location, actions),
@@ -1599,6 +1603,7 @@ public abstract class CcModule
}
if (disallowPicOutputs) {
helper.setGeneratePicAction(false);
+ helper.setGenerateNoPicAction(true);
}
try {
CompilationInfo compilationInfo = helper.compile();
