The following patch from Nidal Faour fixes LTO issues on windows.
Thanks for tracking this down. Aplied to trunk and GCC 8 branch. Richard. 2019-01-22 Nidal Faour <nidal.fa...@wdc.com> PR lto/88422 * simple-object.c (O_BINARY): Define if not already defined. (simple_object_copy_lto_debug_sections): Create file in binary mode. Index: libiberty/simple-object.c =================================================================== --- libiberty/simple-object.c (revision 268137) +++ libiberty/simple-object.c (working copy) @@ -44,6 +44,10 @@ Boston, MA 02110-1301, USA. */ #define SEEK_SET 0 #endif +#ifndef O_BINARY +#define O_BINARY 0 +#endif + #include "simple-object-common.h" /* The known object file formats. */ @@ -349,7 +353,7 @@ simple_object_copy_lto_debug_sections (s return errmsg; } - outfd = creat (dest, 00777); + outfd = open (dest, O_CREAT|O_WRONLY|O_TRUNC|O_BINARY, 00777); if (outfd == -1) { *err = errno;