[llvm-dev] No Targets in TargetRegistry
Alexander Benikowski via llvm-dev
llvm-dev at lists.llvm.org
Tue Jan 23 03:52:23 PST 2018
Not sure. But when doing this in the C-Api, you've to initialize/add the
Targets first. It'll not run with all buildin-targets by default.
As an example: LLVMInitializeX86Target
<http://llvm.org/doxygen/X86TargetMachine_8cpp_source.html#l00068>
This is for the C-API, so i think similar things apply to the C++ API the
C-API is based on.
2018-01-20 22:32 GMT+01:00 Brent Lewis via llvm-dev <llvm-dev at lists.llvm.org
>:
> 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?
>
>
> <https://www.avast.com/sig-email?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail&utm_term=icon> Virus-free.
> www.avast.com
> <https://www.avast.com/sig-email?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail&utm_term=link>
> <#m_6598553150662470869_DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2>
>
> _______________________________________________
> LLVM Developers mailing list
> llvm-dev at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20180123/c9163528/attachment.html>
More information about the llvm-dev
mailing list