<br><div class="gmail_quote"><br>Hello guys,<br><br>I'm using llvm 3.3 on windows with mingw (triple: "i386-unknown-mingw32") to compile IR code that my <br>program generates.<br><br>I do it in two phases: first I emit assembly code and then assemble it.<br>

<br>       TargetMachine targetMachine = <br>target.createTargetMachine(triple);<br><br>        targetMachine.setAsmVerbosityDefault(true);<br>        targetMachine.setFunctionSections(true);<br>        targetMachine.setDataSections(true);<br>

        targetMachine.getOptions().setNoFramePointerElim(true);<br>        output.reset();<br>        targetMachine.emit(module, output, <br>CodeGenFileType.AssemblyFile);<br>        module.dispose();<br>        context.dispose();<br>

<br>        byte[] asm = output.toByteArray();<br>        output.reset();<br>        asm = output.toByteArray();<br><br>        BufferedOutputStream oOut = new BufferedOutputStream(new <br>FileOutputStream(oFile));<br><br>

        targetMachine.assemble(asm, clazz.getClassName(), oOut);<br>        oOut.close();<br><br>(I use a java binding for llvm)<br><br>Unfortunately, the assemble call fails with the error: <br><br>org.robovm.llvm.LlvmException: java.io.PrintWriter:478:2: error: <br>

unknown directive<br>        .section        <br>.text$java_io_PrintWriter_checkError__Z_lookup,"xr"<br>        ^<br>java.io.PrintWriter:479:2: error: unknown directive<br>        .linkonce discard<br>        ^<br>

java.io.PrintWriter:629:2: error: unknown directive<br>        .section        <br>.text$java_io_PrintWriter_clearError__V_lookup,"xr"<br>        ^<br>java.io.PrintWriter:630:2: error: unknown directive<br>        .linkonce discard<br>

        ^<br>java.io.PrintWriter:818:2: error: unknown directive<br>        .section        <br>.text$java_io_PrintWriter_close__V_lookup,"xr"<br>        ^<br>java.io.PrintWriter:819:2: error: unknown directive<br>

        .linkonce discard<br>        ^<br>java.io.PrintWriter:1008:2: error: unknown directive<br>        .section        <br>.text$java_io_PrintWriter_flush__V_lookup,"xr"<br>        ^<br>java.io.PrintWriter:1009:2: error: unknown directive<br>

        .linkonce discard<br>        ^<br>java.io.PrintWriter:1062:2: error: unknown directive<br>        .section        <br>.text$java_io_PrintWriter_format__Ljava_lang_String$3B$5BLjava_lang_Object$3B__Ljava_io_PrintWriter$3B_lookup,"xr"<br>

        ^<br>java.io.PrintWriter:1063:2: error: unknown directive<br>        .linkonce discard<br><br>Did you ever get that error?<br>The fact is I need to generate my code in two steps (emit <br>assembly and then assemble) because of some ASM processing that my program later does (and that I commented out).<br>

It is interesting to notice that if I generate the obj directly with <br>    targetMachine.emit(module, output, CodeGenFileType.ObjectFile);<br>the generation is OK.<br><br>(but then my program is unable to process the ASM, so that's not <br>

good).<br><br>More info about my llvm configuration: <br><br><span style="font-family:courier new,monospace">LLVM (<a href="http://llvm.org/" target="_blank">http://llvm.org/</a>):<br>  LLVM version 3.3<br>  Optimized build with assertions.<br>

  Built Aug  4 2013 (14:50:50).<br>  Default target: i686-w64-mingw32<br>  Host CPU: corei7-avx<br><br>  Registered Targets:<br>    aarch64  - AArch64<br>    arm      - ARM<br>    cpp      - C++ backend<br>    hexagon  - Hexagon<br>

    mblaze   - MBlaze<br>    mips     - Mips<br>    mips64   - Mips64 [experimental]<br>    mips64el - Mips64el [experimental]<br>    mipsel   - Mipsel<br>    msp430   - MSP430 [experimental]<br>    nvptx    - NVIDIA PTX 32-bit<br>

    nvptx64  - NVIDIA PTX 64-bit<br>    ppc32    - PowerPC 32<br>    ppc64    - PowerPC 64<br>    sparc    - Sparc<br>    sparcv9  - Sparc V9<br>    systemz  - SystemZ<br>    thumb    - Thumb<br>    x86      - 32-bit X86: Pentium-Pro and above<br>

    x86-64   - 64-bit X86: EM64T and AMD64<br>    xcore    - XCore</span><br><br>Any idea what may be wrong?<span class="HOEnZb"><font color="#888888"><br><br>Carl.<br>
</font></span></div><br>