Build 32 bit Ada Library with GCC 4.1.2

EXT-Pennington, Dale K dale.k.pennington@boeing.com
Wed Mar 25 13:55:00 GMT 2009


Folks,

As before, I am trying to port onto a system running Red Hat Linux
(kernel 2.6), where the compiler is gcc 4.1.2.

Our old system, which we are still building on, is an IBM AIX 6.1, using
the IBM xlC compilers for the most part.

Our code is written in C, and is compiled as 32 bit applications.

One of the subcontractors on this project provides us with a library
that is written in Ada. They provide it to us pre-compiled (apparently
using gnat 5.03, which is based on GCC 3.4.4), along with the GCC 3.4.4
libraries in a static form, which we link in and it all works fine. They
are provided as 32 bit libraries. Part of their distribution are the Ada
files they run through GNAT to produce the library.

At this time, they do not provide a pre-compiled library for Linux, so
we are attempting to build the ada files into a library to use. We would
prefer to keep our apps at 32 bit. Mainly this is because the project is
both large and old, and we are not certain if upgrading to 64-bit might
cause new and fun bugs to tracks down.

However the Ada files do not want to build as 32 bit under gcc 4.1.2
(using -m32 switch with gnatmake). The issue turn out to be in the Ada
runtime library. Basically, in s-taskin.ads, lines 770-771 we have :

type Direct_Attribute_Element is mod Memory_Size;
Pragma Atomic (Direct_Attribute_Element);

And Memory_Size is defined in system.ads, line 71 as 

Memory_Size : constant := 2**64;

Needless to say, you cannot guarantee atomic access to a 64 bit value
when compiling as 32 bit. I did check the 3.4.4 based gnat 5.03, and it
defined Memory_Size as 2**32, hence why 32 bit works.

So now, how do we handle this ? 

Firstly, is there a way to get GNAT to behave when making 32 bit apps ?
I checked for any flags that might say, be good 32-bit, but I suspect
that this would need some form of conditional compile in the ada runtime
library, and I see nothing that fits. But if anyone has insight, it
would be welcome.

Second would be to load gcc 3.4.4 just for compiling this library and
trying to link it into the gcc 4.1.2 main code. Personally, I am leery
of trying to mix objects and libraries from 2 versions of GCC. But if
this can actually be safely done, I need to know so I can list it as an
option.

Lastly, would be to compile the project in question as 64 bit so we can
use the 4.1.2 version of gnat to make the library as well. Listed last
due to reasons above.

Thanks, for taking the time to consider this one, and hopefully my next
couple of questions will not be as thorny.

Dale Pennington



More information about the Gcc-help mailing list