Re: Updating in glibc and gnulib

2023-02-27 Thread Florian Weimer
* Bruno Haible:

> Florian Weimer wrote:
>> Does gnulib still override  unconditionally?
>
> Gnulib does not override , and never did.

Thanks for looking into this.  gnulib's libc-config.h does this:

| #ifndef __attribute_nonnull__
| /*  either does not exist, or is too old for Gnulib.
|Prepare to include , which is Gnulib's version of a
|more-recent glibc .  */
| …
| /* Include our copy of glibc .  */
| # include 

And as gnulib's  uses the same _SYS_CDEFS_H header guard as
glibc's, that effectively replaces  with gnulib's
.

> That is, when a package that uses Gnulib does
>   #include 
> it will get the  of the system (from glibc, *BSD, Cygwin,
> etc.).

Apparently not if it includes libc-config.h first.

I think what happened is that the order of backporting

commit 0b5ca7c3e551e5502f3be3b06453324fe8604e82
Author: Paul Eggert 
Date:   Tue Sep 21 07:47:45 2021 -0700

regex: copy back from Gnulib

(which brought in __attribute_nonnull__) and

commit a643f60c53876be0d57b4b7373770e6cb356fd13
Author: Siddhesh Poyarekar 
Date:   Wed Oct 20 18:12:41 2021 +0530

Make sure that the fortified function conditionals are constant

was reversed on the glibc 2.34 branch, so the version check based on
__attribute_nonnull__ would signal that system  is too old.
But with the second commit for fortified functions, glibc 2.34 headers
started requiring other macros not present in gnulib's  copy,
so some projects using copied gnulib sources would start to fail.

I backported the regex sync to glibc 2.34 in November, so this should
now be solved because we now define __attribute_nonnull__ even on the
2.34 branch.  I think only the 2.34 branch had this problem.

I think we should have backported the __attribute_nonnull__-defining
commit to glibc 2.34 earlier, when we noticed problems.  Updating the
gnulib-bundled copy only (which is what happened at first) wasn't the
best resolution.

Thanks,
Florian




Re: Updating in glibc and gnulib

2023-02-26 Thread Bruno Haible
Florian Weimer wrote:
> Does gnulib still override  unconditionally?

Gnulib does not override , and never did.

That is, when a package that uses Gnulib does
  #include 
it will get the  of the system (from glibc, *BSD, Cygwin,
etc.).

Only when a package uses the compiler option "-I /usr/include/sys"
and
  #include 
there would be a conflict between what Gnulib ships and the installed
file in /usr/include/sys. But nobody does that, because there would
already be a conflict between  and .

What Gnulib does is to ship a copy of glibc's  as ,
not . And it is used for a few compilation units only
(essentially regex, fnmatch, glob, and a few others).

> Why does gnulib bundle ?

Gnulib takes the source code of regex, fnmatch, glob, and a few other
functions from glibc and makes them portable to other platforms. Since
this source code contains references to __glibc_unlikely,
__attribute_warn_unused_result__, etc., Gnulib uses the copy of cdefs.h
to define these macros in the way the source code shared with glibc
expects it.

Some of these symbols are also defined on other platforms, sometimes
differently. Therefore Gnulib has to be careful to not override essential
symbols of these other platforms. It's not trivial, but there appears
to be enough room to navigate through the two constraints. [1]

> In the past, some gnulib-using programs supplied their own copy
> of  instead, even when building against glibc.  This caused
> build failures in the glibc headers because they (quite reasonably)
> assumed that  defines the macros for that glibc version.

You need to take this up with the respective packages. As I said above,
Gnulib overrides , not .

There were some problems around the 'glob' code, but they were resolved
more than 1.5 years ago. This area is still a bit fragile, though.

> We could move glibc's internal definitions to a new header, reducing
>  in scope, but presumably that means gnulib would just
> starting bundling that other header, and we would have the same issue
> once more.

Yes, such a move would be pointless.

Bruno

[1] https://lists.gnu.org/archive/html/bug-gnulib/2023-01/msg00238.html






Updating in glibc and gnulib

2023-02-21 Thread Florian Weimer
Why does gnulib bundle ?  We edit this file regularly in
glibc.  In the past, some gnulib-using programs supplied their own copy
of  instead, even when building against glibc.  This caused
build failures in the glibc headers because they (quite reasonably)
assumed that  defines the macros for that glibc version.

Does gnulib still override  unconditionally?

A version check will be difficult because sometimes, we have to backport
header fixes to older versions, and that may require adding additional
macros in .

We could move glibc's internal definitions to a new header, reducing
 in scope, but presumably that means gnulib would just
starting bundling that other header, and we would have the same issue
once more.

Thanks,
Florian