Hi Matt,

I suspect this is an issue in libtool. We'll take a look at it. We routinely test NAG compiler, but I guess we never tried clang+NAG. Once we figure out the issue, we typically will maintain custom patches to libtool until libtool fixes it upstream.

--
Hui Zhou

From: Thompson, Matt (GSFC-610.1)[SCIENCE SYSTEMS AND APPLICATIONS INC] via discuss <discuss@mpich.org>
Sent: Tuesday, January 18, 2022 12:49 PM
To: discuss@mpich.org <discuss@mpich.org>
Cc: Thompson, Matt (GSFC-610.1)[SCIENCE SYSTEMS AND APPLICATIONS INC] <matthew.thompson@nasa.gov>
Subject: [mpich-discuss] Help building MPICH as shared library with NAG Fortran and Clang
 

All,

 

As the subject says, I'm having issues building MPICH as a shared library with NAG Fortran and Clang on my MacBook.

 

I configured mpich as:

 

../configure FCFLAGS="-mismatch_all -fpp" FFLAGS="-mismatch_all -fpp" --prefix=$HOME/installed/Compiler/nag-7.0_7066/mpich/4.0rc3 |& tee configure.nag-7.0_7066.log

 

where CC=clang, CXX=clang++, and FC=nagfor (set in environment). When I do this, the configure step is fine, but upon build:

 

make[2]: Entering directory '/Users/mathomp4/src/MPI/mpich-4.0rc3/build-nag-7.0_7066'

  GEN      lib/libmpifort.la

NAG Fortran Compiler Release 7.0(Yurakucho) Build 7066

Option error: Unrecognised option -dynamiclib

make[2]: *** [Makefile:7606: lib/libmpifort.la] Error 2

make[2]: Leaving directory '/Users/mathomp4/src/MPI/mpich-4.0rc3/build-nag-7.0_7066'

make[1]: *** [Makefile:30237: all-recursive] Error 1

make[1]: Leaving directory '/Users/mathomp4/src/MPI/mpich-4.0rc3/build-nag-7.0_7066'

make: *** [Makefile:7300: all] Error 2

 

The issue seems to be that MPICH (or libtool?) assumes that flags that clang accepts will be accepted by the Fortran compiler as well. But NAG doesn't accept '-dynamiclib' as an option. (I am asking NAG about this as well.)

 

I can kind of see places where this is happening. For example in config.status:

 

749:archive_cmds_FC='$CC -dynamiclib $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags -install_name $rpath/$soname $verstring $single_module'

 

Now, the interesting thing is this *exact same* issue happened to me with Open MPI:

 

https://www.mail-archive.com/users@lists.open-mpi.org//msg34635.html

 

On that thread, I eventually figured out how to build Open MPI as static, but now I ran into this:

 

https://discourse.cmake.org/t/cmake-and-mpi-fortran-cmake-doesnt-see-it/4869

 

My fear is that if I try and build MPICH as a static library, the same thing will happen.

 

Does anyone at MPICH have any thoughts on this?

 

Thanks,
Matt

-- 

Matt Thompson, SSAI, Ld Scientific Programmer/Analyst

NASA GSFC,    Global Modeling and Assimilation Office

Code 610.1,  8800 Greenbelt Rd,  Greenbelt,  MD 20771

Phone: 301-614-6712                 Fax: 301-614-6246

http://science.gsfc.nasa.gov/sed/bio/matthew.thompson