I'm trying to compile a large scale FORTRAN application and need to link the HDF5 library to it. The program needs to be compiled with gfortran and needs the -mcmodel=large options. When using only -mcmodel=medium I'm getting error messages like:
:(.text+0x3019): relocation truncated to fit: R_X86_64_32 against `.lrodata'
I'm compiling the HDF5 library using configure:
./configure --enable-static-exec --enable-fortran FCFLAGS="-mcmodel=large" CFLAGS="-mcmodel=large"
make -j
make install
When compiling the FORTRAN program, I'm getting:
H5_ff.f90:(.text+0x23): relocation truncated to fit: R_X86_64_PC32 against symbol `predefined_types_' defined in COMMON section in /tmp/ccHO0WzS.o
H5_ff.f90:(.text+0x3c): relocation truncated to fit: R_X86_64_PC32 against symbol `predefined_types_' defined in COMMON section in /tmp/ccHO0WzS.o
H5_ff.f90:(.text+0x52): relocation truncated to fit: R_X86_64_PC32 against symbol `predefined_types_' defined in COMMON section in /tmp/ccHO0WzS.o
H5_ff.f90:(.text+0x68): relocation truncated to fit: R_X86_64_PC32 against symbol `predefined_types_' defined in COMMON section in /tmp/ccHO0WzS.o
H5_ff.f90:(.text+0x89): relocation truncated to fit: R_X86_64_PC32 against symbol `predefined_types_' defined in COMMON section in /tmp/ccHO0WzS.o
H5_ff.f90:(.text+0x9f): relocation truncated to fit: R_X86_64_PC32 against symbol `predefined_types_' defined in COMMON section in /tmp/ccHO0WzS.o
H5_ff.f90:(.text+0xb5): relocation truncated to fit: R_X86_64_PC32 against symbol `predefined_types_' defined in COMMON section in /tmp/ccHO0WzS.o
I'm on linux and am using gfortran version: 4.7.2.
Compiling with -mcmodel=medium works, but only if I reduce the size of variables in the FORTRAN program. So, what can I do to compile a FORTRAN program with gfortran and the HDF5 libraries when using -mcmodel=large?
I can not show the real program here, but to get the idea, here is a fortran program which reproduces the error:
PROGRAM test
IMPLICIT NONE
DOUBLE PRECISION tst(1000,1000,1000,1),bf
COMMON /tt/ tst
bf = tst(1,1,1,1)
print *,'Hello World.'
call kk
END PROGRAM
SUBROUTINE kk
USE H5LT
USE HDF5
IMPLICIT NONE
INTEGER(KIND=4)::errcode
call h5open_f(errcode)
print *,"Hello Subroutine."
END SUBROUTINE
Compiling it with:
gfortran -o tst -mcmodel=large tst.f90 -I./hdf5/hdf5/include -L./hdf5/hdf5/lib ./hdf5/hdf5/lib/libhdf5hl_fortran.a ./hdf5/hdf5/lib/libhdf5_hl.a ./hdf5/hdf5/lib/libhdf5_fortran.a ./hdf5/hdf5/lib/libhdf5.a -lz -lrt -ldl -lm -Wl,-rpath -Wl,./hdf5/hdf5/lib
and assuming the HDF5 library in ./hdf5/hdf5. However, this program would compile and run with -mcmodel=medium, but my real program does not. I wasn't able to come up with a simple program which would not compile with -mcmodel=medium, but with -mcmodel=large. I'm not even sure why -mcmodel=medium is not working for the real program.
The HDF5 library is available here: http://www.hdfgroup.org/HDF5/release/obtain5.html