Message ID | 20250221180225.3176533-1-audrey@rhelmot.io (mailing list archive) |
---|---|
State | New |
Headers | show |
Series | git-compat-util.h: Bump _XOPEN_SOURCE on OpenBSD | expand |
Audrey Dutcher <audrey@rhelmot.io> writes: > On OpenBSD, getdelim() in <stdio.h> is behind __POSIX_VISIBLE >= 200809, > which is in turn locked behind _XOPEN_SOURCE >= 700. Without this patch, > compiling on OpenBSD 7.5 or 7.6, we get implicit declaration errors > when compiling with -Werror=implicit-function-declaration (default in > clang 19). Is this a recent regression? Blaming these two line ranges ... > > [1] https://github.com/openbsd/src/blob/6a403588e27467d1f271831ca1de62a3befea6a0/include/stdio.h#L236-L237 > [2] https://github.com/openbsd/src/blob/6a403588e27467d1f271831ca1de62a3befea6a0/sys/sys/cdefs.h#L299-L302 ... in the OpenBSD repository says they haven't changed for many years, and I am wondering what triggered this all of a sudden. If we know how we used to have no issue, in addition to how we now have issue with the current OpenBSD (which you outlined very well above), and when the situation changed, please add to the proposed log message. That would help people on OpenBSD to decide when they want to upgrade their copy of Git. > Signed-off-by: Audrey Dutcher <audrey@rhelmot.io> > --- > git-compat-util.h | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/git-compat-util.h b/git-compat-util.h > index e123288e8f..f6902ca2e8 100644 > --- a/git-compat-util.h > +++ b/git-compat-util.h > @@ -195,7 +195,7 @@ DISABLE_WARNING(-Wsign-compare) > !defined(_M_UNIX) && !defined(__sgi) && !defined(__DragonFly__) && \ > !defined(__TANDEM) && !defined(__QNX__) && !defined(__MirBSD__) && \ > !defined(__CYGWIN__) > -#define _XOPEN_SOURCE 600 /* glibc2 and AIX 5.3L need 500, OpenBSD needs 600 for S_ISLNK() */ > +#define _XOPEN_SOURCE 700 /* glibc2 and AIX 5.3L need 500, OpenBSD needs 700 for getdelim() */ Also, I am wondering if this "A and B needs only 500 but C needs 600, hence require 600 from all three" is a healthy thing to continue. How bad it would become to split C at least from A and B, to give it an independent status, i.e. leaving the above line as-is, but insert #elif defined(OPENBSD) #define _XOPEN_SOURCE 700 before the existing catchall "#elif !defined(__APPLE__) && !defined(__FreeBSD__) ..." line? If there is somebody stilll on AIX who can test, we might go further by separating it out as well, but that would be a separate project that should be handled outside the scope of adjusting for OpenBSD. Thanks. > #define _XOPEN_SOURCE_EXTENDED 1 /* AIX 5.3L needs this */ > #endif > #define _ALL_SOURCE 1
> Is this a recent regression? Blaming these two line ranges ... > > > > > [1] https://github.com/openbsd/src/blob/6a403588e27467d1f271831ca1de62a3befea6a0/include/stdio.h#L236-L237 > > [2] https://github.com/openbsd/src/blob/6a403588e27467d1f271831ca1de62a3befea6a0/sys/sys/cdefs.h#L299-L302 > > ... in the OpenBSD repository says they haven't changed for many > years, and I am wondering what triggered this all of a sudden. > > If we know how we used to have no issue, in addition to how we now > have issue with the current OpenBSD (which you outlined very well > above), and when the situation changed, please add to the proposed > log message. That would help people on OpenBSD to decide when they > want to upgrade their copy of Git. The thing that changed was the release of clang 19, which enabled the mentioned Werror by default. This is showing up now because I am experimenting with building software for OpenBSD through nixpkgs, which prefers the most recent version of everything. I am not sure what of this is appropriate to add to the commit message. > Also, I am wondering if this "A and B needs only 500 but C needs > 600, hence require 600 from all three" is a healthy thing to > continue. How bad it would become to split C at least from A and B, > to give it an independent status, i.e. leaving the above line as-is, > but insert > > #elif defined(OPENBSD) > #define _XOPEN_SOURCE 700 > > before the existing catchall > "#elif !defined(__APPLE__) && !defined(__FreeBSD__) ..." line? I can give it a shot.
On Fri, Feb 21, 2025 at 01:41:08PM -0700, Audrey Dutcher wrote: > > Is this a recent regression? Blaming these two line ranges ... > > > > > > > > [1] https://github.com/openbsd/src/blob/6a403588e27467d1f271831ca1de62a3befea6a0/include/stdio.h#L236-L237 > > > [2] https://github.com/openbsd/src/blob/6a403588e27467d1f271831ca1de62a3befea6a0/sys/sys/cdefs.h#L299-L302 > > > > ... in the OpenBSD repository says they haven't changed for many > > years, and I am wondering what triggered this all of a sudden. > > > > If we know how we used to have no issue, in addition to how we now > > have issue with the current OpenBSD (which you outlined very well > > above), and when the situation changed, please add to the proposed > > log message. That would help people on OpenBSD to decide when they > > want to upgrade their copy of Git. > > The thing that changed was the release of clang 19, which enabled the > mentioned Werror by default. This is showing up now because I am > experimenting with building software for OpenBSD through nixpkgs, > which prefers the most recent version of everything. I am not sure > what of this is appropriate to add to the commit message. I'd guess a missing piece of the puzzle is your config.mak settings. We do not use getdelim() unless HAVE_GETDELIM is set, and our default platform settings in config.mak.uname do so only for Linux and macOS. There is a check for it in configure.ac, so if you are using autoconf, that may enable it in config.mak.autogen. But most Git developers (who ordinarily would build with -Werror) do not use autoconf. So that may explain why nobody complained about it until now. I do wonder if the autoconf test should be more picky about making sure it builds without warnings, but I'd guess those are usually lenient by default to avoid false negatives. All that said, fixing the source to build without warnings like you are doing is obviously the right thing to do. Patches to config.mak.uname to turn it on by default for OpenBSD would also be welcome. We tend to be conservative in flipping those switches, and wait until somebody who actively uses the platform and cares enough proposes a patch. -Peff
Audrey Dutcher <audrey@rhelmot.io> writes: >> Is this a recent regression? Blaming these two line ranges ... >> >> > >> > [1] https://github.com/openbsd/src/blob/6a403588e27467d1f271831ca1de62a3befea6a0/include/stdio.h#L236-L237 >> > [2] https://github.com/openbsd/src/blob/6a403588e27467d1f271831ca1de62a3befea6a0/sys/sys/cdefs.h#L299-L302 >> >> ... in the OpenBSD repository says they haven't changed for many >> years, and I am wondering what triggered this all of a sudden. >> >> If we know how we used to have no issue, in addition to how we now >> have issue with the current OpenBSD (which you outlined very well >> above), and when the situation changed, please add to the proposed >> log message. That would help people on OpenBSD to decide when they >> want to upgrade their copy of Git. > > The thing that changed was the release of clang 19, which enabled the > mentioned Werror by default. This is showing up now because I am > experimenting with building software for OpenBSD through nixpkgs, > which prefers the most recent version of everything. I am not sure > what of this is appropriate to add to the commit message. When reviewers help me by asking questions on what I wrote in a proposed commit log message, a trick I try to stick to is to pretend that they are not who are asking, but the question is coming from those who read the commit in the future and they do not have an easy way to ask me the question. The only way for me to help them is by updating the message they would read when they see the commit (IOW, I unfortunately would not have the luxury of going back-and-forth). In this case, if I were writing the message for the commit, "Unlike versions of clang earlier than 19, clang 19, enables the '-Werror=...' option by default...", would be something that would help them. And as Peff mentioned elsewhere in the thread, "When HAVE_GETDELIM is enabled" would also be an important clue to leave. Thanks.
diff --git a/git-compat-util.h b/git-compat-util.h index e123288e8f..f6902ca2e8 100644 --- a/git-compat-util.h +++ b/git-compat-util.h @@ -195,7 +195,7 @@ DISABLE_WARNING(-Wsign-compare) !defined(_M_UNIX) && !defined(__sgi) && !defined(__DragonFly__) && \ !defined(__TANDEM) && !defined(__QNX__) && !defined(__MirBSD__) && \ !defined(__CYGWIN__) -#define _XOPEN_SOURCE 600 /* glibc2 and AIX 5.3L need 500, OpenBSD needs 600 for S_ISLNK() */ +#define _XOPEN_SOURCE 700 /* glibc2 and AIX 5.3L need 500, OpenBSD needs 700 for getdelim() */ #define _XOPEN_SOURCE_EXTENDED 1 /* AIX 5.3L needs this */ #endif #define _ALL_SOURCE 1
On OpenBSD, getdelim() in <stdio.h> is behind __POSIX_VISIBLE >= 200809, which is in turn locked behind _XOPEN_SOURCE >= 700. Without this patch, compiling on OpenBSD 7.5 or 7.6, we get implicit declaration errors when compiling with -Werror=implicit-function-declaration (default in clang 19). [1] https://github.com/openbsd/src/blob/6a403588e27467d1f271831ca1de62a3befea6a0/include/stdio.h#L236-L237 [2] https://github.com/openbsd/src/blob/6a403588e27467d1f271831ca1de62a3befea6a0/sys/sys/cdefs.h#L299-L302 Signed-off-by: Audrey Dutcher <audrey@rhelmot.io> --- git-compat-util.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)