Re: [PATCH] fixincludes breaks mingw64 build

2019-06-11 Thread Bruce Korb
On 5/31/19 6:35 AM, Jonas Jelten wrote:
> 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:

<>

> Author: Jonas Jelten 
> 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

Looks reasonable to me, but I don't see a test case.

> #define _iob  __iob_func()

should be added to the test code and validated that it remains
unmodified in the output.



[PATCH] fixincludes breaks mingw64 build

2019-05-31 Thread Jonas Jelten
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 
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