{"thread":{"id":"63207","subject":"[PATCH 0/4] Collection of build fixes","startedAt":"2025-03-28T08:38:45Z","lastAt":"2025-04-03T08:39:53Z","messageCount":22,"participants":["Patrick Steinhardt","Sam James","Junio C Hamano","Johannes Schindelin","Toon Claes","Karthik Nayak"],"isPatch":true,"patchVersion":1,"patchTotal":4},"messages":[{"id":"515217","messageId":"20250328-b4-pks-collect-build-fixes-v1-0-ead9deda3fbc@pks.im","threadId":"63207","inReplyTo":null,"subject":"[PATCH 0/4] Collection of build fixes","fromName":"Patrick Steinhardt","fromEmail":"ps@pks.im","sentAt":"2025-03-28T08:38:34Z","receivedAt":"2025-03-28T08:38:45Z","isPatch":true,"sender":{"key":"ps@pks.im","avatar":"https://avatars.githubusercontent.com/u/4056630?v=4"},"body":"Hi,\n\nthis small patch series collects various different smallish fixes for\nissues with the build systems. The intent here is to bundle all of them\ninto a single series to make it a bit easier for Junio to keep track of\nthem.\n\nMore specifically, this series:\n\n  - Fixes an issue with handling \"-Dcurl=auto\" that I spotted recently.\n\n  - Replaces Sam's \"sj/meson-test-environ-fix\" [1] with an alternative\n    solution. The branch is currently in \"seen\".\n\n  - Picks up Eli's patch from [2] to fix building docs when all optional\n    Perl features have been disabled. The fix has not yet been picked up\n    by Junio.\n\n  - Picks up and massages Thorsten's patch from [3] to fix generation of\n    \"gitweb.js\". The fix has not yet been picked up by Junio.\n\nPlease let me know if any of you are unhappy with the way I have given\ncredit. I'm totally happy to change authorship or adjust trailers.\n\nThanks!\n\nPatrick\n\n[1]: <310a34bace801d288e369c6a01a8d04ffc4c3c06.1741975367.git.sam@gentoo.org>\n[2]: <20250316060605.166364-1-eschwartz@gentoo.org>\n[3]: <070641d0-730c-7d92-af4a-9157dc1edd3d@debian.org>\n\n---\nEli Schwartz (1):\n      meson: require Perl when building docs\n\nPatrick Steinhardt (3):\n      meson: fix handling of '-Dcurl=auto'\n      gitweb: fix generation of \"gitweb.js\"\n      meson: respect 'tests' build option in contrib\n\n contrib/credential/netrc/meson.build | 22 ++++++++++++----------\n contrib/subtree/meson.build          | 20 +++++++++++---------\n gitweb/Makefile                      |  2 +-\n meson.build                          |  4 ++--\n 4 files changed, 26 insertions(+), 22 deletions(-)\n\n\n---\nbase-commit: 683c54c999c301c2cd6f715c411407c413b1d84e\nchange-id: 20250328-b4-pks-collect-build-fixes-b5a6ce086b72\n\n"},{"id":"515218","messageId":"20250328-b4-pks-collect-build-fixes-v1-1-ead9deda3fbc@pks.im","threadId":"63207","inReplyTo":"20250328-b4-pks-collect-build-fixes-v1-0-ead9deda3fbc@pks.im","subject":"[PATCH 1/4] meson: fix handling of '-Dcurl=auto'","fromName":"Patrick Steinhardt","fromEmail":"ps@pks.im","sentAt":"2025-03-28T08:38:35Z","receivedAt":"2025-03-28T08:38:47Z","isPatch":true,"sender":{"key":"ps@pks.im","avatar":"https://avatars.githubusercontent.com/u/4056630?v=4"},"body":"The \"curl\" option controls whether or not a couple of features that\ndepend on curl shall be included. Most importantly, these features\ninclude the HTTP remote helpers, which are rather quintessential for a\nwell-functioning Git installation. So while the dependency can in theory\nbe dropped, most users wouldn't consider the resulting installation to\nbe fully functional.\n\nThe \"curl\" option is defined as a feature, which means that it can be\n\"enabled\", \"disabled\" or \"auto\", which has the effect that the feature\nwill be enabled if the dependency itself has been found. While most of\nthe other features have \"auto\" as default value, the \"curl\" option is\nset to \"enabled\" by default due to it being so important. Consequently,\nautoconfiguration of Git will fail by default if the library cannot be\nfound.\n\nThere is a bug though with how we handle the option in case the user\noverrides the feature with `meson setup -Dcurl=auto`: while we will try\nto find the library in that case, we won't ever use it because we later\non check for `get_option('curl').enabled()` when deciding whether or not\nwe want to build dependent sources. But `enabled()` only returns true if\nthe option has the value \"enabled\", for \"auto\" it will return false.\n\nFix the issue by instead checking for `curl.found()`, which is only true\nif the library has been found. And as we only try to find the library\nwhen `get_option('curl')` returns \"true\" or \"auto\" this is exactly what\nwe want.\n\nSigned-off-by: Patrick Steinhardt <ps@pks.im>\n---\n meson.build | 2 +-\n 1 file changed, 1 insertion(+), 1 deletion(-)\n\ndiff --git a/meson.build b/meson.build\nindex efe2871c9db..a8d1e63ccc6 100644\n--- a/meson.build\n+++ b/meson.build\n@@ -1686,7 +1686,7 @@ bin_wrappers += executable('scalar',\n   install_dir: get_option('libexecdir') / 'git-core',\n )\n \n-if get_option('curl').enabled()\n+if curl.found()\n   libgit_curl = declare_dependency(\n     sources: [\n       'http.c',\n\n-- \n2.49.0.472.ge94155a9ec.dirty\n\n"},{"id":"515219","messageId":"20250328-b4-pks-collect-build-fixes-v1-2-ead9deda3fbc@pks.im","threadId":"63207","inReplyTo":"20250328-b4-pks-collect-build-fixes-v1-0-ead9deda3fbc@pks.im","subject":"[PATCH 2/4] gitweb: fix generation of \"gitweb.js\"","fromName":"Patrick Steinhardt","fromEmail":"ps@pks.im","sentAt":"2025-03-28T08:38:36Z","receivedAt":"2025-03-28T08:38:47Z","isPatch":true,"sender":{"key":"ps@pks.im","avatar":"https://avatars.githubusercontent.com/u/4056630?v=4"},"body":"In 19d8fe7da65 (Makefile: extract script to generate gitweb.js,\n2024-12-06) we have extracted the logic to build \"gitweb.js\" into a\nseparate script. As part of that the rules that builds the script\nhas gained a new dependency on that script.\n\nThis refactoring is broken though because we use \"$^\" to determine\nthe set of JavaScript files that need to be concatenated, and this\nimplicit variable now also contains the build script itself. As a\nresult, the build script ends up ni the generated \"gitweb.js\" file,\nwhich is wrong.\n\nFix the issue by filtering out non-JavaScript files.\n\nBased-on-patch-by: Thorsten Glaser <tg@debian.org>\nSigned-off-by: Patrick Steinhardt <ps@pks.im>\n---\n gitweb/Makefile | 2 +-\n 1 file changed, 1 insertion(+), 1 deletion(-)\n\ndiff --git a/gitweb/Makefile b/gitweb/Makefile\nindex d5748e93594..26a683d4421 100644\n--- a/gitweb/Makefile\n+++ b/gitweb/Makefile\n@@ -118,7 +118,7 @@ $(MAK_DIR_GITWEB)gitweb.cgi: $(MAK_DIR_GITWEB)gitweb.perl\n $(MAK_DIR_GITWEB)static/gitweb.js: $(MAK_DIR_GITWEB)generate-gitweb-js.sh\n $(MAK_DIR_GITWEB)static/gitweb.js: $(addprefix $(MAK_DIR_GITWEB),$(GITWEB_JSLIB_FILES))\n \t$(QUIET_GEN)$(RM) $@ $@+ && \\\n-\t$(MAK_DIR_GITWEB)generate-gitweb-js.sh $@+ $^ && \\\n+\t$(MAK_DIR_GITWEB)generate-gitweb-js.sh $@+ $(filter %.js,$^) && \\\n \tmv $@+ $@\n \n ### Installation rules\n\n-- \n2.49.0.472.ge94155a9ec.dirty\n\n"},{"id":"515220","messageId":"20250328-b4-pks-collect-build-fixes-v1-3-ead9deda3fbc@pks.im","threadId":"63207","inReplyTo":"20250328-b4-pks-collect-build-fixes-v1-0-ead9deda3fbc@pks.im","subject":"[PATCH 3/4] meson: require Perl when building docs","fromName":"Patrick Steinhardt","fromEmail":"ps@pks.im","sentAt":"2025-03-28T08:38:37Z","receivedAt":"2025-03-28T08:38:48Z","isPatch":true,"sender":{"key":"ps@pks.im","avatar":"https://avatars.githubusercontent.com/u/4056630?v=4"},"body":"From: Eli Schwartz <eschwartz@gentoo.org>\n\nWhen building our documentation we require Perl to generate the list of\ncommands via \"cmd-list.perl\". Having a Perl interpreter available is\nthus mandatory when building documentation, but Meson does not enforce\nthis prerequisite. Thus, when all optional features that depend on Perl\nare disabled, we won't look up the Perl interpreter, which will in the\nend lead to an error at setup time:\n\n```\n$ meson setup builddir/ -Ddocs=man -Dperl=disabled -Dtests=false\n[...]\nDocumentation/meson.build:308:22: ERROR: Tried to use not-found external program in \"command\"\n```\n\nThere is already a list of other cases where we do need the Perl\ninterpreter. Building documentation should be one of those cases, but\nis missing from the list. Add it to fix the issue.\n\nSigned-off-by: Eli Schwartz <eschwartz@gentoo.org>\nCommit-message-edited-by: Patrick Steinhardt <ps@pks.im>\nSigned-off-by: Patrick Steinhardt <ps@pks.im>\n---\n meson.build | 2 +-\n 1 file changed, 1 insertion(+), 1 deletion(-)\n\ndiff --git a/meson.build b/meson.build\nindex a8d1e63ccc6..51013c70de9 100644\n--- a/meson.build\n+++ b/meson.build\n@@ -772,7 +772,7 @@ endif\n # features. It is optional if you want to neither execute tests nor use any of\n # these optional features.\n perl_required = get_option('perl')\n-if get_option('tests') or get_option('gitweb').enabled() or 'netrc' in get_option('credential_helpers')\n+if get_option('tests') or get_option('gitweb').enabled() or 'netrc' in get_option('credential_helpers') or get_options('docs') != []\n   perl_required = true\n endif\n \n\n-- \n2.49.0.472.ge94155a9ec.dirty\n\n"},{"id":"515221","messageId":"20250328-b4-pks-collect-build-fixes-v1-4-ead9deda3fbc@pks.im","threadId":"63207","inReplyTo":"20250328-b4-pks-collect-build-fixes-v1-0-ead9deda3fbc@pks.im","subject":"[PATCH 4/4] meson: respect 'tests' build option in contrib","fromName":"Patrick Steinhardt","fromEmail":"ps@pks.im","sentAt":"2025-03-28T08:38:38Z","receivedAt":"2025-03-28T08:38:48Z","isPatch":true,"sender":{"key":"ps@pks.im","avatar":"https://avatars.githubusercontent.com/u/4056630?v=4"},"body":"Both the \"netrc\" credential helper and git-subtree(1) from \"contrib/\"\ncarry a couple of tests with them. These tests get wired up in Meson\nunconditionally even in the case where `-Dtests=false`. As those tests\ndepend on the `test_enviroment` variable, which only gets defined in\ncase `-Dtests=true`, the result is an error:\n\n```\n$ meson setup -Dtests=false -Dcontrib=subtree build\n[...]\n\ncontrib/subtree/meson.build:15:27: ERROR: Unknown variable \"test_environment\".\n```\n\nFix the issue by not defining these tests at all in case the \"tests\"\noption is set to `false`.\n\nReported-by: Sam James <sam@gentoo.org>\nSigned-off-by: Patrick Steinhardt <ps@pks.im>\n---\n contrib/credential/netrc/meson.build | 22 ++++++++++++----------\n contrib/subtree/meson.build          | 20 +++++++++++---------\n 2 files changed, 23 insertions(+), 19 deletions(-)\n\ndiff --git a/contrib/credential/netrc/meson.build b/contrib/credential/netrc/meson.build\nindex a990dbb86da..3d74547c8ae 100644\n--- a/contrib/credential/netrc/meson.build\n+++ b/contrib/credential/netrc/meson.build\n@@ -7,14 +7,16 @@ credential_netrc = custom_target(\n   install_dir: get_option('libexecdir') / 'git-core',\n )\n \n-credential_netrc_testenv = test_environment\n-credential_netrc_testenv.set('CREDENTIAL_NETRC_PATH', credential_netrc.full_path())\n+if get_option('tests')\n+  credential_netrc_testenv = test_environment\n+  credential_netrc_testenv.set('CREDENTIAL_NETRC_PATH', credential_netrc.full_path())\n \n-test('t-git-credential-netrc',\n-  shell,\n-  args: [ meson.current_source_dir() / 't-git-credential-netrc.sh' ],\n-  workdir: meson.current_source_dir(),\n-  env: credential_netrc_testenv,\n-  depends: test_dependencies + bin_wrappers + [credential_netrc],\n-  timeout: 0,\n-)\n+  test('t-git-credential-netrc',\n+    shell,\n+    args: [ meson.current_source_dir() / 't-git-credential-netrc.sh' ],\n+    workdir: meson.current_source_dir(),\n+    env: credential_netrc_testenv,\n+    depends: test_dependencies + bin_wrappers + [credential_netrc],\n+    timeout: 0,\n+  )\n+endif\ndiff --git a/contrib/subtree/meson.build b/contrib/subtree/meson.build\nindex 9c72b236259..63714166a61 100644\n--- a/contrib/subtree/meson.build\n+++ b/contrib/subtree/meson.build\n@@ -12,16 +12,18 @@ git_subtree = custom_target(\n   install_dir: get_option('libexecdir') / 'git-core',\n )\n \n-subtree_test_environment = test_environment\n-subtree_test_environment.prepend('PATH', meson.current_build_dir())\n+if get_option('tests')\n+  subtree_test_environment = test_environment\n+  subtree_test_environment.prepend('PATH', meson.current_build_dir())\n \n-test('t7900-subtree', shell,\n-  args: [ 't7900-subtree.sh' ],\n-  env: subtree_test_environment,\n-  workdir: meson.current_source_dir() / 't',\n-  depends: test_dependencies + bin_wrappers + [ git_subtree ],\n-  timeout: 0,\n-)\n+  test('t7900-subtree', shell,\n+    args: [ 't7900-subtree.sh' ],\n+    env: subtree_test_environment,\n+    workdir: meson.current_source_dir() / 't',\n+    depends: test_dependencies + bin_wrappers + [ git_subtree ],\n+    timeout: 0,\n+  )\n+endif\n \n if get_option('docs').contains('man')\n   subtree_xml = custom_target(\n\n-- \n2.49.0.472.ge94155a9ec.dirty\n\n"},{"id":"515252","messageId":"87semx3tct.fsf@gentoo.org","threadId":"63207","inReplyTo":"20250328-b4-pks-collect-build-fixes-v1-4-ead9deda3fbc@pks.im","subject":"Re: [PATCH 4/4] meson: respect 'tests' build option in contrib","fromName":"Sam James","fromEmail":"sam@gentoo.org","sentAt":"2025-03-28T18:25:38Z","receivedAt":"2025-03-28T18:25:42Z","isPatch":true,"sender":{"key":"sam@gentoo.org","avatar":"https://avatars.githubusercontent.com/u/11667869?v=4"},"body":"Patrick Steinhardt <ps@pks.im> writes:\n\n> Both the \"netrc\" credential helper and git-subtree(1) from \"contrib/\"\n> carry a couple of tests with them. These tests get wired up in Meson\n> unconditionally even in the case where `-Dtests=false`. As those tests\n> depend on the `test_enviroment` variable, which only gets defined in\n> case `-Dtests=true`, the result is an error:\n>\n> ```\n> $ meson setup -Dtests=false -Dcontrib=subtree build\n> [...]\n>\n> contrib/subtree/meson.build:15:27: ERROR: Unknown variable \"test_environment\".\n> ```\n>\n> Fix the issue by not defining these tests at all in case the \"tests\"\n> option is set to `false`.\n\nThank you! Sorry for the delay in getting back to you -- I had some\nthought that I was trying to resolve about the nicer style and then\ndropped the ball. LGTM.\n\n>\n> Reported-by: Sam James <sam@gentoo.org>\n> Signed-off-by: Patrick Steinhardt <ps@pks.im>\n> ---\n>  contrib/credential/netrc/meson.build | 22 ++++++++++++----------\n>  contrib/subtree/meson.build          | 20 +++++++++++---------\n>  2 files changed, 23 insertions(+), 19 deletions(-)\n>\n> diff --git a/contrib/credential/netrc/meson.build b/contrib/credential/netrc/meson.build\n> index a990dbb86da..3d74547c8ae 100644\n> --- a/contrib/credential/netrc/meson.build\n> +++ b/contrib/credential/netrc/meson.build\n> @@ -7,14 +7,16 @@ credential_netrc = custom_target(\n>    install_dir: get_option('libexecdir') / 'git-core',\n>  )\n>  \n> -credential_netrc_testenv = test_environment\n> -credential_netrc_testenv.set('CREDENTIAL_NETRC_PATH', credential_netrc.full_path())\n> +if get_option('tests')\n> +  credential_netrc_testenv = test_environment\n> +  credential_netrc_testenv.set('CREDENTIAL_NETRC_PATH', credential_netrc.full_path())\n>  \n> -test('t-git-credential-netrc',\n> -  shell,\n> -  args: [ meson.current_source_dir() / 't-git-credential-netrc.sh' ],\n> -  workdir: meson.current_source_dir(),\n> -  env: credential_netrc_testenv,\n> -  depends: test_dependencies + bin_wrappers + [credential_netrc],\n> -  timeout: 0,\n> -)\n> +  test('t-git-credential-netrc',\n> +    shell,\n> +    args: [ meson.current_source_dir() / 't-git-credential-netrc.sh' ],\n> +    workdir: meson.current_source_dir(),\n> +    env: credential_netrc_testenv,\n> +    depends: test_dependencies + bin_wrappers + [credential_netrc],\n> +    timeout: 0,\n> +  )\n> +endif\n> diff --git a/contrib/subtree/meson.build b/contrib/subtree/meson.build\n> index 9c72b236259..63714166a61 100644\n> --- a/contrib/subtree/meson.build\n> +++ b/contrib/subtree/meson.build\n> @@ -12,16 +12,18 @@ git_subtree = custom_target(\n>    install_dir: get_option('libexecdir') / 'git-core',\n>  )\n>  \n> -subtree_test_environment = test_environment\n> -subtree_test_environment.prepend('PATH', meson.current_build_dir())\n> +if get_option('tests')\n> +  subtree_test_environment = test_environment\n> +  subtree_test_environment.prepend('PATH', meson.current_build_dir())\n>  \n> -test('t7900-subtree', shell,\n> -  args: [ 't7900-subtree.sh' ],\n> -  env: subtree_test_environment,\n> -  workdir: meson.current_source_dir() / 't',\n> -  depends: test_dependencies + bin_wrappers + [ git_subtree ],\n> -  timeout: 0,\n> -)\n> +  test('t7900-subtree', shell,\n> +    args: [ 't7900-subtree.sh' ],\n> +    env: subtree_test_environment,\n> +    workdir: meson.current_source_dir() / 't',\n> +    depends: test_dependencies + bin_wrappers + [ git_subtree ],\n> +    timeout: 0,\n> +  )\n> +endif\n>  \n>  if get_option('docs').contains('man')\n>    subtree_xml = custom_target(\n"},{"id":"515279","messageId":"xmqqwmc7d8ki.fsf@gitster.g","threadId":"63207","inReplyTo":"20250328-b4-pks-collect-build-fixes-v1-3-ead9deda3fbc@pks.im","subject":"Re: [PATCH 3/4] meson: require Perl when building docs","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2025-03-29T17:56:45Z","receivedAt":"2025-03-29T17:56:48Z","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> From: Eli Schwartz <eschwartz@gentoo.org>\n>\n> When building our documentation we require Perl to generate the list of\n> commands via \"cmd-list.perl\". Having a Perl interpreter available is\n> thus mandatory when building documentation, but Meson does not enforce\n> this prerequisite. Thus, when all optional features that depend on Perl\n> are disabled, we won't look up the Perl interpreter, which will in the\n> end lead to an error at setup time:\n>\n> ```\n> $ meson setup builddir/ -Ddocs=man -Dperl=disabled -Dtests=false\n> [...]\n> Documentation/meson.build:308:22: ERROR: Tried to use not-found external program in \"command\"\n> ```\n>\n> There is already a list of other cases where we do need the Perl\n> interpreter. Building documentation should be one of those cases, but\n> is missing from the list. Add it to fix the issue.\n>\n> Signed-off-by: Eli Schwartz <eschwartz@gentoo.org>\n> Commit-message-edited-by: Patrick Steinhardt <ps@pks.im>\n> Signed-off-by: Patrick Steinhardt <ps@pks.im>\n> ---\n>  meson.build | 2 +-\n>  1 file changed, 1 insertion(+), 1 deletion(-)\n\nTwo puzzling things.\n\n * How is this different from 7c8cd9c1 (meson: fix perl detection\n   when docs are enabled, but perl bindings aren't, 2025-03-16)?\n\n * This uses get_options('docs'); shouldn't it be\n   get_option('docs')?  With that changed, the patch becomes\n   identical to the patch from May 16th, but the proposed log\n   message seems to be vastly different.\n\nI'll drop this step from the series for now, as the other one\nalready has been in 'next'.\n\nThanks.\n\n> diff --git a/meson.build b/meson.build\n> index a8d1e63ccc6..51013c70de9 100644\n> --- a/meson.build\n> +++ b/meson.build\n> @@ -772,7 +772,7 @@ endif\n>  # features. It is optional if you want to neither execute tests nor use any of\n>  # these optional features.\n>  perl_required = get_option('perl')\n> -if get_option('tests') or get_option('gitweb').enabled() or 'netrc' in get_option('credential_helpers')\n> +if get_option('tests') or get_option('gitweb').enabled() or 'netrc' in get_option('credential_helpers') or get_options('docs') != []\n>    perl_required = true\n>  endif\n"},{"id":"515314","messageId":"Z-ovV-9dlXafhJtX@pks.im","threadId":"63207","inReplyTo":"xmqqwmc7d8ki.fsf@gitster.g","subject":"Re: [PATCH 3/4] meson: require Perl when building docs","fromName":"Patrick Steinhardt","fromEmail":"ps@pks.im","sentAt":"2025-03-31T05:59:51Z","receivedAt":"2025-03-31T06:00:01Z","isPatch":true,"sender":{"key":"ps@pks.im","avatar":"https://avatars.githubusercontent.com/u/4056630?v=4"},"body":"On Sat, Mar 29, 2025 at 10:56:45AM -0700, Junio C Hamano wrote:\n> Patrick Steinhardt <ps@pks.im> writes:\n> \n> > From: Eli Schwartz <eschwartz@gentoo.org>\n> >\n> > When building our documentation we require Perl to generate the list of\n> > commands via \"cmd-list.perl\". Having a Perl interpreter available is\n> > thus mandatory when building documentation, but Meson does not enforce\n> > this prerequisite. Thus, when all optional features that depend on Perl\n> > are disabled, we won't look up the Perl interpreter, which will in the\n> > end lead to an error at setup time:\n> >\n> > ```\n> > $ meson setup builddir/ -Ddocs=man -Dperl=disabled -Dtests=false\n> > [...]\n> > Documentation/meson.build:308:22: ERROR: Tried to use not-found external program in \"command\"\n> > ```\n> >\n> > There is already a list of other cases where we do need the Perl\n> > interpreter. Building documentation should be one of those cases, but\n> > is missing from the list. Add it to fix the issue.\n> >\n> > Signed-off-by: Eli Schwartz <eschwartz@gentoo.org>\n> > Commit-message-edited-by: Patrick Steinhardt <ps@pks.im>\n> > Signed-off-by: Patrick Steinhardt <ps@pks.im>\n> > ---\n> >  meson.build | 2 +-\n> >  1 file changed, 1 insertion(+), 1 deletion(-)\n> \n> Two puzzling things.\n> \n>  * How is this different from 7c8cd9c1 (meson: fix perl detection\n>    when docs are enabled, but perl bindings aren't, 2025-03-16)?\n> \n>  * This uses get_options('docs'); shouldn't it be\n>    get_option('docs')?  With that changed, the patch becomes\n>    identical to the patch from May 16th, but the proposed log\n>    message seems to be vastly different.\n\nOh, yeah. I did try to double-check that the topic didn't yet end up in\n'seen' or 'next', but I obviously failed.\n\n> I'll drop this step from the series for now, as the other one\n> already has been in 'next'.\n\nYup, makes sense, thanks!\n\nPatrick\n"},{"id":"515332","messageId":"20250331-b4-pks-collect-build-fixes-v2-0-6b06136808f3@pks.im","threadId":"63207","inReplyTo":"20250328-b4-pks-collect-build-fixes-v1-0-ead9deda3fbc@pks.im","subject":"[PATCH v2 0/5] Collection of build fixes","fromName":"Patrick Steinhardt","fromEmail":"ps@pks.im","sentAt":"2025-03-31T08:33:06Z","receivedAt":"2025-03-31T08:33:20Z","isPatch":true,"sender":{"key":"ps@pks.im","avatar":"https://avatars.githubusercontent.com/u/4056630?v=4"},"body":"Hi,\n\nthis small patch series collects various different smallish fixes for\nissues with the build systems. The intent here is to bundle all of them\ninto a single series to make it a bit easier for Junio to keep track of\nthem.\n\nMore specifically, this series:\n\n  - Fixes an issue with handling \"-Dcurl=auto\" that I spotted recently.\n\n  - Replaces Sam's \"sj/meson-test-environ-fix\" [1] with an alternative\n    solution. The branch is currently in \"seen\".\n\n  - Picks up and massages Thorsten's patch from [2] to fix generation of\n    \"gitweb.js\". The fix has not yet been picked up by Junio.\n\n  - Picks up a cross-compilation fix for Meson [3]. There has been a bit\n    of discussion with Peter whether this is the proper fix, but based\n    on Eli's feedback it should be okay. I'm still open for alternative\n    implementations in case anybody has suggestions for how to do them.\n\nPlease let me know if any of you are unhappy with the way I have given\ncredit. I'm totally happy to change authorship or adjust trailers.\n\nChanges in v2:\n  - Drop the fix for Perl-less documentation builds.\n  - Pick up the fix to use correct environment in our CI builds.\n    Johannes mentioned that he wants to eventually get rid of those\n    builds completely, but meanwhile this is a trivial change to make\n    the jobs do what they should.\n  - Pick up the improvement for cross-compiling Git.\n  - Link to v1: https://lore.kernel.org/r/20250328-b4-pks-collect-build-fixes-v1-0-ead9deda3fbc@pks.im\n\nThanks!\n\nPatrick\n\n[1]: <310a34bace801d288e369c6a01a8d04ffc4c3c06.1741975367.git.sam@gentoo.org>\n[2]: <070641d0-730c-7d92-af4a-9157dc1edd3d@debian.org>\n[3]: <20250303-pks-meson-cross-compiling-v1-1-73002ef6432e@pks.im>\n\n---\nPatrick Steinhardt (5):\n      meson: fix handling of '-Dcurl=auto'\n      gitweb: fix generation of \"gitweb.js\"\n      meson: respect 'tests' build option in contrib\n      meson: distinguish build and target host binaries\n      ci: use Visual Studio for win+meson job on GitHub Workflows\n\n .github/workflows/main.yml           |  2 +-\n .gitlab-ci.yml                       |  2 +-\n Documentation/meson.build            | 12 +++----\n contrib/credential/netrc/meson.build | 22 ++++++------\n contrib/subtree/meson.build          | 20 ++++++-----\n gitweb/Makefile                      |  2 +-\n gitweb/meson.build                   |  2 +-\n meson.build                          | 68 +++++++++++++++++++++++++++---------\n templates/meson.build                |  4 +--\n 9 files changed, 87 insertions(+), 47 deletions(-)\n\nRange-diff versus v1:\n\n1:  4bc8060a975 = 1:  3e9137c2d18 meson: fix handling of '-Dcurl=auto'\n2:  4365cfc4a4e = 2:  7ba983d446e gitweb: fix generation of \"gitweb.js\"\n3:  02d6ae13dd2 < -:  ----------- meson: require Perl when building docs\n4:  fcf2478bd82 = 3:  33cd3e490eb meson: respect 'tests' build option in contrib\n-:  ----------- > 4:  1cb210c91a1 meson: distinguish build and target host binaries\n-:  ----------- > 5:  3172db10a10 ci: use Visual Studio for win+meson job on GitHub Workflows\n\n---\nbase-commit: 683c54c999c301c2cd6f715c411407c413b1d84e\nchange-id: 20250328-b4-pks-collect-build-fixes-b5a6ce086b72\n\n"},{"id":"515333","messageId":"20250331-b4-pks-collect-build-fixes-v2-1-6b06136808f3@pks.im","threadId":"63207","inReplyTo":"20250331-b4-pks-collect-build-fixes-v2-0-6b06136808f3@pks.im","subject":"[PATCH v2 1/5] meson: fix handling of '-Dcurl=auto'","fromName":"Patrick Steinhardt","fromEmail":"ps@pks.im","sentAt":"2025-03-31T08:33:07Z","receivedAt":"2025-03-31T08:33:21Z","isPatch":true,"sender":{"key":"ps@pks.im","avatar":"https://avatars.githubusercontent.com/u/4056630?v=4"},"body":"The \"curl\" option controls whether or not a couple of features that\ndepend on curl shall be included. Most importantly, these features\ninclude the HTTP remote helpers, which are rather quintessential for a\nwell-functioning Git installation. So while the dependency can in theory\nbe dropped, most users wouldn't consider the resulting installation to\nbe fully functional.\n\nThe \"curl\" option is defined as a feature, which means that it can be\n\"enabled\", \"disabled\" or \"auto\", which has the effect that the feature\nwill be enabled if the dependency itself has been found. While most of\nthe other features have \"auto\" as default value, the \"curl\" option is\nset to \"enabled\" by default due to it being so important. Consequently,\nautoconfiguration of Git will fail by default if the library cannot be\nfound.\n\nThere is a bug though with how we handle the option in case the user\noverrides the feature with `meson setup -Dcurl=auto`: while we will try\nto find the library in that case, we won't ever use it because we later\non check for `get_option('curl').enabled()` when deciding whether or not\nwe want to build dependent sources. But `enabled()` only returns true if\nthe option has the value \"enabled\", for \"auto\" it will return false.\n\nFix the issue by instead checking for `curl.found()`, which is only true\nif the library has been found. And as we only try to find the library\nwhen `get_option('curl')` returns \"true\" or \"auto\" this is exactly what\nwe want.\n\nSigned-off-by: Patrick Steinhardt <ps@pks.im>\n---\n meson.build | 2 +-\n 1 file changed, 1 insertion(+), 1 deletion(-)\n\ndiff --git a/meson.build b/meson.build\nindex efe2871c9db..a8d1e63ccc6 100644\n--- a/meson.build\n+++ b/meson.build\n@@ -1686,7 +1686,7 @@ bin_wrappers += executable('scalar',\n   install_dir: get_option('libexecdir') / 'git-core',\n )\n \n-if get_option('curl').enabled()\n+if curl.found()\n   libgit_curl = declare_dependency(\n     sources: [\n       'http.c',\n\n-- \n2.49.0.604.gff1f9ca942.dirty\n\n"},{"id":"515334","messageId":"20250331-b4-pks-collect-build-fixes-v2-2-6b06136808f3@pks.im","threadId":"63207","inReplyTo":"20250331-b4-pks-collect-build-fixes-v2-0-6b06136808f3@pks.im","subject":"[PATCH v2 2/5] gitweb: fix generation of \"gitweb.js\"","fromName":"Patrick Steinhardt","fromEmail":"ps@pks.im","sentAt":"2025-03-31T08:33:08Z","receivedAt":"2025-03-31T08:33:21Z","isPatch":true,"sender":{"key":"ps@pks.im","avatar":"https://avatars.githubusercontent.com/u/4056630?v=4"},"body":"In 19d8fe7da65 (Makefile: extract script to generate gitweb.js,\n2024-12-06) we have extracted the logic to build \"gitweb.js\" into a\nseparate script. As part of that the rules that builds the script\nhas gained a new dependency on that script.\n\nThis refactoring is broken though because we use \"$^\" to determine\nthe set of JavaScript files that need to be concatenated, and this\nimplicit variable now also contains the build script itself. As a\nresult, the build script ends up ni the generated \"gitweb.js\" file,\nwhich is wrong.\n\nFix the issue by filtering out non-JavaScript files.\n\nBased-on-patch-by: Thorsten Glaser <tg@debian.org>\nSigned-off-by: Patrick Steinhardt <ps@pks.im>\n---\n gitweb/Makefile | 2 +-\n 1 file changed, 1 insertion(+), 1 deletion(-)\n\ndiff --git a/gitweb/Makefile b/gitweb/Makefile\nindex d5748e93594..26a683d4421 100644\n--- a/gitweb/Makefile\n+++ b/gitweb/Makefile\n@@ -118,7 +118,7 @@ $(MAK_DIR_GITWEB)gitweb.cgi: $(MAK_DIR_GITWEB)gitweb.perl\n $(MAK_DIR_GITWEB)static/gitweb.js: $(MAK_DIR_GITWEB)generate-gitweb-js.sh\n $(MAK_DIR_GITWEB)static/gitweb.js: $(addprefix $(MAK_DIR_GITWEB),$(GITWEB_JSLIB_FILES))\n \t$(QUIET_GEN)$(RM) $@ $@+ && \\\n-\t$(MAK_DIR_GITWEB)generate-gitweb-js.sh $@+ $^ && \\\n+\t$(MAK_DIR_GITWEB)generate-gitweb-js.sh $@+ $(filter %.js,$^) && \\\n \tmv $@+ $@\n \n ### Installation rules\n\n-- \n2.49.0.604.gff1f9ca942.dirty\n\n"},{"id":"515335","messageId":"20250331-b4-pks-collect-build-fixes-v2-3-6b06136808f3@pks.im","threadId":"63207","inReplyTo":"20250331-b4-pks-collect-build-fixes-v2-0-6b06136808f3@pks.im","subject":"[PATCH v2 3/5] meson: respect 'tests' build option in contrib","fromName":"Patrick Steinhardt","fromEmail":"ps@pks.im","sentAt":"2025-03-31T08:33:09Z","receivedAt":"2025-03-31T08:33:23Z","isPatch":true,"sender":{"key":"ps@pks.im","avatar":"https://avatars.githubusercontent.com/u/4056630?v=4"},"body":"Both the \"netrc\" credential helper and git-subtree(1) from \"contrib/\"\ncarry a couple of tests with them. These tests get wired up in Meson\nunconditionally even in the case where `-Dtests=false`. As those tests\ndepend on the `test_enviroment` variable, which only gets defined in\ncase `-Dtests=true`, the result is an error:\n\n```\n$ meson setup -Dtests=false -Dcontrib=subtree build\n[...]\n\ncontrib/subtree/meson.build:15:27: ERROR: Unknown variable \"test_environment\".\n```\n\nFix the issue by not defining these tests at all in case the \"tests\"\noption is set to `false`.\n\nReported-by: Sam James <sam@gentoo.org>\nSigned-off-by: Patrick Steinhardt <ps@pks.im>\n---\n contrib/credential/netrc/meson.build | 22 ++++++++++++----------\n contrib/subtree/meson.build          | 20 +++++++++++---------\n 2 files changed, 23 insertions(+), 19 deletions(-)\n\ndiff --git a/contrib/credential/netrc/meson.build b/contrib/credential/netrc/meson.build\nindex a990dbb86da..3d74547c8ae 100644\n--- a/contrib/credential/netrc/meson.build\n+++ b/contrib/credential/netrc/meson.build\n@@ -7,14 +7,16 @@ credential_netrc = custom_target(\n   install_dir: get_option('libexecdir') / 'git-core',\n )\n \n-credential_netrc_testenv = test_environment\n-credential_netrc_testenv.set('CREDENTIAL_NETRC_PATH', credential_netrc.full_path())\n+if get_option('tests')\n+  credential_netrc_testenv = test_environment\n+  credential_netrc_testenv.set('CREDENTIAL_NETRC_PATH', credential_netrc.full_path())\n \n-test('t-git-credential-netrc',\n-  shell,\n-  args: [ meson.current_source_dir() / 't-git-credential-netrc.sh' ],\n-  workdir: meson.current_source_dir(),\n-  env: credential_netrc_testenv,\n-  depends: test_dependencies + bin_wrappers + [credential_netrc],\n-  timeout: 0,\n-)\n+  test('t-git-credential-netrc',\n+    shell,\n+    args: [ meson.current_source_dir() / 't-git-credential-netrc.sh' ],\n+    workdir: meson.current_source_dir(),\n+    env: credential_netrc_testenv,\n+    depends: test_dependencies + bin_wrappers + [credential_netrc],\n+    timeout: 0,\n+  )\n+endif\ndiff --git a/contrib/subtree/meson.build b/contrib/subtree/meson.build\nindex 9c72b236259..63714166a61 100644\n--- a/contrib/subtree/meson.build\n+++ b/contrib/subtree/meson.build\n@@ -12,16 +12,18 @@ git_subtree = custom_target(\n   install_dir: get_option('libexecdir') / 'git-core',\n )\n \n-subtree_test_environment = test_environment\n-subtree_test_environment.prepend('PATH', meson.current_build_dir())\n+if get_option('tests')\n+  subtree_test_environment = test_environment\n+  subtree_test_environment.prepend('PATH', meson.current_build_dir())\n \n-test('t7900-subtree', shell,\n-  args: [ 't7900-subtree.sh' ],\n-  env: subtree_test_environment,\n-  workdir: meson.current_source_dir() / 't',\n-  depends: test_dependencies + bin_wrappers + [ git_subtree ],\n-  timeout: 0,\n-)\n+  test('t7900-subtree', shell,\n+    args: [ 't7900-subtree.sh' ],\n+    env: subtree_test_environment,\n+    workdir: meson.current_source_dir() / 't',\n+    depends: test_dependencies + bin_wrappers + [ git_subtree ],\n+    timeout: 0,\n+  )\n+endif\n \n if get_option('docs').contains('man')\n   subtree_xml = custom_target(\n\n-- \n2.49.0.604.gff1f9ca942.dirty\n\n"},{"id":"515336","messageId":"20250331-b4-pks-collect-build-fixes-v2-5-6b06136808f3@pks.im","threadId":"63207","inReplyTo":"20250331-b4-pks-collect-build-fixes-v2-0-6b06136808f3@pks.im","subject":"[PATCH v2 5/5] ci: use Visual Studio for win+meson job on GitHub Workflows","fromName":"Patrick Steinhardt","fromEmail":"ps@pks.im","sentAt":"2025-03-31T08:33:11Z","receivedAt":"2025-03-31T08:33:23Z","isPatch":true,"sender":{"key":"ps@pks.im","avatar":"https://avatars.githubusercontent.com/u/4056630?v=4"},"body":"In 7304bd2bc39 (ci: wire up Visual Studio build with Meson, 2025-01-22)\nwe have wired up a new CI job that builds and tests Git with Meson on a\nWindows machine. The expectation here was that this build uses the\nVisual Studio toolchain to do so, and that is true on GitLab CI. But on\nGitHub Workflows it is not the case because we've got GCC in our PATH,\nand thus Meson favors that compiler toolchain over Visual Studio's.\n\nFix this by explicitly asking Meson to use the Visual Studio toolchain.\nWhile this is only really required for GitHub Workflows, let's also pass\nthe flag in GitLab CI so that we don't implicitly assume the toolchain\nthat Meson is going to pick.\n\nReported-by: Johannes Schindelin <johannes.schindelin@gmx.de>\nSigned-off-by: Patrick Steinhardt <ps@pks.im>\n---\n .github/workflows/main.yml | 2 +-\n .gitlab-ci.yml             | 2 +-\n 2 files changed, 2 insertions(+), 2 deletions(-)\n\ndiff --git a/.github/workflows/main.yml b/.github/workflows/main.yml\nindex 9959b61ece2..6a002485aeb 100644\n--- a/.github/workflows/main.yml\n+++ b/.github/workflows/main.yml\n@@ -265,7 +265,7 @@ jobs:\n       run: pip install meson ninja\n     - name: Setup\n       shell: pwsh\n-      run: meson setup build -Dperl=disabled -Dcredential_helpers=wincred\n+      run: meson setup build --vsenv -Dperl=disabled -Dcredential_helpers=wincred\n     - name: Compile\n       shell: pwsh\n       run: meson compile -C build\ndiff --git a/.gitlab-ci.yml b/.gitlab-ci.yml\nindex 2805cdeecb6..4798b283745 100644\n--- a/.gitlab-ci.yml\n+++ b/.gitlab-ci.yml\n@@ -164,7 +164,7 @@ build:msvc-meson:\n   extends: .msvc-meson\n   stage: build\n   script:\n-    - meson setup build -Dperl=disabled -Dbackend_max_links=1 -Dcredential_helpers=wincred\n+    - meson setup build --vsenv -Dperl=disabled -Dbackend_max_links=1 -Dcredential_helpers=wincred\n     - meson compile -C build\n   artifacts:\n     paths:\n\n-- \n2.49.0.604.gff1f9ca942.dirty\n\n"},{"id":"515337","messageId":"20250331-b4-pks-collect-build-fixes-v2-4-6b06136808f3@pks.im","threadId":"63207","inReplyTo":"20250331-b4-pks-collect-build-fixes-v2-0-6b06136808f3@pks.im","subject":"[PATCH v2 4/5] meson: distinguish build and target host binaries","fromName":"Patrick Steinhardt","fromEmail":"ps@pks.im","sentAt":"2025-03-31T08:33:10Z","receivedAt":"2025-03-31T08:33:23Z","isPatch":true,"sender":{"key":"ps@pks.im","avatar":"https://avatars.githubusercontent.com/u/4056630?v=4"},"body":"Almost all of the tools we discover during the build process need to be\nnative programs. There are only a handful of exceptions, which typically\nare programs whose paths we need to embed into the resulting executable\nso that they can be found on the target system when Git executes. While\nthis distinction typically doesn't matter, it does start to matter when\nconsidering cross-compilation where the build and target machines are\ndifferent.\n\nMeson supports cross-compilation via so-called machine files. These\nmachine files allow the user to override parameters for the build\nmachine, but also for the target machine when cross-compiling. Part of\nthe machine file is a section that allows the user to override the\nlocation where binaries are to be found in the target system. The\nfollowing machine file would for example override the path of the POSIX\nshell:\n\n    [binaries]\n    sh = '/usr/xpg4/bin/sh'\n\nIt can be handed over to Meson via `meson setup --cross-file`.\n\nWe do not handle this correctly right now though because we don't know\nto distinguish binaries for the build and target hosts at all. Address\nthis by explicitly passing the `native:` parameter to `find_program()`:\n\n  - When set to `true`, we get binaries discovered on the build host.\n\n  - When set to `false`, we get either the path specified in the\n    machine file. Or, if no machine file exists or it doesn't specify\n    the binary path, then we fall back to the binary discovered on the\n    build host.\n\nAs mentioned, only a handful of binaries are not native: only the system\nshell, Python and Perl need to be treated specially here.\n\nReported-by: Peter Seiderer <ps.report@gmx.net>\nSigned-off-by: Patrick Steinhardt <ps@pks.im>\n---\n Documentation/meson.build | 12 ++++-----\n gitweb/meson.build        |  2 +-\n meson.build               | 66 ++++++++++++++++++++++++++++++++++++-----------\n templates/meson.build     |  4 +--\n 4 files changed, 60 insertions(+), 24 deletions(-)\n\ndiff --git a/Documentation/meson.build b/Documentation/meson.build\nindex 594546d68b1..32f0c5de12a 100644\n--- a/Documentation/meson.build\n+++ b/Documentation/meson.build\n@@ -207,9 +207,9 @@ manpages = {\n \n docs_backend = get_option('docs_backend')\n if docs_backend == 'auto'\n-  if find_program('asciidoc', dirs: program_path, required: false).found()\n+  if find_program('asciidoc', dirs: program_path, native: true, required: false).found()\n     docs_backend = 'asciidoc'\n-  elif find_program('asciidoctor', dirs: program_path, required: false).found()\n+  elif find_program('asciidoctor', dirs: program_path, native: true, required: false).found()\n     docs_backend = 'asciidoctor'\n   else\n     error('Neither asciidoc nor asciidoctor were found.')\n@@ -217,7 +217,7 @@ if docs_backend == 'auto'\n endif\n \n if docs_backend == 'asciidoc'\n-  asciidoc = find_program('asciidoc', dirs: program_path)\n+  asciidoc = find_program('asciidoc', dirs: program_path, native: true)\n   asciidoc_html = 'xhtml11'\n   asciidoc_docbook = 'docbook'\n   xmlto_extra = [ ]\n@@ -246,7 +246,7 @@ if docs_backend == 'asciidoc'\n     asciidoc_conf,\n   ]\n elif docs_backend == 'asciidoctor'\n-  asciidoctor = find_program('asciidoctor', dirs: program_path)\n+  asciidoctor = find_program('asciidoctor', dirs: program_path, native: true)\n   asciidoc_html = 'xhtml5'\n   asciidoc_docbook = 'docbook5'\n   xmlto_extra = [\n@@ -288,7 +288,7 @@ if get_option('breaking_changes')\n    asciidoc_common_options += ['--attribute', 'with-breaking-changes']\n endif\n \n-xmlto = find_program('xmlto', dirs: program_path)\n+xmlto = find_program('xmlto', dirs: program_path, native: true)\n \n cmd_lists = [\n   'cmds-ancillaryinterrogators.adoc',\n@@ -409,7 +409,7 @@ if get_option('docs').contains('html')\n     pointing_to: 'git.html',\n   )\n \n-  xsltproc = find_program('xsltproc', dirs: program_path)\n+  xsltproc = find_program('xsltproc', dirs: program_path, native: true)\n \n   user_manual_xml = custom_target(\n     command: asciidoc_common_options + [\ndiff --git a/gitweb/meson.build b/gitweb/meson.build\nindex 89b403dc9de..88a54b4dc99 100644\n--- a/gitweb/meson.build\n+++ b/gitweb/meson.build\n@@ -1,5 +1,5 @@\n gitweb_config = configuration_data()\n-gitweb_config.set_quoted('PERL_PATH', perl.full_path())\n+gitweb_config.set_quoted('PERL_PATH', target_perl.full_path())\n gitweb_config.set_quoted('CSSMIN', '')\n gitweb_config.set_quoted('JSMIN', '')\n gitweb_config.set_quoted('GIT_BINDIR', get_option('prefix') / get_option('bindir'))\ndiff --git a/meson.build b/meson.build\nindex a8d1e63ccc6..79a50599ba8 100644\n--- a/meson.build\n+++ b/meson.build\n@@ -155,6 +155,37 @@\n # These machine files can be passed to `meson setup` via the `--native-file`\n # option.\n #\n+# Cross compilation\n+# =================\n+#\n+# Machine files can also be used in the context of cross-compilation to\n+# describe the target machine as well as the cross-compiler toolchain that\n+# shall be used. An example machine file could look like the following:\n+#\n+#   [binaries]\n+#   c = 'x86_64-w64-mingw32-gcc'\n+#   cpp = 'x86_64-w64-mingw32-g++'\n+#   ar = 'x86_64-w64-mingw32-ar'\n+#   windres = 'x86_64-w64-mingw32-windres'\n+#   strip = 'x86_64-w64-mingw32-strip'\n+#   exe_wrapper = 'wine64'\n+#   sh = 'C:/Program Files/Git for Windows/usr/bin/sh.exe'\n+#\n+#   [host_machine]\n+#   system = 'windows'\n+#   cpu_family = 'x86_64'\n+#   cpu = 'x86_64'\n+#   endian = 'little'\n+#\n+# These machine files can be passed to `meson setup` via the `--cross-file`\n+# option.\n+#\n+# Note that next to the cross-compiler toolchain, the `[binaries]` section is\n+# also used to locate a couple of binaries that will be built into Git. This\n+# includes `sh`, `python` and `perl`, so when cross-compiling Git you likely\n+# want to set these binary paths in addition to the cross-compiler toolchain\n+# binaries.\n+#\n # Subproject wrappers\n # ===================\n #\n@@ -173,7 +204,7 @@ project('git', 'c',\n   # The version is only of cosmetic nature, so if we cannot find a shell yet we\n   # simply don't set up a version at all. This may be the case for example on\n   # Windows systems, where we first have to bootstrap the host environment.\n-  version: find_program('sh', required: false).found() ? run_command(\n+  version: find_program('sh', native: true, required: false).found() ? run_command(\n     'GIT-VERSION-GEN', meson.current_source_dir(), '--format=@GIT_VERSION@',\n     capture: true,\n     check: true,\n@@ -198,16 +229,18 @@ elif host_machine.system() == 'windows'\n   program_path = [ 'C:/Program Files/Git/bin', 'C:/Program Files/Git/usr/bin' ]\n endif\n \n-cygpath = find_program('cygpath', dirs: program_path, required: false)\n-diff = find_program('diff', dirs: program_path)\n-git = find_program('git', dirs: program_path, required: false)\n-sed = find_program('sed', dirs: program_path)\n-shell = find_program('sh', dirs: program_path)\n-tar = find_program('tar', dirs: program_path)\n+cygpath = find_program('cygpath', dirs: program_path, native: true, required: false)\n+diff = find_program('diff', dirs: program_path, native: true)\n+git = find_program('git', dirs: program_path, native: true, required: false)\n+sed = find_program('sed', dirs: program_path, native: true)\n+shell = find_program('sh', dirs: program_path, native: true)\n+tar = find_program('tar', dirs: program_path, native: true)\n+\n+target_shell = find_program('sh', dirs: program_path, native: false)\n \n # Sanity-check that programs required for the build exist.\n foreach tool : ['cat', 'cut', 'grep', 'sort', 'tr', 'uname']\n-  find_program(tool, dirs: program_path)\n+  find_program(tool, dirs: program_path, native: true)\n endforeach\n \n script_environment = environment()\n@@ -706,7 +739,7 @@ libgit_c_args = [\n   '-DGIT_LOCALE_PATH=\"' + get_option('localedir') + '\"',\n   '-DGIT_MAN_PATH=\"' + get_option('mandir') + '\"',\n   '-DPAGER_ENV=\"' + get_option('pager_environment') + '\"',\n-  '-DSHELL_PATH=\"' + fs.as_posix(shell.full_path()) + '\"',\n+  '-DSHELL_PATH=\"' + fs.as_posix(target_shell.full_path()) + '\"',\n ]\n libgit_include_directories = [ '.' ]\n libgit_dependencies = [ ]\n@@ -761,6 +794,7 @@ endif\n build_options_config.set_quoted('X', executable_suffix)\n \n python = import('python').find_installation('python3', required: get_option('python'))\n+target_python = find_program('python3', native: false, required: python.found())\n if python.found()\n   build_options_config.set('NO_PYTHON', '')\n else\n@@ -790,9 +824,11 @@ endif\n # which we can do starting with Meson 1.5.0 and newer, or we have to\n # match against the minor version.\n if meson.version().version_compare('>=1.5.0')\n-  perl = find_program('perl', dirs: program_path, required: perl_required, version: '>=5.26.0', version_argument: '-V:version')\n+  perl = find_program('perl', dirs: program_path, native: true, required: perl_required, version: '>=5.26.0', version_argument: '-V:version')\n+  target_perl = find_program('perl', dirs: program_path, native: false, required: perl.found(), version: '>=5.26.0', version_argument: '-V:version')\n else\n-  perl = find_program('perl', dirs: program_path, required: perl_required, version: '>=26')\n+  perl = find_program('perl', dirs: program_path, native: true, required: perl_required, version: '>=26')\n+  target_perl = find_program('perl', dirs: program_path, native: false, required: perl.found(), version: '>=26')\n endif\n perl_features_enabled = perl.found() and get_option('perl').allowed()\n if perl_features_enabled\n@@ -843,7 +879,7 @@ else\n   build_options_config.set('NO_PTHREADS', '1')\n endif\n \n-msgfmt = find_program('msgfmt', dirs: program_path, required: false)\n+msgfmt = find_program('msgfmt', dirs: program_path, native: true, required: false)\n gettext_option = get_option('gettext').disable_auto_if(not msgfmt.found())\n if not msgfmt.found() and gettext_option.enabled()\n   error('Internationalization via libintl requires msgfmt')\n@@ -1974,9 +2010,9 @@ foreach key, value : {\n   'GIT_TEST_TEMPLATE_DIR': meson.project_build_root() / 'templates',\n   'GIT_TEST_TEXTDOMAINDIR': meson.project_build_root() / 'po',\n   'PAGER_ENV': get_option('pager_environment'),\n-  'PERL_PATH': perl.found() ? perl.full_path() : '',\n-  'PYTHON_PATH': python.found () ? python.full_path() : '',\n-  'SHELL_PATH': shell.full_path(),\n+  'PERL_PATH': target_perl.found() ? target_perl.full_path() : '',\n+  'PYTHON_PATH': target_python.found () ? target_python.full_path() : '',\n+  'SHELL_PATH': target_shell.full_path(),\n   'TAR': tar.full_path(),\n   'TEST_OUTPUT_DIRECTORY': test_output_directory,\n   'TEST_SHELL_PATH': shell.full_path(),\ndiff --git a/templates/meson.build b/templates/meson.build\nindex 1faf9a44cea..02e6eebe80b 100644\n--- a/templates/meson.build\n+++ b/templates/meson.build\n@@ -1,6 +1,6 @@\n template_config = configuration_data()\n-template_config.set('PERL_PATH', perl.found() ? fs.as_posix(perl.full_path()) : '')\n-template_config.set('SHELL_PATH', fs.as_posix(shell.full_path()))\n+template_config.set('PERL_PATH', target_perl.found() ? fs.as_posix(target_perl.full_path()) : '')\n+template_config.set('SHELL_PATH', fs.as_posix(target_shell.full_path()))\n template_config.set('GITWEBDIR', fs.as_posix(get_option('prefix') / get_option('datadir') / 'gitweb'))\n \n configure_file(\n\n-- \n2.49.0.604.gff1f9ca942.dirty\n\n"},{"id":"515447","messageId":"e9ea3630-a831-dec5-e461-3f550ceb7ec3@gmx.de","threadId":"63207","inReplyTo":"20250331-b4-pks-collect-build-fixes-v2-2-6b06136808f3@pks.im","subject":"Re: [PATCH v2 2/5] gitweb: fix generation of \"gitweb.js\"","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2025-04-01T16:30:01Z","receivedAt":"2025-04-01T16:30:25Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi Patrick,\n\nOn Mon, 31 Mar 2025, Patrick Steinhardt wrote:\n\n> diff --git a/gitweb/Makefile b/gitweb/Makefile\n> index d5748e93594..26a683d4421 100644\n> --- a/gitweb/Makefile\n> +++ b/gitweb/Makefile\n> @@ -118,7 +118,7 @@ $(MAK_DIR_GITWEB)gitweb.cgi: $(MAK_DIR_GITWEB)gitweb.perl\n>  $(MAK_DIR_GITWEB)static/gitweb.js: $(MAK_DIR_GITWEB)generate-gitweb-js.sh\n>  $(MAK_DIR_GITWEB)static/gitweb.js: $(addprefix $(MAK_DIR_GITWEB),$(GITWEB_JSLIB_FILES))\n>  \t$(QUIET_GEN)$(RM) $@ $@+ && \\\n> -\t$(MAK_DIR_GITWEB)generate-gitweb-js.sh $@+ $^ && \\\n> +\t$(MAK_DIR_GITWEB)generate-gitweb-js.sh $@+ $(filter %.js,$^) && \\\n>  \tmv $@+ $@\n\nA safer way might be to use `$(filter-out %.sh,$^)` just in case the\nJavascript libraries might at some stage be renamed (I could imagine, for\nexample, that someone aims for ideological purity and renames them to\n`*.cjs`).\n\nCiao,\nJohannes\n"},{"id":"515448","messageId":"87ecybg7z5.fsf@iotcl.com","threadId":"63207","inReplyTo":"20250331-b4-pks-collect-build-fixes-v2-2-6b06136808f3@pks.im","subject":"Re: [PATCH v2 2/5] gitweb: fix generation of \"gitweb.js\"","fromName":"Toon Claes","fromEmail":"toon@iotcl.com","sentAt":"2025-04-01T16:30:22Z","receivedAt":"2025-04-01T16:30:37Z","isPatch":true,"sender":{"key":"toon@iotcl.com","avatar":"https://avatars.githubusercontent.com/u/121621?v=4"},"body":"Patrick Steinhardt <ps@pks.im> writes:\n\n> In 19d8fe7da65 (Makefile: extract script to generate gitweb.js,\n> 2024-12-06) we have extracted the logic to build \"gitweb.js\" into a\n> separate script. As part of that the rules that builds the script\n> has gained a new dependency on that script.\n>\n> This refactoring is broken though because we use \"$^\" to determine\n> the set of JavaScript files that need to be concatenated, and this\n> implicit variable now also contains the build script itself. As a\n> result, the build script ends up ni the generated \"gitweb.js\" file,\n\nTiniest typo: ni -> in\n\nBut that's all I've got about this patch series. :+1:\n\n-- \nToon\n"},{"id":"515449","messageId":"56435f95-986b-8116-2fef-9d6adfa1bc65@gmx.de","threadId":"63207","inReplyTo":"20250331-b4-pks-collect-build-fixes-v2-3-6b06136808f3@pks.im","subject":"Re: [PATCH v2 3/5] meson: respect 'tests' build option in contrib","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2025-04-01T16:31:57Z","receivedAt":"2025-04-01T16:32:19Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi Patrick,\n\nOn Mon, 31 Mar 2025, Patrick Steinhardt wrote:\n\n> Both the \"netrc\" credential helper and git-subtree(1) from \"contrib/\"\n> carry a couple of tests with them. These tests get wired up in Meson\n> unconditionally even in the case where `-Dtests=false`. As those tests\n> depend on the `test_enviroment` variable, which only gets defined in\n> case `-Dtests=true`, the result is an error:\n>\n> ```\n> $ meson setup -Dtests=false -Dcontrib=subtree build\n> [...]\n>\n> contrib/subtree/meson.build:15:27: ERROR: Unknown variable \"test_environment\".\n> ```\n>\n> Fix the issue by not defining these tests at all in case the \"tests\"\n> option is set to `false`.\n\nSounds good, and the patch looks good to me (it would look even better if\nI had proper code reviewing tools here where I could use the `-w` option,\nbut mailing lists do not offer such tools).\n\nCiao,\nJohannes\n\n>\n> Reported-by: Sam James <sam@gentoo.org>\n> Signed-off-by: Patrick Steinhardt <ps@pks.im>\n> ---\n>  contrib/credential/netrc/meson.build | 22 ++++++++++++----------\n>  contrib/subtree/meson.build          | 20 +++++++++++---------\n>  2 files changed, 23 insertions(+), 19 deletions(-)\n>\n> diff --git a/contrib/credential/netrc/meson.build b/contrib/credential/netrc/meson.build\n> index a990dbb86da..3d74547c8ae 100644\n> --- a/contrib/credential/netrc/meson.build\n> +++ b/contrib/credential/netrc/meson.build\n> @@ -7,14 +7,16 @@ credential_netrc = custom_target(\n>    install_dir: get_option('libexecdir') / 'git-core',\n>  )\n>\n> -credential_netrc_testenv = test_environment\n> -credential_netrc_testenv.set('CREDENTIAL_NETRC_PATH', credential_netrc.full_path())\n> +if get_option('tests')\n> +  credential_netrc_testenv = test_environment\n> +  credential_netrc_testenv.set('CREDENTIAL_NETRC_PATH', credential_netrc.full_path())\n>\n> -test('t-git-credential-netrc',\n> -  shell,\n> -  args: [ meson.current_source_dir() / 't-git-credential-netrc.sh' ],\n> -  workdir: meson.current_source_dir(),\n> -  env: credential_netrc_testenv,\n> -  depends: test_dependencies + bin_wrappers + [credential_netrc],\n> -  timeout: 0,\n> -)\n> +  test('t-git-credential-netrc',\n> +    shell,\n> +    args: [ meson.current_source_dir() / 't-git-credential-netrc.sh' ],\n> +    workdir: meson.current_source_dir(),\n> +    env: credential_netrc_testenv,\n> +    depends: test_dependencies + bin_wrappers + [credential_netrc],\n> +    timeout: 0,\n> +  )\n> +endif\n> diff --git a/contrib/subtree/meson.build b/contrib/subtree/meson.build\n> index 9c72b236259..63714166a61 100644\n> --- a/contrib/subtree/meson.build\n> +++ b/contrib/subtree/meson.build\n> @@ -12,16 +12,18 @@ git_subtree = custom_target(\n>    install_dir: get_option('libexecdir') / 'git-core',\n>  )\n>\n> -subtree_test_environment = test_environment\n> -subtree_test_environment.prepend('PATH', meson.current_build_dir())\n> +if get_option('tests')\n> +  subtree_test_environment = test_environment\n> +  subtree_test_environment.prepend('PATH', meson.current_build_dir())\n>\n> -test('t7900-subtree', shell,\n> -  args: [ 't7900-subtree.sh' ],\n> -  env: subtree_test_environment,\n> -  workdir: meson.current_source_dir() / 't',\n> -  depends: test_dependencies + bin_wrappers + [ git_subtree ],\n> -  timeout: 0,\n> -)\n> +  test('t7900-subtree', shell,\n> +    args: [ 't7900-subtree.sh' ],\n> +    env: subtree_test_environment,\n> +    workdir: meson.current_source_dir() / 't',\n> +    depends: test_dependencies + bin_wrappers + [ git_subtree ],\n> +    timeout: 0,\n> +  )\n> +endif\n>\n>  if get_option('docs').contains('man')\n>    subtree_xml = custom_target(\n>\n> --\n> 2.49.0.604.gff1f9ca942.dirty\n>\n>\n>\n"},{"id":"515451","messageId":"66b9d3d1-9874-8dfd-9de9-5682a7b6655d@gmx.de","threadId":"63207","inReplyTo":"20250331-b4-pks-collect-build-fixes-v2-0-6b06136808f3@pks.im","subject":"Re: [PATCH v2 0/5] Collection of build fixes","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2025-04-01T16:41:43Z","receivedAt":"2025-04-01T16:41:55Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi Patrick,\n\nOn Mon, 31 Mar 2025, Patrick Steinhardt wrote:\n\n> this small patch series collects various different smallish fixes for\n> issues with the build systems. The intent here is to bundle all of them\n> into a single series to make it a bit easier for Junio to keep track of\n> them.\n>\n> More specifically, this series:\n>\n>   - Fixes an issue with handling \"-Dcurl=auto\" that I spotted recently.\n>\n>   - Replaces Sam's \"sj/meson-test-environ-fix\" [1] with an alternative\n>     solution. The branch is currently in \"seen\".\n>\n>   - Picks up and massages Thorsten's patch from [2] to fix generation of\n>     \"gitweb.js\". The fix has not yet been picked up by Junio.\n>\n>   - Picks up a cross-compilation fix for Meson [3]. There has been a bit\n>     of discussion with Peter whether this is the proper fix, but based\n>     on Eli's feedback it should be okay. I'm still open for alternative\n>     implementations in case anybody has suggestions for how to do them.\n\nThese all look good to me (with the exception of the cross-compilation\nfix, but only because I am too unfamiliar with Meson to speak about the\ncorrectness of this patch).\n\n>\n> Please let me know if any of you are unhappy with the way I have given\n> credit. I'm totally happy to change authorship or adjust trailers.\n>\n> Changes in v2:\n>   - Drop the fix for Perl-less documentation builds.\n>   - Pick up the fix to use correct environment in our CI builds.\n>     Johannes mentioned that he wants to eventually get rid of those\n>     builds completely, but meanwhile this is a trivial change to make\n>     the jobs do what they should.\n\nMore precisely, since we are now spending around 9.5 hours of total CPU\ntime for every single CI build (completely running over the concurrency\nlimit of 20 parallel jobs on GitHub even for a single CI run, with the\nobvious congestion when there are parallel CI runs), I want to drop all\npretense that Git supports CMake builds on Windows (or Visual Studio\nbuilds, for that matter). It's just too much of an uphill battle and I no\nlonger have the will to deal with it.\n\nThank you for reminding me that I wanted to work on that patch.\n\nCiao,\nJohannes\n\n>   - Pick up the improvement for cross-compiling Git.\n>   - Link to v1: https://lore.kernel.org/r/20250328-b4-pks-collect-build-fixes-v1-0-ead9deda3fbc@pks.im\n>\n> Thanks!\n>\n> Patrick\n>\n> [1]: <310a34bace801d288e369c6a01a8d04ffc4c3c06.1741975367.git.sam@gentoo.org>\n> [2]: <070641d0-730c-7d92-af4a-9157dc1edd3d@debian.org>\n> [3]: <20250303-pks-meson-cross-compiling-v1-1-73002ef6432e@pks.im>\n>\n> ---\n> Patrick Steinhardt (5):\n>       meson: fix handling of '-Dcurl=auto'\n>       gitweb: fix generation of \"gitweb.js\"\n>       meson: respect 'tests' build option in contrib\n>       meson: distinguish build and target host binaries\n>       ci: use Visual Studio for win+meson job on GitHub Workflows\n>\n>  .github/workflows/main.yml           |  2 +-\n>  .gitlab-ci.yml                       |  2 +-\n>  Documentation/meson.build            | 12 +++----\n>  contrib/credential/netrc/meson.build | 22 ++++++------\n>  contrib/subtree/meson.build          | 20 ++++++-----\n>  gitweb/Makefile                      |  2 +-\n>  gitweb/meson.build                   |  2 +-\n>  meson.build                          | 68 +++++++++++++++++++++++++++---------\n>  templates/meson.build                |  4 +--\n>  9 files changed, 87 insertions(+), 47 deletions(-)\n>\n> Range-diff versus v1:\n>\n> 1:  4bc8060a975 = 1:  3e9137c2d18 meson: fix handling of '-Dcurl=auto'\n> 2:  4365cfc4a4e = 2:  7ba983d446e gitweb: fix generation of \"gitweb.js\"\n> 3:  02d6ae13dd2 < -:  ----------- meson: require Perl when building docs\n> 4:  fcf2478bd82 = 3:  33cd3e490eb meson: respect 'tests' build option in contrib\n> -:  ----------- > 4:  1cb210c91a1 meson: distinguish build and target host binaries\n> -:  ----------- > 5:  3172db10a10 ci: use Visual Studio for win+meson job on GitHub Workflows\n>\n> ---\n> base-commit: 683c54c999c301c2cd6f715c411407c413b1d84e\n> change-id: 20250328-b4-pks-collect-build-fixes-b5a6ce086b72\n>\n>\n>\n"},{"id":"515476","messageId":"Z-zb7yPcPgJRhhXR@pks.im","threadId":"63207","inReplyTo":"e9ea3630-a831-dec5-e461-3f550ceb7ec3@gmx.de","subject":"Re: [PATCH v2 2/5] gitweb: fix generation of \"gitweb.js\"","fromName":"Patrick Steinhardt","fromEmail":"ps@pks.im","sentAt":"2025-04-02T06:40:47Z","receivedAt":"2025-04-02T06:40:56Z","isPatch":true,"sender":{"key":"ps@pks.im","avatar":"https://avatars.githubusercontent.com/u/4056630?v=4"},"body":"On Tue, Apr 01, 2025 at 06:30:01PM +0200, Johannes Schindelin wrote:\n> Hi Patrick,\n> \n> On Mon, 31 Mar 2025, Patrick Steinhardt wrote:\n> \n> > diff --git a/gitweb/Makefile b/gitweb/Makefile\n> > index d5748e93594..26a683d4421 100644\n> > --- a/gitweb/Makefile\n> > +++ b/gitweb/Makefile\n> > @@ -118,7 +118,7 @@ $(MAK_DIR_GITWEB)gitweb.cgi: $(MAK_DIR_GITWEB)gitweb.perl\n> >  $(MAK_DIR_GITWEB)static/gitweb.js: $(MAK_DIR_GITWEB)generate-gitweb-js.sh\n> >  $(MAK_DIR_GITWEB)static/gitweb.js: $(addprefix $(MAK_DIR_GITWEB),$(GITWEB_JSLIB_FILES))\n> >  \t$(QUIET_GEN)$(RM) $@ $@+ && \\\n> > -\t$(MAK_DIR_GITWEB)generate-gitweb-js.sh $@+ $^ && \\\n> > +\t$(MAK_DIR_GITWEB)generate-gitweb-js.sh $@+ $(filter %.js,$^) && \\\n> >  \tmv $@+ $@\n> \n> A safer way might be to use `$(filter-out %.sh,$^)` just in case the\n> Javascript libraries might at some stage be renamed (I could imagine, for\n> example, that someone aims for ideological purity and renames them to\n> `*.cjs`).\n\nI could see arguments both ways:\n\n  - If we use \"filter-out\" the developer now has to remember to also\n    filter out files whenever a new dependency is added.\n\n  - If we use \"filter\" the developer has to remember to update the\n    pattern if any of the files are renamed.\n\nI think the developer is going to be more on the guard in the second\ncase -- after all, renaming files always requires you to also update the\nbuild instructions. On the other hand it's quite easy to miss that you\nhave to adapt the \"filter-out\" logic when adding a new dependency. In\nthe end neither of these solutions is perfect, but the worst part is\nthat we don't have any tests at all that would detect a broken build.\n\nSo I lean towards keeping the current mechanism, but don't feel strongly\nabout it. Let me know in case you still prefer \"filter-out\" and I'll\nadapt accordingly.\n\nPatrick\n"},{"id":"515568","messageId":"CAOLa=ZRoeXumWxTPeZ-dw-vOPb1-BeaTxYJ_sSYx=CpekQT0eA@mail.gmail.com","threadId":"63207","inReplyTo":"20250331-b4-pks-collect-build-fixes-v2-1-6b06136808f3@pks.im","subject":"Re: [PATCH v2 1/5] meson: fix handling of '-Dcurl=auto'","fromName":"Karthik Nayak","fromEmail":"karthik.188@gmail.com","sentAt":"2025-04-03T08:24:21Z","receivedAt":"2025-04-03T08:24:23Z","isPatch":true,"sender":{"key":"karthik.188@gmail.com","avatar":"https://avatars.githubusercontent.com/u/1786334?v=4"},"body":"Patrick Steinhardt <ps@pks.im> writes:\n\n> The \"curl\" option controls whether or not a couple of features that\n> depend on curl shall be included. Most importantly, these features\n> include the HTTP remote helpers, which are rather quintessential for a\n> well-functioning Git installation. So while the dependency can in theory\n> be dropped, most users wouldn't consider the resulting installation to\n> be fully functional.\n>\n> The \"curl\" option is defined as a feature, which means that it can be\n> \"enabled\", \"disabled\" or \"auto\", which has the effect that the feature\n> will be enabled if the dependency itself has been found. While most of\n> the other features have \"auto\" as default value, the \"curl\" option is\n> set to \"enabled\" by default due to it being so important. Consequently,\n> autoconfiguration of Git will fail by default if the library cannot be\n> found.\n>\n> There is a bug though with how we handle the option in case the user\n> overrides the feature with `meson setup -Dcurl=auto`: while we will try\n> to find the library in that case, we won't ever use it because we later\n> on check for `get_option('curl').enabled()` when deciding whether or not\n> we want to build dependent sources. But `enabled()` only returns true if\n> the option has the value \"enabled\", for \"auto\" it will return false.\n>\n> Fix the issue by instead checking for `curl.found()`, which is only true\n> if the library has been found. And as we only try to find the library\n> when `get_option('curl')` returns \"true\" or \"auto\" this is exactly what\n> we want.\n>\n> Signed-off-by: Patrick Steinhardt <ps@pks.im>\n> ---\n>  meson.build | 2 +-\n>  1 file changed, 1 insertion(+), 1 deletion(-)\n>\n> diff --git a/meson.build b/meson.build\n> index efe2871c9db..a8d1e63ccc6 100644\n> --- a/meson.build\n> +++ b/meson.build\n> @@ -1686,7 +1686,7 @@ bin_wrappers += executable('scalar',\n>    install_dir: get_option('libexecdir') / 'git-core',\n>  )\n>\n> -if get_option('curl').enabled()\n> +if curl.found()\n>    libgit_curl = declare_dependency(\n>      sources: [\n>        'http.c',\n>\n\nSo here, curl is defined as a dependency on 'libcurl'. Ok makes sense.\n\n> --\n> 2.49.0.604.gff1f9ca942.dirty\n"},{"id":"515569","messageId":"CAOLa=ZQkrFepBOQrgxForphncUPkiJ7QXpRmLsDQB5EG--Kj0A@mail.gmail.com","threadId":"63207","inReplyTo":"20250331-b4-pks-collect-build-fixes-v2-4-6b06136808f3@pks.im","subject":"Re: [PATCH v2 4/5] meson: distinguish build and target host binaries","fromName":"Karthik Nayak","fromEmail":"karthik.188@gmail.com","sentAt":"2025-04-03T08:38:03Z","receivedAt":"2025-04-03T08:38:05Z","isPatch":true,"sender":{"key":"karthik.188@gmail.com","avatar":"https://avatars.githubusercontent.com/u/1786334?v=4"},"body":"Patrick Steinhardt <ps@pks.im> writes:\n\n> Almost all of the tools we discover during the build process need to be\n> native programs. There are only a handful of exceptions, which typically\n> are programs whose paths we need to embed into the resulting executable\n> so that they can be found on the target system when Git executes. While\n> this distinction typically doesn't matter, it does start to matter when\n> considering cross-compilation where the build and target machines are\n> different.\n>\n> Meson supports cross-compilation via so-called machine files. These\n> machine files allow the user to override parameters for the build\n> machine, but also for the target machine when cross-compiling. Part of\n> the machine file is a section that allows the user to override the\n> location where binaries are to be found in the target system. The\n> following machine file would for example override the path of the POSIX\n> shell:\n>\n>     [binaries]\n>     sh = '/usr/xpg4/bin/sh'\n>\n> It can be handed over to Meson via `meson setup --cross-file`.\n>\n> We do not handle this correctly right now though because we don't know\n> to distinguish binaries for the build and target hosts at all. Address\n> this by explicitly passing the `native:` parameter to `find_program()`:\n>\n>   - When set to `true`, we get binaries discovered on the build host.\n>\n>   - When set to `false`, we get either the path specified in the\n>     machine file. Or, if no machine file exists or it doesn't specify\n>     the binary path, then we fall back to the binary discovered on the\n>     build host.\n>\n> As mentioned, only a handful of binaries are not native: only the system\n> shell, Python and Perl need to be treated specially here.\n>\n\nThese are not native because they'll be run onthe target machine, while\nthe rest are run on the host machine. Makes sense.\n\n> Reported-by: Peter Seiderer <ps.report@gmx.net>\n> Signed-off-by: Patrick Steinhardt <ps@pks.im>\n> ---\n>  Documentation/meson.build | 12 ++++-----\n>  gitweb/meson.build        |  2 +-\n>  meson.build               | 66 ++++++++++++++++++++++++++++++++++++-----------\n>  templates/meson.build     |  4 +--\n>  4 files changed, 60 insertions(+), 24 deletions(-)\n>\n> diff --git a/Documentation/meson.build b/Documentation/meson.build\n> index 594546d68b1..32f0c5de12a 100644\n> --- a/Documentation/meson.build\n> +++ b/Documentation/meson.build\n> @@ -207,9 +207,9 @@ manpages = {\n>\n>  docs_backend = get_option('docs_backend')\n>  if docs_backend == 'auto'\n> -  if find_program('asciidoc', dirs: program_path, required: false).found()\n> +  if find_program('asciidoc', dirs: program_path, native: true, required: false).found()\n>      docs_backend = 'asciidoc'\n> -  elif find_program('asciidoctor', dirs: program_path, required: false).found()\n> +  elif find_program('asciidoctor', dirs: program_path, native: true, required: false).found()\n>      docs_backend = 'asciidoctor'\n>    else\n>      error('Neither asciidoc nor asciidoctor were found.')\n> @@ -217,7 +217,7 @@ if docs_backend == 'auto'\n>  endif\n>\n>  if docs_backend == 'asciidoc'\n> -  asciidoc = find_program('asciidoc', dirs: program_path)\n> +  asciidoc = find_program('asciidoc', dirs: program_path, native: true)\n>    asciidoc_html = 'xhtml11'\n>    asciidoc_docbook = 'docbook'\n>    xmlto_extra = [ ]\n> @@ -246,7 +246,7 @@ if docs_backend == 'asciidoc'\n>      asciidoc_conf,\n>    ]\n>  elif docs_backend == 'asciidoctor'\n> -  asciidoctor = find_program('asciidoctor', dirs: program_path)\n> +  asciidoctor = find_program('asciidoctor', dirs: program_path, native: true)\n>    asciidoc_html = 'xhtml5'\n>    asciidoc_docbook = 'docbook5'\n>    xmlto_extra = [\n> @@ -288,7 +288,7 @@ if get_option('breaking_changes')\n>     asciidoc_common_options += ['--attribute', 'with-breaking-changes']\n>  endif\n>\n> -xmlto = find_program('xmlto', dirs: program_path)\n> +xmlto = find_program('xmlto', dirs: program_path, native: true)\n>\n>  cmd_lists = [\n>    'cmds-ancillaryinterrogators.adoc',\n> @@ -409,7 +409,7 @@ if get_option('docs').contains('html')\n>      pointing_to: 'git.html',\n>    )\n>\n> -  xsltproc = find_program('xsltproc', dirs: program_path)\n> +  xsltproc = find_program('xsltproc', dirs: program_path, native: true)\n>\n>    user_manual_xml = custom_target(\n>      command: asciidoc_common_options + [\n> diff --git a/gitweb/meson.build b/gitweb/meson.build\n> index 89b403dc9de..88a54b4dc99 100644\n> --- a/gitweb/meson.build\n> +++ b/gitweb/meson.build\n> @@ -1,5 +1,5 @@\n>  gitweb_config = configuration_data()\n> -gitweb_config.set_quoted('PERL_PATH', perl.full_path())\n> +gitweb_config.set_quoted('PERL_PATH', target_perl.full_path())\n>  gitweb_config.set_quoted('CSSMIN', '')\n>  gitweb_config.set_quoted('JSMIN', '')\n>  gitweb_config.set_quoted('GIT_BINDIR', get_option('prefix') / get_option('bindir'))\n> diff --git a/meson.build b/meson.build\n> index a8d1e63ccc6..79a50599ba8 100644\n> --- a/meson.build\n> +++ b/meson.build\n> @@ -155,6 +155,37 @@\n>  # These machine files can be passed to `meson setup` via the `--native-file`\n>  # option.\n>  #\n> +# Cross compilation\n> +# =================\n> +#\n> +# Machine files can also be used in the context of cross-compilation to\n> +# describe the target machine as well as the cross-compiler toolchain that\n> +# shall be used. An example machine file could look like the following:\n> +#\n> +#   [binaries]\n> +#   c = 'x86_64-w64-mingw32-gcc'\n> +#   cpp = 'x86_64-w64-mingw32-g++'\n> +#   ar = 'x86_64-w64-mingw32-ar'\n> +#   windres = 'x86_64-w64-mingw32-windres'\n> +#   strip = 'x86_64-w64-mingw32-strip'\n> +#   exe_wrapper = 'wine64'\n> +#   sh = 'C:/Program Files/Git for Windows/usr/bin/sh.exe'\n> +#\n> +#   [host_machine]\n> +#   system = 'windows'\n> +#   cpu_family = 'x86_64'\n> +#   cpu = 'x86_64'\n> +#   endian = 'little'\n> +#\n> +# These machine files can be passed to `meson setup` via the `--cross-file`\n> +# option.\n> +#\n> +# Note that next to the cross-compiler toolchain, the `[binaries]` section is\n> +# also used to locate a couple of binaries that will be built into Git. This\n> +# includes `sh`, `python` and `perl`, so when cross-compiling Git you likely\n> +# want to set these binary paths in addition to the cross-compiler toolchain\n> +# binaries.\n> +#\n>  # Subproject wrappers\n>  # ===================\n>  #\n> @@ -173,7 +204,7 @@ project('git', 'c',\n>    # The version is only of cosmetic nature, so if we cannot find a shell yet we\n>    # simply don't set up a version at all. This may be the case for example on\n>    # Windows systems, where we first have to bootstrap the host environment.\n> -  version: find_program('sh', required: false).found() ? run_command(\n> +  version: find_program('sh', native: true, required: false).found() ? run_command(\n\nWhile we generally want a target shell, this one is simply to get the\nverson during build time. Makes sense.\n\n>      'GIT-VERSION-GEN', meson.current_source_dir(), '--format=@GIT_VERSION@',\n>      capture: true,\n>      check: true,\n> @@ -198,16 +229,18 @@ elif host_machine.system() == 'windows'\n>    program_path = [ 'C:/Program Files/Git/bin', 'C:/Program Files/Git/usr/bin' ]\n>  endif\n>\n> -cygpath = find_program('cygpath', dirs: program_path, required: false)\n> -diff = find_program('diff', dirs: program_path)\n> -git = find_program('git', dirs: program_path, required: false)\n> -sed = find_program('sed', dirs: program_path)\n> -shell = find_program('sh', dirs: program_path)\n> -tar = find_program('tar', dirs: program_path)\n> +cygpath = find_program('cygpath', dirs: program_path, native: true, required: false)\n> +diff = find_program('diff', dirs: program_path, native: true)\n> +git = find_program('git', dirs: program_path, native: true, required: false)\n> +sed = find_program('sed', dirs: program_path, native: true)\n> +shell = find_program('sh', dirs: program_path, native: true)\n> +tar = find_program('tar', dirs: program_path, native: true)\n> +\n> +target_shell = find_program('sh', dirs: program_path, native: false)\n>\n>  # Sanity-check that programs required for the build exist.\n>  foreach tool : ['cat', 'cut', 'grep', 'sort', 'tr', 'uname']\n> -  find_program(tool, dirs: program_path)\n> +  find_program(tool, dirs: program_path, native: true)\n>  endforeach\n>\n>  script_environment = environment()\n> @@ -706,7 +739,7 @@ libgit_c_args = [\n>    '-DGIT_LOCALE_PATH=\"' + get_option('localedir') + '\"',\n>    '-DGIT_MAN_PATH=\"' + get_option('mandir') + '\"',\n>    '-DPAGER_ENV=\"' + get_option('pager_environment') + '\"',\n> -  '-DSHELL_PATH=\"' + fs.as_posix(shell.full_path()) + '\"',\n> +  '-DSHELL_PATH=\"' + fs.as_posix(target_shell.full_path()) + '\"',\n>  ]\n>  libgit_include_directories = [ '.' ]\n>  libgit_dependencies = [ ]\n> @@ -761,6 +794,7 @@ endif\n>  build_options_config.set_quoted('X', executable_suffix)\n>\n>  python = import('python').find_installation('python3', required: get_option('python'))\n> +target_python = find_program('python3', native: false, required: python.found())\n>  if python.found()\n>    build_options_config.set('NO_PYTHON', '')\n>  else\n> @@ -790,9 +824,11 @@ endif\n>  # which we can do starting with Meson 1.5.0 and newer, or we have to\n>  # match against the minor version.\n>  if meson.version().version_compare('>=1.5.0')\n> -  perl = find_program('perl', dirs: program_path, required: perl_required, version: '>=5.26.0', version_argument: '-V:version')\n> +  perl = find_program('perl', dirs: program_path, native: true, required: perl_required, version: '>=5.26.0', version_argument: '-V:version')\n> +  target_perl = find_program('perl', dirs: program_path, native: false, required: perl.found(), version: '>=5.26.0', version_argument: '-V:version')\n>  else\n> -  perl = find_program('perl', dirs: program_path, required: perl_required, version: '>=26')\n> +  perl = find_program('perl', dirs: program_path, native: true, required: perl_required, version: '>=26')\n> +  target_perl = find_program('perl', dirs: program_path, native: false, required: perl.found(), version: '>=26')\n>  endif\n>  perl_features_enabled = perl.found() and get_option('perl').allowed()\n>  if perl_features_enabled\n> @@ -843,7 +879,7 @@ else\n>    build_options_config.set('NO_PTHREADS', '1')\n>  endif\n>\n> -msgfmt = find_program('msgfmt', dirs: program_path, required: false)\n> +msgfmt = find_program('msgfmt', dirs: program_path, native: true, required: false)\n>  gettext_option = get_option('gettext').disable_auto_if(not msgfmt.found())\n>  if not msgfmt.found() and gettext_option.enabled()\n>    error('Internationalization via libintl requires msgfmt')\n> @@ -1974,9 +2010,9 @@ foreach key, value : {\n>    'GIT_TEST_TEMPLATE_DIR': meson.project_build_root() / 'templates',\n>    'GIT_TEST_TEXTDOMAINDIR': meson.project_build_root() / 'po',\n>    'PAGER_ENV': get_option('pager_environment'),\n> -  'PERL_PATH': perl.found() ? perl.full_path() : '',\n> -  'PYTHON_PATH': python.found () ? python.full_path() : '',\n> -  'SHELL_PATH': shell.full_path(),\n> +  'PERL_PATH': target_perl.found() ? target_perl.full_path() : '',\n> +  'PYTHON_PATH': target_python.found () ? target_python.full_path() : '',\n> +  'SHELL_PATH': target_shell.full_path(),\n>    'TAR': tar.full_path(),\n>    'TEST_OUTPUT_DIRECTORY': test_output_directory,\n>    'TEST_SHELL_PATH': shell.full_path(),\n> diff --git a/templates/meson.build b/templates/meson.build\n> index 1faf9a44cea..02e6eebe80b 100644\n> --- a/templates/meson.build\n> +++ b/templates/meson.build\n> @@ -1,6 +1,6 @@\n>  template_config = configuration_data()\n> -template_config.set('PERL_PATH', perl.found() ? fs.as_posix(perl.full_path()) : '')\n> -template_config.set('SHELL_PATH', fs.as_posix(shell.full_path()))\n> +template_config.set('PERL_PATH', target_perl.found() ? fs.as_posix(target_perl.full_path()) : '')\n> +template_config.set('SHELL_PATH', fs.as_posix(target_shell.full_path()))\n>  template_config.set('GITWEBDIR', fs.as_posix(get_option('prefix') / get_option('datadir') / 'gitweb'))\n>\n>  configure_file(\n>\n> --\n> 2.49.0.604.gff1f9ca942.dirty\n\nLooks good!\n"},{"id":"515570","messageId":"CAOLa=ZQ8bTn-prAs2ycLdLLjVaLQL4GtLw_gFsvAcx_6j=MBjA@mail.gmail.com","threadId":"63207","inReplyTo":"20250331-b4-pks-collect-build-fixes-v2-0-6b06136808f3@pks.im","subject":"Re: [PATCH v2 0/5] Collection of build fixes","fromName":"Karthik Nayak","fromEmail":"karthik.188@gmail.com","sentAt":"2025-04-03T08:39:52Z","receivedAt":"2025-04-03T08:39:53Z","isPatch":true,"sender":{"key":"karthik.188@gmail.com","avatar":"https://avatars.githubusercontent.com/u/1786334?v=4"},"body":"Patrick Steinhardt <ps@pks.im> writes:\n\n> Hi,\n>\n> this small patch series collects various different smallish fixes for\n> issues with the build systems. The intent here is to bundle all of them\n> into a single series to make it a bit easier for Junio to keep track of\n> them.\n>\n> More specifically, this series:\n>\n>   - Fixes an issue with handling \"-Dcurl=auto\" that I spotted recently.\n>\n>   - Replaces Sam's \"sj/meson-test-environ-fix\" [1] with an alternative\n>     solution. The branch is currently in \"seen\".\n>\n>   - Picks up and massages Thorsten's patch from [2] to fix generation of\n>     \"gitweb.js\". The fix has not yet been picked up by Junio.\n>\n>   - Picks up a cross-compilation fix for Meson [3]. There has been a bit\n>     of discussion with Peter whether this is the proper fix, but based\n>     on Eli's feedback it should be okay. I'm still open for alternative\n>     implementations in case anybody has suggestions for how to do them.\n>\n> Please let me know if any of you are unhappy with the way I have given\n> credit. I'm totally happy to change authorship or adjust trailers.\n>\n\nThese patches look good to me, as someone who is getting upto date with\nthe meson build system, I really appreciate the commit messages.\n\n> Changes in v2:\n>   - Drop the fix for Perl-less documentation builds.\n>   - Pick up the fix to use correct environment in our CI builds.\n>     Johannes mentioned that he wants to eventually get rid of those\n>     builds completely, but meanwhile this is a trivial change to make\n>     the jobs do what they should.\n>   - Pick up the improvement for cross-compiling Git.\n>   - Link to v1: https://lore.kernel.org/r/20250328-b4-pks-collect-build-fixes-v1-0-ead9deda3fbc@pks.im\n>\n> Thanks!\n>\n> Patrick\n>\n> [1]: <310a34bace801d288e369c6a01a8d04ffc4c3c06.1741975367.git.sam@gentoo.org>\n> [2]: <070641d0-730c-7d92-af4a-9157dc1edd3d@debian.org>\n> [3]: <20250303-pks-meson-cross-compiling-v1-1-73002ef6432e@pks.im>\n>\n> ---\n> Patrick Steinhardt (5):\n>       meson: fix handling of '-Dcurl=auto'\n>       gitweb: fix generation of \"gitweb.js\"\n>       meson: respect 'tests' build option in contrib\n>       meson: distinguish build and target host binaries\n>       ci: use Visual Studio for win+meson job on GitHub Workflows\n>\n>  .github/workflows/main.yml           |  2 +-\n>  .gitlab-ci.yml                       |  2 +-\n>  Documentation/meson.build            | 12 +++----\n>  contrib/credential/netrc/meson.build | 22 ++++++------\n>  contrib/subtree/meson.build          | 20 ++++++-----\n>  gitweb/Makefile                      |  2 +-\n>  gitweb/meson.build                   |  2 +-\n>  meson.build                          | 68 +++++++++++++++++++++++++++---------\n>  templates/meson.build                |  4 +--\n>  9 files changed, 87 insertions(+), 47 deletions(-)\n>\n> Range-diff versus v1:\n>\n> 1:  4bc8060a975 = 1:  3e9137c2d18 meson: fix handling of '-Dcurl=auto'\n> 2:  4365cfc4a4e = 2:  7ba983d446e gitweb: fix generation of \"gitweb.js\"\n> 3:  02d6ae13dd2 < -:  ----------- meson: require Perl when building docs\n> 4:  fcf2478bd82 = 3:  33cd3e490eb meson: respect 'tests' build option in contrib\n> -:  ----------- > 4:  1cb210c91a1 meson: distinguish build and target host binaries\n> -:  ----------- > 5:  3172db10a10 ci: use Visual Studio for win+meson job on GitHub Workflows\n>\n> ---\n> base-commit: 683c54c999c301c2cd6f715c411407c413b1d84e\n> change-id: 20250328-b4-pks-collect-build-fixes-b5a6ce086b72\n"}]}