简体   繁体   English

我可以使用gcc -march编译到其他ISA中吗

[英]Can I use gcc -march to compile into other ISA

My own computer has an Intel Core I5. 我自己的计算机上装有Intel Core I5。 However, I want to know what the assembly will look like if I use some RISC ISA, for example, ARM or powerPC. 但是,我想知道如果使用某些RISC ISA(例如ARM或powerPC)的程序集是什么样的。

Can I compile C code into assembly using other microarchitecture's ISA? 我可以使用其他微体系结构的ISA将C代码编译为汇编语言吗?

No. -march only affects what subarchitecture the compiler will target (eg, whether it will use features which are not available on all CPUs). 不。- -march仅影响编译器将针对的子体系结构(例如,是否使用并非所有CPU都可用的功能)。 It does not allow the compiler to build code for a different architecture altogether. 它不允许编译器完全为不同的体系结构构建代码。

What you're looking for is a cross-compiler -- a copy of GCC which is compiled for x86 (or whatever), but compiles to PowerPC/ARM/MIPS/whatever code. 您正在寻找的是交叉编译器-GCC的副本,已针对x86(或其他版本)进行编译,但可以编译为PowerPC / ARM / MIPS /任何代码。 Building a cross-compiler is a complex process, but there are instructions available online. 构建交叉编译器是一个复杂的过程,但是可以在线获得说明。

You'll need to build (or install) a cross-compiler for that. 您需要为此构建(或安装)交叉编译器。 A given build of GCC only targets one CPU "family"; 给定的GCC版本仅针对一个CPU“系列”; for instance a GCC compiler that targets x86 and x86_64 can be built. 例如,可以构建针对x86和x86_64的GCC编译器。 But you can't (as far as I know) build a GCC compiler that targets both x86 and PPC. 但是(据我所知)您不能构建针对x86和PPC的GCC编译器。

You can run a compiler that outputs PPC assembly on x86 though - that's called a cross-compiler. 可以运行在x86上输出PPC程序集的编译器-称为交叉编译器。 Look for them in your distribution's package repositories, or use tools like crossdev to make yourself one. 在发行版的软件包存储库中查找它们,或者使用诸如crossdev之类的工具使自己成为一个。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM