{"thread":{"id":"62988","subject":"[PATCH] git-compat-util.h: Bump _XOPEN_SOURCE on OpenBSD","startedAt":"2025-02-21T18:02:29Z","lastAt":"2025-02-22T02:07:51Z","messageCount":5,"participants":["Audrey Dutcher","Junio C Hamano","Jeff King"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"512839","messageId":"20250221180225.3176533-1-audrey@rhelmot.io","threadId":"62988","inReplyTo":null,"subject":"[PATCH] git-compat-util.h: Bump _XOPEN_SOURCE on OpenBSD","fromName":"Audrey Dutcher","fromEmail":"audrey@rhelmot.io","sentAt":"2025-02-21T18:02:25Z","receivedAt":"2025-02-21T18:02:29Z","isPatch":true,"sender":{"key":"audrey@rhelmot.io","avatar":null},"body":"On OpenBSD, getdelim() in <stdio.h> is behind __POSIX_VISIBLE >= 200809,\nwhich is in turn locked behind _XOPEN_SOURCE >= 700. Without this patch,\ncompiling on OpenBSD 7.5 or 7.6, we get implicit declaration errors\nwhen compiling with -Werror=implicit-function-declaration (default in\nclang 19).\n\n[1] https://github.com/openbsd/src/blob/6a403588e27467d1f271831ca1de62a3befea6a0/include/stdio.h#L236-L237\n[2] https://github.com/openbsd/src/blob/6a403588e27467d1f271831ca1de62a3befea6a0/sys/sys/cdefs.h#L299-L302\n\nSigned-off-by: Audrey Dutcher <audrey@rhelmot.io>\n---\n git-compat-util.h | 2 +-\n 1 file changed, 1 insertion(+), 1 deletion(-)\n\ndiff --git a/git-compat-util.h b/git-compat-util.h\nindex e123288e8f..f6902ca2e8 100644\n--- a/git-compat-util.h\n+++ b/git-compat-util.h\n@@ -195,7 +195,7 @@ DISABLE_WARNING(-Wsign-compare)\n       !defined(_M_UNIX) && !defined(__sgi) && !defined(__DragonFly__) && \\\n       !defined(__TANDEM) && !defined(__QNX__) && !defined(__MirBSD__) && \\\n       !defined(__CYGWIN__)\n-#define _XOPEN_SOURCE 600 /* glibc2 and AIX 5.3L need 500, OpenBSD needs 600 for S_ISLNK() */\n+#define _XOPEN_SOURCE 700 /* glibc2 and AIX 5.3L need 500, OpenBSD needs 700 for getdelim() */\n #define _XOPEN_SOURCE_EXTENDED 1 /* AIX 5.3L needs this */\n #endif\n #define _ALL_SOURCE 1\n-- \n2.43.0\n\n"},{"id":"512857","messageId":"xmqqeczr9guk.fsf@gitster.g","threadId":"62988","inReplyTo":"20250221180225.3176533-1-audrey@rhelmot.io","subject":"Re: [PATCH] git-compat-util.h: Bump _XOPEN_SOURCE on OpenBSD","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2025-02-21T20:34:59Z","receivedAt":"2025-02-21T20:35:02Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Audrey Dutcher <audrey@rhelmot.io> writes:\n\n> On OpenBSD, getdelim() in <stdio.h> is behind __POSIX_VISIBLE >= 200809,\n> which is in turn locked behind _XOPEN_SOURCE >= 700. Without this patch,\n> compiling on OpenBSD 7.5 or 7.6, we get implicit declaration errors\n> when compiling with -Werror=implicit-function-declaration (default in\n> clang 19).\n\nIs this a recent regression?  Blaming these two line ranges ...\n\n>\n> [1] https://github.com/openbsd/src/blob/6a403588e27467d1f271831ca1de62a3befea6a0/include/stdio.h#L236-L237\n> [2] https://github.com/openbsd/src/blob/6a403588e27467d1f271831ca1de62a3befea6a0/sys/sys/cdefs.h#L299-L302\n\n... in the OpenBSD repository says they haven't changed for many\nyears, and I am wondering what triggered this all of a sudden.\n\nIf we know how we used to have no issue, in addition to how we now\nhave issue with the current OpenBSD (which you outlined very well\nabove), and when the situation changed, please add to the proposed\nlog message.  That would help people on OpenBSD to decide when they\nwant to upgrade their copy of Git.\n\n> Signed-off-by: Audrey Dutcher <audrey@rhelmot.io>\n> ---\n>  git-compat-util.h | 2 +-\n>  1 file changed, 1 insertion(+), 1 deletion(-)\n>\n> diff --git a/git-compat-util.h b/git-compat-util.h\n> index e123288e8f..f6902ca2e8 100644\n> --- a/git-compat-util.h\n> +++ b/git-compat-util.h\n> @@ -195,7 +195,7 @@ DISABLE_WARNING(-Wsign-compare)\n>        !defined(_M_UNIX) && !defined(__sgi) && !defined(__DragonFly__) && \\\n>        !defined(__TANDEM) && !defined(__QNX__) && !defined(__MirBSD__) && \\\n>        !defined(__CYGWIN__)\n> -#define _XOPEN_SOURCE 600 /* glibc2 and AIX 5.3L need 500, OpenBSD needs 600 for S_ISLNK() */\n> +#define _XOPEN_SOURCE 700 /* glibc2 and AIX 5.3L need 500, OpenBSD needs 700 for getdelim() */\n\nAlso, I am wondering if this \"A and B needs only 500 but C needs\n600, hence require 600 from all three\" is a healthy thing to\ncontinue.  How bad it would become to split C at least from A and B,\nto give it an independent status, i.e. leaving the above line as-is,\nbut insert\n\n\t#elif defined(OPENBSD)\n\t#define _XOPEN_SOURCE 700\n\nbefore the existing catchall\n\"#elif !defined(__APPLE__) && !defined(__FreeBSD__) ...\"  line?\n\nIf there is somebody stilll on AIX who can test, we might go further\nby separating it out as well, but that would be a separate project\nthat should be handled outside the scope of adjusting for OpenBSD.\n\nThanks.\n\n\n>  #define _XOPEN_SOURCE_EXTENDED 1 /* AIX 5.3L needs this */\n>  #endif\n>  #define _ALL_SOURCE 1\n"},{"id":"512858","messageId":"CADanSV3w++kkTgedLQorKgJ15kc5bEkNvYTidRU1UbwW4jCC6Q@mail.gmail.com","threadId":"62988","inReplyTo":"xmqqeczr9guk.fsf@gitster.g","subject":"Re: [PATCH] git-compat-util.h: Bump _XOPEN_SOURCE on OpenBSD","fromName":"Audrey Dutcher","fromEmail":"audrey@rhelmot.io","sentAt":"2025-02-21T20:41:08Z","receivedAt":"2025-02-21T20:41:20Z","isPatch":true,"sender":{"key":"audrey@rhelmot.io","avatar":null},"body":"> Is this a recent regression?  Blaming these two line ranges ...\n>\n> >\n> > [1] https://github.com/openbsd/src/blob/6a403588e27467d1f271831ca1de62a3befea6a0/include/stdio.h#L236-L237\n> > [2] https://github.com/openbsd/src/blob/6a403588e27467d1f271831ca1de62a3befea6a0/sys/sys/cdefs.h#L299-L302\n>\n> ... in the OpenBSD repository says they haven't changed for many\n> years, and I am wondering what triggered this all of a sudden.\n>\n> If we know how we used to have no issue, in addition to how we now\n> have issue with the current OpenBSD (which you outlined very well\n> above), and when the situation changed, please add to the proposed\n> log message.  That would help people on OpenBSD to decide when they\n> want to upgrade their copy of Git.\n\nThe thing that changed was the release of clang 19, which enabled the\nmentioned Werror by default. This is showing up now because I am\nexperimenting with building software for OpenBSD through nixpkgs,\nwhich prefers the most recent version of everything. I am not sure\nwhat of this is appropriate to add to the commit message.\n\n> Also, I am wondering if this \"A and B needs only 500 but C needs\n> 600, hence require 600 from all three\" is a healthy thing to\n> continue.  How bad it would become to split C at least from A and B,\n> to give it an independent status, i.e. leaving the above line as-is,\n> but insert\n>\n>         #elif defined(OPENBSD)\n>         #define _XOPEN_SOURCE 700\n>\n> before the existing catchall\n> \"#elif !defined(__APPLE__) && !defined(__FreeBSD__) ...\"  line?\n\nI can give it a shot.\n"},{"id":"512859","messageId":"20250221205448.GA3069593@coredump.intra.peff.net","threadId":"62988","inReplyTo":"CADanSV3w++kkTgedLQorKgJ15kc5bEkNvYTidRU1UbwW4jCC6Q@mail.gmail.com","subject":"Re: [PATCH] git-compat-util.h: Bump _XOPEN_SOURCE on OpenBSD","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2025-02-21T20:54:48Z","receivedAt":"2025-02-21T20:54:52Z","isPatch":true,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Fri, Feb 21, 2025 at 01:41:08PM -0700, Audrey Dutcher wrote:\n\n> > Is this a recent regression?  Blaming these two line ranges ...\n> >\n> > >\n> > > [1] https://github.com/openbsd/src/blob/6a403588e27467d1f271831ca1de62a3befea6a0/include/stdio.h#L236-L237\n> > > [2] https://github.com/openbsd/src/blob/6a403588e27467d1f271831ca1de62a3befea6a0/sys/sys/cdefs.h#L299-L302\n> >\n> > ... in the OpenBSD repository says they haven't changed for many\n> > years, and I am wondering what triggered this all of a sudden.\n> >\n> > If we know how we used to have no issue, in addition to how we now\n> > have issue with the current OpenBSD (which you outlined very well\n> > above), and when the situation changed, please add to the proposed\n> > log message.  That would help people on OpenBSD to decide when they\n> > want to upgrade their copy of Git.\n> \n> The thing that changed was the release of clang 19, which enabled the\n> mentioned Werror by default. This is showing up now because I am\n> experimenting with building software for OpenBSD through nixpkgs,\n> which prefers the most recent version of everything. I am not sure\n> what of this is appropriate to add to the commit message.\n\nI'd guess a missing piece of the puzzle is your config.mak settings. We\ndo not use getdelim() unless HAVE_GETDELIM is set, and our default\nplatform settings in config.mak.uname do so only for Linux and macOS.\n\nThere is a check for it in configure.ac, so if you are using autoconf,\nthat may enable it in config.mak.autogen. But most Git developers (who\nordinarily would build with -Werror) do not use autoconf. So that may\nexplain why nobody complained about it until now.\n\nI do wonder if the autoconf test should be more picky about making sure\nit builds without warnings, but I'd guess those are usually lenient by\ndefault to avoid false negatives.\n\nAll that said, fixing the source to build without warnings like you are\ndoing is obviously the right thing to do.\n\nPatches to config.mak.uname to turn it on by default for OpenBSD would\nalso be welcome. We tend to be conservative in flipping those switches,\nand wait until somebody who actively uses the platform and cares enough\nproposes a patch.\n\n-Peff\n"},{"id":"512868","messageId":"xmqqplja91fu.fsf@gitster.g","threadId":"62988","inReplyTo":"CADanSV3w++kkTgedLQorKgJ15kc5bEkNvYTidRU1UbwW4jCC6Q@mail.gmail.com","subject":"Re: [PATCH] git-compat-util.h: Bump _XOPEN_SOURCE on OpenBSD","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2025-02-22T02:07:49Z","receivedAt":"2025-02-22T02:07:51Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Audrey Dutcher <audrey@rhelmot.io> writes:\n\n>> Is this a recent regression?  Blaming these two line ranges ...\n>>\n>> >\n>> > [1] https://github.com/openbsd/src/blob/6a403588e27467d1f271831ca1de62a3befea6a0/include/stdio.h#L236-L237\n>> > [2] https://github.com/openbsd/src/blob/6a403588e27467d1f271831ca1de62a3befea6a0/sys/sys/cdefs.h#L299-L302\n>>\n>> ... in the OpenBSD repository says they haven't changed for many\n>> years, and I am wondering what triggered this all of a sudden.\n>>\n>> If we know how we used to have no issue, in addition to how we now\n>> have issue with the current OpenBSD (which you outlined very well\n>> above), and when the situation changed, please add to the proposed\n>> log message.  That would help people on OpenBSD to decide when they\n>> want to upgrade their copy of Git.\n>\n> The thing that changed was the release of clang 19, which enabled the\n> mentioned Werror by default. This is showing up now because I am\n> experimenting with building software for OpenBSD through nixpkgs,\n> which prefers the most recent version of everything. I am not sure\n> what of this is appropriate to add to the commit message.\n\nWhen reviewers help me by asking questions on what I wrote in a\nproposed commit log message, a trick I try to stick to is to pretend\nthat they are not who are asking, but the question is coming from\nthose who read the commit in the future and they do not have an easy\nway to ask me the question.  The only way for me to help them is by\nupdating the message they would read when they see the commit (IOW,\nI unfortunately would not have the luxury of going back-and-forth).\n\nIn this case, if I were writing the message for the commit, \"Unlike\nversions of clang earlier than 19, clang 19, enables the\n'-Werror=...' option by default...\", would be something that would\nhelp them.  And as Peff mentioned elsewhere in the thread, \"When\nHAVE_GETDELIM is enabled\" would also be an important clue to leave.\n\nThanks.\n"}]}