Bug 64972 - [5 Regression] Build failure in libgomp for i686-w64-mingw32 target after latest merge from gomp-4_0-branch
Summary: [5 Regression] Build failure in libgomp for i686-w64-mingw32 target after lat...
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: libgomp (show other bugs)
Version: 5.0
: P1 critical
Target Milestone: 5.0
Assignee: Not yet assigned to anyone
URL:
Keywords: build, openacc
Depends on:
Blocks:
 
Reported: 2015-02-08 13:43 UTC by Erik van Pienbroek
Modified: 2015-03-25 15:07 UTC (History)
4 users (show)

See Also:
Host:
Target: i686-w64-mingw32
Build:
Known to work: 4.9.3
Known to fail: 5.0
Last reconfirmed: 2015-02-11 00:00:00


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Erik van Pienbroek 2015-02-08 13:43:38 UTC
Recent snapshots of gcc 5 can not be built any more for the i686-w64-mingw32 target:

make[4]: Entering directory
'/home/erik/fedora/mingw-gcc/gcc-5-20150125/build_win32/i686-w64-mingw32/libgomp'
/bin/sh ./libtool --tag=CC
--mode=compile /home/erik/fedora/mingw-gcc/gcc-5-20150125/build_win32/./gcc/xgcc -B/home/erik/fedora/mingw-gcc/gcc-5-20150125/build_win32/./gcc/ -L/usr/i686-w64-mingw32/lib -L/usr/mingw/lib -isystem /usr/i686-w64-mingw32/include -isystem /usr/mingw/include -B/usr/i686-w64-mingw32/bin/ -B/usr/i686-w64-mingw32/lib/ -isystem /usr/i686-w64-mingw32/include -isystem /usr/i686-w64-mingw32/sys-include    -DHAVE_CONFIG_H -I. -I../../../libgomp  -I../../../libgomp/config/mingw32 -I../../../libgomp/config/posix -I../../../libgomp -I../../../libgomp/../include  -Wall -Werror -Wc,-pthread -g -O2 -MT target.lo -MD -MP -MF .deps/target.Tpo -c -o target.lo ../../../libgomp/target.c
libtool:
compile:  /home/erik/fedora/mingw-gcc/gcc-5-20150125/build_win32/./gcc/xgcc -B/home/erik/fedora/mingw-gcc/gcc-5-20150125/build_win32/./gcc/ -L/usr/i686-w64-mingw32/lib -L/usr/mingw/lib -isystem /usr/i686-w64-mingw32/include -isystem /usr/mingw/include -B/usr/i686-w64-mingw32/bin/ -B/usr/i686-w64-mingw32/lib/ -isystem /usr/i686-w64-mingw32/include -isystem /usr/i686-w64-mingw32/sys-include -DHAVE_CONFIG_H -I. -I../../../libgomp -I../../../libgomp/config/mingw32 -I../../../libgomp/config/posix -I../../../libgomp -I../../../libgomp/../include -Wall -pthread -Werror -g -O2 -MT target.lo -MD -MP -MF .deps/target.Tpo -c ../../../libgomp/target.c  -DDLL_EXPORT -DPIC -o .libs/target.o
../../../libgomp/target.c: In function 'gomp_map_vars':
../../../libgomp/target.c:440:21: error: unknown conversion type
character 'z' in format [-Werror=format=]
         gomp_fatal ("present clause: !acc_is_present (%p, "
                     ^
../../../libgomp/target.c:440:21: error: unknown conversion type
character 'z' in format [-Werror=format=]
../../../libgomp/target.c:440:21: error: too many arguments for format
[-Werror=format-extra-args]
cc1: all warnings being treated as errors
Makefile:613: recipe for target 'target.lo' failed
make[4]: *** [target.lo] Error 1
make[4]: Leaving directory
'/home/erik/fedora/mingw-gcc/gcc-5-20150125/build_win32/i686-w64-mingw32/libgomp'


The offending line contains this piece of code:
    gomp_fatal ("present clause: !acc_is_present (%p, "
                "%zd (0x%zx))", (void *) k->host_start,
                size, size);

This piece of code was introduced in r219682 which was applied on January 15 2015.

This issue was also discussed at the mingw-w64 mailing list @  http://sourceforge.net/p/mingw-w64/mailman/mingw-w64-public/thread/54CD7703.8080206@users.sourceforge.net/ and also contains some possible solutions
Comment 1 Kai Tietz 2015-02-11 15:54:32 UTC
Confirmed.  '%z' isn't valid for msvcrt as width-specifier.
Shouldn't we use here instead inttypes.h header and PRIxPTR?
Comment 2 Rainer Emrich 2015-03-24 07:09:22 UTC
Issue exists for target x86_64-w64-mingw32 too.
By the way, this is a regression.
At the moment gcc doesn't build for the *-w64-mingw32 targets.
Comment 3 Kai Tietz 2015-03-24 07:41:56 UTC
Issue is that libgomp uses gnu-style printf formatters without checking, if formatter is available on that platform.

Due it operates on size_t, the defines provided by inttypes.h are of not much help.
Comment 4 Jakub Jelinek 2015-03-24 07:50:10 UTC
And the suggested fix is just to cast to unsigned long and use %ld or %lx instead of %zd and %zx.  I can't test it on these targets, so it is better if somebody with M$ access writes and tests the patch.
Comment 5 Rainer Emrich 2015-03-24 10:46:03 UTC
(In reply to Jakub Jelinek from comment #4)
> And the suggested fix is just to cast to unsigned long and use %ld or %lx
> instead of %zd and %zx.  I can't test it on these targets, so it is better
> if somebody with M$ access writes and tests the patch.

Index: target.c
===================================================================
--- target.c    (Revision 221607)
+++ target.c    (Arbeitskopie)
@@ -439,8 +439,8 @@ gomp_map_vars (struct gomp_device_descr
                         was missing.  */
                      size_t size = k->host_end - k->host_start;
                      gomp_fatal ("present clause: !acc_is_present (%p, "
-                                 "%zd (0x%zx))", (void *) k->host_start,
-                                 size, size);
+                                 "%ld (0x%lx))", (void *) k->host_start,
+                                 (unsigned long) size, (unsigned long) size);
                    }
                    break;
                  case GOMP_MAP_FORCE_DEVICEPTR:

Something like this? At least that builds on x86_64-w64-mingw32.

But there is another issue with formatters in oacc-parallel.c.
Shall I append to this bug or open a new one?
Comment 6 Jakub Jelinek 2015-03-24 10:51:38 UTC
(In reply to Rainer Emrich from comment #5)
> (In reply to Jakub Jelinek from comment #4)
> > And the suggested fix is just to cast to unsigned long and use %ld or %lx
> > instead of %zd and %zx.  I can't test it on these targets, so it is better
> > if somebody with M$ access writes and tests the patch.
> 
> Index: target.c
> ===================================================================
> --- target.c    (Revision 221607)
> +++ target.c    (Arbeitskopie)
> @@ -439,8 +439,8 @@ gomp_map_vars (struct gomp_device_descr
>                          was missing.  */
>                       size_t size = k->host_end - k->host_start;
>                       gomp_fatal ("present clause: !acc_is_present (%p, "
> -                                 "%zd (0x%zx))", (void *) k->host_start,
> -                                 size, size);
> +                                 "%ld (0x%lx))", (void *) k->host_start,
> +                                 (unsigned long) size, (unsigned long)
> size);
>                     }
>                     break;
>                   case GOMP_MAP_FORCE_DEVICEPTR:
> 
> Something like this? At least that builds on x86_64-w64-mingw32.

Yeah.

> But there is another issue with formatters in oacc-parallel.c.
> Shall I append to this bug or open a new one?

Please don't create a new bug, it is the same thing.
Comment 7 Rainer Emrich 2015-03-24 11:04:02 UTC
Ok, here's the additional issue in oacc-parallel.c.

libtool: compile:  /opt/devel/SCRATCH/tmp.UotBZukqBt/gcc-5.0.0/gcc-5.0.0/./gcc/xgcc -B/opt/devel/SCRATCH/tmp.UotBZukqBt/gcc-5.0.0/gcc-5.0.0/./gcc/ -L/opt/devel/gnu/gcc/MINGW_NT/x86_64-w64-mingw32/mingw-w64-runtime-trunk-svn/gcc-5.0.0/x86_64-w64-mingw32/lib -L/opt/devel/gnu/gcc/MINGW_NT/x86_64-w64-mingw32/mingw-w64-runtime-trunk-svn/gcc-5.0.0/mingw/lib -isystem /opt/devel/gnu/gcc/MINGW_NT/x86_64-w64-mingw32/mingw-w64-runtime-trunk-svn/gcc-5.0.0/x86_64-w64-mingw32/include -isystem /opt/devel/gnu/gcc/MINGW_NT/x86_64-w64-mingw32/mingw-w64-runtime-trunk-svn/gcc-5.0.0/mingw/include -B/opt/devel/gnu/gcc/MINGW_NT/x86_64-w64-mingw32/mingw-w64-runtime-trunk-svn/gcc-5.0.0/x86_64-w64-mingw32/bin/ -B/opt/devel/gnu/gcc/MINGW_NT/x86_64-w64-mingw32/mingw-w64-runtime-trunk-svn/gcc-5.0.0/x86_64-w64-mingw32/lib/ -isystem /opt/devel/gnu/gcc/MINGW_NT/x86_64-w64-mingw32/mingw-w64-runtime-trunk-svn/gcc-5.0.0/x86_64-w64-mingw32/include -isystem /opt/devel/gnu/gcc/MINGW_NT/x86_64-w64-mingw32/mingw-w64-runtime-trunk-svn/gcc-5.0.0/x86_64-w64-mingw32/sys-include -DHAVE_CONFIG_H -I. -I../../../../../../../../opt/devel/gnu/src/gcc-mingw-w64/gcc-5.0.0/libgomp -I../../../../../../../../opt/devel/gnu/src/gcc-mingw-w64/gcc-5.0.0/libgomp/config/mingw32 -I../../../../../../../../opt/devel/gnu/src/gcc-mingw-w64/gcc-5.0.0/libgomp/config/posix -I../../../../../../../../opt/devel/gnu/src/gcc-mingw-w64/gcc-5.0.0/libgomp -I../../../../../../../../opt/devel/gnu/src/gcc-mingw-w64/gcc-5.0.0/libgomp/../include -Wall -pthread -Werror -g -O2 -MT oacc-parallel.lo -MD -MP -MF .deps/oacc-parallel.Tpo -c ../../../../../../../../opt/devel/gnu/src/gcc-mingw-w64/gcc-5.0.0/libgomp/oacc-parallel.c  -DDLL_EXPORT -DPIC -o .libs/oacc-parallel.o
In file included from ../../../../../../../../opt/devel/gnu/src/gcc-mingw-w64/gcc-5.0.0/libgomp/oacc-parallel.c:30:0:
../../../../../../../../opt/devel/gnu/src/gcc-mingw-w64/gcc-5.0.0/libgomp/oacc-parallel.c: In function 'GOACC_parallel':
../../../../../../../../opt/devel/gnu/src/gcc-mingw-w64/gcc-5.0.0/libgomp/oacc-parallel.c:102:18: error: unknown conversion type character 'z' in format [-Werror=format=]
   gomp_debug (0, "%s: mapnum=%zd, hostaddrs=%p, sizes=%p, kinds=%p, async=%d\n",
                  ^
d:\opt\devel\gnu\src\gcc-mingw-w64\gcc-5.0.0\libgomp\libgomp.h:554:29: note: in definition of macro 'gomp_debug'
       (gomp_debug) ((KIND), __VA_ARGS__); \
                             ^
../../../../../../../../opt/devel/gnu/src/gcc-mingw-w64/gcc-5.0.0/libgomp/oacc-parallel.c:102:18: error: format '%p' expects argument of type 'void *', but argument 4 has type 'size_t {aka long long unsigned int}' [-Werror=format=]
   gomp_debug (0, "%s: mapnum=%zd, hostaddrs=%p, sizes=%p, kinds=%p, async=%d\n",
                  ^
d:\opt\devel\gnu\src\gcc-mingw-w64\gcc-5.0.0\libgomp\libgomp.h:554:29: note: in definition of macro 'gomp_debug'
       (gomp_debug) ((KIND), __VA_ARGS__); \
                             ^
../../../../../../../../opt/devel/gnu/src/gcc-mingw-w64/gcc-5.0.0/libgomp/oacc-parallel.c:102:18: error: format '%d' expects argument of type 'int', but argument 7 has type 'short unsigned int *' [-Werror=format=]
   gomp_debug (0, "%s: mapnum=%zd, hostaddrs=%p, sizes=%p, kinds=%p, async=%d\n",
                  ^
d:\opt\devel\gnu\src\gcc-mingw-w64\gcc-5.0.0\libgomp\libgomp.h:554:29: note: in definition of macro 'gomp_debug'
       (gomp_debug) ((KIND), __VA_ARGS__); \
                             ^
../../../../../../../../opt/devel/gnu/src/gcc-mingw-w64/gcc-5.0.0/libgomp/oacc-parallel.c:102:18: error: too many arguments for format [-Werror=format-extra-args]
   gomp_debug (0, "%s: mapnum=%zd, hostaddrs=%p, sizes=%p, kinds=%p, async=%d\n",
                  ^
d:\opt\devel\gnu\src\gcc-mingw-w64\gcc-5.0.0\libgomp\libgomp.h:554:29: note: in definition of macro 'gomp_debug'
       (gomp_debug) ((KIND), __VA_ARGS__); \
                             ^
../../../../../../../../opt/devel/gnu/src/gcc-mingw-w64/gcc-5.0.0/libgomp/oacc-parallel.c: In function 'GOACC_data_start':
../../../../../../../../opt/devel/gnu/src/gcc-mingw-w64/gcc-5.0.0/libgomp/oacc-parallel.c:181:18: error: unknown conversion type character 'z' in format [-Werror=format=]
   gomp_debug (0, "%s: mapnum=%zd, hostaddrs=%p, sizes=%p, kinds=%p\n",
                  ^
d:\opt\devel\gnu\src\gcc-mingw-w64\gcc-5.0.0\libgomp\libgomp.h:554:29: note: in definition of macro 'gomp_debug'
       (gomp_debug) ((KIND), __VA_ARGS__); \
                             ^
../../../../../../../../opt/devel/gnu/src/gcc-mingw-w64/gcc-5.0.0/libgomp/oacc-parallel.c:181:18: error: format '%p' expects argument of type 'void *', but argument 4 has type 'size_t {aka long long unsigned int}' [-Werror=format=]
   gomp_debug (0, "%s: mapnum=%zd, hostaddrs=%p, sizes=%p, kinds=%p\n",
                  ^
d:\opt\devel\gnu\src\gcc-mingw-w64\gcc-5.0.0\libgomp\libgomp.h:554:29: note: in definition of macro 'gomp_debug'
       (gomp_debug) ((KIND), __VA_ARGS__); \
                             ^
../../../../../../../../opt/devel/gnu/src/gcc-mingw-w64/gcc-5.0.0/libgomp/oacc-parallel.c:181:18: error: too many arguments for format [-Werror=format-extra-args]
   gomp_debug (0, "%s: mapnum=%zd, hostaddrs=%p, sizes=%p, kinds=%p\n",
                  ^
d:\opt\devel\gnu\src\gcc-mingw-w64\gcc-5.0.0\libgomp\libgomp.h:554:29: note: in definition of macro 'gomp_debug'
       (gomp_debug) ((KIND), __VA_ARGS__); \
                             ^
cc1.exe: all warnings being treated as errors


Issue at these two locations:

lines 102,103:
  gomp_debug (0, "%s: mapnum=%zd, hostaddrs=%p, sizes=%p, kinds=%p, async=%d\n",
              __FUNCTION__, mapnum, hostaddrs, sizes, kinds, async);

lines 181,182:
  gomp_debug (0, "%s: mapnum=%zd, hostaddrs=%p, sizes=%p, kinds=%p\n",
              __FUNCTION__, mapnum, hostaddrs, sizes, kinds);
Comment 8 Rainer Emrich 2015-03-24 11:40:54 UTC
I'm testing the following on x86_64-w64-mingw32 at the moment.

Index: oacc-parallel.c
===================================================================
--- oacc-parallel.c     (Revision 221607)
+++ oacc-parallel.c     (Arbeitskopie)
@@ -99,8 +99,9 @@ GOACC_parallel (int device, void (*fn) (
     gomp_fatal ("num_workers (%d) different from one is not yet supported",
                num_workers);

-  gomp_debug (0, "%s: mapnum=%zd, hostaddrs=%p, sizes=%p, kinds=%p, async=%d\n",
-             __FUNCTION__, mapnum, hostaddrs, sizes, kinds, async);
+  gomp_debug (0, "%s: mapnum=%ld, hostaddrs=%p, sizes=%p, kinds=%p, async=%d\n",
+             __FUNCTION__, (unsigned long) mapnum, (void *) hostaddrs,
+             sizes, kinds, (int) async);

   select_acc_device (device);

@@ -178,8 +179,9 @@ GOACC_data_start (int device, size_t map
   bool host_fallback = device == GOMP_DEVICE_HOST_FALLBACK;
   struct target_mem_desc *tgt;

-  gomp_debug (0, "%s: mapnum=%zd, hostaddrs=%p, sizes=%p, kinds=%p\n",
-             __FUNCTION__, mapnum, hostaddrs, sizes, kinds);
+  gomp_debug (0, "%s: mapnum=%ld, hostaddrs=%p, sizes=%p, kinds=%p\n",
+             __FUNCTION__, (unsigned long) mapnum, (void *) hostaddrs,
+             sizes, kinds);

   select_acc_device (device);

Index: target.c
===================================================================
--- target.c    (Revision 221607)
+++ target.c    (Arbeitskopie)
@@ -439,8 +439,8 @@ gomp_map_vars (struct gomp_device_descr
                         was missing.  */
                      size_t size = k->host_end - k->host_start;
                      gomp_fatal ("present clause: !acc_is_present (%p, "
-                                 "%zd (0x%zx))", (void *) k->host_start,
-                                 size, size);
+                                 "%ld (0x%lx))", (void *) k->host_start,
+                                 (unsigned long) size, (unsigned long) size);
                    }
                    break;
                  case GOMP_MAP_FORCE_DEVICEPTR:
Comment 9 Mikael Pettersson 2015-03-24 14:53:58 UTC
Please note that sizeof(long) == 4 while sizeof(size_t) == sizeof(void*) == 8 on x86_64-w64-mingw32, so your patch changes the behaviour of the code.  Perhaps the change is benign, but I'd use uintptr_t and PRIxPTR.
Comment 10 Kai Tietz 2015-03-24 15:23:50 UTC
I agree that suggested patch changes here behavior on non LP64 targets.  Nevertheless it would be something to live by until we reach stage 1 to address this more accurate.
To us uintptr_t is by idea ok, just have the weakness that size_t not necessarily has same precision as uintptr_t.  If gomp maintainer will say that inttypes.h header use and casting to uintptr_t would be ok for them, I agree.

A real solution would be to add in configure a test for used size_t printf-formatter sign, and then use it in source.  For gnu-style width-specifier is 'z', for ms-style it is 'I'.
Comment 11 Jakub Jelinek 2015-03-24 15:30:44 UTC
I wouldn't call %zd gnu-style, as it is POSIX.
Anyway, libgomp already uses inttypes.h, but only conditionally:
#ifdef HAVE_INTTYPES_H
      fprintf (stderr, "  GOMP_SPINCOUNT = '%"PRIu64"'\n",
               (uint64_t) gomp_spin_count_var);
#else
      fprintf (stderr, "  GOMP_SPINCOUNT = '%lu'\n",
               (unsigned long) gomp_spin_count_var);
#endif
So, if you'd like to do the same (but then cast to uint64_t and use PRIu64, dunno how portable is PRIuPTR compared to PRIu64), that is also an option,
but IMNSHO not worth the trouble.
All these messages are unimportant OpenACC debugging messages or a fancy abort that will very likely not have sizes of anything > 2GB - trying to offload 2GB+ of data to offloading device in one chunk is hardly a case to worry about.
Comment 12 Thomas Schwinge 2015-03-24 17:48:10 UTC
Sorry for introducing this breakage; and thanks for working on fixing it.

(In reply to Jakub Jelinek from comment #11)
> I wouldn't call %zd gnu-style, as it is POSIX.
> Anyway, libgomp already uses inttypes.h, but only conditionally:
> #ifdef HAVE_INTTYPES_H
>       fprintf (stderr, "  GOMP_SPINCOUNT = '%"PRIu64"'\n",
>                (uint64_t) gomp_spin_count_var);
> #else
>       fprintf (stderr, "  GOMP_SPINCOUNT = '%lu'\n",
>                (unsigned long) gomp_spin_count_var);
> #endif
> So, if you'd like to do the same (but then cast to uint64_t and use PRIu64,
> dunno how portable is PRIuPTR compared to PRIu64), that is also an option,
> but IMNSHO not worth the trouble.
> All these messages are unimportant OpenACC debugging messages or a fancy
> abort that will very likely not have sizes of anything > 2GB - trying to
> offload 2GB+ of data to offloading device in one chunk is hardly a case to
> worry about.

..., and »640 K ought to be enough for anybody«?  ;-)

Please do not change the code -- even if only "unimportant" debugging messages -- so that it might print incorrect data.
Comment 13 Kai Tietz 2015-03-24 19:26:54 UTC
Rainer: does following patch works for you?

Index: oacc-parallel.c
===================================================================
--- oacc-parallel.c	(Revision 221640)
+++ oacc-parallel.c	(Arbeitskopie)
@@ -31,6 +31,9 @@
 #include "libgomp_g.h"
 #include "gomp-constants.h"
 #include "oacc-int.h"
+#ifdef HAVE_INTTYPES_H
+# include <inttypes.h>  /* For PRIu64.  */
+#endif
 #include <string.h>
 #include <stdarg.h>
 #include <assert.h>
@@ -99,9 +102,14 @@ GOACC_parallel (int device, void (*fn) (void *),
     gomp_fatal ("num_workers (%d) different from one is not yet supported",
 		num_workers);
 
+#ifdef HAVE_INTTYPES_H
+  gomp_debug (0, "%s: mapnum=%"PRIu64", hostaddrs=%p, size=%p, kinds=%p, "
+		 "async = %d\n",
+	      __FUNCTION__, (uint64_t) mapnum, hostaddrs, sizes, kinds, async);
+#else
   gomp_debug (0, "%s: mapnum=%zd, hostaddrs=%p, sizes=%p, kinds=%p, async=%d\n",
 	      __FUNCTION__, mapnum, hostaddrs, sizes, kinds, async);
-
+#endif
   select_acc_device (device);
 
   thr = goacc_thread ();
@@ -178,8 +186,13 @@ GOACC_data_start (int device, size_t mapnum,
   bool host_fallback = device == GOMP_DEVICE_HOST_FALLBACK;
   struct target_mem_desc *tgt;
 
+#ifdef HAVE_INTTYPES_H
+  gomp_debug (0, "%s: mapnum=%"PRIu64", hostaddrs=%p, size=%p, kinds=%p\n",
+	      __FUNCTION__, (uint64_t) mapnum, hostaddrs, sizes, kinds);
+#else
   gomp_debug (0, "%s: mapnum=%zd, hostaddrs=%p, sizes=%p, kinds=%p\n",
 	      __FUNCTION__, mapnum, hostaddrs, sizes, kinds);
+#endif
 
   select_acc_device (device);
 
Index: target.c
===================================================================
--- target.c	(Revision 221640)
+++ target.c	(Arbeitskopie)
@@ -33,6 +33,9 @@
 #include <limits.h>
 #include <stdbool.h>
 #include <stdlib.h>
+#ifdef HAVE_INTTYPES_H
+# include <inttypes.h>  /* For PRIu64.  */
+#endif
 #include <string.h>
 #include <assert.h>
 
@@ -438,9 +441,16 @@ gomp_map_vars (struct gomp_device_descr *devicep,
 		      /* We already looked up the memory region above and it
 			 was missing.  */
 		      size_t size = k->host_end - k->host_start;
+#ifdef HAVE_INTTYPES_H
 		      gomp_fatal ("present clause: !acc_is_present (%p, "
+				  PRIu64" (0x"PRIx64"))",
+				  (void *) k->host_start,
+				  (uint64_t) size, (uint64_t) size);
+#else
+		      gomp_fatal ("present clause: !acc_is_present (%p, "
 				  "%zd (0x%zx))", (void *) k->host_start,
 				  size, size);
+#endif
 		    }
 		    break;
 		  case GOMP_MAP_FORCE_DEVICEPTR:
Comment 14 Jakub Jelinek 2015-03-24 19:49:13 UTC
(In reply to Kai Tietz from comment #13)
> Rainer: does following patch works for you?
> 
> Index: oacc-parallel.c
> ===================================================================
> --- oacc-parallel.c	(Revision 221640)
> +++ oacc-parallel.c	(Arbeitskopie)
> @@ -31,6 +31,9 @@
>  #include "libgomp_g.h"
>  #include "gomp-constants.h"
>  #include "oacc-int.h"
> +#ifdef HAVE_INTTYPES_H
> +# include <inttypes.h>  /* For PRIu64.  */
> +#endif
>  #include <string.h>
>  #include <stdarg.h>
>  #include <assert.h>
> @@ -99,9 +102,14 @@ GOACC_parallel (int device, void (*fn) (void *),
>      gomp_fatal ("num_workers (%d) different from one is not yet supported",
>  		num_workers);
>  
> +#ifdef HAVE_INTTYPES_H
> +  gomp_debug (0, "%s: mapnum=%"PRIu64", hostaddrs=%p, size=%p, kinds=%p, "
> +		 "async = %d\n",
> +	      __FUNCTION__, (uint64_t) mapnum, hostaddrs, sizes, kinds, async);
> +#else
>    gomp_debug (0, "%s: mapnum=%zd, hostaddrs=%p, sizes=%p, kinds=%p,
> async=%d\n",
>  	      __FUNCTION__, mapnum, hostaddrs, sizes, kinds, async);
> -
> +#endif
>    select_acc_device (device);
>  
>    thr = goacc_thread ();
> @@ -178,8 +186,13 @@ GOACC_data_start (int device, size_t mapnum,
>    bool host_fallback = device == GOMP_DEVICE_HOST_FALLBACK;
>    struct target_mem_desc *tgt;
>  
> +#ifdef HAVE_INTTYPES_H
> +  gomp_debug (0, "%s: mapnum=%"PRIu64", hostaddrs=%p, size=%p, kinds=%p\n",
> +	      __FUNCTION__, (uint64_t) mapnum, hostaddrs, sizes, kinds);
> +#else
>    gomp_debug (0, "%s: mapnum=%zd, hostaddrs=%p, sizes=%p, kinds=%p\n",
>  	      __FUNCTION__, mapnum, hostaddrs, sizes, kinds);
> +#endif
>  
>    select_acc_device (device);
>  
> Index: target.c
> ===================================================================
> --- target.c	(Revision 221640)
> +++ target.c	(Arbeitskopie)
> @@ -33,6 +33,9 @@
>  #include <limits.h>
>  #include <stdbool.h>
>  #include <stdlib.h>
> +#ifdef HAVE_INTTYPES_H
> +# include <inttypes.h>  /* For PRIu64.  */
> +#endif
>  #include <string.h>
>  #include <assert.h>
>  
> @@ -438,9 +441,16 @@ gomp_map_vars (struct gomp_device_descr *devicep,
>  		      /* We already looked up the memory region above and it
>  			 was missing.  */
>  		      size_t size = k->host_end - k->host_start;
> +#ifdef HAVE_INTTYPES_H
>  		      gomp_fatal ("present clause: !acc_is_present (%p, "
> +				  PRIu64" (0x"PRIx64"))",
> +				  (void *) k->host_start,
> +				  (uint64_t) size, (uint64_t) size);
> +#else
> +		      gomp_fatal ("present clause: !acc_is_present (%p, "
>  				  "%zd (0x%zx))", (void *) k->host_start,
>  				  size, size);
> +#endif
>  		    }
>  		    break;
>  		  case GOMP_MAP_FORCE_DEVICEPTR:

The fallback case really should use %ld or %lx and casts to (unsigned long).
Targets that have inttypes.h will (with the exception of M$ targets) likely also support %zd / %zx.
Comment 15 Kai Tietz 2015-03-24 20:13:02 UTC
Ok, I am fine.  So patch should be something like:

Index: oacc-parallel.c
===================================================================
--- oacc-parallel.c	(Revision 221640)
+++ oacc-parallel.c	(Arbeitskopie)
@@ -31,6 +31,9 @@
 #include "libgomp_g.h"
 #include "gomp-constants.h"
 #include "oacc-int.h"
+#ifdef HAVE_INTTYPES_H
+# include <inttypes.h>  /* For PRIu64.  */
+#endif
 #include <string.h>
 #include <stdarg.h>
 #include <assert.h>
@@ -99,9 +102,15 @@ GOACC_parallel (int device, void (*fn) (void *),
     gomp_fatal ("num_workers (%d) different from one is not yet supported",
 		num_workers);
 
-  gomp_debug (0, "%s: mapnum=%zd, hostaddrs=%p, sizes=%p, kinds=%p, async=%d\n",
-	      __FUNCTION__, mapnum, hostaddrs, sizes, kinds, async);
-
+#ifdef HAVE_INTTYPES_H
+  gomp_debug (0, "%s: mapnum=%"PRIu64", hostaddrs=%p, size=%p, kinds=%p, "
+		 "async = %d\n",
+	      __FUNCTION__, (uint64_t) mapnum, hostaddrs, sizes, kinds, async);
+#else
+  gomp_debug (0, "%s: mapnum=%lu, hostaddrs=%p, sizes=%p, kinds=%p, async=%d\n",
+	      __FUNCTION__, (unsigned long) mapnum, hostaddrs, sizes, kinds,
+	      async);
+#endif
   select_acc_device (device);
 
   thr = goacc_thread ();
@@ -178,8 +187,13 @@ GOACC_data_start (int device, size_t mapnum,
   bool host_fallback = device == GOMP_DEVICE_HOST_FALLBACK;
   struct target_mem_desc *tgt;
 
-  gomp_debug (0, "%s: mapnum=%zd, hostaddrs=%p, sizes=%p, kinds=%p\n",
-	      __FUNCTION__, mapnum, hostaddrs, sizes, kinds);
+#ifdef HAVE_INTTYPES_H
+  gomp_debug (0, "%s: mapnum=%"PRIu64", hostaddrs=%p, size=%p, kinds=%p\n",
+	      __FUNCTION__, (uint64_t) mapnum, hostaddrs, sizes, kinds);
+#else
+  gomp_debug (0, "%s: mapnum=%lu, hostaddrs=%p, sizes=%p, kinds=%p\n",
+	      __FUNCTION__, (unsigned long) mapnum, hostaddrs, sizes, kinds);
+#endif
 
   select_acc_device (device);
 
Index: target.c
===================================================================
--- target.c	(Revision 221640)
+++ target.c	(Arbeitskopie)
@@ -33,6 +33,9 @@
 #include <limits.h>
 #include <stdbool.h>
 #include <stdlib.h>
+#ifdef HAVE_INTTYPES_H
+# include <inttypes.h>  /* For PRIu64.  */
+#endif
 #include <string.h>
 #include <assert.h>
 
@@ -438,9 +441,16 @@ gomp_map_vars (struct gomp_device_descr *devicep,
 		      /* We already looked up the memory region above and it
 			 was missing.  */
 		      size_t size = k->host_end - k->host_start;
+#ifdef HAVE_INTTYPES_H
 		      gomp_fatal ("present clause: !acc_is_present (%p, "
-				  "%zd (0x%zx))", (void *) k->host_start,
-				  size, size);
+				  PRIu64" (0x"PRIx64"))",
+				  (void *) k->host_start,
+				  (uint64_t) size, (uint64_t) size);
+#else
+		      gomp_fatal ("present clause: !acc_is_present (%p, "
+				  "%lu (0x%lx))", (void *) k->host_start,
+				  (unsigned long) size, (unsigned long) size);
+#endif
 		    }
 		    break;
 		  case GOMP_MAP_FORCE_DEVICEPTR:
Comment 16 Jakub Jelinek 2015-03-24 20:18:03 UTC
(In reply to Kai Tietz from comment #15)
> Ok, I am fine.  So patch should be something like:

Patch preapproved for trunk with proper ChangeLog if it works on i686-w64-mingw32, please post it to gcc-patches anyway.
Comment 17 Kai Tietz 2015-03-25 15:05:34 UTC
Author: ktietz
Date: Wed Mar 25 15:05:02 2015
New Revision: 221665

URL: https://gcc.gnu.org/viewcvs?rev=221665&root=gcc&view=rev
Log:
	PR libgomp/64972
	* oacc-parallel.c (GOACC_parallel): Use PRIu64 if available.
	(GOACC_data_start): Likewise.
	* target.c (gomp_map_vars): Likewise.


Modified:
    trunk/libgomp/ChangeLog
    trunk/libgomp/oacc-parallel.c
    trunk/libgomp/target.c
Comment 18 Kai Tietz 2015-03-25 15:07:49 UTC
Fixed on trunk.