iovisor / bcc

BCC - Tools for BPF-based Linux IO analysis, networking, monitoring, and more
Apache License 2.0
20.61k stars 3.89k forks source link

bcc build error with LLVM 19 #5125

Open jchecahi opened 4 weeks ago

jchecahi commented 4 weeks ago

Trying to build bcc with LLVM 19 fails with the following error:

/root/rpmbuild/BUILD/bcc-0.30.0-build/bcc-0.30.0/src/cc/frontends/clang/b_frontend_action.cc: In member function ‘bool ebpf::MapVisitor::VisitCallExpr(clang::CallExpr*)’:
/root/rpmbuild/BUILD/bcc-0.30.0-build/bcc-0.30.0/src/cc/frontends/clang/b_frontend_action.cc:341:27: error: ‘class llvm::StringRef’ has no member named ‘startswith’; did you mean ‘starts_with’?
  341 |         if (!A->getName().startswith("maps"))
      |                           ^~~~~~~~~~
      |                           starts_with
/root/rpmbuild/BUILD/bcc-0.30.0-build/bcc-0.30.0/src/cc/frontends/clang/b_frontend_action.cc: In member function ‘bool ebpf::ProbeVisitor::assignsExtPtr(clang::Expr*, int*)’:
/root/rpmbuild/BUILD/bcc-0.30.0-build/bcc-0.30.0/src/cc/frontends/clang/b_frontend_action.cc:393:29: error: ‘class llvm::StringRef’ has no member named ‘startswith’; did you mean ‘starts_with’?
  393 |           if (!A->getName().startswith("maps"))
      |                             ^~~~~~~~~~
      |                             starts_with
/root/rpmbuild/BUILD/bcc-0.30.0-build/bcc-0.30.0/src/cc/frontends/clang/b_frontend_action.cc: In member function ‘bool ebpf::BTypeVisitor::VisitCallExpr(clang::CallExpr*)’:
/root/rpmbuild/BUILD/bcc-0.30.0-build/bcc-0.30.0/src/cc/frontends/clang/b_frontend_action.cc:940:27: error: ‘class llvm::StringRef’ has no member named ‘startswith’; did you mean ‘starts_with’?
  940 |         if (!A->getName().startswith("maps"))
      |                           ^~~~~~~~~~
      |                           starts_with
/root/rpmbuild/BUILD/bcc-0.30.0-build/bcc-0.30.0/src/cc/frontends/clang/b_frontend_action.cc: In member function ‘bool ebpf::BTypeVisitor::VisitVarDecl(clang::VarDecl*)’:
/root/rpmbuild/BUILD/bcc-0.30.0-build/bcc-0.30.0/src/cc/frontends/clang/b_frontend_action.cc:1458:23: error: ‘class llvm::StringRef’ has no member named ‘startswith’; did you mean ‘starts_with’?
 1458 |     if (!A->getName().startswith("maps"))
      |                       ^~~~~~~~~~
      |                       starts_with

StringRef::startswith was marked for deprecation in LLVM 18 and finally removed in LLVM 19 in commit 4ec9a662. Replacing the ocurrences of startswith with starts_with fixes the build.

Reproduced in Fedora 41 with bcc-0.30.0

hhoffstaette commented 3 weeks ago

Previously reported in https://github.com/iovisor/bcc/pull/5002 and fixed in https://github.com/iovisor/bcc/commit/8caf04080c9211c47567a144c688d08b762a89b4 :)