Put the dtor of mca::CustomBehaviour into the cpp file to avoid undefined vtable when linking libLLVMMCACustomBehaviourAMDGPU as shared library.
Here is the original error message:
FAILED: lib/libLLVMMCACustomBehaviourAMDGPU.so.13git ... ld.lld: error: undefined symbol: vtable for llvm::mca::CustomBehaviour >>> referenced by CustomBehaviour.h:64 (llvm-project/llvm/include/llvm/MCA/CustomBehaviour.h:64) >>> tools/llvm-mca/lib/AMDGPU/CMakeFiles/LLVMMCACustomBehaviourAMDGPU.dir/AMDGPUCustomBehaviour.cpp.o:(llvm::mca::CustomBehaviour::CustomBehaviour(llvm::MCSubtargetInfo const&, llvm::mca::CircularSourceMgr const&, llvm::MCInstrInfo const&)) >>> referenced by CustomBehaviour.h:66 (llvm-project/llvm/include/llvm/MCA/CustomBehaviour.h:66) >>> tools/llvm-mca/lib/AMDGPU/CMakeFiles/LLVMMCACustomBehaviourAMDGPU.dir/AMDGPUCustomBehaviour.cpp.o:(llvm::mca::CustomBehaviour::~CustomBehaviour()) the vtable symbol may be undefined because the class is missing its key function (see https://lld.llvm.org/missingkeyfunction)