Project

General

Profile

Build failure with Nagfor/Clang

Added by Matt Thompson almost 4 years ago

All,

First, I'm on macOS Catalina using nagfor 7.0.7009, clang 11.0.3, Open MPI 4.0.2, and I'm building CDO 1.9.8.

I'm hoping someone smarter than I can help figure this out. I maintain a set of base libraries (Baselibs) for an earth system model, and CDO is one of the ones I build. I can build CDO with a good chunk of compiler combinations, but NAG Fortran/Clang on my MacBook stumps me. When I try to build CDO it fails at the link:

libtool: link: mpic++ -std=gnu++11 -g -O2 -D_THREAD_SAFE -pthread -o cdo cdo-cdo.o cdo-Adisit.o cdo-Afterburner.o cdo-Arith.o cdo-Arithc.o cdo-Arithdays.o cdo-Arithlat.o cdo-CDItest.o cdo-CD
Iread.o cdo-CDIwrite.o cdo-Cat.o cdo-Change.o cdo-Change_e5slm.o cdo-Cloudlayer.o cdo-CMOR.o cdo-CMOR_lite.o cdo-CMOR_table.o cdo-Collgrid.o cdo-Command.o cdo-Comp.o cdo-Compc.o cdo-Complext
orect.o cdo-Cond.o cdo-Cond2.o cdo-Condc.o cdo-Consecstat.o cdo-Copy.o cdo-Deltat.o cdo-Deltime.o cdo-Derivepar.o cdo-Detrend.o cdo-Diff.o cdo-Distgrid.o cdo-Duplicate.o cdo-EOFs.o cdo-Eof3d
.o cdo-EcaIndices.o cdo-Echam5ini.o cdo-Enlarge.o cdo-Enlargegrid.o cdo-Ensstat.o cdo-Ensstat3.o cdo-Ensval.o cdo-Eofcoeff.o cdo-Eofcoeff3d.o cdo-EstFreq.o cdo-Exprf.o cdo-FC.o cdo-Filedes.o
 cdo-Fillmiss.o cdo-Filter.o cdo-Fldrms.o cdo-Fldstat.o cdo-Fldstat2.o cdo-Fourier.o cdo-Gengrid.o cdo-Gradsdes.o cdo-Gridboxstat.o cdo-Gridcell.o cdo-Gridsearch.o cdo-Harmonic.o cdo-Hi.o cd
