diff --git a/mesonbuild/backend/ninjabackend.py b/mesonbuild/backend/ninjabackend.py index 782b264acc90..f82f0bb0d606 100644 --- a/mesonbuild/backend/ninjabackend.py +++ b/mesonbuild/backend/ninjabackend.py @@ -1215,6 +1215,8 @@ def generate_coverage_command(self, elem, outputs): if not hasattr(target, 'compilers'): continue for compiler in target.compilers.values(): + if compiler.get_id() == 'rustc': + use_llvm_cov = True if compiler.get_id() == 'clang' and not compiler.info.is_darwin(): use_llvm_cov = True break diff --git a/mesonbuild/compilers/rust.py b/mesonbuild/compilers/rust.py index 89b913a58de1..97d4f85a9b3f 100644 --- a/mesonbuild/compilers/rust.py +++ b/mesonbuild/compilers/rust.py @@ -66,7 +66,7 @@ def __init__(self, exelist: T.List[str], version: str, for_machine: MachineChoic is_cross=is_cross, full_version=full_version, linker=linker) self.exe_wrapper = exe_wrapper - self.base_options.update({OptionKey(o) for o in ['b_colorout', 'b_ndebug']}) + self.base_options.update({OptionKey(o) for o in ['b_colorout', 'b_coverage', 'b_ndebug']}) if 'link' in self.linker.id: self.base_options.add(OptionKey('b_vscrt')) self.native_static_libs: T.List[str] = [] @@ -216,6 +216,9 @@ def get_pie_args(self) -> T.List[str]: # pic is on by rustc return [] + def get_coverage_args(self) -> T.List[str]: + return ['-C', 'instrument-coverage'] + def get_assert_args(self, disable: bool) -> T.List[str]: action = "no" if disable else "yes" return ['-C', f'debug-assertions={action}', '-C', 'overflow-checks=no']