Unable to compile .s files generated with llc.

Hey,

I've been trying this for a couple days now, finding different assemblers and trying different options but I can't figure it out..
I must be missing something very obvious.

I got a simple "hello world" app in llvm, making the .bc file using 'llvm-as test.llvm -o=test.bc' works fine.
then I can use llvm-ld to make an executable which then runs fine (although not native), and I can use llc to build the .bc file into a .s file.
So far I'm all good...

But neither masm, yasm, tasm, fasm, gcc, as, or nasm take the .s file.

I only found one other post about this where it was mentioned that only 'GAS" can compile it, so I tried this in both Cygwin and Ubuntu, but to no avail.
In cygwin I get:

$ gcc /cygdrive/d/test.s
/cygdrive/d/test.s: Assembler messages:
/cygdrive/d/test.s:4: Error: no such instruction: `align 16'
/cygdrive/d/test.s:6: Error: invalid character '@' in mnemonic
/cygdrive/d/test.s:7: Error: junk at end of line, first unrecognized character is `%'
/cygdrive/d/test.s:15: Error: invalid character '@' in mnemonic
/cygdrive/d/test.s:16: Error: no such instruction: `db "Hello, World!\000"'

using 'as' I get the same error (I guess gcc just forwards to 'as').

I've tried specifying -x86-asm-syntax=intel, and the att option, neither work with any of the above mentioned assemblers...
I'm sort of completely lost now...

Using the following:
- LLVM 2.6
- GCC 4.4.3
- Cygwin 1.7

Tom.

Van Dijck, Tom wrote:

Hey,

I've been trying this for a couple days now, finding different assemblers and trying different options but I can't figure it out..
I must be missing something very obvious.

I got a simple "hello world" app in llvm, making the .bc file using 'llvm-as test.llvm -o=test.bc' works fine.
then I can use llvm-ld to make an executable which then runs fine (although not native), and I can use llc to build the .bc file into a .s file.
So far I'm all good...

But neither masm, yasm, tasm, fasm, gcc, as, or nasm take the .s file.

I only found one other post about this where it was mentioned that only 'GAS" can compile it, so I tried this in both Cygwin and Ubuntu, but to no avail.
In cygwin I get:

$ gcc /cygdrive/d/test.s
/cygdrive/d/test.s: Assembler messages:
/cygdrive/d/test.s:4: Error: no such instruction: `align 16'
/cygdrive/d/test.s:6: Error: invalid character '@' in mnemonic
/cygdrive/d/test.s:7: Error: junk at end of line, first unrecognized character is `%'
/cygdrive/d/test.s:15: Error: invalid character '@' in mnemonic
/cygdrive/d/test.s:16: Error: no such instruction: `db "Hello, World!\000"'

using 'as' I get the same error (I guess gcc just forwards to 'as').

I've tried specifying -x86-asm-syntax=intel, and the att option, neither work with any of the above mentioned assemblers...
I'm sort of completely lost now...

This is a known problem. When the target OS is set to "windows", LLVM
generates a weird combination of NASM and GAS assembly.

Try setting the target triple to something like "i386-mingw32". That
should give you something you can assemble with GAS.

Chip

thanks a lot.... that did it indeed.

llc test.bc -mtriple=i386-mingw32

results in a very very different looking .s file..

Tom.

Hello, Everyone

This is a known problem. When the target OS is set to "windows", LLVM
generates a weird combination of NASM and GAS assembly.

We're not doing such insane things anymore. AT&T MCAsmInfo is used for
asmprinting everywhere on windows, since we don't have other usable
asmprinter :slight_smile: