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

Issue 762407 link

Starred by 1 user

Issue metadata

Status: Fixed
Owner:
Closed: Sep 2017
Cc:
Components:
EstimatedDays: ----
NextAction: ----
OS: ----
Pri: 3
Type: Bug



Sign in to add a comment

Cmake 2.8 cannot build using ninja >= 1.8.0

Reported by plauren...@gmail.com, Sep 6 2017

Issue description

After updating ninja to 1.8.0 in the depot_tools repository, cmake 2.8 on Linux will fail building even the simplest project using ninja.

Software versions involved:
Ubuntu 14.04.5 LTS
cmake version 2.8.12.2
depot_tools master branch
  commit 7139a4e23cb97d3848dcc185c443f092ab60cfc2
  Author: Aaron Gable <agable@chromium.org>
  Date:   Tue Sep 5 17:53:09 2017 -0700



What steps will reproduce the problem?
(1) Create a new folder with a very simple CMakeLists.txt project. E.g. take step 1 from here: https://cmake.org/cmake-tutorial/

The CMakeLists.txt file looks like this:
-----
cmake_minimum_required (VERSION 2.6)
project (Tutorial)
add_executable(Tutorial tutorial.cxx)
-----

The source code for tutorial.cxx will compute the square root of a number and the first version of it is very simple, as follows:
-----
// A simple program that computes the square root of a number
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
int main (int argc, char *argv[])
{
  if (argc < 2)
    {
    fprintf(stdout,"Usage: %s number\n",argv[0]);
    return 1;
    }
  double inputValue = atof(argv[1]);
  double outputValue = sqrt(inputValue);
  fprintf(stdout,"The square root of %g is %g\n",
          inputValue, outputValue);
  return 0;
}
-----
See the sources attached as cmake.tst.tar.gz

(2) Try to build this cmake project using ninja
-----
$ export PATH=$PATH:/path_to/depot_tools
$ cd cmake.tst/
$ mkdir build && cd build
$ cmake -G "Ninja" -DCMAKE_BUILD_TYPE=Release  ..
----


What is the expected result?

The expected result is that cmake checks the existence and functionality of the C compiler and everything works fine. E.g.:
-----
$ cmake -G "Ninja" -DCMAKE_BUILD_TYPE=Release  ..
-- The C compiler identification is GNU 4.8.4
-- The CXX compiler identification is GNU 4.8.4
-- Check for working C compiler using: Ninja
-- Check for working C compiler using: Ninja -- works
-----

What happens instead?

Cmake is not able to check the existence and functionality of the C compiler. E.g.:
-----
$ cmake -G "Ninja" -DCMAKE_BUILD_TYPE=Release  ..
-- The C compiler identification is GNU 4.8.4
-- The CXX compiler identification is GNU 4.8.4
-- Check for working C compiler using: Ninja
-- Check for working C compiler using: Ninja -- broken
CMake Error at /usr/share/cmake-2.8/Modules/CMakeTestCCompiler.cmake:61 (message):
  The C compiler "/usr/bin/cc" is not able to compile a simple test program.

  It fails with the following output:

   Change Dir: /home/jenkins/code/tmp/cmake.tst/build/CMakeFiles/CMakeTmp

  

  Run Build Command:/home/jenkins/code/depot_tools/ninja
  cmTryCompileExec3374478763

  ninja: error: dependency cycle: testCCompiler.c -> testCCompiler.c
-----


Please provide any additional information below. Attach a screenshot if
possible.

This problem occurs only after this commit in the depot_tools repository:
-----
commit 372e0fdbfaaf78df357e4d425bf7baa8613dbc9c
Author: Takuto Ikuta <tikuta@google.com>
Date:   Mon Sep 4 17:30:57 2017 +0900

    Update ninja to v1.8.0.
    
    New binaries for Mac, Linux32, Linux64, Windows.  Also update shell script.
    See the bug for how these were built.
    The main "new" thing is performance improvement when building chrome with goma.
    
    After confirming the the behavior of ninja 1.8.0 on buildbot, I will roll ninja 1.8.1 includes fix for non-deterministic test.
    
    TBR=dpranke@chromium.org
    Bug:  761691 ,  738186 
    Change-Id: I108996dccfdf5d95d8815d6cece5eba46f3e8178
    Reviewed-on: https://chromium-review.googlesource.com/648372
    Commit-Queue: Takuto Ikuta <tikuta@google.com>
    Reviewed-by: Nico Weber <thakis@chromium.org>
