pgf77, mcmodel=medium and static binaries under linux

I’m trying to statically link a fortran program built with mcmodel=medium, and I get errors like this:

/nfs/programs/source/compilers/pgi/linux86-64/7.0-2/libso/libpgc.a(stkchk.o)(.text+0x1e7): In function `__setchk':
: relocation truncated to fit: R_X86_64_PC32 .bss
/nfs/programs/source/compilers/pgi/linux86-64/7.0-2/libso/libpgc.a(stkchk.o)(.text+0x21b): In function `__setchk':
: relocation truncated to fit: R_X86_64_PC32 .bss

Per the docs, I have added mcmodel=medium to the linker flags, but that doesn’t seem to help. This post seems to indicate that statically linked binaries using mcmodel=medium are not possible under Linux, but that documentation seems to say otherwise.

Am I barking up the wrong tree? Can I actually build static binaries using mcmodel=medium under linux?

Hi,

-mcmodel=medium says that we use our libraries in libso but the static link says to use archives in libso. Unfortunately, we built our libraries(archives and shared) in libso with -fpic, which is ‘small’. You can try to remove libpgc.a in libso and see if that is sufficient. But then it will link to libso/libpgc.so. I am not sure if that’s what you want.

Also you may need to copy libpgc.so to the machine that you want to run if PGI compilers are not installed.

Thanks for your comment, we will document it appropriately.

Hongyon