Closed neekumar1 closed 4 years ago
Could you run make VERBOSE=1
so I can see the link flags?
I don't why it's making PIE.
Please find the attached log file with make VERBOSE=1. buildlog.NCEPLIBS.Thu_Jul_16_222542_IST_2020.txt
I think it's because -fPIC
is being added here. I don't know where that or -mcmodel=medium
flags are coming from.
/usr/bin/gfortran -fPIC -mcmodel=medium -g -O3 CMakeFiles/tocgrib2.dir/tocgrib2.f.o -o tocgrib2 -L/usr/lib -Wl,-rpath,/home/amd/neeraj/ufs_new/v1.0.0/install/NCEPLIBS-external/lib: ../../../NCEPLIBS-g2/libg2_v3.2.0_4.a ../../../NCEPLIBS-w3nco/libw3nco_v2.1.0_4.a ../../../NCEPLIBS-bacio/libbacio_v2.2.0_4.a /home/amd/neeraj/ufs_new/v1.0.0/install/NCEPLIBS-external/lib/libpng.so /home/amd/neeraj/ufs_new/v1.0.0/install/NCEPLIBS-external/lib/libz.so /home/amd/neeraj/ufs_new/v1.0.0/install/NCEPLIBS-external/lib/libjasper.so /home/amd/neeraj/ufs_new/v1.0.0/install/NCEPLIBS-external/lib/libjpeg.so /home/amd/neeraj/ufs_new/v1.0.0/install/NCEPLIBS-external/lib/libz.so /home/amd/neeraj/ufs_new/v1.0.0/install/NCEPLIBS-external/lib/libjasper.so /home/amd/neeraj/ufs_new/v1.0.0/install/NCEPLIBS-external/lib/libjpeg.so -lomp -lpthread
/usr/bin/ld: ../../../NCEPLIBS-w3nco/libw3nco_v2.1.0_4.a(summary.c.o): relocation R_X86_64_32 against `.rodata.str1.1' can not be used when making a PIE object; recompile with -fPIC
/usr/bin/ld: final link failed: Nonrepresentable section on output
I was able to reproduce your issue on a Linux machine I have, and I think I know what's going on.
Ubuntu compiles position independent executables by default and that doesn't mix with the way we use static and shared libraries since we don't compile with -fPIC
. Or something along those lines.
The way I fixed it was to add set(CMAKE_EXE_LINKER_FLAGS -no-pie)
in the top-level NCEPLIBS CMakeLists.txt. That will pass the -no-pie
option to the linker and everything will build.
I also tried adding set(CMAKE_POSITION_INDEPENDENT_CODE ON)
which will compile NCEPLIBS with -fPIC
so you don't have to disable PIE. It gets farther, but then it fails linking chgres_cube
in UFS_UTILS because wgrib2's internal libraries aren't compiled with -fPIC
.
I'm not sure if this is a permanent fix, but it should resolve your issue. Thoughts @climbfuji?
Thank you @kgerheiser for providing the suggestion. It worked for now. Is this error got anything to do with Clang ? I tried NCEPLIBS-external with combination of Clang and Flang but could not verify as the build failed with following error message: " checking for Fortran 90 integer kind for 8-byte integers... unavailable checking for Fortran 90 integer kind for 4-byte integers... unavailable configure: error: Unable to determine Fortran 90 KIND values for either address-sized integers or offset-sized integers. CMakeFiles/mpi.dir/build.make:106: recipe for target 'mpich/src/mpi-stamp/mpi-configure' failed make[2]: [mpich/src/mpi-stamp/mpi-configure] Error 1 CMakeFiles/Makefile2:338: recipe for target 'CMakeFiles/mpi.dir/all' failed make[1]: [CMakeFiles/mpi.dir/all] Error 2 Makefile:83: recipe for target 'all' failed make: *** [all] Error 2 " Any suggestions please ?
Thank you @kgerheiser for providing the suggestion. It worked for now. Is this error got anything to do with Clang ? I tried NCEPLIBS-external with combination of Clang and Flang but could not verify as the build failed with following error message: " checking for Fortran 90 integer kind for 8-byte integers... unavailable checking for Fortran 90 integer kind for 4-byte integers... unavailable configure: error: Unable to determine Fortran 90 KIND values for either address-sized integers or offset-sized integers. CMakeFiles/mpi.dir/build.make:106: recipe for target 'mpich/src/mpi-stamp/mpi-configure' failed make[2]: [mpich/src/mpi-stamp/mpi-configure] Error 1 CMakeFiles/Makefile2:338: recipe for target 'CMakeFiles/mpi.dir/all' failed make[1]: [CMakeFiles/mpi.dir/all] Error 2 Makefile:83: recipe for target 'all' failed make: *** [all] Error 2 " Any suggestions please ?
We have never tried flang and we don't support it - only gcc+gfortran and clang+gfortran.
@neekumar1
Is there still an issue with clang
+ gfortran
as the issue topic mentions? If so, please indicate the versions you are using and the platform.
As @climbfuji mentions, we have not tested with flang
and don't support it at the moment.
Hello @aerorahul and @climbfuji, the issue with clang+gfortran for NCEPLIBS is resolved now. Thanks for the support.
Hello All, I was trying to build NCEPLIBS with clang and gfortran on Linux Ubuntu 18.04
. NCEPLIBS-external got built successfully. But I am facing following errors while building NCEPLIBS. " [ 59%] Linking Fortran executable nhour /usr/bin/ld: ../../../NCEPLIBS-w3nco/libw3nco_v2.1.0_8.a(summary.c.o): relocation R_X86_64_32 against `.rodata.str1.1' can not be used when making a PIE o bject; recompile with -fPIC /usr/bin/ld: final link failed: Nonrepresentable section on output [ 59%] Linking Fortran executable mdate collect2: error: ld returned 1 exit status NCEPLIBS-grib_util/sorc/grib2grib.fd/CMakeFiles/grib2grib.dir/build.make:100: recipe for target 'NCEPLIBS-grib_util/sorc/grib2grib.fd/grib2grib' failed make[2]: [NCEPLIBS-grib_util/sorc/grib2grib.fd/grib2grib] Error 1 CMakeFiles/Makefile2:2253: recipe for target 'NCEPLIBS-grib_util/sorc/grib2grib.fd/CMakeFiles/grib2grib.dir/all' failed make[1]: [NCEPLIBS-grib_util/sorc/grib2grib.fd/CMakeFiles/grib2grib.dir/all] Error 2 " And then process ends with following error: “ [ 62%] Linking Fortran static library libcrtm_v2.3.0.a 9625 [ 62%] Built target crtm 9626 Makefile:129: recipe for target 'all' failed 9627 make: *** [all] Error 2 “
I am building public release v1 branch: git clone -b ufs-v1.0.0 --recursive https://github.com/NOAA-EMC/NCEPLIBS I have shared the log file. Please check and suggest.