diff mbox series

[committed] btf: Fix -Wformat errors

Message ID ZHoSxwZsh98WrBSU@arm.com
State New
Headers show
Series [committed] btf: Fix -Wformat errors | expand

Commit Message

Alex Coplan June 2, 2023, 4:03 p.m. UTC
Hi,

g:7aae58b04b92303ccda3ead600be98f0d4b7f462 introduced -Wformat errors
breaking bootstrap on some targets. This patch fixes that.

Committed as obvious.

Thanks,
Alex

gcc/ChangeLog:

	* btfout.cc (btf_asm_type): Use PRIu64 instead of %lu for uint64_t.
	(btf_asm_datasec_type): Likewise.
commit e2dc586ecadd2399d5ebb14094d78fff1e6caf55
Author: Alex Coplan <alex.coplan@arm.com>
Date:   Fri Jun 2 16:50:45 2023

    btf: Fix -Wformat errors in btfout.cc

Comments

Rainer Orth June 2, 2023, 4:18 p.m. UTC | #1
Hi Alex,

> g:7aae58b04b92303ccda3ead600be98f0d4b7f462 introduced -Wformat errors
> breaking bootstrap on some targets. This patch fixes that.
>
> Committed as obvious.
>
> Thanks,
> Alex
>
> gcc/ChangeLog:
>
> 	* btfout.cc (btf_asm_type): Use PRIu64 instead of %lu for uint64_t.
> 	(btf_asm_datasec_type): Likewise.

This is PR libstdc++/110077.  Btw., your fix is incomplete: it needs
another change (%lu -> %zu) in btf_asm_func_type.

	Rainer
Iain Sandoe June 2, 2023, 4:23 p.m. UTC | #2
> On 2 Jun 2023, at 17:18, Rainer Orth <ro@CeBiTec.Uni-Bielefeld.DE> wrote:
> 
> Hi Alex,
> 
>> g:7aae58b04b92303ccda3ead600be98f0d4b7f462 introduced -Wformat errors
>> breaking bootstrap on some targets. This patch fixes that.
>> 
>> Committed as obvious.
>> 
>> Thanks,
>> Alex
>> 
>> gcc/ChangeLog:
>> 
>> 	* btfout.cc (btf_asm_type): Use PRIu64 instead of %lu for uint64_t.
>> 	(btf_asm_datasec_type): Likewise.
> 
> This is PR libstdc++/110077.  Btw., your fix is incomplete: it needs
> another change (%lu -> %zu) in btf_asm_func_type.

I think there’s a typo in the PR ref?

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110073

Iain
Jakub Jelinek June 2, 2023, 4:45 p.m. UTC | #3
On Fri, Jun 02, 2023 at 06:18:38PM +0200, Rainer Orth wrote:
> Hi Alex,
> 
> > g:7aae58b04b92303ccda3ead600be98f0d4b7f462 introduced -Wformat errors
> > breaking bootstrap on some targets. This patch fixes that.
> >
> > Committed as obvious.
> >
> > Thanks,
> > Alex
> >
> > gcc/ChangeLog:
> >
> > 	* btfout.cc (btf_asm_type): Use PRIu64 instead of %lu for uint64_t.
> > 	(btf_asm_datasec_type): Likewise.
> 
> This is PR libstdc++/110077.  Btw., your fix is incomplete: it needs
> another change (%lu -> %zu) in btf_asm_func_type.

Can we rely on %zu working?  Sure, it is in C99 and so in C++11 as well,
but I don't see it being used inside of gcc/ at all and not sure if all host
C libraries support it.

	Jakub
Alex Coplan June 2, 2023, 4:49 p.m. UTC | #4
On 02/06/2023 18:45, Jakub Jelinek wrote:
> On Fri, Jun 02, 2023 at 06:18:38PM +0200, Rainer Orth wrote:
> > Hi Alex,
> > 
> > > g:7aae58b04b92303ccda3ead600be98f0d4b7f462 introduced -Wformat errors
> > > breaking bootstrap on some targets. This patch fixes that.
> > >
> > > Committed as obvious.
> > >
> > > Thanks,
> > > Alex
> > >
> > > gcc/ChangeLog:
> > >
> > > 	* btfout.cc (btf_asm_type): Use PRIu64 instead of %lu for uint64_t.
> > > 	(btf_asm_datasec_type): Likewise.
> > 
> > This is PR libstdc++/110077.  Btw., your fix is incomplete: it needs
> > another change (%lu -> %zu) in btf_asm_func_type.
> 
> Can we rely on %zu working?  Sure, it is in C99 and so in C++11 as well,
> but I don't see it being used inside of gcc/ at all and not sure if all host
> C libraries support it.

Looks like the follow-up patch from David fixes this without relying on %zu:
https://gcc.gnu.org/pipermail/gcc-patches/2023-June/620524.html

Alex

> 
> 	Jakub
>
diff mbox series

Patch

diff --git a/gcc/btfout.cc b/gcc/btfout.cc
index f51ccf73242..1ea68b9e8ba 100644
--- a/gcc/btfout.cc
+++ b/gcc/btfout.cc
@@ -799,7 +799,7 @@  btf_asm_type (ctf_container_ref ctfc, ctf_dtdef_ref dtd)
    }
 
   dw2_asm_output_data (4, dtd->dtd_data.ctti_name,
-		       "TYPE %lu BTF_KIND_%s '%s'",
+		       "TYPE %" PRIu64 " BTF_KIND_%s '%s'",
 		       get_btf_id (dtd->dtd_type), btf_kind_name (btf_kind),
 		       dtd->dtd_name);
   dw2_asm_output_data (4, BTF_TYPE_INFO (btf_kind, btf_kflag, btf_vlen),
@@ -967,7 +967,7 @@  btf_asm_datasec_type (ctf_container_ref ctfc, btf_datasec_t ds, ctf_id_t id,
 		      size_t stroffset)
 {
   dw2_asm_output_data (4, ds.name_offset + stroffset,
-		       "TYPE %lu BTF_KIND_DATASEC '%s'",
+		       "TYPE %" PRIu64 " BTF_KIND_DATASEC '%s'",
 		       btf_absolute_datasec_id (id), ds.name);
   dw2_asm_output_data (4, BTF_TYPE_INFO (BTF_KIND_DATASEC, 0,
 					 ds.entries.length ()),