goku420 wrote:
LtG wrote:
I just don't see the benefit of a non-optimizing compiler, given that most (and gcc/llvm) compilers will allow you to disable optimizations anyway.
This is not true. Most compilers (including GCC) does not enable you to disable all optimizations. For example:
Code:
gcc -Q -O0 --help=optimizers | grep enabled | wc
outputs 53 for me; and not all options have an "-fno" equivalent. Further, you can't really disable the optimizer itself (which is what Smaller C means when it says it is not an optimizing compiler) since it is part of the compiler backend that actually emits the bytecode.
Good point, something to keep in mind, but not really relevant to what I was saying. My point wasn't that you can necessarily disable all optimizations, I'm not sure you can even make the distinction fully what is and isn't an optimization, since compilers can do pretty much anything they want with the input C code, so long as they follow a few rules.
My point was that practically speaking, given the choice of two compilers, one which doesn't optimize and one which does but allows (to a reasonable extent) to also disable them, why would you want the non-optimizing one? Iansjack made a good point about self-hosting, that may be valid. I don't know if GCC is hard to port and Smaller-C is easy to port.
However, at least for me porting Smaller-C would be useless since it would defeat the whole point. Until some compiler is ported I will have to cross-compile, and I'm doing so with an optimizing compiler. Once I had Smaller-C ported and started to compile my OS _on_ my OS using Smaller-C I immediately get bloated (non-optimized) binaries, which I assume will hurt performance (I don't know how much), which means I probably continue to cross-compile on some other OS, leaving ported Smaller-C unused, thus not useful for me.
Though I am curious if GCC is really hard to port, whether LLVM would be easier, and if Smaller-C is significantly easier that the former two..