Windows build: how did you do it?
Carl
name.is.carl at gmail.com
Sun Jan 26 05:48:28 PST 2014
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 =
target.createTargetMachine(triple);
targetMachine.setAsmVerbosityDefault(true);
targetMachine.setFunctionSections(true);
targetMachine.setDataSections(true);
targetMachine.getOptions().setNoFramePointerElim(true);
output.reset();
targetMachine.emit(module, output,
CodeGenFileType.AssemblyFile);
module.dispose();
context.dispose();
byte[] asm = output.toByteArray();
output.reset();
asm = output.toByteArray();
BufferedOutputStream oOut = new BufferedOutputStream(new
FileOutputStream(oFile));
targetMachine.assemble(asm, clazz.getClassName(), oOut);
oOut.close();
Unfortunately, the assemble call fails with the error
org.robovm.llvm.LlvmException: java.io.PrintWriter:478:2: error:
unknown directive
.section
.text$java_io_PrintWriter_checkError__Z_lookup,"xr"
^
java.io.PrintWriter:479:2: error: unknown directive
.linkonce discard
^
java.io.PrintWriter:629:2: error: unknown directive
.section
.text$java_io_PrintWriter_clearError__V_lookup,"xr"
^
java.io.PrintWriter:630:2: error: unknown directive
.linkonce discard
^
java.io.PrintWriter:818:2: error: unknown directive
.section
.text$java_io_PrintWriter_close__V_lookup,"xr"
^
java.io.PrintWriter:819:2: error: unknown directive
.linkonce discard
^
java.io.PrintWriter:1008:2: error: unknown directive
.section
.text$java_io_PrintWriter_flush__V_lookup,"xr"
^
java.io.PrintWriter:1009:2: error: unknown directive
.linkonce discard
^
java.io.PrintWriter:1062:2: error: unknown directive
.section
.text$java_io_PrintWriter_format__Ljava_lang_String$3B$5BLjava_lang_Object$3B__Ljava_io_PrintWriter$3B_lookup,"xr"
^
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,
CodeGenFileType.ObjectFile);
the generation is OKAY.
(but then my program is unable to process the ASM, so that's not
good).
More information about the digitalmars-d-ldc
mailing list