eunomia-bpf / bpftime

Userspace eBPF runtime for fast Uprobe & Syscall hook & Extensions with LLVM JIT
https://eunomia.dev/bpftime/
MIT License
699 stars 70 forks source link

[BUG] LLVM JIT fails to compile with LLVM 14.0 #188

Closed agentzh closed 5 months ago

agentzh commented 6 months ago

I'm getting the following compilation errors when building LLVM JIT with LLVM 14.0:

/home/agentzh/bpftime/vm/llvm-jit/src/llvm/compiler_utils.cpp: In function ‘void bpftime::emitStoreWritingResult(const ebpf_inst&, llvm::IRBuilder<>&, llvm::Value**, llvm::Value*)’:
/home/agentzh/bpftime/vm/llvm-jit/src/llvm/compiler_utils.cpp:136:34: error: ‘class llvm::IRBuilder<>’ has no member named ‘getPtrTy’; did you mean ‘getInt1Ty’?
  136 |       builder.CreateLoad(builder.getPtrTy(),
      |                                  ^~~~~~~~
      |                                  getInt1Ty
/home/agentzh/bpftime/vm/llvm-jit/src/llvm/compiler_utils.cpp: In function ‘llvm::Value* bpftime::emitLDXLoadingAddr(llvm::IRBuilder<>&, llvm::Value**, const ebpf_inst&)’:
/home/agentzh/bpftime/vm/llvm-jit/src/llvm/compiler_utils.cpp:253:33: error: ‘class llvm::IRBuilder<>’ has no member named ‘getPtrTy’; did you mean ‘getInt1Ty’?
  253 |      builder.CreateLoad(builder.getPtrTy(),
      |                                 ^~~~~~~~
      |                                 getInt1Ty
/home/agentzh/bpftime/vm/llvm-jit/src/llvm/compiler_utils.cpp: In function ‘void bpftime::emitAtomicBinOp(llvm::IRBuilder<>&, llvm::Value**, llvm::AtomicRMWInst::BinOp, const ebpf_inst&, bool, bool)’:
/home/agentzh/bpftime/vm/llvm-jit/src/llvm/compiler_utils.cpp:338:34: error: ‘class llvm::IRBuilder<>’ has no member named ‘getPtrTy’; did you mean ‘getInt1Ty’?
  338 |       builder.CreateLoad(builder.getPtrTy(),
      |                                  ^~~~~~~~
      |                                  getInt1Ty
gmake[3]: *** [vm/llvm-jit/CMakeFiles/vm-bpf.dir/build.make:118: vm/llvm-jit/CMakeFiles/vm-bpf.dir/src/llvm/compiler_utils.cpp.o] Error 1
gmake[3]: *** Waiting for unfinished jobs....

But I saw in the cmake files, it indeed tries to look for LLVM 15, 14, and 13. Is it a known issue?

agentzh commented 6 months ago

The raw compilation command is like this:

cd /home/agentzh/bpftime/build/vm/llvm-jit && ccache /usr/lib64/ccache/c++ -DSPDLOG_ACTIVE_LEVEL=SPDLOG_LEVEL_DEBUG -DSPDLOG_COMPILED_LIB -I/home/agentzh/bpftime/vm/llvm-jit/src -I/home/agentzh/bpftime/vm/llvm-jit/include -I/opt/llvm/include -I/home/agentzh/bpftime/third_party/spdlog/include -I/home/agentzh/bpftime/vm/llvm-jit/../include -I/home/agentzh/bpftime/build/_deps/picosha2-src -g -std=gnu++2a -fPIC -D_DEBUG -Wall -Wextra -Wno-shadow -Wcast-align -Wunused -Wnull-dereference -Wdouble-promotion -Wformat=2 -fPIE -fPIC -fno-common -Wno-unused-function -Wno-unused-parameter -Wno-unused-variable -Wno-missing-field-initializers -Wmisleading-indentation -Wduplicated-cond -Wduplicated-branches -Wlogical-op -MD -MT vm/llvm-jit/CMakeFiles/vm-bpf.dir/src/llvm/llvm_jit_context.cpp.o -MF CMakeFiles/vm-bpf.dir/src/llvm/llvm_jit_context.cpp.o.d -o CMakeFiles/vm-bpf.dir/src/llvm/llvm_jit_context.cpp.o -c /home/agentzh/bpftime/vm/llvm-jit/src/llvm/llvm_jit_context.cpp

Seems like it is using the right headers in my /opt/llvm/ installation.

Officeyutong commented 5 months ago

We don't support LLVM 14. At least LLVM 15 is required

Zheaoli commented 5 months ago

This is not a bug, for now we don't support LLVM 14 yet. Plz use 15 or higher