Hi, the attached patch reduces the size of module files on disk by compressing them with zlib and storing them in the gzip format (RFC 1952). I chose zlib because it's a) ubiquitous and b) there's already a copy of zlib in the GCC source tree, so this doesn't introduce any further build dependencies. Since the mod files with the patch are in the gzip format, one can use tools like zcat, zless, zgrep, zdiff etc. to inspect the uncompressed contents easily.
As the gzip file format already contains a CRC32 checksum, the patch gets rid of the current MD5 checksumming, and instead compares the CRC32 to determine whether a mod file should be replaced or not. As the gz* functions can also handle uncompressed files, and because I replaced the line with the MD5 sum with an empty line, there was no need to bump the module version number. Based on some testing with CP2K_2009-05-01.f90 (a single file containing all of CP2K), the compile time with -fsyntax-only increased from about 46 to 48 seconds, and the total size of the module files were reduced from 124 MB to 13 MB. (IMHO the increase in compile time is modest enough that it's not worth doing the caching of uncompressed module files that I was previously thinking about, especially considering that large projects are invariably(?!) split over several source files, thereby reducing the effectiveness of such a caching scheme.) Regtested on x86_64-unknown-linux-gnu, Ok for trunk? 2013-04-09 Janne Blomqvist <j...@gcc.gnu.org> PR fortran/40958 * scanner.h: New file. * Make-lang.in: Dependencies on scanner.h. * scanner.c (gfc_directorylist): Move to scanner.h. * module.c: Don't include md5.h, include scanner.h and zlib.h. (MOD_VERSION): Add comment about backwards compatibility. (module_fp): Change type to gzFile. (ctx): Remove. (gzopen_included_file_1): New function. (gzopen_included_file): New function. (gzopen_intrinsic_module): New function. (write_char): Use gzputc. (read_crc32_from_module_file): New function. (read_md5_from_module_file): Remove. (gfc_dump_module): Use gz* functions instead of stdio, check gzip crc32 instead of md5. (read_module_to_tmpbuf): Use gz* functions instead of stdio. (gfc_use_module): Use gz* functions. testsuite: 2013-04-09 Janne Blomqvist <j...@gcc.gnu.org> PR fortran/40958 * lib/gcc-dg.exp (scan-module): Uncompress module file before scanning. * gfortran.dg/module_md5_1.f90: Remove. -- Janne Blomqvist
modzlib.diff
Description: Binary data