<div dir="ltr">Hi Alexei,<div><br></div><div>I haven't tried to run code yet. The clang frontend can generate machine code for bpf but llc does not do the job.</div><div><br></div><div>When i use : <span style="line-height:1.5;font-size:13.1999998092651px">llc -march bpf -filetype=obj arith.bc</span></div>
<div><br></div><div>It has this error message:</div><div>
<p class="p1"><span class="s1">Assertion failed: (isa<X>(Val) && "cast<Ty>() argument of incompatible type!"), function cast, file /Users/xil174/Experiments/vcore_tool/llvm/include/llvm/Support/Casting.h, line 237.</span></p>
<p class="p1"><span class="s1">0 llc 0x00000001052318ce llvm::sys::PrintStackTrace(llvm::raw_ostream&) + 46</span></p>
<p class="p1"><span class="s1">1 llc 0x0000000105233199 PrintStackTraceSignalHandler(void*) + 25</span></p>
<p class="p1"><span class="s1">2 llc 0x000000010522fe89 llvm::sys::RunSignalHandlers() + 425</span></p>
<p class="p1"><span class="s1">3 llc 0x000000010523351e SignalHandler(int) + 366</span></p>
<p class="p1"><span class="s1">4 libsystem_platform.dylib 0x00007fff8f363f1a _sigtramp + 26</span></p>
<p class="p1"><span class="s1">5 llc 0x000000010566fb75 (anonymous namespace)::RewriteSymbols::ID + 40849</span></p>
<p class="p1"><span class="s1">6 llc 0x00000001052331bb raise + 27</span></p>
<p class="p1"><span class="s1">7 llc 0x0000000105233272 abort + 18</span></p>
<p class="p1"><span class="s1">8 llc 0x0000000105233251 __assert_rtn + 129</span></p>
<p class="p1"><span class="s1">9 llc 0x0000000104dd593e llvm::cast_retty<llvm::MCSectionMachO, llvm::MCSection*>::ret_type llvm::cast<llvm::MCSectionMachO, llvm::MCSection>(llvm::MCSection*) + 110</span></p>
<p class="p1"><span class="s1">10 llc 0x0000000104dcecdb (anonymous namespace)::MCMachOStreamer::ChangeSection(llvm::MCSection*, llvm::MCExpr const*) + 75</span></p>
<p class="p1"><span class="s1">11 llc 0x0000000104de9c2d llvm::MCStreamer::SwitchSection(llvm::MCSection*, llvm::MCExpr const*) + 797</span></p>
<p class="p1"><span class="s1">12 llc 0x0000000104de5300 llvm::MCStreamer::InitSections(bool) + 80</span></p>
<p class="p1"><span class="s1">13 llc 0x00000001044f02b6 llvm::AsmPrinter::doInitialization(llvm::Module&) + 182</span></p>
<p class="p1"><span class="s1">14 llc 0x0000000104c5e683 llvm::FPPassManager::doInitialization(llvm::Module&) + 99</span></p>
<p class="p1"><span class="s1">15 llc 0x0000000104c5ee65 (anonymous namespace)::MPPassManager::runOnModule(llvm::Module&) + 997</span></p>
<p class="p1"><span class="s1">16 llc 0x0000000104c5e896 llvm::legacy::PassManagerImpl::run(llvm::Module&) + 310</span></p>
<p class="p1"><span class="s1">17 llc 0x0000000104c5f771 llvm::legacy::PassManager::run(llvm::Module&) + 33</span></p>
<p class="p1"><span class="s1">18 llc 0x0000000104279403 compileModule(char**, llvm::LLVMContext&) + 10755</span></p>
<p class="p1"><span class="s1">19 llc 0x0000000104276996 main + 230</span></p>
<p class="p1"><span class="s1">20 libdyld.dylib 0x00007fff907f25c9 start + 1</span></p>
<p class="p1"><span class="s1">Stack dump:</span></p>
<p class="p1"><span class="s1">0.<span class="Apple-tab-span"> </span>Program arguments: ../build/Debug/bin/llc -march bpf -filetype=obj arith.bc </span></p>
<p class="p1"><span class="s1">Illegal instruction: 4</span></p><p class="p1"><span class="s1"><br></span></p></div><div><br></div></div><br><div class="gmail_quote"><div dir="ltr">On Sun, Aug 2, 2015 at 5:57 PM Alexei Starovoitov <<a href="mailto:alexei.starovoitov@gmail.com">alexei.starovoitov@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">On Sun, Aug 2, 2015 at 12:24 AM, Xiaochu Liu <<a href="mailto:xiaochu1122@gmail.com" target="_blank">xiaochu1122@gmail.com</a>> wrote:<br>
> Dear there,<br>
><br>
> I wasn't able to generate obj file for bpf using llc:<br>
><br>
> llc -march bpf -filetype=obj foo.bc<br>
><br>
> Anyone knows what is the missing part in their backend? I want to make it<br>
> work for my project.<br>
<br>
what do you mean exactly?<br>
Is there some error message or foo.o is rejected by kernel?<br>
</blockquote></div>