Skip to content

Prepare CaGe to be extensible via plugins#129

Merged
TimHeldmann merged 6 commits intotudasc:develfrom
TimHeldmann:feat/CagePlugins
Mar 13, 2026
Merged

Prepare CaGe to be extensible via plugins#129
TimHeldmann merged 6 commits intotudasc:develfrom
TimHeldmann:feat/CagePlugins

Conversation

@TimHeldmann
Copy link
Member

@TimHeldmann TimHeldmann commented Mar 11, 2026

Similar to CGC2, we want users to be able to add custom collection and metadata logic to CaGe without modifying CaGe itself.

This PR prepares CaGe to be used with plugins.

It clears up the naming confunsion, by renaming CaGe's main file from Plugin, to CaGe.
This allows the filename Plugin to now refer to CaGe plugins.
We allow to add Plugins via commandline and load them at runtime.
We augment the existing CallGraphConsumer interface to add an option CallGraphAugmentation step.

Copy link
Member

@jplehr jplehr left a comment

Choose a reason for hiding this comment

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

A few comments and please reformat with clang-format.
I don't think this complies with formatting rules.


Plugin* loadPlugin(const std::string& pluginPath) {
metacg::MCGLogger::instance().getConsole()->debug("Loading plugin");
void* handle = dlopen(pluginPath.c_str(), 1);
Copy link
Member

Choose a reason for hiding this comment

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

I believe we rely on LLVM anyway here, right?
Can you double check whether LLVM offers helpers to work with dlfcn? I vaguely recall there to be helper that we use(d) in libomptarget.

Copy link
Member Author

Choose a reason for hiding this comment

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

Didn't know this existed, thank you.
Swapped for LLVM's helper functions.

This seems to work based on preliminary testing, but I am not sure if they have behave identically.
If I understood correctly, one can define a search order for which LLVM's helper function traverse possible candidates for getting symbols from libraries, which I have not yet found for the dlopen/dlsym version.

Copy link
Member

@jplehr jplehr left a comment

Choose a reason for hiding this comment

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

Seems reasonable.
Do we have tests for it?

return nullptr;
}
auto getPlugin = reinterpret_cast<Plugin* (*)()>(sym);
Plugin* loadedPlugin=getPlugin();
Copy link
Member

Choose a reason for hiding this comment

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

I think this is still not correctly formatted.

Copy link
Member Author

Choose a reason for hiding this comment

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

As far as I can tell, it is.
Does it format differently on your machine?

Copy link
Member

Choose a reason for hiding this comment

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

I would expect it to be

Suggested change
Plugin* loadedPlugin=getPlugin();
Plugin* loadedPlugin = getPlugin();

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes you are right, I don't know why I didn't get the formatter to do it for me the first time.
Changed

@TimHeldmann
Copy link
Member Author

@jplehr

Seems reasonable. Do we have tests for it?

We currently do not have tests as part of this Repository, but @ahueck and I have developed a plugin based on this here: https://github.com/TimHeldmann/ACGPlugin/tree/master.

I want to touch up the CGC2 plugin interface and its accompanying test plugin with the learnings gathered from this PR anyway, so I propose I add the example plugin in the second PR?

@jplehr
Copy link
Member

jplehr commented Mar 12, 2026

I want to touch up the CGC2 plugin interface and its accompanying test plugin with the learnings gathered from this PR anyway, so I propose I add the example plugin in the second PR?

WFM

@jplehr jplehr self-requested a review March 12, 2026 15:25
@TimHeldmann TimHeldmann merged commit 953b489 into tudasc:devel Mar 13, 2026
4 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.

2 participants