Describe the bug
A target without any Rust source files that has link_language : 'rust' causes Meson to first warn build statement for ['libfoo.so'] references nonexistent rule rust_LINKER, and then to finally raise AttributeError: 'NinjaBuildElement' object has no attribute 'rule'.
To Reproduce
project(
'hello-link-rust',
'c', 'rust',
version : '0.0.1',
)
# Does not error.
library(
'woof',
files('meow.rs', 'meow.c'),
link_language : 'rust',
)
# ERROR
library(
'meow',
files('meow.c'),
link_language : 'rust',
)
The contents of the relevant C and Rust files don't seem to matter, but here's my reproducer:
#[no_mangle]
pub extern "C" fn woof(_: *mut ())
{
println!("woof!");
}
#include <stdio.h>
void fake_callable_from_rust(void *p)
{
printf("meow!\n");
(void) p;
}
Expected behavior
I would expect it to use rustc to link, even for non-Rust sources, but failing that I would expect an intentional descriptive error of why link_language : 'rust' isn't supported in this case.
system parameters
- Is this a cross build or just a plain native build (for the same computer)?: native
- what operating system (e.g. MacOS Catalina, Windows 10, CentOS 8.0, Ubuntu 18.04, etc.): NixOS 26.05.20251228
- what Python version are you using e.g. 3.8.0:
Python 3.13.9
- what
meson --version: 1.9.1
- what
ninja --version if it's a Ninja build: 1.13.2