简体   繁体   中英

Can I use gcc -march to compile into other ISA

My own computer has an 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.

Can I compile C code into assembly using other microarchitecture's ISA?

No. -march only affects what subarchitecture the compiler will target (eg, whether it will use features which are not available on all CPUs). 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. 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"; for instance a GCC compiler that targets x86 and x86_64 can be built. But you can't (as far as I know) build a GCC compiler that targets both x86 and PPC.

You can run a compiler that outputs PPC assembly on x86 though - that's called a cross-compiler. Look for them in your distribution's package repositories, or use tools like crossdev to make yourself one.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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