Bug 44292 - [libgfortran ABI breakage] Increase internal size of RECL= of the OPEN statement
Summary: [libgfortran ABI breakage] Increase internal size of RECL= of the OPEN statement
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: fortran (show other bugs)
Version: 4.6.0
: P3 normal
Target Milestone: ---
Assignee: Janne Blomqvist
URL: https://gcc.gnu.org/ml/gcc-patches/20...
Keywords: rejects-valid
Depends on:
Blocks: 56818 29602 53796
  Show dependency treegraph
 
Reported: 2010-05-27 12:47 UTC by Tobias Burnus
Modified: 2017-11-18 22:14 UTC (History)
4 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2017-07-31 00:00:00


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Tobias Burnus 2010-05-27 12:47:32 UTC
libgfortran/io/io.h defines the "struct st_parameter_open" with
  GFC_INTEGER_4 recl_in;

However, the Fortran 95/2003/2008 standard allows any kind of integer expression and not only the default type. As http://gcc.gnu.org/ml/fortran/2010-05/msg00302.html shows, gfortran currently fails if the RECL= is larger than 2 GB.

Expected: The size is increased to GFC_INTEGER_8 to allow large-record access.

See also http://gcc.gnu.org/wiki/LibgfortranAbiCleanup
Comment 1 Thomas Koenig 2010-05-29 22:20:03 UTC
Confirmed.
Comment 2 Jerry DeLisle 2010-05-30 05:38:00 UTC
I would like to work this one.
Comment 3 Jerry DeLisle 2010-06-06 06:01:14 UTC
I have managed a patch that writes one very big record as in the test case.  I don't have sufficient memory to actually test a read.

It should be noted that the record length stored in gfc_unit which is created at runtime is a 64 bit value already.  The front-end changes needed to support large record lengths is almost trivial.

On the library side, writing is fairly simple as well.  Reading is a little bit more complicated.  Hopefully soon I will post a partial patch (or maybe even a complete but untested one)  I know Steve has a machine with lots of RAM, is there anyone else who would like to help with testing this? 
Comment 4 Tobias Burnus 2010-06-30 08:08:40 UTC
See also: PR 29602
Comment 5 Thomas Koenig 2017-07-31 10:57:25 UTC
Hi Jerry,

should we also look at this when we bump the library number?
Comment 6 Jerry DeLisle 2017-08-04 19:21:52 UTC
(In reply to Thomas Koenig from comment #5)
> Hi Jerry,
> 
> should we also look at this when we bump the library number?

Sure, but I will have to start over to find the places since things have moved around.
Comment 7 Janne Blomqvist 2017-11-17 20:52:01 UTC
I have a functioning patch, will post shortly.
Comment 8 Janne Blomqvist 2017-11-17 21:15:28 UTC
Patch: https://gcc.gnu.org/ml/gcc-patches/2017-11/msg01563.html
Comment 9 Janne Blomqvist 2017-11-18 16:13:51 UTC
Author: jb
Date: Sat Nov 18 16:13:20 2017
New Revision: 254915

URL: https://gcc.gnu.org/viewcvs?rev=254915&root=gcc&view=rev
Log:
PR 44292 Enable large record lengths in OPEN and INQUIRE statements

This is a straightforward change that we can do now that the ABI has
been bumped (again!).

Regtested on x86_64-pc-linux-gnu.

gcc/fortran/ChangeLog:

2017-11-18  Janne Blomqvist  <jb@gcc.gnu.org>

	PR fortran/44292
	* ioparm.def (IOPARM): Make recl_in intio, and recl_out pintio.

libgfortran/ChangeLog:

2017-11-18  Janne Blomqvist  <jb@gcc.gnu.org>

	PR fortran/44292
	* io/io.h: Make recl_in a GC_IO_INT and recl_out a type
	GFC_IO_INT*.

gcc/testsuite/ChangeLog:

2017-11-18  Janne Blomqvist  <jb@gcc.gnu.org>

	PR fortran/44292
	* gfortran.dg/large_recl.f90: New test.

Added:
    trunk/gcc/testsuite/gfortran.dg/large_recl.f90
Modified:
    trunk/gcc/fortran/ChangeLog
    trunk/gcc/fortran/ioparm.def
    trunk/gcc/testsuite/ChangeLog
    trunk/libgfortran/ChangeLog
    trunk/libgfortran/io/io.h
Comment 10 Janne Blomqvist 2017-11-18 19:57:07 UTC
Follow-up patch: https://gcc.gnu.org/ml/gcc-patches/2017-11/msg01646.html
Comment 11 Janne Blomqvist 2017-11-18 22:05:44 UTC
Author: jb
Date: Sat Nov 18 22:05:13 2017
New Revision: 254918

URL: https://gcc.gnu.org/viewcvs?rev=254918&root=gcc&view=rev
Log:
PR 44292 Handle large record lengths

Now that the ABI supports large record lengths, there's a few places
in libgfortran where we need to use larger types. For internal units
which by definition are in-memory, it's enought to use ptrdiff_t, for
external units gfc_offset.

Regtested on x86_64-pc-linux-gnu?

libgfortran/ChangeLog:

2017-11-19  Janne Blomqvist  <jb@gcc.gnu.org>

        PR fortran/44292
	* io/transfer.c (skip_record): Use gfc_offset to handle large
	records.
	(next_record_r): Likewise.
	(sset): Likewise.
	(next_record_w): Use gfc_offset/ptrdiff_t appropriately.

Modified:
    trunk/libgfortran/ChangeLog
    trunk/libgfortran/io/transfer.c
Comment 12 Janne Blomqvist 2017-11-18 22:14:37 UTC
Fixed on trunk, closing. There might still be uses of 32-bit integers for record lengths in the library (if so, file a new bug or reopen this one), but the ABI issue and at least the most obvious internal usage should now be fixed.