1

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 Answers 4

1
    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

0

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.

0
 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

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.

4
  • lli -load /usr/lib/libdruntime-ldc-debug.so.72 -load /usr/lib/libphobos2-ldc-debug.so.72 main.ll no work :( i forgot something ? LLVM ERROR: Program used external function '__start___minfo' which could not be resolved!
    – Barre_k
    Commented Jun 15, 2017 at 14:49
  • Which operating system do you have? Commented Jun 15, 2017 at 15:39
  • Linux unknown 4.11.3-1-ARCH #1 SMP PREEMPT Sun May 28 10:40:17 CEST 2017 x86_64 GNU/Linux
    – Barre_k
    Commented Jun 15, 2017 at 15:43
  • 1
    @Barre_k, I have updated my answer with more details. Maybe this will help. Commented Jun 18, 2017 at 21:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.