https://gcc.gnu.org/bugzilla/show_bug.cgi?id=56549
creeon <Dmitriy.Poterukha at uvoteam dot com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |Dmitriy.Poterukha at uvoteam dot c | |om --- Comment #8 from creeon <Dmitriy.Poterukha at uvoteam dot com> --- Here is the patch for the current master. I have tested it on large C++ code bases. So far, it builds successfully and significantly faster. diff --git a/libcpp/files.c b/libcpp/files.c index 301b2379a23..cbc2b0f4540 https://goo.gl/2DqXGj 100644 --- a/libcpp/files.c +++ b/libcpp/files.c @@ -1978,25 +1978,28 @@ _cpp_save_file_entries (cpp_reader *pfile, FILE *fp) result->entries[count].once_only = f->once_only; /* |= is avoided in the next line because of an HP C compiler bug */ result->have_once_only = result->have_once_only | f->once_only; + if (f->buffer_valid) - md5_buffer ((const char *)f->buffer, - f->st.st_size, result->entries[count].sum); + { + md5_buffer ((const char *)f->buffer, + f->st.st_size, result->entries[count].sum); + } else - { - FILE *ff; - int oldfd = f->fd; - - if (!open_file (f)) - { - open_file_failed (pfile, f, 0, 0); - free (result); - return false; - } - ff = fdopen (f->fd, "rb"); - md5_stream (ff, result->entries[count].sum); - fclose (ff); - f->fd = oldfd; - } + { + if (!read_file (pfile, f, 0)) + { + return false; + } + + md5_buffer ((const char *)f->buffer, + f->st.st_size, result->entries[count].sum); + + const void* to_free = f->buffer_start; + f->buffer_start = NULL; + f->buffer = NULL; + f->buffer_valid = false; + free ((void*) to_free); + } result->entries[count].size = f->st.st_size; } Hi how are you fixed it?