commit:     83ae2fc04485d54bb78e9b96747794b61fd7e0ec
Author:     Sam James <sam <AT> gentoo <DOT> org>
AuthorDate: Thu Dec  4 03:11:30 2025 +0000
Commit:     Sam James <sam <AT> gentoo <DOT> org>
CommitDate: Thu Dec  4 03:11:30 2025 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=83ae2fc0

dev-vcs/git: fix cross compat

Closes: https://bugs.gentoo.org/953122
Signed-off-by: Sam James <sam <AT> gentoo.org>

 .../0001-meson-ignore-subprojects-.wraplock.patch  | 33 +++++++++++++++
 ...n-only-detect-ICONV_OMITS_BOM-if-possible.patch | 38 +++++++++++++++++
 ...3-meson-use-is_cross_build-where-possible.patch | 48 ++++++++++++++++++++++
 dev-vcs/git/git-2.51.2-r2.ebuild                   |  5 +++
 dev-vcs/git/git-2.52.0.ebuild                      |  5 +++
 5 files changed, 129 insertions(+)

diff --git a/dev-vcs/git/files/0001-meson-ignore-subprojects-.wraplock.patch 
b/dev-vcs/git/files/0001-meson-ignore-subprojects-.wraplock.patch
new file mode 100644
index 000000000000..c5a1347f7990
--- /dev/null
+++ b/dev-vcs/git/files/0001-meson-ignore-subprojects-.wraplock.patch
@@ -0,0 +1,33 @@
+https://bugs.gentoo.org/953122
+https://lore.kernel.org/git/[email protected]/
+
+From 6437cb608c9c9894852499da36e22095adb57a8e Mon Sep 17 00:00:00 2001
+Message-ID: 
<6437cb608c9c9894852499da36e22095adb57a8e.1764817376.git....@gentoo.org>
+From: Toon Claes <[email protected]>
+Date: Tue, 2 Dec 2025 11:48:08 +0100
+Subject: [PATCH 1/3] meson: ignore subprojects/.wraplock
+
+When asking Meson to wrap subprojects, it generates a .wraplock file in
+the subprojects/ directory. Ignore this file.
+
+See also https://github.com/mesonbuild/meson/issues/14948.
+
+Signed-off-by: Toon Claes <[email protected]>
+---
+ subprojects/.gitignore | 1 +
+ 1 file changed, 1 insertion(+)
+
+diff --git a/subprojects/.gitignore b/subprojects/.gitignore
+index 63ea916ef5..2bb68c8794 100644
+--- a/subprojects/.gitignore
++++ b/subprojects/.gitignore
+@@ -1 +1,2 @@
+ /*/
++.wraplock
+
+base-commit: f0ef5b6d9bcc258e4cbef93839d1b7465d5212b9
+prerequisite-patch-id: b59f73a32b9910a2e72eb13797a0f9bd76ce4812
+prerequisite-patch-id: 9f1fdad38ca8082e13069df63de6af32599fe654
+-- 
+2.52.0
+

diff --git 
a/dev-vcs/git/files/0002-meson-only-detect-ICONV_OMITS_BOM-if-possible.patch 
b/dev-vcs/git/files/0002-meson-only-detect-ICONV_OMITS_BOM-if-possible.patch
new file mode 100644
index 000000000000..67443f4d26ca
--- /dev/null
+++ b/dev-vcs/git/files/0002-meson-only-detect-ICONV_OMITS_BOM-if-possible.patch
@@ -0,0 +1,38 @@
+https://bugs.gentoo.org/953122
+https://lore.kernel.org/git/[email protected]/
+
+From 4f638a773a0f9f6961abe92226be9c23a486110d Mon Sep 17 00:00:00 2001
+Message-ID: 
<4f638a773a0f9f6961abe92226be9c23a486110d.1764817376.git....@gentoo.org>
+In-Reply-To: 
<6437cb608c9c9894852499da36e22095adb57a8e.1764817376.git....@gentoo.org>
+References: 
<6437cb608c9c9894852499da36e22095adb57a8e.1764817376.git....@gentoo.org>
+From: Toon Claes <[email protected]>
+Date: Tue, 2 Dec 2025 11:48:09 +0100
+Subject: [PATCH 2/3] meson: only detect ICONV_OMITS_BOM if possible
+
+In our Meson setup it automatically detects whether ICONV_OMITS_BOM
+should be defined. To check this, a piece of code is compiled and ran.
+
+When cross-compiling, it's not possible to run this piece of code. Guard
+this test with a can_run_host_binaries() check to ensure it can run.
+
+Signed-off-by: Toon Claes <[email protected]>
+---
+ meson.build | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/meson.build b/meson.build
+index f1b3615659..95348e69a4 100644
+--- a/meson.build
++++ b/meson.build
+@@ -1064,7 +1064,7 @@ if iconv.found()
+     }
+   '''
+ 
+-  if compiler.run(iconv_omits_bom_source,
++  if meson.can_run_host_binaries() and compiler.run(iconv_omits_bom_source,
+     dependencies: iconv,
+     name: 'iconv omits BOM',
+   ).returncode() != 0
+-- 
+2.52.0
+

diff --git 
a/dev-vcs/git/files/0003-meson-use-is_cross_build-where-possible.patch 
b/dev-vcs/git/files/0003-meson-use-is_cross_build-where-possible.patch
new file mode 100644
index 000000000000..d3ba9a872df9
--- /dev/null
+++ b/dev-vcs/git/files/0003-meson-use-is_cross_build-where-possible.patch
@@ -0,0 +1,48 @@
+https://bugs.gentoo.org/953122
+https://lore.kernel.org/git/[email protected]/
+
+From 9e911f149088538f67ca9e8bf5cbfc95d3fe23fe Mon Sep 17 00:00:00 2001
+Message-ID: 
<9e911f149088538f67ca9e8bf5cbfc95d3fe23fe.1764817376.git....@gentoo.org>
+In-Reply-To: 
<6437cb608c9c9894852499da36e22095adb57a8e.1764817376.git....@gentoo.org>
+References: 
<6437cb608c9c9894852499da36e22095adb57a8e.1764817376.git....@gentoo.org>
+From: Toon Claes <[email protected]>
+Date: Wed, 3 Dec 2025 15:53:31 +0100
+Subject: [PATCH 3/3] meson: use is_cross_build() where possible
+
+In previous commit the first use of meson.can_run_host_binaries() was
+introduced. This is a guard around compiler.run() to ensure it's
+actually possible to execute the provided.
+
+In other places we've been having the same issue, but here `not
+meson.is_cross_build()` is used as guard. This does the trick, but it
+also prevents the code from running even when an exe_wrapper is
+configured.
+
+Switch to using meson.can_run_host_binaries() here as well.
+
+There is another place left that still uses `not
+meson.is_cross_build()`, but here it's a guard around fs.exists(). That
+function will always run on the build machine, so checking for
+cross-compilation is still in place here.
+
+Signed-off-by: Toon Claes <[email protected]>
+---
+ meson.build | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/meson.build b/meson.build
+index 95348e69a4..00ad8a5c60 100644
+--- a/meson.build
++++ b/meson.build
+@@ -1492,7 +1492,7 @@ if not has_bsd_sysctl
+   endif
+ endif
+ 
+-if not meson.is_cross_build() and compiler.run('''
++if meson.can_run_host_binaries() and compiler.run('''
+   #include <stdio.h>
+ 
+   int main(int argc, const char **argv)
+-- 
+2.52.0
+

diff --git a/dev-vcs/git/git-2.51.2-r2.ebuild b/dev-vcs/git/git-2.51.2-r2.ebuild
index 515d4b31bb3a..b0a2ea9fcddb 100644
--- a/dev-vcs/git/git-2.51.2-r2.ebuild
+++ b/dev-vcs/git/git-2.51.2-r2.ebuild
@@ -148,6 +148,11 @@ PATCHES=(
        # demand from developers. It's opt-in (needs a config option)
        # and the documentation mentions that it is a Gentoo addition.
        
"${FILESDIR}"/${PN}-2.50.0-diff-implement-config.diff.renames-copies-harder.patch
+
+       # Backports for cross
+       "${FILESDIR}"/0001-meson-ignore-subprojects-.wraplock.patch
+       "${FILESDIR}"/0002-meson-only-detect-ICONV_OMITS_BOM-if-possible.patch
+       "${FILESDIR}"/0003-meson-use-is_cross_build-where-possible.patch
 )
 
 pkg_setup() {

diff --git a/dev-vcs/git/git-2.52.0.ebuild b/dev-vcs/git/git-2.52.0.ebuild
index 9635a818b7e4..5a4d0c17b6c9 100644
--- a/dev-vcs/git/git-2.52.0.ebuild
+++ b/dev-vcs/git/git-2.52.0.ebuild
@@ -153,6 +153,11 @@ PATCHES=(
 
        "${FILESDIR}"/${PN}-2.52.0-0001-rust-don-t-pass-quiet-to-cargo.patch
        
"${FILESDIR}"/${PN}-2.52.0-0002-rust-respect-CARGO-environment-variable.patch
+
+       # Backports for cross
+       "${FILESDIR}"/0001-meson-ignore-subprojects-.wraplock.patch
+       "${FILESDIR}"/0002-meson-only-detect-ICONV_OMITS_BOM-if-possible.patch
+       "${FILESDIR}"/0003-meson-use-is_cross_build-where-possible.patch
 )
 
 pkg_setup() {

Reply via email to