[LLVMdev] Compiler driver

Jean-Daniel Dupas devlists at shadowlab.org
Wed Dec 16 03:49:13 PST 2009

Le 16 déc. 2009 à 10:54, Mark Muir a écrit :

> Hi all,
> I'm developing a custom back-end for an odd-ball architecture (but one that is still describable by LLVMTargetMachine). The toolchain that it will fit into doesn't have a linker as such, so I want to use assembly as the default output. I've got to the point of emitting working custom assembly for very simple C programs (i.e. ones that don't rely on libraries). At the moment, I'm doing this through clang-cc and llc:
> 	clang-cc -D=MY_ARCH -emit-llvm-bc -o -  in.c \
> 	| llc -filetype=asm -march=my_arch
> I want to be able to package this compiler as a cross-compiler - a single binary to go from C to assembly for that target. It should define a macro (as shown above) to allow the target to be identified by source code. I was thinking of doing this using llvmc to capture the above command-line. Is that the recommended approach?

clang-cc does not longer exist, so you should not rely on it and use clang instead.

You should be able to use it exactly the same way that you was using gcc (it is designed to be a drop in replacement), so "clang -arch my_arch -DMY_ARCH -S -o - in.c" should works.

-- Jean-Daniel

More information about the llvm-dev mailing list