o-Histogram.o cdo-Importamsr.o cdo-Importbinary.o cdo-Importcmsaf.o cdo-Importobs.o cdo-Importfv3grid.o cdo-Info.o cdo-Input.o cdo-Intgrid.o cdo-Intgridtraj.o cdo-Intlevel.o cdo-Intlevel3d.o cdo-Intntime.o cdo-Inttime.o cdo-Intyear.o cdo-Invert.o cdo-Invertlev.o cdo-Isosurface.o cdo-Lic.o cdo-MapReduce.o cdo-Maskbox.o cdo-Mastrfu.o cdo-Math.o cdo-Merge.o cdo-Mergegrid.o cdo-Mergetime.o cdo-Merstat.o cdo-Monarith.o cdo-Mrotuv.o cdo-Mrotuvb.o cdo-NCL_wind.o cdo-Ninfo.o cdo-Nmldump.o cdo-Output.o cdo-Outputgmt.o cdo-Pack.o cdo-Pardup.o cdo-Pinfo.o cdo-Pressure.o cdo-Recttocomplex.o cdo-Regres.o cdo-Remap.o cdo-Remapweights.o cdo-Remapeta.o cdo-Replace.o cdo-Replacevalues.o cdo-Rhopot.o cdo-Rotuv.o cdo-Runpctl.o cdo-Runstat.o cdo-Samplegrid.o cdo-Samplegridicon.o cdo-Seascount.o cdo-Seaspctl.o cdo-Seasstat.o cdo-Selbox.o cdo-Selgridcell.o cdo-Select.o cdo-Selmulti.o cdo-Seloperator.o cdo-Selrec.o cdo-Seltime.o cdo-Selvar.o cdo-Selyearidx.o cdo-Set.o cdo-Setattribute.o cdo-Setbox.o cdo-Setgatt.o cdo-Setgrid.o cdo-Sethalo.o cdo-Setmiss.o cdo-Setpartab.o cdo-Setrcaname.o cdo-Settime.o cdo-Setzaxis.o cdo-Shiftxy.o cdo-Showinfo.o cdo-Showattribute.o cdo-Sinfo.o cdo-Smooth.o cdo-Sort.o cdo-Sorttimestamp.o cdo-Specinfo.o cdo-Spectral.o cdo-Spectrum.o cdo-Split.o cdo-Splitrec.o cdo-Splitsel.o cdo-Splittime.o cdo-Splityear.o cdo-Subtrend.o cdo-Tee.o cdo-Templates.o cdo-Test.o cdo-Tests.o cdo-Timcount.o cdo-Timcumsum.o cdo-Timpctl.o cdo-Timselpctl.o cdo-Timselstat.o cdo-Timsort.o cdo-Timstat.o cdo-Timstat2.o cdo-Timstat3.o cdo-Tinfo.o cdo-Tocomplex.o cdo-Transpose.o cdo-Trend.o cdo-Tstepcount.o cdo-Unpack.o cdo-Vargen.o cdo-Varrms.o cdo-Varsstat.o cdo-Vertintml.o cdo-Vertintap.o cdo-Vertstat.o cdo-Vertcum.o cdo-Vertwind.o cdo-Verifygrid.o cdo-Wct.o cdo-Wind.o cdo-WindTrans.o cdo-Writegrid.o cdo-Writerandom.o cdo-XTimstat.o cdo-Yearmonstat.o cdo-Ydayarith.o cdo-Ydaypctl.o cdo-Ydaystat.o cdo-Ydrunpctl.o cdo-Ydrunstat.o cdo-Yhourarith.o cdo-Yhourstat.o cdo-Ymonarith.o cdo-Ymonpctl.o cdo-Ymonstat.o cdo-Yseaspctl.o cdo-Yseasstat.o cdo-Zonstat.o cdo-Magplot.o cdo-Magvector.o cdo-Maggraph.o cdo-template_parser.o cdo-results_template_parser.o cdo-magics_template_parser.o cdo-string_utilities.o cdo-cdo_magics_mapper.o -Wl,-bind_at_load  -L/Users/mathomp4/Baselibs/ESMA-Baselibs-6.0.13-Test/x86_64-apple-darwin19.4.0/nagfor/Darwin/lib ./.libs/libcdo.a ../libcdi/src/.libs/libcdi.a ../src/lib/yac/.libs/libyac.a ../src/lib/gradsdes/.libs/libgradsdes.a ../src/lib/ncl/.libs/libncl.a /Users/mathomp4/Baselibs/ESMA-Baselibs-6.0.13-Test/x86_64-apple-darwin19.4.0/nagfor/Darwin/lib/libudunits2.a /Users/mathomp4/Baselibs/ESMA-Baselibs-6.0.13-Test/x86_64-apple-darwin19.4.0/nagfor/Darwin/lib/libnetcdf.a /Users/mathomp4/Baselibs/ESMA-Baselibs-6.0.13-Test/x86_64-apple-darwin19.4.0/nagfor/Darwin/lib/libhdf5_hl.a /Users/mathomp4/Baselibs/ESMA-Baselibs-6.0.13-Test/x86_64-apple-darwin19.4.0/nagfor/Darwin/lib/libhdf5.a /Users/mathomp4/Baselibs/ESMA-Baselibs-6.0.13-Test/x86_64-apple-darwin19.4.0/nagfor/Darwin/lib/libcurl.a -lexpat /Users/mathomp4/Baselibs/ESMA-Baselibs-6.0.13-Test/x86_64-apple-darwin19.4.0/nagfor/Darwin/lib/libmfhdf.a /Users/mathomp4/Baselibs/ESMA-Baselibs-6.0.13-Test/x86_64-apple-darwin19.4.0/nagfor/Darwin/lib/libdf.a -lz /Users/mathomp4/Baselibs/ESMA-Baselibs-6.0.13-Test/x86_64-apple-darwin19.4.0/nagfor/Darwin/lib/libsz.a /Users/mathomp4/Baselibs/ESMA-Baselibs-6.0.13-Test/x86_64-apple-darwin19.4.0/nagfor/Darwin/lib/libjpeg.a -ldl -lm -pthread
Undefined symbols for architecture x86_64:
  "___NAGf90_DeAlloc_o", referenced from:
      _dvrfidf_ in libncl.a(rvdv.o)
      _ddvfidf_ in libncl.a(rvdv.o)
  "___NAGf90_cosd", referenced from:
      _dvrfidf_ in libncl.a(rvdv.o)
      _ddvfidf_ in libncl.a(rvdv.o)
  "___NAGf90_line_Alloc_zvar", referenced from:
      _dvrfidf_ in libncl.a(rvdv.o)
      _ddvfidf_ in libncl.a(rvdv.o)
  "___NAGf90_tand", referenced from:
      _dvrfidf_ in libncl.a(rvdv.o)
      _ddvfidf_ in libncl.a(rvdv.o)
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

You'll see I'm using mpic++ since I built HDF5 with parallel support (thus netCDF was built with mpicc, mpifort...).

The odd thing is, I can build with Intel Fortran/Clang, so clang should be enough.

Any ideas?


Replies (3)

RE: Build failure with Nagfor/Clang - Added by Ralf Mueller almost 4 years ago

Hi Matthew!

please try this in your build directory

