Ada program uses word size 64 bit even when gnatmake is passed -m32 flag
Issue
The following information has been provided by Red Hat, but is outside the scope of the posted Service Level Agreements and support procedures. The information is provided as-is and any configuration settings or installed applications made from the information in this article could make the Operating System unsupported by Red Hat Global Support Services. The intent of this article is to provide information to accomplish the system's needs. Use of the information in this article at the user's own risk.
Issue
- The ADA system files that are part of the gcc-gnat package on a 64 bit system hard code word size (the size of an address or a pointer) as 64 bits. It does this even if you pass gnatmake the “-m32” flag.
Environment
- Red Hat Enterprise Linux 5
- gcc-gnat
- libgnat
Resolution
One may work around this issue by copying over the directory /usr/lib/gcc/i386-redhat-linux/4.1.2 from an i386 system to the system and use the --RTS=<path> flag for gnatmake to build. This is not a supported solution, but only a suggested workaround.
The issue is fixed in RHEL-6 gcc-gnat with a complete package restructure. The adainclude and adalib contents have been put in a separate libgnat-devel package
Root Cause
- The -m32 option forces the compiler and linker to produce 32 bit object files and executable. However, it appears that since the ADA system file (/usr/lib/gcc/x86_64/redhat-linux/4.1.2/adainclude/system.ads) says that the Word_Size is “64” and Memory_Size is “2**64”, the 32 bit output fails on a system fwrite call
- The fwrite system call expects pointers as 32 bit since it is a 32 bit application, but they are being passed as 64 bit values
Subscriber exclusive content
A Red Hat subscription provides unlimited access to our knowledgebase of over 48,000 articles and solutions.
Welcome! Check out the Getting Started with Red Hat page for quick tours and guides for common tasks.
