bug#54817: Outdated IBM XL Fortran shared library work around

William T Jones via Bug-libtool via Bug reports for the GNU libtool shared library maintenance tool <[email protected]> Mon, 11 Apr 2022 14:17:58 -0400
Newsgroups gmane.comp.gnu.libtool.bugs
Message-ID <[email protected]>
Alex,

It appears to be in the git repo, so if that is 2.4.7, then yes. 
Attached is a patch that works for me, checking to see if the XL Fortran 
compiler is at least Version 16 or better (maybe a better way of checking).

Thanks for responding so quickly,

Bill


I have more general workaround where I check the IBM XL Fortran 
version.  See example below:

On 4/9/22 12:24 PM, Alex Ameen wrote:
> This sounds reasonable to me. Just to clarify, is this workaround 
> still in 2.4.7?
>
> On Sat, Apr 9, 2022, 10:02 AM William T Jones via Bug-libtool via Bug 
> reports for the GNU libtool shared library maintenance tool 
> <[email protected]> wrote:
>
>     Hello,
>
>     Libtool 2.4.6 has an apparently outdated work around for the IBM XL
>     Fortran compiler's inability to link shared libraries (see
>     m4/libtool.m4
>     lines 5208, 5237-5248).
>
>     As comments in m4/libtool.m4 state, the problem is with IBM XL
>     Fortran
>     version 10.1 on PowerPC.  However, we are now using IBM XL Fortran
>     version 16.1 on PPC (ORNL summit) and it does allow linking of shared
>     objects with xlf via the same "-qmkshrobj" command line option
>     used by
>     xlc and xlC on lines 5208-5210 of m4/libtool.m4.
>
>     To make matters worse, the workaround of using $LD to link shared
>     libraries with Fortran objects does not easily work when linking
>     mixed
>     language object code into such a shared library (one needs to know
>     IBM
>     XL paths to libraries like libibmc++.so and libstdc++.so, for
>     example).
>     This is easily resolved when one links with `xlf -qmkshrobj ...`.
>
>     It is suggested that this workaround check for compiler version or be
>     deprecated.
>
>     Resolution is appreciated,
>
>
>     -- 
>     =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
>
>          Bill Jones [email protected]
>          Mail Stop 128                     Computational AeroSciences
>     Branch
>          15 Langley Boulevard                           Research
>     Directorate
>          NASA Langley Research Center               Building 1268,
>     Room 1044
>          Hampton, VA  23681-2199                       Phone +1 757
>     864-5318
>                                                          Fax +1 757
>     864-8816
>     http://fun3d.larc.nasa.gov
>
>
>
>
>     _______________________________________________
>     Bug-libtool mailing list
>     [email protected]
>     https://lists.gnu.org/mailman/listinfo/bug-libtool
>     <https://gcc02.safelinks.protection.outlook.com/?url=https%3A%2F%2Flists.gnu.org%2Fmailman%2Flistinfo%2Fbug-libtool&data=04%7C01%7Cw.t.jones%40nasa.gov%7C048ad35efb4d49bb2e5108da1a45877d%7C7005d45845be48ae8140d43da96dd17b%7C0%7C0%7C637851183171355906%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=A3cTh16ONe08vyfeB%2Fe2zNF1EGiGbVwdNfFFBVZp0is%3D&reserved=0>
>
-- 
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-

     Bill [email protected]
     Mail Stop 128                     Computational AeroSciences Branch
     15 Langley Boulevard                           Research Directorate
     NASA Langley Research Center               Building 1268, Room 1044
     Hampton, VA  23681-2199                       Phone +1 757 864-5318
                                                     Fax +1 757 864-8816
                                              http://fun3d.larc.nasa.gov

_______________________________________________
Bug-libtool mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/bug-libtool
libtool-xlf.patch (text/plain, 2.5 KB)
diff --git a/m4/libtool.m4 b/m4/libtool.m4
index 79a2451e..bb2c9bd2 100644
--- a/m4/libtool.m4
+++ b/m4/libtool.m4
@@ -5229,6 +5229,14 @@ _LT_EOF
 	xl[[cC]]* | bgxl[[cC]]* | mpixl[[cC]]*) # IBM XL C 8.0 on PPC (deal with xlf below)
 	  tmp_sharedflag='-qmkshrobj'
 	  tmp_addflag= ;;
+	xlf* | bgf* | bgxlf* | mpixlf*)
+	  # IBM XL Fortran 16.1 on PPC can create shared libs itself
+	  if test `$CC -qversion | $GREP IBM | $SED -e 's/IBM XL Fortran for Linux, V//' | $SED -e 's/\..*$//'` -ge 16
+	  then
+	    tmp_sharedflag='-qmkshrobj'
+	    tmp_addflag=
+	  fi
+	  ;;
 	nvcc*)	# Cuda Compiler Driver 2.2
 	  _LT_TAGVAR(whole_archive_flag_spec, $1)='$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'
 	  _LT_TAGVAR(compiler_needs_object, $1)=yes
@@ -5257,14 +5265,17 @@ _LT_EOF
 	  ;;
 	xlf* | bgf* | bgxlf* | mpixlf*)
 	  # IBM XL Fortran 10.1 on PPC cannot create shared libs itself
-	  _LT_TAGVAR(whole_archive_flag_spec, $1)='--whole-archive$convenience --no-whole-archive'
-	  _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-rpath $wl$libdir'
-	  _LT_TAGVAR(archive_cmds, $1)='$LD -shared $libobjs $deplibs $linker_flags -soname $soname -o $lib'
-	  if test yes = "$supports_anon_versioning"; then
-	    _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $output_objdir/$libname.ver~
-              cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~
-              echo "local: *; };" >> $output_objdir/$libname.ver~
-              $LD -shared $libobjs $deplibs $linker_flags -soname $soname -version-script $output_objdir/$libname.ver -o $lib'
+	  if test `$CC -qversion | $GREP IBM | $SED -e 's/IBM XL Fortran for Linux, V//' | $SED -e 's/\..*$//'` -lt 16
+	  then
+	    _LT_TAGVAR(whole_archive_flag_spec, $1)='--whole-archive$convenience --no-whole-archive'
+	    _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-rpath $wl$libdir'
+	    _LT_TAGVAR(archive_cmds, $1)='$LD -shared $libobjs $deplibs $linker_flags -soname $soname -o $lib'
+	    if test yes = "$supports_anon_versioning"; then
+	      _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $output_objdir/$libname.ver~
+                cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~
+                echo "local: *; };" >> $output_objdir/$libname.ver~
+                $LD -shared $libobjs $deplibs $linker_flags -soname $soname -version-script $output_objdir/$libname.ver -o $lib'
+	    fi
 	  fi
 	  ;;
 	esac