LBEM-CH / focus

High Throughput Electron Microscopy Image Processing Software
http://www.focus-em.org
GNU General Public License v2.0
35 stars 14 forks source link

relocation truncation error when linking 2dx_fftrans.exe #229

Open andrew-niaid opened 5 years ago

andrew-niaid commented 5 years ago

I get the following error when building focus on Linux (CentOS 7.5).

[ 52%] Linking Fortran executable 2dx_fftrans.exe
CMakeFiles/2dx_fftrans.dir/2dx_fftrans.for.o: In function `MAIN__':
2dx_fftrans.for:(.text+0x10c): relocation truncated to fit: R_X86_64_PC32 against symbol `__BLNK__' defined in COMMON section in CMakeFiles/2dx_fftrans.dir/2dx_fftrans.for.o
2dx_fftrans.for:(.text+0x112): relocation truncated to fit: R_X86_64_PC32 against symbol `__BLNK__' defined in COMMON section in CMakeFiles/2dx_fftrans.dir/2dx_fftrans.for.o
2dx_fftrans.for:(.text+0x1b6): relocation truncated to fit: R_X86_64_PC32 against symbol `__BLNK__' defined in COMMON section in CMakeFiles/2dx_fftrans.dir/2dx_fftrans.for.o
2dx_fftrans.for:(.text+0x1bc): relocation truncated to fit: R_X86_64_PC32 against symbol `__BLNK__' defined in COMMON section in CMakeFiles/2dx_fftrans.dir/2dx_fftrans.for.o
2dx_fftrans.for:(.text+0x1cd): relocation truncated to fit: R_X86_64_PC32 against symbol `__BLNK__' defined in COMMON section in CMakeFiles/2dx_fftrans.dir/2dx_fftrans.for.o
2dx_fftrans.for:(.text+0x3e0): relocation truncated to fit: R_X86_64_32S against symbol `__BLNK__' defined in COMMON section in CMakeFiles/2dx_fftrans.dir/2dx_fftrans.for.o
2dx_fftrans.for:(.text+0x42d): relocation truncated to fit: R_X86_64_PC32 against symbol `__BLNK__' defined in COMMON section in CMakeFiles/2dx_fftrans.dir/2dx_fftrans.for.o
2dx_fftrans.for:(.text+0x54d): relocation truncated to fit: R_X86_64_PC32 against symbol `__BLNK__' defined in COMMON section in CMakeFiles/2dx_fftrans.dir/2dx_fftrans.for.o
2dx_fftrans.for:(.text+0x6a1): relocation truncated to fit: R_X86_64_PC32 against symbol `__BLNK__' defined in COMMON section in CMakeFiles/2dx_fftrans.dir/2dx_fftrans.for.o
2dx_fftrans.for:(.text+0x742): relocation truncated to fit: R_X86_64_PC32 against symbol `__BLNK__' defined in COMMON section in CMakeFiles/2dx_fftrans.dir/2dx_fftrans.for.o
2dx_fftrans.for:(.text+0x774): additional relocation overflows omitted from the output
collect2: error: ld returned 1 exit status
kernel/mrc/source/CMakeFiles/2dx_fftrans.dir/build.make:94: recipe for target 'kernel/mrc/source/2dx_fftrans.exe' failed
make[2]: *** [kernel/mrc/source/2dx_fftrans.exe] Error 1
CMakeFiles/Makefile2:4932: recipe for target 'kernel/mrc/source/CMakeFiles/2dx_fftrans.dir/all' failed
make[1]: *** [kernel/mrc/source/CMakeFiles/2dx_fftrans.dir/all] Error 2
Makefile:151: recipe for target 'all' failed
make: *** [all] Error 2
Build failed for Focus

I'm linking against fftw 3.3.3 provided with the distro (not sure if it's relevant here).

I've tried gcc/gfortran versions 4.8.5 and 6.3.1 and get the same result.

sthennin commented 5 years ago

That error means that a 32-bit compiler was asked to allocate memory larger than the 32-bit addressing can reach. I now reduced the block dimensions in 2dx_fftrans.for. Please try again if this works now better. Thanks.

andrew-niaid commented 5 years ago

Interesting. Since I don't have a 32bit compiler anywhere on the system, I did some more digging. It appears we are bumping into a memory model issue. The default gcc/gfortran option of -mcmodel=small is generating this error.

https://stackoverflow.com/a/12917191

I was able to fix the error (with the original larger block dimensions in 2dx_fftrans.for) by adding this option to the cmake in build_all:

-DCMAKE_Fortran_FLAGS=-mcmodel=medium

I can also confirm that the reduced block dimensions also compile correctly now without this option.

Thanks.