Skip to content

Commit cdcdcff

Browse files
yonghong-songdkruces
authored andcommitted
Fix LLVM-20 compilation failure (iovisor#5155)
Upstream llvm patch llvm/llvm-project#115852 changed signature for function createDiagnostics(). This patch fixed the issue. Signed-off-by: Yonghong Song <[email protected]>
1 parent 00b341f commit cdcdcff

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

src/cc/frontends/clang/loader.cc

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -467,7 +467,11 @@ int ClangLoader::do_compile(
467467
}
468468
invocation0.getFrontendOpts().DisableFree = false;
469469

470+
#if LLVM_VERSION_MAJOR >= 20
471+
compiler0.createDiagnostics(*llvm::vfs::getRealFileSystem(), new IgnoringDiagConsumer());
472+
#else
470473
compiler0.createDiagnostics(new IgnoringDiagConsumer());
474+
#endif
471475

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

493+
#if LLVM_VERSION_MAJOR >= 20
494+
compiler1.createDiagnostics(*llvm::vfs::getRealFileSystem());
495+
#else
489496
compiler1.createDiagnostics();
497+
#endif
490498

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

517529
EmitLLVMOnlyAction ir_act(&*ctx_);
518530
if (!compiler2.ExecuteAction(ir_act))

0 commit comments

Comments
 (0)