Why do cross-compilers have a two stage compilation?

流过昼夜 提交于 2020-01-02 09:28:31

问题


I currently try to understand how cross-compilers work. I'm a bit confused about the two-staged compiler compilation process.

As far as I read, the following procedure is applied:

  • Compile bintutils for the target architecture
  • Compile GCC (stage 1)
  • Compile newlib/eglibc/... with GCC
  • Compile GCC with the libc (stage 2)

Why is there a second stage involved? Couldn't I just invoke the first stage compiler with some flag like -lc to include libc?


回答1:


I'm not sure why gcc has such a complicated build process. My clang/LLVM based ELLCC (http://ellcc.org) cross tool chain project builds like this:

  1. Compile the compiler (using either gcc or a pre-built version of the ELLCC compiler available from the web site.).
  2. Use the compiler to build the C++ and C libraries for all targets.
  3. Build binutils and gdb for all targets (for all targets: don't make target specific utilitities except for the assemblers. ld, gdb, objdump, etc. all support this)
  4. (optional) Use your newly built compiler to cross build itself for all the targets.

BTW, ELLCC currently supports ARM, Microblaze, Mips, PowerPC, and x86 targets for Linux and bare metal execution environments.



来源:https://stackoverflow.com/questions/27457835/why-do-cross-compilers-have-a-two-stage-compilation

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!