C compiler as back end

Started by
3 comments, last by Dawoodoz 11 years, 10 months ago
I want to make a compiler that parse my own language and returns C code to a lower compiler. The problem is that every free C/C++ compiler that I have tried takes around 100 megabytes with all it's dependencies. Is there any free lighweight C compiler for Windows that was made to be used as a back end?
Advertisement
www.tinycc.org is extremely small: it can compile code at run time even. However I don't think it includes any of the C headers, which are probably what are using most of your space in the first place

www.tinycc.org is extremely small: it can compile code at run time even. However I don't think it includes any of the C headers, which are probably what are using most of your space in the first place


Nice, I don't even have to compile it using another compiler. :)
Have you considered using llvm? Generating llvm "assembly code" is pretty easy (as it abstracts away the really annoying stuff like register allocation), you can get llvm to compile it as native code or to JIT it, it can optimize it as good as the best compilers out there, or as little as you want if you prefer the compilation process to be very light and fast, and I doubt that including only the llvm libraries + the target specific back end is that big.

LLVM is pretty much designed for the very purpose of handling your type of use case.

Have you considered using llvm? Generating llvm "assembly code" is pretty easy (as it abstracts away the really annoying stuff like register allocation), you can get llvm to compile it as native code or to JIT it, it can optimize it as good as the best compilers out there, or as little as you want if you prefer the compilation process to be very light and fast, and I doubt that including only the llvm libraries + the target specific back end is that big.

LLVM is pretty much designed for the very purpose of handling your type of use case.


I plan to use my front end compiler in Visual Studio projects so that I can use it together with C++. The C compiler will just make it complete for module testing.

This topic is closed to new replies.

Advertisement