Skip to content

Commit

Permalink
backend/ninja: Don't run -t cleandead when using dyndeps
Browse files Browse the repository at this point in the history
There's a known ninja bug
(ninja-build/ninja#1952) that running this
with dyndeps will result in Ninja deleting implicit outputs from the
dyndeps, leading to pointless rebuilds. For reference, this is what
CMake does as well.
  • Loading branch information
dcbaker committed Mar 28, 2024
1 parent 9bfa04d commit 9e4bdb8
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion mesonbuild/backend/ninjabackend.py
Expand Up @@ -494,6 +494,7 @@ def __init__(self, build: T.Optional[build.Build], interpreter: T.Optional[Inter
self.created_llvm_ir_rule = PerMachine(False, False)
self.rust_crates: T.Dict[str, RustCrate] = {}
self.implicit_meson_outs = []
self._uses_dyndeps = False

def create_phony_target(self, dummy_outfile: str, rulename: str, phony_infilename: str) -> NinjaBuildElement:
'''
Expand Down Expand Up @@ -669,7 +670,8 @@ def generate(self, capture: bool = False, vslite_ctx: dict = None) -> T.Optional
os.replace(tempfilename, outfilename)
mlog.cmd_ci_include(outfilename) # For CI debugging
# Refresh Ninja's caches. https://github.com/ninja-build/ninja/pull/1685
if mesonlib.version_compare(self.ninja_version, '>=1.10.0') and os.path.exists(os.path.join(self.environment.build_dir, '.ninja_log')):
# Cannot use when running with dyndeps: https://github.com/ninja-build/ninja/issues/1952
if mesonlib.version_compare(self.ninja_version, '>=1.10.0') and os.path.exists(os.path.join(self.environment.build_dir, '.ninja_log')) and not self._uses_dyndeps:
subprocess.call(self.ninja_command + ['-t', 'restat'], cwd=self.environment.build_dir)
subprocess.call(self.ninja_command + ['-t', 'cleandead'], cwd=self.environment.build_dir)
self.generate_compdb()
Expand Down Expand Up @@ -1094,6 +1096,7 @@ def generate_dependency_scan_target(self, target: build.BuildTarget,
object_deps: T.List['mesonlib.FileOrString']) -> None:
if not self.should_use_dyndeps_for_target(target):
return
self._uses_dyndeps = True
depscan_file = self.get_dep_scan_file_for(target)
pickle_base = target.name + '.dat'
pickle_file = os.path.join(self.get_target_private_dir(target), pickle_base).replace('\\', '/')
Expand Down

0 comments on commit 9e4bdb8

Please sign in to comment.