]> git.pld-linux.org Git - packages/meson.git/commitdiff
add patch to filter out --target for rust proc-macro crate
authorJan Palus <atler@pld-linux.org>
Wed, 11 Oct 2023 19:04:56 +0000 (21:04 +0200)
committerJan Palus <atler@pld-linux.org>
Wed, 11 Oct 2023 19:04:56 +0000 (21:04 +0200)
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

meson.spec
rust-proc-macro-filter-out-target.patch [new file with mode: 0644]

index 9093a48d1232e2325ae59b4e994132f68aa41aac..588d09facb78ca7deb18eb5a50ee3ff7dcb32e6f 100644 (file)
@@ -9,6 +9,7 @@ Group:          Development/Tools
 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
@@ -54,6 +55,7 @@ Mesona.
 %prep
 %setup -q
 %patch0 -p1
+%patch1 -p1
 
 %{__sed} -i -e '1s,/usr/bin/env python3,%{__python3},' \
        meson.py
diff --git a/rust-proc-macro-filter-out-target.patch b/rust-proc-macro-filter-out-target.patch
new file mode 100644 (file)
index 0000000..11d97b4
--- /dev/null
@@ -0,0 +1,52 @@
+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
+
This page took 0.229157 seconds and 4 git commands to generate.