nm src/lib/ncl/rvdv.o
This should show the symbol names in the correspoding fortran object file. I suspect them to use a different naming scheme. Unfortunately fortran compilers do this differently. On my system it look like this with gfortran
                 U cos
0000000000000f40 T ddvfidf_
0000000000000000 T dlnextrp_
0000000000000460 T duseave_
00000000000004e0 T dvrfidf_
                 U free
                 U _GLOBAL_OFFSET_TABLE_
0000000000000000 r .LC0
0000000000000008 r .LC2
0000000000000000 r .LC3
0000000000000010 r .LC4
0000000000000018 r .LC5
0000000000000020 r .LC6
0000000000000028 r .LC7
                 U malloc
                 U tan
I added
CFLAGS=-DNAGf90Fortran
to the configure call

RE: Build failure with Nagfor/Clang - Added by Matt Thompson almost 4 years ago

Ralf,

Whoops. Sorry for the late response back. I seem to have missed the email notification (or the overly-eager spam filter got it).

I'm rebuilding now first without:

CFLAGS=-DNAGf90Fortran

so I can do the nm, then I'll try a rebuild with your flag. Hopefully that fixes it!

RE: Build failure with Nagfor/Clang - Added by Matt Thompson almost 4 years ago

Here is the result of nm:

❯ nm src/lib/ncl/rvdv.o

                 U ___NAGf90_DeAlloc_o
                 U ___NAGf90_cosd
                 U ___NAGf90_line_Alloc_zvar
                 U ___NAGf90_tand
0000000000001d30 T _ddvfidf_
0000000000003a60 T _dlnextrp_
0000000000004540 T _duseave_
0000000000000000 T _dvrfidf_

I then added:

CFLAGS=-DNAGf90Fortran

to my configure line, and I did see it take hold:
libtool: compile:  mpicc -DHAVE_CONFIG_H -I. -I/Users/mathomp4/Baselibs/ESMA-Baselibs-6.0.13/x86_64-apple-darwin19.5.0/nagfor/Darwin/include -I/Users/mathomp4/Baselibs/ESMA-Baselibs-6.0.13/x86_64-apple-darwin19.5.0/nagfor/Darwin/include -I/Users/mathomp4/Baselibs/ESMA-Baselibs-6.0.13/x86_64-apple-darwin19.5.0/nagfor/Darwin/include/ -I/Users/mathomp4/Baselibs/ESMA-Baselibs-6.0.13/x86_64-apple-darwin19.5.0/nagfor/Darwin/include/zlib -I/Users/mathomp4/Baselibs/ESMA-Baselibs-6.0.13/x86_64-apple-darwin19.5.0/nagfor/Darwin/include/szlib -I/Users/mathomp4/Baselibs/ESMA-Baselibs-6.0.13/x86_64-apple-darwin19.5.0/nagfor/Darwin/include/jpeg -I/Users/mathomp4/Baselibs/ESMA-Baselibs-6.0.13/x86_64-apple-darwin19.5.0/nagfor/Darwin/include/hdf5 -I/Users/mathomp4/Baselibs/ESMA-Baselibs-6.0.13/x86_64-apple-darwin19.5.0/nagfor/Darwin/include/hdf -I/Users/mathomp4/Baselibs/ESMA-Baselibs-6.0.13/x86_64-apple-darwin19.5.0/nagfor/Darwin/include/netcdf -I/Users/mathomp4/Baselibs/ESMA-Baselibs-6.0.13/x86_64-apple-darwin19.5.0/nagfor/Darwin/include/udunits2 -I/Users/mathomp4/Baselibs/ESMA-Baselibs-6.0.13/x86_64-apple-darwin19.5.0/nagfor/Darwin/include/gsl -I/Users/mathomp4/Baselibs/ESMA-Baselibs-6.0.13/x86_64-apple-darwin19.5.0/nagfor/Darwin/include/antlr -DNAGf90Fortran -D_THREAD_SAFE -pthread -MT file.lo -MD -MP -MF .deps/file.Tpo -c file.c  -fno-common -DPIC -o file.o

but:
Undefined symbols for architecture x86_64:
  "___NAGf90_DeAlloc_o", referenced from:
      _dvrfidf_ in libncl.a(rvdv.o)
      _ddvfidf_ in libncl.a(rvdv.o)
  "___NAGf90_cosd", referenced from:
      _dvrfidf_ in libncl.a(rvdv.o)
      _ddvfidf_ in libncl.a(rvdv.o)
  "___NAGf90_line_Alloc_zvar", referenced from:
      _dvrfidf_ in libncl.a(rvdv.o)
      _ddvfidf_ in libncl.a(rvdv.o)
  "___NAGf90_tand", referenced from:
      _dvrfidf_ in libncl.a(rvdv.o)
      _ddvfidf_ in libncl.a(rvdv.o)
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

I get the same thing with using:
CPPFLAGS=-DNAGf90Fortran

    (1-3/3)