From owner-svn-src-head@freebsd.org Wed Aug 24 19:53:40 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 2FD5ABC571B; Wed, 24 Aug 2016 19:53:40 +0000 (UTC) (envelope-from bdrewery@FreeBSD.org) Received: from freefall.freebsd.org (freefall.freebsd.org [IPv6:2001:1900:2254:206c::16:87]) by mx1.freebsd.org (Postfix) with ESMTP id 10EFB1531; Wed, 24 Aug 2016 19:53:40 +0000 (UTC) (envelope-from bdrewery@FreeBSD.org) Received: from mail.xzibition.com (localhost [IPv6:::1]) by freefall.freebsd.org (Postfix) with ESMTP id 040AE1F8A; Wed, 24 Aug 2016 19:53:40 +0000 (UTC) (envelope-from bdrewery@FreeBSD.org) Received: from mail.xzibition.com (localhost [172.31.3.2]) by mail.xzibition.com (Postfix) with ESMTP id BDD881AA95; Wed, 24 Aug 2016 19:53:39 +0000 (UTC) X-Virus-Scanned: amavisd-new at mail.xzibition.com Received: from mail.xzibition.com ([172.31.3.2]) by mail.xzibition.com (mail.xzibition.com [172.31.3.2]) (amavisd-new, port 10026) with LMTP id HbqSTLA0jPhq; Wed, 24 Aug 2016 19:53:31 +0000 (UTC) Subject: Re: svn commit: r303988 - head/lib/libc/gen DKIM-Filter: OpenDKIM Filter v2.9.2 mail.xzibition.com 7D5A61AA8C To: Ed Schouten References: <201608120703.u7C73whf007189@repo.freebsd.org> <9ae1c2eb-02ad-b8fe-6aff-7e17e955607a@FreeBSD.org> <2632f5f8-d765-3df7-74d7-da878eb4b7a8@FreeBSD.org> Cc: svn-src-head@freebsd.org, jilles@freebsd.org, svn-src-all@freebsd.org, src-committers , Ed Schouten From: Bryan Drewery Organization: FreeBSD Message-ID: Date: Wed, 24 Aug 2016 12:53:27 -0700 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.11; rv:45.0) Gecko/20100101 Thunderbird/45.2.0 MIME-Version: 1.0 In-Reply-To: Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="tfpodA24dFOTD595EJagi3dgWNqeXgijB" X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 24 Aug 2016 19:53:40 -0000 This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --tfpodA24dFOTD595EJagi3dgWNqeXgijB Content-Type: multipart/mixed; boundary="OoWae0Ulc2BB2e7I6axj5I2fw8mQ9HkdA" From: Bryan Drewery To: Ed Schouten Cc: svn-src-head@freebsd.org, jilles@freebsd.org, svn-src-all@freebsd.org, src-committers , Ed Schouten Message-ID: Subject: Re: svn commit: r303988 - head/lib/libc/gen References: <201608120703.u7C73whf007189@repo.freebsd.org> <9ae1c2eb-02ad-b8fe-6aff-7e17e955607a@FreeBSD.org> <2632f5f8-d765-3df7-74d7-da878eb4b7a8@FreeBSD.org> In-Reply-To: --OoWae0Ulc2BB2e7I6axj5I2fw8mQ9HkdA Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: quoted-printable On 8/24/16 12:49 PM, Ed Schouten wrote: > 2016-08-24 20:30 GMT+02:00 Bryan Drewery : >> > That would only fix stable/11, stable/10, stable/9, releng/11.0. >> > >> > It won't fix releng/10.3, releng/10.2, releng/10.1, releng/9.3, etc.= =2E. >> > without an EN. >> > >> > It won't fix stable/11 - 1, stable/10 - 1, etc. >> > >> > It will never fix releng/8.4 (unsupported releases) since so@ won't = EN >> > to those. People do sometimes need to build these older releases st= ill. >> > >> > It creates a line in the sand where we can never build checkouts old= er >> > than where the fix was at. So I don't think it is the appropriate f= ix. > Good point! >=20 > Just for the record: Bryan and I just discussed this matter in more > detail on IRC. We came up with a workaround that should be pretty > good. >=20 > Attached is a patch for that adds some extra logic, so that > any calls to basename() and dirname() will expand to calls to > __old_basename() and __old_dirname(). Using __sym_compat(), these will > cause the compiler to generate calls to basename@FBSD_1.0 and > dirname@FBSD_1.0. >=20 > According to Bryan, this fixes the problems he was experiencing. >=20 > -- Ed Schouten Nuxi, 's-Hertogenbosch, the Netherlands > KvK-nr.: 62051717 >=20 >=20 > dirname-basename-xinstall.diff >=20 >=20 > Index: include/libgen.h > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D > --- include/libgen.h (revision 304750) > +++ include/libgen.h (working copy) > @@ -39,4 +39,26 @@ > char *dirname(char *); > __END_DECLS > =20 > +/* > + * In FreeBSD 12, the prototype of basename() and dirname() was modifi= ed > + * to comply to POSIX. These functions may now modify their input. > + * Unfortunately, our copy of xinstall(8) shipped with previous versio= ns > + * of FreeBSD is built using the host headers and libc during the > + * bootstrapping phase and depends on the old behavior. > + * > + * Apply a workaround where we explicitly link against basename@FBSD_1= =2E0 > + * and dirname@FBSD_1.0 in case these functions are called on constant= > + * strings, instead of making the build fail. > + */ > +#if defined(__generic) && !defined(__cplusplus) > +__BEGIN_DECLS > +char *__old_basename(const char *); > +char *__old_dirname(const char *); > +__END_DECLS > +__sym_compat(basename, __old_basename, FBSD_1.0); > +__sym_compat(dirname, __old_dirname, FBSD_1.0); > +#define basename(x) __generic(x, const char *, __old_basename, basenam= e)(x) > +#define dirname(x) __generic(x, const char *, __old_dirname, dirname)(= x) > +#endif Personally I really like this in general as an API-compat pattern. I know Ed wanted to deprecate and remove the old dirname(3)/basename(3), but it was quite painful downstream to convert our checkout to use the new prototypes. It spanned "only" 19 files, but it took 2 days of build-and-fix iterations to fix. We still get the benefit of thread-safe basename(3)/dirname(3) when using the proper prototype. Is it possible to cause the use of these old prototypes to print a warning and note that they are deprecated/unsafe? --=20 Regards, Bryan Drewery --OoWae0Ulc2BB2e7I6axj5I2fw8mQ9HkdA-- --tfpodA24dFOTD595EJagi3dgWNqeXgijB Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Comment: GPGTools - https://gpgtools.org iQEcBAEBCgAGBQJXvfs4AAoJEDXXcbtuRpfPA0MH/Ruegw0YBxd1Z8IXgjrhjEo1 NF0oNkXs1qP6RbXCfe/5R+HTutiIBv2SxkYi1kJM4eti2qrUOKFBLzXOCBNZ4uY0 KJamAYUyAqvmYSkjHMKUhE4x9RhHJxosvDiXUcM+topX/KZJUkJdsc2HfOQgvKh9 WwctbaVPMutgcx1JhkRgONXDACu5zaIptWHxD5Lx0UlrRe1hGhx76IfzT4YeYvl+ 27NtYOBIbilNEvxLo0oDfSMjpGD1mEMjNbuU8ubJ0uV/pclKV5l9D8fhSZdvowJ6 /bLCmL6bQBCiJbCPgtdIk+VGy6yN1/j2M2RIlFqBWnEuOAZ3aZhkSNbbtSDLKSg= =2ici -----END PGP SIGNATURE----- --tfpodA24dFOTD595EJagi3dgWNqeXgijB--