Cisco-Talos / clamav-bytecode-compiler

ClamAV Bytecode Compiler
GNU General Public License v2.0
74 stars 27 forks source link

Compatible issue with clang9 #4

Closed dmknght closed 1 month ago

dmknght commented 3 years ago

clamav-bytecode-compiler version: clambc-0.102.0-2 OS: Parrot 4.11.2, Debian testing based. Available Clang: 9.0.1, 10.0.1, 11.0.1 As the doc mentioned, supported Clang version is only 8. But on Debian testing repo, Clang 8 is not available. So it is great to support Clang 9, clang 11 IMO. Error log when i compiled with Clang 9

[  3%] Building CXX object libclambcc/CMakeFiles/clambcc_obj.dir/ClamBCRTChecks/ClamBCRTChecks.cpp.o
/tmp/clamav-bytecode-compiler/libclambcc/ClamBCRTChecks/ClamBCRTChecks.cpp: In member function ‘llvm::BasicBlock* {anonymous}::PtrVerifier::getAbortBB(unsigned int, llvm::BasicBlock*)’:
/tmp/clamav-bytecode-compiler/libclambcc/ClamBCRTChecks/ClamBCRTChecks.cpp:192:66: error: cannot convert ‘llvm::FunctionCallee’ to ‘llvm::Constant*’ in initialization
  192 |                 BB->getParent()->getParent()->getOrInsertFunction("abort", abrtTy);
      |                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~
      |                                                                  |
      |                                                                  llvm::FunctionCallee
/tmp/clamav-bytecode-compiler/libclambcc/ClamBCRTChecks/ClamBCRTChecks.cpp:194:66: error: cannot convert ‘llvm::FunctionCallee’ to ‘llvm::Constant*’ in initialization
  194 |                 BB->getParent()->getParent()->getOrInsertFunction("bytecode_rt_error", rterrTy);
      |                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      |                                                                  |
      |                                                                  llvm::FunctionCallee
/tmp/clamav-bytecode-compiler/libclambcc/ClamBCRTChecks/ClamBCRTChecks.cpp: In member function ‘virtual bool {anonymous}::PtrVerifier::runOnFunction(llvm::Function&)’:
/tmp/clamav-bytecode-compiler/libclambcc/ClamBCRTChecks/ClamBCRTChecks.cpp:1033:51: error: cannot convert ‘llvm::FunctionCallee’ to ‘llvm::Constant*’ in initialization
 1033 |                 F.getParent()->getOrInsertFunction("abort", abrtTy);
      |                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~
      |                                                   |
      |                                                   llvm::FunctionCallee
/tmp/clamav-bytecode-compiler/libclambcc/ClamBCRTChecks/ClamBCRTChecks.cpp: In member function ‘bool {anonymous}::PtrVerifier::insertCheck(const llvm::SCEV*, const llvm::SCEV*, llvm::Instruction*, bool)’:
/tmp/clamav-bytecode-compiler/libclambcc/ClamBCRTChecks/ClamBCRTChecks.cpp:1631:62: error: cannot convert ‘llvm::FunctionCallee’ to ‘llvm::Constant*’ in initialization
 1631 |             BB->getParent()->getParent()->getOrInsertFunction("abort", abrtTy);
      |             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~
      |                                                              |
      |                                                              llvm::FunctionCallee
/tmp/clamav-bytecode-compiler/libclambcc/ClamBCRTChecks/ClamBCRTChecks.cpp:1633:62: error: cannot convert ‘llvm::FunctionCallee’ to ‘llvm::Constant*’ in initialization
 1633 |             BB->getParent()->getParent()->getOrInsertFunction("bytecode_rt_error", rterrTy);
      |             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      |                                                              |
      |                                                              llvm::FunctionCallee
In file included from /usr/lib/llvm-9/include/llvm/ADT/DenseMapInfo.h:16,
                 from /usr/lib/llvm-9/include/llvm/ADT/DenseMap.h:16,
                 from /usr/lib/llvm-9/include/llvm/ADT/DenseSet.h:16,
                 from /tmp/clamav-bytecode-compiler/libclambcc/ClamBCRTChecks/ClamBCRTChecks.cpp:23:
ragusaa commented 3 years ago

These errors are due to building the compiler itself with llvm-9 and newer libraries (the api changed). The clamav team will investigate supporting both in the future. In the meantime, you can use our docker image.

We currently have a merge request in to support running with newer versions. I'll update this when it's merged.

micahsnyder commented 1 month ago

We've upgraded to support clang-16 now (and only clang-16, not 15 or 17).

Compatibility for the compiler is always going to be very limited. On the plus side, we can get specific LLVM/Clang versions through their package repos or by selecting very specific docker images.