5

I am using the LLVM c bindings to write a compiler and when I try to create a target from the default target triple (x86_64-pc-windows-msvc), LLVM says there are no registered targets.

llvm::InitializeNativeTarget();
llvm::InitializeAllTargetInfos();
llvm::InitializeAllTargets();
llvm::InitializeAllTargetMCs();
llvm::InitializeAllAsmParsers();
llvm::InitializeAllAsmPrinters();

auto target_triple = llvm::sys::getDefaultTargetTriple();
std::string err; // unable to find target for this triple (no targets are registered)
auto target = llvm::TargetRegistry::lookupTarget(target_triple, err);

llvm::TargetRegistry::printRegisteredTargetsForVersion(llvm::outs()); // prints (none)

I have build LLVM from source and used the LLVM_TARGETS_TO_BUILD=all flag to enable all targets. When I call llc --help, however, a large list of targets are listed. So why cant the llvm C++ code find the targets?

0 Answers0