Skip to content

Commit

Permalink
C++: Fix compile API to create at least one action
Browse files Browse the repository at this point in the history
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
PiperOrigin-RevId: 263318198
  • Loading branch information
oquenchil authored and copybara-github committed Aug 14, 2019
1 parent c0240e8 commit 2f42d17
Showing 1 changed file with 5 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1559,6 +1559,10 @@ protected Tuple<Object> compile(
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),
Expand Down Expand Up @@ -1599,6 +1603,7 @@ protected Tuple<Object> compile(
}
if (disallowPicOutputs) {
helper.setGeneratePicAction(false);
helper.setGenerateNoPicAction(true);
}
try {
CompilationInfo compilationInfo = helper.compile();
Expand Down

0 comments on commit 2f42d17

Please sign in to comment.