[llvm-dev] Error running clang++ generated bitcode in lli

Lang Hames via llvm-dev llvm-dev at lists.llvm.org
Sun Sep 5 21:31:54 PDT 2021


Hi Leer, David,

Leer -- I would try Dave's suggestion. LLI is still isn't set up to handle
arbitrary C++.

That's likely to change in the near future though: LLI will probably be
upgraded to use the ORC runtime in the next release or so, and that does
handle most C++ (including iostreams, at least in the cases that I have
tested).

-- Lang.

On Wed, Aug 25, 2021 at 10:58 AM David Blaikie <dblaikie at gmail.com> wrote:

> I /think/ this might be because lli doesn't support global ctors (Lang -
> can you confirm?) & so c++'s iostreams haven't been initialized. Maybe try
> a C-style printf hello world, and maybe try printf printing in a global
> ctor, see if that executes?
>
> C style hello world is just generally simpler/doesn't need to exercise
> quite so many complicated things as C++ iostream's hello world, so would be
> a good place to start to narrow down the problem space in any case.
>
> On Tue, Aug 24, 2021 at 5:01 PM Leer Laar via llvm-dev <
> llvm-dev at lists.llvm.org> wrote:
>
>> I am trying to generate a bit code from a c++ source code and running it
>> through the just-in-time compiler. When I compile through the clang++ and
>> generate binary executable it runs perfectly but when I generated the
>> bitcode and tried running through the JIT with lli command it generated a
>> run-time error. Could you please help me understand what's going on.
>>
>> For example: Let example.cpp contains the following code:
>>
>>  #include <iostream>
>>
>>  int main(){
>>     std::cout << "\nHello World!";
>>     return 0;
>>  }
>>
>> I am using the following command to generate executable which runs
>> perfectly fine.
>>
>> clang++ example.cpp
>>
>> I am using the following command to generate the bitcode:
>>
>> clang++ -S -emit-llvm example.cpp
>>
>> And then running through the JIT using the following command which
>> generates run-time error:
>>
>> lli example.ll
>>
>> I am getting the following access violation error:
>>
>> Stack dump:0.      Program arguments: lli example.ll
>> #0 0x00000000025fd9af llvm::sys::PrintStackTrace(llvm::raw_ostream&) /home/xpc/llvm/llvm-project1/llvm-project/llvm/lib/Support/Unix/Signals.inc:564:0
>> #1 0x00000000025fda42 PrintStackTraceSignalHandler(void*) /home/xpc/llvm/llvm-project1/llvm-project/llvm/lib/Support/Unix/Signals.inc:625:0
>> #2 0x00000000025fb7ca llvm::sys::RunSignalHandlers() /home/xpc/llvm/llvm-project1/llvm-project/llvm/lib/Support/Signals.cpp:68:0
>> #3 0x00000000025fd329 SignalHandler(int) /home/xpc/llvm/llvm-project1/llvm-project/llvm/lib/Support/Unix/Signals.inc:406:0
>> #4 0x00007fa75dbdc390 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0x11390)Segmentation fault (core dumped)
>>
>>
>> _______________________________________________
>> LLVM Developers mailing list
>> llvm-dev at lists.llvm.org
>> https://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/20210906/8a59817a/attachment.html>


More information about the llvm-dev mailing list