easybuild-easyblocks
easybuild-easyblocks copied to clipboard
GCC not built with PIC - static linking fails
Today one of our developers wanted/needed to statically link to libgfortran. Though that fails. Reason is that GCC is not configured with --with-pic. I can of course add "configopts = '--with-pic'" to all GCC-.eb and GCCcore-.eb files, or better to the gcc easyblock. May I suggest to add --with-pic to gcc.py by default?
Example to test if it is working:
gfortran -c -fPIC test.f90
gfortran -static-libgfortran -shared -o libtest.so test.o
>>>>>>>>>>>> CODE for test.f90 <<<<<<<<<<
subroutine subber
print*,'hi'
end
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
@DirkdeDraak: please share the exact error messages you were running into?
I remember running into similar problems a while ago, and building GCC with PIC enabled sounds easier than it is...
See also https://github.com/JuliaLang/julia/issues/326, where they conclude fully statically linking to libgfortran doesn't work (although that may not be what you're after).
Just to make this issue a bit easier to find: when statically linking -lgfortran, you'll hit an error like:
/software/binutils/2.31.1/bin/ld.gold: error: /software/GCCcore/8.2.0/lib/gcc/x86_64-pc-linux-gnu/8.2.0/../../../../lib64/libgfortran.a(fpu.o): requires unsupported dynamic reloc 11; recompile with -fPIC