can gcc cross compile for different CPU?

后端 未结 2 1707
灰色年华
灰色年华 2021-02-13 17:17

Is it possible for gcc, installed on fedora 16, to cross compile for a different CPU, say SPARC? I have build a certain understanding, need some expert to correct me if I am wr

相关标签:
2条回答
  • 2021-02-13 17:55

    No. You can't use native machine (x86) gcc for compiling program files for a different architecture. For that you require a cross-compiler-gcc that is specific to that processor architecture.

    Your understanding about system calls for OS is correct. Each OS has its own set of system call which is been used by library. These libraries at the end will be translated into machine language for the processor.

    Each Processor Architecture has its own set of instruction know as Instruction Set Architecture(ISA). So when a program written in high-level-language (like C) is compiled, it should be converted into machine language from its ISA. This job is done by the compiler(gcc). A compiler will be specific to only one processor architecture. For example gcc is for x86 processor. So if you want a compiler for different processor in you x86 machine you should go for a cross-compiler of that processor.

    0 讨论(0)
  • 2021-02-13 17:59

    You would have to build such a version. That's part of the process of porting gcc to a new platform. You build a version that cross-compiles, then you cross-compile that version, then you test that version on the new platform, debug, rinse, and repeat.

    0 讨论(0)
提交回复
热议问题