32-bit application on a 64-bit machine

Dear PGI developers,

I am trying to compile a 32-bit application on a 64-bit machine. For the fortran files I do not have any problem, but I do have problems for the C files (I have only two C files). The compilation runs OK when I do not use any “–m32” specification flags, i.e. “gcc –v –m32” or “pgcc –tp k8-32”; but as you might know, I get a “SEGMENTATION FAULT” error message when running the executables.

Then, I tried to incorporate “-m32” specification flags for either the gcc or the pgcc compilers. But at this point, the compilation stops with the following error message:

/usr/bin/ld: warning: i386 architecture of input file .//libzindo.a(xalloc.o)' is incompatible with i386:x86-64 output .//libzindo.a(matrix.o): In function matrix_‘:
matrix.o(.text+0x419): undefined reference to `xalloc_’
make: *** [zindo1] Error 2

My Makefile archive is very simple, but I just cannot make to work for my two C files.

Make file for maintaining INDO on the SUN

Macro Definitions

FC = pgf90
FFLAGS = -fast
FFLAGS2 = -fast
CC = pgcc -tp k8-32
CFLAGS = -fast
#CC = gcc -v -m32
#CFLAGS = -O3 -v -m32
LDFLAGS = -L./
PGM = zindo1
FLIB = zindo
MAINO = zindo.o

I am using a PGI 5.1 compiler on an AMD opteron processor. Any ideas or comments will be greatly appreciated.

Thanks,
Sigi

I am not developer of PGI.
But I have similar situation before & let it work after.
The following might be wrong, and any comments will be appreciated.

From your message, it seems you try to link a lib libzindo.a which probably compile with 64bit mode (I guess).

Compile with 64bit probably OK, but return error during execution.
I guess the code is written with 32bit standard(real*4) and cause such problem.
Add -r8 in compile option probably can solve segmentation fault.

Compile with 32 bit failed due to you try to link a 64bit lib (libzindo.a).
If you can compile that lib with 32bit mode, this probably can be solved, too.

Hope my coding experiences might help.

Dear Danishyo,

Thank you for your prompt replay. Actually, I ended up doing a “static compilation” in a 32-bit architecture. This static version is the one that I am using on the 64-bit machine.

pgf90 -Bstatic
pgcc -Bstatic

About the -r8 compiling option. I guess that this option is only for the pgf90 compiler and not for the pgcc. At least in the PGI 5.1 version there is not a -r8 option for pgcc.

Thank you for your help,
Sigi

Hi Sigi,

“-r8” is only available for Fortran since is sets the default kind of reals to 8 instead of 4. In C, the underlying data representation changes depending upon your architecture and OS, and can not be set by the user.

As for your 64-bit segmentation violation, I’m guessing that you may need to port your code, in particular the inter-language calling (C to Fortran, Fortran to C). C longs and pointers change data sizes when you move to 64-bits so if you’ve made any assumptions about data size, you may need to revisit these parts of your code. Chapters 10 and 11 of the PGI User’s Guide give more detailed information about porting to 64-bits and inter-language calling.

  • Mat