www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.ldc - Compiling to LLVM Bitcode

reply "Dave G" <test test.com> writes:
LDC has the -output-bc flag to generate bitcode files, but they 
are generated before linking. Is there any way to generate a 
single complete bitcode file (instead of an executable or 
library)?

"llvm-link" can link the files "ldc2 -output-bc" generates, but I 
still need it to link to the standard library and runtime. I 
rebuilt LDC to generate the bitcode files for phobos and the 
runtime and then joined them all, but could not create a working 
executable from that.

The goal here is to generate something that emscripten can 
compile.


PS: I've played around with D a bit, but have never used LDC or 
emscripten before.
Apr 07 2013
parent reply "David Nadlinger" <see klickverbot.at> writes:
I'm in a hurry right now, sorry for the short reply:

On Monday, 8 April 2013 at 04:31:06 UTC, Dave G wrote:
 "llvm-link" can link the files "ldc2 -output-bc" generates, but 
 I still need it to link to the standard library and runtime. I 
 rebuilt LDC to generate the bitcode files for phobos and the 
 runtime and then joined them all, but could not create a 
 working executable from that.
What exactly have you tried, and how did it fail? If you just used the .bc files generated by CMake, I think the issue might be that the C parts of druntime/Phobos (e.g. zlib) are missing. This is a known issue (https://github.com/ldc-developers/ldc/issues/220), and should be fairly easy to fix.
 The goal here is to generate something that emscripten can 
 compile.
I'm not sure if you are on the right track here. druntime contains a lot of stuff that is just not translatable to JavaScript that easily (GC, threading, …). David
Apr 12 2013
parent "Dave G" <test test.com> writes:
On Friday, 12 April 2013 at 20:49:54 UTC, David Nadlinger wrote:
 What exactly have you tried, and how did it fail? If you just 
 used the .bc files generated by CMake, I think the issue might 
 be that the C parts of druntime/Phobos (e.g. zlib) are missing. 
 This is a known issue 
 (https://github.com/ldc-developers/ldc/issues/220), and should 
 be fairly easy to fix.
Yes, I used the .bc files generated by cmake. When compiling with the library there is a multiple symbol definition error (opErr as I recall - I'm not at my pc right now).
 I'm not sure if you are on the right track here. druntime 
 contains a lot of stuff that is just not translatable to 
 JavaScript that easily (GC, threading, …).
I believe you are correct; after I originally posted I realised there was no way the runtime would work out of the box, and without the runtime there would be little point in using D (the hope was to use the same code on the client and server so I didn't have to write/maintain the same functionality twice). When I saw the port of Unreal Engine my excitement must have clouded my judgment. https://github.com/kripken/emscripten/wiki
Apr 12 2013