{"thread":{"id":"63129","subject":"[PATCH 00/12] miscellaneous build mods (part 1)","startedAt":"2025-03-15T02:49:13Z","lastAt":"2025-04-17T22:06:55Z","messageCount":51,"participants":["Ramsay Jones","Patrick Steinhardt","Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":12},"messages":[{"id":"514342","messageId":"1c04882b-e518-4272-bd18-ab918774e424@ramsayjones.plus.com","threadId":"63129","inReplyTo":null,"subject":"[PATCH 00/12] miscellaneous build mods (part 1)","fromName":"Ramsay Jones","fromEmail":"ramsay@ramsayjones.plus.com","sentAt":"2025-03-15T02:46:01Z","receivedAt":"2025-03-15T02:49:13Z","isPatch":true,"sender":{"key":"ramsay@ramsayjones.plus.com","avatar":"https://avatars.githubusercontent.com/u/33702710?v=4"},"body":"\nThis series contains some miscellaneous changes to the make, meson and\nautoconf build systems. These are only the patches I have managed to\nwrite a commit message for; I have some others with no commit message,\nsome need more testing and others are yet to be written. (So, there will\nbe a 'part #2' series later... :) ).\n\n(I have notes from a couple of months ago - as an example, I have a note\nthat the meson build incorrectly sets ETC_GITATTRIBUTES and ETC_GITCONFIG\nto e.g. '/etc/gitattributes' rather than 'etc/gitattributes').\n\nThis series is based on the master branch at commit 683c54c999 (\"Git 2.49\",\n2025-03-14).\n\nAs a simple means for comparing the build products, we can compare the\nsymbols exported by git. So, starting at current master:\n\n  $ git checkout master\n  Switched to branch 'master'\n  Your branch is up-to-date with 'origin/master'.\n  $ git describe\n  v2.49.0\n  $ \n\n  $ make >out 2>&1\n  $ \n\n  $ meson setup build/\n  The Meson build system\n  ...\n  Found ninja-1.11.1 at /usr/bin/ninja\n  $ \n\n  $ cd build\n  $ meson compile\n  INFO: autodetecting backend as ninja\n  INFO: calculating backend command to run: /usr/bin/ninja\n  [661/661] Copying file contrib/completion/git-completion.zsh\n  $ cd ..\n  $ \n\n  $ rm *.syms\n  $ ./syms.pl git >git.syms 2>/dev/null\n  $ ./syms.pl build/git >mgit.syms 2>/dev/null\n  $ \n\n  $ diff git.syms mgit.syms\n  88a89\n  > U -- arc4random_buf@GLIBC_2.36\n  98a100,101\n  > U -- atoi@GLIBC_2.2.5\n  > U -- atol@GLIBC_2.2.5\n  195a199\n  > U -- bsearch@GLIBC_2.2.5\n  586,587d589\n  < U -- dcgettext@GLIBC_2.2.5\n  < U -- dcngettext@GLIBC_2.2.5\n  746,747c748,749\n  < B -- __environ@GLIBC_2.2.5\n  < V -- environ@GLIBC_2.2.5\n  ---\n  > U -- __environ@GLIBC_2.2.5\n  > U -- environ@GLIBC_2.2.5\n  909c911\n  < U -- __fprintf_chk@GLIBC_2.3.4\n  ---\n  > U -- fprintf@GLIBC_2.2.5\n  914d915\n  < U -- __fread_chk@GLIBC_2.7\n  1007c1008\n  < U -- getc@GLIBC_2.2.5\n  ---\n  > U -- getchar@GLIBC_2.2.5\n  1018a1020\n  > U -- getc_unlocked@GLIBC_2.2.5\n  1107a1110\n  > U -- gettext@GLIBC_2.2.5\n  1253d1255\n  < T -- gitstrlcpy\n  1355a1358\n  > U -- htons@GLIBC_2.2.5\n  1666d1668\n  < U -- __memcpy_chk@GLIBC_2.3.4\n  1673d1674\n  < U -- __memmove_chk@GLIBC_2.3.4\n  1684d1684\n  < U -- __memset_chk@GLIBC_2.3.4\n  1737a1738\n  > U -- ngettext@GLIBC_2.2.5\n  1759a1761\n  > U -- ntohs@GLIBC_2.2.5\n  1819d1820\n  < U -- __open64_2@GLIBC_2.7\n  1988a1990,2007\n  > U -- pcre2_code_free_8\n  > U -- pcre2_compile_8\n  > U -- pcre2_compile_context_create_8\n  > U -- pcre2_compile_context_free_8\n  > U -- pcre2_config_8\n  > U -- pcre2_general_context_create_8\n  > U -- pcre2_general_context_free_8\n  > U -- pcre2_get_error_message_8\n  > U -- pcre2_get_ovector_pointer_8\n  > U -- pcre2_jit_compile_8\n  > U -- pcre2_jit_match_8\n  > U -- pcre2_maketables_8\n  > U -- pcre2_maketables_free_8\n  > U -- pcre2_match_8\n  > U -- pcre2_match_data_create_from_pattern_8\n  > U -- pcre2_match_data_free_8\n  > U -- pcre2_pattern_info_8\n  > U -- pcre2_set_character_tables_8\n  2045c2064\n  < U -- __printf_chk@GLIBC_2.3.4\n  ---\n  > U -- printf@GLIBC_2.2.5\n  2080a2100\n  > U -- pthread_equal@GLIBC_2.2.5\n  2767c2787\n  < U -- __snprintf_chk@GLIBC_2.3.4\n  ---\n  > U -- snprintf@GLIBC_2.2.5\n  2925a2946\n  > U -- strlcpy@GLIBC_2.38\n  3185d3205\n  < U -- __uflow@GLIBC_2.2.5\n  3289,3290c3309,3311\n  < U -- __vfprintf_chk@GLIBC_2.3.4\n  < U -- __vsnprintf_chk@GLIBC_2.3.4\n  ---\n  > U -- vfprintf@GLIBC_2.2.5\n  > U -- vprintf@GLIBC_2.2.5\n  > U -- vsnprintf@GLIBC_2.2.5\n  $ \n\nLooking at the above, you can see that quite a few differences relate to\nsymbols which differ due to the level of optimization during compilation.\nThis reflects, among other things, the different 'default' settings between\nthe Makefile and the meson build; e.g. prefix=$HOME vs. /usr/local, initial\nCFLAGS='-g -O2 -Wall' vs. '-g -O0 -Wall'. Also, note that the make build\ndoes not include the (optional) pcre2 library, even if it is installed on\nthe system.\n\n[On cygwin the diff is slightly different, but also contains more symbols,\nsuch as all symbols relating to the compat regex routines, clock_gettime,\ngetdelim, sysinfo and so on ... ;) ]\n\nIf we change the meson setup, thus:\n\n  $ meson setup --optimization=2 -Dprefix=$HOME -Dpcre2=disabled build/\n\nAfter we re-build and repeat the above symbol generation, we find:\n\n  $ diff git.syms mgit.syms\n  88a89\n  > U -- arc4random_buf@GLIBC_2.36\n  746,747c747,748\n  < B -- __environ@GLIBC_2.2.5\n  < V -- environ@GLIBC_2.2.5\n  ---\n  > U -- __environ@GLIBC_2.2.5\n  > U -- environ@GLIBC_2.2.5\n  1253d1253\n  < T -- gitstrlcpy\n  2925a2926\n  > U -- strlcpy@GLIBC_2.38\n  $ \n\nAfter applying these patches and adding settings to the config.mak file: \n\n  $ vim config.mak # add NO_STRLCPY and CSPRNG_METHOD\n  $ \n  $ cat config.mak\n  DEFAULT_TEST_TARGET=prove\n  GIT_PROVE_OPTS='--timer'\n  PYTHON_PATH=/usr/bin/python3\n  GIT_TEST_HTTPD=false\n  export GIT_TEST_HTTPD\n  #DEVELOPER=1\n  SPARSE_FLAGS += -D__STDC_NO_VLA__\n  NO_STRLCPY=\n  CSPRNG_METHOD=arc4random\n  $ \n\n[Note that I commented out DEVELOPER=1. I'm not entirely sure why I did\nthat. :) Maybe it was one less variable? ]\n\n  $ make >out 2>&1\n  $ \n\n  $ meson setup --optimization=2 -Dprefix=$HOME -Dpcre2=disabled build/\n  The Meson build system\n  ...\n    User defined options\n      optimization: 2\n      prefix      : /home/ramsay\n      pcre2       : disabled\n  \n  Found ninja-1.11.1 at /usr/bin/ninja\n  $ \n\n  $ cd build\n  $ meson compile\n  INFO: autodetecting backend as ninja\n  INFO: calculating backend command to run: /usr/bin/ninja\n  [661/661] Copying file contrib/completion/git-prompt.sh\n  $ cd ..\n  $ \n\n  $ rm *.syms\n  $ ./syms.pl git >git.syms 2>/dev/null\n  $ ./syms.pl build/git >mgit.syms 2>/dev/null\n  $ \n\n  $ diff git.syms mgit.syms\n  747,748c747,748\n  < B -- __environ@GLIBC_2.2.5\n  < V -- environ@GLIBC_2.2.5\n  ---\n  > U -- __environ@GLIBC_2.2.5\n  > U -- environ@GLIBC_2.2.5\n  $ \n \nOn cygwin, this diff is now empty. ;)\n\nThe above diff seems to imply a difference in the linking of main() and\nthe C library startup routines (or something similar). However, I happened\nto notice that the meson build included '-fPIC' in the build flags, so I\nthought it was worth a punt:\n\n  $ make CFLAGS='-g -O2 -Wall -fPIC' >out 2>&1\n\n[with the advent of ASLR, I thought -fPIC/-fPIE was the default anyway!]\n\n  $ diff git.syms mgit.syms\n  2809,2811c2809,2811\n  < U -- stderr@GLIBC_2.2.5\n  < U -- stdin@GLIBC_2.2.5\n  < U -- stdout@GLIBC_2.2.5\n  ---\n  > B -- stderr@GLIBC_2.2.5\n  > B -- stdin@GLIBC_2.2.5\n  > B -- stdout@GLIBC_2.2.5\n  $ \n\nHmm, so one step forward, one step back! (or is it 2 steps forward, 3 steps\nback? ;) ). So, something for another day.\n\nNote that both test suite runs ('make test' and 'meson test') pass all\ntests (excluding the http, cvs, svn, and p4 tests) on Linux. (I am still\nwaiting for the v2.49.0 test run to finish on cygwin! :( ).\n\nAlso, patches #5 and #12 only add/modify a comment, so they could be\ndropped, if people feel that they are not appropriate.\n\n[Just in case you want to reproduce the above, I have appended the syms.pl\nscript below.]\n\nATB,\nRamsay Jones\n\nRamsay Jones (12):\n  meson.build: remove -DCURL_DISABLE_TYPECHECK\n  Makefile: only set some BASIC_CFLAGS when RUNTIME_PREFIX is set\n  meson.build: only set build variables for non-default values\n  Makefile: remove NEEDS_LIBRT build variable\n  config.mak.uname: add a note about NO_STRLCPY for Linux\n  config.mak.uname: only set NO_REGEX on cygwin for v1.7\n  config.mak.uname: add HAVE_GETDELIM to the cygwin section\n  config.mak.uname: add clock_gettime() to the cygwin build\n  builtin/gc.c: correct RAM calculation when using sysinfo\n  config.mak.uname: add sysinfo() configuration for cygwin\n  config.mak.uname; add arc4random to the cygwin build\n  config.mak.uname: add a note about CSPRNG_METHOD for Linux\n\n Makefile         | 45 +++++++++++++++++++++++----------------------\n builtin/gc.c     |  9 +++++++--\n config.mak.uname | 16 ++++++++++++----\n configure.ac     |  8 ++++++++\n meson.build      | 14 ++++++++++----\n 5 files changed, 60 insertions(+), 32 deletions(-)\n\n-- \n2.49.0\n\n----------------- >8 ------------------ [syms.pl]\n#!/usr/bin/perl -w\n\nopen(I, \"-|\", qw(nm -g), $ARGV[0]) or die;\nwhile (<I>) {\n\tunless (/^[0-9a-f ]+ ([A-Z]) (\\S*)$/) {\n\t\tprint STDERR \"? $_\";\n\t\tnext;\n\t}\n\tnext if ($2 =~ /^\\.refptr\\./);\n\tprint \"$1 -- $2\\n\";\n}\nclose I;\n\n"},{"id":"515722","messageId":"8c76671f0e7dbfe2fba6a57b80bae974e75a7522.1743859985.git.ramsay@ramsayjones.plus.com","threadId":"63129","inReplyTo":"cover.1743859985.git.ramsay@ramsayjones.plus.com","subject":"[PATCH v2 06/13] config.mak.uname: add a note about NO_STRLCPY for Linux","fromName":"Ramsay Jones","fromEmail":"ramsay@ramsayjones.plus.com","sentAt":"2025-04-06T19:38:32Z","receivedAt":"2025-04-06T19:39:45Z","isPatch":true,"sender":{"key":"ramsay@ramsayjones.plus.com","avatar":"https://avatars.githubusercontent.com/u/33702710?v=4"},"body":"Commit 817151e61a (\"Rename safe_strncpy() to strlcpy().\", 2006-06-24)\nadded the NO_STRLCPY make variable to allow the conditional use of\nthe gitstrlcpy() compat function on those platforms which didn't\nprovide the 'standard' strlcpy() function.\n\nRecently, in the summer of 2023, the strlcpy() and strlcat() functions\nwere added to the glibc library (v2.38), so some of the more up-to-date\nLinux distributions no longer need to set NO_STRLCPY. For example, both\nUbuntu 24.04 LTS and RHEL 10 beta have glibc v2.39. However, several\ndistributions, which are still within their support window, have an\nearlier version and must still use the 'compat' version of strlcpy().\n\nIf the meson or autoconf build systems are used on newer platforms, then\nthey will be configured to to use strlcpy() from glibc, whereas the make\nbuild will always choose the 'compat' function instead. Add a note to\nthe config.mak.uname file, in the Linux section, to prompt make users to\noverride NO_STRLCPY in the config.mak file, if appropriate.\n\nSigned-off-by: Ramsay Jones <ramsay@ramsayjones.plus.com>\n---\n config.mak.uname | 1 +\n 1 file changed, 1 insertion(+)\n\ndiff --git a/config.mak.uname b/config.mak.uname\nindex 88007c4f13..ae6ba15586 100644\n--- a/config.mak.uname\n+++ b/config.mak.uname\n@@ -48,6 +48,7 @@ ifeq ($(uname_S),OSF1)\n endif\n ifeq ($(uname_S),Linux)\n \tHAVE_ALLOCA_H = YesPlease\n+\t# override in config.mak if you have glibc >= 2.38\n \tNO_STRLCPY = YesPlease\n \tHAVE_PATHS_H = YesPlease\n \tLIBC_CONTAINS_LIBINTL = YesPlease\n-- \n2.49.0\n\n"},{"id":"515723","messageId":"324bb213426ffc9c1f9cd155de309bd0b63cdbc4.1743859985.git.ramsay@ramsayjones.plus.com","threadId":"63129","inReplyTo":"cover.1743859985.git.ramsay@ramsayjones.plus.com","subject":"[PATCH v2 07/13] config.mak.uname: only set NO_REGEX on cygwin for v1.7","fromName":"Ramsay Jones","fromEmail":"ramsay@ramsayjones.plus.com","sentAt":"2025-04-06T19:38:33Z","receivedAt":"2025-04-06T19:39:49Z","isPatch":true,"sender":{"key":"ramsay@ramsayjones.plus.com","avatar":"https://avatars.githubusercontent.com/u/33702710?v=4"},"body":"Commit 92f63d2b05 (\"Cygwin 1.7 needs compat/regex\", 2013-07-19) set\nthe NO_REGEX build variable because the platform regex library failed\nsome of the tests (t4018 and t4034), which passed just fine with the\ncompat library.\n\nAfter some time (maybe a year or two), the platform library had been\nupdated (with an import from FreeBSD, I believe) and now passed the full\ntest-suite. This would be about the time of the v1.7 -> v2.0 transition\nin 2015. I had a patch ready to send, but just didn't get around to\nsubmitting it to the list. At some point in the interim, the official\ncygwin git package used the autoconf build system, which sets the\nNO_REGEX variable to use the platform regex library functions. The new\nmeson build system does likewise.\n\nThe cygwin platform regex library, in addition to now passing the tests\nwhich formerly failed, now passes an 'test_expect_failure' test in the\nt7815-grep-binary test file. In particular, test #12 'git grep .fi a'\nwhich determines that the regex pattern '.' matches a NUL character.\nThe commit f96e56733a (\"grep: use REG_STARTEND for all matching if\navailable\", 2010-05-22) added the test in question, but it does not\ngive any indication as to why the test was framed as an expected fail,\nrather than a 'positive' test that the 'git grep' command fails to\nmatch a NUL. Note that the previous test #11 was also originally\nmarked in that commit as a 'test_expect_failure', but was flipped to\nan 'success' test in commit 7e36de5859 (\"t/t7008-grep-binary.sh: un-TODO\na test that needs REG_STARTEND\", 2010-08-17).\n\nIn order to produce the same NO_REGEX configuration from autoconf, meson\nand make, modify config.mak.uname to only set NO_REGEX for cygwin v1.7.\nIn addition, skip test t7815.12 on cygwin, by adding the !CYGWIN pre-\nrequisite to the test header, which (among other things) removes an\n'...; please update test(s)' comment.\n\nSigned-off-by: Ramsay Jones <ramsay@ramsayjones.plus.com>\n---\n config.mak.uname       | 4 +++-\n t/t7815-grep-binary.sh | 2 +-\n 2 files changed, 4 insertions(+), 2 deletions(-)\n\ndiff --git a/config.mak.uname b/config.mak.uname\nindex ae6ba15586..b6adce0bc4 100644\n--- a/config.mak.uname\n+++ b/config.mak.uname\n@@ -245,7 +245,9 @@ ifeq ($(uname_O),Cygwin)\n \t\t# Try commenting this out if you suspect MMAP is more efficient\n \t\tNO_MMAP = YesPlease\n         else\n-\t\tNO_REGEX = UnfortunatelyYes\n+                ifeq ($(shell expr \"$(uname_R)\" : '1\\.7\\.'),4)\n+\t\t        NO_REGEX = UnfortunatelyYes\n+                endif\n         endif\n \tHAVE_DEV_TTY = YesPlease\n \tHAVE_ALLOCA_H = YesPlease\ndiff --git a/t/t7815-grep-binary.sh b/t/t7815-grep-binary.sh\nindex 90ebb64f46..b7000dfa32 100755\n--- a/t/t7815-grep-binary.sh\n+++ b/t/t7815-grep-binary.sh\n@@ -63,7 +63,7 @@ test_expect_success 'git grep ile a' '\n \tgit grep ile a\n '\n \n-test_expect_failure 'git grep .fi a' '\n+test_expect_failure !CYGWIN 'git grep .fi a' '\n \tgit grep .fi a\n '\n \n-- \n2.49.0\n\n"},{"id":"515724","messageId":"0a3ce7e80abe4dd83ac5e6fe1579e8e559406acf.1743859985.git.ramsay@ramsayjones.plus.com","threadId":"63129","inReplyTo":"cover.1743859985.git.ramsay@ramsayjones.plus.com","subject":"[PATCH v2 08/13] config.mak.uname: add HAVE_GETDELIM to the cygwin section","fromName":"Ramsay Jones","fromEmail":"ramsay@ramsayjones.plus.com","sentAt":"2025-04-06T19:38:34Z","receivedAt":"2025-04-06T19:39:52Z","isPatch":true,"sender":{"key":"ramsay@ramsayjones.plus.com","avatar":"https://avatars.githubusercontent.com/u/33702710?v=4"},"body":"Cygwin has provided the getdelim() function as far back as (at least)\n2011. The autoconf and meson builds enable the use of this symbol.\nIn order to have the same configuration for autoconf, meson and make,\nenable the HAVE_GETDELIM build variable in the cygwin section of the\nconfig.mak.uname file.\n\nSigned-off-by: Ramsay Jones <ramsay@ramsayjones.plus.com>\n---\n config.mak.uname | 1 +\n 1 file changed, 1 insertion(+)\n\ndiff --git a/config.mak.uname b/config.mak.uname\nindex b6adce0bc4..1b3ba8a341 100644\n--- a/config.mak.uname\n+++ b/config.mak.uname\n@@ -250,6 +250,7 @@ ifeq ($(uname_O),Cygwin)\n                 endif\n         endif\n \tHAVE_DEV_TTY = YesPlease\n+\tHAVE_GETDELIM = YesPlease\n \tHAVE_ALLOCA_H = YesPlease\n \tNEEDS_LIBICONV = YesPlease\n \tNO_FAST_WORKING_DIRECTORY = UnfortunatelyYes\n-- \n2.49.0\n\n"},{"id":"515725","messageId":"3bd6e40cd23b07b86b5db146a00bfa01458f2e04.1743859985.git.ramsay@ramsayjones.plus.com","threadId":"63129","inReplyTo":"cover.1743859985.git.ramsay@ramsayjones.plus.com","subject":"[PATCH v2 09/13] config.mak.uname: add clock_gettime() to the cygwin build","fromName":"Ramsay Jones","fromEmail":"ramsay@ramsayjones.plus.com","sentAt":"2025-04-06T19:38:35Z","receivedAt":"2025-04-06T19:39:56Z","isPatch":true,"sender":{"key":"ramsay@ramsayjones.plus.com","avatar":"https://avatars.githubusercontent.com/u/33702710?v=4"},"body":"Cygwin supports the clock_gettime() function, along with the associated\nCLOCK_MONOTONIC preprocessor symbol. The autoconf and meson builds both\nenable the use of those symbols. In order to have the same configuration\nfor the make builds, add the HAVE_CLOCK_GETTIME and HAVE_CLOCK_MONOTONIC\nbuild variables to the cygwin section of the config.mak.uname file.\n\nSigned-off-by: Ramsay Jones <ramsay@ramsayjones.plus.com>\n---\n config.mak.uname | 2 ++\n 1 file changed, 2 insertions(+)\n\ndiff --git a/config.mak.uname b/config.mak.uname\nindex 1b3ba8a341..942550fb9e 100644\n--- a/config.mak.uname\n+++ b/config.mak.uname\n@@ -251,6 +251,8 @@ ifeq ($(uname_O),Cygwin)\n         endif\n \tHAVE_DEV_TTY = YesPlease\n \tHAVE_GETDELIM = YesPlease\n+\tHAVE_CLOCK_GETTIME=YesPlease\n+\tHAVE_CLOCK_MONOTONIC=YesPlease\n \tHAVE_ALLOCA_H = YesPlease\n \tNEEDS_LIBICONV = YesPlease\n \tNO_FAST_WORKING_DIRECTORY = UnfortunatelyYes\n-- \n2.49.0\n\n"},{"id":"515726","messageId":"a2eb9ab117c9a7ea8723c166739b30243388ea77.1743859985.git.ramsay@ramsayjones.plus.com","threadId":"63129","inReplyTo":"cover.1743859985.git.ramsay@ramsayjones.plus.com","subject":"[PATCH v2 10/13] builtin/gc.c: correct RAM calculation when using sysinfo","fromName":"Ramsay Jones","fromEmail":"ramsay@ramsayjones.plus.com","sentAt":"2025-04-06T19:38:36Z","receivedAt":"2025-04-06T19:40:00Z","isPatch":true,"sender":{"key":"ramsay@ramsayjones.plus.com","avatar":"https://avatars.githubusercontent.com/u/33702710?v=4"},"body":"The man page for sysinfo(2) on Linux states that (from v2.3.48) the\nsizes of the memory and swap fields, of the returned structure, are\ngiven as multiples of 'mem_unit' bytes. In earlier versions (prior to\nv2.3.23 on i386 in particular), the 'mem_unit' field was not part of\nthe structure, and all sizes were measured in bytes. The man page does\nnot discuss the motivation for this change, but it is possible that the\nchange was intended for the, relatively rare, 32-bit platform with more\nthan 4GB of memory.\n\nThe total_ram() function makes the assumption that the 'totalram' field\nof the 'struct sysinfo' is measured in bytes, or alternatively that the\n'mem_unit' field is always equal to one. Having writen a program to call\nthe sysinfo() function and print the structure fields, it seems that, on\nLinux x84_64 and i686 anyway, the 'mem_unit' field is indeed set to one\n(note that the 32-bit system had only 2GB ram). However, cygwin also has\nan sysinfo() implementation, which gives the following values:\n\n  $ ./sysinfo\n  uptime:      21381\n  loads:       0, 0, 0\n  total ram:   2074637\n  free ram:    843237\n  shared ram:  0\n  buffer ram:  0\n  total swap:  327680\n  free swap:   306932\n  procs:       15\n  total high:  0\n  free high:   0\n  mem_unit:    4096\n\n  total ram: 8497713152\n  $\n\n[This laptop has 8GB ram, so a little bit seems to be missing. ;) ]\n\nModify the total_ram() function to allow for the possibility that the\nmemory size is not specified in bytes (ie 'mem_unit' is greater than\none).\n\nSigned-off-by: Ramsay Jones <ramsay@ramsayjones.plus.com>\n---\n builtin/gc.c | 9 +++++++--\n 1 file changed, 7 insertions(+), 2 deletions(-)\n\ndiff --git a/builtin/gc.c b/builtin/gc.c\nindex 99431fd467..cdcf1dc6e7 100644\n--- a/builtin/gc.c\n+++ b/builtin/gc.c\n@@ -373,8 +373,13 @@ static uint64_t total_ram(void)\n #if defined(HAVE_SYSINFO)\n \tstruct sysinfo si;\n \n-\tif (!sysinfo(&si))\n-\t\treturn si.totalram;\n+\tif (!sysinfo(&si)) {\n+\t\tuint64_t total = si.totalram;\n+\n+\t\tif (si.mem_unit > 1)\n+\t\t\ttotal *= (uint64_t)si.mem_unit;\n+\t\treturn total;\n+\t}\n #elif defined(HAVE_BSD_SYSCTL) && (defined(HW_MEMSIZE) || defined(HW_PHYSMEM))\n \tint64_t physical_memory;\n \tint mib[2];\n-- \n2.49.0\n\n"},{"id":"515727","messageId":"e45b9df3a43d0f862f1703a3af84c2a796e708f4.1743859985.git.ramsay@ramsayjones.plus.com","threadId":"63129","inReplyTo":"cover.1743859985.git.ramsay@ramsayjones.plus.com","subject":"[PATCH v2 11/13] config.mak.uname: add sysinfo() configuration for cygwin","fromName":"Ramsay Jones","fromEmail":"ramsay@ramsayjones.plus.com","sentAt":"2025-04-06T19:38:37Z","receivedAt":"2025-04-06T19:40:04Z","isPatch":true,"sender":{"key":"ramsay@ramsayjones.plus.com","avatar":"https://avatars.githubusercontent.com/u/33702710?v=4"},"body":"Although sysinfo() is a 'Linux only' function, cygwin provides an\nimplementation which appears to be functional. The assumption that\nthis function is Linux only is reflected in the way the HAVE_SYSINFO\nbuild variable is handled by the Makefile and config.mak.uname.\n\nRework the setting of HAVE_SYSINFO in the Linux section of the system\nspecific config file, along with the corresponding setting of the\nBASIC_CFLAGS in the Makefile. Add the setting of HAVE_SYSINFO to the\ncygwin section of 'config.mak.uname'. While here, add a test for the\nsysinfo() function to the autoconf build system.\n\nSigned-off-by: Ramsay Jones <ramsay@ramsayjones.plus.com>\n---\n Makefile         | 4 ++++\n config.mak.uname | 3 ++-\n configure.ac     | 8 ++++++++\n 3 files changed, 14 insertions(+), 1 deletion(-)\n\ndiff --git a/Makefile b/Makefile\nindex 8fa4d2664e..ff89f2b81f 100644\n--- a/Makefile\n+++ b/Makefile\n@@ -2168,6 +2168,10 @@ ifdef HAVE_SYNC_FILE_RANGE\n \tBASIC_CFLAGS += -DHAVE_SYNC_FILE_RANGE\n endif\n \n+ifdef HAVE_SYSINFO\n+\tBASIC_CFLAGS += -DHAVE_SYSINFO\n+endif\n+\n ifdef HAVE_BSD_SYSCTL\n \tBASIC_CFLAGS += -DHAVE_BSD_SYSCTL\n endif\ndiff --git a/config.mak.uname b/config.mak.uname\nindex 942550fb9e..0e29341056 100644\n--- a/config.mak.uname\n+++ b/config.mak.uname\n@@ -58,7 +58,7 @@ ifeq ($(uname_S),Linux)\n \tHAVE_SYNC_FILE_RANGE = YesPlease\n \tHAVE_GETDELIM = YesPlease\n \tFREAD_READS_DIRECTORIES = UnfortunatelyYes\n-\tBASIC_CFLAGS += -DHAVE_SYSINFO\n+\tHAVE_SYSINFO = YesPlease\n \tPROCFS_EXECUTABLE_PATH = /proc/self/exe\n \tHAVE_PLATFORM_PROCINFO = YesPlease\n \tCOMPAT_OBJS += compat/linux/procinfo.o\n@@ -253,6 +253,7 @@ ifeq ($(uname_O),Cygwin)\n \tHAVE_GETDELIM = YesPlease\n \tHAVE_CLOCK_GETTIME=YesPlease\n \tHAVE_CLOCK_MONOTONIC=YesPlease\n+\tHAVE_SYSINFO = YesPlease\n \tHAVE_ALLOCA_H = YesPlease\n \tNEEDS_LIBICONV = YesPlease\n \tNO_FAST_WORKING_DIRECTORY = UnfortunatelyYes\ndiff --git a/configure.ac b/configure.ac\nindex 5923edc44a..d7e0503f1e 100644\n--- a/configure.ac\n+++ b/configure.ac\n@@ -1066,6 +1066,14 @@ AC_CHECK_LIB([iconv], [locale_charset],\n        [AC_CHECK_LIB([charset], [locale_charset],\n                      [CHARSET_LIB=-lcharset])])\n GIT_CONF_SUBST([CHARSET_LIB])\n+\n+#\n+# Define HAVE_SYSINFO=YesPlease if sysinfo is available.\n+GIT_CHECK_FUNC(sysinfo,\n+\t[HAVE_SYSINFO=YesPlease],\n+\t[HAVE_SYSINFO=])\n+GIT_CONF_SUBST([HAVE_SYSINFO])\n+\n #\n # Define HAVE_CLOCK_GETTIME=YesPlease if clock_gettime is available.\n GIT_CHECK_FUNC(clock_gettime,\n-- \n2.49.0\n\n"},{"id":"515728","messageId":"422d4b2571c718dd605dd0d924252c618b9e7e73.1743859985.git.ramsay@ramsayjones.plus.com","threadId":"63129","inReplyTo":"cover.1743859985.git.ramsay@ramsayjones.plus.com","subject":"[PATCH v2 12/13] config.mak.uname: add arc4random to the cygwin build","fromName":"Ramsay Jones","fromEmail":"ramsay@ramsayjones.plus.com","sentAt":"2025-04-06T19:38:38Z","receivedAt":"2025-04-06T19:40:08Z","isPatch":true,"sender":{"key":"ramsay@ramsayjones.plus.com","avatar":"https://avatars.githubusercontent.com/u/33702710?v=4"},"body":"The arc4random_buf() function has been available in cygwin since\nabout 2016 (somewhere in the v2.x branch). Set the CSPRNG_METHOD\nbuild variable to 'arc4random', in the cygwin section, to enable\nthe use of this cryptographically-secure pseudorandom number\nfunction. Note that the autoconf and new meson builds also enable\nthis function.\n\nSigned-off-by: Ramsay Jones <ramsay@ramsayjones.plus.com>\n---\n config.mak.uname | 1 +\n 1 file changed, 1 insertion(+)\n\ndiff --git a/config.mak.uname b/config.mak.uname\nindex 0e29341056..4f6770a5f4 100644\n--- a/config.mak.uname\n+++ b/config.mak.uname\n@@ -254,6 +254,7 @@ ifeq ($(uname_O),Cygwin)\n \tHAVE_CLOCK_GETTIME=YesPlease\n \tHAVE_CLOCK_MONOTONIC=YesPlease\n \tHAVE_SYSINFO = YesPlease\n+\tCSPRNG_METHOD = arc4random\n \tHAVE_ALLOCA_H = YesPlease\n \tNEEDS_LIBICONV = YesPlease\n \tNO_FAST_WORKING_DIRECTORY = UnfortunatelyYes\n-- \n2.49.0\n\n"},{"id":"515729","messageId":"7b133af24b472e343a19ddc0e89c31da80ade098.1743859985.git.ramsay@ramsayjones.plus.com","threadId":"63129","inReplyTo":"cover.1743859985.git.ramsay@ramsayjones.plus.com","subject":"[PATCH v2 13/13] config.mak.uname: set CSPRNG_METHOD to getrandom on Linux","fromName":"Ramsay Jones","fromEmail":"ramsay@ramsayjones.plus.com","sentAt":"2025-04-06T19:38:39Z","receivedAt":"2025-04-06T19:40:11Z","isPatch":true,"sender":{"key":"ramsay@ramsayjones.plus.com","avatar":"https://avatars.githubusercontent.com/u/33702710?v=4"},"body":"Commit 05cd988dce (\"wrapper: add a helper to generate numbers from a\nCSPRNG\", 2022-01-17) added a csprng_bytes() function which used one\nof several interfaces to provide a source of cryptographically secure\npseudorandom numbers. The CSPRNG_METHOD make variable was provided to\ndetermine the choice of available 'backends' for the source of random\nbytes.\n\nCommit 05cd988dce did not set CSPRNG_METHOD in the Linux section of\nthe config.mak.uname file, so it defaults to using '/dev/urandom' as\nthe source of random bytes. The 'backend' values which could be used\non Linux are 'arc4random', 'getrandom' or 'getentropy' ('openssl' is\nan option, but seems to be discouraged).\n\nThe arc4random routines (ar4random_buf() is the one actually used) were\nadded to glibc in version 2.36, while both getrandom() and getentropy()\nwere included in 2.25. So, some of the more up-to-date distributions of\nLinux (eg Debian 12, Ubuntu 24.04) would be able to use the 'arc4random'\nsetting. All currently supported distributions have glibc 2.25 or later\n(RHEL 8 has v2.28) and, therefore, have support for the 'getrandom' and\n'getentropy' settings.\n\nThe arc4random routines on the *BSDs (along with cygwin) implement the\nChaCha20 stream cipher algorithm (see RFC8439) in userspace, rather than\nas a system call, and are thus somewhat faster (having avoided a context\nswitch to the kernel). In contrast, on Linux all three functions are\nsimple wrappers around the same kernel CSPRNG syscall.\n\nIf the meson build system is used on a newer platform, then they will be\nconfigured to use 'arc4random', whereas the make build will currently\ndefault to using '/dev/urandom' on Linux. Since there is no advantage,\nin terms of performance, to the 'arc4random' setting, the 'getrandom'\nsetting should be preferred from an availability perspective. (Also, the\ncurrent uses of csprng_bytes() are not in any hot path).\n\nIn order to set an appropriate default, set the CSPRNG_METHOD build\nvariable to 'getrandom' in the Linux section of the 'config.mak.uname'\nfile.\n\nSigned-off-by: Ramsay Jones <ramsay@ramsayjones.plus.com>\n---\n config.mak.uname | 1 +\n 1 file changed, 1 insertion(+)\n\ndiff --git a/config.mak.uname b/config.mak.uname\nindex 4f6770a5f4..6ebe6dcf37 100644\n--- a/config.mak.uname\n+++ b/config.mak.uname\n@@ -50,6 +50,7 @@ ifeq ($(uname_S),Linux)\n \tHAVE_ALLOCA_H = YesPlease\n \t# override in config.mak if you have glibc >= 2.38\n \tNO_STRLCPY = YesPlease\n+\tCSPRNG_METHOD = getrandom\n \tHAVE_PATHS_H = YesPlease\n \tLIBC_CONTAINS_LIBINTL = YesPlease\n \tHAVE_DEV_TTY = YesPlease\n-- \n2.49.0\n\n"},{"id":"515730","messageId":"fe969deec0f8d9542bbb39cd7fb3df98240657f7.1743859985.git.ramsay@ramsayjones.plus.com","threadId":"63129","inReplyTo":"cover.1743859985.git.ramsay@ramsayjones.plus.com","subject":"[PATCH v2 01/13] meson.build: remove -DCURL_DISABLE_TYPECHECK","fromName":"Ramsay Jones","fromEmail":"ramsay@ramsayjones.plus.com","sentAt":"2025-04-06T19:38:27Z","receivedAt":"2025-04-06T19:42:14Z","isPatch":true,"sender":{"key":"ramsay@ramsayjones.plus.com","avatar":"https://avatars.githubusercontent.com/u/33702710?v=4"},"body":"Commit 9371322a60 (\"sparse: suppress some \\\"using sizeof on a function\\\"\nwarnings\", 2013-10-06) used target-specific variable assignments to add\n-DCURL_DISABLE_TYPECHECK to SPARSE_FLAGS for each of the files affected\nby the \"typecheck-gcc.h\" warnings. (http-push.c, http.c, http-walker.c\nand remote-curl.c).\n\nThese warnings are only issued by sparse, and not by gcc, so we do not\nwant to disable the 'type checking' for non-sparse targets. The meson\nbuild does not provide any sparse targets, so there is no need to use\nthe CURL_DISABLE_TYPECHECK preprocessor flag with the c compiler.\n\nIn order to re-enable the curl 'type checking' in the meson build, remove\nthe assignment of -DCURL_DISABLE_TYPECHECK to libgit_c_args.\n\nSigned-off-by: Ramsay Jones <ramsay@ramsayjones.plus.com>\n---\n meson.build | 1 -\n 1 file changed, 1 deletion(-)\n\ndiff --git a/meson.build b/meson.build\nindex efe2871c9d..88a29fd043 100644\n--- a/meson.build\n+++ b/meson.build\n@@ -966,7 +966,6 @@ if curl.found()\n   # Most executables don't have to link against libcurl, but we still need its\n   # include directories so that we can resolve LIBCURL_VERSION in \"help.c\".\n   libgit_dependencies += curl.partial_dependency(includes: true)\n-  libgit_c_args += '-DCURL_DISABLE_TYPECHECK'\n   build_options_config.set('NO_CURL', '')\n else\n   libgit_c_args += '-DNO_CURL'\n-- \n2.49.0\n\n"},{"id":"515731","messageId":"cover.1743859985.git.ramsay@ramsayjones.plus.com","threadId":"63129","inReplyTo":"1c04882b-e518-4272-bd18-ab918774e424@ramsayjones.plus.com","subject":"[PATCH v2 00/13] miscellaneous build mods (part 1)","fromName":"Ramsay Jones","fromEmail":"ramsay@ramsayjones.plus.com","sentAt":"2025-04-06T19:38:26Z","receivedAt":"2025-04-06T19:42:14Z","isPatch":true,"sender":{"key":"ramsay@ramsayjones.plus.com","avatar":"https://avatars.githubusercontent.com/u/33702710?v=4"},"body":"\nchanges in v2:\n--------------\n\n- patch #3 has been split into two (new patches #3,4). The motivation\n  for the original patch seems not to have been too obvious. The new\n  patch #3 combines the suppressing the -Defines for standard default\n  values for editor and pager, with the setting of the missing docs\n  attributes. The new patch #4 combines the suppressing of the -Define\n  for the default-help-format, with the overriding of the default value\n  on the windows platform.\n\n- patch #6 (new #7) updates the commit message along with skipping the\n  'failing' test #12 in t7815-grep-binary.sh on cygwin. (With the cygwin\n  platform regex library the '.' pattern matches a NUL character).\n\n- patch #11 (new #12) fixes a simple typo in the patch subject.\n\n- patch #12 (new #13) updates the commit message and makes a choice for\n  the default CSPRNG_METHOD on Linux; 'getrandom' as advised by Brian\n  here [0].\n\n[0] https://lore.kernel.org/git/Z9YbJFJjtXNYnTzk@tapette.crustytoothpaste.net/\n\nAs before, this series is based on commit 683c54c999 (\"Git 2.49\", 2025-03-14).\n\nAlso, I did a test merge to 'master'@5b97a56fa0, 'next'@ff1f9ca942 and\n'seen'@1b09671a54 and they all 'auto-merged' without issue.\n\nAs an experiment, I am using 'git sendemail' to send this series for the\nfirst time (I have sent single patches before, but not a series), so if\nanything goes awry I apologize in advance! :)\n\nA range-diff is given below.\n\n\nThe original v1 cover-letter follows:\n-------------------------------------\n\nThis series contains some miscellaneous changes to the make, meson and\nautoconf build systems. These are only the patches I have managed to\nwrite a commit message for; I have some others with no commit message,\nsome need more testing and others are yet to be written. (So, there will\nbe a 'part #2' series later... :) ).\n\n(I have notes from a couple of months ago - as an example, I have a note\nthat the meson build incorrectly sets ETC_GITATTRIBUTES and ETC_GITCONFIG\nto e.g. '/etc/gitattributes' rather than 'etc/gitattributes').\n\nThis series is based on the master branch at commit 683c54c999 (\"Git 2.49\",\n2025-03-14).\n\nAs a simple means for comparing the build products, we can compare the\nsymbols exported by git. So, starting at current master:\n\n  $ git checkout master\n  Switched to branch 'master'\n  Your branch is up-to-date with 'origin/master'.\n  $ git describe\n  v2.49.0\n  $ \n\n  $ make >out 2>&1\n  $ \n\n  $ meson setup build/\n  The Meson build system\n  ...\n  Found ninja-1.11.1 at /usr/bin/ninja\n  $ \n\n  $ cd build\n  $ meson compile\n  INFO: autodetecting backend as ninja\n  INFO: calculating backend command to run: /usr/bin/ninja\n  [661/661] Copying file contrib/completion/git-completion.zsh\n  $ cd ..\n  $ \n\n  $ rm *.syms\n  $ ./syms.pl git >git.syms 2>/dev/null\n  $ ./syms.pl build/git >mgit.syms 2>/dev/null\n  $ \n\n  $ diff git.syms mgit.syms\n  88a89\n  > U -- arc4random_buf@GLIBC_2.36\n  98a100,101\n  > U -- atoi@GLIBC_2.2.5\n  > U -- atol@GLIBC_2.2.5\n  195a199\n  > U -- bsearch@GLIBC_2.2.5\n  586,587d589\n  < U -- dcgettext@GLIBC_2.2.5\n  < U -- dcngettext@GLIBC_2.2.5\n  746,747c748,749\n  < B -- __environ@GLIBC_2.2.5\n  < V -- environ@GLIBC_2.2.5\n  ---\n  > U -- __environ@GLIBC_2.2.5\n  > U -- environ@GLIBC_2.2.5\n  909c911\n  < U -- __fprintf_chk@GLIBC_2.3.4\n  ---\n  > U -- fprintf@GLIBC_2.2.5\n  914d915\n  < U -- __fread_chk@GLIBC_2.7\n  1007c1008\n  < U -- getc@GLIBC_2.2.5\n  ---\n  > U -- getchar@GLIBC_2.2.5\n  1018a1020\n  > U -- getc_unlocked@GLIBC_2.2.5\n  1107a1110\n  > U -- gettext@GLIBC_2.2.5\n  1253d1255\n  < T -- gitstrlcpy\n  1355a1358\n  > U -- htons@GLIBC_2.2.5\n  1666d1668\n  < U -- __memcpy_chk@GLIBC_2.3.4\n  1673d1674\n  < U -- __memmove_chk@GLIBC_2.3.4\n  1684d1684\n  < U -- __memset_chk@GLIBC_2.3.4\n  1737a1738\n  > U -- ngettext@GLIBC_2.2.5\n  1759a1761\n  > U -- ntohs@GLIBC_2.2.5\n  1819d1820\n  < U -- __open64_2@GLIBC_2.7\n  1988a1990,2007\n  > U -- pcre2_code_free_8\n  > U -- pcre2_compile_8\n  > U -- pcre2_compile_context_create_8\n  > U -- pcre2_compile_context_free_8\n  > U -- pcre2_config_8\n  > U -- pcre2_general_context_create_8\n  > U -- pcre2_general_context_free_8\n  > U -- pcre2_get_error_message_8\n  > U -- pcre2_get_ovector_pointer_8\n  > U -- pcre2_jit_compile_8\n  > U -- pcre2_jit_match_8\n  > U -- pcre2_maketables_8\n  > U -- pcre2_maketables_free_8\n  > U -- pcre2_match_8\n  > U -- pcre2_match_data_create_from_pattern_8\n  > U -- pcre2_match_data_free_8\n  > U -- pcre2_pattern_info_8\n  > U -- pcre2_set_character_tables_8\n  2045c2064\n  < U -- __printf_chk@GLIBC_2.3.4\n  ---\n  > U -- printf@GLIBC_2.2.5\n  2080a2100\n  > U -- pthread_equal@GLIBC_2.2.5\n  2767c2787\n  < U -- __snprintf_chk@GLIBC_2.3.4\n  ---\n  > U -- snprintf@GLIBC_2.2.5\n  2925a2946\n  > U -- strlcpy@GLIBC_2.38\n  3185d3205\n  < U -- __uflow@GLIBC_2.2.5\n  3289,3290c3309,3311\n  < U -- __vfprintf_chk@GLIBC_2.3.4\n  < U -- __vsnprintf_chk@GLIBC_2.3.4\n  ---\n  > U -- vfprintf@GLIBC_2.2.5\n  > U -- vprintf@GLIBC_2.2.5\n  > U -- vsnprintf@GLIBC_2.2.5\n  $ \n\nLooking at the above, you can see that quite a few differences relate to\nsymbols which differ due to the level of optimization during compilation.\nThis reflects, among other things, the different 'default' settings between\nthe Makefile and the meson build; e.g. prefix=$HOME vs. /usr/local, initial\nCFLAGS='-g -O2 -Wall' vs. '-g -O0 -Wall'. Also, note that the make build\ndoes not include the (optional) pcre2 library, even if it is installed on\nthe system.\n\n[On cygwin the diff is slightly different, but also contains more symbols,\nsuch as all symbols relating to the compat regex routines, clock_gettime,\ngetdelim, sysinfo and so on ... ;) ]\n\nIf we change the meson setup, thus:\n\n  $ meson setup --optimization=2 -Dprefix=$HOME -Dpcre2=disabled build/\n\nAfter we re-build and repeat the above symbol generation, we find:\n\n  $ diff git.syms mgit.syms\n  88a89\n  > U -- arc4random_buf@GLIBC_2.36\n  746,747c747,748\n  < B -- __environ@GLIBC_2.2.5\n  < V -- environ@GLIBC_2.2.5\n  ---\n  > U -- __environ@GLIBC_2.2.5\n  > U -- environ@GLIBC_2.2.5\n  1253d1253\n  < T -- gitstrlcpy\n  2925a2926\n  > U -- strlcpy@GLIBC_2.38\n  $ \n\nAfter applying these patches and adding settings to the config.mak file: \n\n  $ vim config.mak # add NO_STRLCPY and CSPRNG_METHOD\n  $ \n  $ cat config.mak\n  DEFAULT_TEST_TARGET=prove\n  GIT_PROVE_OPTS='--timer'\n  PYTHON_PATH=/usr/bin/python3\n  GIT_TEST_HTTPD=false\n  export GIT_TEST_HTTPD\n  #DEVELOPER=1\n  SPARSE_FLAGS += -D__STDC_NO_VLA__\n  NO_STRLCPY=\n  CSPRNG_METHOD=arc4random\n  $ \n\n[Note that I commented out DEVELOPER=1. I'm not entirely sure why I did\nthat. :) Maybe it was one less variable? ]\n\n  $ make >out 2>&1\n  $ \n\n  $ meson setup --optimization=2 -Dprefix=$HOME -Dpcre2=disabled build/\n  The Meson build system\n  ...\n    User defined options\n      optimization: 2\n      prefix      : /home/ramsay\n      pcre2       : disabled\n  \n  Found ninja-1.11.1 at /usr/bin/ninja\n  $ \n\n  $ cd build\n  $ meson compile\n  INFO: autodetecting backend as ninja\n  INFO: calculating backend command to run: /usr/bin/ninja\n  [661/661] Copying file contrib/completion/git-prompt.sh\n  $ cd ..\n  $ \n\n  $ rm *.syms\n  $ ./syms.pl git >git.syms 2>/dev/null\n  $ ./syms.pl build/git >mgit.syms 2>/dev/null\n  $ \n\n  $ diff git.syms mgit.syms\n  747,748c747,748\n  < B -- __environ@GLIBC_2.2.5\n  < V -- environ@GLIBC_2.2.5\n  ---\n  > U -- __environ@GLIBC_2.2.5\n  > U -- environ@GLIBC_2.2.5\n  $ \n \nOn cygwin, this diff is now empty. ;)\n\nThe above diff seems to imply a difference in the linking of main() and\nthe C library startup routines (or something similar). However, I happened\nto notice that the meson build included '-fPIC' in the build flags, so I\nthought it was worth a punt:\n\n  $ make CFLAGS='-g -O2 -Wall -fPIC' >out 2>&1\n\n[with the advent of ASLR, I thought -fPIC/-fPIE was the default anyway!]\n\n  $ diff git.syms mgit.syms\n  2809,2811c2809,2811\n  < U -- stderr@GLIBC_2.2.5\n  < U -- stdin@GLIBC_2.2.5\n  < U -- stdout@GLIBC_2.2.5\n  ---\n  > B -- stderr@GLIBC_2.2.5\n  > B -- stdin@GLIBC_2.2.5\n  > B -- stdout@GLIBC_2.2.5\n  $ \n\nHmm, so one step forward, one step back! (or is it 2 steps forward, 3 steps\nback? ;) ). So, something for another day.\n\nNote that both test suite runs ('make test' and 'meson test') pass all\ntests (excluding the http, cvs, svn, and p4 tests) on Linux. (I am still\nwaiting for the v2.49.0 test run to finish on cygwin! :( ).\n\nAlso, patches #5 and #12 only add/modify a comment, so they could be\ndropped, if people feel that they are not appropriate.\n\n[Just in case you want to reproduce the above, I have appended the syms.pl\nscript below.]\n\nATB,\nRamsay Jones\n\nRamsay Jones (13):\n  meson.build: remove -DCURL_DISABLE_TYPECHECK\n  Makefile: only set some BASIC_CFLAGS when RUNTIME_PREFIX is set\n  meson.build: only set build variables for non-default values\n  meson.build: set default help format to html on windows\n  Makefile: remove NEEDS_LIBRT build variable\n  config.mak.uname: add a note about NO_STRLCPY for Linux\n  config.mak.uname: only set NO_REGEX on cygwin for v1.7\n  config.mak.uname: add HAVE_GETDELIM to the cygwin section\n  config.mak.uname: add clock_gettime() to the cygwin build\n  builtin/gc.c: correct RAM calculation when using sysinfo\n  config.mak.uname: add sysinfo() configuration for cygwin\n  config.mak.uname: add arc4random to the cygwin build\n  config.mak.uname: set CSPRNG_METHOD to getrandom on Linux\n\n Documentation/meson.build | 20 +++++++++++++++++\n Makefile                  | 45 ++++++++++++++++++++-------------------\n builtin/gc.c              |  9 ++++++--\n config.mak.uname          | 15 +++++++++----\n configure.ac              |  8 +++++++\n meson.build               | 27 +++++++++++++++++++----\n meson_options.txt         |  2 +-\n t/t7815-grep-binary.sh    |  2 +-\n 8 files changed, 94 insertions(+), 34 deletions(-)\n\nrange-diff against v1:\n\n 1:  50ce21363e =  1:  fe969deec0 meson.build: remove -DCURL_DISABLE_TYPECHECK\n 2:  b7097a71b4 =  2:  8df541634a Makefile: only set some BASIC_CFLAGS when RUNTIME_PREFIX is set\n 3:  85363624b2 <  -:  ---------- meson.build: only set build variables for non-default values\n -:  ---------- >  3:  280363cd56 meson.build: only set build variables for non-default values\n -:  ---------- >  4:  34349bf98c meson.build: set default help format to html on windows\n 4:  4bda84bbf2 =  5:  e73c2c3219 Makefile: remove NEEDS_LIBRT build variable\n 5:  45d570f6d4 =  6:  8c76671f0e config.mak.uname: add a note about NO_STRLCPY for Linux\n 6:  45ef2d4268 !  7:  324bb21342 config.mak.uname: only set NO_REGEX on cygwin for v1.7\n    @@ Commit message\n         some of the tests (t4018 and t4034), which passed just fine with the\n         compat library.\n     \n    -    After some time (may a year or two), the platform library had been\n    +    After some time (maybe a year or two), the platform library had been\n         updated (with an import from FreeBSD, I believe) and now passed the full\n         test-suite. This would be about the time of the v1.7 -> v2.0 transition\n         in 2015. I had a patch ready to send, but just didn't get around to\n    @@ Commit message\n         NO_REGEX variable to use the platform regex library functions. The new\n         meson build system does likewise.\n     \n    +    The cygwin platform regex library, in addition to now passing the tests\n    +    which formerly failed, now passes an 'test_expect_failure' test in the\n    +    t7815-grep-binary test file. In particular, test #12 'git grep .fi a'\n    +    which determines that the regex pattern '.' matches a NUL character.\n    +    The commit f96e56733a (\"grep: use REG_STARTEND for all matching if\n    +    available\", 2010-05-22) added the test in question, but it does not\n    +    give any indication as to why the test was framed as an expected fail,\n    +    rather than a 'positive' test that the 'git grep' command fails to\n    +    match a NUL. Note that the previous test #11 was also originally\n    +    marked in that commit as a 'test_expect_failure', but was flipped to\n    +    an 'success' test in commit 7e36de5859 (\"t/t7008-grep-binary.sh: un-TODO\n    +    a test that needs REG_STARTEND\", 2010-08-17).\n    +\n         In order to produce the same NO_REGEX configuration from autoconf, meson\n         and make, modify config.mak.uname to only set NO_REGEX for cygwin v1.7.\n    +    In addition, skip test t7815.12 on cygwin, by adding the !CYGWIN pre-\n    +    requisite to the test header, which (among other things) removes an\n    +    '...; please update test(s)' comment.\n     \n      ## config.mak.uname ##\n     @@ config.mak.uname: ifeq ($(uname_O),Cygwin)\n    @@ config.mak.uname: ifeq ($(uname_O),Cygwin)\n              endif\n      \tHAVE_DEV_TTY = YesPlease\n      \tHAVE_ALLOCA_H = YesPlease\n    +\n    + ## t/t7815-grep-binary.sh ##\n    +@@ t/t7815-grep-binary.sh: test_expect_success 'git grep ile a' '\n    + \tgit grep ile a\n    + '\n    + \n    +-test_expect_failure 'git grep .fi a' '\n    ++test_expect_failure !CYGWIN 'git grep .fi a' '\n    + \tgit grep .fi a\n    + '\n    + \n 7:  aa3e298fde =  8:  0a3ce7e80a config.mak.uname: add HAVE_GETDELIM to the cygwin section\n 8:  dc30aa5653 =  9:  3bd6e40cd2 config.mak.uname: add clock_gettime() to the cygwin build\n 9:  1e92c641a6 = 10:  a2eb9ab117 builtin/gc.c: correct RAM calculation when using sysinfo\n10:  6e208c53dd = 11:  e45b9df3a4 config.mak.uname: add sysinfo() configuration for cygwin\n11:  990fde71bb ! 12:  422d4b2571 config.mak.uname; add arc4random to the cygwin build\n    @@ Metadata\n     Author: Ramsay Jones <ramsay@ramsayjones.plus.com>\n     \n      ## Commit message ##\n    -    config.mak.uname; add arc4random to the cygwin build\n    +    config.mak.uname: add arc4random to the cygwin build\n     \n         The arc4random_buf() function has been available in cygwin since\n         about 2016 (somewhere in the v2.x branch). Set the CSPRNG_METHOD\n12:  847ca6b16c ! 13:  7b133af24b config.mak.uname: add a note about CSPRNG_METHOD for Linux\n    @@ Metadata\n     Author: Ramsay Jones <ramsay@ramsayjones.plus.com>\n     \n      ## Commit message ##\n    -    config.mak.uname: add a note about CSPRNG_METHOD for Linux\n    +    config.mak.uname: set CSPRNG_METHOD to getrandom on Linux\n     \n         Commit 05cd988dce (\"wrapper: add a helper to generate numbers from a\n         CSPRNG\", 2022-01-17) added a csprng_bytes() function which used one\n    @@ Commit message\n         Commit 05cd988dce did not set CSPRNG_METHOD in the Linux section of\n         the config.mak.uname file, so it defaults to using '/dev/urandom' as\n         the source of random bytes. The 'backend' values which could be used\n    -    on Linux, in order of preference, are 'arc4random', 'getrandom' or\n    -    'getentropy' ('openssl' is an option, but seems to be discouraged).\n    +    on Linux are 'arc4random', 'getrandom' or 'getentropy' ('openssl' is\n    +    an option, but seems to be discouraged).\n     \n         The arc4random routines (ar4random_buf() is the one actually used) were\n         added to glibc in version 2.36, while both getrandom() and getentropy()\n         were included in 2.25. So, some of the more up-to-date distributions of\n    -    Linux (eg Debian 12, Ubuntu 24.04) would be able to use the preferred\n    -    'arc4random' setting.\n    +    Linux (eg Debian 12, Ubuntu 24.04) would be able to use the 'arc4random'\n    +    setting. All currently supported distributions have glibc 2.25 or later\n    +    (RHEL 8 has v2.28) and, therefore, have support for the 'getrandom' and\n    +    'getentropy' settings.\n    +\n    +    The arc4random routines on the *BSDs (along with cygwin) implement the\n    +    ChaCha20 stream cipher algorithm (see RFC8439) in userspace, rather than\n    +    as a system call, and are thus somewhat faster (having avoided a context\n    +    switch to the kernel). In contrast, on Linux all three functions are\n    +    simple wrappers around the same kernel CSPRNG syscall.\n     \n         If the meson build system is used on a newer platform, then they will be\n         configured to use 'arc4random', whereas the make build will currently\n    -    default to using '/dev/urandom'. Add a note to the config.mak.uname file,\n    -    in the Linux section, to prompt make users to override CSPRNG_METHOD in\n    -    the config.mak file, if appropriate.\n    +    default to using '/dev/urandom' on Linux. Since there is no advantage,\n    +    in terms of performance, to the 'arc4random' setting, the 'getrandom'\n    +    setting should be preferred from an availability perspective. (Also, the\n    +    current uses of csprng_bytes() are not in any hot path).\n    +\n    +    In order to set an appropriate default, set the CSPRNG_METHOD build\n    +    variable to 'getrandom' in the Linux section of the 'config.mak.uname'\n    +    file.\n     \n      ## config.mak.uname ##\n     @@ config.mak.uname: ifeq ($(uname_S),Linux)\n      \tHAVE_ALLOCA_H = YesPlease\n      \t# override in config.mak if you have glibc >= 2.38\n      \tNO_STRLCPY = YesPlease\n    -+\t# set to arc4random (in config.mak) if you have glibc >= 2.36\n    -+\tCSPRNG_METHOD =\n    ++\tCSPRNG_METHOD = getrandom\n      \tHAVE_PATHS_H = YesPlease\n      \tLIBC_CONTAINS_LIBINTL = YesPlease\n      \tHAVE_DEV_TTY = YesPlease\n-- \n2.49.0\n\n----------------- >8 ------------------ [syms.pl]\n#!/usr/bin/perl -w\n\nopen(I, \"-|\", qw(nm -g), $ARGV[0]) or die;\nwhile (<I>) {\n\tunless (/^[0-9a-f ]+ ([A-Z]) (\\S*)$/) {\n\t\tprint STDERR \"? $_\";\n\t\tnext;\n\t}\n\tnext if ($2 =~ /^\\.refptr\\./);\n\tprint \"$1 -- $2\\n\";\n}\nclose I;\n\n"},{"id":"515732","messageId":"8df541634aedbba40d8b0fa57dbf9cb0e495f11b.1743859985.git.ramsay@ramsayjones.plus.com","threadId":"63129","inReplyTo":"cover.1743859985.git.ramsay@ramsayjones.plus.com","subject":"[PATCH v2 02/13] Makefile: only set some BASIC_CFLAGS when RUNTIME_PREFIX is set","fromName":"Ramsay Jones","fromEmail":"ramsay@ramsayjones.plus.com","sentAt":"2025-04-06T19:38:28Z","receivedAt":"2025-04-06T19:42:22Z","isPatch":true,"sender":{"key":"ramsay@ramsayjones.plus.com","avatar":"https://avatars.githubusercontent.com/u/33702710?v=4"},"body":"Several build variables only have any meaning when the RUNTIME_PREFIX\nvariable has been set. In particular, the following build variables are\notherwise ignored:\n\n    HAVE_BSD_KERN_PROC_SYSCTL\n    PROCFS_EXECUTABLE_PATH\n    HAVE_NS_GET_EXECUTABLE_PATH\n    HAVE_ZOS_GET_EXECUTABLE_PATH\n    HAVE_WPGMPTR\n\nMake setting BASIC_CFLAGS, for each of these variables, conditional on\nthe RUNTIME_PREFIX being defined.\n\nSigned-off-by: Ramsay Jones <ramsay@ramsayjones.plus.com>\n---\n Makefile | 38 +++++++++++++++++++++-----------------\n 1 file changed, 21 insertions(+), 17 deletions(-)\n\ndiff --git a/Makefile b/Makefile\nindex 7315507381..818dde32a9 100644\n--- a/Makefile\n+++ b/Makefile\n@@ -2179,10 +2179,6 @@ ifdef HAVE_BSD_SYSCTL\n \tBASIC_CFLAGS += -DHAVE_BSD_SYSCTL\n endif\n \n-ifdef HAVE_BSD_KERN_PROC_SYSCTL\n-\tBASIC_CFLAGS += -DHAVE_BSD_KERN_PROC_SYSCTL\n-endif\n-\n ifdef HAVE_GETDELIM\n \tBASIC_CFLAGS += -DHAVE_GETDELIM\n endif\n@@ -2213,25 +2209,33 @@ ifneq ($(findstring openssl,$(CSPRNG_METHOD)),)\n \tEXTLIBS += -lcrypto -lssl\n endif\n \n-ifneq ($(PROCFS_EXECUTABLE_PATH),)\n-\tprocfs_executable_path_SQ = $(subst ','\\'',$(PROCFS_EXECUTABLE_PATH))\n-\tBASIC_CFLAGS += '-DPROCFS_EXECUTABLE_PATH=\"$(procfs_executable_path_SQ)\"'\n-endif\n-\n ifndef HAVE_PLATFORM_PROCINFO\n \tCOMPAT_OBJS += compat/stub/procinfo.o\n endif\n \n-ifdef HAVE_NS_GET_EXECUTABLE_PATH\n-\tBASIC_CFLAGS += -DHAVE_NS_GET_EXECUTABLE_PATH\n-endif\n+ifdef RUNTIME_PREFIX\n \n-ifdef HAVE_ZOS_GET_EXECUTABLE_PATH\n-        BASIC_CFLAGS += -DHAVE_ZOS_GET_EXECUTABLE_PATH\n-endif\n+        ifdef HAVE_BSD_KERN_PROC_SYSCTL\n+\t\tBASIC_CFLAGS += -DHAVE_BSD_KERN_PROC_SYSCTL\n+        endif\n+\n+        ifneq ($(PROCFS_EXECUTABLE_PATH),)\n+\t\tpep_SQ = $(subst ','\\'',$(PROCFS_EXECUTABLE_PATH))\n+\t\tBASIC_CFLAGS += '-DPROCFS_EXECUTABLE_PATH=\"$(pep_SQ)\"'\n+        endif\n+\n+        ifdef HAVE_NS_GET_EXECUTABLE_PATH\n+\t\tBASIC_CFLAGS += -DHAVE_NS_GET_EXECUTABLE_PATH\n+        endif\n+\n+        ifdef HAVE_ZOS_GET_EXECUTABLE_PATH\n+\t\tBASIC_CFLAGS += -DHAVE_ZOS_GET_EXECUTABLE_PATH\n+        endif\n+\n+        ifdef HAVE_WPGMPTR\n+\t\tBASIC_CFLAGS += -DHAVE_WPGMPTR\n+        endif\n \n-ifdef HAVE_WPGMPTR\n-\tBASIC_CFLAGS += -DHAVE_WPGMPTR\n endif\n \n ifdef FILENO_IS_A_MACRO\n-- \n2.49.0\n\n"},{"id":"515733","messageId":"280363cd569a8c6e870107eb219597b42911fed2.1743859985.git.ramsay@ramsayjones.plus.com","threadId":"63129","inReplyTo":"cover.1743859985.git.ramsay@ramsayjones.plus.com","subject":"[PATCH v2 03/13] meson.build: only set build variables for non-default values","fromName":"Ramsay Jones","fromEmail":"ramsay@ramsayjones.plus.com","sentAt":"2025-04-06T19:38:29Z","receivedAt":"2025-04-06T19:42:29Z","isPatch":true,"sender":{"key":"ramsay@ramsayjones.plus.com","avatar":"https://avatars.githubusercontent.com/u/33702710?v=4"},"body":"Some preprocessor -Defines have defaults set in the source code when\nthey have not been provided to the C compiler. In this case, there is\nno need to pass them on the command-line, unless the build requires a\nnon-standard value.\n\nThe build variables for DEFAULT_EDITOR and DEFAULT_PAGER have appropriate\ndefaults ('vi' and 'less') set in the code. Add the preprocessor -Defines\nto the 'libgit_c_args' only if the values set with the corresponding\n'options' are different to these standard values.\n\nAlso, the 'git-var' documentation contains some conditional text which\ndocuments the chosen compiled in value, which would not read well for\nthe standard values. Similar to the above, only add the corresponding\n'-a' attribute arguments to the 'asciidoc_common_options' variable, if\nthe values set in the 'options' are different to these standard values.\n\nSigned-off-by: Ramsay Jones <ramsay@ramsayjones.plus.com>\n---\n Documentation/meson.build | 20 ++++++++++++++++++++\n meson.build               | 13 +++++++++++--\n 2 files changed, 31 insertions(+), 2 deletions(-)\n\ndiff --git a/Documentation/meson.build b/Documentation/meson.build\nindex 594546d68b..1642b6e2a3 100644\n--- a/Documentation/meson.build\n+++ b/Documentation/meson.build\n@@ -242,6 +242,16 @@ if docs_backend == 'asciidoc'\n     '--attribute=build_dir=' + meson.current_build_dir(),\n   ]\n \n+  pager_opt = get_option('default_pager')\n+  if pager_opt != '' and pager_opt != 'less'\n+    asciidoc_common_options += '-agit-default-pager=' + pager_opt\n+  endif\n+\n+  editor_opt = get_option('default_editor')\n+  if editor_opt != '' and editor_opt != 'vi'\n+    asciidoc_common_options += '-agit-default-editor=' + editor_opt\n+  endif\n+\n   documentation_deps = [\n     asciidoc_conf,\n   ]\n@@ -279,6 +289,16 @@ elif docs_backend == 'asciidoctor'\n     '--require', 'asciidoctor-extensions',\n   ]\n \n+  pager_opt = get_option('default_pager')\n+  if pager_opt != '' and pager_opt != 'less'\n+    asciidoc_common_options += '-agit-default-pager=' + pager_opt\n+  endif\n+\n+  editor_opt = get_option('default_editor')\n+  if editor_opt != '' and editor_opt != 'vi'\n+    asciidoc_common_options += '-agit-default-editor=' + editor_opt\n+  endif\n+\n   documentation_deps = [\n     asciidoctor_extensions,\n   ]\ndiff --git a/meson.build b/meson.build\nindex 88a29fd043..efd0bd3319 100644\n--- a/meson.build\n+++ b/meson.build\n@@ -693,10 +693,8 @@ endif\n # These variables are used for building libgit.a.\n libgit_c_args = [\n   '-DBINDIR=\"' + get_option('bindir') + '\"',\n-  '-DDEFAULT_EDITOR=\"' + get_option('default_editor') + '\"',\n   '-DDEFAULT_GIT_TEMPLATE_DIR=\"' + get_option('datadir') / 'git-core/templates' + '\"',\n   '-DDEFAULT_HELP_FORMAT=\"' + get_option('default_help_format') + '\"',\n-  '-DDEFAULT_PAGER=\"' + get_option('default_pager') + '\"',\n   '-DETC_GITATTRIBUTES=\"' + get_option('gitattributes') + '\"',\n   '-DETC_GITCONFIG=\"' + get_option('gitconfig') + '\"',\n   '-DFALLBACK_RUNTIME_PREFIX=\"' + get_option('prefix') + '\"',\n@@ -708,6 +706,17 @@ libgit_c_args = [\n   '-DPAGER_ENV=\"' + get_option('pager_environment') + '\"',\n   '-DSHELL_PATH=\"' + fs.as_posix(shell.full_path()) + '\"',\n ]\n+\n+editor_opt = get_option('default_editor')\n+if editor_opt != '' and editor_opt != 'vi'\n+  libgit_c_args += '-DDEFAULT_EDITOR=\"' + editor_opt + '\"'\n+endif\n+\n+pager_opt = get_option('default_pager')\n+if pager_opt != '' and pager_opt != 'less'\n+  libgit_c_args += '-DDEFAULT_PAGER=\"' + pager_opt + '\"'\n+endif\n+\n libgit_include_directories = [ '.' ]\n libgit_dependencies = [ ]\n \n-- \n2.49.0\n\n"},{"id":"515734","messageId":"34349bf98c5b01dd1b73065448b616517bb784a3.1743859985.git.ramsay@ramsayjones.plus.com","threadId":"63129","inReplyTo":"cover.1743859985.git.ramsay@ramsayjones.plus.com","subject":"[PATCH v2 04/13] meson.build: set default help format to html on windows","fromName":"Ramsay Jones","fromEmail":"ramsay@ramsayjones.plus.com","sentAt":"2025-04-06T19:38:30Z","receivedAt":"2025-04-06T19:42:33Z","isPatch":true,"sender":{"key":"ramsay@ramsayjones.plus.com","avatar":"https://avatars.githubusercontent.com/u/33702710?v=4"},"body":"The build variable DEFAULT_HELP_FORMAT has an appropriate default\n('man') set in the code, so there is no need to pass the -Define on\nthe compiler command-line, unless the build requires a non-standard\nvalue.\n\nIn addition, on windows the make build overrides the default help\nformat to 'html', rather than 'man', in the 'config.mak.uname' file.\n\nIn order to suppress the -Define on the C compiler command-line, only\nadd the -Define to the 'libgit_c_args' variable when the requested\nvalue is not the standard 'man'. In order to override the default value\non windows, add a 'platform' value to the 'default_help_format' combo\noption and set it as the default choice. When this option is set to\n'platform', use the 'host_machine.system()' method call to determine the\nappropriate default value for the host system.\n\nSigned-off-by: Ramsay Jones <ramsay@ramsayjones.plus.com>\n---\n meson.build       | 13 ++++++++++++-\n meson_options.txt |  2 +-\n 2 files changed, 13 insertions(+), 2 deletions(-)\n\ndiff --git a/meson.build b/meson.build\nindex efd0bd3319..8f8a258064 100644\n--- a/meson.build\n+++ b/meson.build\n@@ -694,7 +694,6 @@ endif\n libgit_c_args = [\n   '-DBINDIR=\"' + get_option('bindir') + '\"',\n   '-DDEFAULT_GIT_TEMPLATE_DIR=\"' + get_option('datadir') / 'git-core/templates' + '\"',\n-  '-DDEFAULT_HELP_FORMAT=\"' + get_option('default_help_format') + '\"',\n   '-DETC_GITATTRIBUTES=\"' + get_option('gitattributes') + '\"',\n   '-DETC_GITCONFIG=\"' + get_option('gitconfig') + '\"',\n   '-DFALLBACK_RUNTIME_PREFIX=\"' + get_option('prefix') + '\"',\n@@ -717,6 +716,18 @@ if pager_opt != '' and pager_opt != 'less'\n   libgit_c_args += '-DDEFAULT_PAGER=\"' + pager_opt + '\"'\n endif\n \n+help_format_opt = get_option('default_help_format')\n+if help_format_opt == 'platform'\n+  if host_machine.system() == 'windows'\n+    help_format_opt = 'html'\n+  else\n+    help_format_opt = 'man'\n+  endif\n+endif\n+if help_format_opt != 'man'\n+    libgit_c_args += '-DDEFAULT_HELP_FORMAT=\"' + help_format_opt + '\"'\n+endif\n+\n libgit_include_directories = [ '.' ]\n libgit_dependencies = [ ]\n \ndiff --git a/meson_options.txt b/meson_options.txt\nindex 78d172a740..8ac30a5223 100644\n--- a/meson_options.txt\n+++ b/meson_options.txt\n@@ -95,7 +95,7 @@ option('highlight_bin', type: 'string', value: 'highlight')\n # Documentation.\n option('docs', type: 'array', choices: ['man', 'html'], value: [],\n   description: 'Which documenattion formats to build and install.')\n-option('default_help_format', type: 'combo', choices: ['man', 'html'], value: 'man',\n+option('default_help_format', type: 'combo', choices: ['man', 'html', 'platform'], value: 'platform',\n   description: 'Default format used when executing git-help(1).')\n option('docs_backend', type: 'combo', choices: ['asciidoc', 'asciidoctor', 'auto'], value: 'auto',\n   description: 'Which backend to use to generate documentation.')\n-- \n2.49.0\n\n"},{"id":"515735","messageId":"e73c2c321985d6e17f2592ad36f4d319ea655459.1743859985.git.ramsay@ramsayjones.plus.com","threadId":"63129","inReplyTo":"cover.1743859985.git.ramsay@ramsayjones.plus.com","subject":"[PATCH v2 05/13] Makefile: remove NEEDS_LIBRT build variable","fromName":"Ramsay Jones","fromEmail":"ramsay@ramsayjones.plus.com","sentAt":"2025-04-06T19:38:31Z","receivedAt":"2025-04-06T19:42:39Z","isPatch":true,"sender":{"key":"ramsay@ramsayjones.plus.com","avatar":"https://avatars.githubusercontent.com/u/33702710?v=4"},"body":"Commit d19e3a5b21 (\"Makefile: add NEEDS_LIBRT to optionally link with\nlibrt\", 2016-07-07) introduced the NEEDS_LIBRT build variable to\ndisassociate the HAVE_CLOCK_GETTIME variable with the unconditional\nlinking of the librt library. At one time, the clock_gettime() function\nwas not available as part of the libc library and (on some unix systems)\nrequired linking with librt.\n\nCommit 52fcec75ce (\"config.mak.uname: define NEEDS_LIBRT under Linux, for\nnow\", 2016-07-10) set the NEEDS_LIBRT variable in the Linux section of\nthe config.mak.uname file, since Debian 7 (wheezy) was one of the few\nremaining distributions, with glibc 2.13, that required linking with\nlibrt for clock_gettime(). Note that from glibc version 2.17, this is no\nlonger necessary.\n\nNote that Debian 7.0 was released on May 4th, 2013 and benefited from\nlong term support until May 2018 when it went end-of-life. Since that\ntime, Linux distributions use a more up-to-date library, for example:\n\n    Distribution   version  end of support\n\n    Debian 8       2.19     30th June 2020\n    RHEL   8       2.28     31st May  2024 *\n    Ubuntu 16.04   2.23     30th Apr  2021\n\n* paid 'Maintenance support' ends 31st May 2029\n\nSince it is no longer required, remove NEEDS_LIBRT from the Makefile and\nconfig.mak.uname.\n\nSigned-off-by: Ramsay Jones <ramsay@ramsayjones.plus.com>\n---\n Makefile         | 7 -------\n config.mak.uname | 2 --\n 2 files changed, 9 deletions(-)\n\ndiff --git a/Makefile b/Makefile\nindex 818dde32a9..8fa4d2664e 100644\n--- a/Makefile\n+++ b/Makefile\n@@ -340,9 +340,6 @@ include shared.mak\n #\n # Define HAVE_SYNC_FILE_RANGE if your platform has sync_file_range.\n #\n-# Define NEEDS_LIBRT if your platform requires linking with librt (glibc version\n-# before 2.17) for clock_gettime and CLOCK_MONOTONIC.\n-#\n # Define HAVE_BSD_SYSCTL if your platform has a BSD-compatible sysctl function.\n #\n # Define HAVE_GETDELIM if your system has the getdelim() function.\n@@ -2171,10 +2168,6 @@ ifdef HAVE_SYNC_FILE_RANGE\n \tBASIC_CFLAGS += -DHAVE_SYNC_FILE_RANGE\n endif\n \n-ifdef NEEDS_LIBRT\n-\tEXTLIBS += -lrt\n-endif\n-\n ifdef HAVE_BSD_SYSCTL\n \tBASIC_CFLAGS += -DHAVE_BSD_SYSCTL\n endif\ndiff --git a/config.mak.uname b/config.mak.uname\nindex b12d4e168a..88007c4f13 100644\n--- a/config.mak.uname\n+++ b/config.mak.uname\n@@ -54,8 +54,6 @@ ifeq ($(uname_S),Linux)\n \tHAVE_DEV_TTY = YesPlease\n \tHAVE_CLOCK_GETTIME = YesPlease\n \tHAVE_CLOCK_MONOTONIC = YesPlease\n-\t# -lrt is needed for clock_gettime on glibc <= 2.16\n-\tNEEDS_LIBRT = YesPlease\n \tHAVE_SYNC_FILE_RANGE = YesPlease\n \tHAVE_GETDELIM = YesPlease\n \tFREAD_READS_DIRECTORIES = UnfortunatelyYes\n-- \n2.49.0\n\n"},{"id":"515736","messageId":"a5795bfa-cc02-4c9a-b7d2-4924a94cd0db@ramsayjones.plus.com","threadId":"63129","inReplyTo":"280363cd569a8c6e870107eb219597b42911fed2.1743859985.git.ramsay@ramsayjones.plus.com","subject":"Re: [PATCH v2 03/13] meson.build: only set build variables for non-default values","fromName":"Ramsay Jones","fromEmail":"ramsay@ramsayjones.plus.com","sentAt":"2025-04-06T19:49:54Z","receivedAt":"2025-04-06T19:49:57Z","isPatch":true,"sender":{"key":"ramsay@ramsayjones.plus.com","avatar":"https://avatars.githubusercontent.com/u/33702710?v=4"},"body":"\n\nOn 06/04/2025 20:38, Ramsay Jones wrote:\n[snip]\n> diff --git a/meson.build b/meson.build\n> index 88a29fd043..efd0bd3319 100644\n> --- a/meson.build\n> +++ b/meson.build\n> @@ -693,10 +693,8 @@ endif\n>  # These variables are used for building libgit.a.\n>  libgit_c_args = [\n>    '-DBINDIR=\"' + get_option('bindir') + '\"',\n> -  '-DDEFAULT_EDITOR=\"' + get_option('default_editor') + '\"',\n>    '-DDEFAULT_GIT_TEMPLATE_DIR=\"' + get_option('datadir') / 'git-core/templates' + '\"',\n>    '-DDEFAULT_HELP_FORMAT=\"' + get_option('default_help_format') + '\"',\n> -  '-DDEFAULT_PAGER=\"' + get_option('default_pager') + '\"',\n>    '-DETC_GITATTRIBUTES=\"' + get_option('gitattributes') + '\"',\n>    '-DETC_GITCONFIG=\"' + get_option('gitconfig') + '\"',\n>    '-DFALLBACK_RUNTIME_PREFIX=\"' + get_option('prefix') + '\"',\n> @@ -708,6 +706,17 @@ libgit_c_args = [\n>    '-DPAGER_ENV=\"' + get_option('pager_environment') + '\"',\n>    '-DSHELL_PATH=\"' + fs.as_posix(shell.full_path()) + '\"',\n>  ]\n> +\n> +editor_opt = get_option('default_editor')\n> +if editor_opt != '' and editor_opt != 'vi'\n> +  libgit_c_args += '-DDEFAULT_EDITOR=\"' + editor_opt + '\"'\n> +endif\n> +\n> +pager_opt = get_option('default_pager')\n> +if pager_opt != '' and pager_opt != 'less'\n> +  libgit_c_args += '-DDEFAULT_PAGER=\"' + pager_opt + '\"'\n> +endif\n> +\n>  libgit_include_directories = [ '.' ]\n>  libgit_dependencies = [ ]\n>  \n\n\nIt would be somewhat remiss of me to not mention here that this does not\nwork for any but the simplest of values! :( If you set a simple single\n'bareword' like 'vim' or 'more' (even '~/bin/vi') then every thing works\njust fine. However, if the value contains any of (at least) the following\ncharacters: single quote, double quote or backslash, then things\nstop working!\n\n[I spent one whole evening (and a bit - always something else to 'try')\ntrying to 'fix' this problem, without success]\n\nIf you try an example that is given in the Makefile:312, then the make build:\n\n  $ make V=1 DEFAULT_EDITOR='\"C:\\Program Files\\Vim\\gvim.exe\" --nofork' all doc >m-out 2>&1\n\npasses the folowing arguments to (respectively) gcc and asciidoc:\n\n  -DDEFAULT_EDITOR='\"\\\"C:\\\\Program Files\\\\Vim\\\\gvim.exe\\\" --nofork\"'\n  -a 'git-default-editor=\"C:\\Program Files\\Vim\\gvim.exe\" --nofork'\n\nwhereas, the meson build:\n\n  $ meson setup --optimization=2 -Ddocs=man,html -Ddefault_editor='\"C:\\Program Files\\Vim\\gvim.exe\" --nofork' -Ddefault_pager=more -Dprefix=$HOME -Dpcre2=disabled build/\n  The Meson build system\n  ...\n   User defined options\n      optimization  : 2\n      prefix        : /home/ramsay\n      default_editor: \"C:\\Program Files\\Vim\\gvim.exe\" --nofork\n      default_pager : more\n      docs          : man,html\n      pcre2         : disabled\n\n  Found ninja-1.11.1 at /usr/bin/ninja\n  $ \n\nsimilarly, passes the folowing arguments to (respectively) gcc and asciidoc:\n\n  '-DDEFAULT_EDITOR=\"\"C:\\\\Program Files\\\\Vim\\\\gvim.exe\" --nofork\"'\n  '-agit-default-editor=\"C:/Program Files/Vim/gvim.exe\" --nofork'\n\nIf you now attempt a 'meson compile' it will, of course, fail to compile\neditor.c because the DEFAULT_EDITOR is the empty string (\"\") followed by\n(C:\\\\Program Files\\\\Vim\\\\gvim.exe\" --nofork\").\n\nAlso, note that the directory seperators have changed from \\\\ to / in the\nargument to asciidoc.\n\n[Again, spelunking the docs for meson, it said that \"if you want quotes, you\nwill have to do it yourself\"! ;) ]\n\nOK, so I couldn't come up with any incantation which would fix this issue.\nI will have to admit defeat and ask someone who actually knows meson to\nfix it. :(\n\nThanks.\n\nATB,\nRamsay Jones\n\n\n\n"},{"id":"515737","messageId":"94a3083c-fcc5-4489-8612-c15fa781c0f9@ramsayjones.plus.com","threadId":"63129","inReplyTo":"34349bf98c5b01dd1b73065448b616517bb784a3.1743859985.git.ramsay@ramsayjones.plus.com","subject":"Re: [PATCH v2 04/13] meson.build: set default help format to html on windows","fromName":"Ramsay Jones","fromEmail":"ramsay@ramsayjones.plus.com","sentAt":"2025-04-06T20:16:58Z","receivedAt":"2025-04-06T20:17:02Z","isPatch":true,"sender":{"key":"ramsay@ramsayjones.plus.com","avatar":"https://avatars.githubusercontent.com/u/33702710?v=4"},"body":"\n\nOn 06/04/2025 20:38, Ramsay Jones wrote:\n> The build variable DEFAULT_HELP_FORMAT has an appropriate default\n> ('man') set in the code, so there is no need to pass the -Define on\n> the compiler command-line, unless the build requires a non-standard\n> value.\n> \n> In addition, on windows the make build overrides the default help\n> format to 'html', rather than 'man', in the 'config.mak.uname' file.\n> \n> In order to suppress the -Define on the C compiler command-line, only\n> add the -Define to the 'libgit_c_args' variable when the requested\n> value is not the standard 'man'. In order to override the default value\n> on windows, add a 'platform' value to the 'default_help_format' combo\n> option and set it as the default choice. When this option is set to\n> 'platform', use the 'host_machine.system()' method call to determine the\n> appropriate default value for the host system.\n> \n> Signed-off-by: Ramsay Jones <ramsay@ramsayjones.plus.com>\n> ---\n>  meson.build       | 13 ++++++++++++-\n>  meson_options.txt |  2 +-\n>  2 files changed, 13 insertions(+), 2 deletions(-)\n> \n> diff --git a/meson.build b/meson.build\n> index efd0bd3319..8f8a258064 100644\n> --- a/meson.build\n> +++ b/meson.build\n> @@ -694,7 +694,6 @@ endif\n>  libgit_c_args = [\n>    '-DBINDIR=\"' + get_option('bindir') + '\"',\n>    '-DDEFAULT_GIT_TEMPLATE_DIR=\"' + get_option('datadir') / 'git-core/templates' + '\"',\n> -  '-DDEFAULT_HELP_FORMAT=\"' + get_option('default_help_format') + '\"',\n>    '-DETC_GITATTRIBUTES=\"' + get_option('gitattributes') + '\"',\n>    '-DETC_GITCONFIG=\"' + get_option('gitconfig') + '\"',\n>    '-DFALLBACK_RUNTIME_PREFIX=\"' + get_option('prefix') + '\"',\n> @@ -717,6 +716,18 @@ if pager_opt != '' and pager_opt != 'less'\n>    libgit_c_args += '-DDEFAULT_PAGER=\"' + pager_opt + '\"'\n>  endif\n>  \n> +help_format_opt = get_option('default_help_format')\n> +if help_format_opt == 'platform'\n> +  if host_machine.system() == 'windows'\n> +    help_format_opt = 'html'\n> +  else\n> +    help_format_opt = 'man'\n> +  endif\n> +endif\n> +if help_format_opt != 'man'\n> +    libgit_c_args += '-DDEFAULT_HELP_FORMAT=\"' + help_format_opt + '\"'\n> +endif\n> +\n\nNote that host_machine.system() classifies 'cygwin' to include cygwin and\nMSYS2 and 'windows' as windows but not cygwin or MSYS2! ;) The make build\noverrides the help format to 'html' for windows and MINGW{32,64}, so it is\nnot clear to me if the test above includes MINGW.\n\nAlso, in general cygwin != MSYS2 != MINGW{32,6} != Gfw flavour MSYS2, but\nit appears meson does not allow you to obtain such specific system info\n(for example, by executing uname directly).\n\n[Just a note that the make build includes 'info' as a choice, but Patrick\nmade the decision earlier to drop that for the meson build. Also, there is\na 'pdf' make target (I think that made it once, years ago ...)]\n\nThanks.\n\nATB,\nRamsay Jones\n\n\n"},{"id":"516079","messageId":"Z_y_REMmW95_5IcI@pks.im","threadId":"63129","inReplyTo":"8df541634aedbba40d8b0fa57dbf9cb0e495f11b.1743859985.git.ramsay@ramsayjones.plus.com","subject":"Re: [PATCH v2 02/13] Makefile: only set some BASIC_CFLAGS when RUNTIME_PREFIX is set","fromName":"Patrick Steinhardt","fromEmail":"ps@pks.im","sentAt":"2025-04-14T07:54:44Z","receivedAt":"2025-04-14T07:54:54Z","isPatch":true,"sender":{"key":"ps@pks.im","avatar":"https://avatars.githubusercontent.com/u/4056630?v=4"},"body":"On Sun, Apr 06, 2025 at 08:38:28PM +0100, Ramsay Jones wrote:\n> Several build variables only have any meaning when the RUNTIME_PREFIX\n> variable has been set. In particular, the following build variables are\n> otherwise ignored:\n> \n>     HAVE_BSD_KERN_PROC_SYSCTL\n>     PROCFS_EXECUTABLE_PATH\n>     HAVE_NS_GET_EXECUTABLE_PATH\n>     HAVE_ZOS_GET_EXECUTABLE_PATH\n>     HAVE_WPGMPTR\n> \n> Make setting BASIC_CFLAGS, for each of these variables, conditional on\n> the RUNTIME_PREFIX being defined.\n\nMakes sense. We already handle all of these conditionally in Meson, so\nthere's nothing else we need to do there.\n\nPatrick\n"},{"id":"516080","messageId":"Z_y_Tp5pfJ-gZLEF@pks.im","threadId":"63129","inReplyTo":"a5795bfa-cc02-4c9a-b7d2-4924a94cd0db@ramsayjones.plus.com","subject":"Re: [PATCH v2 03/13] meson.build: only set build variables for non-default values","fromName":"Patrick Steinhardt","fromEmail":"ps@pks.im","sentAt":"2025-04-14T07:54:54Z","receivedAt":"2025-04-14T07:54:57Z","isPatch":true,"sender":{"key":"ps@pks.im","avatar":"https://avatars.githubusercontent.com/u/4056630?v=4"},"body":"On Sun, Apr 06, 2025 at 08:49:54PM +0100, Ramsay Jones wrote:\n> \n> \n> On 06/04/2025 20:38, Ramsay Jones wrote:\n> [snip]\n> > diff --git a/meson.build b/meson.build\n> > index 88a29fd043..efd0bd3319 100644\n> > --- a/meson.build\n> > +++ b/meson.build\n> > @@ -693,10 +693,8 @@ endif\n> >  # These variables are used for building libgit.a.\n> >  libgit_c_args = [\n> >    '-DBINDIR=\"' + get_option('bindir') + '\"',\n> > -  '-DDEFAULT_EDITOR=\"' + get_option('default_editor') + '\"',\n> >    '-DDEFAULT_GIT_TEMPLATE_DIR=\"' + get_option('datadir') / 'git-core/templates' + '\"',\n> >    '-DDEFAULT_HELP_FORMAT=\"' + get_option('default_help_format') + '\"',\n> > -  '-DDEFAULT_PAGER=\"' + get_option('default_pager') + '\"',\n> >    '-DETC_GITATTRIBUTES=\"' + get_option('gitattributes') + '\"',\n> >    '-DETC_GITCONFIG=\"' + get_option('gitconfig') + '\"',\n> >    '-DFALLBACK_RUNTIME_PREFIX=\"' + get_option('prefix') + '\"',\n> > @@ -708,6 +706,17 @@ libgit_c_args = [\n> >    '-DPAGER_ENV=\"' + get_option('pager_environment') + '\"',\n> >    '-DSHELL_PATH=\"' + fs.as_posix(shell.full_path()) + '\"',\n> >  ]\n> > +\n> > +editor_opt = get_option('default_editor')\n> > +if editor_opt != '' and editor_opt != 'vi'\n> > +  libgit_c_args += '-DDEFAULT_EDITOR=\"' + editor_opt + '\"'\n> > +endif\n> > +\n> > +pager_opt = get_option('default_pager')\n> > +if pager_opt != '' and pager_opt != 'less'\n> > +  libgit_c_args += '-DDEFAULT_PAGER=\"' + pager_opt + '\"'\n> > +endif\n> > +\n> >  libgit_include_directories = [ '.' ]\n> >  libgit_dependencies = [ ]\n> >  \n> \n> \n> It would be somewhat remiss of me to not mention here that this does not\n> work for any but the simplest of values! :( If you set a simple single\n> 'bareword' like 'vim' or 'more' (even '~/bin/vi') then every thing works\n> just fine. However, if the value contains any of (at least) the following\n> characters: single quote, double quote or backslash, then things\n> stop working!\n> \n> [I spent one whole evening (and a bit - always something else to 'try')\n> trying to 'fix' this problem, without success]\n\nShouldn't it be possible to escape these values via `.replace()` [1]? I\nsuspect that you already tried, but wanted to ask anyway :)\n\nPatrick\n\n[1]: https://mesonbuild.com/Reference-manual_elementary_str.html#strreplace\n"},{"id":"516081","messageId":"Z_y_UWhY2RK3nBMm@pks.im","threadId":"63129","inReplyTo":"94a3083c-fcc5-4489-8612-c15fa781c0f9@ramsayjones.plus.com","subject":"Re: [PATCH v2 04/13] meson.build: set default help format to html on windows","fromName":"Patrick Steinhardt","fromEmail":"ps@pks.im","sentAt":"2025-04-14T07:54:57Z","receivedAt":"2025-04-14T07:55:01Z","isPatch":true,"sender":{"key":"ps@pks.im","avatar":"https://avatars.githubusercontent.com/u/4056630?v=4"},"body":"On Sun, Apr 06, 2025 at 09:16:58PM +0100, Ramsay Jones wrote:\n> [Just a note that the make build includes 'info' as a choice, but Patrick\n> made the decision earlier to drop that for the meson build. Also, there is\n> a 'pdf' make target (I think that made it once, years ago ...)]\n\nYeah, I just didn't find any distros where either of these were\ninstalled at all, so I didn't bother porting them over. Which doesn't\nmean that it has to stay this way if there actually are any users, but\nthis might also be a good opportunity to gauge interest in some of the\nmore esoteric parts of our build infra and potentially drop them if\nnobody complains.\n\nPatrick\n"},{"id":"516082","messageId":"Z_y_VeJzT82by8wg@pks.im","threadId":"63129","inReplyTo":"324bb213426ffc9c1f9cd155de309bd0b63cdbc4.1743859985.git.ramsay@ramsayjones.plus.com","subject":"Re: [PATCH v2 07/13] config.mak.uname: only set NO_REGEX on cygwin for v1.7","fromName":"Patrick Steinhardt","fromEmail":"ps@pks.im","sentAt":"2025-04-14T07:55:01Z","receivedAt":"2025-04-14T07:55:04Z","isPatch":true,"sender":{"key":"ps@pks.im","avatar":"https://avatars.githubusercontent.com/u/4056630?v=4"},"body":"On Sun, Apr 06, 2025 at 08:38:33PM +0100, Ramsay Jones wrote:\n> Commit 92f63d2b05 (\"Cygwin 1.7 needs compat/regex\", 2013-07-19) set\n> the NO_REGEX build variable because the platform regex library failed\n> some of the tests (t4018 and t4034), which passed just fine with the\n> compat library.\n> \n> After some time (maybe a year or two), the platform library had been\n> updated (with an import from FreeBSD, I believe) and now passed the full\n> test-suite. This would be about the time of the v1.7 -> v2.0 transition\n> in 2015. I had a patch ready to send, but just didn't get around to\n> submitting it to the list. At some point in the interim, the official\n> cygwin git package used the autoconf build system, which sets the\n> NO_REGEX variable to use the platform regex library functions. The new\n> meson build system does likewise.\n> \n> The cygwin platform regex library, in addition to now passing the tests\n> which formerly failed, now passes an 'test_expect_failure' test in the\n> t7815-grep-binary test file. In particular, test #12 'git grep .fi a'\n> which determines that the regex pattern '.' matches a NUL character.\n> The commit f96e56733a (\"grep: use REG_STARTEND for all matching if\n> available\", 2010-05-22) added the test in question, but it does not\n> give any indication as to why the test was framed as an expected fail,\n> rather than a 'positive' test that the 'git grep' command fails to\n> match a NUL. Note that the previous test #11 was also originally\n> marked in that commit as a 'test_expect_failure', but was flipped to\n> an 'success' test in commit 7e36de5859 (\"t/t7008-grep-binary.sh: un-TODO\n> a test that needs REG_STARTEND\", 2010-08-17).\n> \n> In order to produce the same NO_REGEX configuration from autoconf, meson\n> and make, modify config.mak.uname to only set NO_REGEX for cygwin v1.7.\n> In addition, skip test t7815.12 on cygwin, by adding the !CYGWIN pre-\n> requisite to the test header, which (among other things) removes an\n> '...; please update test(s)' comment.\n\nOut of curiosity, because I really don't know any better: why do we have\nto even care about such oldish Cygwin installations from more than 10\nyears ago? Wouldn't people generally update Cygwin every once in a while\nto have recent packages? Or is there a good reason why we should\ncontinue to support it?\n\nPatrick\n"},{"id":"516083","messageId":"Z_y_WbTyOXmR7ObU@pks.im","threadId":"63129","inReplyTo":"3bd6e40cd23b07b86b5db146a00bfa01458f2e04.1743859985.git.ramsay@ramsayjones.plus.com","subject":"Re: [PATCH v2 09/13] config.mak.uname: add clock_gettime() to the cygwin build","fromName":"Patrick Steinhardt","fromEmail":"ps@pks.im","sentAt":"2025-04-14T07:55:05Z","receivedAt":"2025-04-14T07:55:08Z","isPatch":true,"sender":{"key":"ps@pks.im","avatar":"https://avatars.githubusercontent.com/u/4056630?v=4"},"body":"On Sun, Apr 06, 2025 at 08:38:35PM +0100, Ramsay Jones wrote:\n> diff --git a/config.mak.uname b/config.mak.uname\n> index 1b3ba8a341..942550fb9e 100644\n> --- a/config.mak.uname\n> +++ b/config.mak.uname\n> @@ -251,6 +251,8 @@ ifeq ($(uname_O),Cygwin)\n>          endif\n>  \tHAVE_DEV_TTY = YesPlease\n>  \tHAVE_GETDELIM = YesPlease\n> +\tHAVE_CLOCK_GETTIME=YesPlease\n> +\tHAVE_CLOCK_MONOTONIC=YesPlease\n\nNit: let's also have spaces around the assignment operator.\n\n>  \tHAVE_ALLOCA_H = YesPlease\n>  \tNEEDS_LIBICONV = YesPlease\n>  \tNO_FAST_WORKING_DIRECTORY = UnfortunatelyYes\n\nPatrick\n"},{"id":"516084","messageId":"Z_y_XL2C_Za5SB5m@pks.im","threadId":"63129","inReplyTo":"a2eb9ab117c9a7ea8723c166739b30243388ea77.1743859985.git.ramsay@ramsayjones.plus.com","subject":"Re: [PATCH v2 10/13] builtin/gc.c: correct RAM calculation when using sysinfo","fromName":"Patrick Steinhardt","fromEmail":"ps@pks.im","sentAt":"2025-04-14T07:55:08Z","receivedAt":"2025-04-14T07:55:11Z","isPatch":true,"sender":{"key":"ps@pks.im","avatar":"https://avatars.githubusercontent.com/u/4056630?v=4"},"body":"On Sun, Apr 06, 2025 at 08:38:36PM +0100, Ramsay Jones wrote:\n> The man page for sysinfo(2) on Linux states that (from v2.3.48) the\n> sizes of the memory and swap fields, of the returned structure, are\n> given as multiples of 'mem_unit' bytes. In earlier versions (prior to\n> v2.3.23 on i386 in particular), the 'mem_unit' field was not part of\n> the structure, and all sizes were measured in bytes. The man page does\n> not discuss the motivation for this change, but it is possible that the\n> change was intended for the, relatively rare, 32-bit platform with more\n> than 4GB of memory.\n> \n> The total_ram() function makes the assumption that the 'totalram' field\n> of the 'struct sysinfo' is measured in bytes, or alternatively that the\n> 'mem_unit' field is always equal to one. Having writen a program to call\n> the sysinfo() function and print the structure fields, it seems that, on\n> Linux x84_64 and i686 anyway, the 'mem_unit' field is indeed set to one\n> (note that the 32-bit system had only 2GB ram). However, cygwin also has\n> an sysinfo() implementation, which gives the following values:\n> \n>   $ ./sysinfo\n>   uptime:      21381\n>   loads:       0, 0, 0\n>   total ram:   2074637\n>   free ram:    843237\n>   shared ram:  0\n>   buffer ram:  0\n>   total swap:  327680\n>   free swap:   306932\n>   procs:       15\n>   total high:  0\n>   free high:   0\n>   mem_unit:    4096\n> \n>   total ram: 8497713152\n>   $\n> \n> [This laptop has 8GB ram, so a little bit seems to be missing. ;) ]\n\nInteresting. I can confirm that `mem_unit` is 1 on my system, so this\ndoes not make a difference here. But my tests on Cygwin show the same\nbehaviour as on your system, so the patch looks reasonable to me.\n\n> Modify the total_ram() function to allow for the possibility that the\n> memory size is not specified in bytes (ie 'mem_unit' is greater than\n> one).\n> \n> Signed-off-by: Ramsay Jones <ramsay@ramsayjones.plus.com>\n> ---\n>  builtin/gc.c | 9 +++++++--\n>  1 file changed, 7 insertions(+), 2 deletions(-)\n> \n> diff --git a/builtin/gc.c b/builtin/gc.c\n> index 99431fd467..cdcf1dc6e7 100644\n> --- a/builtin/gc.c\n> +++ b/builtin/gc.c\n> @@ -373,8 +373,13 @@ static uint64_t total_ram(void)\n>  #if defined(HAVE_SYSINFO)\n>  \tstruct sysinfo si;\n>  \n> -\tif (!sysinfo(&si))\n> -\t\treturn si.totalram;\n> +\tif (!sysinfo(&si)) {\n> +\t\tuint64_t total = si.totalram;\n> +\n> +\t\tif (si.mem_unit > 1)\n> +\t\t\ttotal *= (uint64_t)si.mem_unit;\n> +\t\treturn total;\n> +\t}\n\nI expect that all systems have a proper value for `si.mem_unit` set so\nthat we could unconditionally multiplicate the fields with one another.\nBut it doesn't hurt either, so I don't mind the guarding clause.\n\nPatrick\n"},{"id":"516085","messageId":"Z_y_X8BlW_SojO11@pks.im","threadId":"63129","inReplyTo":"e45b9df3a43d0f862f1703a3af84c2a796e708f4.1743859985.git.ramsay@ramsayjones.plus.com","subject":"Re: [PATCH v2 11/13] config.mak.uname: add sysinfo() configuration for cygwin","fromName":"Patrick Steinhardt","fromEmail":"ps@pks.im","sentAt":"2025-04-14T07:55:11Z","receivedAt":"2025-04-14T07:55:15Z","isPatch":true,"sender":{"key":"ps@pks.im","avatar":"https://avatars.githubusercontent.com/u/4056630?v=4"},"body":"On Sun, Apr 06, 2025 at 08:38:37PM +0100, Ramsay Jones wrote:\n> Although sysinfo() is a 'Linux only' function, cygwin provides an\n> implementation which appears to be functional. The assumption that\n> this function is Linux only is reflected in the way the HAVE_SYSINFO\n> build variable is handled by the Makefile and config.mak.uname.\n> \n> Rework the setting of HAVE_SYSINFO in the Linux section of the system\n> specific config file, along with the corresponding setting of the\n> BASIC_CFLAGS in the Makefile. Add the setting of HAVE_SYSINFO to the\n> cygwin section of 'config.mak.uname'. While here, add a test for the\n> sysinfo() function to the autoconf build system.\n\nMakes sense. Meson already does this, so it doesn't need to be adjusted.\n\nPatrick\n"},{"id":"516122","messageId":"7c5a2998-fe71-495f-8841-64e5b2ad03f2@ramsayjones.plus.com","threadId":"63129","inReplyTo":"Z_y_Tp5pfJ-gZLEF@pks.im","subject":"Re: [-SPAM-] Re: [PATCH v2 03/13] meson.build: only set build variables for non-default values","fromName":"Ramsay Jones","fromEmail":"ramsay@ramsayjones.plus.com","sentAt":"2025-04-14T19:19:15Z","receivedAt":"2025-04-14T19:22:27Z","isPatch":true,"sender":{"key":"ramsay@ramsayjones.plus.com","avatar":"https://avatars.githubusercontent.com/u/33702710?v=4"},"body":"\n\nOn 14/04/2025 08:54, Patrick Steinhardt wrote:\n> On Sun, Apr 06, 2025 at 08:49:54PM +0100, Ramsay Jones wrote:\n>>\n>>\n>> On 06/04/2025 20:38, Ramsay Jones wrote:\n>> [snip]\n>>> diff --git a/meson.build b/meson.build\n>>> index 88a29fd043..efd0bd3319 100644\n>>> --- a/meson.build\n>>> +++ b/meson.build\n>>> @@ -693,10 +693,8 @@ endif\n>>>  # These variables are used for building libgit.a.\n>>>  libgit_c_args = [\n>>>    '-DBINDIR=\"' + get_option('bindir') + '\"',\n>>> -  '-DDEFAULT_EDITOR=\"' + get_option('default_editor') + '\"',\n>>>    '-DDEFAULT_GIT_TEMPLATE_DIR=\"' + get_option('datadir') / 'git-core/templates' + '\"',\n>>>    '-DDEFAULT_HELP_FORMAT=\"' + get_option('default_help_format') + '\"',\n>>> -  '-DDEFAULT_PAGER=\"' + get_option('default_pager') + '\"',\n>>>    '-DETC_GITATTRIBUTES=\"' + get_option('gitattributes') + '\"',\n>>>    '-DETC_GITCONFIG=\"' + get_option('gitconfig') + '\"',\n>>>    '-DFALLBACK_RUNTIME_PREFIX=\"' + get_option('prefix') + '\"',\n>>> @@ -708,6 +706,17 @@ libgit_c_args = [\n>>>    '-DPAGER_ENV=\"' + get_option('pager_environment') + '\"',\n>>>    '-DSHELL_PATH=\"' + fs.as_posix(shell.full_path()) + '\"',\n>>>  ]\n>>> +\n>>> +editor_opt = get_option('default_editor')\n>>> +if editor_opt != '' and editor_opt != 'vi'\n>>> +  libgit_c_args += '-DDEFAULT_EDITOR=\"' + editor_opt + '\"'\n>>> +endif\n>>> +\n>>> +pager_opt = get_option('default_pager')\n>>> +if pager_opt != '' and pager_opt != 'less'\n>>> +  libgit_c_args += '-DDEFAULT_PAGER=\"' + pager_opt + '\"'\n>>> +endif\n>>> +\n>>>  libgit_include_directories = [ '.' ]\n>>>  libgit_dependencies = [ ]\n>>>  \n>>\n>>\n>> It would be somewhat remiss of me to not mention here that this does not\n>> work for any but the simplest of values! :( If you set a simple single\n>> 'bareword' like 'vim' or 'more' (even '~/bin/vi') then every thing works\n>> just fine. However, if the value contains any of (at least) the following\n>> characters: single quote, double quote or backslash, then things\n>> stop working!\n>>\n>> [I spent one whole evening (and a bit - always something else to 'try')\n>> trying to 'fix' this problem, without success]\n> \n> Shouldn't it be possible to escape these values via `.replace()` [1]? I\n> suspect that you already tried, but wanted to ask anyway :)\n\nYep. :)\n\nI still haven't studied the meson documentation, but when I searched\nfor variations of 'quotes', the results showed that '... if you want\nquotes, you will have to do it yourself ...'. So, I eventually found\n'.replace()' in the 'string operations' section of the docs and tried\nto reproduce what the Makefile does (see #2382):\n\n\n  ifdef DEFAULT_EDITOR\n  DEFAULT_EDITOR_CQ = \"$(subst \",\\\",$(subst \\,\\\\,$(DEFAULT_EDITOR)))\"\n  DEFAULT_EDITOR_CQ_SQ = $(subst ','\\'',$(DEFAULT_EDITOR_CQ))\n\n  BASIC_CFLAGS += -DDEFAULT_EDITOR='$(DEFAULT_EDITOR_CQ_SQ)'\n  endif\n\nwhich I translated into (on top of these patches):\n\n  diff --git a/meson.build b/meson.build\n  index 8f8a258064..608d665fd3 100644\n  --- a/meson.build\n  +++ b/meson.build\n  @@ -708,7 +708,11 @@ libgit_c_args = [\n \n   editor_opt = get_option('default_editor')\n   if editor_opt != '' and editor_opt != 'vi'\n  -  libgit_c_args += '-DDEFAULT_EDITOR=\"' + editor_opt + '\"'\n  +  editor_opt = editor_opt.replace('\\\\', '\\\\\\\\')\n  +  editor_opt = editor_opt.replace('\"', '\\\"')\n  +  editor_opt = '\"' + editor_opt + '\"'\n  +  editor_opt = editor_opt.replace('\\'', '\\\\\\'')\n  +  libgit_c_args += '-DDEFAULT_EDITOR=' + editor_opt\n   endif\n \n[Actually, I think the very first attempt had:\n\n  libgit_c_args += '-DDEFAULT_EDITOR=\\'' + editor_opt + '\\''\n\nbut meson, for some reason, adds a set of ' around the whole\n-D argument to gcc, so I got rid of them - but it still didn't\nwork!]\n\nAlong with many, many, *many* such permutations! (trying to debug\nthis is hard work, with no help from meson).\n\nSo, just a little earlier this evening I read an email from Karthik\n([PATCH v2 3/4] meson: add support for 'hdr-check') in which he\nmentioned a problem with backslashes and referenced a github issue\non the mesonbuild repo [0], which is worth a read. ;)\n\nSorry I couldn't fix this issue, but it seems to be (in part) an issue\nwith meson. (Of course the example I used, which is taken directly\nfrom the Makefile, happens to be particularly good at demonstrating\nthe problem!)\n\nIn any event, I think the current patch is a strict improvement, even\nif it may need to be updated at a later date. I hope you agree.\n\nThank you for taking the time to review this series. I think this patch\nwas the only review comment that required a response - please let me\nknow, if that is not the case!\n\nThanks!\n\nATB,\nRamsay Jones\n\n[0]: https://github.com/mesonbuild/meson/issues/1564\n\n\n"},{"id":"516127","messageId":"db92840f-ed4a-46b7-aba0-b556ed33af6f@ramsayjones.plus.com","threadId":"63129","inReplyTo":"Z_y_VeJzT82by8wg@pks.im","subject":"Re: [-SPAM-] Re: [PATCH v2 07/13] config.mak.uname: only set NO_REGEX on cygwin for v1.7","fromName":"Ramsay Jones","fromEmail":"ramsay@ramsayjones.plus.com","sentAt":"2025-04-14T20:03:30Z","receivedAt":"2025-04-14T20:03:34Z","isPatch":true,"sender":{"key":"ramsay@ramsayjones.plus.com","avatar":"https://avatars.githubusercontent.com/u/33702710?v=4"},"body":"\n\nOn 14/04/2025 08:55, Patrick Steinhardt wrote:\n> On Sun, Apr 06, 2025 at 08:38:33PM +0100, Ramsay Jones wrote:\n>> Commit 92f63d2b05 (\"Cygwin 1.7 needs compat/regex\", 2013-07-19) set\n>> the NO_REGEX build variable because the platform regex library failed\n>> some of the tests (t4018 and t4034), which passed just fine with the\n>> compat library.\n>>\n>> After some time (maybe a year or two), the platform library had been\n>> updated (with an import from FreeBSD, I believe) and now passed the full\n>> test-suite. This would be about the time of the v1.7 -> v2.0 transition\n>> in 2015. I had a patch ready to send, but just didn't get around to\n>> submitting it to the list. At some point in the interim, the official\n>> cygwin git package used the autoconf build system, which sets the\n>> NO_REGEX variable to use the platform regex library functions. The new\n>> meson build system does likewise.\n>>\n>> The cygwin platform regex library, in addition to now passing the tests\n>> which formerly failed, now passes an 'test_expect_failure' test in the\n>> t7815-grep-binary test file. In particular, test #12 'git grep .fi a'\n>> which determines that the regex pattern '.' matches a NUL character.\n>> The commit f96e56733a (\"grep: use REG_STARTEND for all matching if\n>> available\", 2010-05-22) added the test in question, but it does not\n>> give any indication as to why the test was framed as an expected fail,\n>> rather than a 'positive' test that the 'git grep' command fails to\n>> match a NUL. Note that the previous test #11 was also originally\n>> marked in that commit as a 'test_expect_failure', but was flipped to\n>> an 'success' test in commit 7e36de5859 (\"t/t7008-grep-binary.sh: un-TODO\n>> a test that needs REG_STARTEND\", 2010-08-17).\n>>\n>> In order to produce the same NO_REGEX configuration from autoconf, meson\n>> and make, modify config.mak.uname to only set NO_REGEX for cygwin v1.7.\n>> In addition, skip test t7815.12 on cygwin, by adding the !CYGWIN pre-\n>> requisite to the test header, which (among other things) removes an\n>> '...; please update test(s)' comment.\n> \n> Out of curiosity, because I really don't know any better: why do we have\n> to even care about such oldish Cygwin installations from more than 10\n> years ago? Wouldn't people generally update Cygwin every once in a while\n> to have recent packages? Or is there a good reason why we should\n> continue to support it?\n\nHeh, as I said in response to Junio, I have a patch that removes all\nof the config in the conditional, so that we would no longer support\nany 'pre-v2.x' versions of cygwin[*]. I think that would be an entirely\nreasonable thing to do, particularly as cygwin thinks of itself as\na 'rolling release' type distribution. ;)\n\nHowever, I don't think it is my place to make that kind of decision\nand I was leaving that patch until last. Hopefully, Adam will make\nthat call. :)\n\nThanks.\n\nATB,\nRamsay Jones\n\n[*] Note, even *with* that config in place, I have no idea if pre-v2.x\nversions would even compile!\n\n\n\n"},{"id":"516128","messageId":"39bd9980-0009-4b2e-a8e8-b07b0013c2ec@ramsayjones.plus.com","threadId":"63129","inReplyTo":"Z_y_WbTyOXmR7ObU@pks.im","subject":"Re: [-SPAM-] Re: [PATCH v2 09/13] config.mak.uname: add clock_gettime() to the cygwin build","fromName":"Ramsay Jones","fromEmail":"ramsay@ramsayjones.plus.com","sentAt":"2025-04-14T20:05:02Z","receivedAt":"2025-04-14T20:05:06Z","isPatch":true,"sender":{"key":"ramsay@ramsayjones.plus.com","avatar":"https://avatars.githubusercontent.com/u/33702710?v=4"},"body":"\n\nOn 14/04/2025 08:55, Patrick Steinhardt wrote:\n> On Sun, Apr 06, 2025 at 08:38:35PM +0100, Ramsay Jones wrote:\n>> diff --git a/config.mak.uname b/config.mak.uname\n>> index 1b3ba8a341..942550fb9e 100644\n>> --- a/config.mak.uname\n>> +++ b/config.mak.uname\n>> @@ -251,6 +251,8 @@ ifeq ($(uname_O),Cygwin)\n>>          endif\n>>  \tHAVE_DEV_TTY = YesPlease\n>>  \tHAVE_GETDELIM = YesPlease\n>> +\tHAVE_CLOCK_GETTIME=YesPlease\n>> +\tHAVE_CLOCK_MONOTONIC=YesPlease\n> \n> Nit: let's also have spaces around the assignment operator.\n\nAh, yes, I forgot this one. If I need to re-roll, then I can\nadjust this.\n\nThanks.\n\nATB,\nRamsay Jones\n\n> \n>>  \tHAVE_ALLOCA_H = YesPlease\n>>  \tNEEDS_LIBICONV = YesPlease\n>>  \tNO_FAST_WORKING_DIRECTORY = UnfortunatelyYes\n> \n> Patrick\n> \n\n"},{"id":"516138","messageId":"fb967067-ece7-4791-aa43-65b95ccd4cac@ramsayjones.plus.com","threadId":"63129","inReplyTo":"Z_y_XL2C_Za5SB5m@pks.im","subject":"Re: [-SPAM-] Re: [PATCH v2 10/13] builtin/gc.c: correct RAM calculation when using sysinfo","fromName":"Ramsay Jones","fromEmail":"ramsay@ramsayjones.plus.com","sentAt":"2025-04-14T20:11:59Z","receivedAt":"2025-04-14T20:12:02Z","isPatch":true,"sender":{"key":"ramsay@ramsayjones.plus.com","avatar":"https://avatars.githubusercontent.com/u/33702710?v=4"},"body":"\n\nOn 14/04/2025 08:55, Patrick Steinhardt wrote:\n> On Sun, Apr 06, 2025 at 08:38:36PM +0100, Ramsay Jones wrote:\n>> The man page for sysinfo(2) on Linux states that (from v2.3.48) the\n>> sizes of the memory and swap fields, of the returned structure, are\n>> given as multiples of 'mem_unit' bytes. In earlier versions (prior to\n>> v2.3.23 on i386 in particular), the 'mem_unit' field was not part of\n>> the structure, and all sizes were measured in bytes. The man page does\n>> not discuss the motivation for this change, but it is possible that the\n>> change was intended for the, relatively rare, 32-bit platform with more\n>> than 4GB of memory.\n>>\n>> The total_ram() function makes the assumption that the 'totalram' field\n>> of the 'struct sysinfo' is measured in bytes, or alternatively that the\n>> 'mem_unit' field is always equal to one. Having writen a program to call\n>> the sysinfo() function and print the structure fields, it seems that, on\n>> Linux x84_64 and i686 anyway, the 'mem_unit' field is indeed set to one\n>> (note that the 32-bit system had only 2GB ram). However, cygwin also has\n>> an sysinfo() implementation, which gives the following values:\n>>\n>>   $ ./sysinfo\n>>   uptime:      21381\n>>   loads:       0, 0, 0\n>>   total ram:   2074637\n>>   free ram:    843237\n>>   shared ram:  0\n>>   buffer ram:  0\n>>   total swap:  327680\n>>   free swap:   306932\n>>   procs:       15\n>>   total high:  0\n>>   free high:   0\n>>   mem_unit:    4096\n>>\n>>   total ram: 8497713152\n>>   $\n>>\n>> [This laptop has 8GB ram, so a little bit seems to be missing. ;) ]\n> \n> Interesting. I can confirm that `mem_unit` is 1 on my system, so this\n> does not make a difference here. But my tests on Cygwin show the same\n> behaviour as on your system, so the patch looks reasonable to me.\n> \n>> Modify the total_ram() function to allow for the possibility that the\n>> memory size is not specified in bytes (ie 'mem_unit' is greater than\n>> one).\n>>\n>> Signed-off-by: Ramsay Jones <ramsay@ramsayjones.plus.com>\n>> ---\n>>  builtin/gc.c | 9 +++++++--\n>>  1 file changed, 7 insertions(+), 2 deletions(-)\n>>\n>> diff --git a/builtin/gc.c b/builtin/gc.c\n>> index 99431fd467..cdcf1dc6e7 100644\n>> --- a/builtin/gc.c\n>> +++ b/builtin/gc.c\n>> @@ -373,8 +373,13 @@ static uint64_t total_ram(void)\n>>  #if defined(HAVE_SYSINFO)\n>>  \tstruct sysinfo si;\n>>  \n>> -\tif (!sysinfo(&si))\n>> -\t\treturn si.totalram;\n>> +\tif (!sysinfo(&si)) {\n>> +\t\tuint64_t total = si.totalram;\n>> +\n>> +\t\tif (si.mem_unit > 1)\n>> +\t\t\ttotal *= (uint64_t)si.mem_unit;\n>> +\t\treturn total;\n>> +\t}\n> \n> I expect that all systems have a proper value for `si.mem_unit` set so\n> that we could unconditionally multiplicate the fields with one another.\n> But it doesn't hurt either, so I don't mind the guarding clause.\n\nHmm, you may well be right, but I prefer to be cautious here.\n\nThanks.\n\nATB,\nRamsay Jones\n\n"},{"id":"516160","messageId":"Z_31noB-CAqtYOd2@pks.im","threadId":"63129","inReplyTo":"7c5a2998-fe71-495f-8841-64e5b2ad03f2@ramsayjones.plus.com","subject":"Re: [-SPAM-] Re: [PATCH v2 03/13] meson.build: only set build variables for non-default values","fromName":"Patrick Steinhardt","fromEmail":"ps@pks.im","sentAt":"2025-04-15T05:59:38Z","receivedAt":"2025-04-15T05:59:45Z","isPatch":true,"sender":{"key":"ps@pks.im","avatar":"https://avatars.githubusercontent.com/u/4056630?v=4"},"body":"On Mon, Apr 14, 2025 at 08:19:15PM +0100, Ramsay Jones wrote:\n> \n> \n> On 14/04/2025 08:54, Patrick Steinhardt wrote:\n> > On Sun, Apr 06, 2025 at 08:49:54PM +0100, Ramsay Jones wrote:\n> >>\n> >>\n> >> On 06/04/2025 20:38, Ramsay Jones wrote:\n> >> [snip]\n> >>> diff --git a/meson.build b/meson.build\n> >>> index 88a29fd043..efd0bd3319 100644\n> >>> --- a/meson.build\n> >>> +++ b/meson.build\n> >>> @@ -693,10 +693,8 @@ endif\n> >>>  # These variables are used for building libgit.a.\n> >>>  libgit_c_args = [\n> >>>    '-DBINDIR=\"' + get_option('bindir') + '\"',\n> >>> -  '-DDEFAULT_EDITOR=\"' + get_option('default_editor') + '\"',\n> >>>    '-DDEFAULT_GIT_TEMPLATE_DIR=\"' + get_option('datadir') / 'git-core/templates' + '\"',\n> >>>    '-DDEFAULT_HELP_FORMAT=\"' + get_option('default_help_format') + '\"',\n> >>> -  '-DDEFAULT_PAGER=\"' + get_option('default_pager') + '\"',\n> >>>    '-DETC_GITATTRIBUTES=\"' + get_option('gitattributes') + '\"',\n> >>>    '-DETC_GITCONFIG=\"' + get_option('gitconfig') + '\"',\n> >>>    '-DFALLBACK_RUNTIME_PREFIX=\"' + get_option('prefix') + '\"',\n> >>> @@ -708,6 +706,17 @@ libgit_c_args = [\n> >>>    '-DPAGER_ENV=\"' + get_option('pager_environment') + '\"',\n> >>>    '-DSHELL_PATH=\"' + fs.as_posix(shell.full_path()) + '\"',\n> >>>  ]\n> >>> +\n> >>> +editor_opt = get_option('default_editor')\n> >>> +if editor_opt != '' and editor_opt != 'vi'\n> >>> +  libgit_c_args += '-DDEFAULT_EDITOR=\"' + editor_opt + '\"'\n> >>> +endif\n> >>> +\n> >>> +pager_opt = get_option('default_pager')\n> >>> +if pager_opt != '' and pager_opt != 'less'\n> >>> +  libgit_c_args += '-DDEFAULT_PAGER=\"' + pager_opt + '\"'\n> >>> +endif\n> >>> +\n> >>>  libgit_include_directories = [ '.' ]\n> >>>  libgit_dependencies = [ ]\n> >>>  \n> >>\n> >>\n> >> It would be somewhat remiss of me to not mention here that this does not\n> >> work for any but the simplest of values! :( If you set a simple single\n> >> 'bareword' like 'vim' or 'more' (even '~/bin/vi') then every thing works\n> >> just fine. However, if the value contains any of (at least) the following\n> >> characters: single quote, double quote or backslash, then things\n> >> stop working!\n> >>\n> >> [I spent one whole evening (and a bit - always something else to 'try')\n> >> trying to 'fix' this problem, without success]\n> > \n> > Shouldn't it be possible to escape these values via `.replace()` [1]? I\n> > suspect that you already tried, but wanted to ask anyway :)\n> \n> Yep. :)\n> \n> I still haven't studied the meson documentation, but when I searched\n> for variations of 'quotes', the results showed that '... if you want\n> quotes, you will have to do it yourself ...'. So, I eventually found\n> '.replace()' in the 'string operations' section of the docs and tried\n> to reproduce what the Makefile does (see #2382):\n> \n> \n>   ifdef DEFAULT_EDITOR\n>   DEFAULT_EDITOR_CQ = \"$(subst \",\\\",$(subst \\,\\\\,$(DEFAULT_EDITOR)))\"\n>   DEFAULT_EDITOR_CQ_SQ = $(subst ','\\'',$(DEFAULT_EDITOR_CQ))\n> \n>   BASIC_CFLAGS += -DDEFAULT_EDITOR='$(DEFAULT_EDITOR_CQ_SQ)'\n>   endif\n> \n> which I translated into (on top of these patches):\n> \n>   diff --git a/meson.build b/meson.build\n>   index 8f8a258064..608d665fd3 100644\n>   --- a/meson.build\n>   +++ b/meson.build\n>   @@ -708,7 +708,11 @@ libgit_c_args = [\n>  \n>    editor_opt = get_option('default_editor')\n>    if editor_opt != '' and editor_opt != 'vi'\n>   -  libgit_c_args += '-DDEFAULT_EDITOR=\"' + editor_opt + '\"'\n>   +  editor_opt = editor_opt.replace('\\\\', '\\\\\\\\')\n>   +  editor_opt = editor_opt.replace('\"', '\\\"')\n>   +  editor_opt = '\"' + editor_opt + '\"'\n>   +  editor_opt = editor_opt.replace('\\'', '\\\\\\'')\n>   +  libgit_c_args += '-DDEFAULT_EDITOR=' + editor_opt\n>    endif\n>  \n> [Actually, I think the very first attempt had:\n> \n>   libgit_c_args += '-DDEFAULT_EDITOR=\\'' + editor_opt + '\\''\n> \n> but meson, for some reason, adds a set of ' around the whole\n> -D argument to gcc, so I got rid of them - but it still didn't\n> work!]\n> \n> Along with many, many, *many* such permutations! (trying to debug\n> this is hard work, with no help from meson).\n> \n> So, just a little earlier this evening I read an email from Karthik\n> ([PATCH v2 3/4] meson: add support for 'hdr-check') in which he\n> mentioned a problem with backslashes and referenced a github issue\n> on the mesonbuild repo [0], which is worth a read. ;)\n> \n> Sorry I couldn't fix this issue, but it seems to be (in part) an issue\n> with meson. (Of course the example I used, which is taken directly\n> from the Makefile, happens to be particularly good at demonstrating\n> the problem!)\n\nFair enough. Maybe I'll try to upstream a feature like this into Meson.\nIt would be nice to have a `.quoted()` method on `str`, and it shouldn't\nbe hard to do.\n\n> In any event, I think the current patch is a strict improvement, even\n> if it may need to be updated at a later date. I hope you agree.\n\nAgreed.\n\n> Thank you for taking the time to review this series. I think this patch\n> was the only review comment that required a response - please let me\n> know, if that is not the case!\n\nYup. The only other thing was missing spaces around assignment\noperators, but that alone doesn't feel like it's worth a reroll.\n\nThanks!\n\nPatrick\n"},{"id":"516161","messageId":"Z_310iVKmhrl0UGE@pks.im","threadId":"63129","inReplyTo":"db92840f-ed4a-46b7-aba0-b556ed33af6f@ramsayjones.plus.com","subject":"Re: [-SPAM-] Re: [PATCH v2 07/13] config.mak.uname: only set NO_REGEX on cygwin for v1.7","fromName":"Patrick Steinhardt","fromEmail":"ps@pks.im","sentAt":"2025-04-15T05:59:46Z","receivedAt":"2025-04-15T05:59:50Z","isPatch":true,"sender":{"key":"ps@pks.im","avatar":"https://avatars.githubusercontent.com/u/4056630?v=4"},"body":"On Mon, Apr 14, 2025 at 09:03:30PM +0100, Ramsay Jones wrote:\n> On 14/04/2025 08:55, Patrick Steinhardt wrote:\n> > On Sun, Apr 06, 2025 at 08:38:33PM +0100, Ramsay Jones wrote:\n> >> Commit 92f63d2b05 (\"Cygwin 1.7 needs compat/regex\", 2013-07-19) set\n> >> the NO_REGEX build variable because the platform regex library failed\n> >> some of the tests (t4018 and t4034), which passed just fine with the\n> >> compat library.\n> >>\n> >> After some time (maybe a year or two), the platform library had been\n> >> updated (with an import from FreeBSD, I believe) and now passed the full\n> >> test-suite. This would be about the time of the v1.7 -> v2.0 transition\n> >> in 2015. I had a patch ready to send, but just didn't get around to\n> >> submitting it to the list. At some point in the interim, the official\n> >> cygwin git package used the autoconf build system, which sets the\n> >> NO_REGEX variable to use the platform regex library functions. The new\n> >> meson build system does likewise.\n> >>\n> >> The cygwin platform regex library, in addition to now passing the tests\n> >> which formerly failed, now passes an 'test_expect_failure' test in the\n> >> t7815-grep-binary test file. In particular, test #12 'git grep .fi a'\n> >> which determines that the regex pattern '.' matches a NUL character.\n> >> The commit f96e56733a (\"grep: use REG_STARTEND for all matching if\n> >> available\", 2010-05-22) added the test in question, but it does not\n> >> give any indication as to why the test was framed as an expected fail,\n> >> rather than a 'positive' test that the 'git grep' command fails to\n> >> match a NUL. Note that the previous test #11 was also originally\n> >> marked in that commit as a 'test_expect_failure', but was flipped to\n> >> an 'success' test in commit 7e36de5859 (\"t/t7008-grep-binary.sh: un-TODO\n> >> a test that needs REG_STARTEND\", 2010-08-17).\n> >>\n> >> In order to produce the same NO_REGEX configuration from autoconf, meson\n> >> and make, modify config.mak.uname to only set NO_REGEX for cygwin v1.7.\n> >> In addition, skip test t7815.12 on cygwin, by adding the !CYGWIN pre-\n> >> requisite to the test header, which (among other things) removes an\n> >> '...; please update test(s)' comment.\n> > \n> > Out of curiosity, because I really don't know any better: why do we have\n> > to even care about such oldish Cygwin installations from more than 10\n> > years ago? Wouldn't people generally update Cygwin every once in a while\n> > to have recent packages? Or is there a good reason why we should\n> > continue to support it?\n> \n> Heh, as I said in response to Junio, I have a patch that removes all\n> of the config in the conditional, so that we would no longer support\n> any 'pre-v2.x' versions of cygwin[*]. I think that would be an entirely\n> reasonable thing to do, particularly as cygwin thinks of itself as\n> a 'rolling release' type distribution. ;)\n> \n> However, I don't think it is my place to make that kind of decision\n> and I was leaving that patch until last. Hopefully, Adam will make\n> that call. :)\n\nMakes sense, it's a bigger discussion indeed. I do think it would be\nreasonable to drop pre-2.0 Cygwin, and we have recently become a bit\nmore aggressive in dropping support for ancient OS versions. But I'm\ntotally fine with not doing it now.\n\nPatrick\n"},{"id":"516201","messageId":"xmqqfri9o47t.fsf@gitster.g","threadId":"63129","inReplyTo":"Z_310iVKmhrl0UGE@pks.im","subject":"Re: [-SPAM-] Re: [PATCH v2 07/13] config.mak.uname: only set NO_REGEX on cygwin for v1.7","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2025-04-15T15:05:10Z","receivedAt":"2025-04-15T15:05:14Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Patrick Steinhardt <ps@pks.im> writes:\n\n> On Mon, Apr 14, 2025 at 09:03:30PM +0100, Ramsay Jones wrote:\n>> Heh, as I said in response to Junio, I have a patch that removes all\n>> of the config in the conditional, so that we would no longer support\n>> any 'pre-v2.x' versions of cygwin[*]. I think that would be an entirely\n>> reasonable thing to do, particularly as cygwin thinks of itself as\n>> a 'rolling release' type distribution. ;)\n>> \n>> However, I don't think it is my place to make that kind of decision\n>> and I was leaving that patch until last. Hopefully, Adam will make\n>> that call. :)\n>\n> Makes sense, it's a bigger discussion indeed. I do think it would be\n> reasonable to drop pre-2.0 Cygwin, and we have recently become a bit\n> more aggressive in dropping support for ancient OS versions. But I'm\n> totally fine with not doing it now.\n\nSurely, and thanks.\n\nIf Adam declares that pre-2.0 is no longer relevant to us, I am fine\ndropping support for it.  The fewer knobs to tweak we have, the\nbetter.\n\nI do not know what the best plan is for changes to update things\nthat supposedly help supporting pre-2.0 boxes, without us being able\nto test, though.  I think I am OK with \"this patchset I try to cover\neverybody, but this and that systems are untested and untestable by\nme\" and I am also OK with \"this patchset does not address this and\nthat systems at all, as there is no way to test them by me\".\n\nThanks.\n"},{"id":"516313","messageId":"20250416231835.2492562-1-ramsay@ramsayjones.plus.com","threadId":"63129","inReplyTo":"cover.1743859985.git.ramsay@ramsayjones.plus.com","subject":"[PATCH v3 00/13] miscellaneous build mods (part 1)","fromName":"Ramsay Jones","fromEmail":"ramsay@ramsayjones.plus.com","sentAt":"2025-04-16T23:18:21Z","receivedAt":"2025-04-16T23:19:02Z","isPatch":true,"sender":{"key":"ramsay@ramsayjones.plus.com","avatar":"https://avatars.githubusercontent.com/u/33702710?v=4"},"body":"changes in v3:\n--------------\n\n- patch #9 adds some whitespace around the '=' sign in the\n  assignment to HAVE_CLOCK_GETTIME and HAVE_CLOCK_MONOTONIC\n  build variables\n\nThe range-diff below was generated with a 'creation-factor'\nof 80%, otherwise patches after #9 are shown as complete\nre-writes.\n\nI have built and tested both the make and meson builds on Linux,\nalong with the make build and meson build and test on cygwin.\n(A 'make test' on cygwin takes 6 hours, so I will test that\ntomorrow and let you know if it fails! ;) Highly unlikely to\nfail, since the v2 patches passed just fine).\n\nchanges in v2:\n--------------\n\n- patch #3 has been split into two (new patches #3,4). The motivation\n  for the original patch seems not to have been too obvious. The new\n  patch #3 combines the suppressing the -Defines for standard default\n  values for editor and pager, with the setting of the missing docs\n  attributes. The new patch #4 combines the suppressing of the -Define\n  for the default-help-format, with the overriding of the default value\n  on the windows platform.\n\n- patch #6 (new #7) updates the commit message along with skipping the\n  'failing' test #12 in t7815-grep-binary.sh on cygwin. (With the cygwin\n  platform regex library the '.' pattern matches a NUL character).\n\n- patch #11 (new #12) fixes a simple typo in the patch subject.\n\n- patch #12 (new #13) updates the commit message and makes a choice for\n  the default CSPRNG_METHOD on Linux; 'getrandom' as advised by Brian\n  here [0].\n\n[0] https://lore.kernel.org/git/Z9YbJFJjtXNYnTzk@tapette.crustytoothpaste.net/\n\nAs before, this series is based on commit 683c54c999 (\"Git 2.49\", 2025-03-14).\n\nAlso, I did a test merge to 'master'@5b97a56fa0, 'next'@ff1f9ca942 and\n'seen'@1b09671a54 and they all 'auto-merged' without issue.\n\nAs an experiment, I am using 'git sendemail' to send this series for the\nfirst time (I have sent single patches before, but not a series), so if\nanything goes awry I apologize in advance! :)\n\nA range-diff is given below.\n\n\nThe original v1 cover-letter follows:\n-------------------------------------\n\nThis series contains some miscellaneous changes to the make, meson and\nautoconf build systems. These are only the patches I have managed to\nwrite a commit message for; I have some others with no commit message,\nsome need more testing and others are yet to be written. (So, there will\nbe a 'part #2' series later... :) ).\n\n(I have notes from a couple of months ago - as an example, I have a note\nthat the meson build incorrectly sets ETC_GITATTRIBUTES and ETC_GITCONFIG\nto e.g. '/etc/gitattributes' rather than 'etc/gitattributes').\n\nThis series is based on the master branch at commit 683c54c999 (\"Git 2.49\",\n2025-03-14).\n\nAs a simple means for comparing the build products, we can compare the\nsymbols exported by git. So, starting at current master:\n\n  $ git checkout master\n  Switched to branch 'master'\n  Your branch is up-to-date with 'origin/master'.\n  $ git describe\n  v2.49.0\n  $ \n\n  $ make >out 2>&1\n  $ \n\n  $ meson setup build/\n  The Meson build system\n  ...\n  Found ninja-1.11.1 at /usr/bin/ninja\n  $ \n\n  $ cd build\n  $ meson compile\n  INFO: autodetecting backend as ninja\n  INFO: calculating backend command to run: /usr/bin/ninja\n  [661/661] Copying file contrib/completion/git-completion.zsh\n  $ cd ..\n  $ \n\n  $ rm *.syms\n  $ ./syms.pl git >git.syms 2>/dev/null\n  $ ./syms.pl build/git >mgit.syms 2>/dev/null\n  $ \n\n  $ diff git.syms mgit.syms\n  88a89\n  > U -- arc4random_buf@GLIBC_2.36\n  98a100,101\n  > U -- atoi@GLIBC_2.2.5\n  > U -- atol@GLIBC_2.2.5\n  195a199\n  > U -- bsearch@GLIBC_2.2.5\n  586,587d589\n  < U -- dcgettext@GLIBC_2.2.5\n  < U -- dcngettext@GLIBC_2.2.5\n  746,747c748,749\n  < B -- __environ@GLIBC_2.2.5\n  < V -- environ@GLIBC_2.2.5\n  ---\n  > U -- __environ@GLIBC_2.2.5\n  > U -- environ@GLIBC_2.2.5\n  909c911\n  < U -- __fprintf_chk@GLIBC_2.3.4\n  ---\n  > U -- fprintf@GLIBC_2.2.5\n  914d915\n  < U -- __fread_chk@GLIBC_2.7\n  1007c1008\n  < U -- getc@GLIBC_2.2.5\n  ---\n  > U -- getchar@GLIBC_2.2.5\n  1018a1020\n  > U -- getc_unlocked@GLIBC_2.2.5\n  1107a1110\n  > U -- gettext@GLIBC_2.2.5\n  1253d1255\n  < T -- gitstrlcpy\n  1355a1358\n  > U -- htons@GLIBC_2.2.5\n  1666d1668\n  < U -- __memcpy_chk@GLIBC_2.3.4\n  1673d1674\n  < U -- __memmove_chk@GLIBC_2.3.4\n  1684d1684\n  < U -- __memset_chk@GLIBC_2.3.4\n  1737a1738\n  > U -- ngettext@GLIBC_2.2.5\n  1759a1761\n  > U -- ntohs@GLIBC_2.2.5\n  1819d1820\n  < U -- __open64_2@GLIBC_2.7\n  1988a1990,2007\n  > U -- pcre2_code_free_8\n  > U -- pcre2_compile_8\n  > U -- pcre2_compile_context_create_8\n  > U -- pcre2_compile_context_free_8\n  > U -- pcre2_config_8\n  > U -- pcre2_general_context_create_8\n  > U -- pcre2_general_context_free_8\n  > U -- pcre2_get_error_message_8\n  > U -- pcre2_get_ovector_pointer_8\n  > U -- pcre2_jit_compile_8\n  > U -- pcre2_jit_match_8\n  > U -- pcre2_maketables_8\n  > U -- pcre2_maketables_free_8\n  > U -- pcre2_match_8\n  > U -- pcre2_match_data_create_from_pattern_8\n  > U -- pcre2_match_data_free_8\n  > U -- pcre2_pattern_info_8\n  > U -- pcre2_set_character_tables_8\n  2045c2064\n  < U -- __printf_chk@GLIBC_2.3.4\n  ---\n  > U -- printf@GLIBC_2.2.5\n  2080a2100\n  > U -- pthread_equal@GLIBC_2.2.5\n  2767c2787\n  < U -- __snprintf_chk@GLIBC_2.3.4\n  ---\n  > U -- snprintf@GLIBC_2.2.5\n  2925a2946\n  > U -- strlcpy@GLIBC_2.38\n  3185d3205\n  < U -- __uflow@GLIBC_2.2.5\n  3289,3290c3309,3311\n  < U -- __vfprintf_chk@GLIBC_2.3.4\n  < U -- __vsnprintf_chk@GLIBC_2.3.4\n  ---\n  > U -- vfprintf@GLIBC_2.2.5\n  > U -- vprintf@GLIBC_2.2.5\n  > U -- vsnprintf@GLIBC_2.2.5\n  $ \n\nLooking at the above, you can see that quite a few differences relate to\nsymbols which differ due to the level of optimization during compilation.\nThis reflects, among other things, the different 'default' settings between\nthe Makefile and the meson build; e.g. prefix=$HOME vs. /usr/local, initial\nCFLAGS='-g -O2 -Wall' vs. '-g -O0 -Wall'. Also, note that the make build\ndoes not include the (optional) pcre2 library, even if it is installed on\nthe system.\n\n[On cygwin the diff is slightly different, but also contains more symbols,\nsuch as all symbols relating to the compat regex routines, clock_gettime,\ngetdelim, sysinfo and so on ... ;) ]\n\nIf we change the meson setup, thus:\n\n  $ meson setup --optimization=2 -Dprefix=$HOME -Dpcre2=disabled build/\n\nAfter we re-build and repeat the above symbol generation, we find:\n\n  $ diff git.syms mgit.syms\n  88a89\n  > U -- arc4random_buf@GLIBC_2.36\n  746,747c747,748\n  < B -- __environ@GLIBC_2.2.5\n  < V -- environ@GLIBC_2.2.5\n  ---\n  > U -- __environ@GLIBC_2.2.5\n  > U -- environ@GLIBC_2.2.5\n  1253d1253\n  < T -- gitstrlcpy\n  2925a2926\n  > U -- strlcpy@GLIBC_2.38\n  $ \n\nAfter applying these patches and adding settings to the config.mak file: \n\n  $ vim config.mak # add NO_STRLCPY and CSPRNG_METHOD\n  $ \n  $ cat config.mak\n  DEFAULT_TEST_TARGET=prove\n  GIT_PROVE_OPTS='--timer'\n  PYTHON_PATH=/usr/bin/python3\n  GIT_TEST_HTTPD=false\n  export GIT_TEST_HTTPD\n  #DEVELOPER=1\n  SPARSE_FLAGS += -D__STDC_NO_VLA__\n  NO_STRLCPY=\n  CSPRNG_METHOD=arc4random\n  $ \n\n[Note that I commented out DEVELOPER=1. I'm not entirely sure why I did\nthat. :) Maybe it was one less variable? ]\n\n  $ make >out 2>&1\n  $ \n\n  $ meson setup --optimization=2 -Dprefix=$HOME -Dpcre2=disabled build/\n  The Meson build system\n  ...\n    User defined options\n      optimization: 2\n      prefix      : /home/ramsay\n      pcre2       : disabled\n  \n  Found ninja-1.11.1 at /usr/bin/ninja\n  $ \n\n  $ cd build\n  $ meson compile\n  INFO: autodetecting backend as ninja\n  INFO: calculating backend command to run: /usr/bin/ninja\n  [661/661] Copying file contrib/completion/git-prompt.sh\n  $ cd ..\n  $ \n\n  $ rm *.syms\n  $ ./syms.pl git >git.syms 2>/dev/null\n  $ ./syms.pl build/git >mgit.syms 2>/dev/null\n  $ \n\n  $ diff git.syms mgit.syms\n  747,748c747,748\n  < B -- __environ@GLIBC_2.2.5\n  < V -- environ@GLIBC_2.2.5\n  ---\n  > U -- __environ@GLIBC_2.2.5\n  > U -- environ@GLIBC_2.2.5\n  $ \n \nOn cygwin, this diff is now empty. ;)\n\nThe above diff seems to imply a difference in the linking of main() and\nthe C library startup routines (or something similar). However, I happened\nto notice that the meson build included '-fPIC' in the build flags, so I\nthought it was worth a punt:\n\n  $ make CFLAGS='-g -O2 -Wall -fPIC' >out 2>&1\n\n[with the advent of ASLR, I thought -fPIC/-fPIE was the default anyway!]\n\n  $ diff git.syms mgit.syms\n  2809,2811c2809,2811\n  < U -- stderr@GLIBC_2.2.5\n  < U -- stdin@GLIBC_2.2.5\n  < U -- stdout@GLIBC_2.2.5\n  ---\n  > B -- stderr@GLIBC_2.2.5\n  > B -- stdin@GLIBC_2.2.5\n  > B -- stdout@GLIBC_2.2.5\n  $ \n\nHmm, so one step forward, one step back! (or is it 2 steps forward, 3 steps\nback? ;) ). So, something for another day.\n\nNote that both test suite runs ('make test' and 'meson test') pass all\ntests (excluding the http, cvs, svn, and p4 tests) on Linux. (I am still\nwaiting for the v2.49.0 test run to finish on cygwin! :( ).\n\nAlso, patches #5 and #12 only add/modify a comment, so they could be\ndropped, if people feel that they are not appropriate.\n\n[Just in case you want to reproduce the above, I have appended the syms.pl\nscript below.]\n\nATB,\nRamsay Jones\n\nRamsay Jones (13):\n  meson.build: remove -DCURL_DISABLE_TYPECHECK\n  Makefile: only set some BASIC_CFLAGS when RUNTIME_PREFIX is set\n  meson.build: only set build variables for non-default values\n  meson.build: set default help format to html on windows\n  Makefile: remove NEEDS_LIBRT build variable\n  config.mak.uname: add a note about NO_STRLCPY for Linux\n  config.mak.uname: only set NO_REGEX on cygwin for v1.7\n  config.mak.uname: add HAVE_GETDELIM to the cygwin section\n  config.mak.uname: add clock_gettime() to the cygwin build\n  builtin/gc.c: correct RAM calculation when using sysinfo\n  config.mak.uname: add sysinfo() configuration for cygwin\n  config.mak.uname: add arc4random to the cygwin build\n  config.mak.uname: set CSPRNG_METHOD to getrandom on Linux\n\n Documentation/meson.build | 20 +++++++++++++++++\n Makefile                  | 45 ++++++++++++++++++++-------------------\n builtin/gc.c              |  9 ++++++--\n config.mak.uname          | 15 +++++++++----\n configure.ac              |  8 +++++++\n meson.build               | 27 +++++++++++++++++++----\n meson_options.txt         |  2 +-\n t/t7815-grep-binary.sh    |  2 +-\n 8 files changed, 94 insertions(+), 34 deletions(-)\n\n\nrange-diff between v2 and v3:\n\n 1:  fe969deec0 =  1:  62173d3c48 meson.build: remove -DCURL_DISABLE_TYPECHECK\n 2:  8df541634a =  2:  cded8cb86c Makefile: only set some BASIC_CFLAGS when RUNTIME_PREFIX is set\n 3:  280363cd56 =  3:  f6a5e46876 meson.build: only set build variables for non-default values\n 4:  34349bf98c =  4:  a39952e29c meson.build: set default help format to html on windows\n 5:  e73c2c3219 =  5:  9d4f2736cd Makefile: remove NEEDS_LIBRT build variable\n 6:  8c76671f0e =  6:  619bee80a3 config.mak.uname: add a note about NO_STRLCPY for Linux\n 7:  324bb21342 =  7:  b0909d3eba config.mak.uname: only set NO_REGEX on cygwin for v1.7\n 8:  0a3ce7e80a =  8:  b61bf9ea2e config.mak.uname: add HAVE_GETDELIM to the cygwin section\n 9:  3bd6e40cd2 !  9:  b2fcec5b9b config.mak.uname: add clock_gettime() to the cygwin build\n    @@ config.mak.uname: ifeq ($(uname_O),Cygwin)\n              endif\n      \tHAVE_DEV_TTY = YesPlease\n      \tHAVE_GETDELIM = YesPlease\n    -+\tHAVE_CLOCK_GETTIME=YesPlease\n    -+\tHAVE_CLOCK_MONOTONIC=YesPlease\n    ++\tHAVE_CLOCK_GETTIME = YesPlease\n    ++\tHAVE_CLOCK_MONOTONIC = YesPlease\n      \tHAVE_ALLOCA_H = YesPlease\n      \tNEEDS_LIBICONV = YesPlease\n      \tNO_FAST_WORKING_DIRECTORY = UnfortunatelyYes\n10:  a2eb9ab117 = 10:  7d62945b26 builtin/gc.c: correct RAM calculation when using sysinfo\n11:  e45b9df3a4 ! 11:  eff0c2a1a2 config.mak.uname: add sysinfo() configuration for cygwin\n    @@ config.mak.uname: ifeq ($(uname_S),Linux)\n      \tCOMPAT_OBJS += compat/linux/procinfo.o\n     @@ config.mak.uname: ifeq ($(uname_O),Cygwin)\n      \tHAVE_GETDELIM = YesPlease\n    - \tHAVE_CLOCK_GETTIME=YesPlease\n    - \tHAVE_CLOCK_MONOTONIC=YesPlease\n    + \tHAVE_CLOCK_GETTIME = YesPlease\n    + \tHAVE_CLOCK_MONOTONIC = YesPlease\n     +\tHAVE_SYSINFO = YesPlease\n      \tHAVE_ALLOCA_H = YesPlease\n      \tNEEDS_LIBICONV = YesPlease\n12:  422d4b2571 ! 12:  5f8bf7862f config.mak.uname: add arc4random to the cygwin build\n    @@ Commit message\n     \n      ## config.mak.uname ##\n     @@ config.mak.uname: ifeq ($(uname_O),Cygwin)\n    - \tHAVE_CLOCK_GETTIME=YesPlease\n    - \tHAVE_CLOCK_MONOTONIC=YesPlease\n    + \tHAVE_CLOCK_GETTIME = YesPlease\n    + \tHAVE_CLOCK_MONOTONIC = YesPlease\n      \tHAVE_SYSINFO = YesPlease\n     +\tCSPRNG_METHOD = arc4random\n      \tHAVE_ALLOCA_H = YesPlease\n13:  7b133af24b = 13:  07db9583bf config.mak.uname: set CSPRNG_METHOD to getrandom on Linux\n\n-- \n2.49.0\n\n----------------- >8 ------------------ [syms.pl]\n#!/usr/bin/perl -w\n\nopen(I, \"-|\", qw(nm -g), $ARGV[0]) or die;\nwhile (<I>) {\n\tunless (/^[0-9a-f ]+ ([A-Z]) (\\S*)$/) {\n\t\tprint STDERR \"? $_\";\n\t\tnext;\n\t}\n\tnext if ($2 =~ /^\\.refptr\\./);\n\tprint \"$1 -- $2\\n\";\n}\nclose I;\n\n"},{"id":"516314","messageId":"20250416231835.2492562-2-ramsay@ramsayjones.plus.com","threadId":"63129","inReplyTo":"20250416231835.2492562-1-ramsay@ramsayjones.plus.com","subject":"[PATCH v3 01/13] meson.build: remove -DCURL_DISABLE_TYPECHECK","fromName":"Ramsay Jones","fromEmail":"ramsay@ramsayjones.plus.com","sentAt":"2025-04-16T23:18:22Z","receivedAt":"2025-04-16T23:19:16Z","isPatch":true,"sender":{"key":"ramsay@ramsayjones.plus.com","avatar":"https://avatars.githubusercontent.com/u/33702710?v=4"},"body":"Commit 9371322a60 (\"sparse: suppress some \\\"using sizeof on a function\\\"\nwarnings\", 2013-10-06) used target-specific variable assignments to add\n-DCURL_DISABLE_TYPECHECK to SPARSE_FLAGS for each of the files affected\nby the \"typecheck-gcc.h\" warnings. (http-push.c, http.c, http-walker.c\nand remote-curl.c).\n\nThese warnings are only issued by sparse, and not by gcc, so we do not\nwant to disable the 'type checking' for non-sparse targets. The meson\nbuild does not provide any sparse targets, so there is no need to use\nthe CURL_DISABLE_TYPECHECK preprocessor flag with the c compiler.\n\nIn order to re-enable the curl 'type checking' in the meson build, remove\nthe assignment of -DCURL_DISABLE_TYPECHECK to libgit_c_args.\n\nSigned-off-by: Ramsay Jones <ramsay@ramsayjones.plus.com>\n---\n meson.build | 1 -\n 1 file changed, 1 deletion(-)\n\ndiff --git a/meson.build b/meson.build\nindex efe2871c9d..88a29fd043 100644\n--- a/meson.build\n+++ b/meson.build\n@@ -966,7 +966,6 @@ if curl.found()\n   # Most executables don't have to link against libcurl, but we still need its\n   # include directories so that we can resolve LIBCURL_VERSION in \"help.c\".\n   libgit_dependencies += curl.partial_dependency(includes: true)\n-  libgit_c_args += '-DCURL_DISABLE_TYPECHECK'\n   build_options_config.set('NO_CURL', '')\n else\n   libgit_c_args += '-DNO_CURL'\n-- \n2.49.0\n\n"},{"id":"516315","messageId":"20250416231835.2492562-3-ramsay@ramsayjones.plus.com","threadId":"63129","inReplyTo":"20250416231835.2492562-1-ramsay@ramsayjones.plus.com","subject":"[PATCH v3 02/13] Makefile: only set some BASIC_CFLAGS when RUNTIME_PREFIX is set","fromName":"Ramsay Jones","fromEmail":"ramsay@ramsayjones.plus.com","sentAt":"2025-04-16T23:18:23Z","receivedAt":"2025-04-16T23:19:21Z","isPatch":true,"sender":{"key":"ramsay@ramsayjones.plus.com","avatar":"https://avatars.githubusercontent.com/u/33702710?v=4"},"body":"Several build variables only have any meaning when the RUNTIME_PREFIX\nvariable has been set. In particular, the following build variables are\notherwise ignored:\n\n    HAVE_BSD_KERN_PROC_SYSCTL\n    PROCFS_EXECUTABLE_PATH\n    HAVE_NS_GET_EXECUTABLE_PATH\n    HAVE_ZOS_GET_EXECUTABLE_PATH\n    HAVE_WPGMPTR\n\nMake setting BASIC_CFLAGS, for each of these variables, conditional on\nthe RUNTIME_PREFIX being defined.\n\nSigned-off-by: Ramsay Jones <ramsay@ramsayjones.plus.com>\n---\n Makefile | 38 +++++++++++++++++++++-----------------\n 1 file changed, 21 insertions(+), 17 deletions(-)\n\ndiff --git a/Makefile b/Makefile\nindex 7315507381..818dde32a9 100644\n--- a/Makefile\n+++ b/Makefile\n@@ -2179,10 +2179,6 @@ ifdef HAVE_BSD_SYSCTL\n \tBASIC_CFLAGS += -DHAVE_BSD_SYSCTL\n endif\n \n-ifdef HAVE_BSD_KERN_PROC_SYSCTL\n-\tBASIC_CFLAGS += -DHAVE_BSD_KERN_PROC_SYSCTL\n-endif\n-\n ifdef HAVE_GETDELIM\n \tBASIC_CFLAGS += -DHAVE_GETDELIM\n endif\n@@ -2213,25 +2209,33 @@ ifneq ($(findstring openssl,$(CSPRNG_METHOD)),)\n \tEXTLIBS += -lcrypto -lssl\n endif\n \n-ifneq ($(PROCFS_EXECUTABLE_PATH),)\n-\tprocfs_executable_path_SQ = $(subst ','\\'',$(PROCFS_EXECUTABLE_PATH))\n-\tBASIC_CFLAGS += '-DPROCFS_EXECUTABLE_PATH=\"$(procfs_executable_path_SQ)\"'\n-endif\n-\n ifndef HAVE_PLATFORM_PROCINFO\n \tCOMPAT_OBJS += compat/stub/procinfo.o\n endif\n \n-ifdef HAVE_NS_GET_EXECUTABLE_PATH\n-\tBASIC_CFLAGS += -DHAVE_NS_GET_EXECUTABLE_PATH\n-endif\n+ifdef RUNTIME_PREFIX\n \n-ifdef HAVE_ZOS_GET_EXECUTABLE_PATH\n-        BASIC_CFLAGS += -DHAVE_ZOS_GET_EXECUTABLE_PATH\n-endif\n+        ifdef HAVE_BSD_KERN_PROC_SYSCTL\n+\t\tBASIC_CFLAGS += -DHAVE_BSD_KERN_PROC_SYSCTL\n+        endif\n+\n+        ifneq ($(PROCFS_EXECUTABLE_PATH),)\n+\t\tpep_SQ = $(subst ','\\'',$(PROCFS_EXECUTABLE_PATH))\n+\t\tBASIC_CFLAGS += '-DPROCFS_EXECUTABLE_PATH=\"$(pep_SQ)\"'\n+        endif\n+\n+        ifdef HAVE_NS_GET_EXECUTABLE_PATH\n+\t\tBASIC_CFLAGS += -DHAVE_NS_GET_EXECUTABLE_PATH\n+        endif\n+\n+        ifdef HAVE_ZOS_GET_EXECUTABLE_PATH\n+\t\tBASIC_CFLAGS += -DHAVE_ZOS_GET_EXECUTABLE_PATH\n+        endif\n+\n+        ifdef HAVE_WPGMPTR\n+\t\tBASIC_CFLAGS += -DHAVE_WPGMPTR\n+        endif\n \n-ifdef HAVE_WPGMPTR\n-\tBASIC_CFLAGS += -DHAVE_WPGMPTR\n endif\n \n ifdef FILENO_IS_A_MACRO\n-- \n2.49.0\n\n"},{"id":"516316","messageId":"20250416231835.2492562-4-ramsay@ramsayjones.plus.com","threadId":"63129","inReplyTo":"20250416231835.2492562-1-ramsay@ramsayjones.plus.com","subject":"[PATCH v3 03/13] meson.build: only set build variables for non-default values","fromName":"Ramsay Jones","fromEmail":"ramsay@ramsayjones.plus.com","sentAt":"2025-04-16T23:18:24Z","receivedAt":"2025-04-16T23:19:26Z","isPatch":true,"sender":{"key":"ramsay@ramsayjones.plus.com","avatar":"https://avatars.githubusercontent.com/u/33702710?v=4"},"body":"Some preprocessor -Defines have defaults set in the source code when\nthey have not been provided to the C compiler. In this case, there is\nno need to pass them on the command-line, unless the build requires a\nnon-standard value.\n\nThe build variables for DEFAULT_EDITOR and DEFAULT_PAGER have appropriate\ndefaults ('vi' and 'less') set in the code. Add the preprocessor -Defines\nto the 'libgit_c_args' only if the values set with the corresponding\n'options' are different to these standard values.\n\nAlso, the 'git-var' documentation contains some conditional text which\ndocuments the chosen compiled in value, which would not read well for\nthe standard values. Similar to the above, only add the corresponding\n'-a' attribute arguments to the 'asciidoc_common_options' variable, if\nthe values set in the 'options' are different to these standard values.\n\nSigned-off-by: Ramsay Jones <ramsay@ramsayjones.plus.com>\n---\n Documentation/meson.build | 20 ++++++++++++++++++++\n meson.build               | 13 +++++++++++--\n 2 files changed, 31 insertions(+), 2 deletions(-)\n\ndiff --git a/Documentation/meson.build b/Documentation/meson.build\nindex 594546d68b..1642b6e2a3 100644\n--- a/Documentation/meson.build\n+++ b/Documentation/meson.build\n@@ -242,6 +242,16 @@ if docs_backend == 'asciidoc'\n     '--attribute=build_dir=' + meson.current_build_dir(),\n   ]\n \n+  pager_opt = get_option('default_pager')\n+  if pager_opt != '' and pager_opt != 'less'\n+    asciidoc_common_options += '-agit-default-pager=' + pager_opt\n+  endif\n+\n+  editor_opt = get_option('default_editor')\n+  if editor_opt != '' and editor_opt != 'vi'\n+    asciidoc_common_options += '-agit-default-editor=' + editor_opt\n+  endif\n+\n   documentation_deps = [\n     asciidoc_conf,\n   ]\n@@ -279,6 +289,16 @@ elif docs_backend == 'asciidoctor'\n     '--require', 'asciidoctor-extensions',\n   ]\n \n+  pager_opt = get_option('default_pager')\n+  if pager_opt != '' and pager_opt != 'less'\n+    asciidoc_common_options += '-agit-default-pager=' + pager_opt\n+  endif\n+\n+  editor_opt = get_option('default_editor')\n+  if editor_opt != '' and editor_opt != 'vi'\n+    asciidoc_common_options += '-agit-default-editor=' + editor_opt\n+  endif\n+\n   documentation_deps = [\n     asciidoctor_extensions,\n   ]\ndiff --git a/meson.build b/meson.build\nindex 88a29fd043..efd0bd3319 100644\n--- a/meson.build\n+++ b/meson.build\n@@ -693,10 +693,8 @@ endif\n # These variables are used for building libgit.a.\n libgit_c_args = [\n   '-DBINDIR=\"' + get_option('bindir') + '\"',\n-  '-DDEFAULT_EDITOR=\"' + get_option('default_editor') + '\"',\n   '-DDEFAULT_GIT_TEMPLATE_DIR=\"' + get_option('datadir') / 'git-core/templates' + '\"',\n   '-DDEFAULT_HELP_FORMAT=\"' + get_option('default_help_format') + '\"',\n-  '-DDEFAULT_PAGER=\"' + get_option('default_pager') + '\"',\n   '-DETC_GITATTRIBUTES=\"' + get_option('gitattributes') + '\"',\n   '-DETC_GITCONFIG=\"' + get_option('gitconfig') + '\"',\n   '-DFALLBACK_RUNTIME_PREFIX=\"' + get_option('prefix') + '\"',\n@@ -708,6 +706,17 @@ libgit_c_args = [\n   '-DPAGER_ENV=\"' + get_option('pager_environment') + '\"',\n   '-DSHELL_PATH=\"' + fs.as_posix(shell.full_path()) + '\"',\n ]\n+\n+editor_opt = get_option('default_editor')\n+if editor_opt != '' and editor_opt != 'vi'\n+  libgit_c_args += '-DDEFAULT_EDITOR=\"' + editor_opt + '\"'\n+endif\n+\n+pager_opt = get_option('default_pager')\n+if pager_opt != '' and pager_opt != 'less'\n+  libgit_c_args += '-DDEFAULT_PAGER=\"' + pager_opt + '\"'\n+endif\n+\n libgit_include_directories = [ '.' ]\n libgit_dependencies = [ ]\n \n-- \n2.49.0\n\n"},{"id":"516317","messageId":"20250416231835.2492562-5-ramsay@ramsayjones.plus.com","threadId":"63129","inReplyTo":"20250416231835.2492562-1-ramsay@ramsayjones.plus.com","subject":"[PATCH v3 04/13] meson.build: set default help format to html on windows","fromName":"Ramsay Jones","fromEmail":"ramsay@ramsayjones.plus.com","sentAt":"2025-04-16T23:18:25Z","receivedAt":"2025-04-16T23:19:31Z","isPatch":true,"sender":{"key":"ramsay@ramsayjones.plus.com","avatar":"https://avatars.githubusercontent.com/u/33702710?v=4"},"body":"The build variable DEFAULT_HELP_FORMAT has an appropriate default\n('man') set in the code, so there is no need to pass the -Define on\nthe compiler command-line, unless the build requires a non-standard\nvalue.\n\nIn addition, on windows the make build overrides the default help\nformat to 'html', rather than 'man', in the 'config.mak.uname' file.\n\nIn order to suppress the -Define on the C compiler command-line, only\nadd the -Define to the 'libgit_c_args' variable when the requested\nvalue is not the standard 'man'. In order to override the default value\non windows, add a 'platform' value to the 'default_help_format' combo\noption and set it as the default choice. When this option is set to\n'platform', use the 'host_machine.system()' method call to determine the\nappropriate default value for the host system.\n\nSigned-off-by: Ramsay Jones <ramsay@ramsayjones.plus.com>\n---\n meson.build       | 13 ++++++++++++-\n meson_options.txt |  2 +-\n 2 files changed, 13 insertions(+), 2 deletions(-)\n\ndiff --git a/meson.build b/meson.build\nindex efd0bd3319..8f8a258064 100644\n--- a/meson.build\n+++ b/meson.build\n@@ -694,7 +694,6 @@ endif\n libgit_c_args = [\n   '-DBINDIR=\"' + get_option('bindir') + '\"',\n   '-DDEFAULT_GIT_TEMPLATE_DIR=\"' + get_option('datadir') / 'git-core/templates' + '\"',\n-  '-DDEFAULT_HELP_FORMAT=\"' + get_option('default_help_format') + '\"',\n   '-DETC_GITATTRIBUTES=\"' + get_option('gitattributes') + '\"',\n   '-DETC_GITCONFIG=\"' + get_option('gitconfig') + '\"',\n   '-DFALLBACK_RUNTIME_PREFIX=\"' + get_option('prefix') + '\"',\n@@ -717,6 +716,18 @@ if pager_opt != '' and pager_opt != 'less'\n   libgit_c_args += '-DDEFAULT_PAGER=\"' + pager_opt + '\"'\n endif\n \n+help_format_opt = get_option('default_help_format')\n+if help_format_opt == 'platform'\n+  if host_machine.system() == 'windows'\n+    help_format_opt = 'html'\n+  else\n+    help_format_opt = 'man'\n+  endif\n+endif\n+if help_format_opt != 'man'\n+    libgit_c_args += '-DDEFAULT_HELP_FORMAT=\"' + help_format_opt + '\"'\n+endif\n+\n libgit_include_directories = [ '.' ]\n libgit_dependencies = [ ]\n \ndiff --git a/meson_options.txt b/meson_options.txt\nindex 78d172a740..8ac30a5223 100644\n--- a/meson_options.txt\n+++ b/meson_options.txt\n@@ -95,7 +95,7 @@ option('highlight_bin', type: 'string', value: 'highlight')\n # Documentation.\n option('docs', type: 'array', choices: ['man', 'html'], value: [],\n   description: 'Which documenattion formats to build and install.')\n-option('default_help_format', type: 'combo', choices: ['man', 'html'], value: 'man',\n+option('default_help_format', type: 'combo', choices: ['man', 'html', 'platform'], value: 'platform',\n   description: 'Default format used when executing git-help(1).')\n option('docs_backend', type: 'combo', choices: ['asciidoc', 'asciidoctor', 'auto'], value: 'auto',\n   description: 'Which backend to use to generate documentation.')\n-- \n2.49.0\n\n"},{"id":"516318","messageId":"20250416231835.2492562-6-ramsay@ramsayjones.plus.com","threadId":"63129","inReplyTo":"20250416231835.2492562-1-ramsay@ramsayjones.plus.com","subject":"[PATCH v3 05/13] Makefile: remove NEEDS_LIBRT build variable","fromName":"Ramsay Jones","fromEmail":"ramsay@ramsayjones.plus.com","sentAt":"2025-04-16T23:18:26Z","receivedAt":"2025-04-16T23:19:36Z","isPatch":true,"sender":{"key":"ramsay@ramsayjones.plus.com","avatar":"https://avatars.githubusercontent.com/u/33702710?v=4"},"body":"Commit d19e3a5b21 (\"Makefile: add NEEDS_LIBRT to optionally link with\nlibrt\", 2016-07-07) introduced the NEEDS_LIBRT build variable to\ndisassociate the HAVE_CLOCK_GETTIME variable with the unconditional\nlinking of the librt library. At one time, the clock_gettime() function\nwas not available as part of the libc library and (on some unix systems)\nrequired linking with librt.\n\nCommit 52fcec75ce (\"config.mak.uname: define NEEDS_LIBRT under Linux, for\nnow\", 2016-07-10) set the NEEDS_LIBRT variable in the Linux section of\nthe config.mak.uname file, since Debian 7 (wheezy) was one of the few\nremaining distributions, with glibc 2.13, that required linking with\nlibrt for clock_gettime(). Note that from glibc version 2.17, this is no\nlonger necessary.\n\nNote that Debian 7.0 was released on May 4th, 2013 and benefited from\nlong term support until May 2018 when it went end-of-life. Since that\ntime, Linux distributions use a more up-to-date library, for example:\n\n    Distribution   version  end of support\n\n    Debian 8       2.19     30th June 2020\n    RHEL   8       2.28     31st May  2024 *\n    Ubuntu 16.04   2.23     30th Apr  2021\n\n* paid 'Maintenance support' ends 31st May 2029\n\nSince it is no longer required, remove NEEDS_LIBRT from the Makefile and\nconfig.mak.uname.\n\nSigned-off-by: Ramsay Jones <ramsay@ramsayjones.plus.com>\n---\n Makefile         | 7 -------\n config.mak.uname | 2 --\n 2 files changed, 9 deletions(-)\n\ndiff --git a/Makefile b/Makefile\nindex 818dde32a9..8fa4d2664e 100644\n--- a/Makefile\n+++ b/Makefile\n@@ -340,9 +340,6 @@ include shared.mak\n #\n # Define HAVE_SYNC_FILE_RANGE if your platform has sync_file_range.\n #\n-# Define NEEDS_LIBRT if your platform requires linking with librt (glibc version\n-# before 2.17) for clock_gettime and CLOCK_MONOTONIC.\n-#\n # Define HAVE_BSD_SYSCTL if your platform has a BSD-compatible sysctl function.\n #\n # Define HAVE_GETDELIM if your system has the getdelim() function.\n@@ -2171,10 +2168,6 @@ ifdef HAVE_SYNC_FILE_RANGE\n \tBASIC_CFLAGS += -DHAVE_SYNC_FILE_RANGE\n endif\n \n-ifdef NEEDS_LIBRT\n-\tEXTLIBS += -lrt\n-endif\n-\n ifdef HAVE_BSD_SYSCTL\n \tBASIC_CFLAGS += -DHAVE_BSD_SYSCTL\n endif\ndiff --git a/config.mak.uname b/config.mak.uname\nindex b12d4e168a..88007c4f13 100644\n--- a/config.mak.uname\n+++ b/config.mak.uname\n@@ -54,8 +54,6 @@ ifeq ($(uname_S),Linux)\n \tHAVE_DEV_TTY = YesPlease\n \tHAVE_CLOCK_GETTIME = YesPlease\n \tHAVE_CLOCK_MONOTONIC = YesPlease\n-\t# -lrt is needed for clock_gettime on glibc <= 2.16\n-\tNEEDS_LIBRT = YesPlease\n \tHAVE_SYNC_FILE_RANGE = YesPlease\n \tHAVE_GETDELIM = YesPlease\n \tFREAD_READS_DIRECTORIES = UnfortunatelyYes\n-- \n2.49.0\n\n"},{"id":"516319","messageId":"20250416231835.2492562-7-ramsay@ramsayjones.plus.com","threadId":"63129","inReplyTo":"20250416231835.2492562-1-ramsay@ramsayjones.plus.com","subject":"[PATCH v3 06/13] config.mak.uname: add a note about NO_STRLCPY for Linux","fromName":"Ramsay Jones","fromEmail":"ramsay@ramsayjones.plus.com","sentAt":"2025-04-16T23:18:27Z","receivedAt":"2025-04-16T23:19:41Z","isPatch":true,"sender":{"key":"ramsay@ramsayjones.plus.com","avatar":"https://avatars.githubusercontent.com/u/33702710?v=4"},"body":"Commit 817151e61a (\"Rename safe_strncpy() to strlcpy().\", 2006-06-24)\nadded the NO_STRLCPY make variable to allow the conditional use of\nthe gitstrlcpy() compat function on those platforms which didn't\nprovide the 'standard' strlcpy() function.\n\nRecently, in the summer of 2023, the strlcpy() and strlcat() functions\nwere added to the glibc library (v2.38), so some of the more up-to-date\nLinux distributions no longer need to set NO_STRLCPY. For example, both\nUbuntu 24.04 LTS and RHEL 10 beta have glibc v2.39. However, several\ndistributions, which are still within their support window, have an\nearlier version and must still use the 'compat' version of strlcpy().\n\nIf the meson or autoconf build systems are used on newer platforms, then\nthey will be configured to to use strlcpy() from glibc, whereas the make\nbuild will always choose the 'compat' function instead. Add a note to\nthe config.mak.uname file, in the Linux section, to prompt make users to\noverride NO_STRLCPY in the config.mak file, if appropriate.\n\nSigned-off-by: Ramsay Jones <ramsay@ramsayjones.plus.com>\n---\n config.mak.uname | 1 +\n 1 file changed, 1 insertion(+)\n\ndiff --git a/config.mak.uname b/config.mak.uname\nindex 88007c4f13..ae6ba15586 100644\n--- a/config.mak.uname\n+++ b/config.mak.uname\n@@ -48,6 +48,7 @@ ifeq ($(uname_S),OSF1)\n endif\n ifeq ($(uname_S),Linux)\n \tHAVE_ALLOCA_H = YesPlease\n+\t# override in config.mak if you have glibc >= 2.38\n \tNO_STRLCPY = YesPlease\n \tHAVE_PATHS_H = YesPlease\n \tLIBC_CONTAINS_LIBINTL = YesPlease\n-- \n2.49.0\n\n"},{"id":"516320","messageId":"20250416231835.2492562-8-ramsay@ramsayjones.plus.com","threadId":"63129","inReplyTo":"20250416231835.2492562-1-ramsay@ramsayjones.plus.com","subject":"[PATCH v3 07/13] config.mak.uname: only set NO_REGEX on cygwin for v1.7","fromName":"Ramsay Jones","fromEmail":"ramsay@ramsayjones.plus.com","sentAt":"2025-04-16T23:18:28Z","receivedAt":"2025-04-16T23:19:46Z","isPatch":true,"sender":{"key":"ramsay@ramsayjones.plus.com","avatar":"https://avatars.githubusercontent.com/u/33702710?v=4"},"body":"Commit 92f63d2b05 (\"Cygwin 1.7 needs compat/regex\", 2013-07-19) set\nthe NO_REGEX build variable because the platform regex library failed\nsome of the tests (t4018 and t4034), which passed just fine with the\ncompat library.\n\nAfter some time (maybe a year or two), the platform library had been\nupdated (with an import from FreeBSD, I believe) and now passed the full\ntest-suite. This would be about the time of the v1.7 -> v2.0 transition\nin 2015. I had a patch ready to send, but just didn't get around to\nsubmitting it to the list. At some point in the interim, the official\ncygwin git package used the autoconf build system, which sets the\nNO_REGEX variable to use the platform regex library functions. The new\nmeson build system does likewise.\n\nThe cygwin platform regex library, in addition to now passing the tests\nwhich formerly failed, now passes an 'test_expect_failure' test in the\nt7815-grep-binary test file. In particular, test #12 'git grep .fi a'\nwhich determines that the regex pattern '.' matches a NUL character.\nThe commit f96e56733a (\"grep: use REG_STARTEND for all matching if\navailable\", 2010-05-22) added the test in question, but it does not\ngive any indication as to why the test was framed as an expected fail,\nrather than a 'positive' test that the 'git grep' command fails to\nmatch a NUL. Note that the previous test #11 was also originally\nmarked in that commit as a 'test_expect_failure', but was flipped to\nan 'success' test in commit 7e36de5859 (\"t/t7008-grep-binary.sh: un-TODO\na test that needs REG_STARTEND\", 2010-08-17).\n\nIn order to produce the same NO_REGEX configuration from autoconf, meson\nand make, modify config.mak.uname to only set NO_REGEX for cygwin v1.7.\nIn addition, skip test t7815.12 on cygwin, by adding the !CYGWIN pre-\nrequisite to the test header, which (among other things) removes an\n'...; please update test(s)' comment.\n\nSigned-off-by: Ramsay Jones <ramsay@ramsayjones.plus.com>\n---\n config.mak.uname       | 4 +++-\n t/t7815-grep-binary.sh | 2 +-\n 2 files changed, 4 insertions(+), 2 deletions(-)\n\ndiff --git a/config.mak.uname b/config.mak.uname\nindex ae6ba15586..b6adce0bc4 100644\n--- a/config.mak.uname\n+++ b/config.mak.uname\n@@ -245,7 +245,9 @@ ifeq ($(uname_O),Cygwin)\n \t\t# Try commenting this out if you suspect MMAP is more efficient\n \t\tNO_MMAP = YesPlease\n         else\n-\t\tNO_REGEX = UnfortunatelyYes\n+                ifeq ($(shell expr \"$(uname_R)\" : '1\\.7\\.'),4)\n+\t\t        NO_REGEX = UnfortunatelyYes\n+                endif\n         endif\n \tHAVE_DEV_TTY = YesPlease\n \tHAVE_ALLOCA_H = YesPlease\ndiff --git a/t/t7815-grep-binary.sh b/t/t7815-grep-binary.sh\nindex 90ebb64f46..b7000dfa32 100755\n--- a/t/t7815-grep-binary.sh\n+++ b/t/t7815-grep-binary.sh\n@@ -63,7 +63,7 @@ test_expect_success 'git grep ile a' '\n \tgit grep ile a\n '\n \n-test_expect_failure 'git grep .fi a' '\n+test_expect_failure !CYGWIN 'git grep .fi a' '\n \tgit grep .fi a\n '\n \n-- \n2.49.0\n\n"},{"id":"516321","messageId":"20250416231835.2492562-9-ramsay@ramsayjones.plus.com","threadId":"63129","inReplyTo":"20250416231835.2492562-1-ramsay@ramsayjones.plus.com","subject":"[PATCH v3 08/13] config.mak.uname: add HAVE_GETDELIM to the cygwin section","fromName":"Ramsay Jones","fromEmail":"ramsay@ramsayjones.plus.com","sentAt":"2025-04-16T23:18:29Z","receivedAt":"2025-04-16T23:19:50Z","isPatch":true,"sender":{"key":"ramsay@ramsayjones.plus.com","avatar":"https://avatars.githubusercontent.com/u/33702710?v=4"},"body":"Cygwin has provided the getdelim() function as far back as (at least)\n2011. The autoconf and meson builds enable the use of this symbol.\nIn order to have the same configuration for autoconf, meson and make,\nenable the HAVE_GETDELIM build variable in the cygwin section of the\nconfig.mak.uname file.\n\nSigned-off-by: Ramsay Jones <ramsay@ramsayjones.plus.com>\n---\n config.mak.uname | 1 +\n 1 file changed, 1 insertion(+)\n\ndiff --git a/config.mak.uname b/config.mak.uname\nindex b6adce0bc4..1b3ba8a341 100644\n--- a/config.mak.uname\n+++ b/config.mak.uname\n@@ -250,6 +250,7 @@ ifeq ($(uname_O),Cygwin)\n                 endif\n         endif\n \tHAVE_DEV_TTY = YesPlease\n+\tHAVE_GETDELIM = YesPlease\n \tHAVE_ALLOCA_H = YesPlease\n \tNEEDS_LIBICONV = YesPlease\n \tNO_FAST_WORKING_DIRECTORY = UnfortunatelyYes\n-- \n2.49.0\n\n"},{"id":"516322","messageId":"20250416231835.2492562-10-ramsay@ramsayjones.plus.com","threadId":"63129","inReplyTo":"20250416231835.2492562-1-ramsay@ramsayjones.plus.com","subject":"[PATCH v3 09/13] config.mak.uname: add clock_gettime() to the cygwin build","fromName":"Ramsay Jones","fromEmail":"ramsay@ramsayjones.plus.com","sentAt":"2025-04-16T23:18:30Z","receivedAt":"2025-04-16T23:19:54Z","isPatch":true,"sender":{"key":"ramsay@ramsayjones.plus.com","avatar":"https://avatars.githubusercontent.com/u/33702710?v=4"},"body":"Cygwin supports the clock_gettime() function, along with the associated\nCLOCK_MONOTONIC preprocessor symbol. The autoconf and meson builds both\nenable the use of those symbols. In order to have the same configuration\nfor the make builds, add the HAVE_CLOCK_GETTIME and HAVE_CLOCK_MONOTONIC\nbuild variables to the cygwin section of the config.mak.uname file.\n\nSigned-off-by: Ramsay Jones <ramsay@ramsayjones.plus.com>\n---\n config.mak.uname | 2 ++\n 1 file changed, 2 insertions(+)\n\ndiff --git a/config.mak.uname b/config.mak.uname\nindex 1b3ba8a341..d058b34292 100644\n--- a/config.mak.uname\n+++ b/config.mak.uname\n@@ -251,6 +251,8 @@ ifeq ($(uname_O),Cygwin)\n         endif\n \tHAVE_DEV_TTY = YesPlease\n \tHAVE_GETDELIM = YesPlease\n+\tHAVE_CLOCK_GETTIME = YesPlease\n+\tHAVE_CLOCK_MONOTONIC = YesPlease\n \tHAVE_ALLOCA_H = YesPlease\n \tNEEDS_LIBICONV = YesPlease\n \tNO_FAST_WORKING_DIRECTORY = UnfortunatelyYes\n-- \n2.49.0\n\n"},{"id":"516323","messageId":"20250416231835.2492562-11-ramsay@ramsayjones.plus.com","threadId":"63129","inReplyTo":"20250416231835.2492562-1-ramsay@ramsayjones.plus.com","subject":"[PATCH v3 10/13] builtin/gc.c: correct RAM calculation when using sysinfo","fromName":"Ramsay Jones","fromEmail":"ramsay@ramsayjones.plus.com","sentAt":"2025-04-16T23:18:31Z","receivedAt":"2025-04-16T23:19:58Z","isPatch":true,"sender":{"key":"ramsay@ramsayjones.plus.com","avatar":"https://avatars.githubusercontent.com/u/33702710?v=4"},"body":"The man page for sysinfo(2) on Linux states that (from v2.3.48) the\nsizes of the memory and swap fields, of the returned structure, are\ngiven as multiples of 'mem_unit' bytes. In earlier versions (prior to\nv2.3.23 on i386 in particular), the 'mem_unit' field was not part of\nthe structure, and all sizes were measured in bytes. The man page does\nnot discuss the motivation for this change, but it is possible that the\nchange was intended for the, relatively rare, 32-bit platform with more\nthan 4GB of memory.\n\nThe total_ram() function makes the assumption that the 'totalram' field\nof the 'struct sysinfo' is measured in bytes, or alternatively that the\n'mem_unit' field is always equal to one. Having writen a program to call\nthe sysinfo() function and print the structure fields, it seems that, on\nLinux x84_64 and i686 anyway, the 'mem_unit' field is indeed set to one\n(note that the 32-bit system had only 2GB ram). However, cygwin also has\nan sysinfo() implementation, which gives the following values:\n\n  $ ./sysinfo\n  uptime:      21381\n  loads:       0, 0, 0\n  total ram:   2074637\n  free ram:    843237\n  shared ram:  0\n  buffer ram:  0\n  total swap:  327680\n  free swap:   306932\n  procs:       15\n  total high:  0\n  free high:   0\n  mem_unit:    4096\n\n  total ram: 8497713152\n  $\n\n[This laptop has 8GB ram, so a little bit seems to be missing. ;) ]\n\nModify the total_ram() function to allow for the possibility that the\nmemory size is not specified in bytes (ie 'mem_unit' is greater than\none).\n\nSigned-off-by: Ramsay Jones <ramsay@ramsayjones.plus.com>\n---\n builtin/gc.c | 9 +++++++--\n 1 file changed, 7 insertions(+), 2 deletions(-)\n\ndiff --git a/builtin/gc.c b/builtin/gc.c\nindex 99431fd467..cdcf1dc6e7 100644\n--- a/builtin/gc.c\n+++ b/builtin/gc.c\n@@ -373,8 +373,13 @@ static uint64_t total_ram(void)\n #if defined(HAVE_SYSINFO)\n \tstruct sysinfo si;\n \n-\tif (!sysinfo(&si))\n-\t\treturn si.totalram;\n+\tif (!sysinfo(&si)) {\n+\t\tuint64_t total = si.totalram;\n+\n+\t\tif (si.mem_unit > 1)\n+\t\t\ttotal *= (uint64_t)si.mem_unit;\n+\t\treturn total;\n+\t}\n #elif defined(HAVE_BSD_SYSCTL) && (defined(HW_MEMSIZE) || defined(HW_PHYSMEM))\n \tint64_t physical_memory;\n \tint mib[2];\n-- \n2.49.0\n\n"},{"id":"516324","messageId":"20250416231835.2492562-12-ramsay@ramsayjones.plus.com","threadId":"63129","inReplyTo":"20250416231835.2492562-1-ramsay@ramsayjones.plus.com","subject":"[PATCH v3 11/13] config.mak.uname: add sysinfo() configuration for cygwin","fromName":"Ramsay Jones","fromEmail":"ramsay@ramsayjones.plus.com","sentAt":"2025-04-16T23:18:32Z","receivedAt":"2025-04-16T23:20:02Z","isPatch":true,"sender":{"key":"ramsay@ramsayjones.plus.com","avatar":"https://avatars.githubusercontent.com/u/33702710?v=4"},"body":"Although sysinfo() is a 'Linux only' function, cygwin provides an\nimplementation which appears to be functional. The assumption that\nthis function is Linux only is reflected in the way the HAVE_SYSINFO\nbuild variable is handled by the Makefile and config.mak.uname.\n\nRework the setting of HAVE_SYSINFO in the Linux section of the system\nspecific config file, along with the corresponding setting of the\nBASIC_CFLAGS in the Makefile. Add the setting of HAVE_SYSINFO to the\ncygwin section of 'config.mak.uname'. While here, add a test for the\nsysinfo() function to the autoconf build system.\n\nSigned-off-by: Ramsay Jones <ramsay@ramsayjones.plus.com>\n---\n Makefile         | 4 ++++\n config.mak.uname | 3 ++-\n configure.ac     | 8 ++++++++\n 3 files changed, 14 insertions(+), 1 deletion(-)\n\ndiff --git a/Makefile b/Makefile\nindex 8fa4d2664e..ff89f2b81f 100644\n--- a/Makefile\n+++ b/Makefile\n@@ -2168,6 +2168,10 @@ ifdef HAVE_SYNC_FILE_RANGE\n \tBASIC_CFLAGS += -DHAVE_SYNC_FILE_RANGE\n endif\n \n+ifdef HAVE_SYSINFO\n+\tBASIC_CFLAGS += -DHAVE_SYSINFO\n+endif\n+\n ifdef HAVE_BSD_SYSCTL\n \tBASIC_CFLAGS += -DHAVE_BSD_SYSCTL\n endif\ndiff --git a/config.mak.uname b/config.mak.uname\nindex d058b34292..e7bd07cf6e 100644\n--- a/config.mak.uname\n+++ b/config.mak.uname\n@@ -58,7 +58,7 @@ ifeq ($(uname_S),Linux)\n \tHAVE_SYNC_FILE_RANGE = YesPlease\n \tHAVE_GETDELIM = YesPlease\n \tFREAD_READS_DIRECTORIES = UnfortunatelyYes\n-\tBASIC_CFLAGS += -DHAVE_SYSINFO\n+\tHAVE_SYSINFO = YesPlease\n \tPROCFS_EXECUTABLE_PATH = /proc/self/exe\n \tHAVE_PLATFORM_PROCINFO = YesPlease\n \tCOMPAT_OBJS += compat/linux/procinfo.o\n@@ -253,6 +253,7 @@ ifeq ($(uname_O),Cygwin)\n \tHAVE_GETDELIM = YesPlease\n \tHAVE_CLOCK_GETTIME = YesPlease\n \tHAVE_CLOCK_MONOTONIC = YesPlease\n+\tHAVE_SYSINFO = YesPlease\n \tHAVE_ALLOCA_H = YesPlease\n \tNEEDS_LIBICONV = YesPlease\n \tNO_FAST_WORKING_DIRECTORY = UnfortunatelyYes\ndiff --git a/configure.ac b/configure.ac\nindex 5923edc44a..d7e0503f1e 100644\n--- a/configure.ac\n+++ b/configure.ac\n@@ -1066,6 +1066,14 @@ AC_CHECK_LIB([iconv], [locale_charset],\n        [AC_CHECK_LIB([charset], [locale_charset],\n                      [CHARSET_LIB=-lcharset])])\n GIT_CONF_SUBST([CHARSET_LIB])\n+\n+#\n+# Define HAVE_SYSINFO=YesPlease if sysinfo is available.\n+GIT_CHECK_FUNC(sysinfo,\n+\t[HAVE_SYSINFO=YesPlease],\n+\t[HAVE_SYSINFO=])\n+GIT_CONF_SUBST([HAVE_SYSINFO])\n+\n #\n # Define HAVE_CLOCK_GETTIME=YesPlease if clock_gettime is available.\n GIT_CHECK_FUNC(clock_gettime,\n-- \n2.49.0\n\n"},{"id":"516325","messageId":"20250416231835.2492562-13-ramsay@ramsayjones.plus.com","threadId":"63129","inReplyTo":"20250416231835.2492562-1-ramsay@ramsayjones.plus.com","subject":"[PATCH v3 12/13] config.mak.uname: add arc4random to the cygwin build","fromName":"Ramsay Jones","fromEmail":"ramsay@ramsayjones.plus.com","sentAt":"2025-04-16T23:18:33Z","receivedAt":"2025-04-16T23:20:05Z","isPatch":true,"sender":{"key":"ramsay@ramsayjones.plus.com","avatar":"https://avatars.githubusercontent.com/u/33702710?v=4"},"body":"The arc4random_buf() function has been available in cygwin since\nabout 2016 (somewhere in the v2.x branch). Set the CSPRNG_METHOD\nbuild variable to 'arc4random', in the cygwin section, to enable\nthe use of this cryptographically-secure pseudorandom number\nfunction. Note that the autoconf and new meson builds also enable\nthis function.\n\nSigned-off-by: Ramsay Jones <ramsay@ramsayjones.plus.com>\n---\n config.mak.uname | 1 +\n 1 file changed, 1 insertion(+)\n\ndiff --git a/config.mak.uname b/config.mak.uname\nindex e7bd07cf6e..330741eb5a 100644\n--- a/config.mak.uname\n+++ b/config.mak.uname\n@@ -254,6 +254,7 @@ ifeq ($(uname_O),Cygwin)\n \tHAVE_CLOCK_GETTIME = YesPlease\n \tHAVE_CLOCK_MONOTONIC = YesPlease\n \tHAVE_SYSINFO = YesPlease\n+\tCSPRNG_METHOD = arc4random\n \tHAVE_ALLOCA_H = YesPlease\n \tNEEDS_LIBICONV = YesPlease\n \tNO_FAST_WORKING_DIRECTORY = UnfortunatelyYes\n-- \n2.49.0\n\n"},{"id":"516326","messageId":"20250416231835.2492562-14-ramsay@ramsayjones.plus.com","threadId":"63129","inReplyTo":"20250416231835.2492562-1-ramsay@ramsayjones.plus.com","subject":"[PATCH v3 13/13] config.mak.uname: set CSPRNG_METHOD to getrandom on Linux","fromName":"Ramsay Jones","fromEmail":"ramsay@ramsayjones.plus.com","sentAt":"2025-04-16T23:18:34Z","receivedAt":"2025-04-16T23:20:08Z","isPatch":true,"sender":{"key":"ramsay@ramsayjones.plus.com","avatar":"https://avatars.githubusercontent.com/u/33702710?v=4"},"body":"Commit 05cd988dce (\"wrapper: add a helper to generate numbers from a\nCSPRNG\", 2022-01-17) added a csprng_bytes() function which used one\nof several interfaces to provide a source of cryptographically secure\npseudorandom numbers. The CSPRNG_METHOD make variable was provided to\ndetermine the choice of available 'backends' for the source of random\nbytes.\n\nCommit 05cd988dce did not set CSPRNG_METHOD in the Linux section of\nthe config.mak.uname file, so it defaults to using '/dev/urandom' as\nthe source of random bytes. The 'backend' values which could be used\non Linux are 'arc4random', 'getrandom' or 'getentropy' ('openssl' is\nan option, but seems to be discouraged).\n\nThe arc4random routines (ar4random_buf() is the one actually used) were\nadded to glibc in version 2.36, while both getrandom() and getentropy()\nwere included in 2.25. So, some of the more up-to-date distributions of\nLinux (eg Debian 12, Ubuntu 24.04) would be able to use the 'arc4random'\nsetting. All currently supported distributions have glibc 2.25 or later\n(RHEL 8 has v2.28) and, therefore, have support for the 'getrandom' and\n'getentropy' settings.\n\nThe arc4random routines on the *BSDs (along with cygwin) implement the\nChaCha20 stream cipher algorithm (see RFC8439) in userspace, rather than\nas a system call, and are thus somewhat faster (having avoided a context\nswitch to the kernel). In contrast, on Linux all three functions are\nsimple wrappers around the same kernel CSPRNG syscall.\n\nIf the meson build system is used on a newer platform, then they will be\nconfigured to use 'arc4random', whereas the make build will currently\ndefault to using '/dev/urandom' on Linux. Since there is no advantage,\nin terms of performance, to the 'arc4random' setting, the 'getrandom'\nsetting should be preferred from an availability perspective. (Also, the\ncurrent uses of csprng_bytes() are not in any hot path).\n\nIn order to set an appropriate default, set the CSPRNG_METHOD build\nvariable to 'getrandom' in the Linux section of the 'config.mak.uname'\nfile.\n\nSigned-off-by: Ramsay Jones <ramsay@ramsayjones.plus.com>\n---\n config.mak.uname | 1 +\n 1 file changed, 1 insertion(+)\n\ndiff --git a/config.mak.uname b/config.mak.uname\nindex 330741eb5a..db22a8fb31 100644\n--- a/config.mak.uname\n+++ b/config.mak.uname\n@@ -50,6 +50,7 @@ ifeq ($(uname_S),Linux)\n \tHAVE_ALLOCA_H = YesPlease\n \t# override in config.mak if you have glibc >= 2.38\n \tNO_STRLCPY = YesPlease\n+\tCSPRNG_METHOD = getrandom\n \tHAVE_PATHS_H = YesPlease\n \tLIBC_CONTAINS_LIBINTL = YesPlease\n \tHAVE_DEV_TTY = YesPlease\n-- \n2.49.0\n\n"},{"id":"516331","messageId":"xmqqa58ffo2p.fsf@gitster.g","threadId":"63129","inReplyTo":"20250416231835.2492562-1-ramsay@ramsayjones.plus.com","subject":"Re: [PATCH v3 00/13] miscellaneous build mods (part 1)","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2025-04-17T03:45:34Z","receivedAt":"2025-04-17T03:45:38Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Ramsay Jones <ramsay@ramsayjones.plus.com> writes:\n\n> changes in v3:\n> --------------\n>\n> - patch #9 adds some whitespace around the '=' sign in the\n>   assignment to HAVE_CLOCK_GETTIME and HAVE_CLOCK_MONOTONIC\n>   build variables\n>\n> The range-diff below was generated with a 'creation-factor'\n> of 80%, otherwise patches after #9 are shown as complete\n> re-writes.\n>\n> I have built and tested both the make and meson builds on Linux,\n> along with the make build and meson build and test on cygwin.\n> (A 'make test' on cygwin takes 6 hours, so I will test that\n> tomorrow and let you know if it fails! ;) Highly unlikely to\n> fail, since the v2 patches passed just fine).\n\nThanks, will queue.\n"},{"id":"516335","messageId":"aAC9ptpajuOnH1Gr@pks.im","threadId":"63129","inReplyTo":"xmqqa58ffo2p.fsf@gitster.g","subject":"Re: [PATCH v3 00/13] miscellaneous build mods (part 1)","fromName":"Patrick Steinhardt","fromEmail":"ps@pks.im","sentAt":"2025-04-17T08:36:54Z","receivedAt":"2025-04-17T08:37:00Z","isPatch":true,"sender":{"key":"ps@pks.im","avatar":"https://avatars.githubusercontent.com/u/4056630?v=4"},"body":"On Wed, Apr 16, 2025 at 08:45:34PM -0700, Junio C Hamano wrote:\n> Ramsay Jones <ramsay@ramsayjones.plus.com> writes:\n> \n> > changes in v3:\n> > --------------\n> >\n> > - patch #9 adds some whitespace around the '=' sign in the\n> >   assignment to HAVE_CLOCK_GETTIME and HAVE_CLOCK_MONOTONIC\n> >   build variables\n> >\n> > The range-diff below was generated with a 'creation-factor'\n> > of 80%, otherwise patches after #9 are shown as complete\n> > re-writes.\n> >\n> > I have built and tested both the make and meson builds on Linux,\n> > along with the make build and meson build and test on cygwin.\n> > (A 'make test' on cygwin takes 6 hours, so I will test that\n> > tomorrow and let you know if it fails! ;) Highly unlikely to\n> > fail, since the v2 patches passed just fine).\n> \n> Thanks, will queue.\n\nThis version looks good to me based on reading the range-diff. Thanks!\n\nPatrick\n"},{"id":"516344","messageId":"xmqq4iymgadz.fsf@gitster.g","threadId":"63129","inReplyTo":"20250416231835.2492562-14-ramsay@ramsayjones.plus.com","subject":"Re: [PATCH v3 13/13] config.mak.uname: set CSPRNG_METHOD to getrandom on Linux","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2025-04-17T13:55:52Z","receivedAt":"2025-04-17T13:55:56Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Ramsay Jones <ramsay@ramsayjones.plus.com> writes:\n\n> Commit 05cd988dce (\"wrapper: add a helper to generate numbers from a\n> CSPRNG\", 2022-01-17) added a csprng_bytes() function which used one\n> of several interfaces to provide a source of cryptographically secure\n> pseudorandom numbers. The CSPRNG_METHOD make variable was provided to\n> determine the choice of available 'backends' for the source of random\n> bytes.\n>\n> Commit 05cd988dce did not set CSPRNG_METHOD in the Linux section of\n> the config.mak.uname file, so it defaults to using '/dev/urandom' as\n> the source of random bytes. The 'backend' values which could be used\n> on Linux are 'arc4random', 'getrandom' or 'getentropy' ('openssl' is\n> an option, but seems to be discouraged).\n>\n> The arc4random routines (ar4random_buf() is the one actually used) were\n\narc4random_buf(), if I am not mistaken?\n\n> added to glibc in version 2.36, while both getrandom() and getentropy()\n> were included in 2.25. So, some of the more up-to-date distributions of\n> Linux (eg Debian 12, Ubuntu 24.04) would be able to use the 'arc4random'\n> setting. All currently supported distributions have glibc 2.25 or later\n> (RHEL 8 has v2.28) and, therefore, have support for the 'getrandom' and\n> 'getentropy' settings.\n\nOK.  This explains that getrandom/getentropy have better\navailability than arc4random.\n\n> The arc4random routines on the *BSDs (along with cygwin) implement the\n> ChaCha20 stream cipher algorithm (see RFC8439) in userspace, rather than\n> as a system call, and are thus somewhat faster (having avoided a context\n> switch to the kernel). In contrast, on Linux all three functions are\n> simple wrappers around the same kernel CSPRNG syscall.\n\nOK.  With this and the previous paragraph, we establish that there\nis no reason to use arc4random on Linux, while on BSDs and Cygwin,\nit is a natural choice.\n\nVery clearly explained.  Thanks.\n\n> If the meson build system is used on a newer platform, then they will be\n> configured to use 'arc4random', whereas the make build will currently\n> default to using '/dev/urandom' on Linux.\n\n\n\n> Since there is no advantage,\n> in terms of performance, to the 'arc4random' setting, the 'getrandom'\n> setting should be preferred from an availability perspective. (Also, the\n> current uses of csprng_bytes() are not in any hot path).\n>\n> In order to set an appropriate default, set the CSPRNG_METHOD build\n> variable to 'getrandom' in the Linux section of the 'config.mak.uname'\n> file.\n>\n> Signed-off-by: Ramsay Jones <ramsay@ramsayjones.plus.com>\n> ---\n>  config.mak.uname | 1 +\n>  1 file changed, 1 insertion(+)\n>\n> diff --git a/config.mak.uname b/config.mak.uname\n> index 330741eb5a..db22a8fb31 100644\n> --- a/config.mak.uname\n> +++ b/config.mak.uname\n> @@ -50,6 +50,7 @@ ifeq ($(uname_S),Linux)\n>  \tHAVE_ALLOCA_H = YesPlease\n>  \t# override in config.mak if you have glibc >= 2.38\n>  \tNO_STRLCPY = YesPlease\n> +\tCSPRNG_METHOD = getrandom\n>  \tHAVE_PATHS_H = YesPlease\n>  \tLIBC_CONTAINS_LIBINTL = YesPlease\n>  \tHAVE_DEV_TTY = YesPlease\n"},{"id":"516348","messageId":"aee15694-6a15-4409-9854-dad5f511dc48@ramsayjones.plus.com","threadId":"63129","inReplyTo":"xmqq4iymgadz.fsf@gitster.g","subject":"Re: [PATCH v3 13/13] config.mak.uname: set CSPRNG_METHOD to getrandom on Linux","fromName":"Ramsay Jones","fromEmail":"ramsay@ramsayjones.plus.com","sentAt":"2025-04-17T18:27:43Z","receivedAt":"2025-04-17T18:30:56Z","isPatch":true,"sender":{"key":"ramsay@ramsayjones.plus.com","avatar":"https://avatars.githubusercontent.com/u/33702710?v=4"},"body":"\n\nOn 17/04/2025 14:55, Junio C Hamano wrote:\n> Ramsay Jones <ramsay@ramsayjones.plus.com> writes:\n[snip]\n>> The arc4random routines (ar4random_buf() is the one actually used) were\n> \n> arc4random_buf(), if I am not mistaken?\n\nOops, yes ... an unfortunate tyop! ;)\n\nDo you want a v4? (The cygwin v3 'make test' has been running for under\ntwo hours, I could Ctrl-C it ...)\n\n> \n>> added to glibc in version 2.36, while both getrandom() and getentropy()\n>> were included in 2.25. So, some of the more up-to-date distributions of\n>> Linux (eg Debian 12, Ubuntu 24.04) would be able to use the 'arc4random'\n>> setting. All currently supported distributions have glibc 2.25 or later\n>> (RHEL 8 has v2.28) and, therefore, have support for the 'getrandom' and\n>> 'getentropy' settings.\n> \n> OK.  This explains that getrandom/getentropy have better\n> availability than arc4random.\n> \n>> The arc4random routines on the *BSDs (along with cygwin) implement the\n>> ChaCha20 stream cipher algorithm (see RFC8439) in userspace, rather than\n>> as a system call, and are thus somewhat faster (having avoided a context\n>> switch to the kernel). In contrast, on Linux all three functions are\n>> simple wrappers around the same kernel CSPRNG syscall.\n> \n> OK.  With this and the previous paragraph, we establish that there\n> is no reason to use arc4random on Linux, while on BSDs and Cygwin,\n> it is a natural choice.\n> \n> Very clearly explained.  Thanks.\n> \n\nThanks!\n\nATB,\nRamsay Jones\n\n\n\n"},{"id":"516349","messageId":"xmqqr01qeebx.fsf@gitster.g","threadId":"63129","inReplyTo":"aee15694-6a15-4409-9854-dad5f511dc48@ramsayjones.plus.com","subject":"Re: [PATCH v3 13/13] config.mak.uname: set CSPRNG_METHOD to getrandom on Linux","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2025-04-17T20:13:38Z","receivedAt":"2025-04-17T20:13:41Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Ramsay Jones <ramsay@ramsayjones.plus.com> writes:\n\n> On 17/04/2025 14:55, Junio C Hamano wrote:\n>> Ramsay Jones <ramsay@ramsayjones.plus.com> writes:\n> [snip]\n>>> The arc4random routines (ar4random_buf() is the one actually used) were\n>> \n>> arc4random_buf(), if I am not mistaken?\n>\n> Oops, yes ... an unfortunate tyop! ;)\n>\n> Do you want a v4? (The cygwin v3 'make test' has been running for under\n> two hours, I could Ctrl-C it ...)\n\nNah, if you send one I will replace my copy with it, but in the\nmeantime I'll locally make a typofix myself to v3.\n\nThanks.\n"},{"id":"516356","messageId":"4d4ec104-392b-4630-871c-8398dd12d6f1@ramsayjones.plus.com","threadId":"63129","inReplyTo":"xmqqr01qeebx.fsf@gitster.g","subject":"Re: [PATCH v3 13/13] config.mak.uname: set CSPRNG_METHOD to getrandom on Linux","fromName":"Ramsay Jones","fromEmail":"ramsay@ramsayjones.plus.com","sentAt":"2025-04-17T22:06:52Z","receivedAt":"2025-04-17T22:06:55Z","isPatch":true,"sender":{"key":"ramsay@ramsayjones.plus.com","avatar":"https://avatars.githubusercontent.com/u/33702710?v=4"},"body":"\n\nOn 17/04/2025 21:13, Junio C Hamano wrote:\n> Ramsay Jones <ramsay@ramsayjones.plus.com> writes:\n> \n>> On 17/04/2025 14:55, Junio C Hamano wrote:\n>>> Ramsay Jones <ramsay@ramsayjones.plus.com> writes:\n>> [snip]\n>>>> The arc4random routines (ar4random_buf() is the one actually used) were\n>>>\n>>> arc4random_buf(), if I am not mistaken?\n>>\n>> Oops, yes ... an unfortunate tyop! ;)\n>>\n>> Do you want a v4? (The cygwin v3 'make test' has been running for under\n>> two hours, I could Ctrl-C it ...)\n> \n> Nah, if you send one I will replace my copy with it, but in the\n> meantime I'll locally make a typofix myself to v3.\n\nOK, thanks. I have made the change locally just in case there is\na need to send another version. Hopefully, that won't be necessary!\n\n(The cygwin 'make test' just finished and, as expected, passed\njust fine).\n\nThanks.\n\nATB,\nRamsay Jones\n\n\n"}]}