Dlang LLVM ERROR: Program used external function which could not be resolved

David Nadlinger via digitalmars-d-ldc digitalmars-d-ldc at puremagic.com
Wed Jun 14 10:05:00 PDT 2017


Hi Kevin,

On 14 Jun 2017, at 17:48, BARRE KEVIN via digitalmars-d-ldc wrote:
> LLVM ERROR: Program used external function '_d_throw_exception' which 
> could not be resolved!
>
> Why in c or c++ with
>
> clang -S -emit-llvm foo.c
> lli foo.ll

`_d_throw_exception` is a function in the D standard library (druntime, 
to be precise). As such, even though the LLVM IR produced by LDC is 
well-formed (i.e. LDC is not at fault here), when lli tries to interpret 
the IR in question, it isn't able to find the address of the function 
("could not be resolved"), because it doesn't know anything about 
druntime or how to load it.

lli has the necessary provisions for C/C++, so it works there (I don't 
remember off the top of my head whether they hardcode the C runtime 
functions or simply use the symbols from the lli executable itself, 
which is of course written in C++).

You could, for instance, work around this by compiling druntime into 
bitcode and linking that with your .ll files before trying to execute 
them. Why do you want to use lli in the first place, though?

Best,
David


More information about the digitalmars-d-ldc mailing list