开发者

Porting GCC to new architectures [closed]

开发者_StackOverflow中文版 It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center. Closed 11 years ago.

How do I go about porting gcc to a new architecture? I am specifically interested in the following architectures:

  • ARM (TI OMAPs)
  • TI MSP430
  • x86

but guidance on how to port to any architecture would go some way to solving my problem.


Learning to port gcc is going to be a significantly non-trivial task. As a rough guide of what to expect, you will need to know:

  • The target architecture inside out. Literally, otherwise how else will you know how to convert C to it?
  • The C standard, so C89, C99 etc.
  • How compilers work. There are whole books on this.

In order to start the process, you would typically start with the C-to-assembly translation on your host architecture, such that you could compile something for the target architecture (but on your host). You would then get to the stage where you can compile a compiler for your target architecture on your host. At this stage, you produce a compiler on the target which can then self-compile, so you now have gcc on the target.

Once this work has been done, actually porting gcc is simply a case of building gcc from the host on the target. If that's all you're interested in, Linux from scratch is a very good guide for doing everything you'll need to do (as gcc would, amongst other things, be a prerequisite for porting the kernel).


In all likelihood GCC is already available for the architecture you want, in which case you want GCC as a cross-compiler (f.e. on a x86 machine with Windows, use gcc to cross-compile for ARM chips). You can see the targets for gcc here.

Note that in all likelihood you will need to compile GCC yourself with that target.

BTW, what is your target architecture?

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