为 SPARC、IBM Power CPU 开发应用程序是否需要除 x86、x86-64 目标之外的单独编译器?
是否为 SPARC 开发应用程序,IBM PowerPC 需要除 x86 和 x86-64 目标之外的单独编译器吗?
如果属实,那么将 Linux 中的 x86、x64 二进制文件移植到 SPARC 和 PowerPC 有多容易?有没有办法使用虚拟化来模拟这些环境?
Does developing applications for SPARC, IBM PowerPC require separate compliers, other than x86 and x86-64 targets?
If true, how easily could x86, x64 binaries in Linux be ported to SPARC and PowerPC? Is there a way to simulate these environments using virtualization?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
第一个答案是,是的,要开发 Power Architecture 或 SPARC 的编译代码,您需要编译器来为这些处理器生成代码。生成 x86 或 x86_64 代码的编译器不会生成在 Power Architecture 或 SPARC 上运行的代码。不过,您可能会发现在 x86(32 或 64)上运行的交叉编译器将生成 Power 或 SPARC 代码。但另一件事需要注意的是目标文件格式(elf、xcoff 等)。指令集只是图片的一部分。如果您提供有关您的特定起点和目标的更多详细信息,您可能会得到更清晰的答案。
其次,人们通常不会谈论移植二进制文件。我们移植源代码,其中可能包括汇编语言以及 C 或其他语言。执行此操作的过程包括编译器选择,之后您可以开始编译、移植、编译和链接新硬件代码的迭代过程。我省略了很多细节。同样,如果您在问题中提供更多细节,您可能会得到更具体的答案。
第三,正如其他人所说,不,您不能在您提到的场景中使用虚拟化。您可能会找到可接受的仿真解决方案。再次,如果可以的话,请提供更多细节。
First answer is, yes, to develop compiled code for Power Architecture or SPARC you need compilers that will generate code for those processors. A compiler that generates x86 or x86_64 code will not generate code that runs on Power Architecture or SPARC. You might find cross compilers running on x86 (32 or 64) that will generate Power or SPARC code, though. But the other thing to be aware of is the object file format (elf, xcoff, and so on). Instruction set is just part of the picture. You might get clearer answers if your provide more details of your particular starting point and goals.
Second, one normally doesn't talk of porting binaries. We port source code, which may include assembly language as well as C or other languages. The process for doing this includes compiler selection, after which you can begin an iterative process of compiling, porting, compiling, and linking the code for the new hardware. I'm omitting many details. Again, if you provide more specifics in your question, you might get more specific answers.
Third, as others have said, no, you can't use virtualization in the scenarios you allude to. You might find acceptable emulation solutions. Again, please provide more specifics if you can.
不,虚拟化不是答案。虚拟化采用您的硬件平台并创建相同硬件的独立“虚拟”机器。因此,当在 x86 上运行时,您可以使用虚拟化来创建第二台 x86 计算机。
要模拟完全不同的硬件架构,您需要查看模拟。
将软件从一种架构移植到另一种架构的难易程度完全取决于软件的编写方式。如果它使用一种体系结构特有的东西而不是另一种体系结构(例如,x86 可以处理非对齐内存访问,而 SPARC 则不能),那么您将需要修复类似的问题。另一个可能导致移植困难的例子是,如果软件假设了硬件的特定字节序。
No, virtualization is not the answer. Virtualization takes your hardware platform and creates an independent "virtual" machine of the same hardware. So when running on x86, you use virtualization to create a second x86 machine.
To simulate a completely different hardware architecture, you would want to look into emulation.
How easy / hard it is to port software from one architecture to another architecture depends completely on how the software was written. If it uses something particular to one architecture but not the other (for example, x86 can handle non-aligned memory accesses while SPARC does not) you are going to need to fix things like that. Another example that could make it difficult to port would be if the software has assumed a specific endian-ess of the hardware.
我不想太尖刻,但鉴于 IBM PowerPC 和 SPARC 不支持 x86 或 x86-64 命令集(即完全独立的机器语言),您从哪里得知它们会兼容?
可能是的,但它会非常慢,因为您必须翻译机器代码,或者 - 好吧 - 解释它。由于 CPU 架构不同,硬件虚拟化将不起作用。 SPARC和PowerPC不仅仅是“同一事物的不同标签”,它们的内部确实不同。
I hate to be really snippy, but given that IBM PowerPC and SPARC do not support the x86 or x86-64 command sets (i.e. talk totally separate machine langauge), where did you even get the idea they would be compatible?
Possibly yes, but it would be REALLY slow, because you would have to either translate the machine code, or - well - interpret it. Hardware virtualiaztion would not work, given that the CPU architectures are different. SPARC and PowerPC are not just "different labels for the same thing", they are really different internally.
使用 Java 或 LLVM,或尝试 QEMU 来测试其他 CPU。
如果您的代码是为了可移植而编写的,那么这很容易,但如果不是可移植的,那就很困难了。每个平台的数据类型和依赖于它的代码的大小不同、内联汇编等将使事情变得更加困难。
LLVM 和 QEMU 主页:
Use Java or LLVM, or try QEMU to test other CPUs.
It's easy if your code was written to be portable, it's not if it wasn't. Varying sizes of data types per platform and code that depends on it, inline assembly, etc. will make it harder.
Home page for LLVM and QEMU: