public inbox for fortran@gcc.gnu.org
 help / color / mirror / Atom feed
From: Thomas Schwinge <thomas@codesourcery.com>
To: Jerry D <jvdelisle2@gmail.com>,
	Andrew Stubbs <ams@codesourcery.com>, <gcc-patches@gcc.gnu.org>
Cc: Tobias Burnus <tobias@codesourcery.com>,
	Jakub Jelinek <jakub@redhat.com>, <fortran@gcc.gnu.org>,
	<gcc@gcc.gnu.org>
Subject: Fix 'libgomp/config/linux/allocator.c' 'size_t' vs. '%ld' format string mismatch (was: Build breakage)
Date: Wed, 13 Dec 2023 21:17:33 +0100	[thread overview]
Message-ID: <87a5qd97s2.fsf@euler.schwinge.homeip.net> (raw)
In-Reply-To: <87cyv999o7.fsf@euler.schwinge.homeip.net>

[-- Attachment #1: Type: text/plain, Size: 2433 bytes --]

Hi!

On 2023-12-13T20:36:40+0100, I wrote:
> On 2023-12-13T11:15:54-0800, Jerry D via Gcc <gcc@gcc.gnu.org> wrote:
>> I am getting this failure to build from clean trunk.
>
> This is due to commit r14-6499-g348874f0baac0f22c98ab11abbfa65fd172f6bdd
> "libgomp: basic pinned memory on Linux", which supposedly was only tested
> with '--disable-multilib' or so.  As Andrew's now on vacations --
> conveniently ;-P -- I'll soon push a fix.

Pushed to master branch commit 5445ff4a51fcee4d281f79b5f54b349290d0327d
"Fix 'libgomp/config/linux/allocator.c' 'size_t' vs. '%ld' format string mismatch",
see attached.


Grüße
 Thomas


>> In file included from ../../../../trunk/libgomp/config/linux/allocator.c:31:
>> ../../../../trunk/libgomp/config/linux/allocator.c: In function
>> ‘linux_memspace_alloc’:
>> ../../../../trunk/libgomp/config/linux/allocator.c:70:26: error: format
>> ‘%ld’ expects argument of type ‘long int’, but argument 3 has type
>> ‘size_t’ {aka ‘unsigned int’} [-Werror=format=]
>>     70 |           gomp_debug (0, "libgomp: failed to pin %ld bytes of"
>>        |                          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>>     71 |                       " memory (ulimit too low?)\n", size);
>>        |                                                      ~~~~
>>        |                                                      |
>>        |                                                      size_t
>> {aka unsigned int}
>> ../../../../trunk/libgomp/libgomp.h:186:29: note: in definition of macro
>> ‘gomp_debug’
>>    186 |       (gomp_debug) ((KIND), __VA_ARGS__); \
>>        |                             ^~~~~~~~~~~
>> ../../../../trunk/libgomp/config/linux/allocator.c:70:52: note: format
>> string is defined here
>>     70 |           gomp_debug (0, "libgomp: failed to pin %ld bytes of"
>>        |                                                  ~~^
>>        |                                                    |
>>        |                                                    long int
>>        |                                                  %d


-----------------
Siemens Electronic Design Automation GmbH; Anschrift: Arnulfstraße 201, 80634 München; Gesellschaft mit beschränkter Haftung; Geschäftsführer: Thomas Heurung, Frank Thürauf; Sitz der Gesellschaft: München; Registergericht München, HRB 106955

[-- Attachment #2: 0001-Fix-libgomp-config-linux-allocator.c-size_t-vs.-ld-f.patch --]
[-- Type: text/x-diff, Size: 3578 bytes --]

From 5445ff4a51fcee4d281f79b5f54b349290d0327d Mon Sep 17 00:00:00 2001
From: Thomas Schwinge <thomas@codesourcery.com>
Date: Wed, 13 Dec 2023 17:48:11 +0100
Subject: [PATCH] Fix 'libgomp/config/linux/allocator.c' 'size_t' vs. '%ld'
 format string mismatch
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Fix-up for commit 348874f0baac0f22c98ab11abbfa65fd172f6bdd
"libgomp: basic pinned memory on Linux", which may result in build failures
as follow, for example, for the '-m32' multilib of x86_64-pc-linux-gnu:

    In file included from [...]/source-gcc/libgomp/config/linux/allocator.c:31:
    [...]/source-gcc/libgomp/config/linux/allocator.c: In function ‘linux_memspace_alloc’:
    [...]/source-gcc/libgomp/config/linux/allocator.c:70:26: error: format ‘%ld’ expects argument of type ‘long int’, but argument 3 has type ‘size_t’ {aka ‘unsigned int’} [-Werror=format=]
       70 |           gomp_debug (0, "libgomp: failed to pin %ld bytes of"
          |                          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
       71 |                       " memory (ulimit too low?)\n", size);
          |                                                      ~~~~
          |                                                      |
          |                                                      size_t {aka unsigned int}
    [...]/source-gcc/libgomp/libgomp.h:186:29: note: in definition of macro ‘gomp_debug’
      186 |       (gomp_debug) ((KIND), __VA_ARGS__); \
          |                             ^~~~~~~~~~~
    [...]/source-gcc/libgomp/config/linux/allocator.c:70:52: note: format string is defined here
       70 |           gomp_debug (0, "libgomp: failed to pin %ld bytes of"
          |                                                  ~~^
          |                                                    |
          |                                                    long int
          |                                                  %d
    cc1: all warnings being treated as errors
    make[9]: *** [allocator.lo] Error 1
    make[9]: Leaving directory `[...]/build-gcc/x86_64-pc-linux-gnu/32/libgomp'
    [...]

Fix this in the same way as used elsewhere in libgomp.

	libgomp/
	* config/linux/allocator.c (linux_memspace_alloc): Fix 'size_t'
	vs. '%ld' format string mismatch.
---
 libgomp/config/linux/allocator.c | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/libgomp/config/linux/allocator.c b/libgomp/config/linux/allocator.c
index 269d0d607d8..6ffa2417913 100644
--- a/libgomp/config/linux/allocator.c
+++ b/libgomp/config/linux/allocator.c
@@ -50,6 +50,9 @@
 #include <sys/mman.h>
 #include <string.h>
 #include "libgomp.h"
+#ifdef HAVE_INTTYPES_H
+# include <inttypes.h>  /* For PRIu64.  */
+#endif
 
 static void *
 linux_memspace_alloc (omp_memspace_handle_t memspace, size_t size, int pin)
@@ -67,8 +70,13 @@ linux_memspace_alloc (omp_memspace_handle_t memspace, size_t size, int pin)
 
       if (mlock (addr, size))
 	{
-	  gomp_debug (0, "libgomp: failed to pin %ld bytes of"
-		      " memory (ulimit too low?)\n", size);
+#ifdef HAVE_INTTYPES_H
+	  gomp_debug (0, "libgomp: failed to pin %"PRIu64" bytes of"
+		      " memory (ulimit too low?)\n", (uint64_t) size);
+#else
+	  gomp_debug (0, "libgomp: failed to pin %lu bytes of"
+		      " memory (ulimit too low?)\n", (unsigned long) size);
+#endif
 	  munmap (addr, size);
 	  return NULL;
 	}
-- 
2.34.1


  reply	other threads:[~2023-12-13 20:17 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <fe58c7bf-1f14-4794-8f99-abab8360fc4b@codesourcery.com>
2023-12-13 19:15 ` Build breakage Jerry D
2023-12-13 19:36   ` Thomas Schwinge
2023-12-13 20:17     ` Thomas Schwinge [this message]
2023-12-13 20:27     ` Jonathan Wakely
2023-12-13 20:56       ` Thomas Schwinge
2023-12-13 21:04         ` Jonathan Wakely

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87a5qd97s2.fsf@euler.schwinge.homeip.net \
    --to=thomas@codesourcery.com \
    --cc=ams@codesourcery.com \
    --cc=fortran@gcc.gnu.org \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=gcc@gcc.gnu.org \
    --cc=jakub@redhat.com \
    --cc=jvdelisle2@gmail.com \
    --cc=tobias@codesourcery.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).