www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.ldc - Windows build: how did you do it?

reply "Carl" <name.is.carl gmail.com> writes:
Hello guys,

I would like to ask a question more about llvm than about d :)
I'm not sure that this is "correct" thing to do, but I'm stuck 
and out of options.
(flame away if you feel like I'm abusing your forum)

I'm using llvm on windows (with mingw) to compile IR code that my 
program generates.

Which is pretty much what you did with the D compiler.

I do it in two phases:

        TargetMachine targetMachine = 

         targetMachine.emit(module, output, 

         byte[] asm = output.toByteArray();
         asm = output.toByteArray();

         BufferedOutputStream oOut = new BufferedOutputStream(new 

         targetMachine.assemble(asm, clazz.getClassName(), oOut);

Unfortunately, the assemble call fails with the error

org.robovm.llvm.LlvmException: java.io.PrintWriter:478:2: error: 
unknown directive
java.io.PrintWriter:479:2: error: unknown directive
         .linkonce discard
java.io.PrintWriter:629:2: error: unknown directive
java.io.PrintWriter:630:2: error: unknown directive
         .linkonce discard
java.io.PrintWriter:818:2: error: unknown directive
java.io.PrintWriter:819:2: error: unknown directive
         .linkonce discard
java.io.PrintWriter:1008:2: error: unknown directive
java.io.PrintWriter:1009:2: error: unknown directive
         .linkonce discard
java.io.PrintWriter:1062:2: error: unknown directive
java.io.PrintWriter:1063:2: error: unknown directive
         .linkonce discard

Did you ever get that error?
The fact is I need to generate my code in two steps (emit 
assembly and then assemble) because of some ASM processing.
It is interesting to notice that if I generate the obj directly 
with targetMachine.emit(module, output, 
the generation is OKAY.

(but then my program is unable to process the ASM, so that's not 
Jan 26 2014
next sibling parent David Nadlinger <code klickverbot.at> writes:
Hi Carl,

we are currently invoking gcc (i.e. GAS) as a subprocess for
assembling, because the MC COFF backend does not support emitting
Dwarf EH information yet (at least when I last checked). Before we had
working EH, we were using MC to directly write out the COFF object
files, which as you mentioned works without problems.

I never tried to make MC emit ASM and then parse it again, although it
seems as though it should work.

Jan 26 2014
prev sibling parent "Kai Nacke" <kai redstar.de> writes:
On Sunday, 26 January 2014 at 13:48:29 UTC, Carl wrote:
 Did you ever get that error?
Hi Carl! LLVM has not implemented everything which is needed for Windows. Some time ago I tried the same with clang: clang -S -emit-llvm -o exc_alloc.ll exc_alloc.c llc -filetype=asm exc_alloc.ll clang -c exc_alloc.s The file exc_alloc.c contained a dll_import reference which was/is not supported by the assembler. IMHO you are getting the same kind of error. (Windows is not yet a first class citizen of LLVM. If you really need something implemented then you should look if you can contribute it to LLVM. I do the same.) Regards, Kai
Jan 26 2014