Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clang 16 upgrade #48

Merged
merged 18 commits into from
May 9, 2024
Merged

Conversation

ragusaa
Copy link
Contributor

@ragusaa ragusaa commented Dec 8, 2023

No description provided.

@ragusaa ragusaa force-pushed the Clang-16-Upgrade_2 branch 2 times, most recently from afac373 to 18efdb4 Compare December 19, 2023 18:09
Copy link
Contributor

@micahsnyder micahsnyder left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Initial review just going through cmakelists.txt and clambc-compiler.py. Lotta dead code to clean up, and some stuff that was disabled/deleted for testing that should be restored (namely the 4 cmake files).

I'll look at the optpass code changes after the break, which I suspect is what you actually wanted me to look at (and not this 😅).

CMakeLists.txt Show resolved Hide resolved
clambcc/clambc-compiler.py Show resolved Hide resolved
clambcc/clambc-compiler.py Show resolved Hide resolved
clambcc/clambc-compiler.py Outdated Show resolved Hide resolved
clambcc/clambc-compiler.py Outdated Show resolved Hide resolved
clambcc/clambc-compiler.py Outdated Show resolved Hide resolved
clambcc/clambc-compiler.py Outdated Show resolved Hide resolved
clambcc/clambc-compiler.py Outdated Show resolved Hide resolved
clambcc/clambc-compiler.py Outdated Show resolved Hide resolved
clambcc/clambc-compiler.py Outdated Show resolved Hide resolved
@micahsnyder
Copy link
Contributor

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.

@micahsnyder
Copy link
Contributor

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?)

@micahsnyder
Copy link
Contributor

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

@micahsnyder
Copy link
Contributor

micahsnyder commented Jan 12, 2024

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

@micahsnyder
Copy link
Contributor

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

@ragusaa ragusaa force-pushed the Clang-16-Upgrade_2 branch 2 times, most recently from dd0a8e3 to c682c3c Compare January 19, 2024 19:29
libclambcc/ClamBCAnalyzer/ClamBCAnalyzer.cpp Show resolved Hide resolved
libclambcc/ClamBCAnalyzer/ClamBCAnalyzer.cpp Show resolved Hide resolved
libclambcc/ClamBCAnalyzer/ClamBCAnalyzer.h Outdated Show resolved Hide resolved
libclambcc/ClamBCAnalyzer/ClamBCAnalyzer.h Outdated Show resolved Hide resolved
libclambcc/ClamBCAnalyzer/ClamBCAnalyzer.h Outdated Show resolved Hide resolved
clambcc/clambc-compiler.py Outdated Show resolved Hide resolved
clambcc/clambc-compiler.py Outdated Show resolved Hide resolved
clambcc/clambc-compiler.py Outdated Show resolved Hide resolved
clambcc/clambc-compiler.py Outdated Show resolved Hide resolved
clambcc/clambc-compiler.py Outdated Show resolved Hide resolved
examples/PassManager/AnalysisPlugin/CMakeLists.txt Outdated Show resolved Hide resolved
examples/LegacyPassManager/CMakeLists.txt Outdated Show resolved Hide resolved
examples/LegacyPassManager/HelloWorld/HelloWorld.cpp Outdated Show resolved Hide resolved
examples/PassManager/AnalysisPlugin/AnalysisPlugin.cpp Outdated Show resolved Hide resolved
examples/PassManager/AnalysisPlugin/AnalysisPlugin.cpp Outdated Show resolved Hide resolved
libclambcc/ClamBCRemoveUSUB/ClamBCRemoveUSUB.cpp Outdated Show resolved Hide resolved
libclambcc/ClamBCWriter/ClamBCWriter.cpp Outdated Show resolved Hide resolved
libclambcc/Common/ClamBCUtilities.h Outdated Show resolved Hide resolved
@micahsnyder
Copy link
Contributor

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.

examples/PassManager/CMakeLists.txt Outdated Show resolved Hide resolved
@ragusaa
Copy link
Contributor Author

ragusaa commented Feb 9, 2024

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.

Copy link
Contributor

@micahsnyder micahsnyder left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

@micahsnyder
Copy link
Contributor

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.

@micahsnyder
Copy link
Contributor

Here's the clamav-docker PR: Cisco-Talos/clamav-docker#42

The unit tests rely on all of the opt pass libraries being located in
the same directory as libclambccommon.so, as specified using
LD_LIBRARY_PATH.

One solution would have been to specify a path for each opt pass library
in LD_LIBRARY_PATH and then search for each library in each of those
LD_LIBRARY_PATH paths. However this felt very clunky.

Instead, this commit solves the problem by placing the source for all
opt passes in the same directory, which will mean that the .so's created
in the build directory will also be co-located and thus using a single
path for LD_LIBRARY_PATH will suffice.

To make present and future copy-pasting easy, I also renamed the
libraries to be camel-case.
@micahsnyder micahsnyder changed the title Clang 16 upgrade 2 (not ready to merge, only for testing) Clang 16 upgrade Feb 15, 2024
NEWS.md Outdated Show resolved Hide resolved
@micahsnyder
Copy link
Contributor

The clang-format-16 check failed

Copy link
Contributor

@micahsnyder micahsnyder left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm good with this. BCC test pipeline results seemed good, though we did find some improvements needed to the test pipeline itself.

@micahsnyder micahsnyder merged commit 2beadb7 into Cisco-Talos:main May 9, 2024
2 of 3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants