Skip to content

Commit

Permalink
Add ResetAllOptionOccurrences before creating CompilerInvocation
Browse files Browse the repository at this point in the history
After this change:
llvm/llvm-project@7bdad08
To be more precise, in this line:
https://github.com/llvm/llvm-project/blob/d2a710ea784eea43c63e3831224de6355f1e4a6f/clang/lib/Frontend/CompilerInvocation.cpp#L3587

We have a problem during second compilation of user kernel via opencl-clang in the same process. When we hit this place two times - it will abort the compilation, because we are trying to assign the same flag twice which is wrong.

message error:
clang (LLVM option parsing): for the --pgo-warn-misexpect option: may only occur zero or one times!
  • Loading branch information
lwesiers authored and AlexeySachkov committed Feb 11, 2020
1 parent 1f73e0b commit 0a5a9f6
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions common_clang.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,9 @@ Compile(const char *pszProgramSource, const char **pInputHeaders,
compiler->createFileManager(OverlayFS);
compiler->createSourceManager(compiler->getFileManager());

// Calling ResetAllOptionOccurrences as WA for issue from here:
// https://reviews.llvm.org/D66324?id=219733#1680231
llvm::cl::ResetAllOptionOccurrences();
// Create compiler invocation from user args before trickering with it
clang::CompilerInvocation::CreateFromArgs(compiler->getInvocation(),
optionsParser.args(), *Diags);
Expand Down

0 comments on commit 0a5a9f6

Please sign in to comment.