This is from https://stackoverflow.com/questions/48360685/no-targets-in-targetregistry
I have the following code, which should get the default llvm::Target.
auto const targetTriple = llvm::sys::getDefaultTargetTriple();
llvm_module.setTargetTriple(targetTriple);
std::string error;
auto const * target = llvm::TargetRegistry::lookupTarget(targetTriple, error);
if (target == nullptr) {
auto targets = llvm::TargetRegistry::targets();
size_t targetCount = 0;
for (auto const & _ : targets) {
++targetCount;
}
ERROR(Unknown, "llvm::TargetRegistry::lookupTarget failed for " + targetTriple + “. llvm::TargetRegistry::targets() contains " + std::to_string(targetCount) + " elements.”);
}
This code produces this error message:
…
llvm::TargetRegistry::lookupTarget failed for i686-pc-windows-msvc.
llvm::TargetRegistry::targets() contains 0 elements
…
Am I missing a step?