public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH] fixincludes breaks mingw64 build
@ 2019-05-31 13:59 Jonas Jelten
  2019-05-31 14:51 ` Jonathan Wakely
  2019-06-11 20:32 ` Bruce Korb
  0 siblings, 2 replies; 7+ messages in thread
From: Jonas Jelten @ 2019-05-31 13:59 UTC (permalink / raw)
  To: gcc-bugs, gcc-patches, bkorb

Hi!

I'm trying to build the x86_64-w64-mingw64 crosscompiler on gentoo.
 It breaks because a fixincludes-fix is applied at a place where it should not be applied.

This broke the cross-gcc build for gcc-8.3.0 and 9.1.0 with error messages that made it tricky to figure out what was
really going on.


This code snippet of mingw's stdio.h:


#ifdef _WIN64
  _CRTIMP FILE *__cdecl __iob_func(void);
#define _iob  __iob_func()
#else
[.....]
#if (!defined(NO_OLDNAMES) || defined(__GNUC__))
  __MINGW_EXTENSION typedef __int64 fpos_t;
#define _FPOSOFF(fp) ((long)(fp))


============= is modified by fixincludes to be:


#ifdef _WIN64
  _CRTIMP FILE *__cdecl __iob_func(void);
#define _iob  __iob

#  if defined(__STDC__) || defined(__cplusplus)
     extern int snprintf(char *, size_t, const char *, ...);
     extern int vsnprintf(char *, size_t, const char *, __gnuc_va_list);
#  else /* not __STDC__) || __cplusplus */
     extern int snprintf();
     extern int vsnprintf();
#  endif /* __STDC__) || __cplusplus */
_func()
#else
[....]
#if (!defined(NO_OLDNAMES) || defined(__GNUC__))
  __MINGW_EXTENSION typedef __int64 fpos_t;
#define _FPOSOFF(fp) ((long)(fp))


which leads to this compiler error:

In file included from /usr/x86_64-w64-mingw64/sys-include/_mingw.h:12,
                 from /usr/x86_64-w64-mingw64/sys-include/crtdefs.h:10,
                 from /usr/x86_64-w64-mingw64/sys-include/stddef.h:7,
                 from /tmp/portage/cross-x86_64-w64-mingw64/gcc-8.3.0-r1/work/build/gcc/include/stddef.h:1,
                 from /tmp/portage/cross-x86_64-w64-mingw64/gcc-8.3.0-r1/work/gcc-8.3.0/libgcc/../gcc/tsystem.h:44,
                 from /tmp/portage/cross-x86_64-w64-mingw64/gcc-8.3.0-r1/work/gcc-8.3.0/libgcc/libgcc2.c:27:
/tmp/portage/cross-x86_64-w64-mingw64/gcc-8.3.0-r1/work/build/gcc/include-fixed/stdio.h: In function ‘_func’:
/tmp/portage/cross-x86_64-w64-mingw64/gcc-8.3.0-r1/work/build/gcc/include-fixed/stdio.h:136:3: error: expected
declaration specifiers before ‘__extension__’
   __MINGW_EXTENSION typedef __int64 fpos_t;
   ^~~~~~~~~~~~~~~~~

and many many more follow-up errors.



A simple fix seems to be to check for a line ending in the select-regex:

Author: Jonas Jelten <jj@sft.mx>
Date:   Wed May 31 15:10:52 2019 +0200

    fixincludes: check for lineending to not break mingw64-build

--- a/fixincludes/inclhack.def  2019-05-31 15:01:31.841235934 +0200
+++ b/fixincludes/inclhack.def  2019-05-31 15:09:31.068347492 +0200
@@ -2163,7 +2163,7 @@
 fix = {
     hackname = hpux10_stdio_declarations;
     files    = stdio.h;
-    select   = "^#[ \t]*define _iob[ \t]*__iob";
+    select   = "^#[ \t]*define _iob[ \t]*__iob[ \t]*\n";
     bypass   = "^[ \t]*extern[ \t]*int[ \t]*vsnprintf[ \t]*\\(";
     c_fix     = format;
     c_fix_arg = "%0\n\n"
--- a/fixincludes/fixincl.x     2019-05-31 15:13:20.430156243 +0200
+++ b/fixincludes/fixincl.x     2019-05-31 15:13:24.953156662 +0200
@@ -4272,7 +4272,7 @@
  *  content selection pattern - do fix if pattern found
  */
 tSCC zHpux10_Stdio_DeclarationsSelect0[] =
-       "^#[ \t]*define _iob[ \t]*__iob";
+       "^#[ \t]*define _iob[ \t]*__iob[ \t]*\n";

 /*
  *  content bypass pattern - skip fix if pattern found



Cheers

-- Jonas

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2019-08-12 21:57 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-05-31 13:59 [PATCH] fixincludes breaks mingw64 build Jonas Jelten
2019-05-31 14:51 ` Jonathan Wakely
2019-05-31 15:35   ` Jonas Jelten
2019-05-31 19:48     ` Jonathan Wakely
2019-06-11 20:38       ` Bruce Korb
2019-08-12 22:09         ` Gerald Pfeifer
2019-06-11 20:32 ` Bruce Korb

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).