aboutsummaryrefslogtreecommitdiff
path: root/mesonbuild
diff options
context:
space:
mode:
authorXavier Claessens <xavier.claessens@collabora.com>2023-04-22 09:13:44 -0400
committerXavier Claessens <xclaesse@gmail.com>2023-09-19 13:54:49 -0400
commitdbf081c9ce7c145908d96eb9fa664b8b5b1f5896 (patch)
treea076182cf4c465f81dc50c8096e72fc34c7277b7 /mesonbuild
parent7321f01678d6dc286a4616a843f835cb6b949520 (diff)
downloadmeson-dbf081c9ce7c145908d96eb9fa664b8b5b1f5896.zip
meson-dbf081c9ce7c145908d96eb9fa664b8b5b1f5896.tar.gz
meson-dbf081c9ce7c145908d96eb9fa664b8b5b1f5896.tar.bz2
Rust: Fix both_libraries() case
Rustc does not produce object files we can reuse to build both libraries. Ideally this should be done with a single target that has both `--crate-type` arguments instead of having 2 different build rules. As temporary workaround, build twice and ensure they don't get conflicts in intermediary files created by rustc by passing target's private directory as --out-dir. See https://github.com/rust-lang/rust/issues/111083.
Diffstat (limited to 'mesonbuild')
-rw-r--r--mesonbuild/backend/ninjabackend.py5
-rw-r--r--mesonbuild/interpreter/interpreter.py4
2 files changed, 6 insertions, 3 deletions
diff --git a/mesonbuild/backend/ninjabackend.py b/mesonbuild/backend/ninjabackend.py
index 767baea..3d3eefd 100644
--- a/mesonbuild/backend/ninjabackend.py
+++ b/mesonbuild/backend/ninjabackend.py
@@ -1951,10 +1951,9 @@ class NinjaBackend(backends.Backend):
# Rustc replaces - with _. spaces or dots are not allowed, so we replace them with underscores
args += ['--crate-name', target.name.replace('-', '_').replace(' ', '_').replace('.', '_')]
depfile = os.path.join(target.subdir, target.name + '.d')
- args += ['--emit', f'dep-info={depfile}', '--emit', 'link']
+ args += ['--emit', f'dep-info={depfile}', '--emit', f'link={target_name}']
+ args += ['--out-dir', self.get_target_private_dir(target)]
args += target.get_extra_args('rust')
- output = rustc.get_output_args(os.path.join(target.subdir, target.get_filename()))
- args += output
linkdirs = mesonlib.OrderedSet()
external_deps = target.external_deps.copy()
diff --git a/mesonbuild/interpreter/interpreter.py b/mesonbuild/interpreter/interpreter.py
index 464ebea..a5c8a5a 100644
--- a/mesonbuild/interpreter/interpreter.py
+++ b/mesonbuild/interpreter/interpreter.py
@@ -3206,6 +3206,10 @@ class Interpreter(InterpreterBase, HoldableObject):
# Feel free to submit patches to get this fixed if it is an
# issue for you.
reuse_object_files = False
+ elif shared_lib.uses_rust():
+ # FIXME: rustc supports generating both libraries in a single invocation,
+ # but for now compile twice.
+ reuse_object_files = False
else:
reuse_object_files = static_lib.pic