Vyacheslav Akhmechet
2005-Mar-07 16:20 UTC
[LLVMdev] GCC assembler rejects native code generated by LLVM
I successfully compiled CVS HEAD yesterday on my win32 machine using Visual C++ Express (2005). I also have Mingw tools installed. I wrote a simple hello world application and generated native assembly code using llvm. When I tried to feed the code into GCC, it rejected it with "junk at the end of line" error messages. Shouldn't GCC be able to assemble this code? I realize win32 port isn't complete but I was under the impression that this should work. Thanks.
Chris Lattner
2005-Mar-07 16:36 UTC
[LLVMdev] GCC assembler rejects native code generated by LLVM
On Mon, 7 Mar 2005, Vyacheslav Akhmechet wrote:> I successfully compiled CVS HEAD yesterday on my win32 machine using > Visual C++ Express (2005). I also have Mingw tools installed. I wrote > a simple hello world application and generated native assembly code > using llvm. When I tried to feed the code into GCC, it rejected it > with "junk at the end of line" error messages. Shouldn't GCC be able > to assemble this code? I realize win32 port isn't complete but I was > under the impression that this should work.I'm not sure what the issue is, but if you send in the exact .s file produced and the errors you're getting, we can fix it. :) -Chris -- http://nondot.org/sabre/ http://llvm.cs.uiuc.edu/
Vyacheslav Akhmechet
2005-Mar-07 16:38 UTC
[LLVMdev] GCC assembler rejects native code generated by LLVM
I'm at work so I don't have exact details at the moment. I'll send the .s file and the errors tonight. Thanks for the quick reply! On Mon, 7 Mar 2005 10:36:10 -0600 (CST), Chris Lattner <sabre at nondot.org> wrote:> On Mon, 7 Mar 2005, Vyacheslav Akhmechet wrote: > > I successfully compiled CVS HEAD yesterday on my win32 machine using > > Visual C++ Express (2005). I also have Mingw tools installed. I wrote > > a simple hello world application and generated native assembly code > > using llvm. When I tried to feed the code into GCC, it rejected it > > with "junk at the end of line" error messages. Shouldn't GCC be able > > to assemble this code? I realize win32 port isn't complete but I was > > under the impression that this should work. > > I'm not sure what the issue is, but if you send in the exact .s file > produced and the errors you're getting, we can fix it. :) > > -Chris > > -- > http://nondot.org/sabre/ > http://llvm.cs.uiuc.edu/ >
Jeff Cohen
2005-Mar-07 16:40 UTC
[LLVMdev] GCC assembler rejects native code generated by LLVM
I'm confused. My understanding is that Visual C++ Express does not include Visual Studio, which is required to build LLVM. Anyway, assembly code generation is not yet supported using the Microsoft tool chain (as documented in the Getting Started with VS page), and when it is it will be with NASMW and not GCC. Not that any of this explains the "junk at the end of line" you got. Vyacheslav Akhmechet wrote:>I successfully compiled CVS HEAD yesterday on my win32 machine using >Visual C++ Express (2005). I also have Mingw tools installed. I wrote >a simple hello world application and generated native assembly code >using llvm. When I tried to feed the code into GCC, it rejected it >with "junk at the end of line" error messages. Shouldn't GCC be able >to assemble this code? I realize win32 port isn't complete but I was >under the impression that this should work. > >Thanks. > >_______________________________________________ >LLVM Developers mailing list >LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu >http://mail.cs.uiuc.edu/mailman/listinfo/llvmdev > > > >
Vyacheslav Akhmechet
2005-Mar-07 16:57 UTC
[LLVMdev] GCC assembler rejects native code generated by LLVM
> I'm confused. My understanding is that Visual C++ Express does not > include Visual Studio, which is required to build LLVM.Well, Visual C++ Express is a cut down version of Visual Studio. I'm not sure about exact differences between editions but Visual C++ Express does read the .sln files and comes with an excellent C++ compiler. I didn't encounter any problems building llvm or running various tools.> Anyway, > assembly code generation is not yet supported using the Microsoft tool > chain (as documented in the Getting Started with VS page)I've seen that document. It suggests that one cannot assemble native executables using MS tools because they don't come with an assembler. Another document (don't remember which one, exactly) says native code generation is supported on Windows using Mingw tools. This is exactly what I'm trying to do: assemble an executable using Mingw. I don't see why it should matter whether llvm tools are built using gcc or MSVC, the generated assembly code should be the same, shouldn't it?
Vyacheslav Akhmechet
2005-Mar-08 00:39 UTC
[LLVMdev] GCC assembler rejects native code generated by LLVM
Ok, I got home so I have more details. Here's the sample C program: ----------------- C program --------------- #include <stdio.h> int main() { printf("hello world\n"); return 0; } ------------- end C program ------------- This is compiled using llvm online demo into the following llvm code (target removed): ----------------- LLVM code -------------- deplibs = [ "stdc++", "c", "crtend" ] %.str_1 = internal constant [13 x sbyte] c"hello world\0A\00"; <[13 x sbyte]*> [#uses=1] implementation ; Functions: declare int %printf(sbyte*, ...) int %main() { entry: call void %__main( ) %tmp.0 = call int (sbyte*, ...)* %printf( sbyte* getelementptr ([13 x sbyte]* %.str_1, int 0, int 0) ); <int> [#uses=0] ret int 0 } declare void %__main() ------------- End LLVM code ----------- which in turn produces the following assembly code: ------------- Assembly code ------------- .text .align 16 .globl main .type main, @function main: subl $12, %esp fnstcw 10(%esp) movb $2, 11(%esp) fldcw 10(%esp) call __main movl $l1__2E_str_1, %eax movl %eax, (%esp) call printf movl $0, %eax #IMPLICIT_USE addl $12, %esp ret .data .align 1 .type l1__2E_str_1, at object .size l1__2E_str_1,13 l1__2E_str_1: # [13 x sbyte]* %.str_1 = c"hello world\0A\00" .ascii "hello world\n\000" ---------- End assembly code ---------- When I try to assemble the above code using gcc hello.c.s -o hello.exe I get the following errors: hello.c.s: Assembler messages: hello.c.s:6: Warning: .type pseudo-op used outside of .def/.endef ignored. hello.c.s:6: Error: junk at end of line, first unrecognized character is `m' hello.c.s:24: Warning: .type pseudo-op used outside of .def/.endef ignored. hello.c.s:24: Error: junk at end of line, first unrecognized character is `l' hello.c.s:25: Warning: .size pseudo-op used outside of .def/.endef ignored. hello.c.s:25: Error: junk at end of line, first unrecognized character is `l' Sorry for the long email. I attach all relevant files for clarity. -------------- next part -------------- An embedded and charset-unspecified text was scrubbed... Name: hello.c.s URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20050307/09270a51/attachment.ksh> -------------- next part -------------- An embedded and charset-unspecified text was scrubbed... Name: hello.c URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20050307/09270a51/attachment.c>
Reid Spencer
2005-Mar-08 01:19 UTC
[LLVMdev] GCC assembler rejects native code generated by LLVM
Vyacheslav, This is the same problem that I had with Cygwin .. nearly identical. The issue was documented in PR492 if you want some background. I'm currently trying to dig up what I did to fix this in December for Cygwin and see if I can apply the same change for mingw. Reid. On Mon, 2005-03-07 at 16:39, Vyacheslav Akhmechet wrote:> Ok, I got home so I have more details. Here's the sample C program: > ----------------- C program --------------- > #include <stdio.h> > int main() { > printf("hello world\n"); > return 0; > } > ------------- end C program ------------- > > This is compiled using llvm online demo into the following llvm code > (target removed): > ----------------- LLVM code -------------- > deplibs = [ "stdc++", "c", "crtend" ] > %.str_1 = internal constant [13 x sbyte] c"hello world\0A\00"; <[13 x > sbyte]*> [#uses=1] > > implementation ; Functions: > > declare int %printf(sbyte*, ...) > > int %main() { > entry: > call void %__main( ) > %tmp.0 = call int (sbyte*, ...)* %printf( sbyte* getelementptr ([13 x > sbyte]* %.str_1, int 0, int 0) ); <int> [#uses=0] > ret int 0 > } > > declare void %__main() > ------------- End LLVM code ----------- > > which in turn produces the following assembly code: > > ------------- Assembly code ------------- > .text > .align 16 > .globl main > .type main, @function > main: > subl $12, %esp > fnstcw 10(%esp) > movb $2, 11(%esp) > fldcw 10(%esp) > call __main > movl $l1__2E_str_1, %eax > movl %eax, (%esp) > call printf > movl $0, %eax > #IMPLICIT_USE > addl $12, %esp > ret > > > .data > .align 1 > .type l1__2E_str_1, at object > .size l1__2E_str_1,13 > l1__2E_str_1: # [13 x sbyte]* %.str_1 = c"hello world\0A\00" > .ascii "hello world\n\000" > ---------- End assembly code ---------- > > When I try to assemble the above code using > gcc hello.c.s -o hello.exe > I get the following errors: > > hello.c.s: Assembler messages: > hello.c.s:6: Warning: .type pseudo-op used outside of .def/.endef ignored. > hello.c.s:6: Error: junk at end of line, first unrecognized character is `m' > hello.c.s:24: Warning: .type pseudo-op used outside of .def/.endef ignored. > hello.c.s:24: Error: junk at end of line, first unrecognized character is `l' > hello.c.s:25: Warning: .size pseudo-op used outside of .def/.endef ignored. > hello.c.s:25: Error: junk at end of line, first unrecognized character is `l' > > Sorry for the long email. I attach all relevant files for clarity. > > ______________________________________________________________________ > _______________________________________________ > LLVM Developers mailing list > LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu > http://mail.cs.uiuc.edu/mailman/listinfo/llvmdev-------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 189 bytes Desc: This is a digitally signed message part URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20050307/f34cdf94/attachment.sig>
Reid Spencer
2005-Mar-08 01:32 UTC
[LLVMdev] GCC assembler rejects native code generated by LLVM
Vyacheslav, I've tracked down the change and I have a fix for you to test. The attached patch should be applied to the CVS head (version 1.132) of X86AsmPrinter.cpp in llvm/lib/Target/X86. The patch just includes MINGW targets in the same set of choices that it makes for Cygwin. Could you please try the patch and let me know if it solves your problem? If it does, I'll commit the patch. Thanks, Reid. On Mon, 2005-03-07 at 16:39, Vyacheslav Akhmechet wrote:> Ok, I got home so I have more details. Here's the sample C program: > ----------------- C program --------------- > #include <stdio.h> > int main() { > printf("hello world\n"); > return 0; > } > ------------- end C program ------------- > > This is compiled using llvm online demo into the following llvm code > (target removed): > ----------------- LLVM code -------------- > deplibs = [ "stdc++", "c", "crtend" ] > %.str_1 = internal constant [13 x sbyte] c"hello world\0A\00"; <[13 x > sbyte]*> [#uses=1] > > implementation ; Functions: > > declare int %printf(sbyte*, ...) > > int %main() { > entry: > call void %__main( ) > %tmp.0 = call int (sbyte*, ...)* %printf( sbyte* getelementptr ([13 x > sbyte]* %.str_1, int 0, int 0) ); <int> [#uses=0] > ret int 0 > } > > declare void %__main() > ------------- End LLVM code ----------- > > which in turn produces the following assembly code: > > ------------- Assembly code ------------- > .text > .align 16 > .globl main > .type main, @function > main: > subl $12, %esp > fnstcw 10(%esp) > movb $2, 11(%esp) > fldcw 10(%esp) > call __main > movl $l1__2E_str_1, %eax > movl %eax, (%esp) > call printf > movl $0, %eax > #IMPLICIT_USE > addl $12, %esp > ret > > > .data > .align 1 > .type l1__2E_str_1, at object > .size l1__2E_str_1,13 > l1__2E_str_1: # [13 x sbyte]* %.str_1 = c"hello world\0A\00" > .ascii "hello world\n\000" > ---------- End assembly code ---------- > > When I try to assemble the above code using > gcc hello.c.s -o hello.exe > I get the following errors: > > hello.c.s: Assembler messages: > hello.c.s:6: Warning: .type pseudo-op used outside of .def/.endef ignored. > hello.c.s:6: Error: junk at end of line, first unrecognized character is `m' > hello.c.s:24: Warning: .type pseudo-op used outside of .def/.endef ignored. > hello.c.s:24: Error: junk at end of line, first unrecognized character is `l' > hello.c.s:25: Warning: .size pseudo-op used outside of .def/.endef ignored. > hello.c.s:25: Error: junk at end of line, first unrecognized character is `l' > > Sorry for the long email. I attach all relevant files for clarity. > > ______________________________________________________________________ > _______________________________________________ > LLVM Developers mailing list > LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu > http://mail.cs.uiuc.edu/mailman/listinfo/llvmdev-------------- next part -------------- Index: X86AsmPrinter.cpp ==================================================================RCS file: /var/cvs/llvm/llvm/lib/Target/X86/X86AsmPrinter.cpp,v retrieving revision 1.132 diff -r1.132 X86AsmPrinter.cpp 89c89 < #ifdef __CYGWIN__ ---> #if defined(__CYGWIN__) || defined(__MINGW32__)-------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 189 bytes Desc: This is a digitally signed message part URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20050307/f02fe591/attachment.sig>
Possibly Parallel Threads
- [LLVMdev] GCC assembler rejects native code generated by LLVM
- [LLVMdev] GCC assembler rejects native code generated by LLVM
- [LLVMdev] GCC assembler rejects native code generated by LLVM
- [LLVMdev] GCC assembler rejects native code generated by LLVM
- [LLVMdev] GCC assembler rejects native code generated by LLVM