Skip to content

Commit

Permalink
Fix LLVM-20 compilation failure (#5155)
Browse files Browse the repository at this point in the history
Upstream llvm patch
  llvm/llvm-project#115852
changed signature for function createDiagnostics().
This patch fixed the issue.

Signed-off-by: Yonghong Song <[email protected]>
  • Loading branch information
yonghong-song authored Nov 23, 2024
1 parent ebcc7a7 commit 9713b91
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/cc/frontends/clang/loader.cc
Original file line number Diff line number Diff line change
Expand Up @@ -467,7 +467,11 @@ int ClangLoader::do_compile(
}
invocation0.getFrontendOpts().DisableFree = false;

#if LLVM_VERSION_MAJOR >= 20
compiler0.createDiagnostics(*llvm::vfs::getRealFileSystem(), new IgnoringDiagConsumer());
#else
compiler0.createDiagnostics(new IgnoringDiagConsumer());
#endif

// capture the rewritten c file
string out_str;
Expand All @@ -486,7 +490,11 @@ int ClangLoader::do_compile(
add_main_input(invocation1, main_path, &*out_buf);
invocation1.getFrontendOpts().DisableFree = false;

#if LLVM_VERSION_MAJOR >= 20
compiler1.createDiagnostics(*llvm::vfs::getRealFileSystem());
#else
compiler1.createDiagnostics();
#endif

// capture the rewritten c file
string out_str1;
Expand All @@ -512,7 +520,11 @@ int ClangLoader::do_compile(
invocation2.getCodeGenOpts().setInlining(CodeGenOptions::NormalInlining);
// suppress warnings in the 2nd pass, but bail out on errors (our fault)
invocation2.getDiagnosticOpts().IgnoreWarnings = true;
#if LLVM_VERSION_MAJOR >= 20
compiler2.createDiagnostics(*llvm::vfs::getRealFileSystem());
#else
compiler2.createDiagnostics();
#endif

EmitLLVMOnlyAction ir_act(&*ctx_);
if (!compiler2.ExecuteAction(ir_act))
Expand Down

0 comments on commit 9713b91

Please sign in to comment.