What is the reason for llvm-gcc? Will regular gcc work (except for the releases that are broken, of course)? Does llvm in any way depend on features of llvm-gcc instead of gcc? Or is it optional? Was it conceived to give llvm itself a through shakedown? Is it there just in case you really want llvm code in some form from a C program? Is such llvm code necessary for some kind of use -- might it be that that a compiler that uses llvm can only link with ofher llvm-generated code? -- hendrik
Hendrik Boom wrote:> What is the reason for llvm-gcc? Will regular gcc work (except for the > releases that are broken, of course)? Does llvm in any way depend on > features of llvm-gcc instead of gcc? >llvm-gcc has a two-fold purpose. First, they are the front-end compilers for C/C++ for LLVM. In other words, they take C/C++ source code and translate it to LLVM assembly code which can then be assembled using llvm-as and transformed/analysis using the LLVM tools. This functionality is enabled using the -emit-llvm option. Second, llvm-gcc is a compiler built using LLVM that compiles C/C++ code to native code. It does the same thing as regular gcc except that it uses the LLVM optimization and code generation libraries instead of the original ones found in gcc. This is the default way of using llvm-gcc; it basically makes it easier for people to use LLVM as a drop-in replacement for GCC.> Or is it optional? Was it conceived to give llvm itself a through > shakedown? Is it there just in case you really want llvm code in some > form from a C program? Is such llvm code necessary for some kind of use > -- might it be that that a compiler that uses llvm can only link with > ofher llvm-generated code? >It depends on what you want to do. If you want to use LLVM as a replacement for GCC, then yes. If you want to compiler C/C++ code to LLVM so that you can analyze/transform it using your own LLVM passes, yes. If you're writing your own language front-end for LLVM, then no. Hope that helps. -- John T.> -- hendrik > > _______________________________________________ > LLVM Developers mailing list > LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev >
On Tue, 03 Jun 2008 09:23:46 -0500, John Criswell wrote:> It depends on what you want to do. If you want to use LLVM as a > replacement for GCC, then yes. If you want to compiler C/C++ code to > LLVM so that you can analyze/transform it using your own LLVM passes, > yes. If you're writing your own language front-end for LLVM, then no. > > Hope that helps.That's exactly what I needed to know. Thanks. -- hendrik
Matthijs Kooijman
2008-Jun-03 14:55 UTC
[LLVMdev] Why llvm-gcc? Another beginner's question.
Hi Hendrik,> What is the reason for llvm-gcc? Will regular gcc work (except for the > releases that are broken, of course)? Does llvm in any way depend on > features of llvm-gcc instead of gcc?llvm-gcc is a frontend: It can compile various languages (C, C++ and probably more) into llvm assembly / bitcode. Regular gcc can only compile into native machine code, and is not really needed or useful with llvm. LLVM can work fine without llvm-gcc, but you will have to have some other way of creating llvm assembly / bitcode, such as writing assembly directly, writing your own frontend, or using the clang frontend (also developed within the llvm project). LLVM does require binutils for assembling (and perhaps also linking?) executables at the end of the chain. However, for the middle part (optimizing, codegeneration and I think also linking) llvm is selfsufficient.> -- might it be that that a compiler that uses llvm can only link with > ofher llvm-generated code?llvm can codegen into normal object files, which can be linked against normal libraries, also by other linkers. However, any llvm code that is still in bitcode (LLVM IR) form can only be processed by LLVM of course. Gr. Matthijs -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 189 bytes Desc: Digital signature URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20080603/4e102e24/attachment.sig>
> What is the reason for llvm-gcc? Will regular gcc work > (except for the releases that are broken, of course)?No one can tell the answer to this question ... because the answer depends on what you're up to. LLVM itself is frontend agnostic. It itself starts from a low-level, assembly like, but SSA-formed language. See http://www.llvm.org/docs/LangRef.html. Mangling objects in this language are a bunch of analyzers and optimizers, http://www.llvm.org/docs/Passes.html. And finally, there are a bunch of various backends that generate assembly-language ... to JIT or to link as a standalong applicant. Now, how do you get this Low-Level-Language? For one, you can write it by hand. Many test-case in the LLVM framework have been written by hand, see all the *.ll file at http://www.llvm.org/viewvc/llvm-project/llvm/trunk/test/ Or you can use a compiler. llvm-gcc is just one of the possible compilers. It uses gcc to parse C, C++, produces gimple, like gcc normally does. But then the gimple is converted to the LLVM low-level language and handed over to LLVM. There are other frontends, e.g. "clang", which aims to be a faster and less-resource-hungry compiler (or, compiler library, e.g. easy to include/link into an IDE). Or I have heard about a compiler for the "D" language to LLVM, see http://www.dsource.org/projects/llvmdc. There's an examply forth-link front page ... and so on.> Does llvm in any way depend on features of llvm-gcc instead of > gcc?Now you might realize that this question doesn't really make sense.> Or is it optional?Again, this depends. If you want to compile/optimize C++ via llvm, you need llvm-g++, so it's not optional. But for some C programs, clang migth already be usable (yet it's highly experimental). If it's needed for your needs ... who knows, but you? Greetings, Holger