Libgfortran ABI cleanup TODO list
See also ArrayDescriptorUpdate, which will break the ABI and thus give the opportunity to cleanup the ABI.
Since version 4.3 libgfortran uses SymbolVersioning, so hopefully ABI compatibility can be maintained for many future releases, making life easier for our users.
However, if the ABI is ever broken, we can as well do some ABI cleanup at the same time. Here is a list of ABI cleanup projects:
- VTABLE: Use a size-type node (or at least ptrdiff_t) for "_size" instead of hard coding a kind-4 integer.
OOP: PR53971. Change the order in the CLASS container. Currently, it is: _data, _vtab. For arrays, _data is the class container. Thus, when passing an assumed/deferred-rank polymorphic array to an assumed-rank polymorphic dummy. Thus, the _data part needs to be a GFC_MAX_DIMENSIONS array - and, hence, assumed/deferred-shape arrays need to be copied to have a class container of the same size. The main reason is that class._vtab just matches "(vtab *) &class + sizeof(_data)". Hence, any attempt to change GFC_MAX_DIMENSIONS will lead to an ABI breakage. If the order in the class container were (_vtab, _data), one the dimension field of _data could be of variable length, avoiding the need for copy in and copy out. Additionally, one could later bump the maximally allowed GFC_MAX_DIMENENSIONS.
Consider removing libgfortran/intrinsics/malloc.c's _gfortran_malloc/_gfortran_free. (Cf. PR53668.They are used with Cray pointers and are identical to a simple BUILT_IN_MALLOC / BUILT_IN_FREE.)
Move the character length hindden dummy (__len) to INTEGER(8) or size_t (as Intel does)? Pro: string.h et alia use size_t, allows longer strings. Con: Breaks API for old programs. -- See also the casting/valgrind issue of PR47552.
Change ALLOCATE,INTENT(OUT) handling, cf. PR41897
Remove function wrappers if possible, cf. PR47493
Remove LEADZ and TRAILZ intrinsics, cf. patch
RECL= of the OPEN statement allows any INTEGER kind; however, effectively gfortran only supports INTEGER(4) PR44292
- Remove SHAPE/SIZE handling from the library as it is now done in the FE.
- Removing the EXPONENT, FRACTION, NEAREST, RRSPACING, SPACING, SCALE, SET_EXPONENT intrinsics. As of 2008-02-27, the frontend directly generates code to call the equivalent C99 functions and inline code to do the necessary argument massaging.
Remove old gfortran <4.6 STOP functions, which have been superseded by F2008 versions.
- Renaming the symbols for the ISO C BINDING stuff so that they are in the same _gfortran_ namespace as the rest of the library.
Remove c_f_pointer for scalars (i.e. without SHAPE=) - nowadays done in the FE. Ditto for shape=
- For many intrinsics there are multiple implementations for different argument kinds. In many cases these should be replaced by a single implementation and having the frontend convert the arguments. E.g. fseek, isatty etc. Of course intrinsics with floating point arguments or that are otherwise performance sensitive must still be kept separate. Also, it should be noted that the current system with foo_i4 and foo_i8 works for F95 where intrinsics require an integer of default kind, in F2003 this restricitons has been lifted and most intrinsics should now accept integers of any kind the compiler supports. Hence doing intrinsics the old way with separate library functions leads to a combinatorial explosion for those intrinsics with multiple integer arguments.
After the fix for PR39654, libgfortran has an unused ftell function. This one can be removed, the ftell2 function renamed to ftell, and the fronted changed to call ftell.
Somewhat unrelated: libgfortranbegin should be removed; strictly speaking this is not an ABI breakage. See PR40267
- store_exe_path() does not need to be exported from the library, and it can be made static.
- Change c_f_pointer_* calls to c_f_pointer calls with an additional sizeof() argument. That way, c_f_pointer also works for other datatypes, we save a call and remove several functions from the library.
- Combine the enum dtype (GFC_DTYPE_*) and enum bt (BT_*), perhaps using the type tags from the TR29113 descriptor. These enums are used throughout the library and the frontend too.
The front end should auto-deallcoate allocatable INTENT(OUT) variables in the callee (trans-decl.c) and not in the caller (trans-expr.c's gfc_conv_procedure_call); cf. PR41897
Font end: Remove the double-conversion of the BOUNDS of ASSUMED-SHAPE variables in the CALLER and in the CALLEE (lbounds always start at 1, unless something special is specified). Presumably not as trivial as it seems ... PR41911
Remove TRANSPOSE intrinsic, cf. patchset
- Restructure st_parameter_dt and st_parameter_common to consolidate some items, get rid of unneeded items, and figure out how to reuse the dtp structure from io call to io call so that less memory is used.
- Refactor the I/O to reduce overhead, particularly related to data_transfer_init and READ vs WRITE.
Wrong name mangling for procedure pointers PR52909