Technically, mine does use code that's not of my own creation by using the builtin va_* functions for the kprintf() I wrote, but gcc is inlining whatever code it adds. There are no function calls generated.bzt wrote:Mine neither. I've deliberately eliminated all compiler-specific libraries (wasn't easy, but possible). Now I can compile my OS with both gcc and CLang as-is (and possibly with many other ANSI C compilers too).sj95126 wrote:My kernel is built with gcc and doesn't use libgcc.
Well, that's why I said "simple C code". A main() that doesn't invoke any functions shouldn't need any call instructions. Theoretically, you could implement simple "subroutines" with gotos. There may be architectures I don't know in detail where this can't work.bzt wrote:On the other hand I don't think this is possible (not on all architectures that is). Regardless to the ABI, on x86 some CPU instructions need the stack (like "call" or "ret" for example), and I don't think you can convince a C compiler not to use such instructions.sj95126 wrote:To be *really* pedantic, you could conceivably compile simple C code into a standalone flat binary and never use a stack either.
I didn't say it was practical, just possible.