Hello,
Compiling some apps with the HPC(20.9) compilers has resulted in several error messages of the type relocation R_AARCH64_ADR_PREL_PG_HI21
. This happens when trying to build a shared library with autotools. An example is netcdf-fortran (GitHub - Unidata/netcdf-fortran: Official GitHub repository for netCDF-Fortran libraries, which depend on the netCDF C library. Install the netCDF C library first. ) that results in the error:
libtool: compile: /opt/openmpi/bin/mpif90 -I. -g -c nf_fortv2.f90 -o nf_fortv2.o >/dev/null 2>&1
/bin/bash ../libtool --tag=FC --mode=link /opt/openmpi/bin/mpif90 -I. -g -version-info 7:0:0 -L/opt/openmpi/lib -L/opt/hdf5/lib -L/opt/netcdf/lib -lcurl -o libnetcdff.la -rpath /opt/netcdf/lib nf_attio.lo nf_control.lo nf_dim.lo nf_misc.lo nf_genatt.lo nf_geninq.lo nf_genvar.lo nf_vario.lo nf_var1io.lo nf_varaio.lo nf_varmio.lo nf_varsio.lo nf_logging.lo nf_nc.lo nf_v2compat.lo nf_fortv2.lo nf_lib.lo nf_nc4.lo libtypeSizes.la libnetcdf_nc_data.la libnetcdf_nf_data.la libnetcdf_nc_interfaces.la libnetcdf_nf_interfaces.la libnetcdfm.la libnetcdf_f03.la libnetcdf_fortv2_c_interfaces.la libnetcdf4_nc_interfaces.la libnetcdf4_nf_interfaces.la libnetcdf4_f03.la -lnetcdf -lm
libtool: link: /opt/openmpi/bin/mpif90 -shared .libs/nf_attio.o .libs/nf_control.o .libs/nf_dim.o .libs/nf_misc.o .libs/nf_genatt.o .libs/nf_geninq.o .libs/nf_genvar.o .libs/nf_vario.o .libs/nf_var1io.o .libs/nf_varaio.o .libs/nf_varmio.o .libs/nf_varsio.o .libs/nf_logging.o .libs/nf_nc.o .libs/nf_v2compat.o .libs/nf_fortv2.o .libs/nf_lib.o .libs/nf_nc4.o --whole-archive ./.libs/libtypeSizes.a ./.libs/libnetcdf_nc_data.a ./.libs/libnetcdf_nf_data.a ./.libs/libnetcdf_nc_interfaces.a ./.libs/libnetcdf_nf_interfaces.a ./.libs/libnetcdfm.a ./.libs/libnetcdf_f03.a ./.libs/libnetcdf_fortv2_c_interfaces.a ./.libs/libnetcdf4_nc_interfaces.a ./.libs/libnetcdf4_nf_interfaces.a ./.libs/libnetcdf4_f03.a --no-whole-archive -L/opt/openmpi/lib -L/opt/hdf5/lib -L/opt/netcdf/lib -lcurl /opt/hdf5/lib/libhdf5_hl.so /opt/hdf5/lib/libhdf5.so -ldl -lz /opt/netcdf/lib/libnetcdf.so -lm -g -soname libnetcdff.so.7 -o .libs/libnetcdff.so.7.0.0
/usr/bin/ld: .libs/nf_dim.o: relocation R_AARCH64_ADR_PREL_PG_HI21 against symbol `pgf90_ptr_alloc04a_i8' which may bind externally can not be used when making a shared object; recompile with -fPIC
/usr/bin/ld: .libs/nf_dim.o(.text+0x28): unresolvable R_AARCH64_ADR_PREL_PG_HI21 relocation against symbol `pgf90_ptr_alloc04a_i8'
/usr/bin/ld: final link failed: bad value
make[2]: *** [Makefile:734: libnetcdff.la] Error 2
make[2]: Leaving directory '/home/ubuntu/netcdf-fortran/fortran'
make[1]: *** [Makefile:626: all] Error 2
make[1]: Leaving directory '/home/ubuntu/netcdf-fortran/fortran'
make: *** [Makefile:581: all-recursive] Error 1
The -fPIC flag is on (for compilers & pre-compiler) so I’m not sure why it keeps asking for it. Thanks.