Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 2 Jul 2024 11:58:16 -0600
From:      Warner Losh <imp@bsdimp.com>
To:        John Baldwin <jhb@freebsd.org>
Cc:        Warner Losh <imp@freebsd.org>, src-committers <src-committers@freebsd.org>,  dev-commits-src-all@freebsd.org, dev-commits-src-main@freebsd.org
Subject:   Re: git: 67d1a1cd9e77 - main - cdefs.h: Remove support for pre gcc 4.0
Message-ID:  <CANCZdfoWdra0kQm1V-qa76GoCg77oWsbV60rMTCJyG9g0dWe2A@mail.gmail.com>
In-Reply-To: <CANCZdfqRusqMiJtbh_iBr2cDwTccDyti0mJo36GeNee%2B7ns4dQ@mail.gmail.com>
References:  <202406210241.45L2fOkP057010@gitrepo.freebsd.org> <4ecc814d-5df1-4db8-b9e0-4919895c5e6a@FreeBSD.org> <CANCZdfrrLWW=JSZ_%2BJcZkbyXnz4Av6dbqn2RBZRyh=8=R6n4zQ@mail.gmail.com> <df672d3e-8b34-478a-b2a7-1ed7fece0b9b@FreeBSD.org> <CANCZdfqRusqMiJtbh_iBr2cDwTccDyti0mJo36GeNee%2B7ns4dQ@mail.gmail.com>

next in thread | previous in thread | raw e-mail | index | archive | help
--000000000000f04164061c477510
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

On Tue, Jul 2, 2024 at 10:30=E2=80=AFAM Warner Losh <imp@bsdimp.com> wrote:

> Hey John,
>
> On Tue, Jul 2, 2024 at 9:44=E2=80=AFAM John Baldwin <jhb@freebsd.org> wro=
te:
>
>> On 7/1/24 4:09 PM, Warner Losh wrote:
>> > On Mon, Jul 1, 2024, 3:53=E2=80=AFPM John Baldwin <jhb@freebsd.org> wr=
ote:
>> >
>> >> On 6/20/24 7:41 PM, Warner Losh wrote:
>> >>> The branch main has been updated by imp:
>> >>>
>> >>> URL:
>> >>
>> https://cgit.FreeBSD.org/src/commit/?id=3D67d1a1cd9e772e2ef94003579f4fbc=
271d38be7d
>> >>>
>> >>> commit 67d1a1cd9e772e2ef94003579f4fbc271d38be7d
>> >>> Author:     Warner Losh <imp@FreeBSD.org>
>> >>> AuthorDate: 2024-06-20 23:02:56 +0000
>> >>> Commit:     Warner Losh <imp@FreeBSD.org>
>> >>> CommitDate: 2024-06-21 02:41:08 +0000
>> >>>
>> >>>       cdefs.h: Remove support for pre gcc 4.0
>> >>>
>> >>>       All supported compilers support the gcc 3 attribute extensions=
.
>> >> Remove
>> >>>       the #else clauses for this. Also, latter-day pcc compilers als=
o
>> >> define
>> >>>       __GNUC__, so there's not need to also test for __PCC__.
>> >>>
>> >>>       Reviewed by:            brooks
>> >>>       Differential Revision:  https://reviews.freebsd.org/D45654
>> >>>       Sponsored by:           Netflix
>> >>> ---
>> >>>    sys/sys/cdefs.h | 42 ++++--------------------------------------
>> >>>    1 file changed, 4 insertions(+), 38 deletions(-)
>> >>>
>> >>> diff --git a/sys/sys/cdefs.h b/sys/sys/cdefs.h
>> >>> index 88019819eb35..a6ecdca5d8b9 100644
>> >>> --- a/sys/sys/cdefs.h
>> >>> +++ b/sys/sys/cdefs.h
>> >>> @@ -408,15 +389,10 @@
>> >>>     * assign pointer x to a local variable, to check that its type i=
s
>> >>>     * compatible with member m.
>> >>>     */
>> >>> -#if __GNUC_PREREQ__(3, 1)
>> >>>    #define     __containerof(x, s, m) ({
>> >>       \
>> >>>        const volatile __typeof(((s *)0)->m) *__x =3D (x);
>>   \
>> >>>        __DEQUALIFY(s *, (const volatile char *)__x - __offsetof(s,
>> m));\
>> >>>    })
>> >>> -#else
>> >>> -#define      __containerof(x, s, m)
>> >>        \
>> >>> -     __DEQUALIFY(s *, (const volatile char *)(x) - __offsetof(s, m)=
)
>> >>> -#endif
>> >>>
>> >>>    /*
>> >>>     * Compiler-dependent macros to declare that functions take
>> printf-like
>> >>> @@ -434,14 +410,8 @@
>> >>>    #define     __strftimelike(fmtarg, firstvararg) \
>> >>>            __attribute__((__format__ (__strftime__, fmtarg,
>> firstvararg)))
>> >>>
>> >>> -/* Compiler-dependent macros that rely on FreeBSD-specific
>> extensions.
>> >> */
>> >>> -#if defined(__FreeBSD_cc_version) && __FreeBSD_cc_version >=3D 3000=
01
>> && \
>> >>> -    defined(__GNUC__)
>> >>>    #define     __printf0like(fmtarg, firstvararg) \
>> >>>            __attribute__((__format__ (__printf0__, fmtarg,
>> firstvararg)))
>> >>> -#else
>> >>> -#define      __printf0like(fmtarg, firstvararg)
>> >>> -#endif
>> >>
>> >> Does this still work with external GCC?  I didn't think printf0 was
>> >> supported
>> >> by external GCC (or maybe I had to readd it in the port and that's
>> what I
>> >> remember).  Ah, yes, printf0 is a local patch in the devel/freebsd-gc=
cX
>> >> ports, but is not available in stock GCC (e.g. lang/gcc does not
>> support
>> >> it).
>> >>
>> >
>> > Ah. That would explain why it just worked for me. That's what I tested
>> > with. Clang also seemed happy with it. But that was the in tree clang.
>> Is
>> > there a similar issue? Gnuc is defined for both.
>>
>> So we don't support building the base system with lang/gcc, only
>> devel/freebsd-gccX (which has a local patch to add printf0 support).
>> The only question might be, do we support using __printf0like for things
>> that aren't in the base system that could be built with lang/gcc.  If so=
,
>> we might need to guard this somehow.  I'm not sure though that we care
>> about random software not in base using a FreeBSD-specific keyword from
>> <sys/cdefs.h>.
>>
>
> Yes. The question is "do we use __printf0like  in our headers" since we
> definitely
> can't build FreeBSD itself w/o at least some of the extensions for other
> things...
> and the answer is "yes". err.h uses it, for example, as does setproctitle
> in stdlib.h
>
> The interesting thing for me is that gcc13 will produce no warnings if I
> include errr.h
> because -Wsystem-header is off. With it on, warnings crop up too. This is
> why my testing
> didn't see it...
>
> It looks like clang has it as a builtin for all versions we care about, s=
o
> I'll create a phab to add some
> of this back. Maybe we should upstream what we have, for this and
> freebsd_printf since that's also
> in clang and one of the small number of patches we have for the lang/gcc*
> family?
>

 https://reviews.freebsd.org/D45836

Warner

--000000000000f04164061c477510
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr"><div dir=3D"ltr"><br></div><br><div class=3D"gmail_quote">=
<div dir=3D"ltr" class=3D"gmail_attr">On Tue, Jul 2, 2024 at 10:30=E2=80=AF=
AM Warner Losh &lt;<a href=3D"mailto:imp@bsdimp.com">imp@bsdimp.com</a>&gt;=
 wrote:<br></div><blockquote class=3D"gmail_quote" style=3D"margin:0px 0px =
0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir=
=3D"ltr"><div dir=3D"ltr">Hey John,<br></div><br><div class=3D"gmail_quote"=
><div dir=3D"ltr" class=3D"gmail_attr">On Tue, Jul 2, 2024 at 9:44=E2=80=AF=
AM John Baldwin &lt;<a href=3D"mailto:jhb@freebsd.org" target=3D"_blank">jh=
b@freebsd.org</a>&gt; wrote:<br></div><blockquote class=3D"gmail_quote" sty=
le=3D"margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);paddi=
ng-left:1ex">On 7/1/24 4:09 PM, Warner Losh wrote:<br>
&gt; On Mon, Jul 1, 2024, 3:53=E2=80=AFPM John Baldwin &lt;<a href=3D"mailt=
o:jhb@freebsd.org" target=3D"_blank">jhb@freebsd.org</a>&gt; wrote:<br>
&gt; <br>
&gt;&gt; On 6/20/24 7:41 PM, Warner Losh wrote:<br>
&gt;&gt;&gt; The branch main has been updated by imp:<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; URL:<br>
&gt;&gt; <a href=3D"https://cgit.FreeBSD.org/src/commit/?id=3D67d1a1cd9e772=
e2ef94003579f4fbc271d38be7d" rel=3D"noreferrer" target=3D"_blank">https://c=
git.FreeBSD.org/src/commit/?id=3D67d1a1cd9e772e2ef94003579f4fbc271d38be7d</=
a><br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; commit 67d1a1cd9e772e2ef94003579f4fbc271d38be7d<br>
&gt;&gt;&gt; Author:=C2=A0 =C2=A0 =C2=A0Warner Losh &lt;imp@FreeBSD.org&gt;=
<br>
&gt;&gt;&gt; AuthorDate: 2024-06-20 23:02:56 +0000<br>
&gt;&gt;&gt; Commit:=C2=A0 =C2=A0 =C2=A0Warner Losh &lt;imp@FreeBSD.org&gt;=
<br>
&gt;&gt;&gt; CommitDate: 2024-06-21 02:41:08 +0000<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt;=C2=A0 =C2=A0 =C2=A0 =C2=A0cdefs.h: Remove support for pre gcc =
4.0<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt;=C2=A0 =C2=A0 =C2=A0 =C2=A0All supported compilers support the =
gcc 3 attribute extensions.<br>
&gt;&gt; Remove<br>
&gt;&gt;&gt;=C2=A0 =C2=A0 =C2=A0 =C2=A0the #else clauses for this. Also, la=
tter-day pcc compilers also<br>
&gt;&gt; define<br>
&gt;&gt;&gt;=C2=A0 =C2=A0 =C2=A0 =C2=A0__GNUC__, so there&#39;s not need to=
 also test for __PCC__.<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt;=C2=A0 =C2=A0 =C2=A0 =C2=A0Reviewed by:=C2=A0 =C2=A0 =C2=A0 =C2=
=A0 =C2=A0 =C2=A0 brooks<br>
&gt;&gt;&gt;=C2=A0 =C2=A0 =C2=A0 =C2=A0Differential Revision:=C2=A0 <a href=
=3D"https://reviews.freebsd.org/D45654" rel=3D"noreferrer" target=3D"_blank=
">https://reviews.freebsd.org/D45654</a><br>;
&gt;&gt;&gt;=C2=A0 =C2=A0 =C2=A0 =C2=A0Sponsored by:=C2=A0 =C2=A0 =C2=A0 =
=C2=A0 =C2=A0 =C2=A0Netflix<br>
&gt;&gt;&gt; ---<br>
&gt;&gt;&gt;=C2=A0 =C2=A0 sys/sys/cdefs.h | 42 ++++------------------------=
--------------<br>
&gt;&gt;&gt;=C2=A0 =C2=A0 1 file changed, 4 insertions(+), 38 deletions(-)<=
br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; diff --git a/sys/sys/cdefs.h b/sys/sys/cdefs.h<br>
&gt;&gt;&gt; index 88019819eb35..a6ecdca5d8b9 100644<br>
&gt;&gt;&gt; --- a/sys/sys/cdefs.h<br>
&gt;&gt;&gt; +++ b/sys/sys/cdefs.h<br>
&gt;&gt;&gt; @@ -408,15 +389,10 @@<br>
&gt;&gt;&gt;=C2=A0 =C2=A0 =C2=A0* assign pointer x to a local variable, to =
check that its type is<br>
&gt;&gt;&gt;=C2=A0 =C2=A0 =C2=A0* compatible with member m.<br>
&gt;&gt;&gt;=C2=A0 =C2=A0 =C2=A0*/<br>
&gt;&gt;&gt; -#if __GNUC_PREREQ__(3, 1)<br>
&gt;&gt;&gt;=C2=A0 =C2=A0 #define=C2=A0 =C2=A0 =C2=A0__containerof(x, s, m)=
 ({<br>
&gt;&gt;=C2=A0 =C2=A0 =C2=A0 =C2=A0\<br>
&gt;&gt;&gt;=C2=A0 =C2=A0 =C2=A0 =C2=A0 const volatile __typeof(((s *)0)-&g=
t;m) *__x =3D (x);=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 \=
<br>
&gt;&gt;&gt;=C2=A0 =C2=A0 =C2=A0 =C2=A0 __DEQUALIFY(s *, (const volatile ch=
ar *)__x - __offsetof(s, m));\<br>
&gt;&gt;&gt;=C2=A0 =C2=A0 })<br>
&gt;&gt;&gt; -#else<br>
&gt;&gt;&gt; -#define=C2=A0 =C2=A0 =C2=A0 __containerof(x, s, m)<br>
&gt;&gt;=C2=A0 =C2=A0 =C2=A0 =C2=A0 \<br>
&gt;&gt;&gt; -=C2=A0 =C2=A0 =C2=A0__DEQUALIFY(s *, (const volatile char *)(=
x) - __offsetof(s, m))<br>
&gt;&gt;&gt; -#endif<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt;=C2=A0 =C2=A0 /*<br>
&gt;&gt;&gt;=C2=A0 =C2=A0 =C2=A0* Compiler-dependent macros to declare that=
 functions take printf-like<br>
&gt;&gt;&gt; @@ -434,14 +410,8 @@<br>
&gt;&gt;&gt;=C2=A0 =C2=A0 #define=C2=A0 =C2=A0 =C2=A0__strftimelike(fmtarg,=
 firstvararg) \<br>
&gt;&gt;&gt;=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 __attribute__((__form=
at__ (__strftime__, fmtarg, firstvararg)))<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; -/* Compiler-dependent macros that rely on FreeBSD-specific ex=
tensions.<br>
&gt;&gt; */<br>
&gt;&gt;&gt; -#if defined(__FreeBSD_cc_version) &amp;&amp; __FreeBSD_cc_ver=
sion &gt;=3D 300001 &amp;&amp; \<br>
&gt;&gt;&gt; -=C2=A0 =C2=A0 defined(__GNUC__)<br>
&gt;&gt;&gt;=C2=A0 =C2=A0 #define=C2=A0 =C2=A0 =C2=A0__printf0like(fmtarg, =
firstvararg) \<br>
&gt;&gt;&gt;=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 __attribute__((__form=
at__ (__printf0__, fmtarg, firstvararg)))<br>
&gt;&gt;&gt; -#else<br>
&gt;&gt;&gt; -#define=C2=A0 =C2=A0 =C2=A0 __printf0like(fmtarg, firstvararg=
)<br>
&gt;&gt;&gt; -#endif<br>
&gt;&gt;<br>
&gt;&gt; Does this still work with external GCC?=C2=A0 I didn&#39;t think p=
rintf0 was<br>
&gt;&gt; supported<br>
&gt;&gt; by external GCC (or maybe I had to readd it in the port and that&#=
39;s what I<br>
&gt;&gt; remember).=C2=A0 Ah, yes, printf0 is a local patch in the devel/fr=
eebsd-gccX<br>
&gt;&gt; ports, but is not available in stock GCC (e.g. lang/gcc does not s=
upport<br>
&gt;&gt; it).<br>
&gt;&gt;<br>
&gt; <br>
&gt; Ah. That would explain why it just worked for me. That&#39;s what I te=
sted<br>
&gt; with. Clang also seemed happy with it. But that was the in tree clang.=
 Is<br>
&gt; there a similar issue? Gnuc is defined for both.<br>
<br>
So we don&#39;t support building the base system with lang/gcc, only<br>
devel/freebsd-gccX (which has a local patch to add printf0 support).<br>
The only question might be, do we support using __printf0like for things<br=
>
that aren&#39;t in the base system that could be built with lang/gcc.=C2=A0=
 If so,<br>
we might need to guard this somehow.=C2=A0 I&#39;m not sure though that we =
care<br>
about random software not in base using a FreeBSD-specific keyword from<br>
&lt;sys/cdefs.h&gt;.<br></blockquote><div><br></div><div>Yes. The question =
is &quot;do we use __printf0like=C2=A0 in our headers&quot; since we defini=
tely</div><div>can&#39;t build FreeBSD itself w/o at least some of the exte=
nsions for other things...</div><div>and the answer is &quot;yes&quot;. err=
.h uses it, for example, as does setproctitle in stdlib.h</div><div><br></d=
iv><div>The interesting thing for me is that gcc13 will produce no warnings=
 if I include errr.h=C2=A0</div><div>because -Wsystem-header=C2=A0is off. W=
ith it on, warnings crop up too. This is why my testing</div><div>didn&#39;=
t see it...</div><div><br></div><div>It looks like clang has it as a builti=
n for all versions we care about, so I&#39;ll create a phab to add some</di=
v><div>of this back. Maybe we should upstream what we have, for this and fr=
eebsd_printf since that&#39;s also</div><div>in clang and one of the small =
number of patches we have for the lang/gcc* family?</div></div></div></bloc=
kquote><div><br></div><div>=C2=A0<a href=3D"https://reviews.freebsd.org/D45=
836">https://reviews.freebsd.org/D45836</a></div><div><br></div><div>Warner=
</div></div></div>

--000000000000f04164061c477510--



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?CANCZdfoWdra0kQm1V-qa76GoCg77oWsbV60rMTCJyG9g0dWe2A>