I’m trying to implement a custom target for LLVM (version 6.0.1) based on the X86 target as a loadable module to use it with llc’s -load option. I have defined the module in the CMakeLists.txt file in the target folder as:
I also defined new versions of the LLVMInitializeMyTarget(AsmPrinter|Target|AsmParser|Disassembler|TargetMC|TargetInfo) functions. The shared module gets created, but when I load it into llc the target is not present in the list of loaded targets (from llc -version) and I cannot use it with -march=mytarget. However, when I use the llc binary that was compiled with my custom target, and load the module with it, I get errors because of duplicated options, meaning that the custom target is, in fact, loaded from the module in this case.
What am I missing here? The documentation I’ve been able to find on loadable modules seems to be targeted at previous versions of LLVM which use the LOADABLE_MODULE makefile value instead of the current cmake compilation pipeline.