Feature request for include llvm-mc in llvm.org/builds

It's already contained C/C++ compiler, but
lack of a assembler. so request for that.

Clang can be used like an assembler in the sense that if it's fed a .s
file, it will assemble it. (I noted that clang-cl doesn't do this for
.asm files, I should fix that.)

I'm not sure that we want to include llvm-mc in the installer. Is it
really intended to be used as an assembler by the end user? The help
text says "llvm machine code playground", which seems to indicate it's
more of an internal tool.

- Hans

2013年10月18日 上午1:15于 “Hans Wennborg” <hans@chromium.org>写道:

It’s already contained C/C++ compiler, but
lack of a assembler. so request for that.

Clang can be used like an assembler in the sense that if it’s fed a .s

oh, thank you very much, i just want to compile some assembly file and link with compiled c object file

Clang can be used like an assembler in the sense that if it's fed a .s
file, it will assemble it. (I noted that clang-cl doesn't do this for
.asm files, I should fix that.)

I'm not sure that we want to include llvm-mc in the installer. Is it
really intended to be used as an assembler by the end user? The help
text says "llvm machine code playground", which seems to indicate it's
more of an internal tool.

I agree. Using the clang binary is the supported public interface for
using the integrated assembler.

Cheers,
Rafael

Clang can be used like an assembler in the sense that if it's fed a .s
file, it will assemble it. (I noted that clang-cl doesn't do this for
.asm files, I should fix that.)

I'm not sure that we want to include llvm-mc in the installer. Is it
really intended to be used as an assembler by the end user? The help
text says "llvm machine code playground", which seems to indicate it's
more of an internal tool.

I agree. Using the clang binary is the supported public interface for
using the integrated assembler.

Yes. It’s not intended for end users at all.

I found that access llvm-mc from clang driver is impossible, and I
want to use llvm-mc to compile assembly files, how to do that?

H:\CI\bld\compilers\musl\src\math\i386>clang -c -v --target=i686-pc-mingw sqrt.s

clang version 3.4 (trunk)
Target: i686-pc-mingw
Thread model: posix
Selected GCC installation:
"gcc" -v -c -m32 -o sqrt.o -x assembler sqrt.s
clang.exe: error: unable to execute command: program not executable
clang.exe: error: assembler (via gcc) command failed with exit code 1 (use -v to
see invocation)

Try "clang -integrated-as -c test.s"

Cheers,
Rafael

I found that access llvm-mc from clang driver is impossible, and I
want to use llvm-mc to compile assembly files, how to do that?

Try "clang -integrated-as -c test.s"

Thank you very much, I use the following command compiled successfully:
clang -integrated-as -c -v --target=i686-pc-mingw sqrt.s

The output format is file format ELF32-i386, i wanna to know
is there a way to output COFF format along with target=i686-pc-mingw.
because I want to compile to following asm file for both linux/gcc and
windows/visual C++.

.global sqrt
.type sqrt,@function
sqrt: fldl 4(%esp)
fsqrt
fstsw %ax
sub $12,%esp
fld %st(0)
fstpt (%esp)
mov (%esp),%ecx
and $0x7ff,%ecx
cmp $0x400,%ecx
jnz 1f
and $0x200,%eax
sub $0x100,%eax
sub %eax,(%esp)
fstp %st(0)
fldt (%esp)
1: add $12,%esp
fstpl 4(%esp)
fldl 4(%esp)
ret

I can confirm I get the same behavior, and that’s a real bug. If you use --target=i686-pc-win32, you get COFF, and that should be a good workaround for now. There must be a conditional somewhere that isn’t handling mingw correctly.

Ah, so clang only understands the spelling mingw32, not mingw. That’ll give you COFF. :slight_smile:

Thanks a lot, I found how it's works, use both
clang -integrated-as -c -v --target=i686-pc-win32 sqrt.s
clang -integrated-as -c -v --target=i686-pc-mingw32 sqrt.s
works. Just because my sqrt.s source code file is invalid for win32.