[patch, fortran] PR77828 Linking gfortran-7 compiled program with libgfortran of 5.x allowed but crashes

Jerry DeLisle jvdelisle@charter.net
Tue Oct 18 23:49:00 GMT 2016


Hi Folks,

The attached patch does some minor cleanup and bumps the libgfortran version 
number.  I have wanted to reorder the dtp structure for many years now. Not 
strictly needed but it has bugged me forever.

The bump is needed because of the significant changes from implementation of DTIO.

I also took care of the stream I/O TODO and added a new test case for the error 
message.

On my system, I have LD_LIBRARY_PATH set to point to the new library version 
first and then the version 3 are found elsewhere. With the patch we now see the 
following behavior. (Test case in the PR)

Compile with version 6. Finds libgfortran3 on execution:
$gfc6 pr77828.f90
$ ./a.out
  Greetings from i 42 of 43

  Greetings from i 42 of 43

Compile with version 7. Finds libgfortran4 on execution:
$ gfc pr77828.f90
[jerry@amda8 pr77828]$ ./a.out
  Greetings from i 42 of 43

  Greetings from i 42 of 43

Change LD_LIBRARY_PATH to not find libgfortran4:
$ export LD_LIBRARY_PATH=/home/jerry/dev/usr6/lib64
$ gfc pr77828.f90
$ ./a.out
./a.out: error while loading shared libraries: libgfortran.so.4: cannot open 
shared object file: No such file or directory

Word of caution. When this patch is applied rebuild from a clean/empty build 
directory. You must delete any libgfortran3 remnants that may have been built 
and installed previously with gcc version 7 trunk, Otherwise the linker/loader 
may find those rather than a libgfortran3 built for gcc 6 or previous. (When 
compiling with a previous version of gcc)

New test case provided for the streamio error check.

Regression tested on x86-64-linux.

OK for trunk?

Regards,

Jerry

2016-10-18  Jerry DeLisle  <jvdelisle@gcc.gnu.org>

	PR fortran/77828
	* io/io.h (st_parameter_dt): Reorder for readability and sanity.
	* io/transfer.c (data_transfer_init): Remove TODO and enable the
	runtime error message, rec= specifier not allowed in STREAM
	access.
	* libtool-version: Bump major version of libgfortran to 4.

2016-10-18  Jerry DeLisle  <jvdelisle@gcc.gnu.org>

	PR fortran/77828
	* ioparm.def: Reorder dt parameters to match libgfortran.



-------------- next part --------------
A non-text attachment was scrubbed...
Name: bump.diff
Type: text/x-patch
Size: 4417 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/gcc-patches/attachments/20161018/3a1fe69a/attachment.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: streamio_17.f90
Type: text/x-fortran
Size: 336 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/gcc-patches/attachments/20161018/3a1fe69a/attachment-0001.bin>


More information about the Gcc-patches mailing list