can gcc cross compile for different CPU?

后端 未结 2 1708
灰色年华
灰色年华 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.

提交回复
热议问题