From e3b357ad87dbc119c67befaef65588ca48236b16 Mon Sep 17 00:00:00 2001 From: Sergey Kosukhin Date: Mon, 2 Mar 2020 15:40:37 +0100 Subject: Update flag_handler for 'netcdf-fortran'. (#14789) * Update flag_handler for 'netcdf-fortran'. * Refactoring. * Enable old versions of netcdf-fortran for NAG. * Disable parallel 'make check' for versions before 4.5.0. * Fix shared libraries built with NAG instead of conflicting it. * Add 'skosukhin' as a maintainer of 'netcdf-fortran'. --- .../netcdf-fortran/excessive_linking.patch | 312 +++++++++++++++++++++ .../builtin/packages/netcdf-fortran/logging.patch | 13 + .../builtin/packages/netcdf-fortran/nag.patch | 31 -- .../netcdf-fortran/nag_libtool_2.4.2.patch | 124 ++++++++ .../netcdf-fortran/nag_libtool_2.4.6.patch | 96 +++++++ .../packages/netcdf-fortran/nag_testing.patch | 11 + .../builtin/packages/netcdf-fortran/package.py | 67 ++++- 7 files changed, 612 insertions(+), 42 deletions(-) create mode 100644 var/spack/repos/builtin/packages/netcdf-fortran/excessive_linking.patch create mode 100644 var/spack/repos/builtin/packages/netcdf-fortran/logging.patch delete mode 100644 var/spack/repos/builtin/packages/netcdf-fortran/nag.patch create mode 100644 var/spack/repos/builtin/packages/netcdf-fortran/nag_libtool_2.4.2.patch create mode 100644 var/spack/repos/builtin/packages/netcdf-fortran/nag_libtool_2.4.6.patch create mode 100644 var/spack/repos/builtin/packages/netcdf-fortran/nag_testing.patch (limited to 'var') diff --git a/var/spack/repos/builtin/packages/netcdf-fortran/excessive_linking.patch b/var/spack/repos/builtin/packages/netcdf-fortran/excessive_linking.patch new file mode 100644 index 0000000000..11e149081a --- /dev/null +++ b/var/spack/repos/builtin/packages/netcdf-fortran/excessive_linking.patch @@ -0,0 +1,312 @@ +--- a/config.h.in ++++ b/config.h.in +@@ -52,9 +52,6 @@ + /* Define to 1 if you have the header file. */ + #undef HAVE_INTTYPES_H + +-/* Define to 1 if you have the `curl' library (-lcurl). */ +-#undef HAVE_LIBCURL +- + /* Define to 1 if you have the `m' library (-lm). */ + #undef HAVE_LIBM + +--- a/configure ++++ b/configure +@@ -22122,6 +22122,14 @@ $as_echo "$as_me: checking types, headers, and functions" >&6;} + + # We must check for all these, because they may be used by the netCDF + # C library. ++# Removing the checks for some of the libraries because of issues ++# observed when they are detected, are not needed, and an attempt to ++# link against is made anyways. ++# See https://github.com/Unidata/netcdf-fortran/issues/164 ++# ++# Specifying LDFLAGS="$(nc-config --libs [--static])" should ++# let downstream developers link more reliably against libnetcdf. ++ + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for floor in -lm" >&5 + $as_echo_n "checking for floor in -lm... " >&6; } + if ${ac_cv_lib_m_floor+:} false; then : +@@ -22167,163 +22175,6 @@ _ACEOF + + fi + +-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for curl_easy_setopt in -lcurl" >&5 +-$as_echo_n "checking for curl_easy_setopt in -lcurl... " >&6; } +-if ${ac_cv_lib_curl_curl_easy_setopt+:} false; then : +- $as_echo_n "(cached) " >&6 +-else +- ac_check_lib_save_LIBS=$LIBS +-LIBS="-lcurl $LIBS" +-cat confdefs.h - <<_ACEOF >conftest.$ac_ext +-/* end confdefs.h. */ +- +-/* Override any GCC internal prototype to avoid an error. +- Use char because int might match the return type of a GCC +- builtin and then its argument prototype would still apply. */ +-#ifdef __cplusplus +-extern "C" +-#endif +-char curl_easy_setopt (); +-int +-main () +-{ +-return curl_easy_setopt (); +- ; +- return 0; +-} +-_ACEOF +-if ac_fn_c_try_link "$LINENO"; then : +- ac_cv_lib_curl_curl_easy_setopt=yes +-else +- ac_cv_lib_curl_curl_easy_setopt=no +-fi +-rm -f core conftest.err conftest.$ac_objext \ +- conftest$ac_exeext conftest.$ac_ext +-LIBS=$ac_check_lib_save_LIBS +-fi +-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_curl_curl_easy_setopt" >&5 +-$as_echo "$ac_cv_lib_curl_curl_easy_setopt" >&6; } +-if test "x$ac_cv_lib_curl_curl_easy_setopt" = xyes; then : +- cat >>confdefs.h <<_ACEOF +-#define HAVE_LIBCURL 1 +-_ACEOF +- +- LIBS="-lcurl $LIBS" +- +-fi +- +-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing deflate" >&5 +-$as_echo_n "checking for library containing deflate... " >&6; } +-if ${ac_cv_search_deflate+:} false; then : +- $as_echo_n "(cached) " >&6 +-else +- ac_func_search_save_LIBS=$LIBS +-cat confdefs.h - <<_ACEOF >conftest.$ac_ext +-/* end confdefs.h. */ +- +-/* Override any GCC internal prototype to avoid an error. +- Use char because int might match the return type of a GCC +- builtin and then its argument prototype would still apply. */ +-#ifdef __cplusplus +-extern "C" +-#endif +-char deflate (); +-int +-main () +-{ +-return deflate (); +- ; +- return 0; +-} +-_ACEOF +-for ac_lib in '' zlibwapi zlibstat zlib zlib1 z; do +- if test -z "$ac_lib"; then +- ac_res="none required" +- else +- ac_res=-l$ac_lib +- LIBS="-l$ac_lib $ac_func_search_save_LIBS" +- fi +- if ac_fn_c_try_link "$LINENO"; then : +- ac_cv_search_deflate=$ac_res +-fi +-rm -f core conftest.err conftest.$ac_objext \ +- conftest$ac_exeext +- if ${ac_cv_search_deflate+:} false; then : +- break +-fi +-done +-if ${ac_cv_search_deflate+:} false; then : +- +-else +- ac_cv_search_deflate=no +-fi +-rm conftest.$ac_ext +-LIBS=$ac_func_search_save_LIBS +-fi +-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_deflate" >&5 +-$as_echo "$ac_cv_search_deflate" >&6; } +-ac_res=$ac_cv_search_deflate +-if test "$ac_res" != no; then : +- test "$ac_res" = "none required" || LIBS="$ac_res $LIBS" +- +-fi +- +-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing SZ_Compress" >&5 +-$as_echo_n "checking for library containing SZ_Compress... " >&6; } +-if ${ac_cv_search_SZ_Compress+:} false; then : +- $as_echo_n "(cached) " >&6 +-else +- ac_func_search_save_LIBS=$LIBS +-cat confdefs.h - <<_ACEOF >conftest.$ac_ext +-/* end confdefs.h. */ +- +-/* Override any GCC internal prototype to avoid an error. +- Use char because int might match the return type of a GCC +- builtin and then its argument prototype would still apply. */ +-#ifdef __cplusplus +-extern "C" +-#endif +-char SZ_Compress (); +-int +-main () +-{ +-return SZ_Compress (); +- ; +- return 0; +-} +-_ACEOF +-for ac_lib in '' szip sz; do +- if test -z "$ac_lib"; then +- ac_res="none required" +- else +- ac_res=-l$ac_lib +- LIBS="-l$ac_lib $ac_func_search_save_LIBS" +- fi +- if ac_fn_c_try_link "$LINENO"; then : +- ac_cv_search_SZ_Compress=$ac_res +-fi +-rm -f core conftest.err conftest.$ac_objext \ +- conftest$ac_exeext +- if ${ac_cv_search_SZ_Compress+:} false; then : +- break +-fi +-done +-if ${ac_cv_search_SZ_Compress+:} false; then : +- +-else +- ac_cv_search_SZ_Compress=no +-fi +-rm conftest.$ac_ext +-LIBS=$ac_func_search_save_LIBS +-fi +-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_SZ_Compress" >&5 +-$as_echo "$ac_cv_search_SZ_Compress" >&6; } +-ac_res=$ac_cv_search_SZ_Compress +-if test "$ac_res" != no; then : +- test "$ac_res" = "none required" || LIBS="$ac_res $LIBS" +- +-fi +- + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing dlopen" >&5 + $as_echo_n "checking for library containing dlopen... " >&6; } + if ${ac_cv_search_dlopen+:} false; then : +@@ -22380,118 +22231,6 @@ if test "$ac_res" != no; then : + + fi + +-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing H5Fflush" >&5 +-$as_echo_n "checking for library containing H5Fflush... " >&6; } +-if ${ac_cv_search_H5Fflush+:} false; then : +- $as_echo_n "(cached) " >&6 +-else +- ac_func_search_save_LIBS=$LIBS +-cat confdefs.h - <<_ACEOF >conftest.$ac_ext +-/* end confdefs.h. */ +- +-/* Override any GCC internal prototype to avoid an error. +- Use char because int might match the return type of a GCC +- builtin and then its argument prototype would still apply. */ +-#ifdef __cplusplus +-extern "C" +-#endif +-char H5Fflush (); +-int +-main () +-{ +-return H5Fflush (); +- ; +- return 0; +-} +-_ACEOF +-for ac_lib in '' hdf5dll hdf5; do +- if test -z "$ac_lib"; then +- ac_res="none required" +- else +- ac_res=-l$ac_lib +- LIBS="-l$ac_lib $ac_func_search_save_LIBS" +- fi +- if ac_fn_c_try_link "$LINENO"; then : +- ac_cv_search_H5Fflush=$ac_res +-fi +-rm -f core conftest.err conftest.$ac_objext \ +- conftest$ac_exeext +- if ${ac_cv_search_H5Fflush+:} false; then : +- break +-fi +-done +-if ${ac_cv_search_H5Fflush+:} false; then : +- +-else +- ac_cv_search_H5Fflush=no +-fi +-rm conftest.$ac_ext +-LIBS=$ac_func_search_save_LIBS +-fi +-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_H5Fflush" >&5 +-$as_echo "$ac_cv_search_H5Fflush" >&6; } +-ac_res=$ac_cv_search_H5Fflush +-if test "$ac_res" != no; then : +- test "$ac_res" = "none required" || LIBS="$ac_res $LIBS" +- +-fi +- +-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing H5DSis_scale" >&5 +-$as_echo_n "checking for library containing H5DSis_scale... " >&6; } +-if ${ac_cv_search_H5DSis_scale+:} false; then : +- $as_echo_n "(cached) " >&6 +-else +- ac_func_search_save_LIBS=$LIBS +-cat confdefs.h - <<_ACEOF >conftest.$ac_ext +-/* end confdefs.h. */ +- +-/* Override any GCC internal prototype to avoid an error. +- Use char because int might match the return type of a GCC +- builtin and then its argument prototype would still apply. */ +-#ifdef __cplusplus +-extern "C" +-#endif +-char H5DSis_scale (); +-int +-main () +-{ +-return H5DSis_scale (); +- ; +- return 0; +-} +-_ACEOF +-for ac_lib in '' hdf5_hldll hdf5_hl; do +- if test -z "$ac_lib"; then +- ac_res="none required" +- else +- ac_res=-l$ac_lib +- LIBS="-l$ac_lib $ac_func_search_save_LIBS" +- fi +- if ac_fn_c_try_link "$LINENO"; then : +- ac_cv_search_H5DSis_scale=$ac_res +-fi +-rm -f core conftest.err conftest.$ac_objext \ +- conftest$ac_exeext +- if ${ac_cv_search_H5DSis_scale+:} false; then : +- break +-fi +-done +-if ${ac_cv_search_H5DSis_scale+:} false; then : +- +-else +- ac_cv_search_H5DSis_scale=no +-fi +-rm conftest.$ac_ext +-LIBS=$ac_func_search_save_LIBS +-fi +-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_H5DSis_scale" >&5 +-$as_echo "$ac_cv_search_H5DSis_scale" >&6; } +-ac_res=$ac_cv_search_H5DSis_scale +-if test "$ac_res" != no; then : +- test "$ac_res" = "none required" || LIBS="$ac_res $LIBS" +- +-fi +- + + # Find the netCDF header and library. + for ac_header in netcdf.h diff --git a/var/spack/repos/builtin/packages/netcdf-fortran/logging.patch b/var/spack/repos/builtin/packages/netcdf-fortran/logging.patch new file mode 100644 index 0000000000..fadeb8cfe6 --- /dev/null +++ b/var/spack/repos/builtin/packages/netcdf-fortran/logging.patch @@ -0,0 +1,13 @@ +--- a/fortran/nf_logging.F90 ++++ b/fortran/nf_logging.F90 +@@ -1,3 +1,10 @@ ++! This file is compiled only if logging is enabled. However, the macro LOGGING ++! is never defined. For most of the compilers this simply leads to an empty ++! object: they do not complain when a source file is empty. This is not the ++! case for NAG: the compiler fails the compilation of empty sources. To fix ++! this problem, we define the macro here. ++#define LOGGING ++ + #ifdef LOGGING + ! Function to turn on logging + !-------------------------------- nf_set_log_level ---------------------------- diff --git a/var/spack/repos/builtin/packages/netcdf-fortran/nag.patch b/var/spack/repos/builtin/packages/netcdf-fortran/nag.patch deleted file mode 100644 index 458c18813e..0000000000 --- a/var/spack/repos/builtin/packages/netcdf-fortran/nag.patch +++ /dev/null @@ -1,31 +0,0 @@ -diff --git a/configure b/configure -index 06ac8b0..d518a1a 100755 ---- a/configure -+++ b/configure -@@ -10657,6 +10657,8 @@ _LT_EOF - lf95*) # Lahey Fortran 8.1 - whole_archive_flag_spec= - tmp_sharedflag='--shared' ;; -+ nagfor*) -+ tmp_sharedflag='-Wl,-shared' ;; - xl[cC]* | bgxl[cC]* | mpixl[cC]*) # IBM XL C 8.0 on PPC (deal with xlf below) - tmp_sharedflag='-qmkshrobj' - tmp_addflag= ;; -@@ -14252,6 +14254,8 @@ _LT_EOF - lf95*) # Lahey Fortran 8.1 - whole_archive_flag_spec_F77= - tmp_sharedflag='--shared' ;; -+ nagfor*) -+ tmp_sharedflag='-Wl,-shared' ;; - xl[cC]* | bgxl[cC]* | mpixl[cC]*) # IBM XL C 8.0 on PPC (deal with xlf below) - tmp_sharedflag='-qmkshrobj' - tmp_addflag= ;; -@@ -17142,6 +17146,8 @@ _LT_EOF - lf95*) # Lahey Fortran 8.1 - whole_archive_flag_spec_FC= - tmp_sharedflag='--shared' ;; -+ nagfor*) -+ tmp_sharedflag='-Wl,-shared' ;; - xl[cC]* | bgxl[cC]* | mpixl[cC]*) # IBM XL C 8.0 on PPC (deal with xlf below) - tmp_sharedflag='-qmkshrobj' - tmp_addflag= ;; diff --git a/var/spack/repos/builtin/packages/netcdf-fortran/nag_libtool_2.4.2.patch b/var/spack/repos/builtin/packages/netcdf-fortran/nag_libtool_2.4.2.patch new file mode 100644 index 0000000000..73fbdbd03b --- /dev/null +++ b/var/spack/repos/builtin/packages/netcdf-fortran/nag_libtool_2.4.2.patch @@ -0,0 +1,124 @@ +--- a/configure ++++ b/configure +@@ -9584,6 +9584,10 @@ for cc_temp in $compiler""; do + esac + done + cc_basename=`$ECHO "$cc_temp" | $SED "s%.*/%%; s%^$host_alias-%%"` ++case $cc_basename in ++ nagfor*) ;; ++ *) $cc_temp -V 2>&1 | $GREP '^NAG Fortran Compiler Release' >/dev/null 2>&1 && cc_basename='nagfor-wrapper' ;; ++esac + + + # Only perform the check for file, if the check method requires it +@@ -10657,6 +10661,10 @@ _LT_EOF + lf95*) # Lahey Fortran 8.1 + whole_archive_flag_spec= + tmp_sharedflag='--shared' ;; ++ nagfor*) ++ whole_archive_flag_spec='${wl}--whole-archive`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` ${wl}--no-whole-archive' ++ compiler_needs_object=yes ++ tmp_sharedflag='-Wl,-shared' ;; + xl[cC]* | bgxl[cC]* | mpixl[cC]*) # IBM XL C 8.0 on PPC (deal with xlf below) + tmp_sharedflag='-qmkshrobj' + tmp_addflag= ;; +@@ -13415,6 +13423,10 @@ $RM -r conftest* + esac + done + cc_basename=`$ECHO "$cc_temp" | $SED "s%.*/%%; s%^$host_alias-%%"` ++case $cc_basename in ++ nagfor*) ;; ++ *) $cc_temp -V 2>&1 | $GREP '^NAG Fortran Compiler Release' >/dev/null 2>&1 && cc_basename='nagfor-wrapper' ;; ++esac + + GCC=$G77 + if test -n "$compiler"; then +@@ -14252,6 +14264,10 @@ _LT_EOF + lf95*) # Lahey Fortran 8.1 + whole_archive_flag_spec_F77= + tmp_sharedflag='--shared' ;; ++ nagfor*) ++ whole_archive_flag_spec_F77='${wl}--whole-archive`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` ${wl}--no-whole-archive' ++ compiler_needs_object_F77=yes ++ tmp_sharedflag='-Wl,-shared' ;; + xl[cC]* | bgxl[cC]* | mpixl[cC]*) # IBM XL C 8.0 on PPC (deal with xlf below) + tmp_sharedflag='-qmkshrobj' + tmp_addflag= ;; +@@ -16142,6 +16158,10 @@ $RM -r conftest* + esac + done + cc_basename=`$ECHO "$cc_temp" | $SED "s%.*/%%; s%^$host_alias-%%"` ++case $cc_basename in ++ nagfor*) ;; ++ *) $cc_temp -V 2>&1 | $GREP '^NAG Fortran Compiler Release' >/dev/null 2>&1 && cc_basename='nagfor-wrapper' ;; ++esac + + + if test -n "$compiler"; then +@@ -17142,6 +17162,10 @@ _LT_EOF + lf95*) # Lahey Fortran 8.1 + whole_archive_flag_spec_FC= + tmp_sharedflag='--shared' ;; ++ nagfor*) ++ whole_archive_flag_spec_FC='${wl}--whole-archive`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` ${wl}--no-whole-archive' ++ compiler_needs_object_FC=yes ++ tmp_sharedflag='-Wl,-shared' ;; + xl[cC]* | bgxl[cC]* | mpixl[cC]*) # IBM XL C 8.0 on PPC (deal with xlf below) + tmp_sharedflag='-qmkshrobj' + tmp_addflag= ;; +--- a/ltmain.sh ++++ b/ltmain.sh +@@ -180,6 +180,24 @@ func_basename () + func_basename_result=`$ECHO "${1}" | $SED "$basename"` + } # func_basename may be replaced by extended shell implementation + ++# Calculate cc_basename. Skip known compiler wrappers and cross-prefix. ++func_cc_basename () ++{ ++ for cc_temp in $*""; do ++ case $cc_temp in ++ compile | *[\\/]compile | ccache | *[\\/]ccache ) ;; ++ distcc | *[\\/]distcc | purify | *[\\/]purify ) ;; ++ \-*) ;; ++ *) break;; ++ esac ++ done ++ func_cc_basename_result=`$ECHO "$cc_temp" | $SED "s%.*/%%; s%^$host_alias-%%"` ++ case $func_cc_basename_result in ++ nagfor*) ;; ++ *) $cc_temp -V 2>&1 | $GREP '^NAG Fortran Compiler Release' >/dev/null 2>&1 && func_cc_basename_result='nagfor-wrapper' ;; ++ esac ++} ++ + + # func_dirname_and_basename file append nondir_replacement + # perform func_basename and func_dirname in a single function +@@ -6422,6 +6440,13 @@ func_mode_link () + # Convert "-framework foo" to "foo.ltframework" + if test -n "$inherited_linker_flags"; then + tmp_inherited_linker_flags=`$ECHO "$inherited_linker_flags" | $SED 's/-framework \([^ $]*\)/\1.ltframework/g'` ++ ++ # Additionally convert " -pthread" to " -Wl,-pthread" for nagfor ++ func_cc_basename $CC ++ case $func_cc_basename_result in ++ nagfor*) tmp_inherited_linker_flags=`$ECHO "$tmp_inherited_linker_flags" | $SED 's/ -pthread/ -Wl,-pthread/g'` ;; ++ esac ++ + for tmp_inherited_linker_flag in $tmp_inherited_linker_flags; do + case " $new_inherited_linker_flags " in + *" $tmp_inherited_linker_flag "*) ;; +@@ -8007,6 +8032,14 @@ EOF + ;; + esac + ++ # Time to revert the changes made for nagfor. ++ ++ func_cc_basename $CC ++ case $func_cc_basename_result in ++ nagfor*) ++ new_inherited_linker_flags=`$ECHO " $new_inherited_linker_flags" | $SED 's% -Wl,-pthread% -pthread%g'` ;; ++ esac ++ + # move library search paths that coincide with paths to not yet + # installed libraries to the beginning of the library search list + new_libs= diff --git a/var/spack/repos/builtin/packages/netcdf-fortran/nag_libtool_2.4.6.patch b/var/spack/repos/builtin/packages/netcdf-fortran/nag_libtool_2.4.6.patch new file mode 100644 index 0000000000..dfb47fd5f2 --- /dev/null +++ b/var/spack/repos/builtin/packages/netcdf-fortran/nag_libtool_2.4.6.patch @@ -0,0 +1,96 @@ +--- a/configure ++++ b/configure +@@ -9034,6 +9034,12 @@ func_cc_basename () + esac + done + func_cc_basename_result=`$ECHO "$cc_temp" | $SED "s%.*/%%; s%^$host_alias-%%"` ++ ++ # Set result to 'nagfor-wrapper' when NAG compiler is called via a wrapper (e.g. mpif90). ++ case $func_cc_basename_result in ++ nagfor*) ;; ++ *) $cc_temp -V 2>&1 | $GREP '^NAG Fortran Compiler Release' >/dev/null 2>&1 && func_cc_basename_result='nagfor-wrapper' ;; ++ esac + } + + # Check whether --enable-libtool-lock was given. +@@ -11811,6 +11817,8 @@ _LT_EOF + whole_archive_flag_spec= + tmp_sharedflag='--shared' ;; + nagfor*) # NAGFOR 5.3 ++ whole_archive_flag_spec='$wl--whole-archive`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` $wl--no-whole-archive' ++ compiler_needs_object=yes + tmp_sharedflag='-Wl,-shared' ;; + xl[cC]* | bgxl[cC]* | mpixl[cC]*) # IBM XL C 8.0 on PPC (deal with xlf below) + tmp_sharedflag='-qmkshrobj' +@@ -15663,6 +15671,8 @@ _LT_EOF + whole_archive_flag_spec_F77= + tmp_sharedflag='--shared' ;; + nagfor*) # NAGFOR 5.3 ++ whole_archive_flag_spec_F77='$wl--whole-archive`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` $wl--no-whole-archive' ++ compiler_needs_object_F77=yes + tmp_sharedflag='-Wl,-shared' ;; + xl[cC]* | bgxl[cC]* | mpixl[cC]*) # IBM XL C 8.0 on PPC (deal with xlf below) + tmp_sharedflag='-qmkshrobj' +@@ -18788,6 +18798,8 @@ _LT_EOF + whole_archive_flag_spec_FC= + tmp_sharedflag='--shared' ;; + nagfor*) # NAGFOR 5.3 ++ whole_archive_flag_spec_FC='$wl--whole-archive`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` $wl--no-whole-archive' ++ compiler_needs_object_FC=yes + tmp_sharedflag='-Wl,-shared' ;; + xl[cC]* | bgxl[cC]* | mpixl[cC]*) # IBM XL C 8.0 on PPC (deal with xlf below) + tmp_sharedflag='-qmkshrobj' +@@ -26086,6 +26098,12 @@ func_cc_basename () + esac + done + func_cc_basename_result=`$ECHO "$cc_temp" | $SED "s%.*/%%; s%^$host_alias-%%"` ++ ++ # Set result to 'nagfor-wrapper' when NAG compiler is called via a wrapper (e.g. mpif90). ++ case $func_cc_basename_result in ++ nagfor*) ;; ++ *) $cc_temp -V 2>&1 | $GREP '^NAG Fortran Compiler Release' >/dev/null 2>&1 && func_cc_basename_result='nagfor-wrapper' ;; ++ esac + } + + +--- a/ltmain.sh ++++ b/ltmain.sh +@@ -7868,6 +7868,13 @@ func_mode_link () + # Convert "-framework foo" to "foo.ltframework" + if test -n "$inherited_linker_flags"; then + tmp_inherited_linker_flags=`$ECHO "$inherited_linker_flags" | $SED 's/-framework \([^ $]*\)/\1.ltframework/g'` ++ ++ # Additionally convert " -pthread" to " -Wl,-pthread" for nagfor ++ func_cc_basename $CC ++ case $func_cc_basename_result in ++ nagfor*) tmp_inherited_linker_flags=`$ECHO "$tmp_inherited_linker_flags" | $SED 's/ -pthread/ -Wl,-pthread/g'` ;; ++ esac ++ + for tmp_inherited_linker_flag in $tmp_inherited_linker_flags; do + case " $new_inherited_linker_flags " in + *" $tmp_inherited_linker_flag "*) ;; +@@ -8890,7 +8897,8 @@ func_mode_link () + xlcverstring="$wl-compatibility_version $wl$minor_current $wl-current_version $wl$minor_current.$revision" + verstring="-compatibility_version $minor_current -current_version $minor_current.$revision" + # On Darwin other compilers +- case $CC in ++ func_cc_basename $CC ++ case $func_cc_basename_result in + nagfor*) + verstring="$wl-compatibility_version $wl$minor_current $wl-current_version $wl$minor_current.$revision" + ;; +@@ -9502,6 +9510,14 @@ EOF + ;; + esac + ++ # Time to revert the changes made for nagfor. ++ ++ func_cc_basename $CC ++ case $func_cc_basename_result in ++ nagfor*) ++ new_inherited_linker_flags=`$ECHO " $new_inherited_linker_flags" | $SED 's% -Wl,-pthread% -pthread%g'` ;; ++ esac ++ + # move library search paths that coincide with paths to not yet + # installed libraries to the beginning of the library search list + new_libs= diff --git a/var/spack/repos/builtin/packages/netcdf-fortran/nag_testing.patch b/var/spack/repos/builtin/packages/netcdf-fortran/nag_testing.patch new file mode 100644 index 0000000000..4c730f94c8 --- /dev/null +++ b/var/spack/repos/builtin/packages/netcdf-fortran/nag_testing.patch @@ -0,0 +1,11 @@ +--- a/nf_test/ftst_rengrps.F ++++ b/nf_test/ftst_rengrps.F +@@ -11,7 +11,7 @@ C use typeSizes + C use netcdf + C use netcdf4_f03 + implicit none +- include "netcdf.inc" ++ include "netcdf.inc" + + C This is the name of the data file we will create. + character (len = *), parameter :: FILE_NAME = "ftst_rengrps.nc" diff --git a/var/spack/repos/builtin/packages/netcdf-fortran/package.py b/var/spack/repos/builtin/packages/netcdf-fortran/package.py index e3703fd609..5aed9697cd 100644 --- a/var/spack/repos/builtin/packages/netcdf-fortran/package.py +++ b/var/spack/repos/builtin/packages/netcdf-fortran/package.py @@ -13,7 +13,9 @@ class NetcdfFortran(AutotoolsPackage): distribution.""" homepage = "https://www.unidata.ucar.edu/software/netcdf" - url = "https://www.unidata.ucar.edu/downloads/netcdf/ftp/netcdf-fortran-4.5.2.tar.gz" + url = "https://www.gfd-dennou.org/arch/netcdf/unidata-mirror/netcdf-fortran-4.5.2.tar.gz" + + maintainers = ['skosukhin'] version('4.5.2', sha256='b959937d7d9045184e9d2040a915d94a7f4d0185f4a9dceb8f08c94b0c3304aa') version('4.4.5', sha256='2467536ce29daea348c736476aa8e684c075d2f6cab12f3361885cb6905717b8') @@ -24,6 +26,7 @@ class NetcdfFortran(AutotoolsPackage): description='Enable parallel I/O for netcdf-4') variant('pic', default=True, description='Produce position-independent code (for shared libs)') + variant('shared', default=True, description='Enable shared library') # We need to build with MPI wrappers if parallel I/O features is enabled: # https://www.unidata.ucar.edu/software/netcdf/docs/building_netcdf_fortran.html @@ -34,42 +37,79 @@ class NetcdfFortran(AutotoolsPackage): # The default libtool.m4 is too old to handle NAG compiler properly: # https://github.com/Unidata/netcdf-fortran/issues/94 - patch('nag.patch', when='@:4.4.4%nag') + # Moreover, Libtool can't handle '-pthread' flag coming from libcurl, + # doesn't inject convenience libraries into the shared ones, and is unable + # to detect NAG when it is called with an MPI wrapper. + patch('nag_libtool_2.4.2.patch', when='@:4.4.4%nag') + patch('nag_libtool_2.4.6.patch', when='@4.4.5:%nag') + + # Enable 'make check' for NAG, which is too strict. + patch('nag_testing.patch', when='@4.4.5%nag') + + # File fortran/nf_logging.F90 is compiled without -DLOGGING, which leads + # to missing symbols in the library. Additionally, the patch enables + # building with NAG, which refuses to compile empty source files (see also + # comments in the patch): + patch('logging.patch', when='@:4.4.5') + + # Prevent excessive linking to system libraries. Without this patch the + # library might get linked to the system installation of libcurl. See + # https://github.com/Unidata/netcdf-fortran/commit/0a11f580faebbc1c4dce68bf5135709d1c7c7cc1#diff-67e997bcfdac55191033d57a16d1408a + patch('excessive_linking.patch', when='@4.4.5') # Parallel builds do not work in the fortran directory. This patch is # derived from https://github.com/Unidata/netcdf-fortran/pull/211 patch('no_parallel_build.patch', when='@4.5.2') def flag_handler(self, name, flags): + config_flags = None + if name in ['cflags', 'fflags'] and '+pic' in self.spec: - flags.append(self.compiler.pic_flag) + # Unlike NetCDF-C, we add PIC flag only when +pic. Adding the + # flags also when ~shared would make it impossible to build a + # static-only version of the library with NAG. + config_flags = [self.compiler.pic_flag] elif name == 'cppflags': - flags.append(self.spec['netcdf-c'].headers.cpp_flags) + config_flags = [self.spec['netcdf-c'].headers.cpp_flags] elif name == 'ldflags': # We need to specify LDFLAGS to get correct dependency_libs # in libnetcdff.la, so packages that use libtool for linking # could correctly link to all the dependencies even when the # building takes place outside of Spack environment, i.e. # without Spack's compiler wrappers. - flags.append(self.spec['netcdf-c'].libs.search_flags) + config_flags = [self.spec['netcdf-c'].libs.search_flags] - return None, None, flags + return flags, None, config_flags @property def libs(self): libraries = ['libnetcdff'] - # This package installs both shared and static libraries. Permit - # clients to query which one they want. query_parameters = self.spec.last_query.extra_parameters - shared = 'shared' in query_parameters - return find_libraries( + if 'shared' in query_parameters: + shared = True + elif 'static' in query_parameters: + shared = False + else: + shared = '+shared' in self.spec + + libs = find_libraries( libraries, root=self.prefix, shared=shared, recursive=True ) + if libs: + return libs + + msg = 'Unable to recursively locate {0} {1} libraries in {2}' + raise spack.error.NoLibrariesError( + msg.format('shared' if shared else 'static', + self.spec.name, + self.spec.prefix)) + def configure_args(self): - config_args = [] + config_args = self.enable_or_disable('shared') + config_args.append('--enable-static') if '+mpi' in self.spec: config_args.append('CC=%s' % self.spec['mpi'].mpicc) @@ -77,3 +117,8 @@ class NetcdfFortran(AutotoolsPackage): config_args.append('F77=%s' % self.spec['mpi'].mpif77) return config_args + + @when('@:4.4.5') + def check(self): + with working_dir(self.build_directory): + make('check', parallel=False) -- cgit v1.2.3-60-g2f50