Minimal out-of-tree pass

I’m not totally a beginner but posting this in “beginners” anyhow cause it’s a little embarrassing

the other day I wanted to write a little out-of-tree pass and the OOT pass that I wrote a few years ago that I usually use as a template doesn’t work any longer. nor does any of the handful of template OOT passes that I found on github. nor does the documentation work for me – I pieced together the code from these two documents:
https://llvm.org/docs/WritingAnLLVMPass.html
https://llvm.org/docs/CMake.html#developing-llvm-passes-out-of-source

can anyone point me to a minimal OOT pass template? in case it matters I’m working on both an M1 Mac and Linux. I would love for this template to support both the old and new pass managers, but if that’s not available then the new one is preferable. thanks!

You could try Hello-World from llvm-tutor. That’s more or less why it’s there (i.e. to serve as a template).

-Andrzej

1 Like

Thanks! That’s one of the ones I tried, it did not work immediately but I’ll go back and look again.

Ah, ok, it fails to build on my Mac using AppleClang 13.1.6.13160021, but it works if I move the C++ standard from 14 to 17. (I also removed the check for LLVM version == 14.) Thanks again.

1 Like

Should I push a change to the docs adding a link to your repo? Or perhaps we can pin a link here? (Sorry if something like that has already been done, I’m still kind of a bad discourse user.)

1 Like

Also I really like some of the details in this repo such as the comments, and checking for RTTI instead of unconditionally adding the -fno-rtti flag, as we see sometimes.

1 Like

Also I really like some of the details in this repo

Thanks :slight_smile: I really wanted to make it as easy as possible for folks to learn LLVM. These things can be a real blocker for anyone who is new to this.

Should I push a change to the docs adding a link to your repo?

I created it for sharing, so yes please!

Sorry if something like that has already been done

AFAIK it hasn’t :wink: