{"thread":{"id":"62322","subject":"git no longer builds on SunOS 5.10, a report","startedAt":"2024-10-12T02:10:43Z","lastAt":"2024-11-08T12:59:18Z","messageCount":30,"participants":["Alejandro R. Sedeño","Patrick Steinhardt","Toon Claes","Taylor Blau","Kristoffer Haugsbakk","karthik nayak","Bagas Sanjaya","Johannes Schindelin","Phillip Wood"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"504895","messageId":"CAOO-Oz3KsyeSjxbRpU-SdPgU5K+mPDcntT6Y4s46Mg_0ko9e_w@mail.gmail.com","threadId":"62322","inReplyTo":null,"subject":"git no longer builds on SunOS 5.10, a report","fromName":"Alejandro R. Sedeño","fromEmail":"asedeno@mit.edu","sentAt":"2024-10-12T02:10:26Z","receivedAt":"2024-10-12T02:10:43Z","isPatch":false,"sender":{"key":"asedeno@mit.edu","avatar":"https://avatars.githubusercontent.com/u/28302?v=4"},"body":"Hi all,\n\nI've spent the entire day trying to fix the build for SunOS 5.10, as\nI've done a few times over the years out of sheer stubbornness, but\nthis time I'm throwing in the towel. I figured I would at least relay\nwhat I found though, in case anyone else came looking.\n\nFirst, clar.suite was generated as broken because clar-decls.h was\ngenerated as empty. Tweaking the sed one-liner in Makefile that is\nused to generate clar-decls.h fixed that (move the end-of-line marker\noutside of the capture group, `$$\\)` -> `\\)$$`), which I would submit\nas a patch, but (a) that only fixed part of the problem and (b) I'm\nnot entirely sure why it helped. If someone else wants to apply this\nchange, which would align the end-of-line marker placement with the\nstart-of-line marker placement, have at it.\n\nThe next issue was that clar/sandbox.h uses mkdtemp, which I don't\nhave here. Git has solved this in compat/mkdtemp.c via\ngit-compat-util.h, but clar is not using it. Adding git-compat-util.h\nto clar/sandbox.h feels weird, but does get us further along. That\nchange introduced banned.h into clar, which exposed the use of strncpy\nand localtime, both otherwise banned in git.\n\nIncluding git-compat-util.h in clar/sandbox.h (bringing in mkdtemp,\nand replacing strncpy with strlcpy) and clar/summary.h (replacing\nlocaltime with localtime_r) leads to our next issue: a redefinition of\n_FILE_OFFSET_BITS, which is defined unconditionally in\ngit-compat-util.h, because clar.c imports system headers that define\nit first. git-compat-util.h is meant to be included first, so, I added\ngit-compat-util.h to the top of clar.c. That caused system includes\nvia <wchar.h> to no longer compile due to syntax errors. This is where\nI gave up.\n\nI'm sad that I can no longer build git on this old version of SunOS,\nand that it's the newly-imported unit-testing framework and not git\nitself that is preventing me from building it. Given the talk of\nadding rust to git, and of bumping the perl requirements to 5.26.0 (I\nhave a system 5.8.3, and a 5.10.1 for building openssl), this moment\nwas inevitable. On the plus side, this was the slowest platform I\nbuilt git on, so perhaps I should be happy about my new free time.\n\nPlease note that this should not be read as opposition to the new\nunit-testing framework in any way. Building git (and curl, and gmake,\nand zlib, and openssl, and perl, all for git) for SunOS was a hobby\nfor me, and not anything I personally need, and besides, it's not like\nmy previous builds have disappeared.\n\nThe last successful build for me was 2.45.2. I've built or tried to\nbuild most versions since 1.6.6. Some of my build infrastructure was\nunavailable since sometime after 2.45.2, so I have not tried 2.46.x,\nbut it lacks clar, so I expect it would build fine.\n\nCheers,\n-Alejandro\n"},{"id":"504909","messageId":"ZwoxHYD-e4qo7OyW@pks.im","threadId":"62322","inReplyTo":"CAOO-Oz3KsyeSjxbRpU-SdPgU5K+mPDcntT6Y4s46Mg_0ko9e_w@mail.gmail.com","subject":"Re: git no longer builds on SunOS 5.10, a report","fromName":"Patrick Steinhardt","fromEmail":"ps@pks.im","sentAt":"2024-10-12T08:19:55Z","receivedAt":"2024-10-12T08:20:03Z","isPatch":false,"sender":{"key":"ps@pks.im","avatar":"https://avatars.githubusercontent.com/u/4056630?v=4"},"body":"On Fri, Oct 11, 2024 at 10:10:26PM -0400, Alejandro R. Sedeño wrote:\n> First, clar.suite was generated as broken because clar-decls.h was\n> generated as empty. Tweaking the sed one-liner in Makefile that is\n> used to generate clar-decls.h fixed that (move the end-of-line marker\n> outside of the capture group, `$$\\)` -> `\\)$$`), which I would submit\n> as a patch, but (a) that only fixed part of the problem and (b) I'm\n> not entirely sure why it helped. If someone else wants to apply this\n> change, which would align the end-of-line marker placement with the\n> start-of-line marker placement, have at it.\n\nI'd still appreciate it if you could show me the diff. From thereon I\ncan handle the rest.\n\n> The next issue was that clar/sandbox.h uses mkdtemp, which I don't\n> have here. Git has solved this in compat/mkdtemp.c via\n> git-compat-util.h, but clar is not using it. Adding git-compat-util.h\n> to clar/sandbox.h feels weird, but does get us further along. That\n> change introduced banned.h into clar, which exposed the use of strncpy\n> and localtime, both otherwise banned in git.\n\nYeah, we don't want to pull in that header. The clar is from upstream,\nso ideally we shouldn't have to modify it with non-upstreamable bits.\n\nIn any case, I've got a similar report yesterday where some functions\nweren't available. The root cause is that we don't set `_POSIX_C_SOURCE`\nin \"clar.c\", so with the below patch things started to work. Does that\npatch work for you, too? At least I think it should, as [1] mentions\nthat the function is available on SunOS when those defines exist.\n\nIn any case, the patch has already been merged upstream [2], and I'll\nsend a patch early next week that updates our bundled version of clar.\n\n[1]: https://www.unix.com/man-page/sunos/3/MKDTEMP/\n[2]: https://github.com/clar-test/clar/pull/106\n\n[snip]\n> Please note that this should not be read as opposition to the new\n> unit-testing framework in any way. Building git (and curl, and gmake,\n> and zlib, and openssl, and perl, all for git) for SunOS was a hobby\n> for me, and not anything I personally need, and besides, it's not like\n> my previous builds have disappeared.\n\nSure. But if the fix is easy enough I don't see a reason why we\nshouldn't try to support your platform. It would be great to get earlier\nfeedback such that we can fix issues like this before we create the\nrelease (see also our Documentation/technical/platform-support.txt,\nwhich we have released recently.). But I'll take what I can get, so\nthanks a lot for sending the report in the first place!\n\nPatrick\n\ndiff --git a/t/unit-tests/clar/clar.c b/t/unit-tests/clar/clar.c\nindex cef0f023c24..76557df3040 100644\n--- a/t/unit-tests/clar/clar.c\n+++ b/t/unit-tests/clar/clar.c\n@@ -4,6 +4,10 @@\n  * This file is part of clar, distributed under the ISC license.\n  * For full terms see the included COPYING file.\n  */\n+\n+#define _DARWIN_C_SOURCE\n+#define _POSIX_C_SOURCE 200809L\n+\n #include <assert.h>\n #include <setjmp.h>\n #include <stdlib.h>\n@@ -271,9 +275,7 @@ static double clar_time_diff(clar_time *start, clar_time *end)\n \n static void clar_time_now(clar_time *out)\n {\n-\tstruct timezone tz;\n-\n-\tgettimeofday(out, &tz);\n+\tgettimeofday(out, NULL);\n }\n \n static double clar_time_diff(clar_time *start, clar_time *end)\n"},{"id":"504914","messageId":"CAOO-Oz0+sOpF6YQHSu0ytCO5TL+Anpr1k_9vQx6hebr624WjMA@mail.gmail.com","threadId":"62322","inReplyTo":"ZwoxHYD-e4qo7OyW@pks.im","subject":"Re: git no longer builds on SunOS 5.10, a report","fromName":"Alejandro R. Sedeño","fromEmail":"asedeno@mit.edu","sentAt":"2024-10-12T14:34:18Z","receivedAt":"2024-10-12T14:34:35Z","isPatch":false,"sender":{"key":"asedeno@mit.edu","avatar":"https://avatars.githubusercontent.com/u/28302?v=4"},"body":"On Sat, Oct 12, 2024 at 4:20 AM Patrick Steinhardt <ps@pks.im> wrote:\n>\n> On Fri, Oct 11, 2024 at 10:10:26PM -0400, Alejandro R. Sedeño wrote:\n> > First, clar.suite was generated as broken because clar-decls.h was\n> > generated as empty. Tweaking the sed one-liner in Makefile that is\n> > used to generate clar-decls.h fixed that (move the end-of-line marker\n> > outside of the capture group, `$$\\)` -> `\\)$$`), which I would submit\n> > as a patch, but (a) that only fixed part of the problem and (b) I'm\n> > not entirely sure why it helped. If someone else wants to apply this\n> > change, which would align the end-of-line marker placement with the\n> > start-of-line marker placement, have at it.\n>\n> I'd still appreciate it if you could show me the diff. From thereon I\n> can handle the rest.\n\ndiff --git a/Makefile b/Makefile\nindex 2dde1fd2b8..87c1f9e220 100644\n--- a/Makefile\n+++ b/Makefile\n@@ -3906,7 +3906,7 @@ GIT-TEST-SUITES: FORCE\n\n $(UNIT_TEST_DIR)/clar-decls.h: $(patsubst\n%,$(UNIT_TEST_DIR)/%.c,$(CLAR_TEST_SUITES)) GIT-TEST-SUITES\n        $(QUIET_GEN)for suite in $(CLAR_TEST_SUITES); do \\\n-               sed -ne \"s/^\\(void\ntest_$${suite}__[a-zA-Z_0-9][a-zA-Z_0-9]*(void)$$\\)/extern \\1;/p\"\n$(UNIT_TEST_DIR)/$$suite.c; \\\n+               sed -ne \"s/^\\(void\ntest_$${suite}__[a-zA-Z_0-9][a-zA-Z_0-9]*(void)\\)$$/extern \\1;/p\"\n$(UNIT_TEST_DIR)/$$suite.c; \\\n        done >$@\n $(UNIT_TEST_DIR)/clar.suite: $(UNIT_TEST_DIR)/clar-decls.h\n        $(QUIET_GEN)awk -f $(UNIT_TEST_DIR)/clar-generate.awk $<\n>$(UNIT_TEST_DIR)/clar.suite\n\nOr feel free to grab the entire commit from here:\nhttps://asedeno.scripts.mit.edu/gitweb/?p=git.git;a=shortlog;h=refs/heads/clar_sed_tweak\n\n> > The next issue was that clar/sandbox.h uses mkdtemp, which I don't\n> > have here. Git has solved this in compat/mkdtemp.c via\n> > git-compat-util.h, but clar is not using it. Adding git-compat-util.h\n> > to clar/sandbox.h feels weird, but does get us further along. That\n> > change introduced banned.h into clar, which exposed the use of strncpy\n> > and localtime, both otherwise banned in git.\n>\n> Yeah, we don't want to pull in that header. The clar is from upstream,\n> so ideally we shouldn't have to modify it with non-upstreamable bits.\n>\n> In any case, I've got a similar report yesterday where some functions\n> weren't available. The root cause is that we don't set `_POSIX_C_SOURCE`\n> in \"clar.c\", so with the below patch things started to work. Does that\n> patch work for you, too? At least I think it should, as [1] mentions\n> that the function is available on SunOS when those defines exist.\n>\n> In any case, the patch has already been merged upstream [2], and I'll\n> send a patch early next week that updates our bundled version of clar.\n>\n> [1]: https://www.unix.com/man-page/sunos/3/MKDTEMP/\n> [2]: https://github.com/clar-test/clar/pull/106\n\nThe listed man page is from the Linux Programmer's Manual, regardless of\nthe url path. It won't be enough here as mkdtemp is nowhere to be found\nin /usr/include or any other /usr/**/include.\n\nFor what it's worth, the compat objects are being linked in, so perhaps a\nsmaller compat shim for clar that brings in definitions for mkdtemp, mkdir,\nand whatever else might be handy without the weight of git-compat-util.h\nwould be a reasonable compromise. Maybe not. I don't know.\n\n> [snip]\n> > Please note that this should not be read as opposition to the new\n> > unit-testing framework in any way. Building git (and curl, and gmake,\n> > and zlib, and openssl, and perl, all for git) for SunOS was a hobby\n> > for me, and not anything I personally need, and besides, it's not like\n> > my previous builds have disappeared.\n>\n> Sure. But if the fix is easy enough I don't see a reason why we\n> shouldn't try to support your platform. It would be great to get earlier\n> feedback such that we can fix issues like this before we create the\n> release (see also our Documentation/technical/platform-support.txt,\n> which we have released recently.). But I'll take what I can get, so\n> thanks a lot for sending the report in the first place!\n\nI appreciate that. Builds here are very slow, which is why I usually only\nbuild releases. The effort that went into this report would have taken\nmaybe an hour or two on any other platform I use.\n\nOh, and for the sake of future readers of the thread, git v2.46.2 did build.\n\nThanks,\n-Alejandro\n"},{"id":"504915","messageId":"20241012144027.2573690-1-asedeno@mit.edu","threadId":"62322","inReplyTo":"CAOO-Oz0+sOpF6YQHSu0ytCO5TL+Anpr1k_9vQx6hebr624WjMA@mail.gmail.com","subject":"[PATCH] Makefile: adjust sed command for generating \"clar-decls.h\"","fromName":"Alejandro R. Sedeño","fromEmail":"asedeno@mit.edu","sentAt":"2024-10-12T14:40:27Z","receivedAt":"2024-10-12T14:41:19Z","isPatch":true,"sender":{"key":"asedeno@mit.edu","avatar":"https://avatars.githubusercontent.com/u/28302?v=4"},"body":"This moves the end-of-line marker out of the captured group, matching\nthe start-of-line marker and for some reason fixing generation of\n\"clar-decls.h\" on some older, more esoteric platforms.\n\nSigned-off-by: Alejandro R. Sedeño <asedeno@mit.edu>\nSigned-off-by: Alejandro R. Sedeño <asedeno@google.com>\n---\n Makefile | 2 +-\n 1 file changed, 1 insertion(+), 1 deletion(-)\n\ndiff --git a/Makefile b/Makefile\nindex 2dde1fd2b8..87c1f9e220 100644\n--- a/Makefile\n+++ b/Makefile\n@@ -3906,7 +3906,7 @@ GIT-TEST-SUITES: FORCE\n \n $(UNIT_TEST_DIR)/clar-decls.h: $(patsubst %,$(UNIT_TEST_DIR)/%.c,$(CLAR_TEST_SUITES)) GIT-TEST-SUITES\n \t$(QUIET_GEN)for suite in $(CLAR_TEST_SUITES); do \\\n-\t\tsed -ne \"s/^\\(void test_$${suite}__[a-zA-Z_0-9][a-zA-Z_0-9]*(void)$$\\)/extern \\1;/p\" $(UNIT_TEST_DIR)/$$suite.c; \\\n+\t\tsed -ne \"s/^\\(void test_$${suite}__[a-zA-Z_0-9][a-zA-Z_0-9]*(void)\\)$$/extern \\1;/p\" $(UNIT_TEST_DIR)/$$suite.c; \\\n \tdone >$@\n $(UNIT_TEST_DIR)/clar.suite: $(UNIT_TEST_DIR)/clar-decls.h\n \t$(QUIET_GEN)awk -f $(UNIT_TEST_DIR)/clar-generate.awk $< >$(UNIT_TEST_DIR)/clar.suite\n-- \n2.39.5\n\n"},{"id":"504916","messageId":"CAOO-Oz3fTJDC8W6mF-bawn=+9-=s2hLiMDP=16C5DVYgw7cb_A@mail.gmail.com","threadId":"62322","inReplyTo":"CAOO-Oz0+sOpF6YQHSu0ytCO5TL+Anpr1k_9vQx6hebr624WjMA@mail.gmail.com","subject":"Re: git no longer builds on SunOS 5.10, a report","fromName":"Alejandro R. Sedeño","fromEmail":"asedeno@mit.edu","sentAt":"2024-10-12T14:42:35Z","receivedAt":"2024-10-12T14:42:52Z","isPatch":false,"sender":{"key":"asedeno@mit.edu","avatar":"https://avatars.githubusercontent.com/u/28302?v=4"},"body":"On Sat, Oct 12, 2024 at 10:34 AM Alejandro R. Sedeño <asedeno@mit.edu>\nwrote and gmail mangled:\n> diff --git a/Makefile b/Makefile\n> index 2dde1fd2b8..87c1f9e220 100644\n> --- a/Makefile\n> +++ b/Makefile\n<snip>\n\nresent as a whole patch via git send-email, since that was just sad.\n\n-Alejandro\n"},{"id":"504954","messageId":"ZwwmFtF1Y30y8eoU@pks.im","threadId":"62322","inReplyTo":"CAOO-Oz0+sOpF6YQHSu0ytCO5TL+Anpr1k_9vQx6hebr624WjMA@mail.gmail.com","subject":"Re: git no longer builds on SunOS 5.10, a report","fromName":"Patrick Steinhardt","fromEmail":"ps@pks.im","sentAt":"2024-10-13T19:57:10Z","receivedAt":"2024-10-13T19:57:02Z","isPatch":false,"sender":{"key":"ps@pks.im","avatar":"https://avatars.githubusercontent.com/u/4056630?v=4"},"body":"On Sat, Oct 12, 2024 at 10:34:18AM -0400, Alejandro R. Sedeño wrote:\n> On Sat, Oct 12, 2024 at 4:20 AM Patrick Steinhardt <ps@pks.im> wrote:\n> > On Fri, Oct 11, 2024 at 10:10:26PM -0400, Alejandro R. Sedeño wrote:\n> diff --git a/Makefile b/Makefile\n> index 2dde1fd2b8..87c1f9e220 100644\n> --- a/Makefile\n> +++ b/Makefile\n> @@ -3906,7 +3906,7 @@ GIT-TEST-SUITES: FORCE\n> \n>  $(UNIT_TEST_DIR)/clar-decls.h: $(patsubst\n> %,$(UNIT_TEST_DIR)/%.c,$(CLAR_TEST_SUITES)) GIT-TEST-SUITES\n>         $(QUIET_GEN)for suite in $(CLAR_TEST_SUITES); do \\\n> -               sed -ne \"s/^\\(void\n> test_$${suite}__[a-zA-Z_0-9][a-zA-Z_0-9]*(void)$$\\)/extern \\1;/p\"\n> $(UNIT_TEST_DIR)/$$suite.c; \\\n> +               sed -ne \"s/^\\(void\n> test_$${suite}__[a-zA-Z_0-9][a-zA-Z_0-9]*(void)\\)$$/extern \\1;/p\"\n> $(UNIT_TEST_DIR)/$$suite.c; \\\n>         done >$@\n>  $(UNIT_TEST_DIR)/clar.suite: $(UNIT_TEST_DIR)/clar-decls.h\n>         $(QUIET_GEN)awk -f $(UNIT_TEST_DIR)/clar-generate.awk $<\n> >$(UNIT_TEST_DIR)/clar.suite\n> \n> Or feel free to grab the entire commit from here:\n> https://asedeno.scripts.mit.edu/gitweb/?p=git.git;a=shortlog;h=refs/heads/clar_sed_tweak\n\nThanks!\n\n> > > The next issue was that clar/sandbox.h uses mkdtemp, which I don't\n> > > have here. Git has solved this in compat/mkdtemp.c via\n> > > git-compat-util.h, but clar is not using it. Adding git-compat-util.h\n> > > to clar/sandbox.h feels weird, but does get us further along. That\n> > > change introduced banned.h into clar, which exposed the use of strncpy\n> > > and localtime, both otherwise banned in git.\n> >\n> > Yeah, we don't want to pull in that header. The clar is from upstream,\n> > so ideally we shouldn't have to modify it with non-upstreamable bits.\n> >\n> > In any case, I've got a similar report yesterday where some functions\n> > weren't available. The root cause is that we don't set `_POSIX_C_SOURCE`\n> > in \"clar.c\", so with the below patch things started to work. Does that\n> > patch work for you, too? At least I think it should, as [1] mentions\n> > that the function is available on SunOS when those defines exist.\n> >\n> > In any case, the patch has already been merged upstream [2], and I'll\n> > send a patch early next week that updates our bundled version of clar.\n> >\n> > [1]: https://www.unix.com/man-page/sunos/3/MKDTEMP/\n> > [2]: https://github.com/clar-test/clar/pull/106\n> \n> The listed man page is from the Linux Programmer's Manual, regardless of\n> the url path. It won't be enough here as mkdtemp is nowhere to be found\n> in /usr/include or any other /usr/**/include.\n\nOkay. I assume that both mktemp and mkdir are available though, right?\nIf so, does the below patch work? The last bit is new, where we now use\nthe same mkdtemp implementation as we use on NonStop in clar.\n\nPatrick\n\ndiff --git a/t/unit-tests/clar/clar.c b/t/unit-tests/clar/clar.c\nindex cef0f023c2..064ca5c2ea 100644\n--- a/t/unit-tests/clar/clar.c\n+++ b/t/unit-tests/clar/clar.c\n@@ -4,6 +4,10 @@\n  * This file is part of clar, distributed under the ISC license.\n  * For full terms see the included COPYING file.\n  */\n+\n+#define _DARWIN_C_SOURCE\n+#define _POSIX_C_SOURCE=200809L\n+\n #include <assert.h>\n #include <setjmp.h>\n #include <stdlib.h>\n@@ -271,9 +275,7 @@ static double clar_time_diff(clar_time *start, clar_time *end)\n \n static void clar_time_now(clar_time *out)\n {\n-\tstruct timezone tz;\n-\n-\tgettimeofday(out, &tz);\n+\tgettimeofday(out, NULL);\n }\n \n static double clar_time_diff(clar_time *start, clar_time *end)\ndiff --git a/t/unit-tests/clar/clar/sandbox.h b/t/unit-tests/clar/clar/sandbox.h\nindex e25057b7c4..b499d2e1e6 100644\n--- a/t/unit-tests/clar/clar/sandbox.h\n+++ b/t/unit-tests/clar/clar/sandbox.h\n@@ -122,7 +122,7 @@ static int build_sandbox_path(void)\n \n \tif (mkdir(_clar_path, 0700) != 0)\n \t\treturn -1;\n-#elif defined(__TANDEM)\n+#elif defined(__sunos) || defined(__TANDEM)\n \tif (mktemp(_clar_path) == NULL)\n \t\treturn -1;\n \n"},{"id":"504959","messageId":"CAOO-Oz2gN1Y9h-p_AJ=7iKzxOK2ShmgEmWzpFrpwwAD2GH=6TQ@mail.gmail.com","threadId":"62322","inReplyTo":"ZwwmFtF1Y30y8eoU@pks.im","subject":"Re: git no longer builds on SunOS 5.10, a report","fromName":"Alejandro R. Sedeño","fromEmail":"asedeno@mit.edu","sentAt":"2024-10-13T22:50:09Z","receivedAt":"2024-10-13T22:50:25Z","isPatch":false,"sender":{"key":"asedeno@mit.edu","avatar":"https://avatars.githubusercontent.com/u/28302?v=4"},"body":"On Sun, Oct 13, 2024 at 3:57 PM Patrick Steinhardt <ps@pks.im> wrote:\n> diff --git a/t/unit-tests/clar/clar.c b/t/unit-tests/clar/clar.c\n> index cef0f023c2..064ca5c2ea 100644\n> --- a/t/unit-tests/clar/clar.c\n> +++ b/t/unit-tests/clar/clar.c\n> @@ -4,6 +4,10 @@\n>   * This file is part of clar, distributed under the ISC license.\n>   * For full terms see the included COPYING file.\n>   */\n> +\n> +#define _DARWIN_C_SOURCE\n> +#define _POSIX_C_SOURCE=200809L\n\ntoken \"=\" is not valid in preprocessor expressions.\n\n2008 postdates my available compiler by many years, so trying to define this\nis not going to get you everything you might expect here.\n\nFixing the #define to use a space and not = results in\n\n/usr/include/sys/feature_tests.h:332:2: #error \"Compiler or options\ninvalid for pre-UNIX 03 X/Open applications and pre-2001 POSIX\napplications\"\n\nThe relevant bits of the header:\n\n#if defined(_STDC_C99) && (defined(__XOPEN_OR_POSIX) && !defined(_XPG6))\n#error \"Compiler or options invalid for pre-UNIX 03 X/Open applications \\\n        and pre-2001 POSIX applications\"\n#elif !defined(_STDC_C99) && \\\n        (defined(__XOPEN_OR_POSIX) && defined(_XPG6))\n#error \"Compiler or options invalid; UNIX 03 and POSIX.1-2001 applications \\\n        require the use of c99\"\n#endif\n\nRemoving `#define _POSIX_C_SOURCE 200809L` results in successful compilation.\n\n> +\n>  #include <assert.h>\n>  #include <setjmp.h>\n>  #include <stdlib.h>\n> @@ -271,9 +275,7 @@ static double clar_time_diff(clar_time *start, clar_time *end)\n>\n>  static void clar_time_now(clar_time *out)\n>  {\n> -       struct timezone tz;\n> -\n> -       gettimeofday(out, &tz);\n> +       gettimeofday(out, NULL);\n>  }\n>\n>  static double clar_time_diff(clar_time *start, clar_time *end)\n> diff --git a/t/unit-tests/clar/clar/sandbox.h b/t/unit-tests/clar/clar/sandbox.h\n> index e25057b7c4..b499d2e1e6 100644\n> --- a/t/unit-tests/clar/clar/sandbox.h\n> +++ b/t/unit-tests/clar/clar/sandbox.h\n> @@ -122,7 +122,7 @@ static int build_sandbox_path(void)\n>\n>         if (mkdir(_clar_path, 0700) != 0)\n>                 return -1;\n> -#elif defined(__TANDEM)\n> +#elif defined(__sunos) || defined(__TANDEM)\n\nI think we want __sun here, not __sunos.\n\n>         if (mktemp(_clar_path) == NULL)\n>                 return -1;\n>\n\n-Alejandro\n"},{"id":"504971","messageId":"Zwy4NUHQ3zpzkaXU@pks.im","threadId":"62322","inReplyTo":"CAOO-Oz2gN1Y9h-p_AJ=7iKzxOK2ShmgEmWzpFrpwwAD2GH=6TQ@mail.gmail.com","subject":"Re: git no longer builds on SunOS 5.10, a report","fromName":"Patrick Steinhardt","fromEmail":"ps@pks.im","sentAt":"2024-10-14T06:20:42Z","receivedAt":"2024-10-14T06:20:49Z","isPatch":false,"sender":{"key":"ps@pks.im","avatar":"https://avatars.githubusercontent.com/u/4056630?v=4"},"body":"On Sun, Oct 13, 2024 at 06:50:09PM -0400, Alejandro R. Sedeño wrote:\n> On Sun, Oct 13, 2024 at 3:57 PM Patrick Steinhardt <ps@pks.im> wrote:\n> > diff --git a/t/unit-tests/clar/clar.c b/t/unit-tests/clar/clar.c\n> > index cef0f023c2..064ca5c2ea 100644\n> > --- a/t/unit-tests/clar/clar.c\n> > +++ b/t/unit-tests/clar/clar.c\n> > @@ -4,6 +4,10 @@\n> >   * This file is part of clar, distributed under the ISC license.\n> >   * For full terms see the included COPYING file.\n> >   */\n> > +\n> > +#define _DARWIN_C_SOURCE\n> > +#define _POSIX_C_SOURCE=200809L\n> \n> token \"=\" is not valid in preprocessor expressions.\n\nYeah, typoed this one.\n\n> 2008 postdates my available compiler by many years, so trying to define this\n> is not going to get you everything you might expect here.\n> \n> Fixing the #define to use a space and not = results in\n> \n> /usr/include/sys/feature_tests.h:332:2: #error \"Compiler or options\n> invalid for pre-UNIX 03 X/Open applications and pre-2001 POSIX\n> applications\"\n> \n> The relevant bits of the header:\n> \n> #if defined(_STDC_C99) && (defined(__XOPEN_OR_POSIX) && !defined(_XPG6))\n> #error \"Compiler or options invalid for pre-UNIX 03 X/Open applications \\\n>         and pre-2001 POSIX applications\"\n> #elif !defined(_STDC_C99) && \\\n>         (defined(__XOPEN_OR_POSIX) && defined(_XPG6))\n> #error \"Compiler or options invalid; UNIX 03 and POSIX.1-2001 applications \\\n>         require the use of c99\"\n> #endif\n> \n> Removing `#define _POSIX_C_SOURCE 200809L` results in successful compilation.\n\nAh, I didn't even know that headers would bail out in case they don't\nsupport the standard, but it makes sense in retrospect. My current\nversion is:\n\n#define _BSD_SOURCE\n#define _DEFAULT_SOURCE\n#define _DARWIN_C_SOURCE\n\nI hope that should work fine on all platforms. In any case, I have\ncreated [1] upstream now.\n\n[1]: https://github.com/clar-test/clar/pull/107\n\n> > +\n> >  #include <assert.h>\n> >  #include <setjmp.h>\n> >  #include <stdlib.h>\n> > @@ -271,9 +275,7 @@ static double clar_time_diff(clar_time *start, clar_time *end)\n> >\n> >  static void clar_time_now(clar_time *out)\n> >  {\n> > -       struct timezone tz;\n> > -\n> > -       gettimeofday(out, &tz);\n> > +       gettimeofday(out, NULL);\n> >  }\n> >\n> >  static double clar_time_diff(clar_time *start, clar_time *end)\n> > diff --git a/t/unit-tests/clar/clar/sandbox.h b/t/unit-tests/clar/clar/sandbox.h\n> > index e25057b7c4..b499d2e1e6 100644\n> > --- a/t/unit-tests/clar/clar/sandbox.h\n> > +++ b/t/unit-tests/clar/clar/sandbox.h\n> > @@ -122,7 +122,7 @@ static int build_sandbox_path(void)\n> >\n> >         if (mkdir(_clar_path, 0700) != 0)\n> >                 return -1;\n> > -#elif defined(__TANDEM)\n> > +#elif defined(__sunos) || defined(__TANDEM)\n> \n> I think we want __sun here, not __sunos.\n\nAnd typoed that one, as well :)\n\nPatrick\n"},{"id":"504982","messageId":"cover.1728903464.git.ps@pks.im","threadId":"62322","inReplyTo":"CAOO-Oz3KsyeSjxbRpU-SdPgU5K+mPDcntT6Y4s46Mg_0ko9e_w@mail.gmail.com","subject":"[PATCH 0/2] t/unit-tests: improve clar platform compatibility","fromName":"Patrick Steinhardt","fromEmail":"ps@pks.im","sentAt":"2024-10-14T11:45:43Z","receivedAt":"2024-10-14T11:45:53Z","isPatch":true,"sender":{"key":"ps@pks.im","avatar":"https://avatars.githubusercontent.com/u/4056630?v=4"},"body":"Hi,\n\nthis small patch series addresses two recent reports about platform\ncompatibility with OpenSUSE Leap and SunOS.\n\nThanks!\n\nPatrick\n\nAlejandro R. Sedeño (1):\n  Makefile: adjust sed command for generating \"clar-decls.h\"\n\nPatrick Steinhardt (1):\n  t/unit-tests: update clar to 0810a36\n\n Makefile                                   |   2 +-\n t/unit-tests/clar/.editorconfig            |  13 +++\n t/unit-tests/clar/.github/workflows/ci.yml |  20 +++-\n t/unit-tests/clar/.gitignore               |   1 +\n t/unit-tests/clar/CMakeLists.txt           |  28 +++++\n t/unit-tests/clar/clar.c                   | 115 +++++++++++----------\n t/unit-tests/clar/clar/print.h             |  11 +-\n t/unit-tests/clar/clar/sandbox.h           |  17 ++-\n t/unit-tests/clar/clar/summary.h           |  14 +--\n t/unit-tests/clar/test/.gitignore          |   4 -\n t/unit-tests/clar/test/CMakeLists.txt      |  39 +++++++\n t/unit-tests/clar/test/Makefile            |  39 -------\n 12 files changed, 178 insertions(+), 125 deletions(-)\n create mode 100644 t/unit-tests/clar/.editorconfig\n create mode 100644 t/unit-tests/clar/.gitignore\n create mode 100644 t/unit-tests/clar/CMakeLists.txt\n delete mode 100644 t/unit-tests/clar/test/.gitignore\n create mode 100644 t/unit-tests/clar/test/CMakeLists.txt\n delete mode 100644 t/unit-tests/clar/test/Makefile\n\n-- \n2.47.0.dirty\n\n"},{"id":"504983","messageId":"a96fbdbb5f9d547fba52ce5f9e8e58656253fc78.1728903464.git.ps@pks.im","threadId":"62322","inReplyTo":"cover.1728903464.git.ps@pks.im","subject":"[PATCH 1/2] t/unit-tests: update clar to 0810a36","fromName":"Patrick Steinhardt","fromEmail":"ps@pks.im","sentAt":"2024-10-14T11:45:48Z","receivedAt":"2024-10-14T11:45:54Z","isPatch":true,"sender":{"key":"ps@pks.im","avatar":"https://avatars.githubusercontent.com/u/4056630?v=4"},"body":"Update clar from:\n\n    - 1516124 (Merge pull request #97 from pks-t/pks-whitespace-fixes, 2024-08-15).\n\nTo:\n\n    - 0810a36 (Merge pull request #107 from pks-t/pks-sunos-compatibility, 2024-10-14)\n\nThis update includes a bunch of fixes and improvements that we have\ndiscussed in Git when initial support for clar was merged:\n\n  - There is a \".editorconfig\" file now.\n\n  - Compatibility with Windows has been improved so that the clar\n    compiles on this platform without an issue. This has been tested\n    with Cygwin, MinGW and Microsoft Visual Studio.\n\n  - clar now uses CMake. This does not impact us at all as we wire up\n    the clar into our own build infrastructure anyway. This conversion\n    was done such that we can easily run CI jobs against Windows.\n\n  - Allocation failures are now checked for consistently.\n\n  - We now define feature test macros in \"clar.c\", which fixes\n    compilation on some platforms that didn't previously pull in\n    non-standard functions like lstat(3p) or strdup(3p). This was\n    reported by a user of OpenSUSE Leap.\n\n  - We stop using `struct timezone`, which is undefined behaviour\n    nowadays and results in a compilation error on some platforms.\n\n  - We now use the combination of mktemp(3) and mkdir(3) on SunOS, same\n    as we do on NonStop.\n\nThe most important bits here are the improved platform compatibility\nwith Windows, OpenSUSE and SunOS.\n\nSigned-off-by: Patrick Steinhardt <ps@pks.im>\n---\n t/unit-tests/clar/.editorconfig            |  13 +++\n t/unit-tests/clar/.github/workflows/ci.yml |  20 +++-\n t/unit-tests/clar/.gitignore               |   1 +\n t/unit-tests/clar/CMakeLists.txt           |  28 +++++\n t/unit-tests/clar/clar.c                   | 115 +++++++++++----------\n t/unit-tests/clar/clar/print.h             |  11 +-\n t/unit-tests/clar/clar/sandbox.h           |  17 ++-\n t/unit-tests/clar/clar/summary.h           |  14 +--\n t/unit-tests/clar/test/.gitignore          |   4 -\n t/unit-tests/clar/test/CMakeLists.txt      |  39 +++++++\n t/unit-tests/clar/test/Makefile            |  39 -------\n 11 files changed, 177 insertions(+), 124 deletions(-)\n create mode 100644 t/unit-tests/clar/.editorconfig\n create mode 100644 t/unit-tests/clar/.gitignore\n create mode 100644 t/unit-tests/clar/CMakeLists.txt\n delete mode 100644 t/unit-tests/clar/test/.gitignore\n create mode 100644 t/unit-tests/clar/test/CMakeLists.txt\n delete mode 100644 t/unit-tests/clar/test/Makefile\n\ndiff --git a/t/unit-tests/clar/.editorconfig b/t/unit-tests/clar/.editorconfig\nnew file mode 100644\nindex 00000000000..aa343a42885\n--- /dev/null\n+++ b/t/unit-tests/clar/.editorconfig\n@@ -0,0 +1,13 @@\n+root = true\n+\n+[*]\n+charset = utf-8\n+insert_final_newline = true\n+\n+[*.{c,h}]\n+indent_style = tab\n+tab_width = 8\n+\n+[CMakeLists.txt]\n+indent_style = tab\n+tab_width = 8\ndiff --git a/t/unit-tests/clar/.github/workflows/ci.yml b/t/unit-tests/clar/.github/workflows/ci.yml\nindex b1ac2de460a..0065843d17a 100644\n--- a/t/unit-tests/clar/.github/workflows/ci.yml\n+++ b/t/unit-tests/clar/.github/workflows/ci.yml\n@@ -10,14 +10,26 @@ jobs:\n   build:\n     strategy:\n       matrix:\n-        os: [ ubuntu-latest, macos-latest ]\n+        platform:\n+          - os: ubuntu-latest\n+            generator: Unix Makefiles\n+          - os: macos-latest\n+            generator: Unix Makefiles\n+          - os: windows-latest\n+            generator: Visual Studio 17 2022\n+          - os: windows-latest\n+            generator: MSYS Makefiles\n+          - os: windows-latest\n+            generator: MinGW Makefiles\n \n-    runs-on: ${{ matrix.os }}\n+    runs-on: ${{ matrix.platform.os }}\n \n     steps:\n     - name: Check out\n       uses: actions/checkout@v2\n     - name: Build\n       run: |\n-        cd test\n-        make\n+        mkdir build\n+        cd build\n+        cmake .. -G \"${{matrix.platform.generator}}\"\n+        cmake --build .\ndiff --git a/t/unit-tests/clar/.gitignore b/t/unit-tests/clar/.gitignore\nnew file mode 100644\nindex 00000000000..84c048a73cc\n--- /dev/null\n+++ b/t/unit-tests/clar/.gitignore\n@@ -0,0 +1 @@\n+/build/\ndiff --git a/t/unit-tests/clar/CMakeLists.txt b/t/unit-tests/clar/CMakeLists.txt\nnew file mode 100644\nindex 00000000000..12d4af114fe\n--- /dev/null\n+++ b/t/unit-tests/clar/CMakeLists.txt\n@@ -0,0 +1,28 @@\n+cmake_minimum_required(VERSION 3.16..3.29)\n+\n+project(clar LANGUAGES C)\n+\n+option(BUILD_TESTS \"Build test executable\" ON)\n+\n+add_library(clar INTERFACE)\n+target_sources(clar INTERFACE\n+\tclar.c\n+\tclar.h\n+\tclar/fixtures.h\n+\tclar/fs.h\n+\tclar/print.h\n+\tclar/sandbox.h\n+\tclar/summary.h\n+)\n+set_target_properties(clar PROPERTIES\n+\tC_STANDARD 90\n+\tC_STANDARD_REQUIRED ON\n+\tC_EXTENSIONS OFF\n+)\n+\n+if(CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME)\n+\tinclude(CTest)\n+\tif(BUILD_TESTING)\n+\t\tadd_subdirectory(test)\n+\tendif()\n+endif()\ndiff --git a/t/unit-tests/clar/clar.c b/t/unit-tests/clar/clar.c\nindex cef0f023c24..64879cf2bd5 100644\n--- a/t/unit-tests/clar/clar.c\n+++ b/t/unit-tests/clar/clar.c\n@@ -4,7 +4,12 @@\n  * This file is part of clar, distributed under the ISC license.\n  * For full terms see the included COPYING file.\n  */\n-#include <assert.h>\n+\n+#define _BSD_SOURCE\n+#define _DARWIN_C_SOURCE\n+#define _DEFAULT_SOURCE\n+\n+#include <errno.h>\n #include <setjmp.h>\n #include <stdlib.h>\n #include <stdio.h>\n@@ -13,6 +18,7 @@\n #include <stdarg.h>\n #include <wchar.h>\n #include <time.h>\n+#include <inttypes.h>\n \n /* required for sandboxing */\n #include <sys/types.h>\n@@ -28,6 +34,9 @@\n \n #\tifndef stat\n #\t\tdefine stat(path, st) _stat(path, st)\n+\t\ttypedef struct _stat STAT_T;\n+#\telse\n+\t\ttypedef struct stat STAT_T;\n #\tendif\n #\tifndef mkdir\n #\t\tdefine mkdir(path, mode) _mkdir(path)\n@@ -60,30 +69,11 @@\n #\telse\n #\t\tdefine p_snprintf snprintf\n #\tendif\n-\n-#\tifndef PRIuZ\n-#\t\tdefine PRIuZ \"Iu\"\n-#\tendif\n-#\tifndef PRIxZ\n-#\t\tdefine PRIxZ \"Ix\"\n-#\tendif\n-\n-#\tif defined(_MSC_VER) || (defined(__MINGW32__) && !defined(__MINGW64_VERSION_MAJOR))\n-\ttypedef struct stat STAT_T;\n-#\telse\n-\ttypedef struct _stat STAT_T;\n-#\tendif\n #else\n #\tinclude <sys/wait.h> /* waitpid(2) */\n #\tinclude <unistd.h>\n #\tdefine _MAIN_CC\n #\tdefine p_snprintf snprintf\n-#\tifndef PRIuZ\n-#\t\tdefine PRIuZ \"zu\"\n-#\tendif\n-#\tifndef PRIxZ\n-#\t\tdefine PRIxZ \"zx\"\n-#\tendif\n \ttypedef struct stat STAT_T;\n #endif\n \n@@ -102,7 +92,7 @@ fixture_path(const char *base, const char *fixture_name);\n struct clar_error {\n \tconst char *file;\n \tconst char *function;\n-\tsize_t line_number;\n+\tuintmax_t line_number;\n \tconst char *error_msg;\n \tchar *description;\n \n@@ -195,11 +185,12 @@ static void clar_print_shutdown(int test_count, int suite_count, int error_count\n static void clar_print_error(int num, const struct clar_report *report, const struct clar_error *error);\n static void clar_print_ontest(const char *suite_name, const char *test_name, int test_number, enum cl_test_status failed);\n static void clar_print_onsuite(const char *suite_name, int suite_index);\n+static void clar_print_onabortv(const char *msg, va_list argp);\n static void clar_print_onabort(const char *msg, ...);\n \n /* From clar_sandbox.c */\n static void clar_unsandbox(void);\n-static int clar_sandbox(void);\n+static void clar_sandbox(void);\n \n /* From summary.h */\n static struct clar_summary *clar_summary_init(const char *filename);\n@@ -218,6 +209,15 @@ static int clar_summary_shutdown(struct clar_summary *fp);\n \t\t\t\t\t\t\t   _clar.trace_payload);\t\t\t\t\t\\\n \t} while (0)\n \n+static void clar_abort(const char *msg, ...)\n+{\n+\tva_list argp;\n+\tva_start(argp, msg);\n+\tclar_print_onabortv(msg, argp);\n+\tva_end(argp);\n+\texit(-1);\n+}\n+\n void cl_trace_register(cl_trace_cb *cb, void *payload)\n {\n \t_clar.pfn_trace_cb = cb;\n@@ -271,9 +271,7 @@ static double clar_time_diff(clar_time *start, clar_time *end)\n \n static void clar_time_now(clar_time *out)\n {\n-\tstruct timezone tz;\n-\n-\tgettimeofday(out, &tz);\n+\tgettimeofday(out, NULL);\n }\n \n static double clar_time_diff(clar_time *start, clar_time *end)\n@@ -386,7 +384,8 @@ clar_run_suite(const struct clar_suite *suite, const char *filter)\n \n \t\t_clar.active_test = test[i].name;\n \n-\t\treport = calloc(1, sizeof(struct clar_report));\n+\t\tif ((report = calloc(1, sizeof(*report))) == NULL)\n+\t\t\tclar_abort(\"Failed to allocate report.\\n\");\n \t\treport->suite = _clar.active_suite;\n \t\treport->test = _clar.active_test;\n \t\treport->test_number = _clar.tests_ran;\n@@ -479,9 +478,10 @@ clar_parse_args(int argc, char **argv)\n \n \t\t\t\t\tswitch (action) {\n \t\t\t\t\tcase 's': {\n-\t\t\t\t\t\tstruct clar_explicit *explicit =\n-\t\t\t\t\t\t\tcalloc(1, sizeof(struct clar_explicit));\n-\t\t\t\t\t\tassert(explicit);\n+\t\t\t\t\t\tstruct clar_explicit *explicit;\n+\n+\t\t\t\t\t\tif ((explicit = calloc(1, sizeof(*explicit))) == NULL)\n+\t\t\t\t\t\t\tclar_abort(\"Failed to allocate explicit test.\\n\");\n \n \t\t\t\t\t\texplicit->suite_idx = j;\n \t\t\t\t\t\texplicit->filter = argument;\n@@ -505,10 +505,8 @@ clar_parse_args(int argc, char **argv)\n \t\t\t\t}\n \t\t\t}\n \n-\t\t\tif (!found) {\n-\t\t\t\tclar_print_onabort(\"No suite matching '%s' found.\\n\", argument);\n-\t\t\t\texit(-1);\n-\t\t\t}\n+\t\t\tif (!found)\n+\t\t\t\tclar_abort(\"No suite matching '%s' found.\\n\", argument);\n \t\t\tbreak;\n \t\t}\n \n@@ -540,11 +538,17 @@ clar_parse_args(int argc, char **argv)\n \t\tcase 'r':\n \t\t\t_clar.write_summary = 1;\n \t\t\tfree(_clar.summary_filename);\n-\t\t\t_clar.summary_filename = *(argument + 2) ? strdup(argument + 2) : NULL;\n+\t\t\tif (*(argument + 2)) {\n+\t\t\t\tif ((_clar.summary_filename = strdup(argument + 2)) == NULL)\n+\t\t\t\t\tclar_abort(\"Failed to allocate summary filename.\\n\");\n+\t\t\t} else {\n+\t\t\t\t_clar.summary_filename = NULL;\n+\t\t\t}\n \t\t\tbreak;\n \n \t\tdefault:\n-\t\t\tassert(!\"Unexpected commandline argument!\");\n+\t\t\tclar_abort(\"Unexpected commandline argument '%s'.\\n\",\n+\t\t\t\t   argument[1]);\n \t\t}\n \t}\n }\n@@ -566,22 +570,18 @@ clar_test_init(int argc, char **argv)\n \tif (!_clar.summary_filename &&\n \t    (summary_env = getenv(\"CLAR_SUMMARY\")) != NULL) {\n \t\t_clar.write_summary = 1;\n-\t\t_clar.summary_filename = strdup(summary_env);\n+\t\tif ((_clar.summary_filename = strdup(summary_env)) == NULL)\n+\t\t\tclar_abort(\"Failed to allocate summary filename.\\n\");\n \t}\n \n \tif (_clar.write_summary && !_clar.summary_filename)\n-\t\t_clar.summary_filename = strdup(\"summary.xml\");\n+\t\tif ((_clar.summary_filename = strdup(\"summary.xml\")) == NULL)\n+\t\t\tclar_abort(\"Failed to allocate summary filename.\\n\");\n \n-\tif (_clar.write_summary &&\n-\t    !(_clar.summary = clar_summary_init(_clar.summary_filename))) {\n-\t\tclar_print_onabort(\"Failed to open the summary file\\n\");\n-\t\texit(-1);\n-\t}\n+\tif (_clar.write_summary)\n+\t    _clar.summary = clar_summary_init(_clar.summary_filename);\n \n-\tif (clar_sandbox() < 0) {\n-\t\tclar_print_onabort(\"Failed to sandbox the test runner.\\n\");\n-\t\texit(-1);\n-\t}\n+\tclar_sandbox();\n }\n \n int\n@@ -615,10 +615,9 @@ clar_test_shutdown(void)\n \n \tclar_unsandbox();\n \n-\tif (_clar.write_summary && clar_summary_shutdown(_clar.summary) < 0) {\n-\t\tclar_print_onabort(\"Failed to write the summary file\\n\");\n-\t\texit(-1);\n-\t}\n+\tif (_clar.write_summary && clar_summary_shutdown(_clar.summary) < 0)\n+\t\tclar_abort(\"Failed to write the summary file '%s: %s.\\n\",\n+\t\t\t   _clar.summary_filename, strerror(errno));\n \n \tfor (explicit = _clar.explicit; explicit; explicit = explicit_next) {\n \t\texplicit_next = explicit->next;\n@@ -649,7 +648,7 @@ static void abort_test(void)\n {\n \tif (!_clar.trampoline_enabled) {\n \t\tclar_print_onabort(\n-\t\t\t\t\"Fatal error: a cleanup method raised an exception.\");\n+\t\t\t\t\"Fatal error: a cleanup method raised an exception.\\n\");\n \t\tclar_report_errors(_clar.last_report);\n \t\texit(-1);\n \t}\n@@ -673,7 +672,10 @@ void clar__fail(\n \tconst char *description,\n \tint should_abort)\n {\n-\tstruct clar_error *error = calloc(1, sizeof(struct clar_error));\n+\tstruct clar_error *error;\n+\n+\tif ((error = calloc(1, sizeof(*error))) == NULL)\n+\t\tclar_abort(\"Failed to allocate error.\\n\");\n \n \tif (_clar.last_report->errors == NULL)\n \t\t_clar.last_report->errors = error;\n@@ -688,8 +690,9 @@ void clar__fail(\n \terror->line_number = line;\n \terror->error_msg = error_msg;\n \n-\tif (description != NULL)\n-\t\terror->description = strdup(description);\n+\tif (description != NULL &&\n+\t    (error->description = strdup(description)) == NULL)\n+\t\tclar_abort(\"Failed to allocate description.\\n\");\n \n \t_clar.total_errors++;\n \t_clar.last_report->status = CL_TEST_FAILURE;\n@@ -798,8 +801,8 @@ void clar__assert_equal(\n \t\t\t}\n \t\t}\n \t}\n-\telse if (!strcmp(\"%\"PRIuZ, fmt) || !strcmp(\"%\"PRIxZ, fmt)) {\n-\t\tsize_t sz1 = va_arg(args, size_t), sz2 = va_arg(args, size_t);\n+\telse if (!strcmp(\"%\"PRIuMAX, fmt) || !strcmp(\"%\"PRIxMAX, fmt)) {\n+\t\tuintmax_t sz1 = va_arg(args, uintmax_t), sz2 = va_arg(args, uintmax_t);\n \t\tis_equal = (sz1 == sz2);\n \t\tif (!is_equal) {\n \t\t\tint offset = p_snprintf(buf, sizeof(buf), fmt, sz1);\ndiff --git a/t/unit-tests/clar/clar/print.h b/t/unit-tests/clar/clar/print.h\nindex c17e2f693bd..69d0ee967e7 100644\n--- a/t/unit-tests/clar/clar/print.h\n+++ b/t/unit-tests/clar/clar/print.h\n@@ -21,7 +21,7 @@ static void clar_print_clap_error(int num, const struct clar_report *report, con\n {\n \tprintf(\"  %d) Failure:\\n\", num);\n \n-\tprintf(\"%s::%s [%s:%\"PRIuZ\"]\\n\",\n+\tprintf(\"%s::%s [%s:%\"PRIuMAX\"]\\n\",\n \t\treport->suite,\n \t\treport->test,\n \t\terror->file,\n@@ -136,7 +136,7 @@ static void clar_print_tap_ontest(const char *suite_name, const char *test_name,\n \n \t\tprintf(\"    at:\\n\");\n \t\tprintf(\"      file: '\"); print_escaped(error->file); printf(\"'\\n\");\n-\t\tprintf(\"      line: %\" PRIuZ \"\\n\", error->line_number);\n+\t\tprintf(\"      line: %\" PRIuMAX \"\\n\", error->line_number);\n \t\tprintf(\"      function: '%s'\\n\", error->function);\n \t\tprintf(\"    ---\\n\");\n \n@@ -202,10 +202,15 @@ static void clar_print_onsuite(const char *suite_name, int suite_index)\n \tPRINT(onsuite, suite_name, suite_index);\n }\n \n+static void clar_print_onabortv(const char *msg, va_list argp)\n+{\n+\tPRINT(onabort, msg, argp);\n+}\n+\n static void clar_print_onabort(const char *msg, ...)\n {\n \tva_list argp;\n \tva_start(argp, msg);\n-\tPRINT(onabort, msg, argp);\n+\tclar_print_onabortv(msg, argp);\n \tva_end(argp);\n }\ndiff --git a/t/unit-tests/clar/clar/sandbox.h b/t/unit-tests/clar/clar/sandbox.h\nindex e25057b7c49..bc960f50e0f 100644\n--- a/t/unit-tests/clar/clar/sandbox.h\n+++ b/t/unit-tests/clar/clar/sandbox.h\n@@ -122,14 +122,14 @@ static int build_sandbox_path(void)\n \n \tif (mkdir(_clar_path, 0700) != 0)\n \t\treturn -1;\n-#elif defined(__TANDEM)\n-\tif (mktemp(_clar_path) == NULL)\n+#elif defined(_WIN32)\n+\tif (_mktemp_s(_clar_path, sizeof(_clar_path)) != 0)\n \t\treturn -1;\n \n \tif (mkdir(_clar_path, 0700) != 0)\n \t\treturn -1;\n-#elif defined(_WIN32)\n-\tif (_mktemp_s(_clar_path, sizeof(_clar_path)) != 0)\n+#elif defined(__sun) || defined(__TANDEM)\n+\tif (mktemp(_clar_path) == NULL)\n \t\treturn -1;\n \n \tif (mkdir(_clar_path, 0700) != 0)\n@@ -142,15 +142,14 @@ static int build_sandbox_path(void)\n \treturn 0;\n }\n \n-static int clar_sandbox(void)\n+static void clar_sandbox(void)\n {\n \tif (_clar_path[0] == '\\0' && build_sandbox_path() < 0)\n-\t\treturn -1;\n+\t\tclar_abort(\"Failed to build sandbox path.\\n\");\n \n \tif (chdir(_clar_path) != 0)\n-\t\treturn -1;\n-\n-\treturn 0;\n+\t\tclar_abort(\"Failed to change into sandbox directory '%s': %s.\\n\",\n+\t\t\t   _clar_path, strerror(errno));\n }\n \n const char *clar_sandbox_path(void)\ndiff --git a/t/unit-tests/clar/clar/summary.h b/t/unit-tests/clar/clar/summary.h\nindex 4dd352e28b8..0d0b646fe75 100644\n--- a/t/unit-tests/clar/clar/summary.h\n+++ b/t/unit-tests/clar/clar/summary.h\n@@ -66,16 +66,12 @@ struct clar_summary *clar_summary_init(const char *filename)\n \tstruct clar_summary *summary;\n \tFILE *fp;\n \n-\tif ((fp = fopen(filename, \"w\")) == NULL) {\n-\t\tperror(\"fopen\");\n-\t\treturn NULL;\n-\t}\n+\tif ((fp = fopen(filename, \"w\")) == NULL)\n+\t\tclar_abort(\"Failed to open the summary file '%s': %s.\\n\",\n+\t\t\t   filename, strerror(errno));\n \n-\tif ((summary = malloc(sizeof(struct clar_summary))) == NULL) {\n-\t\tperror(\"malloc\");\n-\t\tfclose(fp);\n-\t\treturn NULL;\n-\t}\n+\tif ((summary = malloc(sizeof(struct clar_summary))) == NULL)\n+\t\tclar_abort(\"Failed to allocate summary.\\n\");\n \n \tsummary->filename = filename;\n \tsummary->fp = fp;\ndiff --git a/t/unit-tests/clar/test/.gitignore b/t/unit-tests/clar/test/.gitignore\ndeleted file mode 100644\nindex a477d0c40ca..00000000000\n--- a/t/unit-tests/clar/test/.gitignore\n+++ /dev/null\n@@ -1,4 +0,0 @@\n-clar.suite\n-.clarcache\n-clar_test\n-*.o\ndiff --git a/t/unit-tests/clar/test/CMakeLists.txt b/t/unit-tests/clar/test/CMakeLists.txt\nnew file mode 100644\nindex 00000000000..7f2c1dc17a9\n--- /dev/null\n+++ b/t/unit-tests/clar/test/CMakeLists.txt\n@@ -0,0 +1,39 @@\n+find_package(Python COMPONENTS Interpreter REQUIRED)\n+\n+add_custom_command(OUTPUT \"${CMAKE_CURRENT_BINARY_DIR}/clar.suite\"\n+\tCOMMAND \"${Python_EXECUTABLE}\" \"${CMAKE_SOURCE_DIR}/generate.py\" --output \"${CMAKE_CURRENT_BINARY_DIR}\"\n+\tDEPENDS main.c sample.c clar_test.h\n+\tWORKING_DIRECTORY \"${CMAKE_CURRENT_SOURCE_DIR}\"\n+)\n+\n+add_executable(clar_test)\n+set_target_properties(clar_test PROPERTIES\n+\tC_STANDARD 90\n+\tC_STANDARD_REQUIRED ON\n+\tC_EXTENSIONS OFF\n+)\n+\n+# MSVC generates all kinds of warnings. We may want to fix these in the future\n+# and then unconditionally treat warnings as errors.\n+if(NOT MSVC)\n+\tset_target_properties(clar_test PROPERTIES\n+\t\tCOMPILE_WARNING_AS_ERROR ON\n+\t)\n+endif()\n+\n+target_sources(clar_test PRIVATE\n+\tmain.c\n+\tsample.c\n+\t\"${CMAKE_CURRENT_BINARY_DIR}/clar.suite\"\n+)\n+target_compile_definitions(clar_test PRIVATE\n+\tCLAR_FIXTURE_PATH=\"${CMAKE_CURRENT_SOURCE_DIR}/resources/\"\n+)\n+target_compile_options(clar_test PRIVATE\n+\t$<IF:$<CXX_COMPILER_ID:MSVC>,/W4,-Wall>\n+)\n+target_include_directories(clar_test PRIVATE\n+\t\"${CMAKE_SOURCE_DIR}\"\n+\t\"${CMAKE_CURRENT_BINARY_DIR}\"\n+)\n+target_link_libraries(clar_test clar)\ndiff --git a/t/unit-tests/clar/test/Makefile b/t/unit-tests/clar/test/Makefile\ndeleted file mode 100644\nindex 93c6b2ad32c..00000000000\n--- a/t/unit-tests/clar/test/Makefile\n+++ /dev/null\n@@ -1,39 +0,0 @@\n-#\n-# Copyright (c) Vicent Marti. All rights reserved.\n-#\n-# This file is part of clar, distributed under the ISC license.\n-# For full terms see the included COPYING file.\n-#\n-\n-#\n-# Set up the path to the clar sources and to the fixtures directory\n-#\n-# The fixture path needs to be an absolute path so it can be used\n-# even after we have chdir'ed into the test directory while testing.\n-#\n-CURRENT_MAKEFILE  := $(word $(words $(MAKEFILE_LIST)),$(MAKEFILE_LIST))\n-TEST_DIRECTORY    := $(abspath $(dir $(CURRENT_MAKEFILE)))\n-CLAR_PATH         := $(dir $(TEST_DIRECTORY))\n-CLAR_FIXTURE_PATH := $(TEST_DIRECTORY)/resources/\n-\n-CFLAGS=-g -I.. -I. -Wall -DCLAR_FIXTURE_PATH=\\\"$(CLAR_FIXTURE_PATH)\\\"\n-\n-.PHONY: clean\n-\n-# list the objects that go into our test\n-objects = main.o sample.o\n-\n-# build the test executable itself\n-clar_test: $(objects) clar_test.h clar.suite $(CLAR_PATH)clar.c\n-\t$(CC) $(CFLAGS) -o $@ \"$(CLAR_PATH)clar.c\" $(objects)\n-\n-# test object files depend on clar macros\n-$(objects) : $(CLAR_PATH)clar.h\n-\n-# build the clar.suite file of test metadata\n-clar.suite:\n-\tpython \"$(CLAR_PATH)generate.py\" .\n-\n-# remove all generated files\n-clean:\n-\t$(RM) -rf *.o clar.suite .clarcache clar_test clar_test.dSYM\n-- \n2.47.0.dirty\n\n"},{"id":"504984","messageId":"dda9b8e033c2e32e17dff73cad43211dd355d3ec.1728903464.git.ps@pks.im","threadId":"62322","inReplyTo":"cover.1728903464.git.ps@pks.im","subject":"[PATCH 2/2] Makefile: adjust sed command for generating \"clar-decls.h\"","fromName":"Patrick Steinhardt","fromEmail":"ps@pks.im","sentAt":"2024-10-14T11:45:52Z","receivedAt":"2024-10-14T11:45:56Z","isPatch":true,"sender":{"key":"ps@pks.im","avatar":"https://avatars.githubusercontent.com/u/4056630?v=4"},"body":"From: Alejandro R. Sedeño <asedeno@mit.edu>\n\nThis moves the end-of-line marker out of the captured group, matching\nthe start-of-line marker and for some reason fixing generation of\n\"clar-decls.h\" on some older, more esoteric platforms.\n\nSigned-off-by: Alejandro R. Sedeño <asedeno@mit.edu>\nSigned-off-by: Patrick Steinhardt <ps@pks.im>\n---\n Makefile | 2 +-\n 1 file changed, 1 insertion(+), 1 deletion(-)\n\ndiff --git a/Makefile b/Makefile\nindex feeed6f9321..0101d349f38 100644\n--- a/Makefile\n+++ b/Makefile\n@@ -3905,7 +3905,7 @@ GIT-TEST-SUITES: FORCE\n \n $(UNIT_TEST_DIR)/clar-decls.h: $(patsubst %,$(UNIT_TEST_DIR)/%.c,$(CLAR_TEST_SUITES)) GIT-TEST-SUITES\n \t$(QUIET_GEN)for suite in $(CLAR_TEST_SUITES); do \\\n-\t\tsed -ne \"s/^\\(void test_$${suite}__[a-zA-Z_0-9][a-zA-Z_0-9]*(void)$$\\)/extern \\1;/p\" $(UNIT_TEST_DIR)/$$suite.c; \\\n+\t\tsed -ne \"s/^\\(void test_$${suite}__[a-zA-Z_0-9][a-zA-Z_0-9]*(void)\\)$$/extern \\1;/p\" $(UNIT_TEST_DIR)/$$suite.c; \\\n \tdone >$@\n $(UNIT_TEST_DIR)/clar.suite: $(UNIT_TEST_DIR)/clar-decls.h\n \t$(QUIET_GEN)awk -f $(UNIT_TEST_DIR)/clar-generate.awk $< >$(UNIT_TEST_DIR)/clar.suite\n-- \n2.47.0.dirty\n\n"},{"id":"505447","messageId":"87y12lbeix.fsf@iotcl.com","threadId":"62322","inReplyTo":"dda9b8e033c2e32e17dff73cad43211dd355d3ec.1728903464.git.ps@pks.im","subject":"Re: [PATCH 2/2] Makefile: adjust sed command for generating \"clar-decls.h\"","fromName":"Toon Claes","fromEmail":"toon@iotcl.com","sentAt":"2024-10-18T15:45:58Z","receivedAt":"2024-10-18T15:46:12Z","isPatch":true,"sender":{"key":"toon@iotcl.com","avatar":"https://avatars.githubusercontent.com/u/121621?v=4"},"body":"Patrick Steinhardt <ps@pks.im> writes:\n\n> From: Alejandro R. Sedeño <asedeno@mit.edu>\n>\n> This moves the end-of-line marker out of the captured group, matching\n> the start-of-line marker and for some reason fixing generation of\n> \"clar-decls.h\" on some older, more esoteric platforms.\n>\n> Signed-off-by: Alejandro R. Sedeño <asedeno@mit.edu>\n> Signed-off-by: Patrick Steinhardt <ps@pks.im>\n> ---\n>  Makefile | 2 +-\n>  1 file changed, 1 insertion(+), 1 deletion(-)\n>\n> diff --git a/Makefile b/Makefile\n> index feeed6f9321..0101d349f38 100644\n> --- a/Makefile\n> +++ b/Makefile\n> @@ -3905,7 +3905,7 @@ GIT-TEST-SUITES: FORCE\n>  \n>  $(UNIT_TEST_DIR)/clar-decls.h: $(patsubst %,$(UNIT_TEST_DIR)/%.c,$(CLAR_TEST_SUITES)) GIT-TEST-SUITES\n>  \t$(QUIET_GEN)for suite in $(CLAR_TEST_SUITES); do \\\n> -\t\tsed -ne \"s/^\\(void test_$${suite}__[a-zA-Z_0-9][a-zA-Z_0-9]*(void)$$\\)/extern \\1;/p\" $(UNIT_TEST_DIR)/$$suite.c; \\\n> +\t\tsed -ne \"s/^\\(void test_$${suite}__[a-zA-Z_0-9][a-zA-Z_0-9]*(void)\\)$$/extern \\1;/p\" $(UNIT_TEST_DIR)/$$suite.c; \\\n>  \tdone >$@\n>  $(UNIT_TEST_DIR)/clar.suite: $(UNIT_TEST_DIR)/clar-decls.h\n>  \t$(QUIET_GEN)awk -f $(UNIT_TEST_DIR)/clar-generate.awk $< >$(UNIT_TEST_DIR)/clar.suite\n> -- \n> 2.47.0.dirty\n\nYou're most likely aware, but this change needs to move when the patch\n\"Makefile: extract script to generate clar declarations\" [1] is merged,\nbecause this line then lives in t/unit-tests/generate-clar-decls.sh.\n\n[1]: https://lore.kernel.org/git/7a619677c7af6ba8213a36208e20ab75c4318e38.1728985514.git.ps@pks.im/\n\n-- \nToon\n"},{"id":"505465","messageId":"ZxLPwKdUywa7vlu/@nand.local","threadId":"62322","inReplyTo":"87y12lbeix.fsf@iotcl.com","subject":"Re: [PATCH 2/2] Makefile: adjust sed command for generating \"clar-decls.h\"","fromName":"Taylor Blau","fromEmail":"me@ttaylorr.com","sentAt":"2024-10-18T21:14:40Z","receivedAt":"2024-10-18T21:14:43Z","isPatch":true,"sender":{"key":"me@ttaylorr.com","avatar":"https://avatars.githubusercontent.com/u/301000140?v=4"},"body":"On Fri, Oct 18, 2024 at 05:45:58PM +0200, Toon Claes wrote:\n> You're most likely aware, but this change needs to move when the patch\n> \"Makefile: extract script to generate clar declarations\" [1] is merged,\n> because this line then lives in t/unit-tests/generate-clar-decls.sh.\n>\n> [1]: https://lore.kernel.org/git/7a619677c7af6ba8213a36208e20ab75c4318e38.1728985514.git.ps@pks.im/\n\nI believe that is what Patrick suggested in:\n\n  https://lore.kernel.org/git/cover.1728914219.git.ps@pks.im/\n\n, no?\n\nThanks,\nTaylor\n"},{"id":"505590","messageId":"ZxX8FCE8rnLb-wvU@pks.im","threadId":"62322","inReplyTo":"ZxLPwKdUywa7vlu/@nand.local","subject":"Re: [PATCH 2/2] Makefile: adjust sed command for generating \"clar-decls.h\"","fromName":"Patrick Steinhardt","fromEmail":"ps@pks.im","sentAt":"2024-10-21T07:00:36Z","receivedAt":"2024-10-21T07:00:45Z","isPatch":true,"sender":{"key":"ps@pks.im","avatar":"https://avatars.githubusercontent.com/u/4056630?v=4"},"body":"On Fri, Oct 18, 2024 at 05:14:40PM -0400, Taylor Blau wrote:\n> On Fri, Oct 18, 2024 at 05:45:58PM +0200, Toon Claes wrote:\n> > You're most likely aware, but this change needs to move when the patch\n> > \"Makefile: extract script to generate clar declarations\" [1] is merged,\n> > because this line then lives in t/unit-tests/generate-clar-decls.sh.\n> >\n> > [1]: https://lore.kernel.org/git/7a619677c7af6ba8213a36208e20ab75c4318e38.1728985514.git.ps@pks.im/\n> \n> I believe that is what Patrick suggested in:\n> \n>   https://lore.kernel.org/git/cover.1728914219.git.ps@pks.im/\n> \n> , no?\n\nYup. I think it makes everyones life easier if I were to just merge\nthese two series together. I would've done so right from the start if I\nnoticed that they interact with each other, but only saw this at a later\npoint in time.\n\nI'll send this out later today or early tomorrow.\n\nPatrick\n"},{"id":"505650","messageId":"06145a141dd3485f183bcf8248de0db61a7203db.1729506329.git.ps@pks.im","threadId":"62322","inReplyTo":"cover.1729506329.git.ps@pks.im","subject":"[PATCH v2 1/5] t/unit-tests: update clar to 206accb","fromName":"Patrick Steinhardt","fromEmail":"ps@pks.im","sentAt":"2024-10-21T10:56:33Z","receivedAt":"2024-10-21T10:56:39Z","isPatch":true,"sender":{"key":"ps@pks.im","avatar":"https://avatars.githubusercontent.com/u/4056630?v=4"},"body":"Update clar from:\n\n    - 1516124 (Merge pull request #97 from pks-t/pks-whitespace-fixes, 2024-08-15).\n\nTo:\n\n    - 206accb (Merge pull request #108 from pks-t/pks-uclibc-without-wchar, 2024-10-21)\n\nThis update includes a bunch of fixes and improvements that we have\ndiscussed in Git when initial support for clar was merged:\n\n  - There is a \".editorconfig\" file now.\n\n  - Compatibility with Windows has been improved so that the clar\n    compiles on this platform without an issue. This has been tested\n    with Cygwin, MinGW and Microsoft Visual Studio.\n\n  - clar now uses CMake. This does not impact us at all as we wire up\n    the clar into our own build infrastructure anyway. This conversion\n    was done such that we can easily run CI jobs against Windows.\n\n  - Allocation failures are now checked for consistently.\n\n  - We now define feature test macros in \"clar.c\", which fixes\n    compilation on some platforms that didn't previously pull in\n    non-standard functions like lstat(3p) or strdup(3p). This was\n    reported by a user of OpenSUSE Leap.\n\n  - We stop using `struct timezone`, which is undefined behaviour\n    nowadays and results in a compilation error on some platforms.\n\n  - We now use the combination of mktemp(3) and mkdir(3) on SunOS, same\n    as we do on NonStop.\n\n  - We now support uClibc without support for <wchar.h>.\n\nThe most important bits here are the improved platform compatibility\nwith Windows, OpenSUSE, SunOS and uClibc.\n\nSigned-off-by: Patrick Steinhardt <ps@pks.im>\n---\n t/unit-tests/clar/.editorconfig            |  13 +++\n t/unit-tests/clar/.github/workflows/ci.yml |  20 +++-\n t/unit-tests/clar/.gitignore               |   1 +\n t/unit-tests/clar/CMakeLists.txt           |  28 +++++\n t/unit-tests/clar/clar.c                   | 127 ++++++++++++---------\n t/unit-tests/clar/clar/print.h             |  11 +-\n t/unit-tests/clar/clar/sandbox.h           |  17 ++-\n t/unit-tests/clar/clar/summary.h           |  14 +--\n t/unit-tests/clar/test/.gitignore          |   4 -\n t/unit-tests/clar/test/CMakeLists.txt      |  39 +++++++\n t/unit-tests/clar/test/Makefile            |  39 -------\n 11 files changed, 189 insertions(+), 124 deletions(-)\n create mode 100644 t/unit-tests/clar/.editorconfig\n create mode 100644 t/unit-tests/clar/.gitignore\n create mode 100644 t/unit-tests/clar/CMakeLists.txt\n delete mode 100644 t/unit-tests/clar/test/.gitignore\n create mode 100644 t/unit-tests/clar/test/CMakeLists.txt\n delete mode 100644 t/unit-tests/clar/test/Makefile\n\ndiff --git a/t/unit-tests/clar/.editorconfig b/t/unit-tests/clar/.editorconfig\nnew file mode 100644\nindex 00000000000..aa343a42885\n--- /dev/null\n+++ b/t/unit-tests/clar/.editorconfig\n@@ -0,0 +1,13 @@\n+root = true\n+\n+[*]\n+charset = utf-8\n+insert_final_newline = true\n+\n+[*.{c,h}]\n+indent_style = tab\n+tab_width = 8\n+\n+[CMakeLists.txt]\n+indent_style = tab\n+tab_width = 8\ndiff --git a/t/unit-tests/clar/.github/workflows/ci.yml b/t/unit-tests/clar/.github/workflows/ci.yml\nindex b1ac2de460a..0065843d17a 100644\n--- a/t/unit-tests/clar/.github/workflows/ci.yml\n+++ b/t/unit-tests/clar/.github/workflows/ci.yml\n@@ -10,14 +10,26 @@ jobs:\n   build:\n     strategy:\n       matrix:\n-        os: [ ubuntu-latest, macos-latest ]\n+        platform:\n+          - os: ubuntu-latest\n+            generator: Unix Makefiles\n+          - os: macos-latest\n+            generator: Unix Makefiles\n+          - os: windows-latest\n+            generator: Visual Studio 17 2022\n+          - os: windows-latest\n+            generator: MSYS Makefiles\n+          - os: windows-latest\n+            generator: MinGW Makefiles\n \n-    runs-on: ${{ matrix.os }}\n+    runs-on: ${{ matrix.platform.os }}\n \n     steps:\n     - name: Check out\n       uses: actions/checkout@v2\n     - name: Build\n       run: |\n-        cd test\n-        make\n+        mkdir build\n+        cd build\n+        cmake .. -G \"${{matrix.platform.generator}}\"\n+        cmake --build .\ndiff --git a/t/unit-tests/clar/.gitignore b/t/unit-tests/clar/.gitignore\nnew file mode 100644\nindex 00000000000..84c048a73cc\n--- /dev/null\n+++ b/t/unit-tests/clar/.gitignore\n@@ -0,0 +1 @@\n+/build/\ndiff --git a/t/unit-tests/clar/CMakeLists.txt b/t/unit-tests/clar/CMakeLists.txt\nnew file mode 100644\nindex 00000000000..12d4af114fe\n--- /dev/null\n+++ b/t/unit-tests/clar/CMakeLists.txt\n@@ -0,0 +1,28 @@\n+cmake_minimum_required(VERSION 3.16..3.29)\n+\n+project(clar LANGUAGES C)\n+\n+option(BUILD_TESTS \"Build test executable\" ON)\n+\n+add_library(clar INTERFACE)\n+target_sources(clar INTERFACE\n+\tclar.c\n+\tclar.h\n+\tclar/fixtures.h\n+\tclar/fs.h\n+\tclar/print.h\n+\tclar/sandbox.h\n+\tclar/summary.h\n+)\n+set_target_properties(clar PROPERTIES\n+\tC_STANDARD 90\n+\tC_STANDARD_REQUIRED ON\n+\tC_EXTENSIONS OFF\n+)\n+\n+if(CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME)\n+\tinclude(CTest)\n+\tif(BUILD_TESTING)\n+\t\tadd_subdirectory(test)\n+\tendif()\n+endif()\ndiff --git a/t/unit-tests/clar/clar.c b/t/unit-tests/clar/clar.c\nindex cef0f023c24..d54e4553674 100644\n--- a/t/unit-tests/clar/clar.c\n+++ b/t/unit-tests/clar/clar.c\n@@ -4,7 +4,12 @@\n  * This file is part of clar, distributed under the ISC license.\n  * For full terms see the included COPYING file.\n  */\n-#include <assert.h>\n+\n+#define _BSD_SOURCE\n+#define _DARWIN_C_SOURCE\n+#define _DEFAULT_SOURCE\n+\n+#include <errno.h>\n #include <setjmp.h>\n #include <stdlib.h>\n #include <stdio.h>\n@@ -13,11 +18,22 @@\n #include <stdarg.h>\n #include <wchar.h>\n #include <time.h>\n+#include <inttypes.h>\n \n /* required for sandboxing */\n #include <sys/types.h>\n #include <sys/stat.h>\n \n+#if defined(__UCLIBC__) && ! defined(__UCLIBC_HAS_WCHAR__)\n+\t/*\n+\t * uClibc can optionally be built without wchar support, in which case\n+\t * the installed <wchar.h> is a stub that only defines the `whar_t`\n+\t * type but none of the functions typically declared by it.\n+\t */\n+#else\n+#\tdefine CLAR_HAVE_WCHAR\n+#endif\n+\n #ifdef _WIN32\n #\tdefine WIN32_LEAN_AND_MEAN\n #\tinclude <windows.h>\n@@ -28,6 +44,9 @@\n \n #\tifndef stat\n #\t\tdefine stat(path, st) _stat(path, st)\n+\t\ttypedef struct _stat STAT_T;\n+#\telse\n+\t\ttypedef struct stat STAT_T;\n #\tendif\n #\tifndef mkdir\n #\t\tdefine mkdir(path, mode) _mkdir(path)\n@@ -60,30 +79,11 @@\n #\telse\n #\t\tdefine p_snprintf snprintf\n #\tendif\n-\n-#\tifndef PRIuZ\n-#\t\tdefine PRIuZ \"Iu\"\n-#\tendif\n-#\tifndef PRIxZ\n-#\t\tdefine PRIxZ \"Ix\"\n-#\tendif\n-\n-#\tif defined(_MSC_VER) || (defined(__MINGW32__) && !defined(__MINGW64_VERSION_MAJOR))\n-\ttypedef struct stat STAT_T;\n-#\telse\n-\ttypedef struct _stat STAT_T;\n-#\tendif\n #else\n #\tinclude <sys/wait.h> /* waitpid(2) */\n #\tinclude <unistd.h>\n #\tdefine _MAIN_CC\n #\tdefine p_snprintf snprintf\n-#\tifndef PRIuZ\n-#\t\tdefine PRIuZ \"zu\"\n-#\tendif\n-#\tifndef PRIxZ\n-#\t\tdefine PRIxZ \"zx\"\n-#\tendif\n \ttypedef struct stat STAT_T;\n #endif\n \n@@ -102,7 +102,7 @@ fixture_path(const char *base, const char *fixture_name);\n struct clar_error {\n \tconst char *file;\n \tconst char *function;\n-\tsize_t line_number;\n+\tuintmax_t line_number;\n \tconst char *error_msg;\n \tchar *description;\n \n@@ -195,11 +195,12 @@ static void clar_print_shutdown(int test_count, int suite_count, int error_count\n static void clar_print_error(int num, const struct clar_report *report, const struct clar_error *error);\n static void clar_print_ontest(const char *suite_name, const char *test_name, int test_number, enum cl_test_status failed);\n static void clar_print_onsuite(const char *suite_name, int suite_index);\n+static void clar_print_onabortv(const char *msg, va_list argp);\n static void clar_print_onabort(const char *msg, ...);\n \n /* From clar_sandbox.c */\n static void clar_unsandbox(void);\n-static int clar_sandbox(void);\n+static void clar_sandbox(void);\n \n /* From summary.h */\n static struct clar_summary *clar_summary_init(const char *filename);\n@@ -218,6 +219,15 @@ static int clar_summary_shutdown(struct clar_summary *fp);\n \t\t\t\t\t\t\t   _clar.trace_payload);\t\t\t\t\t\\\n \t} while (0)\n \n+static void clar_abort(const char *msg, ...)\n+{\n+\tva_list argp;\n+\tva_start(argp, msg);\n+\tclar_print_onabortv(msg, argp);\n+\tva_end(argp);\n+\texit(-1);\n+}\n+\n void cl_trace_register(cl_trace_cb *cb, void *payload)\n {\n \t_clar.pfn_trace_cb = cb;\n@@ -271,9 +281,7 @@ static double clar_time_diff(clar_time *start, clar_time *end)\n \n static void clar_time_now(clar_time *out)\n {\n-\tstruct timezone tz;\n-\n-\tgettimeofday(out, &tz);\n+\tgettimeofday(out, NULL);\n }\n \n static double clar_time_diff(clar_time *start, clar_time *end)\n@@ -386,7 +394,8 @@ clar_run_suite(const struct clar_suite *suite, const char *filter)\n \n \t\t_clar.active_test = test[i].name;\n \n-\t\treport = calloc(1, sizeof(struct clar_report));\n+\t\tif ((report = calloc(1, sizeof(*report))) == NULL)\n+\t\t\tclar_abort(\"Failed to allocate report.\\n\");\n \t\treport->suite = _clar.active_suite;\n \t\treport->test = _clar.active_test;\n \t\treport->test_number = _clar.tests_ran;\n@@ -479,9 +488,10 @@ clar_parse_args(int argc, char **argv)\n \n \t\t\t\t\tswitch (action) {\n \t\t\t\t\tcase 's': {\n-\t\t\t\t\t\tstruct clar_explicit *explicit =\n-\t\t\t\t\t\t\tcalloc(1, sizeof(struct clar_explicit));\n-\t\t\t\t\t\tassert(explicit);\n+\t\t\t\t\t\tstruct clar_explicit *explicit;\n+\n+\t\t\t\t\t\tif ((explicit = calloc(1, sizeof(*explicit))) == NULL)\n+\t\t\t\t\t\t\tclar_abort(\"Failed to allocate explicit test.\\n\");\n \n \t\t\t\t\t\texplicit->suite_idx = j;\n \t\t\t\t\t\texplicit->filter = argument;\n@@ -505,10 +515,8 @@ clar_parse_args(int argc, char **argv)\n \t\t\t\t}\n \t\t\t}\n \n-\t\t\tif (!found) {\n-\t\t\t\tclar_print_onabort(\"No suite matching '%s' found.\\n\", argument);\n-\t\t\t\texit(-1);\n-\t\t\t}\n+\t\t\tif (!found)\n+\t\t\t\tclar_abort(\"No suite matching '%s' found.\\n\", argument);\n \t\t\tbreak;\n \t\t}\n \n@@ -540,11 +548,17 @@ clar_parse_args(int argc, char **argv)\n \t\tcase 'r':\n \t\t\t_clar.write_summary = 1;\n \t\t\tfree(_clar.summary_filename);\n-\t\t\t_clar.summary_filename = *(argument + 2) ? strdup(argument + 2) : NULL;\n+\t\t\tif (*(argument + 2)) {\n+\t\t\t\tif ((_clar.summary_filename = strdup(argument + 2)) == NULL)\n+\t\t\t\t\tclar_abort(\"Failed to allocate summary filename.\\n\");\n+\t\t\t} else {\n+\t\t\t\t_clar.summary_filename = NULL;\n+\t\t\t}\n \t\t\tbreak;\n \n \t\tdefault:\n-\t\t\tassert(!\"Unexpected commandline argument!\");\n+\t\t\tclar_abort(\"Unexpected commandline argument '%s'.\\n\",\n+\t\t\t\t   argument[1]);\n \t\t}\n \t}\n }\n@@ -566,22 +580,18 @@ clar_test_init(int argc, char **argv)\n \tif (!_clar.summary_filename &&\n \t    (summary_env = getenv(\"CLAR_SUMMARY\")) != NULL) {\n \t\t_clar.write_summary = 1;\n-\t\t_clar.summary_filename = strdup(summary_env);\n+\t\tif ((_clar.summary_filename = strdup(summary_env)) == NULL)\n+\t\t\tclar_abort(\"Failed to allocate summary filename.\\n\");\n \t}\n \n \tif (_clar.write_summary && !_clar.summary_filename)\n-\t\t_clar.summary_filename = strdup(\"summary.xml\");\n+\t\tif ((_clar.summary_filename = strdup(\"summary.xml\")) == NULL)\n+\t\t\tclar_abort(\"Failed to allocate summary filename.\\n\");\n \n-\tif (_clar.write_summary &&\n-\t    !(_clar.summary = clar_summary_init(_clar.summary_filename))) {\n-\t\tclar_print_onabort(\"Failed to open the summary file\\n\");\n-\t\texit(-1);\n-\t}\n+\tif (_clar.write_summary)\n+\t    _clar.summary = clar_summary_init(_clar.summary_filename);\n \n-\tif (clar_sandbox() < 0) {\n-\t\tclar_print_onabort(\"Failed to sandbox the test runner.\\n\");\n-\t\texit(-1);\n-\t}\n+\tclar_sandbox();\n }\n \n int\n@@ -615,10 +625,9 @@ clar_test_shutdown(void)\n \n \tclar_unsandbox();\n \n-\tif (_clar.write_summary && clar_summary_shutdown(_clar.summary) < 0) {\n-\t\tclar_print_onabort(\"Failed to write the summary file\\n\");\n-\t\texit(-1);\n-\t}\n+\tif (_clar.write_summary && clar_summary_shutdown(_clar.summary) < 0)\n+\t\tclar_abort(\"Failed to write the summary file '%s: %s.\\n\",\n+\t\t\t   _clar.summary_filename, strerror(errno));\n \n \tfor (explicit = _clar.explicit; explicit; explicit = explicit_next) {\n \t\texplicit_next = explicit->next;\n@@ -649,7 +658,7 @@ static void abort_test(void)\n {\n \tif (!_clar.trampoline_enabled) {\n \t\tclar_print_onabort(\n-\t\t\t\t\"Fatal error: a cleanup method raised an exception.\");\n+\t\t\t\t\"Fatal error: a cleanup method raised an exception.\\n\");\n \t\tclar_report_errors(_clar.last_report);\n \t\texit(-1);\n \t}\n@@ -673,7 +682,10 @@ void clar__fail(\n \tconst char *description,\n \tint should_abort)\n {\n-\tstruct clar_error *error = calloc(1, sizeof(struct clar_error));\n+\tstruct clar_error *error;\n+\n+\tif ((error = calloc(1, sizeof(*error))) == NULL)\n+\t\tclar_abort(\"Failed to allocate error.\\n\");\n \n \tif (_clar.last_report->errors == NULL)\n \t\t_clar.last_report->errors = error;\n@@ -688,8 +700,9 @@ void clar__fail(\n \terror->line_number = line;\n \terror->error_msg = error_msg;\n \n-\tif (description != NULL)\n-\t\terror->description = strdup(description);\n+\tif (description != NULL &&\n+\t    (error->description = strdup(description)) == NULL)\n+\t\tclar_abort(\"Failed to allocate description.\\n\");\n \n \t_clar.total_errors++;\n \t_clar.last_report->status = CL_TEST_FAILURE;\n@@ -763,6 +776,7 @@ void clar__assert_equal(\n \t\t\t}\n \t\t}\n \t}\n+#ifdef CLAR_HAVE_WCHAR\n \telse if (!strcmp(\"%ls\", fmt)) {\n \t\tconst wchar_t *wcs1 = va_arg(args, const wchar_t *);\n \t\tconst wchar_t *wcs2 = va_arg(args, const wchar_t *);\n@@ -798,8 +812,9 @@ void clar__assert_equal(\n \t\t\t}\n \t\t}\n \t}\n-\telse if (!strcmp(\"%\"PRIuZ, fmt) || !strcmp(\"%\"PRIxZ, fmt)) {\n-\t\tsize_t sz1 = va_arg(args, size_t), sz2 = va_arg(args, size_t);\n+#endif /* CLAR_HAVE_WCHAR */\n+\telse if (!strcmp(\"%\"PRIuMAX, fmt) || !strcmp(\"%\"PRIxMAX, fmt)) {\n+\t\tuintmax_t sz1 = va_arg(args, uintmax_t), sz2 = va_arg(args, uintmax_t);\n \t\tis_equal = (sz1 == sz2);\n \t\tif (!is_equal) {\n \t\t\tint offset = p_snprintf(buf, sizeof(buf), fmt, sz1);\ndiff --git a/t/unit-tests/clar/clar/print.h b/t/unit-tests/clar/clar/print.h\nindex c17e2f693bd..69d0ee967e7 100644\n--- a/t/unit-tests/clar/clar/print.h\n+++ b/t/unit-tests/clar/clar/print.h\n@@ -21,7 +21,7 @@ static void clar_print_clap_error(int num, const struct clar_report *report, con\n {\n \tprintf(\"  %d) Failure:\\n\", num);\n \n-\tprintf(\"%s::%s [%s:%\"PRIuZ\"]\\n\",\n+\tprintf(\"%s::%s [%s:%\"PRIuMAX\"]\\n\",\n \t\treport->suite,\n \t\treport->test,\n \t\terror->file,\n@@ -136,7 +136,7 @@ static void clar_print_tap_ontest(const char *suite_name, const char *test_name,\n \n \t\tprintf(\"    at:\\n\");\n \t\tprintf(\"      file: '\"); print_escaped(error->file); printf(\"'\\n\");\n-\t\tprintf(\"      line: %\" PRIuZ \"\\n\", error->line_number);\n+\t\tprintf(\"      line: %\" PRIuMAX \"\\n\", error->line_number);\n \t\tprintf(\"      function: '%s'\\n\", error->function);\n \t\tprintf(\"    ---\\n\");\n \n@@ -202,10 +202,15 @@ static void clar_print_onsuite(const char *suite_name, int suite_index)\n \tPRINT(onsuite, suite_name, suite_index);\n }\n \n+static void clar_print_onabortv(const char *msg, va_list argp)\n+{\n+\tPRINT(onabort, msg, argp);\n+}\n+\n static void clar_print_onabort(const char *msg, ...)\n {\n \tva_list argp;\n \tva_start(argp, msg);\n-\tPRINT(onabort, msg, argp);\n+\tclar_print_onabortv(msg, argp);\n \tva_end(argp);\n }\ndiff --git a/t/unit-tests/clar/clar/sandbox.h b/t/unit-tests/clar/clar/sandbox.h\nindex e25057b7c49..bc960f50e0f 100644\n--- a/t/unit-tests/clar/clar/sandbox.h\n+++ b/t/unit-tests/clar/clar/sandbox.h\n@@ -122,14 +122,14 @@ static int build_sandbox_path(void)\n \n \tif (mkdir(_clar_path, 0700) != 0)\n \t\treturn -1;\n-#elif defined(__TANDEM)\n-\tif (mktemp(_clar_path) == NULL)\n+#elif defined(_WIN32)\n+\tif (_mktemp_s(_clar_path, sizeof(_clar_path)) != 0)\n \t\treturn -1;\n \n \tif (mkdir(_clar_path, 0700) != 0)\n \t\treturn -1;\n-#elif defined(_WIN32)\n-\tif (_mktemp_s(_clar_path, sizeof(_clar_path)) != 0)\n+#elif defined(__sun) || defined(__TANDEM)\n+\tif (mktemp(_clar_path) == NULL)\n \t\treturn -1;\n \n \tif (mkdir(_clar_path, 0700) != 0)\n@@ -142,15 +142,14 @@ static int build_sandbox_path(void)\n \treturn 0;\n }\n \n-static int clar_sandbox(void)\n+static void clar_sandbox(void)\n {\n \tif (_clar_path[0] == '\\0' && build_sandbox_path() < 0)\n-\t\treturn -1;\n+\t\tclar_abort(\"Failed to build sandbox path.\\n\");\n \n \tif (chdir(_clar_path) != 0)\n-\t\treturn -1;\n-\n-\treturn 0;\n+\t\tclar_abort(\"Failed to change into sandbox directory '%s': %s.\\n\",\n+\t\t\t   _clar_path, strerror(errno));\n }\n \n const char *clar_sandbox_path(void)\ndiff --git a/t/unit-tests/clar/clar/summary.h b/t/unit-tests/clar/clar/summary.h\nindex 4dd352e28b8..0d0b646fe75 100644\n--- a/t/unit-tests/clar/clar/summary.h\n+++ b/t/unit-tests/clar/clar/summary.h\n@@ -66,16 +66,12 @@ struct clar_summary *clar_summary_init(const char *filename)\n \tstruct clar_summary *summary;\n \tFILE *fp;\n \n-\tif ((fp = fopen(filename, \"w\")) == NULL) {\n-\t\tperror(\"fopen\");\n-\t\treturn NULL;\n-\t}\n+\tif ((fp = fopen(filename, \"w\")) == NULL)\n+\t\tclar_abort(\"Failed to open the summary file '%s': %s.\\n\",\n+\t\t\t   filename, strerror(errno));\n \n-\tif ((summary = malloc(sizeof(struct clar_summary))) == NULL) {\n-\t\tperror(\"malloc\");\n-\t\tfclose(fp);\n-\t\treturn NULL;\n-\t}\n+\tif ((summary = malloc(sizeof(struct clar_summary))) == NULL)\n+\t\tclar_abort(\"Failed to allocate summary.\\n\");\n \n \tsummary->filename = filename;\n \tsummary->fp = fp;\ndiff --git a/t/unit-tests/clar/test/.gitignore b/t/unit-tests/clar/test/.gitignore\ndeleted file mode 100644\nindex a477d0c40ca..00000000000\n--- a/t/unit-tests/clar/test/.gitignore\n+++ /dev/null\n@@ -1,4 +0,0 @@\n-clar.suite\n-.clarcache\n-clar_test\n-*.o\ndiff --git a/t/unit-tests/clar/test/CMakeLists.txt b/t/unit-tests/clar/test/CMakeLists.txt\nnew file mode 100644\nindex 00000000000..7f2c1dc17a9\n--- /dev/null\n+++ b/t/unit-tests/clar/test/CMakeLists.txt\n@@ -0,0 +1,39 @@\n+find_package(Python COMPONENTS Interpreter REQUIRED)\n+\n+add_custom_command(OUTPUT \"${CMAKE_CURRENT_BINARY_DIR}/clar.suite\"\n+\tCOMMAND \"${Python_EXECUTABLE}\" \"${CMAKE_SOURCE_DIR}/generate.py\" --output \"${CMAKE_CURRENT_BINARY_DIR}\"\n+\tDEPENDS main.c sample.c clar_test.h\n+\tWORKING_DIRECTORY \"${CMAKE_CURRENT_SOURCE_DIR}\"\n+)\n+\n+add_executable(clar_test)\n+set_target_properties(clar_test PROPERTIES\n+\tC_STANDARD 90\n+\tC_STANDARD_REQUIRED ON\n+\tC_EXTENSIONS OFF\n+)\n+\n+# MSVC generates all kinds of warnings. We may want to fix these in the future\n+# and then unconditionally treat warnings as errors.\n+if(NOT MSVC)\n+\tset_target_properties(clar_test PROPERTIES\n+\t\tCOMPILE_WARNING_AS_ERROR ON\n+\t)\n+endif()\n+\n+target_sources(clar_test PRIVATE\n+\tmain.c\n+\tsample.c\n+\t\"${CMAKE_CURRENT_BINARY_DIR}/clar.suite\"\n+)\n+target_compile_definitions(clar_test PRIVATE\n+\tCLAR_FIXTURE_PATH=\"${CMAKE_CURRENT_SOURCE_DIR}/resources/\"\n+)\n+target_compile_options(clar_test PRIVATE\n+\t$<IF:$<CXX_COMPILER_ID:MSVC>,/W4,-Wall>\n+)\n+target_include_directories(clar_test PRIVATE\n+\t\"${CMAKE_SOURCE_DIR}\"\n+\t\"${CMAKE_CURRENT_BINARY_DIR}\"\n+)\n+target_link_libraries(clar_test clar)\ndiff --git a/t/unit-tests/clar/test/Makefile b/t/unit-tests/clar/test/Makefile\ndeleted file mode 100644\nindex 93c6b2ad32c..00000000000\n--- a/t/unit-tests/clar/test/Makefile\n+++ /dev/null\n@@ -1,39 +0,0 @@\n-#\n-# Copyright (c) Vicent Marti. All rights reserved.\n-#\n-# This file is part of clar, distributed under the ISC license.\n-# For full terms see the included COPYING file.\n-#\n-\n-#\n-# Set up the path to the clar sources and to the fixtures directory\n-#\n-# The fixture path needs to be an absolute path so it can be used\n-# even after we have chdir'ed into the test directory while testing.\n-#\n-CURRENT_MAKEFILE  := $(word $(words $(MAKEFILE_LIST)),$(MAKEFILE_LIST))\n-TEST_DIRECTORY    := $(abspath $(dir $(CURRENT_MAKEFILE)))\n-CLAR_PATH         := $(dir $(TEST_DIRECTORY))\n-CLAR_FIXTURE_PATH := $(TEST_DIRECTORY)/resources/\n-\n-CFLAGS=-g -I.. -I. -Wall -DCLAR_FIXTURE_PATH=\\\"$(CLAR_FIXTURE_PATH)\\\"\n-\n-.PHONY: clean\n-\n-# list the objects that go into our test\n-objects = main.o sample.o\n-\n-# build the test executable itself\n-clar_test: $(objects) clar_test.h clar.suite $(CLAR_PATH)clar.c\n-\t$(CC) $(CFLAGS) -o $@ \"$(CLAR_PATH)clar.c\" $(objects)\n-\n-# test object files depend on clar macros\n-$(objects) : $(CLAR_PATH)clar.h\n-\n-# build the clar.suite file of test metadata\n-clar.suite:\n-\tpython \"$(CLAR_PATH)generate.py\" .\n-\n-# remove all generated files\n-clean:\n-\t$(RM) -rf *.o clar.suite .clarcache clar_test clar_test.dSYM\n-- \n2.47.0.72.gef8ce8f3d4.dirty\n\n"},{"id":"505651","messageId":"cover.1729506329.git.ps@pks.im","threadId":"62322","inReplyTo":"CAOO-Oz3KsyeSjxbRpU-SdPgU5K+mPDcntT6Y4s46Mg_0ko9e_w@mail.gmail.com","subject":"[PATCH v2 0/5] t/unit-tests: improve clar platform compatibility","fromName":"Patrick Steinhardt","fromEmail":"ps@pks.im","sentAt":"2024-10-21T10:56:30Z","receivedAt":"2024-10-21T10:56:39Z","isPatch":true,"sender":{"key":"ps@pks.im","avatar":"https://avatars.githubusercontent.com/u/4056630?v=4"},"body":"Hi,\n\nthis is the second version of my patch series that addresses some\nplatform compatibility issues with clar. Changes compared to v1:\n\n  - I've merged the CMake fixes at [1] into this patch series to avoid\n    conflicts. @Taylor, please drop that other series, which is\n    \"ps/cmake-clar\".\n\n  - I've fixed up the \"generate-clar-decls.h\" script.\n\n  - I've updated the clar such that it includes upstreamed changes for\n    improved uClibc support when we lack support for `wchar_t`.\n\nThanks!\n\nPatrick\n\n[1]: <cover.1728914219.git.ps@pks.im>\n\nAlejandro R. Sedeño (1):\n  Makefile: adjust sed command for generating \"clar-decls.h\"\n\nPatrick Steinhardt (4):\n  t/unit-tests: update clar to 206accb\n  Makefile: extract script to generate clar declarations\n  cmake: fix compilation of clar-based unit tests\n  cmake: set up proper dependencies for generated clar headers\n\n Makefile                                   |   4 +-\n contrib/buildsystems/CMakeLists.txt        |  52 +++------\n t/unit-tests/clar/.editorconfig            |  13 +++\n t/unit-tests/clar/.github/workflows/ci.yml |  20 +++-\n t/unit-tests/clar/.gitignore               |   1 +\n t/unit-tests/clar/CMakeLists.txt           |  28 +++++\n t/unit-tests/clar/clar.c                   | 127 ++++++++++++---------\n t/unit-tests/clar/clar/print.h             |  11 +-\n t/unit-tests/clar/clar/sandbox.h           |  17 ++-\n t/unit-tests/clar/clar/summary.h           |  14 +--\n t/unit-tests/clar/test/.gitignore          |   4 -\n t/unit-tests/clar/test/CMakeLists.txt      |  39 +++++++\n t/unit-tests/clar/test/Makefile            |  39 -------\n t/unit-tests/generate-clar-decls.sh        |  16 +++\n 14 files changed, 219 insertions(+), 166 deletions(-)\n create mode 100644 t/unit-tests/clar/.editorconfig\n create mode 100644 t/unit-tests/clar/.gitignore\n create mode 100644 t/unit-tests/clar/CMakeLists.txt\n delete mode 100644 t/unit-tests/clar/test/.gitignore\n create mode 100644 t/unit-tests/clar/test/CMakeLists.txt\n delete mode 100644 t/unit-tests/clar/test/Makefile\n create mode 100755 t/unit-tests/generate-clar-decls.sh\n\nRange-diff against v1:\n1:  a96fbdbb5f9 ! 1:  06145a141dd t/unit-tests: update clar to 0810a36\n    @@ Metadata\n     Author: Patrick Steinhardt <ps@pks.im>\n     \n      ## Commit message ##\n    -    t/unit-tests: update clar to 0810a36\n    +    t/unit-tests: update clar to 206accb\n     \n         Update clar from:\n     \n    @@ Commit message\n     \n         To:\n     \n    -        - 0810a36 (Merge pull request #107 from pks-t/pks-sunos-compatibility, 2024-10-14)\n    +        - 206accb (Merge pull request #108 from pks-t/pks-uclibc-without-wchar, 2024-10-21)\n     \n         This update includes a bunch of fixes and improvements that we have\n         discussed in Git when initial support for clar was merged:\n    @@ Commit message\n           - We now use the combination of mktemp(3) and mkdir(3) on SunOS, same\n             as we do on NonStop.\n     \n    +      - We now support uClibc without support for <wchar.h>.\n    +\n         The most important bits here are the improved platform compatibility\n    -    with Windows, OpenSUSE and SunOS.\n    +    with Windows, OpenSUSE, SunOS and uClibc.\n     \n         Signed-off-by: Patrick Steinhardt <ps@pks.im>\n     \n    @@ t/unit-tests/clar/clar.c\n      \n      /* required for sandboxing */\n      #include <sys/types.h>\n    + #include <sys/stat.h>\n    + \n    ++#if defined(__UCLIBC__) && ! defined(__UCLIBC_HAS_WCHAR__)\n    ++\t/*\n    ++\t * uClibc can optionally be built without wchar support, in which case\n    ++\t * the installed <wchar.h> is a stub that only defines the `whar_t`\n    ++\t * type but none of the functions typically declared by it.\n    ++\t */\n    ++#else\n    ++#\tdefine CLAR_HAVE_WCHAR\n    ++#endif\n    ++\n    + #ifdef _WIN32\n    + #\tdefine WIN32_LEAN_AND_MEAN\n    + #\tinclude <windows.h>\n     @@\n      \n      #\tifndef stat\n    @@ t/unit-tests/clar/clar.c: void clar__assert_equal(\n      \t\t\t}\n      \t\t}\n      \t}\n    ++#ifdef CLAR_HAVE_WCHAR\n    + \telse if (!strcmp(\"%ls\", fmt)) {\n    + \t\tconst wchar_t *wcs1 = va_arg(args, const wchar_t *);\n    + \t\tconst wchar_t *wcs2 = va_arg(args, const wchar_t *);\n    +@@ t/unit-tests/clar/clar.c: void clar__assert_equal(\n    + \t\t\t}\n    + \t\t}\n    + \t}\n     -\telse if (!strcmp(\"%\"PRIuZ, fmt) || !strcmp(\"%\"PRIxZ, fmt)) {\n     -\t\tsize_t sz1 = va_arg(args, size_t), sz2 = va_arg(args, size_t);\n    ++#endif /* CLAR_HAVE_WCHAR */\n     +\telse if (!strcmp(\"%\"PRIuMAX, fmt) || !strcmp(\"%\"PRIxMAX, fmt)) {\n     +\t\tuintmax_t sz1 = va_arg(args, uintmax_t), sz2 = va_arg(args, uintmax_t);\n      \t\tis_equal = (sz1 == sz2);\n2:  dda9b8e033c = 2:  17d77f36d41 Makefile: adjust sed command for generating \"clar-decls.h\"\n-:  ----------- > 3:  c2e3fbcd853 Makefile: extract script to generate clar declarations\n-:  ----------- > 4:  a30017a4d89 cmake: fix compilation of clar-based unit tests\n-:  ----------- > 5:  bb005979e7e cmake: set up proper dependencies for generated clar headers\n\nbase-commit: 3a0677f8601d8937562ba14665d773fd8f2d71da\n-- \n2.47.0.72.gef8ce8f3d4.dirty\n\n"},{"id":"505652","messageId":"17d77f36d41fb2928565a4922eab3a67426d2da6.1729506329.git.ps@pks.im","threadId":"62322","inReplyTo":"cover.1729506329.git.ps@pks.im","subject":"[PATCH v2 2/5] Makefile: adjust sed command for generating \"clar-decls.h\"","fromName":"Patrick Steinhardt","fromEmail":"ps@pks.im","sentAt":"2024-10-21T10:56:35Z","receivedAt":"2024-10-21T10:56:41Z","isPatch":true,"sender":{"key":"ps@pks.im","avatar":"https://avatars.githubusercontent.com/u/4056630?v=4"},"body":"From: Alejandro R. Sedeño <asedeno@mit.edu>\n\nThis moves the end-of-line marker out of the captured group, matching\nthe start-of-line marker and for some reason fixing generation of\n\"clar-decls.h\" on some older, more esoteric platforms.\n\nSigned-off-by: Alejandro R. Sedeño <asedeno@mit.edu>\nSigned-off-by: Patrick Steinhardt <ps@pks.im>\n---\n Makefile | 2 +-\n 1 file changed, 1 insertion(+), 1 deletion(-)\n\ndiff --git a/Makefile b/Makefile\nindex feeed6f9321..0101d349f38 100644\n--- a/Makefile\n+++ b/Makefile\n@@ -3905,7 +3905,7 @@ GIT-TEST-SUITES: FORCE\n \n $(UNIT_TEST_DIR)/clar-decls.h: $(patsubst %,$(UNIT_TEST_DIR)/%.c,$(CLAR_TEST_SUITES)) GIT-TEST-SUITES\n \t$(QUIET_GEN)for suite in $(CLAR_TEST_SUITES); do \\\n-\t\tsed -ne \"s/^\\(void test_$${suite}__[a-zA-Z_0-9][a-zA-Z_0-9]*(void)$$\\)/extern \\1;/p\" $(UNIT_TEST_DIR)/$$suite.c; \\\n+\t\tsed -ne \"s/^\\(void test_$${suite}__[a-zA-Z_0-9][a-zA-Z_0-9]*(void)\\)$$/extern \\1;/p\" $(UNIT_TEST_DIR)/$$suite.c; \\\n \tdone >$@\n $(UNIT_TEST_DIR)/clar.suite: $(UNIT_TEST_DIR)/clar-decls.h\n \t$(QUIET_GEN)awk -f $(UNIT_TEST_DIR)/clar-generate.awk $< >$(UNIT_TEST_DIR)/clar.suite\n-- \n2.47.0.72.gef8ce8f3d4.dirty\n\n"},{"id":"505653","messageId":"c2e3fbcd8532038158a0ead6f0a2f752f557ab7f.1729506329.git.ps@pks.im","threadId":"62322","inReplyTo":"cover.1729506329.git.ps@pks.im","subject":"[PATCH v2 3/5] Makefile: extract script to generate clar declarations","fromName":"Patrick Steinhardt","fromEmail":"ps@pks.im","sentAt":"2024-10-21T10:56:38Z","receivedAt":"2024-10-21T10:56:43Z","isPatch":true,"sender":{"key":"ps@pks.im","avatar":"https://avatars.githubusercontent.com/u/4056630?v=4"},"body":"Extract the script to generate function declarations for the clar unit\ntesting framework into a standalone script. This is done such that we\ncan reuse it in other build systems.\n\nSigned-off-by: Patrick Steinhardt <ps@pks.im>\n---\n Makefile                            |  4 +---\n t/unit-tests/generate-clar-decls.sh | 16 ++++++++++++++++\n 2 files changed, 17 insertions(+), 3 deletions(-)\n create mode 100755 t/unit-tests/generate-clar-decls.sh\n\ndiff --git a/Makefile b/Makefile\nindex 0101d349f38..6318ec0271b 100644\n--- a/Makefile\n+++ b/Makefile\n@@ -3904,9 +3904,7 @@ GIT-TEST-SUITES: FORCE\n             fi\n \n $(UNIT_TEST_DIR)/clar-decls.h: $(patsubst %,$(UNIT_TEST_DIR)/%.c,$(CLAR_TEST_SUITES)) GIT-TEST-SUITES\n-\t$(QUIET_GEN)for suite in $(CLAR_TEST_SUITES); do \\\n-\t\tsed -ne \"s/^\\(void test_$${suite}__[a-zA-Z_0-9][a-zA-Z_0-9]*(void)\\)$$/extern \\1;/p\" $(UNIT_TEST_DIR)/$$suite.c; \\\n-\tdone >$@\n+\t$(QUIET_GEN)$(SHELL_PATH) $(UNIT_TEST_DIR)/generate-clar-decls.sh \"$@\" $(filter %.c,$^)\n $(UNIT_TEST_DIR)/clar.suite: $(UNIT_TEST_DIR)/clar-decls.h\n \t$(QUIET_GEN)awk -f $(UNIT_TEST_DIR)/clar-generate.awk $< >$(UNIT_TEST_DIR)/clar.suite\n $(CLAR_TEST_OBJS): $(UNIT_TEST_DIR)/clar-decls.h\ndiff --git a/t/unit-tests/generate-clar-decls.sh b/t/unit-tests/generate-clar-decls.sh\nnew file mode 100755\nindex 00000000000..688e0885f4f\n--- /dev/null\n+++ b/t/unit-tests/generate-clar-decls.sh\n@@ -0,0 +1,16 @@\n+#!/bin/sh\n+\n+if test $# -lt 2\n+then\n+\techo \"USAGE: $0 <OUTPUT> <SUITE>...\" 2>&1\n+\texit 1\n+fi\n+\n+OUTPUT=\"$1\"\n+shift\n+\n+for suite in \"$@\"\n+do\n+\tsed -ne \"s/^\\(void test_$(basename \"${suite%.c}\")__[a-zA-Z_0-9][a-zA-Z_0-9]*(void)\\)$/extern \\1;/p\" \"$suite\" ||\n+\texit 1\n+done >\"$OUTPUT\"\n-- \n2.47.0.72.gef8ce8f3d4.dirty\n\n"},{"id":"505654","messageId":"a30017a4d8998e85915d959c16f181a8d4e813f2.1729506329.git.ps@pks.im","threadId":"62322","inReplyTo":"cover.1729506329.git.ps@pks.im","subject":"[PATCH v2 4/5] cmake: fix compilation of clar-based unit tests","fromName":"Patrick Steinhardt","fromEmail":"ps@pks.im","sentAt":"2024-10-21T10:56:41Z","receivedAt":"2024-10-21T10:56:46Z","isPatch":true,"sender":{"key":"ps@pks.im","avatar":"https://avatars.githubusercontent.com/u/4056630?v=4"},"body":"The compilation of clar-based unit tests is broken because we do not\nadd the binary directory into which we generate the \"clar-decls.h\" and\n\"clar.suite\" files as include directories. Instead, we accidentally set\nup the source directory as include directory.\n\nFix this by including the binary directory instead of the source\ndirectory. Furthermore, set up the include directories as PUBLIC instead\nof PRIVATE such that they propagate from \"unit-tests.lib\" to the\n\"unit-tests\" executable, which needs to include the same directory.\n\nReported-by: Ed Reel <edreel@gmail.com>\nSigned-off-by: Patrick Steinhardt <ps@pks.im>\n---\n contrib/buildsystems/CMakeLists.txt | 2 +-\n 1 file changed, 1 insertion(+), 1 deletion(-)\n\ndiff --git a/contrib/buildsystems/CMakeLists.txt b/contrib/buildsystems/CMakeLists.txt\nindex 62af7b33d2f..093852ad9d6 100644\n--- a/contrib/buildsystems/CMakeLists.txt\n+++ b/contrib/buildsystems/CMakeLists.txt\n@@ -1042,7 +1042,7 @@ file(WRITE \"${CMAKE_BINARY_DIR}/t/unit-tests/clar.suite\" \"${clar_decls}\" \"${clar\n list(TRANSFORM clar_test_SUITES PREPEND \"${CMAKE_SOURCE_DIR}/t/unit-tests/\")\n list(TRANSFORM clar_test_SUITES APPEND \".c\")\n add_library(unit-tests-lib ${clar_test_SUITES} \"${CMAKE_SOURCE_DIR}/t/unit-tests/clar/clar.c\")\n-target_include_directories(unit-tests-lib PRIVATE \"${CMAKE_SOURCE_DIR}/t/unit-tests\")\n+target_include_directories(unit-tests-lib PUBLIC \"${CMAKE_BINARY_DIR}/t/unit-tests\")\n add_executable(unit-tests \"${CMAKE_SOURCE_DIR}/t/unit-tests/unit-test.c\")\n target_link_libraries(unit-tests unit-tests-lib common-main)\n set_target_properties(unit-tests\n-- \n2.47.0.72.gef8ce8f3d4.dirty\n\n"},{"id":"505655","messageId":"bb005979e7eb335b0178094251b5c37682d7d47b.1729506329.git.ps@pks.im","threadId":"62322","inReplyTo":"cover.1729506329.git.ps@pks.im","subject":"[PATCH v2 5/5] cmake: set up proper dependencies for generated clar headers","fromName":"Patrick Steinhardt","fromEmail":"ps@pks.im","sentAt":"2024-10-21T10:56:44Z","receivedAt":"2024-10-21T10:56:51Z","isPatch":true,"sender":{"key":"ps@pks.im","avatar":"https://avatars.githubusercontent.com/u/4056630?v=4"},"body":"The auto-generated headers used by clar are written at configure time\nand thus do not get regenerated automatically. Refactor the build\nrecipes such that we use custom commands instead, which also has the\nbenefit that we can reuse the same infrastructure as our Makefile.\n\nSigned-off-by: Patrick Steinhardt <ps@pks.im>\n---\n contrib/buildsystems/CMakeLists.txt | 50 +++++++----------------------\n 1 file changed, 12 insertions(+), 38 deletions(-)\n\ndiff --git a/contrib/buildsystems/CMakeLists.txt b/contrib/buildsystems/CMakeLists.txt\nindex 093852ad9d6..9f80ab92656 100644\n--- a/contrib/buildsystems/CMakeLists.txt\n+++ b/contrib/buildsystems/CMakeLists.txt\n@@ -1002,46 +1002,20 @@ foreach(unit_test ${unit_test_PROGRAMS})\n endforeach()\n \n parse_makefile_for_scripts(clar_test_SUITES \"CLAR_TEST_SUITES\" \"\")\n-\n-set(clar_decls \"\")\n-set(clar_cbs \"\")\n-set(clar_cbs_count 0)\n-set(clar_suites \"static struct clar_suite _clar_suites[] = {\\n\")\n-list(LENGTH clar_test_SUITES clar_suites_count)\n-foreach(suite ${clar_test_SUITES})\n-\tfile(STRINGS \"${CMAKE_SOURCE_DIR}/t/unit-tests/${suite}.c\" decls\n-\t\tREGEX \"^void test_${suite}__[a-zA-Z_0-9][a-zA-Z_0-9]*\\\\(void\\\\)$\")\n-\n-\tlist(LENGTH decls decls_count)\n-\tstring(REGEX REPLACE \"void (test_${suite}__([a-zA-Z_0-9]*))\\\\(void\\\\)\" \"    { \\\"\\\\2\\\", &\\\\1 },\\n\" cbs ${decls})\n-\tstring(JOIN \"\" cbs ${cbs})\n-\tlist(TRANSFORM decls PREPEND \"extern \")\n-\tstring(JOIN \";\\n\" decls ${decls})\n-\n-\tstring(APPEND clar_decls \"${decls};\\n\")\n-\tstring(APPEND clar_cbs\n-\t\t\"static const struct clar_func _clar_cb_${suite}[] = {\\n\"\n-\t\t${cbs}\n-\t\t\"};\\n\")\n-\tstring(APPEND clar_suites\n-\t\t\"    {\\n\"\n-\t\t\"        \\\"${suite}\\\",\\n\"\n-\t\t\"        { NULL, NULL },\\n\"\n-\t\t\"        { NULL, NULL },\\n\"\n-\t\t\"        _clar_cb_${suite}, ${decls_count}, 1\\n\"\n-\t\t\"    },\\n\")\n-\tmath(EXPR clar_cbs_count \"${clar_cbs_count}+${decls_count}\")\n-endforeach()\n-string(APPEND clar_suites\n-\t\"};\\n\"\n-\t\"static const size_t _clar_suite_count = ${clar_suites_count};\\n\"\n-\t\"static const size_t _clar_callback_count = ${clar_cbs_count};\\n\")\n-file(WRITE \"${CMAKE_BINARY_DIR}/t/unit-tests/clar-decls.h\" \"${clar_decls}\")\n-file(WRITE \"${CMAKE_BINARY_DIR}/t/unit-tests/clar.suite\" \"${clar_decls}\" \"${clar_cbs}\" \"${clar_suites}\")\n-\n list(TRANSFORM clar_test_SUITES PREPEND \"${CMAKE_SOURCE_DIR}/t/unit-tests/\")\n list(TRANSFORM clar_test_SUITES APPEND \".c\")\n-add_library(unit-tests-lib ${clar_test_SUITES} \"${CMAKE_SOURCE_DIR}/t/unit-tests/clar/clar.c\")\n+add_custom_command(OUTPUT \"${CMAKE_BINARY_DIR}/t/unit-tests/clar-decls.h\"\n+\tCOMMAND ${CMAKE_SOURCE_DIR}/t/unit-tests/generate-clar-decls.sh \"${CMAKE_BINARY_DIR}/t/unit-tests/clar-decls.h\" ${clar_test_SUITES}\n+\tDEPENDS ${CMAKE_SOURCE_DIR}/t/unit-tests/generate-clar-decls.sh ${clar_test_SUITES})\n+add_custom_command(OUTPUT \"${CMAKE_BINARY_DIR}/t/unit-tests/clar.suite\"\n+\tCOMMAND awk -f \"${CMAKE_SOURCE_DIR}/t/unit-tests/clar-generate.awk\" \"${CMAKE_BINARY_DIR}/t/unit-tests/clar-decls.h\" > \"${CMAKE_BINARY_DIR}/t/unit-tests/clar.suite\"\n+\tDEPENDS \"${CMAKE_SOURCE_DIR}/t/unit-tests/clar-generate.awk\" \"${CMAKE_BINARY_DIR}/t/unit-tests/clar-decls.h\")\n+\n+add_library(unit-tests-lib ${clar_test_SUITES}\n+\t\"${CMAKE_SOURCE_DIR}/t/unit-tests/clar/clar.c\"\n+\t\"${CMAKE_BINARY_DIR}/t/unit-tests/clar-decls.h\"\n+\t\"${CMAKE_BINARY_DIR}/t/unit-tests/clar.suite\"\n+)\n target_include_directories(unit-tests-lib PUBLIC \"${CMAKE_BINARY_DIR}/t/unit-tests\")\n add_executable(unit-tests \"${CMAKE_SOURCE_DIR}/t/unit-tests/unit-test.c\")\n target_link_libraries(unit-tests unit-tests-lib common-main)\n-- \n2.47.0.72.gef8ce8f3d4.dirty\n\n"},{"id":"505656","messageId":"e3bf73c3-2f4a-4b49-9016-a455163616ca@app.fastmail.com","threadId":"62322","inReplyTo":"17d77f36d41fb2928565a4922eab3a67426d2da6.1729506329.git.ps@pks.im","subject":"Re: [PATCH v2 2/5] Makefile: adjust sed command for generating \"clar-decls.h\"","fromName":"Kristoffer Haugsbakk","fromEmail":"kristofferhaugsbakk@fastmail.com","sentAt":"2024-10-21T11:07:17Z","receivedAt":"2024-10-21T11:07:40Z","isPatch":true,"sender":{"key":"kristofferhaugsbakk@fastmail.com","avatar":null},"body":"On Mon, Oct 21, 2024, at 12:56, Patrick Steinhardt wrote:\n> From: Alejandro R. Sedeño <asedeno@mit.edu>\n>\n> This moves the end-of-line marker out of the captured group, matching\n> the start-of-line marker and for some reason fixing generation of\n> \"clar-decls.h\" on some older, more esoteric platforms.\n>\n> Signed-off-by: Alejandro R. Sedeño <asedeno@mit.edu>\n> Signed-off-by: Patrick Steinhardt <ps@pks.im>\n\nAlejandro used two signoffs in his original:[1]\n\n    Signed-off-by: Alejandro R. Sedeño <asedeno@mit.edu>\n    Signed-off-by: Alejandro R. Sedeño <asedeno@google.com>\n\nI don’t know if this matters?\n\nSee also https://lore.kernel.org/git/xmqqilc571hf.fsf@gitster.g/\n\n🔗 1: https://lore.kernel.org/git/20241012144027.2573690-1-asedeno@mit.edu/\n"},{"id":"505660","messageId":"ZxY8YL-dSlVVBT0K@pks.im","threadId":"62322","inReplyTo":"e3bf73c3-2f4a-4b49-9016-a455163616ca@app.fastmail.com","subject":"Re: [PATCH v2 2/5] Makefile: adjust sed command for generating \"clar-decls.h\"","fromName":"Patrick Steinhardt","fromEmail":"ps@pks.im","sentAt":"2024-10-21T11:35:01Z","receivedAt":"2024-10-21T11:35:08Z","isPatch":true,"sender":{"key":"ps@pks.im","avatar":"https://avatars.githubusercontent.com/u/4056630?v=4"},"body":"On Mon, Oct 21, 2024 at 01:07:17PM +0200, Kristoffer Haugsbakk wrote:\n> On Mon, Oct 21, 2024, at 12:56, Patrick Steinhardt wrote:\n> > From: Alejandro R. Sedeño <asedeno@mit.edu>\n> >\n> > This moves the end-of-line marker out of the captured group, matching\n> > the start-of-line marker and for some reason fixing generation of\n> > \"clar-decls.h\" on some older, more esoteric platforms.\n> >\n> > Signed-off-by: Alejandro R. Sedeño <asedeno@mit.edu>\n> > Signed-off-by: Patrick Steinhardt <ps@pks.im>\n> \n> Alejandro used two signoffs in his original:[1]\n> \n>     Signed-off-by: Alejandro R. Sedeño <asedeno@mit.edu>\n>     Signed-off-by: Alejandro R. Sedeño <asedeno@google.com>\n> \n> I don’t know if this matters?\n> \n> See also https://lore.kernel.org/git/xmqqilc571hf.fsf@gitster.g/\n> \n> 🔗 1: https://lore.kernel.org/git/20241012144027.2573690-1-asedeno@mit.edu/\n\nIt felt more like an accident than intent, but true, I should've asked.\nAlejandro, please let me know whether I should restore the second SOB.\n\nThanks for reading this carefully!\n\nPatrick\n"},{"id":"505760","messageId":"Zxa/CQF3bz8PtD0h@nand.local","threadId":"62322","inReplyTo":"cover.1729506329.git.ps@pks.im","subject":"Re: [PATCH v2 0/5] t/unit-tests: improve clar platform compatibility","fromName":"Taylor Blau","fromEmail":"me@ttaylorr.com","sentAt":"2024-10-21T20:52:25Z","receivedAt":"2024-10-21T20:52:28Z","isPatch":true,"sender":{"key":"me@ttaylorr.com","avatar":"https://avatars.githubusercontent.com/u/301000140?v=4"},"body":"On Mon, Oct 21, 2024 at 12:56:30PM +0200, Patrick Steinhardt wrote:\n> Hi,\n>\n> this is the second version of my patch series that addresses some\n> platform compatibility issues with clar. Changes compared to v1:\n>\n>   - I've merged the CMake fixes at [1] into this patch series to avoid\n>     conflicts. @Taylor, please drop that other series, which is\n>     \"ps/cmake-clar\".\n>\n>   - I've fixed up the \"generate-clar-decls.h\" script.\n>\n>   - I've updated the clar such that it includes upstreamed changes for\n>     improved uClibc support when we lack support for `wchar_t`.\n\nThanks (especially so for the suggestion to drop ps/cmake-clar), will\nqueue.\n\nThanks,\nTaylor\n"},{"id":"506101","messageId":"CAOLa=ZR6cnhxy7K7TChxLafm7Ep0XUVFSK+LgNPtNX8yVLyWtA@mail.gmail.com","threadId":"62322","inReplyTo":"cover.1729506329.git.ps@pks.im","subject":"Re: [PATCH v2 0/5] t/unit-tests: improve clar platform compatibility","fromName":"karthik nayak","fromEmail":"karthik.188@gmail.com","sentAt":"2024-10-25T12:17:50Z","receivedAt":"2024-10-25T12:17:52Z","isPatch":true,"sender":{"key":"karthik.188@gmail.com","avatar":"https://avatars.githubusercontent.com/u/1786334?v=4"},"body":"Patrick Steinhardt <ps@pks.im> writes:\n\n> Hi,\n>\n> this is the second version of my patch series that addresses some\n> platform compatibility issues with clar. Changes compared to v1:\n>\n>   - I've merged the CMake fixes at [1] into this patch series to avoid\n>     conflicts. @Taylor, please drop that other series, which is\n>     \"ps/cmake-clar\".\n>\n>   - I've fixed up the \"generate-clar-decls.h\" script.\n>\n>   - I've updated the clar such that it includes upstreamed changes for\n>     improved uClibc support when we lack support for `wchar_t`.\n>\n> Thanks!\n>\n\nI went through the patches, played around with it locally too, couldn't\nfind any issues. So looks good to me!\n\n\n[snip]\n"},{"id":"506137","messageId":"Zxx3nmfp61DR6vvB@archie.me","threadId":"62322","inReplyTo":"cover.1729506329.git.ps@pks.im","subject":"Re: [PATCH v2 0/5] t/unit-tests: improve clar platform compatibility","fromName":"Bagas Sanjaya","fromEmail":"bagasdotme@gmail.com","sentAt":"2024-10-26T05:01:18Z","receivedAt":"2024-10-26T05:01:23Z","isPatch":true,"sender":{"key":"bagasdotme@gmail.com","avatar":"https://avatars.githubusercontent.com/u/40219486?v=4"},"body":"On Mon, Oct 21, 2024 at 12:56:30PM +0200, Patrick Steinhardt wrote:\n> Hi,\n> \n> this is the second version of my patch series that addresses some\n> platform compatibility issues with clar. Changes compared to v1:\n> \n>   - I've merged the CMake fixes at [1] into this patch series to avoid\n>     conflicts. @Taylor, please drop that other series, which is\n>     \"ps/cmake-clar\".\n> \n>   - I've fixed up the \"generate-clar-decls.h\" script.\n> \n>   - I've updated the clar such that it includes upstreamed changes for\n>     improved uClibc support when we lack support for `wchar_t`.\n> \n\nGit builds successfully on Buildroot (aarch64 uClibc with and without wchar,\naarch64 glibc).\n\nTested-by: Bagas Sanjaya <bagasdotme@gmail.com>\n\n-- \nAn old man doll... just what I always wanted! - Clara\n"},{"id":"506146","messageId":"Zx45nXPWdFIqVPTo@pks.im","threadId":"62322","inReplyTo":"Zxx3nmfp61DR6vvB@archie.me","subject":"Re: [PATCH v2 0/5] t/unit-tests: improve clar platform compatibility","fromName":"Patrick Steinhardt","fromEmail":"ps@pks.im","sentAt":"2024-10-27T13:01:17Z","receivedAt":"2024-10-27T13:01:04Z","isPatch":true,"sender":{"key":"ps@pks.im","avatar":"https://avatars.githubusercontent.com/u/4056630?v=4"},"body":"On Sat, Oct 26, 2024 at 12:01:18PM +0700, Bagas Sanjaya wrote:\n> On Mon, Oct 21, 2024 at 12:56:30PM +0200, Patrick Steinhardt wrote:\n> > Hi,\n> > \n> > this is the second version of my patch series that addresses some\n> > platform compatibility issues with clar. Changes compared to v1:\n> > \n> >   - I've merged the CMake fixes at [1] into this patch series to avoid\n> >     conflicts. @Taylor, please drop that other series, which is\n> >     \"ps/cmake-clar\".\n> > \n> >   - I've fixed up the \"generate-clar-decls.h\" script.\n> > \n> >   - I've updated the clar such that it includes upstreamed changes for\n> >     improved uClibc support when we lack support for `wchar_t`.\n> > \n> \n> Git builds successfully on Buildroot (aarch64 uClibc with and without wchar,\n> aarch64 glibc).\n> \n> Tested-by: Bagas Sanjaya <bagasdotme@gmail.com>\n\nGreat, thanks a lot for verifying whether this fixes your issues!\n\nPatrick\n"},{"id":"506178","messageId":"Zx7TQXoOq38S5gPL@nand.local","threadId":"62322","inReplyTo":"Zx45nXPWdFIqVPTo@pks.im","subject":"Re: [PATCH v2 0/5] t/unit-tests: improve clar platform compatibility","fromName":"Taylor Blau","fromEmail":"me@ttaylorr.com","sentAt":"2024-10-27T23:56:49Z","receivedAt":"2024-10-27T23:56:53Z","isPatch":true,"sender":{"key":"me@ttaylorr.com","avatar":"https://avatars.githubusercontent.com/u/301000140?v=4"},"body":"On Sun, Oct 27, 2024 at 02:01:17PM +0100, Patrick Steinhardt wrote:\n> On Sat, Oct 26, 2024 at 12:01:18PM +0700, Bagas Sanjaya wrote:\n> > On Mon, Oct 21, 2024 at 12:56:30PM +0200, Patrick Steinhardt wrote:\n> > > Hi,\n> > >\n> > > this is the second version of my patch series that addresses some\n> > > platform compatibility issues with clar. Changes compared to v1:\n> > >\n> > >   - I've merged the CMake fixes at [1] into this patch series to avoid\n> > >     conflicts. @Taylor, please drop that other series, which is\n> > >     \"ps/cmake-clar\".\n> > >\n> > >   - I've fixed up the \"generate-clar-decls.h\" script.\n> > >\n> > >   - I've updated the clar such that it includes upstreamed changes for\n> > >     improved uClibc support when we lack support for `wchar_t`.\n> > >\n> >\n> > Git builds successfully on Buildroot (aarch64 uClibc with and without wchar,\n> > aarch64 glibc).\n> >\n> > Tested-by: Bagas Sanjaya <bagasdotme@gmail.com>\n>\n> Great, thanks a lot for verifying whether this fixes your issues!\n\nThanks, both. Let's start merging this one down.\n\nThanks,\nTaylor\n"},{"id":"506680","messageId":"3b2cb360-297a-915c-ae27-c45f38fa49b9@gmx.de","threadId":"62322","inReplyTo":"bb005979e7eb335b0178094251b5c37682d7d47b.1729506329.git.ps@pks.im","subject":"Re: [PATCH v2 5/5] cmake: set up proper dependencies for generated clar headers","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2024-11-05T19:55:23Z","receivedAt":"2024-11-05T19:55:54Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi Patrick,\n\nOn Mon, 21 Oct 2024, Patrick Steinhardt wrote:\n\n> The auto-generated headers used by clar are written at configure time\n> and thus do not get regenerated automatically. Refactor the build\n> recipes such that we use custom commands instead, which also has the\n> benefit that we can reuse the same infrastructure as our Makefile.\n\nFor the record: I did not use a shell script to generate the header for a\nspecific reason: Unix shell scripts are not native to Windows. Therefore\nthey cannot in general be run on Windows, however that was precisely the\nidea for the CMake definition: to be run on a vanilla Windows with Visual\nStudio installed.\n\nSadly, even Git's CI definition sets things up in a way that Git for\nWindows' Bash can be used in the CMake definition, but in the intended use\ncase (opening a checkout of git/git in Visual Studio without any further\ntools required) won't have a usable Bash.\n\nTherefore I am unsure whether this patch is desirable.\n\nCiao,\nJohannes\n\n>\n> Signed-off-by: Patrick Steinhardt <ps@pks.im>\n> ---\n>  contrib/buildsystems/CMakeLists.txt | 50 +++++++----------------------\n>  1 file changed, 12 insertions(+), 38 deletions(-)\n>\n> diff --git a/contrib/buildsystems/CMakeLists.txt b/contrib/buildsystems/CMakeLists.txt\n> index 093852ad9d6..9f80ab92656 100644\n> --- a/contrib/buildsystems/CMakeLists.txt\n> +++ b/contrib/buildsystems/CMakeLists.txt\n> @@ -1002,46 +1002,20 @@ foreach(unit_test ${unit_test_PROGRAMS})\n>  endforeach()\n>\n>  parse_makefile_for_scripts(clar_test_SUITES \"CLAR_TEST_SUITES\" \"\")\n> -\n> -set(clar_decls \"\")\n> -set(clar_cbs \"\")\n> -set(clar_cbs_count 0)\n> -set(clar_suites \"static struct clar_suite _clar_suites[] = {\\n\")\n> -list(LENGTH clar_test_SUITES clar_suites_count)\n> -foreach(suite ${clar_test_SUITES})\n> -\tfile(STRINGS \"${CMAKE_SOURCE_DIR}/t/unit-tests/${suite}.c\" decls\n> -\t\tREGEX \"^void test_${suite}__[a-zA-Z_0-9][a-zA-Z_0-9]*\\\\(void\\\\)$\")\n> -\n> -\tlist(LENGTH decls decls_count)\n> -\tstring(REGEX REPLACE \"void (test_${suite}__([a-zA-Z_0-9]*))\\\\(void\\\\)\" \"    { \\\"\\\\2\\\", &\\\\1 },\\n\" cbs ${decls})\n> -\tstring(JOIN \"\" cbs ${cbs})\n> -\tlist(TRANSFORM decls PREPEND \"extern \")\n> -\tstring(JOIN \";\\n\" decls ${decls})\n> -\n> -\tstring(APPEND clar_decls \"${decls};\\n\")\n> -\tstring(APPEND clar_cbs\n> -\t\t\"static const struct clar_func _clar_cb_${suite}[] = {\\n\"\n> -\t\t${cbs}\n> -\t\t\"};\\n\")\n> -\tstring(APPEND clar_suites\n> -\t\t\"    {\\n\"\n> -\t\t\"        \\\"${suite}\\\",\\n\"\n> -\t\t\"        { NULL, NULL },\\n\"\n> -\t\t\"        { NULL, NULL },\\n\"\n> -\t\t\"        _clar_cb_${suite}, ${decls_count}, 1\\n\"\n> -\t\t\"    },\\n\")\n> -\tmath(EXPR clar_cbs_count \"${clar_cbs_count}+${decls_count}\")\n> -endforeach()\n> -string(APPEND clar_suites\n> -\t\"};\\n\"\n> -\t\"static const size_t _clar_suite_count = ${clar_suites_count};\\n\"\n> -\t\"static const size_t _clar_callback_count = ${clar_cbs_count};\\n\")\n> -file(WRITE \"${CMAKE_BINARY_DIR}/t/unit-tests/clar-decls.h\" \"${clar_decls}\")\n> -file(WRITE \"${CMAKE_BINARY_DIR}/t/unit-tests/clar.suite\" \"${clar_decls}\" \"${clar_cbs}\" \"${clar_suites}\")\n> -\n>  list(TRANSFORM clar_test_SUITES PREPEND \"${CMAKE_SOURCE_DIR}/t/unit-tests/\")\n>  list(TRANSFORM clar_test_SUITES APPEND \".c\")\n> -add_library(unit-tests-lib ${clar_test_SUITES} \"${CMAKE_SOURCE_DIR}/t/unit-tests/clar/clar.c\")\n> +add_custom_command(OUTPUT \"${CMAKE_BINARY_DIR}/t/unit-tests/clar-decls.h\"\n> +\tCOMMAND ${CMAKE_SOURCE_DIR}/t/unit-tests/generate-clar-decls.sh \"${CMAKE_BINARY_DIR}/t/unit-tests/clar-decls.h\" ${clar_test_SUITES}\n> +\tDEPENDS ${CMAKE_SOURCE_DIR}/t/unit-tests/generate-clar-decls.sh ${clar_test_SUITES})\n> +add_custom_command(OUTPUT \"${CMAKE_BINARY_DIR}/t/unit-tests/clar.suite\"\n> +\tCOMMAND awk -f \"${CMAKE_SOURCE_DIR}/t/unit-tests/clar-generate.awk\" \"${CMAKE_BINARY_DIR}/t/unit-tests/clar-decls.h\" > \"${CMAKE_BINARY_DIR}/t/unit-tests/clar.suite\"\n> +\tDEPENDS \"${CMAKE_SOURCE_DIR}/t/unit-tests/clar-generate.awk\" \"${CMAKE_BINARY_DIR}/t/unit-tests/clar-decls.h\")\n> +\n> +add_library(unit-tests-lib ${clar_test_SUITES}\n> +\t\"${CMAKE_SOURCE_DIR}/t/unit-tests/clar/clar.c\"\n> +\t\"${CMAKE_BINARY_DIR}/t/unit-tests/clar-decls.h\"\n> +\t\"${CMAKE_BINARY_DIR}/t/unit-tests/clar.suite\"\n> +)\n>  target_include_directories(unit-tests-lib PUBLIC \"${CMAKE_BINARY_DIR}/t/unit-tests\")\n>  add_executable(unit-tests \"${CMAKE_SOURCE_DIR}/t/unit-tests/unit-test.c\")\n>  target_link_libraries(unit-tests unit-tests-lib common-main)\n> --\n> 2.47.0.72.gef8ce8f3d4.dirty\n>\n>\n"},{"id":"506708","messageId":"829fe630-e46a-4a3a-82dd-4e5feedd190c@gmail.com","threadId":"62322","inReplyTo":"3b2cb360-297a-915c-ae27-c45f38fa49b9@gmx.de","subject":"Re: [PATCH v2 5/5] cmake: set up proper dependencies for generated clar headers","fromName":"Phillip Wood","fromEmail":"phillip.wood123@gmail.com","sentAt":"2024-11-06T10:59:08Z","receivedAt":"2024-11-06T10:59:10Z","isPatch":true,"sender":{"key":"phillip.wood@dunelm.org.uk","avatar":null},"body":"Hi Johannes\n\nOn 05/11/2024 19:55, Johannes Schindelin wrote:\n> Hi Patrick,\n> \n> On Mon, 21 Oct 2024, Patrick Steinhardt wrote:\n> \n>> The auto-generated headers used by clar are written at configure time\n>> and thus do not get regenerated automatically. Refactor the build\n>> recipes such that we use custom commands instead, which also has the\n>> benefit that we can reuse the same infrastructure as our Makefile.\n> \n> For the record: I did not use a shell script to generate the header for a\n> specific reason: Unix shell scripts are not native to Windows. Therefore\n> they cannot in general be run on Windows, however that was precisely the\n> idea for the CMake definition: to be run on a vanilla Windows with Visual\n> Studio installed.\n> \n> Sadly, even Git's CI definition sets things up in a way that Git for\n> Windows' Bash can be used in the CMake definition, but in the intended use\n> case (opening a checkout of git/git in Visual Studio without any further\n> tools required) won't have a usable Bash.\n> \n> Therefore I am unsure whether this patch is desirable.\n\nCMakeLists.txt tries to find sh.exe from git-for-windows and errors out \nif it cannot be found. It then uses that shell to run a number of \nscripts. Perhaps we should do the same in this patch? It would certainly \nbe a worthwhile improvement to regenerate this file at build time if the \nsource has changed.\n\nBest Wishes\n\nPhillip\n\n> Ciao,\n> Johannes\n> \n>>\n>> Signed-off-by: Patrick Steinhardt <ps@pks.im>\n>> ---\n>>   contrib/buildsystems/CMakeLists.txt | 50 +++++++----------------------\n>>   1 file changed, 12 insertions(+), 38 deletions(-)\n>>\n>> diff --git a/contrib/buildsystems/CMakeLists.txt b/contrib/buildsystems/CMakeLists.txt\n>> index 093852ad9d6..9f80ab92656 100644\n>> --- a/contrib/buildsystems/CMakeLists.txt\n>> +++ b/contrib/buildsystems/CMakeLists.txt\n>> @@ -1002,46 +1002,20 @@ foreach(unit_test ${unit_test_PROGRAMS})\n>>   endforeach()\n>>\n>>   parse_makefile_for_scripts(clar_test_SUITES \"CLAR_TEST_SUITES\" \"\")\n>> -\n>> -set(clar_decls \"\")\n>> -set(clar_cbs \"\")\n>> -set(clar_cbs_count 0)\n>> -set(clar_suites \"static struct clar_suite _clar_suites[] = {\\n\")\n>> -list(LENGTH clar_test_SUITES clar_suites_count)\n>> -foreach(suite ${clar_test_SUITES})\n>> -\tfile(STRINGS \"${CMAKE_SOURCE_DIR}/t/unit-tests/${suite}.c\" decls\n>> -\t\tREGEX \"^void test_${suite}__[a-zA-Z_0-9][a-zA-Z_0-9]*\\\\(void\\\\)$\")\n>> -\n>> -\tlist(LENGTH decls decls_count)\n>> -\tstring(REGEX REPLACE \"void (test_${suite}__([a-zA-Z_0-9]*))\\\\(void\\\\)\" \"    { \\\"\\\\2\\\", &\\\\1 },\\n\" cbs ${decls})\n>> -\tstring(JOIN \"\" cbs ${cbs})\n>> -\tlist(TRANSFORM decls PREPEND \"extern \")\n>> -\tstring(JOIN \";\\n\" decls ${decls})\n>> -\n>> -\tstring(APPEND clar_decls \"${decls};\\n\")\n>> -\tstring(APPEND clar_cbs\n>> -\t\t\"static const struct clar_func _clar_cb_${suite}[] = {\\n\"\n>> -\t\t${cbs}\n>> -\t\t\"};\\n\")\n>> -\tstring(APPEND clar_suites\n>> -\t\t\"    {\\n\"\n>> -\t\t\"        \\\"${suite}\\\",\\n\"\n>> -\t\t\"        { NULL, NULL },\\n\"\n>> -\t\t\"        { NULL, NULL },\\n\"\n>> -\t\t\"        _clar_cb_${suite}, ${decls_count}, 1\\n\"\n>> -\t\t\"    },\\n\")\n>> -\tmath(EXPR clar_cbs_count \"${clar_cbs_count}+${decls_count}\")\n>> -endforeach()\n>> -string(APPEND clar_suites\n>> -\t\"};\\n\"\n>> -\t\"static const size_t _clar_suite_count = ${clar_suites_count};\\n\"\n>> -\t\"static const size_t _clar_callback_count = ${clar_cbs_count};\\n\")\n>> -file(WRITE \"${CMAKE_BINARY_DIR}/t/unit-tests/clar-decls.h\" \"${clar_decls}\")\n>> -file(WRITE \"${CMAKE_BINARY_DIR}/t/unit-tests/clar.suite\" \"${clar_decls}\" \"${clar_cbs}\" \"${clar_suites}\")\n>> -\n>>   list(TRANSFORM clar_test_SUITES PREPEND \"${CMAKE_SOURCE_DIR}/t/unit-tests/\")\n>>   list(TRANSFORM clar_test_SUITES APPEND \".c\")\n>> -add_library(unit-tests-lib ${clar_test_SUITES} \"${CMAKE_SOURCE_DIR}/t/unit-tests/clar/clar.c\")\n>> +add_custom_command(OUTPUT \"${CMAKE_BINARY_DIR}/t/unit-tests/clar-decls.h\"\n>> +\tCOMMAND ${CMAKE_SOURCE_DIR}/t/unit-tests/generate-clar-decls.sh \"${CMAKE_BINARY_DIR}/t/unit-tests/clar-decls.h\" ${clar_test_SUITES}\n>> +\tDEPENDS ${CMAKE_SOURCE_DIR}/t/unit-tests/generate-clar-decls.sh ${clar_test_SUITES})\n>> +add_custom_command(OUTPUT \"${CMAKE_BINARY_DIR}/t/unit-tests/clar.suite\"\n>> +\tCOMMAND awk -f \"${CMAKE_SOURCE_DIR}/t/unit-tests/clar-generate.awk\" \"${CMAKE_BINARY_DIR}/t/unit-tests/clar-decls.h\" > \"${CMAKE_BINARY_DIR}/t/unit-tests/clar.suite\"\n>> +\tDEPENDS \"${CMAKE_SOURCE_DIR}/t/unit-tests/clar-generate.awk\" \"${CMAKE_BINARY_DIR}/t/unit-tests/clar-decls.h\")\n>> +\n>> +add_library(unit-tests-lib ${clar_test_SUITES}\n>> +\t\"${CMAKE_SOURCE_DIR}/t/unit-tests/clar/clar.c\"\n>> +\t\"${CMAKE_BINARY_DIR}/t/unit-tests/clar-decls.h\"\n>> +\t\"${CMAKE_BINARY_DIR}/t/unit-tests/clar.suite\"\n>> +)\n>>   target_include_directories(unit-tests-lib PUBLIC \"${CMAKE_BINARY_DIR}/t/unit-tests\")\n>>   add_executable(unit-tests \"${CMAKE_SOURCE_DIR}/t/unit-tests/unit-test.c\")\n>>   target_link_libraries(unit-tests unit-tests-lib common-main)\n>> --\n>> 2.47.0.72.gef8ce8f3d4.dirty\n>>\n>>\n> \n\n"},{"id":"506855","messageId":"Zy4K_rcyGlwv64JZ@pks.im","threadId":"62322","inReplyTo":"829fe630-e46a-4a3a-82dd-4e5feedd190c@gmail.com","subject":"Re: [PATCH v2 5/5] cmake: set up proper dependencies for generated clar headers","fromName":"Patrick Steinhardt","fromEmail":"ps@pks.im","sentAt":"2024-11-08T12:59:05Z","receivedAt":"2024-11-08T12:59:18Z","isPatch":true,"sender":{"key":"ps@pks.im","avatar":"https://avatars.githubusercontent.com/u/4056630?v=4"},"body":"On Wed, Nov 06, 2024 at 10:59:08AM +0000, Phillip Wood wrote:\n> Hi Johannes\n> \n> On 05/11/2024 19:55, Johannes Schindelin wrote:\n> > Hi Patrick,\n> > \n> > On Mon, 21 Oct 2024, Patrick Steinhardt wrote:\n> > \n> > > The auto-generated headers used by clar are written at configure time\n> > > and thus do not get regenerated automatically. Refactor the build\n> > > recipes such that we use custom commands instead, which also has the\n> > > benefit that we can reuse the same infrastructure as our Makefile.\n> > \n> > For the record: I did not use a shell script to generate the header for a\n> > specific reason: Unix shell scripts are not native to Windows. Therefore\n> > they cannot in general be run on Windows, however that was precisely the\n> > idea for the CMake definition: to be run on a vanilla Windows with Visual\n> > Studio installed.\n> > \n> > Sadly, even Git's CI definition sets things up in a way that Git for\n> > Windows' Bash can be used in the CMake definition, but in the intended use\n> > case (opening a checkout of git/git in Visual Studio without any further\n> > tools required) won't have a usable Bash.\n> > \n> > Therefore I am unsure whether this patch is desirable.\n> \n> CMakeLists.txt tries to find sh.exe from git-for-windows and errors out if\n> it cannot be found. It then uses that shell to run a number of scripts.\n> Perhaps we should do the same in this patch? It would certainly be a\n> worthwhile improvement to regenerate this file at build time if the source\n> has changed.\n\nYeah, I think this solution makes most sense. I'll send a patch in a bit\nto address this.\n\nThanks, both of you!\n\nPatrick\n"}]}