diff options
| author | Paolo Bonzini <pbonzini@redhat.com> | 2025-07-21 19:30:10 +0200 |
|---|---|---|
| committer | Jussi Pakkanen <jussi.pakkanen@mailbox.org> | 2025-07-29 21:58:47 +0300 |
| commit | e49f2f7283e1d9f18e2f5f54647c07287cd70339 (patch) | |
| tree | 196ad09e01737567619251fe42a291d106a49487 | |
| parent | 013cf44d86e1b31f9990484a86dac77882d97f16 (diff) | |
| download | meson-e49f2f7283e1d9f18e2f5f54647c07287cd70339.tar.gz | |
build: allow picking 'rust' as a link_language
rustc only needs to be a linker if there are any Rust-ABI dependencies.
Skip it whenever linking to a C-ABI dependency. This makes it possible
for Meson to pick 'rust' whenever it sees Rust sources, but not whenever
it sees Rust used by a dependency with "rust_abi: 'c'".
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
| -rw-r--r-- | mesonbuild/build.py | 7 | ||||
| -rw-r--r-- | mesonbuild/compilers/compilers.py | 2 |
2 files changed, 8 insertions, 1 deletions
diff --git a/mesonbuild/build.py b/mesonbuild/build.py index fcdb7925f..4f581de31 100644 --- a/mesonbuild/build.py +++ b/mesonbuild/build.py @@ -885,6 +885,10 @@ class BuildTarget(Target): if isinstance(t, (CustomTarget, CustomTargetIndex)): continue # We can't know anything about these. for name, compiler in t.compilers.items(): + if name == 'rust': + # Rust is always linked through a C-ABI target, so do not add + # the compiler here + continue if name in link_langs and name not in self.compilers: self.compilers[name] = compiler @@ -1600,6 +1604,9 @@ class BuildTarget(Target): if isinstance(link_target, (CustomTarget, CustomTargetIndex)): continue for language in link_target.compilers: + if language == 'rust' and not link_target.uses_rust_abi(): + # All Rust dependencies must go through a C-ABI dependency, so ignore it + continue if language not in langs: langs.append(language) diff --git a/mesonbuild/compilers/compilers.py b/mesonbuild/compilers/compilers.py index 5915790d0..3b7f066f7 100644 --- a/mesonbuild/compilers/compilers.py +++ b/mesonbuild/compilers/compilers.py @@ -84,7 +84,7 @@ clib_langs = ('objcpp', 'cpp', 'objc', 'c', 'nasm', 'fortran') # List of languages that can be linked with C code directly by the linker # used in build.py:process_compilers() and build.py:get_dynamic_linker() # This must be sorted, see sort_clink(). -clink_langs = ('d', 'cuda') + clib_langs +clink_langs = ('rust', 'd', 'cuda') + clib_langs SUFFIX_TO_LANG = dict(itertools.chain(*( [(suffix, lang) for suffix in v] for lang, v in lang_suffixes.items()))) |
