Running custom pass as non loadable module

Is there a way other than writing llvm pass as out of tree to run custom pass as non loadable module?

I am trying to run Hello pass present at llvm/lib/Transforms/Hello

but I am getting a warning - “LLVMHello ignored – Loadable modules not supported on this platform.” What should one do if there is no loadable modules support?

Hi @shubhamnarlawar :wave:

Sounds like you are trying to load your plugin dynamically (i.e. at run-time). LLVM also supports loading such plugins statically (i.e. at build-time, “loading” in this context can be a bit misleading): Writing an LLVM Pass — LLVM 15.0.0git documentation.

I also documented this in llvm-tutor: GitHub - banach-space/llvm-tutor: A collection of out-of-tree LLVM passes for teaching and learning (there’s an example that you can experiment with as well).

Btw, what’s your platform? Is it Windows? Might be worth trying to understand the reason behind that “Loadable modules not supported on this platform”.


Hello @banach-space

Yes. I was trying to load plugin dynamically.

Thanks for sharing!

The platform which I am working is Ubuntu -

Distributor ID: Ubuntu
Description: Ubuntu 20.04.3 LT
x86_64 GNU/Linux

Actually, I was trying to build cross compiler targeting AArch64 on above machine as follows -

[1] I have build a native compiler using -

cmake -G "Unix Makefiles" -DCMAKE_BUILD_TYPE="Debug" -DCMAKE_INSTALL_PREFIX=../debug-install \
  -DLLVM_ENABLE_PROJECTS="clang" ../llvm

[2] Then I build cross compiler using [1] but I get above error as - “LLVMHello7 ignored – Loadable modules not supported on this platform."

cmake ../llvm -DCMAKE_CROSSCOMPILING=True -DCMAKE_INSTALL_PREFIX=../debug-install-aarch64 -DLLVM_TABLEGEN=$HOME/llvm-project/debug-build/bin/llvm-tblgen -DCLANG_TABLEGEN=$HOME/upstream-llvm/llvm-project/debug-build/bin/clang-tblgen -DLLVM_DEFAULT_TARGET_TRIPLE=aarch64-linux-gnueabihf -DLLVM_TARGET_ARCH=AArch64 -DLLVM_TARGETS_TO_BUILD=AArch64 -DLLVM_ENABLE_PIC=False -DCMAKE_BUILD_TYPE=Debug -DLLVM_ENABLE_PROJECTS="clang" -DLLVM_USE_SPLIT_DWARF=True

Is it expected while building cross compiler?

I was asking about the platform as things are “a bit different” on Windows. Ubuntu should be totally fine.

I’ve not tried cross-compiling myself for ages, and that’s quite an extra complexity in the mix :slight_smile: And I’m not aware of anyone trying to use plugins with a cross-compiler. I could take a look, but would need a full reproducer. Currently there’s no step for building and loading the plugin. Also, how do you make sure that your compiler from [1] is used for [2]?



I use CMAKE_CXX_COMPILER to build [2] by using [1] which is missing in my above options.

Thanks for the reply @banach-space
I will probably try only native build since there is no support for loading plugin dynamically in cross compiler.