5

Initial note: The question mentions AIX because it is the initial context but the question really pertains to gcc itself, most probably regardless of the platform.

AIX is supposed to be backwards binary compatible: a C program compiled on AIX 5.1 will run as is on 5.2, 5.3, 6.1 and 7.1.

In my understanding gcc should be built to target a specific system (whether the current one or another one in the case of cross-compiling). So, gcc built on AIX 6.1 targets AIX 6.1, and produces binaries usable on both 6.1 and 7.1 thanks to binary compatibility.

Yet gcc itself built on AIX 6.1 is a 6.1 program, so it should execute on 7.1 as is. Of course if I compile a program with it on 7.1, this program might get linked or use headers specific to 7.1, thus making the resulting binary requiring 7.1. So as far as I understand it, I should be able to run gcc built on AIX 6.1 onto a 7.1 machine, and produce maybe non-optimal yet perfectly valid binaries, although they would require 7.1 as a side effect of linking.

This looks too much like rainbows and unicorns dancing in glittery skies. I smell something fishy but lack any knowledge of gcc innards. Please mighty crowd, enlighten me.

tl;dr: Can gcc built on and targeting a version N of an OS/platform be run and used on version N+1 by virtue of platform binary compatibility to produce binaries running on version N+1? If not, what mechanism would prevent it?

Jens
  • 69,818
  • 15
  • 125
  • 179
Lloeki
  • 6,573
  • 2
  • 33
  • 32
  • Original context: perzl.org/aix is a wonderful endeavor which provides up-to-date RPM packages for AIX. It notably provides very useful GCC packages, one for each AIX version. Unfortunately, there is no GCC for AIX 7.1. I'd consider myself lucky to be able to use gcc for AIX 6.1. – Lloeki Jan 31 '11 at 14:16
  • The question should be more specific in OS. AIX may be harder, and Linux/BSD OSes are more compatible with older/newer versions. Also, answer will depend heavily on libc. – osgx Sep 03 '11 at 15:26

1 Answers1

2

Here's enlightenment: your question is way too general. In order to answer it, someone would have to have knowledge of

  • the operating systems you care about
  • the OS versions you care about
  • the gcc versions you care about

and then research the binary compatibility in this three dimensional matrix.

Mechanisms preventing binary compatibility are too numerous and directly correlate to your OS and compiler vendor's ingenuity at breaking it. One of the more common and documented ways being official deprecation of API calls, removal of compatibility libraries shipped, and bridges being burnt, like going from a.out to ELF.

Jens
  • 69,818
  • 15
  • 125
  • 179