-----

Reverting the depot_tools to any commit before the one listed above will allow us to build any cmake project using ninja.
 
cmake.tst.tar.gz
9.3 KB Download
Newer versions of cmake like 3.2.2 or 3.4.3 doesn't exhibit the same issue when running with Ninja as generator,
Owner: tikuta@chromium.org
Status: Assigned (was: Unconfirmed)
+tikuta who updated ninja
Cc: thakis@chromium.org
Thank you for reporting.

Nico, do you know root cause?
I guess this PR changes ninja's behavior.
https://github.com/ninja-build/ninja/pull/1111

Cc: brad.k...@kitware.org
Brad: Looks like you broke cmake 2.8 :-(

Guess we'll revert your change and do a 1.8.2, or what do you recommend? Why didn't cmake's tests find this?

plaurentiu: This here is the chromium bug tracker. Please file cmake issues in cmake's bug tracker.
I run following command to keep build.ninja in build/CMakeFiles/CMakeTmp.
$ ~/cmake-2.8.12.2-Linux-i386/bin/cmake --debug-trycompile -G "Ninja" -DCMAKE_BUILD_TYPE=Release  ..

And I confirmed ninja 1.8.0 without https://github.com/ninja-build/ninja/pull/1111 runs correctly.

cmake.tar.gz
13.8 KB Download
CMake versions 2.8.12.x and 3.0.x incorrectly produce `build testCCompiler.c: phony testCCompiler.c` in `build.ninja`.  Ninja didn't previously detect this cycle.  We'll have to teach Ninja to tolerate it again.  I'll post more over in ninja PR 1111.

For reference, this was a bug in CMake introduced by commit `v2.8.12~248^2` (Ninja: Custom Command file depends don't need to exist before building, 2013-06-07) and fixed by commit `v3.1.0-rc1~353^2~2` (Ninja: Consider only custom commands deps as side-effects, 2014-06-27).  See

  https://gitlab.kitware.com/cmake/cmake/issues/14972

I've opened https://github.com/ninja-build/ninja/issues/1322 to discuss solutions.

Comment 8 by thakis@chromium.org, Sep 11 2017

tikuta, I pushed the v1.8.3 tag with Brad's fix. Can you build and push binaries for that too, please?

Comment 9 by tikuta@chromium.org, Sep 11 2017

OK.
nit: Do you mean 1.8.2?

Yes, sorry

Project Member

Comment 11 by bugdroid1@chromium.org, Sep 11 2017

The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/tools/depot_tools/+/aa57b3462009be07ccd9d2bbc8457148ce3b4992

commit aa57b3462009be07ccd9d2bbc8457148ce3b4992
Author: Takuto Ikuta <tikuta@google.com>
Date: Mon Sep 11 03:46:59 2017

Update ninja to v1.8.2

New binaries for Mac, Linux32, Linux64, Windows.  Also update shell script.
See the bug for how these were built.
The main "new" thing is fix for old cmake.

Bug:  762354 ,  762407 
Change-Id: I4f825e357796e1cb52d2efa041bde46d68cbe152
Reviewed-on: https://chromium-review.googlesource.com/659477
Reviewed-by: Nico Weber <thakis@chromium.org>
Commit-Queue: Takuto Ikuta <tikuta@google.com>

[modify] https://crrev.com/aa57b3462009be07ccd9d2bbc8457148ce3b4992/ninja
[modify] https://crrev.com/aa57b3462009be07ccd9d2bbc8457148ce3b4992/ninja-mac
[modify] https://crrev.com/aa57b3462009be07ccd9d2bbc8457148ce3b4992/ninja.exe
[modify] https://crrev.com/aa57b3462009be07ccd9d2bbc8457148ce3b4992/ninja-linux64
[modify] https://crrev.com/aa57b3462009be07ccd9d2bbc8457148ce3b4992/ninja-linux32

Status: Fixed (was: Assigned)
 plaurentiu: please verify that this is now better.
Thanks for the quick reaction.
After the update to Ninja 1.8.2 everything works for me, both in the simple project shown above and in the more complicated projects that we use internally.

Sign in to add a comment