aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorXavier Claessens <xavier.claessens@collabora.com>2023-08-24 12:11:28 -0400
committerXavier Claessens <xclaesse@gmail.com>2023-09-19 13:54:49 -0400
commitc6f33aed2d1da362e35340c2623ffc76624d3903 (patch)
tree8a503b7a3d18917d76c26bb23ef699668c666bba
parent759200348476752b304ffca0cb3737a5b61f9137 (diff)
downloadmeson-c6f33aed2d1da362e35340c2623ffc76624d3903.zip
meson-c6f33aed2d1da362e35340c2623ffc76624d3903.tar.gz
meson-c6f33aed2d1da362e35340c2623ffc76624d3903.tar.bz2
Rust: Fix proc-macro usage when cross compiling
Force BUILD machine and allow to link with HOST machine.
-rw-r--r--mesonbuild/build.py2
-rw-r--r--mesonbuild/interpreter/interpreter.py4
2 files changed, 5 insertions, 1 deletions
diff --git a/mesonbuild/build.py b/mesonbuild/build.py
index 9a87225..c58447b 100644
--- a/mesonbuild/build.py
+++ b/mesonbuild/build.py
@@ -1474,7 +1474,7 @@ class BuildTarget(Target):
links_with_rust_abi = isinstance(t, BuildTarget) and t.uses_rust_abi()
if not self.uses_rust() and links_with_rust_abi:
raise InvalidArguments(f'Try to link Rust ABI library {t.name!r} with a non-Rust target {self.name!r}')
- if self.for_machine is not t.for_machine:
+ if self.for_machine is not t.for_machine and (not links_with_rust_abi or t.rust_crate_type != 'proc-macro'):
msg = f'Tried to mix libraries for machines {self.for_machine} and {t.for_machine} in target {self.name!r}'
if self.environment.is_cross_build():
raise InvalidArguments(msg + ' This is not possible in a cross build.')
diff --git a/mesonbuild/interpreter/interpreter.py b/mesonbuild/interpreter/interpreter.py
index 1c02c5f..464ebea 100644
--- a/mesonbuild/interpreter/interpreter.py
+++ b/mesonbuild/interpreter/interpreter.py
@@ -3247,6 +3247,10 @@ class Interpreter(InterpreterBase, HoldableObject):
name, sources = args
for_machine = self.machine_from_native_kwarg(kwargs)
+ if kwargs.get('rust_crate_type') == 'proc-macro':
+ # Silently force to native because that's the only sensible value
+ # and rust_crate_type is deprecated any way.
+ for_machine = MachineChoice.BUILD
if 'sources' in kwargs:
sources += listify(kwargs['sources'])
if any(isinstance(s, build.BuildTarget) for s in sources):