New issue
Advanced search Search tips
Note: Color blocks (like or ) mean that a user may not be available. Tooltip shows the reason.

Issue 639965 link

Starred by 2 users

Issue metadata

Status: Fixed
Owner:
Last visit 26 days ago
Closed: Oct 2016
Components:
EstimatedDays: ----
NextAction: ----
OS: ----
Pri: 3
Type: Bug



Sign in to add a comment

ninja files are regenerated infinitely or never if out directory is renamed

Project Member Reported by brucedaw...@chromium.org, Aug 22 2016

Issue description

This is actually two related bugs. The first problem is that sometimes running "ninja -C out\Default" will cause the "Regenerating ninja files" step to be run infinitely.

The second problem is that if you halt gn with Ctrl+C while it is generating .ninja files then it leaves the build directory in a bad state where subsequent builds will not generate the ninja files at all.

Both bugs are triggered by the same root cause - renaming an output directory and not running "gn gen" on it. This is presumably not supported behavior, but the failure mode should be more elegant, especially since the Ctrl+C issue can be reproduce in other ways.

Here is what the output looks like (Ctrl+C was typed during the third regenerating of ninja files):

  D:\src\chromium\src>ninja -C out\debug_analyze
  ninja: Entering directory `out\debug_analyze'
  [1/1] Regenerating ninja files
  [1/1] Regenerating ninja files
  [0/1] Regenerating ninja files
  ninja: error: rebuilding 'build.ninja': interrupted by user

  D:\src\chromium\src>ninja -C out\debug_analyze
  ninja: error: loading 'build.ninja': The system cannot find the file specified.

  ninja: Entering directory `out\debug_analyze'

The initial issue is because build.ninja contains the path to the original output directory, the .ninja files are generated there, but the dependency checking expects them to be in the new (renamed) directory, which is why the infinite regenerating happens.

The second issue is more general and therefore more important. If the "Regenerating ninja files" step is halted with Ctrl+C then the build.ninja file is often deleted and subsequent builds will fail. This can occur even without the unsupported directory renaming.
 
out_dir_contents.zip
688 bytes Download
The second problem is on file as  bug 406237 .
Status: Started (was: Assigned)
Status: Fixed (was: Started)
Checked in, still need to roll GN binary.
Project Member

Comment 4 by bugdroid1@chromium.org, Oct 4 2016

The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/eceed2e7c13045dcabfa07e7b7d7b4cd2807a0ec

commit eceed2e7c13045dcabfa07e7b7d7b4cd2807a0ec
Author: brettw <brettw@chromium.org>
Date: Tue Oct 04 23:22:46 2016

GN: use the correct directory for self-invocation.

GN writes a Ninja command to re-invoke GN when a build file changes. Previously
this hardcoded the build directory. But if the user renames the build
directory, Ninja will think the files are out of date but GN will keep
regenerating files in another directory.

This changes the directory to "." because Ninja will invoke all commands with
the build directory as the current one.

BUG= 639965 

Review-Url: https://codereview.chromium.org/2389133003
Cr-Commit-Position: refs/heads/master@{#422995}

[modify] https://crrev.com/eceed2e7c13045dcabfa07e7b7d7b4cd2807a0ec/tools/gn/ninja_build_writer.cc

Sign in to add a comment