开发者

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 开发者_StackOverflow中文版compiler, e.g., eldk, on the target embedded board or machine.

So who comes first? OS or the cross compiler?

Thanks for any clarifications!!


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.


Neither the kernel nor the user-space cross-compiler come first.

Typically, you don't compile the OS kernel with the same cross-compiler you use for userspace. Instead, you compile the kernel and C library with a "bootstrap" cross-compiler that's intended for compiling things to run directly on the hardware without help from an OS, and which is set up to not look for a pre-existing libc. At that point, you have your kernel and core libraries, and can use those to create the normal userspace cross-compiler.

(Linux is somewhat of an exception to this on the kernel side, as there's a fair bit of hackery included that makes it possible to use a userspace compiler to compile the Linux kernel. It's not at all a good example of "normal". But even there the cross-compiler comes first; you don't need to compile the kernel to be able to include kernel header files.)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