horseyguy
horseyguy

Reputation: 29915

How to compile BCC on Ubuntu 20.04?

I am trying to compile the BCC BPF framework (https://github.com/iovisor/bcc) on Ubuntu 20.04. I followed all the instructions for 18.04, but of course; they fail.

The issue i have seems to be clang-related though

In file included from /usr/local/include/clang/Frontend/CompilerInstance.h:15,
                 from /home/matt/code/bpf/bcc/src/cc/frontends/clang/loader.cc:43:
/usr/local/include/clang/Frontend/CompilerInvocation.h:157:15: note: candidate: ‘static bool clang::CompilerInvocation::CreateFromArgs(clang::CompilerInvocation&, llvm::ArrayRef<const char*>, clang::DiagnosticsEngine&)’
  157 |   static bool CreateFromArgs(CompilerInvocation &Res,
      |               ^~~~~~~~~~~~~~
/usr/local/include/clang/Frontend/CompilerInvocation.h:157:15: note:   candidate expects 3 arguments, 4 provided
make[2]: *** [src/cc/frontends/clang/CMakeFiles/clang_frontend.dir/build.make:63: src/cc/frontends/clang/CMakeFiles/clang_frontend.dir/loader.cc.o] Error 1
make[1]: *** [CMakeFiles/Makefile2:982: src/cc/frontends/clang/CMakeFiles/clang_frontend.dir/all] Error 2
make: *** [Makefile:141: all] Error 2

How do i get BCC compiling on Ubuntu 20.04 ?

Upvotes: 3

Views: 3594

Answers (2)

FUJI Goro
FUJI Goro

Reputation: 889

As of BCC v0.14.0-a28337a, I have to use llvm-7 instead of the latest LLVM. Also, -DPYTHON_CMD=python3 because Python2 is no longer installed in Ubuntu by default. Other dependencies listed in https://github.com/iovisor/bcc/blob/master/INSTALL.md#ubuntu---source are also required.

I can build it on my Ubuntu 20.04 VM.

cmake -Bbuild -DPYTHON_CMD=python3 -DCMAKE_PREFIX_PATH=/usr/lib/llvm-7
make -Cbuild -j$(nproc)

Upvotes: 3

Alberto Pires
Alberto Pires

Reputation: 319

I had the same problem. What worked for me was use a different branch, actually the latest tag, you can check that at github site for the project: https://github.com/iovisor/bcc.git

One I did a git checkout v0.24.0 # for example it worked.

Hint: Probably the main branch may not be the best choice as it may be broken due to the latest commit, changing for the last stable release has already worked for me on many other different projects.

Upvotes: 1

Related Questions