Source0: https://github.com/mesonbuild/meson/releases/download/%{version}/%{name}-%{version}.tar.gz
# Source0-md5: 702bfd8b0648521322d3f145a8fc70ea
Patch0: %{name}-gtkdocdir.patch
+Patch1: rust-proc-macro-filter-out-target.patch
URL: https://mesonbuild.com/
BuildRequires: ninja >= 1.8.2
BuildRequires: python3 >= 1:3.7
%prep
%setup -q
%patch0 -p1
+%patch1 -p1
%{__sed} -i -e '1s,/usr/bin/env python3,%{__python3},' \
meson.py
--- /dev/null
+From ace34a0d5e4d27f0eb4e0b6f756e10dfd04e1ff9 Mon Sep 17 00:00:00 2001
+From: Jan Palus <jpalus@fastmail.com>
+Date: Wed, 11 Oct 2023 19:40:48 +0200
+Subject: [PATCH] rust: filter out --target for proc-macro crate
+
+proc-macro is used directly by a host compiler so during its compilation
+target should match host triplet see:
+
+https://github.com/rust-lang/rust/issues/116562
+
+the easiest way to achieve this is to skip --target entirely as by
+default it will produce artifact matching host.
+
+since meson upstream prefers to use full blown cross-compilation for
+tiers without host tools:
+
+https://github.com/mesonbuild/meson/issues/12353
+
+let's patch meson ourselves for convinience to avoid it
+---
+ mesonbuild/backend/backends.py | 15 +++++++++++++++
+ 1 file changed, 15 insertions(+)
+
+diff --git a/mesonbuild/backend/backends.py b/mesonbuild/backend/backends.py
+index 73741a441..191db485d 100644
+--- a/mesonbuild/backend/backends.py
++++ b/mesonbuild/backend/backends.py
+@@ -1064,6 +1064,21 @@ class Backend:
+ for lt in chain(target.link_targets, target.link_whole_targets):
+ priv_dir = self.get_target_private_dir(lt)
+ commands += compiler.get_include_args(priv_dir, False)
++ # filter out --target arguments for host only proc-macro crate
++ if compiler.language == 'rust' and hasattr(target, 'rust_crate_type') and target.rust_crate_type == 'proc-macro':
++ target_commands = []
++ target_arg = False
++ for (i, v) in enumerate(commands):
++ if target_arg:
++ target_commands.append(i)
++ target_arg = False
++ elif v == '--target':
++ target_commands.append(i)
++ target_arg = True
++ elif v.startswith('--target='):
++ target_commands.append(i)
++ for i in reversed(target_commands):
++ del commands[i]
+ return commands
+
+ def build_target_link_arguments(self, compiler: 'Compiler', deps: T.List[build.Target]) -> T.List[str]:
+--
+2.42.0
+