clamav-bytecode-compiler icon indicating copy to clipboard operation
clamav-bytecode-compiler copied to clipboard

Clang 16 upgrade

Open ragusaa opened this issue 1 year ago • 10 comments

ragusaa avatar Dec 08 '23 19:12 ragusaa

It would be good to update the example pass code to use the new style, as well. In https://github.com/Cisco-Talos/clamav-bytecode-compiler/tree/main/example

We should update the CMakeLists.txt / add the new CMakeLists.txt for the object library and shared library. And change all the #include " to #include <. Etc.

val-ms avatar Jan 04 '24 22:01 val-ms

There are still a handful of places where I see #include "llvm instead of #include <llvm:

  • ifacegen.cpp (broken module, due for overhaul and migration to clamav repo. But it couldn't hurt to switch to the other #include style.)
  • HelloWorld.cpp (dated, need to update example)
  • ClamBCPreserveABIs.cpp (some commented out, some not. Can we deleted the commented ones?)
  • ClamBCRegAlloc.cpp (commented out headers. Perhaps delete)
  • libclambcc/Common/ClamBCModule.h (delete file?)
  • libclambcc/Common/ClamBCRegAlloc.cpp (delete file?)

val-ms avatar Jan 04 '24 22:01 val-ms

There are a bunch of #if 0-blocks and it may be time to remove them.

val-ms avatar Jan 04 '24 23:01 val-ms

Looks like the github workflow also needs to be updated to use clang-16 from clang-8: https://github.com/Cisco-Talos/clamav-bytecode-compiler/actions/runs/7480532064/job/20360149066 https://github.com/Cisco-Talos/clamav-bytecode-compiler/blob/Clang-16-Upgrade/.github/workflows/cmake.yml#L143

val-ms avatar Jan 12 '24 21:01 val-ms

To get the clang-format test to pass, we should also upgrade this to use clang-format-16 with the latest version of the github actions plugin, which will be v4.11.0: https://github.com/Cisco-Talos/clamav-bytecode-compiler/blob/Clang-16-Upgrade/.github/workflows/clang-format.yml#L29-L31

val-ms avatar Jan 12 '24 21:01 val-ms

All of the CI tests are failing:

  • cmake build is failing because the selected OS doesn't have clang-16. We could install from https://apt.llvm.org/ to ensure it is available.
  • clang-format-16 is failing, because it expects a space between // or /* and comment bodies.
  • jenkins is failing with some network error in the freebsd 12.1 jail. Possibly because jails/iocage is janky. If Judge is indeed moving us to use Docker for sigmanager, perhaps we can abandon freebsd in the test-bcc pipeline and test our Docker image instead.

val-ms avatar Feb 09 '24 17:02 val-ms

All of the CI tests are failing:

  • cmake build is failing because the selected OS doesn't have clang-16. We could install from https://apt.llvm.org/ to ensure it is available.
  • clang-format-16 is failing, because it expects a space between // or /* and comment bodies.
  • jenkins is failing with some network error in the freebsd 12.1 jail. Possibly because jails/iocage is janky. If Judge is indeed moving us to use Docker for sigmanager, perhaps we can abandon freebsd in the test-bcc pipeline and test our Docker image instead.

clam-format was using clang-format-12. I fixed it and re-formatted, so the formatting errors should go away.

ragusaa avatar Feb 09 '24 17:02 ragusaa

I just added a commit that restructures the libclambcc directory and CMakeLists.txt to have all opt-passes' source code (and thus build objects) located in the same directory instead of subdirectories.

This fixes the unit tests, because they rely on LD_LIBRARY_PATH to specify a directory where the opt-pass libs are located.

I think you should also delete the Dockerfile. We now maintain that in the clamav-docker repo, and having one here confuses things.

Since I made a commit to fix the unit tests, I snuck in this change as well, deleting the Dockerfile.

To test the docker build, will need to grab the Dockerfile from the clamav-docker repo. I'll put in a PR for that in a moment. I have that working as well.

val-ms avatar Feb 13 '24 18:02 val-ms

Here's the clamav-docker PR: https://github.com/Cisco-Talos/clamav-docker/pull/42

val-ms avatar Feb 13 '24 18:02 val-ms

The clang-format-16 check failed

val-ms avatar Apr 22 '24 21:04 val-ms