I am trying to make my pass compiling inside the LLVM tree or outside.
It works when I include my pass inside the tools folder, however when I try to compile it outside the LLVM tree I get the following error:
"add_library cannot create target "LLVMTarget" because an imported target with the same name already exists.”
It happens when I’ve already compiled and installed my target from within LLVM.
I was wondering if there is a way to ignore that and just overwrite the target.
Sorry for the delayed response.
LLVMTarget is a library provided by LLVM, you shouldn't be naming your own targets to conflict with the names already in LLVM. CMake does not allow multiple targets to have the same name because it causes ambiguities in the build system.
sorry I was just using a dummy name for the library but that wasn’t the name that was giving me the error.
However, what I am experiencing is that if I build and install my pass within the LLVM source I cannot install my library if I build it out-of-tree as a standalone library.
The OpenMP runtime allows that though, any solution?
Passes are not treated the same in the build system as how we treat runtime libraries. A pass can either be in-tree, or out-of-tree, but not both.
If the pass is a loadable module you might be able to hack around that by naming the library that contains the pass differently for in-tree and out-of-tree builds.
One thing to keep in mind about how CMake works is that it creates dummy targets for all the LLVM build targets when you import the LLVM package. That means if you built your pass in the LLVM tree, its target will be exported in the CMake, so you can't create the same target in a separate CMake file.