64 bit errors: trouble linking libpgf90 with mcmodel=medium

I am having trouble compiling some code that uses large address space for an Opteron cluster. I am using -tp k8-64 -mcmodel=medium and with or without -Mlarge_arrays I get errors from the linker that look like the section below. Does anybody have an idea of what is going wrong here?

/usr/local/pgi/linux86-64/6.0/lib/libpgf90.a(initpar.o)(.text+0x2): In function __hpf_myprocnum': initpar.c: relocation truncated to fit: R_X86_64_PC32 against symbol __hpf_lcpu’ defined in COMMON section in /usr/local/pgi/linux86-64/6.0/lib/libpgf90.a(initpar.o)
/usr/local/pgi/linux86-64/6.0/lib/libpgf90.a(initpar.o)(.text+0x9): In function __hpf_ncpus': initpar.c: relocation truncated to fit: R_X86_64_PC32 against symbol __hpf_tcpus’ defined in COMMON section in /usr/local/pgi/linux86-64/6.0/lib/libpgf90.a(initpar.o)
/usr/local/pgi/linux86-64/6.0/lib/libpgf90.a(initpar.o)(.text+0x10): In function __hpf_getioproc': initpar.c: relocation truncated to fit: R_X86_64_PC32 against symbol __hpf_ioproc’ defined in COMMON section in /usr/local/pgi/linux86-64/6.0/lib/libpgf90.a(initpar.o)
/usr/local/pgi/linux86-64/6.0/lib/libpgf90.a(initpar.o)(.text+0x17): In function __hpf_is_ioproc': initpar.c: relocation truncated to fit: R_X86_64_PC32 against symbol __hpf_lcpu’ defined in COMMON section in /usr/local/pgi/linux86-64/6.0/lib/libpgf90.a(initpar.o)
/usr/local/pgi/linux86-64/6.0/lib/libpgf90.a(initpar.o)(.text+0x1d):initpar.c: relocation truncated to fit: R_X86_64_PC32 against symbol __hpf_ioproc' defined in COMMON section in /usr/local/pgi/linux86-64/6.0/lib/libpgf90.a(initpar.o) /usr/local/pgi/linux86-64/6.0/lib/libpgf90.a(initpar.o)(.text+0x41): In function __hpf_abort’:
initpar.c: relocation truncated to fit: R_X86_64_PC32 against symbol __hpf_lcpu' defined in COMMON section in /usr/local/pgi/linux86-64/6.0/lib/libpgf90.a(initpar.o) /usr/local/pgi/linux86-64/6.0/lib/libpgf90.a(initpar.o)(.text+0xa5): In function __hpf_abortp’:
initpar.c: relocation truncated to fit: R_X86_64_PC32 against symbol __hpf_lcpu' defined in COMMON section in /usr/local/pgi/linux86-64/6.0/lib/libpgf90.a(initpar.o) /usr/local/pgi/linux86-64/6.0/lib/libpgf90.a(initpar.o)(.text+0x5c0): In function __hpf_istat’:
initpar.c: relocation truncated to fit: R_X86_64_PC32 against symbol __hpf_quiet' defined in COMMON section in /usr/local/pgi/linux86-64/6.0/lib/libpgf90.a(initpar.o) /usr/local/pgi/linux86-64/6.0/lib/libpgf90.a(initpar.o)(.text+0x5e6):initpar.c: relocation truncated to fit: R_X86_64_PC32 against symbol __hpf_quiet’ defined in COMMON section in /usr/local/pgi/linux86-64/6.0/lib/libpgf90.a(initpar.o)
/usr/local/pgi/linux86-64/6.0/lib/libpgf90.a(initpar.o)(.text+0x60c):initpar.c: relocation truncated to fit: R_X86_64_PC32 against symbol `__hpf_quiet’ defined in COMMON section in /usr/local/pgi/linux86-64/6.0/lib/libpgf90.a(initpar.o)
/usr/local/pgi/linux86-64/6.0/lib/libpgf90.a(initpar.o)(.text+0x632):initpar.c: additional relocation overflows omitted from the output
gmake: *** [flash2] Error 2


Thanks,
Sebastian

Hi Sebastien,

You need to add “-mcmodel=medium” to the link line as well. Without it, the compiler will attempt to link with the small memory model libraries.

Hope this helps,
Mat

I have exactly the same problem, but adding -mcmodel=medium to the linking step (or to both the compilation and linking) does not help:
pgf90 -c -Mlist -O3 -byteswapio -Mr8 -I …/…/…/lib -I/include -c modele.f
pgf90 -Wl,-Bstatic -Mbounds -mcmodel=medium -o …/…/…/bin/opa modele.o …/…/…/lib/libsxopa.a …/…/…/lib/libsxioipsl.a -L/usr/local/netcdf/lib/ -lnetcdf
/usr/local/Cluster-Apps/pgi-5.2-4/linux86-64/5.2/lib/libpgf90.a(initpar.o)(.text+0x2): In function `__hpf_myprocnum’:
: relocation truncated to fit: R_X86_64_PC32 __hpf_lcpu

What else could cause this problem?

Hi Martin,

The problem in your case is the “-Wl,-Bstatic” flag. The static libraries that accompany the 5.2 compilers were compiled for the small memory model and can’t be used with the “-mcmodel=medium” flag. Linking dynamically, i.e remove “-Wl,-Bstatic”, will fix your issue.

Note that starting with the 6.0 compilers, two version of the runtime libraries are included. The small memory model versions are located in the “lib” directory while the medium memory model versions are located in the “libso” directory. In other words, with 6.0 and later versions of the compilers, linking “-mcmodel=medium” with static libraries is supported.

Hope this helps,
Mat