Menu

#853 MinGW-w64 8.0.0 fails with printf format errors in libgomp/target.c and libgomp/oacc-parallel.c

v1.0 (example)
open
nobody
None
5
2021-09-21
2020-09-19
No

I'm just tried to build GCC 10.2.0 against MinGW-w64 8.0.0 (in MSYS2 shell on Windows 10) and got errors about printf format using these definitions in inttypes.h:

#if defined(_UCRT) || __USE_MINGW_ANSI_STDIO
#define PRId64 "lld"
#define PRIi64 "lli"
#define PRIo64 "llo"
#define PRIu64 "llu"
#define PRIx64 "llx"
#define PRIX64 "llX"
#else
#define PRId64 "I64d"
#define PRIi64 "I64i"
#define PRIo64 "I64o"
#define PRIu64 "I64u"
#define PRIx64 "I64x"
#define PRIX64 "I64X"
#endif

It appears the definition from the first block were used, while it should have been the second block.

I was able to work around this by editing libgomp/target.c and libgomp/oacc-parallel.c replacing # include <inttypes.h> with # undef HAVE_INTTYPES_H.

I know this is a workaround, not a solution, but it does allow me to build the entire gcc toolchain.

So probably a better fix is required.

Related

Bugs: #853

Discussion

  • Brecht Sanders

    Brecht Sanders - 2020-09-19

    Similar issues building win64 build of pkg-config.

    There I got it to build by adding #define __USE_MINGW_ANSI_STDIO 0 at the top of glib/glib/gslice.c.

    Did something change to the definition of __USE_MINGW_ANSI_STDIO in MinGW-w64 v8.0.0?

     
  • mark

    mark - 2020-09-20

    It looks to me like the relevant change was bfd33f6c0ec5e652cc9911857dd1492ece8d8383 (later modified by 8649bf9ef600e78da2396a99a0c6e2941a82d809).

    I wonder if
    __MSVCRT_VERSION__ < 0xE00
    should be
    __MSVCRT_VERSION__ >= 0xE00

    See https://sourceforge.net/p/mingw-w64/mingw-w64/ci/8649bf9ef600e78da2396a99a0c6e2941a82d809/

     

    Last edit: mark 2020-09-20
    • Kai Tietz

      Kai Tietz - 2020-09-28

      Hello,

      Sorry for telling you, but your assumptions about passing va_list as
      argument, and how it behalfs is plain wrong. So your test-code is
      invalid. Why you assume that a local variable va is modified under
      the hood by a different function? As long as you don't pass reference
      to it, you are not able to modify its contents for an outer function.

      int foo(va_list argp)
      {
      return va_arg(argp, int);
      }

      void zoo(const char *fmt, ...)
      {
      va_list argp;
      argp=va_start(argp, fmt);
      fprintf(stderr, fmt, foo(argp), foo(argp));
      }

      int main()
      {
      zoo("%d", 12, 64);
      return 0;
      }

      will of course display 24, and not - as you were assuming - 76. Btw
      it is absolutely irrelevant how many subs you are putting here
      inbetween of zoo and foo ...

      Cheers,
      Kai

      Am So., 20. Sept. 2020 um 13:17 Uhr schrieb mark
      mabrand@users.sourceforge.net:

      It looks to me like the relevant change was bfd33f6c0ec5e652cc9911857dd1492ece8d8383 (later modified by 8649bf9ef600e78da2396a99a0c6e2941a82d809).

      I wonder if
      MSVCRT_VERSION < 0xE00
      should be
      MSVCRT_VERSION >= 0xE00


      [bugs:#853] MinGW-w64 8.0.0 fails with printf format errors in libgomp/target.c and libgomp/oacc-parallel.c

      Status: open
      Group: v1.0 (example)
      Created: Sat Sep 19, 2020 11:56 AM UTC by Brecht Sanders
      Last Updated: Sat Sep 19, 2020 01:29 PM UTC
      Owner: nobody

      I'm just tried to build GCC 10.2.0 against MinGW-w64 8.0.0 (in MSYS2 shell on Windows 10) and got errors about printf format using these definitions in inttypes.h:

      if defined(_UCRT) || __USE_MINGW_ANSI_STDIO

      define PRId64 "lld"

      define PRIi64 "lli"

      define PRIo64 "llo"

      define PRIu64 "llu"

      define PRIx64 "llx"

      define PRIX64 "llX"

      else

      define PRId64 "I64d"

      define PRIi64 "I64i"

      define PRIo64 "I64o"

      define PRIu64 "I64u"

      define PRIx64 "I64x"

      define PRIX64 "I64X"

      endif

      It appears the definition from the first block were used, while it should have been the second block.

      I was able to work around this by editing libgomp/target.c and libgomp/oacc-parallel.c replacing # include <inttypes.h> with # undef HAVE_INTTYPES_H.</inttypes.h>

      I know this is a workaround, not a solution, but it does allow me to build the entire gcc toolchain.

      So probably a better fix is required.


      Sent from sourceforge.net because you indicated interest in https://sourceforge.net/p/mingw-w64/bugs/853/

      To unsubscribe from further messages, please visit https://sourceforge.net/auth/subscriptions/

       

      Related

      Bugs: #853

  • Brecht Sanders

    Brecht Sanders - 2020-09-28

    @ktietz70 I'm sorry, but I'm not following where you think this wrong assumtion was made. Is this in both gcc and pkg-config source code? Or are you referring to some other code?

     
    • Kai Tietz

      Kai Tietz - 2020-09-28

      Hmm, sorry. I mixed your report up. There was another report with
      code sample, which claimed that va_list would be broken.

      Sorry about that. Nevertheless you should report this to gcc people
      too. As it is more a target-library issue in gcc AFAICS.

      Regards,
      Kai

      Am Mo., 28. Sept. 2020 um 15:27 Uhr schrieb Brecht Sanders
      brechtsanders@users.sourceforge.net:

      @ktietz70 I'm sorry, but I'm not following where you think this wrong assumtion was made. Is this in both gcc and pkg-config source code? Or are you referring to some other code?


      [bugs:#853] MinGW-w64 8.0.0 fails with printf format errors in libgomp/target.c and libgomp/oacc-parallel.c

      Status: open
      Group: v1.0 (example)
      Created: Sat Sep 19, 2020 11:56 AM UTC by Brecht Sanders
      Last Updated: Sun Sep 20, 2020 11:16 AM UTC
      Owner: nobody

      I'm just tried to build GCC 10.2.0 against MinGW-w64 8.0.0 (in MSYS2 shell on Windows 10) and got errors about printf format using these definitions in inttypes.h:

      if defined(_UCRT) || __USE_MINGW_ANSI_STDIO

      define PRId64 "lld"

      define PRIi64 "lli"

      define PRIo64 "llo"

      define PRIu64 "llu"

      define PRIx64 "llx"

      define PRIX64 "llX"

      else

      define PRId64 "I64d"

      define PRIi64 "I64i"

      define PRIo64 "I64o"

      define PRIu64 "I64u"

      define PRIx64 "I64x"

      define PRIX64 "I64X"

      endif

      It appears the definition from the first block were used, while it should have been the second block.

      I was able to work around this by editing libgomp/target.c and libgomp/oacc-parallel.c replacing # include <inttypes.h> with # undef HAVE_INTTYPES_H.</inttypes.h>

      I know this is a workaround, not a solution, but it does allow me to build the entire gcc toolchain.

      So probably a better fix is required.


      Sent from sourceforge.net because you indicated interest in https://sourceforge.net/p/mingw-w64/bugs/853/

      To unsubscribe from further messages, please visit https://sourceforge.net/auth/subscriptions/

       

      Related

      Bugs: #853

  • Brecht Sanders

    Brecht Sanders - 2020-10-16

    Is there any progress on this issue?

     

Log in to post a comment.

MongoDB Logo MongoDB