Skip to content

Commit

Permalink
WIP: add rust support for -Db_coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
eli-schwartz committed Jan 25, 2024
1 parent 12e049e commit 35430aa
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
2 changes: 2 additions & 0 deletions mesonbuild/backend/ninjabackend.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 4 additions & 1 deletion mesonbuild/compilers/rust.py
Original file line number Diff line number Diff line change
Expand Up @@ -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] = []
Expand Down Expand Up @@ -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']
Expand Down

0 comments on commit 35430aa

Please sign in to comment.