GaloisInc / cclyzerpp

cclyzer++ is a precise and scalable pointer analysis for LLVM code.
https://galoisinc.github.io/cclyzerpp/
BSD 3-Clause "New" or "Revised" License
134 stars 15 forks source link

Unable to link with `PointerAnalysis` pass #155

Closed adrianherrera closed 1 year ago

adrianherrera commented 1 year ago

Hi folks,

I'm trying to write my own program that uses the PointerAnalysis pass. However, it currently fails when I try to use the new pass manager (as opposed to the legacy pass manager) because there is an undefined reference to 'cclyzer::PointerAnalysis::Key'. The problem is that the PAPassInterface library does not compile any sources (per here) and cclyzer::PointerAnalysis::Key is in a source file. Separately, I cannot specify PAPass in my CMake file's target_link_libraries because it is a MODULE and thus cannot be linked against (CMake produces the error:

  Target "PAPass" of type MODULE_LIBRARY may not be linked into another
  target.  One may link only to INTERFACE, OBJECT, STATIC or SHARED
  libraries, or to executables with the ENABLE_EXPORTS property set.

What is the preferred solution to this? My preferred solution is to change PAPass from a MODULE library to a SHARED library. This way it can be used with both opt and linked with other programs.

BTW, this doesn't appear to affect the legacy pass manager (I looked here to see how it was done in MATE).

langston-barrett commented 1 year ago

What is the preferred solution to this? My preferred solution is to change PAPass from a MODULE library to a SHARED library. This way it can be used with both opt and linked with other programs.

I'm a complete CMake novice, all of this was hacked together to work enough for MATE :see_no_evil: I'd trust your judgment, please feel free to open a PR if there's a better way of doing things that would still work for MATE!

adrianherrera commented 1 year ago

Sweeet, done!