operating-systemembeddedembedded-linuxcross-compiling

relation between cross compilation tools and OS


HI, All,

I have a question regarding the cross compilation tools (compiler, assemble, linker, etc.) and operating system. let's take ELDK and linux kernel as an example.

From the wiki and the ibm tutorial (https://www6.software.ibm.com/developerworks/education/l-cross/l-cross-ltr.pdf), the configured cross compiler should be aware of some certain target OS header files as well as new libc, etc. However, the target OS kernel also will be cross compiled via the cross compiler, e.g., eldk, on the target embedded board or machine.

So who comes first? OS or the cross compiler?

Thanks for any clarifications!!


Solution

  • The very first version of any OS must either be cross-compiled, or (for a very simple OS, as in the olden days) hand-written in machine code. More complex executables can then be targeted at the simpler OS, and possibly used to build a more complex OS (the initial compile is called "bootstrapping", the process of an OS compiling itself is called "self-hosting".) Some OSs become self-hosting, some never do, if they're not designed for that level of complexity.

    In any case, I'm not 100% sure what you're asking. Many small-device OSs aren't designed to handle a file system and the other complexities needed to host a compiler, so they never become capable of compiling their own code, and cross-compilation is always necessary. The libraries used by a cross-compiler may well have themselves been cross-compiled; the headers are always those of the target system, too, of course.