1

Let's say I've got a collection of source code written for second-generation sparc processors, and some of the C code is architecture-dependent. How can I compile this code for x86 and ARM processors? I initially thought it'd be easy to use GCC and cross compile, but that seems to be too simple. Am I at least on the right track? Thanks!

OrangeCalx01
  • 806
  • 2
  • 7
  • 21
  • 2
    Architecture-dependent code, by definition, will need _rewriting_ appropriately for different architectures. Depending on what it does, and how the architectures in question differ, that may or may not be simple. – Notlikethat Jan 29 '15 at 13:42
  • I think you need to give examples of *architecture-dependent*. This could be inline assembler, endian issues, or code generation and timing problems. There are different tools and techniques to solve each issue. – artless noise Jan 29 '15 at 15:12

1 Answers1

2

You can compile it by using compilers that target the required platforms, on whatever host you like. If you're cross-compiling or not doesn't matter.

What matter is that if the code contains non-portable things, you're going to have to fix those manually. No compiler can do that for you.

For instance, if you assume that the code is running on a big-endian architecture, you're going to have to find all such places and fix them (since x86 and, typically, ARM too are both little-endian). Have fun.

unwind
  • 391,730
  • 64
  • 469
  • 606