Toolchain compatiblity: mixing gcc, ld and library versions?

Jonathan Wakely jwakely.gcc@gmail.com
Fri May 6 15:29:00 GMT 2011


On 6 May 2011 13:58, Steffen Dettmer wrote:
> Hi,
>
> I have hopefully simple questions that I couldn't answer myself
> using FAQs or google:
>
> is it in general allowed to mix old and new versions of toolchain tools?

Yes, in general.

> Is it needed to rebuilt binary libraries (libmy.a) when upgrading
> toolchain version (starting from gcc 3.4.3)?

What do yiou mean "toolchain version" ?
There is no single version of the GNU toolchain, it consists of
multiple independent pieces.

> For example, using arm-elf-gcc-3.4.3 and ld-2.21 or vice versa?

It's usually ok to use a newer ld with an older gcc, and vice versa,
if that's what you mean.

> (I made a quick check and it seems .code and .ro_data in my ELF
> are bitwise equal, so I think there is no problem doing this, right)?
>
> Is it allowed to link libraries compiled with different compiler versions?
> For example, liba.a compiled with arm-elf-gcc-3.4.3 and libb.a with
> 4.3.x or 4.6.x?

Yes, it's allowed.

> If linking works, can I assume that the result will be valid
> - or -
> could it happen that the code links, passes first simple tests
> but later fails under rare circumstances?
>
> Does it make a difference when not only considering C code but
> also considering C++ code?

Yes, a huge difference.
The C++ ABI was not stable prior to G++ 3.4, but for all versions from
3.4 and later the same ABI is used.

The runtime library, libstdc++, has huge changes since GCC 3.4, so if
you are mixing compiler versions then you should always link with the
newest compiler, so that the newest libstdc++ is used.  That should
work for shared libraries, I'm not sure how well it works with static
libs.



More information about the Gcc-help mailing list