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

1.4k Views Asked by At

main.d

import std.stdio;

void    main()
{
    writeln("Hello World !!!");
}

when i compile and execute it is work perfectly

But when i try

ldc2 -output-ll main.d
lli main.ll

LLVM ERROR: Program used external function '_d_throw_exception' which could not be resolved!

I try in c

#include<stdio.h>

void    main()
{
  printf("Hello World !!!");
}

and

clang -S -emit-llvm foo.c

lli foo.ll

it is work !!

Why in Dlang does not work when i compile width ldc ???

4

There are 4 best solutions below

0
On BEST ANSWER

Because the cruntime is avilable to lli. Whereas the druntime is not. If you were to link the druntime and phobos into lli or load it at startup it would work.

4
On

LLVM ERROR: Program used external function '_d_throw_exception' which could not be resolved!

You need to figure out which dynamic library has this symbol and link it dynamically to your program using lli -load /path/to/your/library.{so,dylib} ... foo.ll.

I am not a D developer so I don't what library you need. To find a library look at your Dlang distrubution's libraries. As Stefan K said it you probably need a library responsible for D runtime.


Generally if you are missing any symbols, on Linux system you can use

readelf --syms somelib.so

or

objdump --dynamic-syms somelib.so

Based on this command you can write a routine using find that will traverse through the folder with libraries you suspect to have the symbols you are missing, smth like:

find path-to-dlang-libs-folder -type f ! -name "*.so" -exec objcdump --dynamic-libs -- {} + | grep _start___minfo

You might need to tweak this command to work on Linux though.

0
On
 lli -load /usr/lib/libdruntime-ldc-debug.so.72 -load /usr/lib/libphobos2-ldc-debug.so.72 main.ll

and i have

LLVM ERROR: Program used external function '__start___minfo' which could not be resolved!

0
On
    ldc2 -output-ll -betterC main.d

    lli -load /usr/lib/libphobos2-ldc.so.72 main.ll

    ./main

output -> Hello World !!!

It is because

I need to disable all the functionality requiring runtime

http://forum.dlang.org/post/[email protected] Thanks every one and David Nadlinger